babylon.d.ts 2.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /** Defines the cross module used constants to avoid circular dependncies */
  583. export class Constants {
  584. /** Defines that alpha blending is disabled */
  585. static readonly ALPHA_DISABLE: number;
  586. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  587. static readonly ALPHA_ADD: number;
  588. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  589. static readonly ALPHA_COMBINE: number;
  590. /** Defines that alpha blending is DEST - SRC * DEST */
  591. static readonly ALPHA_SUBTRACT: number;
  592. /** Defines that alpha blending is SRC * DEST */
  593. static readonly ALPHA_MULTIPLY: number;
  594. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  595. static readonly ALPHA_MAXIMIZED: number;
  596. /** Defines that alpha blending is SRC + DEST */
  597. static readonly ALPHA_ONEONE: number;
  598. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  599. static readonly ALPHA_PREMULTIPLIED: number;
  600. /**
  601. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  602. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  603. */
  604. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  605. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  606. static readonly ALPHA_INTERPOLATE: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  609. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_SCREENMODE: number;
  612. /**
  613. * Defines that alpha blending is SRC + DST
  614. * Alpha will be set to SRC ALPHA + DST ALPHA
  615. */
  616. static readonly ALPHA_ONEONE_ONEONE: number;
  617. /**
  618. * Defines that alpha blending is SRC * DST ALPHA + DST
  619. * Alpha will be set to 0
  620. */
  621. static readonly ALPHA_ALPHATOCOLOR: number;
  622. /**
  623. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  624. */
  625. static readonly ALPHA_REVERSEONEMINUS: number;
  626. /**
  627. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  628. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  629. */
  630. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  631. /**
  632. * Defines that alpha blending is SRC + DST
  633. * Alpha will be set to SRC ALPHA
  634. */
  635. static readonly ALPHA_ONEONE_ONEZERO: number;
  636. /**
  637. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  638. * Alpha will be set to DST ALPHA
  639. */
  640. static readonly ALPHA_EXCLUSION: number;
  641. /** Defines that alpha blending equation a SUM */
  642. static readonly ALPHA_EQUATION_ADD: number;
  643. /** Defines that alpha blending equation a SUBSTRACTION */
  644. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  645. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  646. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  647. /** Defines that alpha blending equation a MAX operation */
  648. static readonly ALPHA_EQUATION_MAX: number;
  649. /** Defines that alpha blending equation a MIN operation */
  650. static readonly ALPHA_EQUATION_MIN: number;
  651. /**
  652. * Defines that alpha blending equation a DARKEN operation:
  653. * It takes the min of the src and sums the alpha channels.
  654. */
  655. static readonly ALPHA_EQUATION_DARKEN: number;
  656. /** Defines that the ressource is not delayed*/
  657. static readonly DELAYLOADSTATE_NONE: number;
  658. /** Defines that the ressource was successfully delay loaded */
  659. static readonly DELAYLOADSTATE_LOADED: number;
  660. /** Defines that the ressource is currently delay loading */
  661. static readonly DELAYLOADSTATE_LOADING: number;
  662. /** Defines that the ressource is delayed and has not started loading */
  663. static readonly DELAYLOADSTATE_NOTLOADED: number;
  664. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  665. static readonly NEVER: number;
  666. /** 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 */
  667. static readonly ALWAYS: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  669. static readonly LESS: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  671. static readonly EQUAL: number;
  672. /** 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 */
  673. static readonly LEQUAL: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  675. static readonly GREATER: number;
  676. /** 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 */
  677. static readonly GEQUAL: number;
  678. /** 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 */
  679. static readonly NOTEQUAL: number;
  680. /** Passed to stencilOperation to specify that stencil value must be kept */
  681. static readonly KEEP: number;
  682. /** Passed to stencilOperation to specify that stencil value must be replaced */
  683. static readonly REPLACE: number;
  684. /** Passed to stencilOperation to specify that stencil value must be incremented */
  685. static readonly INCR: number;
  686. /** Passed to stencilOperation to specify that stencil value must be decremented */
  687. static readonly DECR: number;
  688. /** Passed to stencilOperation to specify that stencil value must be inverted */
  689. static readonly INVERT: number;
  690. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  691. static readonly INCR_WRAP: number;
  692. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  693. static readonly DECR_WRAP: number;
  694. /** Texture is not repeating outside of 0..1 UVs */
  695. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  696. /** Texture is repeating outside of 0..1 UVs */
  697. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  698. /** Texture is repeating and mirrored */
  699. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  700. /** ALPHA */
  701. static readonly TEXTUREFORMAT_ALPHA: number;
  702. /** LUMINANCE */
  703. static readonly TEXTUREFORMAT_LUMINANCE: number;
  704. /** LUMINANCE_ALPHA */
  705. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  706. /** RGB */
  707. static readonly TEXTUREFORMAT_RGB: number;
  708. /** RGBA */
  709. static readonly TEXTUREFORMAT_RGBA: number;
  710. /** RED */
  711. static readonly TEXTUREFORMAT_RED: number;
  712. /** RED (2nd reference) */
  713. static readonly TEXTUREFORMAT_R: number;
  714. /** RG */
  715. static readonly TEXTUREFORMAT_RG: number;
  716. /** RED_INTEGER */
  717. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  718. /** RED_INTEGER (2nd reference) */
  719. static readonly TEXTUREFORMAT_R_INTEGER: number;
  720. /** RG_INTEGER */
  721. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  722. /** RGB_INTEGER */
  723. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  724. /** RGBA_INTEGER */
  725. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  726. /** UNSIGNED_BYTE */
  727. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  728. /** UNSIGNED_BYTE (2nd reference) */
  729. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  730. /** FLOAT */
  731. static readonly TEXTURETYPE_FLOAT: number;
  732. /** HALF_FLOAT */
  733. static readonly TEXTURETYPE_HALF_FLOAT: number;
  734. /** BYTE */
  735. static readonly TEXTURETYPE_BYTE: number;
  736. /** SHORT */
  737. static readonly TEXTURETYPE_SHORT: number;
  738. /** UNSIGNED_SHORT */
  739. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  740. /** INT */
  741. static readonly TEXTURETYPE_INT: number;
  742. /** UNSIGNED_INT */
  743. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  744. /** UNSIGNED_SHORT_4_4_4_4 */
  745. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  746. /** UNSIGNED_SHORT_5_5_5_1 */
  747. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  748. /** UNSIGNED_SHORT_5_6_5 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  750. /** UNSIGNED_INT_2_10_10_10_REV */
  751. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  752. /** UNSIGNED_INT_24_8 */
  753. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  754. /** UNSIGNED_INT_10F_11F_11F_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  756. /** UNSIGNED_INT_5_9_9_9_REV */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  758. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  759. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  760. /** nearest is mag = nearest and min = nearest and no mip */
  761. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  762. /** mag = nearest and min = nearest and mip = none */
  763. static readonly TEXTURE_NEAREST_NEAREST: number;
  764. /** Bilinear is mag = linear and min = linear and no mip */
  765. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  766. /** mag = linear and min = linear and mip = none */
  767. static readonly TEXTURE_LINEAR_LINEAR: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** Trilinear is mag = linear and min = linear and mip = linear */
  771. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  772. /** mag = nearest and min = nearest and mip = nearest */
  773. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  774. /** mag = nearest and min = linear and mip = nearest */
  775. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  776. /** mag = nearest and min = linear and mip = linear */
  777. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  778. /** mag = nearest and min = linear and mip = none */
  779. static readonly TEXTURE_NEAREST_LINEAR: number;
  780. /** nearest is mag = nearest and min = nearest and mip = linear */
  781. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  782. /** mag = linear and min = nearest and mip = nearest */
  783. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  784. /** mag = linear and min = nearest and mip = linear */
  785. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = none */
  789. static readonly TEXTURE_LINEAR_NEAREST: number;
  790. /** Explicit coordinates mode */
  791. static readonly TEXTURE_EXPLICIT_MODE: number;
  792. /** Spherical coordinates mode */
  793. static readonly TEXTURE_SPHERICAL_MODE: number;
  794. /** Planar coordinates mode */
  795. static readonly TEXTURE_PLANAR_MODE: number;
  796. /** Cubic coordinates mode */
  797. static readonly TEXTURE_CUBIC_MODE: number;
  798. /** Projection coordinates mode */
  799. static readonly TEXTURE_PROJECTION_MODE: number;
  800. /** Skybox coordinates mode */
  801. static readonly TEXTURE_SKYBOX_MODE: number;
  802. /** Inverse Cubic coordinates mode */
  803. static readonly TEXTURE_INVCUBIC_MODE: number;
  804. /** Equirectangular coordinates mode */
  805. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  806. /** Equirectangular Fixed coordinates mode */
  807. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  808. /** Equirectangular Fixed Mirrored coordinates mode */
  809. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  810. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  811. static readonly SCALEMODE_FLOOR: number;
  812. /** Defines that texture rescaling will look for the nearest power of 2 size */
  813. static readonly SCALEMODE_NEAREST: number;
  814. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  815. static readonly SCALEMODE_CEILING: number;
  816. /**
  817. * The dirty texture flag value
  818. */
  819. static readonly MATERIAL_TextureDirtyFlag: number;
  820. /**
  821. * The dirty light flag value
  822. */
  823. static readonly MATERIAL_LightDirtyFlag: number;
  824. /**
  825. * The dirty fresnel flag value
  826. */
  827. static readonly MATERIAL_FresnelDirtyFlag: number;
  828. /**
  829. * The dirty attribute flag value
  830. */
  831. static readonly MATERIAL_AttributesDirtyFlag: number;
  832. /**
  833. * The dirty misc flag value
  834. */
  835. static readonly MATERIAL_MiscDirtyFlag: number;
  836. /**
  837. * The all dirty flag value
  838. */
  839. static readonly MATERIAL_AllDirtyFlag: number;
  840. /**
  841. * Returns the triangle fill mode
  842. */
  843. static readonly MATERIAL_TriangleFillMode: number;
  844. /**
  845. * Returns the wireframe mode
  846. */
  847. static readonly MATERIAL_WireFrameFillMode: number;
  848. /**
  849. * Returns the point fill mode
  850. */
  851. static readonly MATERIAL_PointFillMode: number;
  852. /**
  853. * Returns the point list draw mode
  854. */
  855. static readonly MATERIAL_PointListDrawMode: number;
  856. /**
  857. * Returns the line list draw mode
  858. */
  859. static readonly MATERIAL_LineListDrawMode: number;
  860. /**
  861. * Returns the line loop draw mode
  862. */
  863. static readonly MATERIAL_LineLoopDrawMode: number;
  864. /**
  865. * Returns the line strip draw mode
  866. */
  867. static readonly MATERIAL_LineStripDrawMode: number;
  868. /**
  869. * Returns the triangle strip draw mode
  870. */
  871. static readonly MATERIAL_TriangleStripDrawMode: number;
  872. /**
  873. * Returns the triangle fan draw mode
  874. */
  875. static readonly MATERIAL_TriangleFanDrawMode: number;
  876. /**
  877. * Stores the clock-wise side orientation
  878. */
  879. static readonly MATERIAL_ClockWiseSideOrientation: number;
  880. /**
  881. * Stores the counter clock-wise side orientation
  882. */
  883. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  884. /**
  885. * Nothing
  886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  887. */
  888. static readonly ACTION_NothingTrigger: number;
  889. /**
  890. * On pick
  891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  892. */
  893. static readonly ACTION_OnPickTrigger: number;
  894. /**
  895. * On left pick
  896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  897. */
  898. static readonly ACTION_OnLeftPickTrigger: number;
  899. /**
  900. * On right pick
  901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  902. */
  903. static readonly ACTION_OnRightPickTrigger: number;
  904. /**
  905. * On center pick
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_OnCenterPickTrigger: number;
  909. /**
  910. * On pick down
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickDownTrigger: number;
  914. /**
  915. * On double pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnDoublePickTrigger: number;
  919. /**
  920. * On pick up
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickUpTrigger: number;
  924. /**
  925. * On pick out.
  926. * This trigger will only be raised if you also declared a OnPickDown
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickOutTrigger: number;
  930. /**
  931. * On long press
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnLongPressTrigger: number;
  935. /**
  936. * On pointer over
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPointerOverTrigger: number;
  940. /**
  941. * On pointer out
  942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  943. */
  944. static readonly ACTION_OnPointerOutTrigger: number;
  945. /**
  946. * On every frame
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnEveryFrameTrigger: number;
  950. /**
  951. * On intersection enter
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnIntersectionEnterTrigger: number;
  955. /**
  956. * On intersection exit
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnIntersectionExitTrigger: number;
  960. /**
  961. * On key down
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnKeyDownTrigger: number;
  965. /**
  966. * On key up
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnKeyUpTrigger: number;
  970. /**
  971. * Billboard mode will only apply to Y axis
  972. */
  973. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  974. /**
  975. * Billboard mode will apply to all axes
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  978. /**
  979. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  982. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  983. * Test order :
  984. * Is the bounding sphere outside the frustum ?
  985. * If not, are the bounding box vertices outside the frustum ?
  986. * It not, then the cullable object is in the frustum.
  987. */
  988. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  989. /** Culling strategy : Bounding Sphere Only.
  990. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  991. * It's also less accurate than the standard because some not visible objects can still be selected.
  992. * Test : is the bounding sphere outside the frustum ?
  993. * If not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  996. /** Culling strategy : Optimistic Inclusion.
  997. * This in an inclusion test first, then the standard exclusion test.
  998. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  999. * 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.
  1000. * Anyway, it's as accurate as the standard strategy.
  1001. * Test :
  1002. * Is the cullable object bounding sphere center in the frustum ?
  1003. * If not, apply the default culling strategy.
  1004. */
  1005. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1006. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1007. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1008. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1009. * 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.
  1010. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1011. * Test :
  1012. * Is the cullable object bounding sphere center in the frustum ?
  1013. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1016. /**
  1017. * No logging while loading
  1018. */
  1019. static readonly SCENELOADER_NO_LOGGING: number;
  1020. /**
  1021. * Minimal logging while loading
  1022. */
  1023. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1024. /**
  1025. * Summary logging while loading
  1026. */
  1027. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1028. /**
  1029. * Detailled logging while loading
  1030. */
  1031. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * This represents the required contract to create a new type of texture loader.
  1037. */
  1038. export interface IInternalTextureLoader {
  1039. /**
  1040. * Defines wether the loader supports cascade loading the different faces.
  1041. */
  1042. supportCascades: boolean;
  1043. /**
  1044. * This returns if the loader support the current file information.
  1045. * @param extension defines the file extension of the file being loaded
  1046. * @returns true if the loader can load the specified file
  1047. */
  1048. canLoad(extension: string): boolean;
  1049. /**
  1050. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1051. * @param data contains the texture data
  1052. * @param texture defines the BabylonJS internal texture
  1053. * @param createPolynomials will be true if polynomials have been requested
  1054. * @param onLoad defines the callback to trigger once the texture is ready
  1055. * @param onError defines the callback to trigger in case of error
  1056. */
  1057. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1058. /**
  1059. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1060. * @param data contains the texture data
  1061. * @param texture defines the BabylonJS internal texture
  1062. * @param callback defines the method to call once ready to upload
  1063. */
  1064. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1065. }
  1066. }
  1067. declare module BABYLON {
  1068. /**
  1069. * Class used to store and describe the pipeline context associated with an effect
  1070. */
  1071. export interface IPipelineContext {
  1072. /**
  1073. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1074. */
  1075. isAsync: boolean;
  1076. /**
  1077. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1078. */
  1079. isReady: boolean;
  1080. /** @hidden */
  1081. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1082. }
  1083. }
  1084. declare module BABYLON {
  1085. /**
  1086. * Class used to store gfx data (like WebGLBuffer)
  1087. */
  1088. export class DataBuffer {
  1089. /**
  1090. * Gets or sets the number of objects referencing this buffer
  1091. */
  1092. references: number;
  1093. /** Gets or sets the size of the underlying buffer */
  1094. capacity: number;
  1095. /**
  1096. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1097. */
  1098. is32Bits: boolean;
  1099. /**
  1100. * Gets the underlying buffer
  1101. */
  1102. get underlyingResource(): any;
  1103. }
  1104. }
  1105. declare module BABYLON {
  1106. /** @hidden */
  1107. export interface IShaderProcessor {
  1108. attributeProcessor?: (attribute: string) => string;
  1109. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1110. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1111. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1112. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1113. lineProcessor?: (line: string, isFragment: boolean) => string;
  1114. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1115. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1116. }
  1117. }
  1118. declare module BABYLON {
  1119. /** @hidden */
  1120. export interface ProcessingOptions {
  1121. defines: string[];
  1122. indexParameters: any;
  1123. isFragment: boolean;
  1124. shouldUseHighPrecisionShader: boolean;
  1125. supportsUniformBuffers: boolean;
  1126. shadersRepository: string;
  1127. includesShadersStore: {
  1128. [key: string]: string;
  1129. };
  1130. processor?: IShaderProcessor;
  1131. version: string;
  1132. platformName: string;
  1133. lookForClosingBracketForUniformBuffer?: boolean;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export class ShaderCodeNode {
  1139. line: string;
  1140. children: ShaderCodeNode[];
  1141. additionalDefineKey?: string;
  1142. additionalDefineValue?: string;
  1143. isValid(preprocessors: {
  1144. [key: string]: string;
  1145. }): boolean;
  1146. process(preprocessors: {
  1147. [key: string]: string;
  1148. }, options: ProcessingOptions): string;
  1149. }
  1150. }
  1151. declare module BABYLON {
  1152. /** @hidden */
  1153. export class ShaderCodeCursor {
  1154. private _lines;
  1155. lineIndex: number;
  1156. get currentLine(): string;
  1157. get canRead(): boolean;
  1158. set lines(value: string[]);
  1159. }
  1160. }
  1161. declare module BABYLON {
  1162. /** @hidden */
  1163. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1164. process(preprocessors: {
  1165. [key: string]: string;
  1166. }, options: ProcessingOptions): string;
  1167. }
  1168. }
  1169. declare module BABYLON {
  1170. /** @hidden */
  1171. export class ShaderDefineExpression {
  1172. isTrue(preprocessors: {
  1173. [key: string]: string;
  1174. }): boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeTestNode extends ShaderCodeNode {
  1180. testExpression: ShaderDefineExpression;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. }
  1185. }
  1186. declare module BABYLON {
  1187. /** @hidden */
  1188. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1189. define: string;
  1190. not: boolean;
  1191. constructor(define: string, not?: boolean);
  1192. isTrue(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1200. leftOperand: ShaderDefineExpression;
  1201. rightOperand: ShaderDefineExpression;
  1202. isTrue(preprocessors: {
  1203. [key: string]: string;
  1204. }): boolean;
  1205. }
  1206. }
  1207. declare module BABYLON {
  1208. /** @hidden */
  1209. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1210. leftOperand: ShaderDefineExpression;
  1211. rightOperand: ShaderDefineExpression;
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1220. define: string;
  1221. operand: string;
  1222. testValue: string;
  1223. constructor(define: string, operand: string, testValue: string);
  1224. isTrue(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /**
  1231. * Class used to enable access to offline support
  1232. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1233. */
  1234. export interface IOfflineProvider {
  1235. /**
  1236. * Gets a boolean indicating if scene must be saved in the database
  1237. */
  1238. enableSceneOffline: boolean;
  1239. /**
  1240. * Gets a boolean indicating if textures must be saved in the database
  1241. */
  1242. enableTexturesOffline: boolean;
  1243. /**
  1244. * Open the offline support and make it available
  1245. * @param successCallback defines the callback to call on success
  1246. * @param errorCallback defines the callback to call on error
  1247. */
  1248. open(successCallback: () => void, errorCallback: () => void): void;
  1249. /**
  1250. * Loads an image from the offline support
  1251. * @param url defines the url to load from
  1252. * @param image defines the target DOM image
  1253. */
  1254. loadImage(url: string, image: HTMLImageElement): void;
  1255. /**
  1256. * Loads a file from offline support
  1257. * @param url defines the URL to load from
  1258. * @param sceneLoaded defines a callback to call on success
  1259. * @param progressCallBack defines a callback to call when progress changed
  1260. * @param errorCallback defines a callback to call on error
  1261. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1262. */
  1263. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1264. }
  1265. }
  1266. declare module BABYLON {
  1267. /**
  1268. * Class used to help managing file picking and drag'n'drop
  1269. * File Storage
  1270. */
  1271. export class FilesInputStore {
  1272. /**
  1273. * List of files ready to be loaded
  1274. */
  1275. static FilesToLoad: {
  1276. [key: string]: File;
  1277. };
  1278. }
  1279. }
  1280. declare module BABYLON {
  1281. /**
  1282. * Class used to define a retry strategy when error happens while loading assets
  1283. */
  1284. export class RetryStrategy {
  1285. /**
  1286. * Function used to defines an exponential back off strategy
  1287. * @param maxRetries defines the maximum number of retries (3 by default)
  1288. * @param baseInterval defines the interval between retries
  1289. * @returns the strategy function to use
  1290. */
  1291. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * @ignore
  1297. * Application error to support additional information when loading a file
  1298. */
  1299. export abstract class BaseError extends Error {
  1300. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1301. }
  1302. }
  1303. declare module BABYLON {
  1304. /** @ignore */
  1305. export class LoadFileError extends BaseError {
  1306. request?: WebRequest;
  1307. file?: File;
  1308. /**
  1309. * Creates a new LoadFileError
  1310. * @param message defines the message of the error
  1311. * @param request defines the optional web request
  1312. * @param file defines the optional file
  1313. */
  1314. constructor(message: string, object?: WebRequest | File);
  1315. }
  1316. /** @ignore */
  1317. export class RequestFileError extends BaseError {
  1318. request: WebRequest;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. */
  1324. constructor(message: string, request: WebRequest);
  1325. }
  1326. /** @ignore */
  1327. export class ReadFileError extends BaseError {
  1328. file: File;
  1329. /**
  1330. * Creates a new ReadFileError
  1331. * @param message defines the message of the error
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, file: File);
  1335. }
  1336. /**
  1337. * @hidden
  1338. */
  1339. export class FileTools {
  1340. /**
  1341. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1342. */
  1343. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1344. /**
  1345. * Gets or sets the base URL to use to load assets
  1346. */
  1347. static BaseUrl: string;
  1348. /**
  1349. * Default behaviour for cors in the application.
  1350. * It can be a string if the expected behavior is identical in the entire app.
  1351. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1352. */
  1353. static CorsBehavior: string | ((url: string | string[]) => string);
  1354. /**
  1355. * Gets or sets a function used to pre-process url before using them to load assets
  1356. */
  1357. static PreprocessUrl: (url: string) => string;
  1358. /**
  1359. * Removes unwanted characters from an url
  1360. * @param url defines the url to clean
  1361. * @returns the cleaned url
  1362. */
  1363. private static _CleanUrl;
  1364. /**
  1365. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1366. * @param url define the url we are trying
  1367. * @param element define the dom element where to configure the cors policy
  1368. */
  1369. static SetCorsBehavior(url: string | string[], element: {
  1370. crossOrigin: string | null;
  1371. }): void;
  1372. /**
  1373. * Loads an image as an HTMLImageElement.
  1374. * @param input url string, ArrayBuffer, or Blob to load
  1375. * @param onLoad callback called when the image successfully loads
  1376. * @param onError callback called when the image fails to load
  1377. * @param offlineProvider offline provider for caching
  1378. * @param mimeType optional mime type
  1379. * @returns the HTMLImageElement of the loaded image
  1380. */
  1381. 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>;
  1382. /**
  1383. * Reads a file from a File object
  1384. * @param file defines the file to load
  1385. * @param onSuccess defines the callback to call when data is loaded
  1386. * @param onProgress defines the callback to call during loading process
  1387. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1388. * @param onError defines the callback to call when an error occurs
  1389. * @returns a file request object
  1390. */
  1391. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1392. /**
  1393. * Loads a file from a url
  1394. * @param url url to load
  1395. * @param onSuccess callback called when the file successfully loads
  1396. * @param onProgress callback called while file is loading (if the server supports this mode)
  1397. * @param offlineProvider defines the offline provider for caching
  1398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1399. * @param onError callback called when the file fails to load
  1400. * @returns a file request object
  1401. */
  1402. 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;
  1403. /**
  1404. * Loads a file
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1409. * @param onError callback called when the file fails to load
  1410. * @param onOpened callback called when the web request is opened
  1411. * @returns a file request object
  1412. */
  1413. 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;
  1414. /**
  1415. * Checks if the loaded document was accessed via `file:`-Protocol.
  1416. * @returns boolean
  1417. */
  1418. static IsFileURL(): boolean;
  1419. }
  1420. }
  1421. declare module BABYLON {
  1422. /** @hidden */
  1423. export class ShaderProcessor {
  1424. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1425. private static _ProcessPrecision;
  1426. private static _ExtractOperation;
  1427. private static _BuildSubExpression;
  1428. private static _BuildExpression;
  1429. private static _MoveCursorWithinIf;
  1430. private static _MoveCursor;
  1431. private static _EvaluatePreProcessors;
  1432. private static _PreparePreProcessors;
  1433. private static _ProcessShaderConversion;
  1434. private static _ProcessIncludes;
  1435. /**
  1436. * Loads a file from a url
  1437. * @param url url to load
  1438. * @param onSuccess callback called when the file successfully loads
  1439. * @param onProgress callback called while file is loading (if the server supports this mode)
  1440. * @param offlineProvider defines the offline provider for caching
  1441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1442. * @param onError callback called when the file fails to load
  1443. * @returns a file request object
  1444. * @hidden
  1445. */
  1446. 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;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /**
  1451. * @hidden
  1452. */
  1453. export interface IColor4Like {
  1454. r: float;
  1455. g: float;
  1456. b: float;
  1457. a: float;
  1458. }
  1459. /**
  1460. * @hidden
  1461. */
  1462. export interface IColor3Like {
  1463. r: float;
  1464. g: float;
  1465. b: float;
  1466. }
  1467. /**
  1468. * @hidden
  1469. */
  1470. export interface IVector4Like {
  1471. x: float;
  1472. y: float;
  1473. z: float;
  1474. w: float;
  1475. }
  1476. /**
  1477. * @hidden
  1478. */
  1479. export interface IVector3Like {
  1480. x: float;
  1481. y: float;
  1482. z: float;
  1483. }
  1484. /**
  1485. * @hidden
  1486. */
  1487. export interface IVector2Like {
  1488. x: float;
  1489. y: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IMatrixLike {
  1495. toArray(): DeepImmutable<Float32Array>;
  1496. updateFlag: int;
  1497. }
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IViewportLike {
  1502. x: float;
  1503. y: float;
  1504. width: float;
  1505. height: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IPlaneLike {
  1511. normal: IVector3Like;
  1512. d: float;
  1513. normalize(): void;
  1514. }
  1515. }
  1516. declare module BABYLON {
  1517. /**
  1518. * Interface used to define common properties for effect fallbacks
  1519. */
  1520. export interface IEffectFallbacks {
  1521. /**
  1522. * Removes the defines that should be removed when falling back.
  1523. * @param currentDefines defines the current define statements for the shader.
  1524. * @param effect defines the current effect we try to compile
  1525. * @returns The resulting defines with defines of the current rank removed.
  1526. */
  1527. reduce(currentDefines: string, effect: Effect): string;
  1528. /**
  1529. * Removes the fallback from the bound mesh.
  1530. */
  1531. unBindMesh(): void;
  1532. /**
  1533. * Checks to see if more fallbacks are still availible.
  1534. */
  1535. hasMoreFallbacks: boolean;
  1536. }
  1537. }
  1538. declare module BABYLON {
  1539. /**
  1540. * Class used to evalaute queries containing `and` and `or` operators
  1541. */
  1542. export class AndOrNotEvaluator {
  1543. /**
  1544. * Evaluate a query
  1545. * @param query defines the query to evaluate
  1546. * @param evaluateCallback defines the callback used to filter result
  1547. * @returns true if the query matches
  1548. */
  1549. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1550. private static _HandleParenthesisContent;
  1551. private static _SimplifyNegation;
  1552. }
  1553. }
  1554. declare module BABYLON {
  1555. /**
  1556. * Class used to store custom tags
  1557. */
  1558. export class Tags {
  1559. /**
  1560. * Adds support for tags on the given object
  1561. * @param obj defines the object to use
  1562. */
  1563. static EnableFor(obj: any): void;
  1564. /**
  1565. * Removes tags support
  1566. * @param obj defines the object to use
  1567. */
  1568. static DisableFor(obj: any): void;
  1569. /**
  1570. * Gets a boolean indicating if the given object has tags
  1571. * @param obj defines the object to use
  1572. * @returns a boolean
  1573. */
  1574. static HasTags(obj: any): boolean;
  1575. /**
  1576. * Gets the tags available on a given object
  1577. * @param obj defines the object to use
  1578. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1579. * @returns the tags
  1580. */
  1581. static GetTags(obj: any, asString?: boolean): any;
  1582. /**
  1583. * Adds tags to an object
  1584. * @param obj defines the object to use
  1585. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1586. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1587. */
  1588. static AddTagsTo(obj: any, tagsString: string): void;
  1589. /**
  1590. * @hidden
  1591. */
  1592. static _AddTagTo(obj: any, tag: string): void;
  1593. /**
  1594. * Removes specific tags from a specific object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tags to remove
  1597. */
  1598. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1599. /**
  1600. * @hidden
  1601. */
  1602. static _RemoveTagFrom(obj: any, tag: string): void;
  1603. /**
  1604. * Defines if tags hosted on an object match a given query
  1605. * @param obj defines the object to use
  1606. * @param tagsQuery defines the tag query
  1607. * @returns a boolean
  1608. */
  1609. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /**
  1614. * Scalar computation library
  1615. */
  1616. export class Scalar {
  1617. /**
  1618. * Two pi constants convenient for computation.
  1619. */
  1620. static TwoPi: number;
  1621. /**
  1622. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1623. * @param a number
  1624. * @param b number
  1625. * @param epsilon (default = 1.401298E-45)
  1626. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1627. */
  1628. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1629. /**
  1630. * Returns a string : the upper case translation of the number i to hexadecimal.
  1631. * @param i number
  1632. * @returns the upper case translation of the number i to hexadecimal.
  1633. */
  1634. static ToHex(i: number): string;
  1635. /**
  1636. * Returns -1 if value is negative and +1 is value is positive.
  1637. * @param value the value
  1638. * @returns the value itself if it's equal to zero.
  1639. */
  1640. static Sign(value: number): number;
  1641. /**
  1642. * Returns the value itself if it's between min and max.
  1643. * Returns min if the value is lower than min.
  1644. * Returns max if the value is greater than max.
  1645. * @param value the value to clmap
  1646. * @param min the min value to clamp to (default: 0)
  1647. * @param max the max value to clamp to (default: 1)
  1648. * @returns the clamped value
  1649. */
  1650. static Clamp(value: number, min?: number, max?: number): number;
  1651. /**
  1652. * the log2 of value.
  1653. * @param value the value to compute log2 of
  1654. * @returns the log2 of value.
  1655. */
  1656. static Log2(value: number): number;
  1657. /**
  1658. * Loops the value, so that it is never larger than length and never smaller than 0.
  1659. *
  1660. * This is similar to the modulo operator but it works with floating point numbers.
  1661. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1662. * With t = 5 and length = 2.5, the result would be 0.0.
  1663. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1664. * @param value the value
  1665. * @param length the length
  1666. * @returns the looped value
  1667. */
  1668. static Repeat(value: number, length: number): number;
  1669. /**
  1670. * Normalize the value between 0.0 and 1.0 using min and max values
  1671. * @param value value to normalize
  1672. * @param min max to normalize between
  1673. * @param max min to normalize between
  1674. * @returns the normalized value
  1675. */
  1676. static Normalize(value: number, min: number, max: number): number;
  1677. /**
  1678. * Denormalize the value from 0.0 and 1.0 using min and max values
  1679. * @param normalized value to denormalize
  1680. * @param min max to denormalize between
  1681. * @param max min to denormalize between
  1682. * @returns the denormalized value
  1683. */
  1684. static Denormalize(normalized: number, min: number, max: number): number;
  1685. /**
  1686. * Calculates the shortest difference between two given angles given in degrees.
  1687. * @param current current angle in degrees
  1688. * @param target target angle in degrees
  1689. * @returns the delta
  1690. */
  1691. static DeltaAngle(current: number, target: number): number;
  1692. /**
  1693. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1694. * @param tx value
  1695. * @param length length
  1696. * @returns The returned value will move back and forth between 0 and length
  1697. */
  1698. static PingPong(tx: number, length: number): number;
  1699. /**
  1700. * Interpolates between min and max with smoothing at the limits.
  1701. *
  1702. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1703. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1704. * @param from from
  1705. * @param to to
  1706. * @param tx value
  1707. * @returns the smooth stepped value
  1708. */
  1709. static SmoothStep(from: number, to: number, tx: number): number;
  1710. /**
  1711. * Moves a value current towards target.
  1712. *
  1713. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1714. * Negative values of maxDelta pushes the value away from target.
  1715. * @param current current value
  1716. * @param target target value
  1717. * @param maxDelta max distance to move
  1718. * @returns resulting value
  1719. */
  1720. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1721. /**
  1722. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1723. *
  1724. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1725. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting angle
  1730. */
  1731. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1734. * @param start start value
  1735. * @param end target value
  1736. * @param amount amount to lerp between
  1737. * @returns the lerped value
  1738. */
  1739. static Lerp(start: number, end: number, amount: number): number;
  1740. /**
  1741. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1742. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1743. * @param start start value
  1744. * @param end target value
  1745. * @param amount amount to lerp between
  1746. * @returns the lerped value
  1747. */
  1748. static LerpAngle(start: number, end: number, amount: number): number;
  1749. /**
  1750. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1751. * @param a start value
  1752. * @param b target value
  1753. * @param value value between a and b
  1754. * @returns the inverseLerp value
  1755. */
  1756. static InverseLerp(a: number, b: number, value: number): number;
  1757. /**
  1758. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1759. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1760. * @param value1 spline value
  1761. * @param tangent1 spline value
  1762. * @param value2 spline value
  1763. * @param tangent2 spline value
  1764. * @param amount input value
  1765. * @returns hermite result
  1766. */
  1767. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1768. /**
  1769. * Returns a random float number between and min and max values
  1770. * @param min min value of random
  1771. * @param max max value of random
  1772. * @returns random value
  1773. */
  1774. static RandomRange(min: number, max: number): number;
  1775. /**
  1776. * This function returns percentage of a number in a given range.
  1777. *
  1778. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1779. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1780. * @param number to convert to percentage
  1781. * @param min min range
  1782. * @param max max range
  1783. * @returns the percentage
  1784. */
  1785. static RangeToPercent(number: number, min: number, max: number): number;
  1786. /**
  1787. * This function returns number that corresponds to the percentage in a given range.
  1788. *
  1789. * PercentToRange(0.34,0,100) will return 34.
  1790. * @param percent to convert to number
  1791. * @param min min range
  1792. * @param max max range
  1793. * @returns the number
  1794. */
  1795. static PercentToRange(percent: number, min: number, max: number): number;
  1796. /**
  1797. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1798. * @param angle The angle to normalize in radian.
  1799. * @return The converted angle.
  1800. */
  1801. static NormalizeRadians(angle: number): number;
  1802. }
  1803. }
  1804. declare module BABYLON {
  1805. /**
  1806. * Constant used to convert a value to gamma space
  1807. * @ignorenaming
  1808. */
  1809. export const ToGammaSpace: number;
  1810. /**
  1811. * Constant used to convert a value to linear space
  1812. * @ignorenaming
  1813. */
  1814. export const ToLinearSpace = 2.2;
  1815. /**
  1816. * Constant used to define the minimal number value in Babylon.js
  1817. * @ignorenaming
  1818. */
  1819. let Epsilon: number;
  1820. }
  1821. declare module BABYLON {
  1822. /**
  1823. * Class used to represent a viewport on screen
  1824. */
  1825. export class Viewport {
  1826. /** viewport left coordinate */
  1827. x: number;
  1828. /** viewport top coordinate */
  1829. y: number;
  1830. /**viewport width */
  1831. width: number;
  1832. /** viewport height */
  1833. height: number;
  1834. /**
  1835. * Creates a Viewport object located at (x, y) and sized (width, height)
  1836. * @param x defines viewport left coordinate
  1837. * @param y defines viewport top coordinate
  1838. * @param width defines the viewport width
  1839. * @param height defines the viewport height
  1840. */
  1841. constructor(
  1842. /** viewport left coordinate */
  1843. x: number,
  1844. /** viewport top coordinate */
  1845. y: number,
  1846. /**viewport width */
  1847. width: number,
  1848. /** viewport height */
  1849. height: number);
  1850. /**
  1851. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1852. * @param renderWidth defines the rendering width
  1853. * @param renderHeight defines the rendering height
  1854. * @returns a new Viewport
  1855. */
  1856. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1857. /**
  1858. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1859. * @param renderWidth defines the rendering width
  1860. * @param renderHeight defines the rendering height
  1861. * @param ref defines the target viewport
  1862. * @returns the current viewport
  1863. */
  1864. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1865. /**
  1866. * Returns a new Viewport copied from the current one
  1867. * @returns a new Viewport
  1868. */
  1869. clone(): Viewport;
  1870. }
  1871. }
  1872. declare module BABYLON {
  1873. /**
  1874. * Class containing a set of static utilities functions for arrays.
  1875. */
  1876. export class ArrayTools {
  1877. /**
  1878. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1879. * @param size the number of element to construct and put in the array
  1880. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1881. * @returns a new array filled with new objects
  1882. */
  1883. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1884. }
  1885. }
  1886. declare module BABYLON {
  1887. /**
  1888. * Class representing a vector containing 2 coordinates
  1889. */
  1890. export class Vector2 {
  1891. /** defines the first coordinate */
  1892. x: number;
  1893. /** defines the second coordinate */
  1894. y: number;
  1895. /**
  1896. * Creates a new Vector2 from the given x and y coordinates
  1897. * @param x defines the first coordinate
  1898. * @param y defines the second coordinate
  1899. */
  1900. constructor(
  1901. /** defines the first coordinate */
  1902. x?: number,
  1903. /** defines the second coordinate */
  1904. y?: number);
  1905. /**
  1906. * Gets a string with the Vector2 coordinates
  1907. * @returns a string with the Vector2 coordinates
  1908. */
  1909. toString(): string;
  1910. /**
  1911. * Gets class name
  1912. * @returns the string "Vector2"
  1913. */
  1914. getClassName(): string;
  1915. /**
  1916. * Gets current vector hash code
  1917. * @returns the Vector2 hash code as a number
  1918. */
  1919. getHashCode(): number;
  1920. /**
  1921. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1922. * @param array defines the source array
  1923. * @param index defines the offset in source array
  1924. * @returns the current Vector2
  1925. */
  1926. toArray(array: FloatArray, index?: number): Vector2;
  1927. /**
  1928. * Copy the current vector to an array
  1929. * @returns a new array with 2 elements: the Vector2 coordinates.
  1930. */
  1931. asArray(): number[];
  1932. /**
  1933. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1934. * @param source defines the source Vector2
  1935. * @returns the current updated Vector2
  1936. */
  1937. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1938. /**
  1939. * Sets the Vector2 coordinates with the given floats
  1940. * @param x defines the first coordinate
  1941. * @param y defines the second coordinate
  1942. * @returns the current updated Vector2
  1943. */
  1944. copyFromFloats(x: number, y: number): Vector2;
  1945. /**
  1946. * Sets the Vector2 coordinates with the given floats
  1947. * @param x defines the first coordinate
  1948. * @param y defines the second coordinate
  1949. * @returns the current updated Vector2
  1950. */
  1951. set(x: number, y: number): Vector2;
  1952. /**
  1953. * Add another vector with the current one
  1954. * @param otherVector defines the other vector
  1955. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1956. */
  1957. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1958. /**
  1959. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1960. * @param otherVector defines the other vector
  1961. * @param result defines the target vector
  1962. * @returns the unmodified current Vector2
  1963. */
  1964. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1965. /**
  1966. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1967. * @param otherVector defines the other vector
  1968. * @returns the current updated Vector2
  1969. */
  1970. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1971. /**
  1972. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1973. * @param otherVector defines the other vector
  1974. * @returns a new Vector2
  1975. */
  1976. addVector3(otherVector: Vector3): Vector2;
  1977. /**
  1978. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1979. * @param otherVector defines the other vector
  1980. * @returns a new Vector2
  1981. */
  1982. subtract(otherVector: Vector2): Vector2;
  1983. /**
  1984. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1985. * @param otherVector defines the other vector
  1986. * @param result defines the target vector
  1987. * @returns the unmodified current Vector2
  1988. */
  1989. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1990. /**
  1991. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1992. * @param otherVector defines the other vector
  1993. * @returns the current updated Vector2
  1994. */
  1995. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1996. /**
  1997. * Multiplies in place the current Vector2 coordinates by the given ones
  1998. * @param otherVector defines the other vector
  1999. * @returns the current updated Vector2
  2000. */
  2001. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2002. /**
  2003. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2004. * @param otherVector defines the other vector
  2005. * @returns a new Vector2
  2006. */
  2007. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2008. /**
  2009. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2010. * @param otherVector defines the other vector
  2011. * @param result defines the target vector
  2012. * @returns the unmodified current Vector2
  2013. */
  2014. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2015. /**
  2016. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2017. * @param x defines the first coordinate
  2018. * @param y defines the second coordinate
  2019. * @returns a new Vector2
  2020. */
  2021. multiplyByFloats(x: number, y: number): Vector2;
  2022. /**
  2023. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. divide(otherVector: Vector2): Vector2;
  2028. /**
  2029. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Divides the current Vector2 coordinates by the given ones
  2037. * @param otherVector defines the other vector
  2038. * @returns the current updated Vector2
  2039. */
  2040. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Gets a new Vector2 with current Vector2 negated coordinates
  2043. * @returns a new Vector2
  2044. */
  2045. negate(): Vector2;
  2046. /**
  2047. * Negate this vector in place
  2048. * @returns this
  2049. */
  2050. negateInPlace(): Vector2;
  2051. /**
  2052. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2053. * @param result defines the Vector3 object where to store the result
  2054. * @returns the current Vector2
  2055. */
  2056. negateToRef(result: Vector2): Vector2;
  2057. /**
  2058. * Multiply the Vector2 coordinates by scale
  2059. * @param scale defines the scaling factor
  2060. * @returns the current updated Vector2
  2061. */
  2062. scaleInPlace(scale: number): Vector2;
  2063. /**
  2064. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2065. * @param scale defines the scaling factor
  2066. * @returns a new Vector2
  2067. */
  2068. scale(scale: number): Vector2;
  2069. /**
  2070. * Scale the current Vector2 values by a factor to a given Vector2
  2071. * @param scale defines the scale factor
  2072. * @param result defines the Vector2 object where to store the result
  2073. * @returns the unmodified current Vector2
  2074. */
  2075. scaleToRef(scale: number, result: Vector2): Vector2;
  2076. /**
  2077. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2078. * @param scale defines the scale factor
  2079. * @param result defines the Vector2 object where to store the result
  2080. * @returns the unmodified current Vector2
  2081. */
  2082. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2083. /**
  2084. * Gets a boolean if two vectors are equals
  2085. * @param otherVector defines the other vector
  2086. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2087. */
  2088. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2089. /**
  2090. * Gets a boolean if two vectors are equals (using an epsilon value)
  2091. * @param otherVector defines the other vector
  2092. * @param epsilon defines the minimal distance to consider equality
  2093. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2094. */
  2095. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2096. /**
  2097. * Gets a new Vector2 from current Vector2 floored values
  2098. * @returns a new Vector2
  2099. */
  2100. floor(): Vector2;
  2101. /**
  2102. * Gets a new Vector2 from current Vector2 floored values
  2103. * @returns a new Vector2
  2104. */
  2105. fract(): Vector2;
  2106. /**
  2107. * Gets the length of the vector
  2108. * @returns the vector length (float)
  2109. */
  2110. length(): number;
  2111. /**
  2112. * Gets the vector squared length
  2113. * @returns the vector squared length (float)
  2114. */
  2115. lengthSquared(): number;
  2116. /**
  2117. * Normalize the vector
  2118. * @returns the current updated Vector2
  2119. */
  2120. normalize(): Vector2;
  2121. /**
  2122. * Gets a new Vector2 copied from the Vector2
  2123. * @returns a new Vector2
  2124. */
  2125. clone(): Vector2;
  2126. /**
  2127. * Gets a new Vector2(0, 0)
  2128. * @returns a new Vector2
  2129. */
  2130. static Zero(): Vector2;
  2131. /**
  2132. * Gets a new Vector2(1, 1)
  2133. * @returns a new Vector2
  2134. */
  2135. static One(): Vector2;
  2136. /**
  2137. * Gets a new Vector2 set from the given index element of the given array
  2138. * @param array defines the data source
  2139. * @param offset defines the offset in the data source
  2140. * @returns a new Vector2
  2141. */
  2142. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2143. /**
  2144. * Sets "result" from the given index element of the given array
  2145. * @param array defines the data source
  2146. * @param offset defines the offset in the data source
  2147. * @param result defines the target vector
  2148. */
  2149. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2150. /**
  2151. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2152. * @param value1 defines 1st point of control
  2153. * @param value2 defines 2nd point of control
  2154. * @param value3 defines 3rd point of control
  2155. * @param value4 defines 4th point of control
  2156. * @param amount defines the interpolation factor
  2157. * @returns a new Vector2
  2158. */
  2159. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2160. /**
  2161. * 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".
  2162. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2163. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2164. * @param value defines the value to clamp
  2165. * @param min defines the lower limit
  2166. * @param max defines the upper limit
  2167. * @returns a new Vector2
  2168. */
  2169. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2170. /**
  2171. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2172. * @param value1 defines the 1st control point
  2173. * @param tangent1 defines the outgoing tangent
  2174. * @param value2 defines the 2nd control point
  2175. * @param tangent2 defines the incoming tangent
  2176. * @param amount defines the interpolation factor
  2177. * @returns a new Vector2
  2178. */
  2179. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2180. /**
  2181. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2182. * @param start defines the start vector
  2183. * @param end defines the end vector
  2184. * @param amount defines the interpolation factor
  2185. * @returns a new Vector2
  2186. */
  2187. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2188. /**
  2189. * Gets the dot product of the vector "left" and the vector "right"
  2190. * @param left defines first vector
  2191. * @param right defines second vector
  2192. * @returns the dot product (float)
  2193. */
  2194. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2195. /**
  2196. * Returns a new Vector2 equal to the normalized given vector
  2197. * @param vector defines the vector to normalize
  2198. * @returns a new Vector2
  2199. */
  2200. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2203. * @param left defines 1st vector
  2204. * @param right defines 2nd vector
  2205. * @returns a new Vector2
  2206. */
  2207. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2208. /**
  2209. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2210. * @param left defines 1st vector
  2211. * @param right defines 2nd vector
  2212. * @returns a new Vector2
  2213. */
  2214. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2215. /**
  2216. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2217. * @param vector defines the vector to transform
  2218. * @param transformation defines the matrix to apply
  2219. * @returns a new Vector2
  2220. */
  2221. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2222. /**
  2223. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2224. * @param vector defines the vector to transform
  2225. * @param transformation defines the matrix to apply
  2226. * @param result defines the target vector
  2227. */
  2228. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2229. /**
  2230. * Determines if a given vector is included in a triangle
  2231. * @param p defines the vector to test
  2232. * @param p0 defines 1st triangle point
  2233. * @param p1 defines 2nd triangle point
  2234. * @param p2 defines 3rd triangle point
  2235. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2236. */
  2237. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2238. /**
  2239. * Gets the distance between the vectors "value1" and "value2"
  2240. * @param value1 defines first vector
  2241. * @param value2 defines second vector
  2242. * @returns the distance between vectors
  2243. */
  2244. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2245. /**
  2246. * Returns the squared distance between the vectors "value1" and "value2"
  2247. * @param value1 defines first vector
  2248. * @param value2 defines second vector
  2249. * @returns the squared distance between vectors
  2250. */
  2251. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2252. /**
  2253. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2254. * @param value1 defines first vector
  2255. * @param value2 defines second vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2261. * @param p defines the middle point
  2262. * @param segA defines one point of the segment
  2263. * @param segB defines the other point of the segment
  2264. * @returns the shortest distance
  2265. */
  2266. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2267. }
  2268. /**
  2269. * Class used to store (x,y,z) vector representation
  2270. * A Vector3 is the main object used in 3D geometry
  2271. * It can represent etiher the coordinates of a point the space, either a direction
  2272. * Reminder: js uses a left handed forward facing system
  2273. */
  2274. export class Vector3 {
  2275. /**
  2276. * Defines the first coordinates (on X axis)
  2277. */
  2278. x: number;
  2279. /**
  2280. * Defines the second coordinates (on Y axis)
  2281. */
  2282. y: number;
  2283. /**
  2284. * Defines the third coordinates (on Z axis)
  2285. */
  2286. z: number;
  2287. private static _UpReadOnly;
  2288. private static _ZeroReadOnly;
  2289. /**
  2290. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2291. * @param x defines the first coordinates (on X axis)
  2292. * @param y defines the second coordinates (on Y axis)
  2293. * @param z defines the third coordinates (on Z axis)
  2294. */
  2295. constructor(
  2296. /**
  2297. * Defines the first coordinates (on X axis)
  2298. */
  2299. x?: number,
  2300. /**
  2301. * Defines the second coordinates (on Y axis)
  2302. */
  2303. y?: number,
  2304. /**
  2305. * Defines the third coordinates (on Z axis)
  2306. */
  2307. z?: number);
  2308. /**
  2309. * Creates a string representation of the Vector3
  2310. * @returns a string with the Vector3 coordinates.
  2311. */
  2312. toString(): string;
  2313. /**
  2314. * Gets the class name
  2315. * @returns the string "Vector3"
  2316. */
  2317. getClassName(): string;
  2318. /**
  2319. * Creates the Vector3 hash code
  2320. * @returns a number which tends to be unique between Vector3 instances
  2321. */
  2322. getHashCode(): number;
  2323. /**
  2324. * Creates an array containing three elements : the coordinates of the Vector3
  2325. * @returns a new array of numbers
  2326. */
  2327. asArray(): number[];
  2328. /**
  2329. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2330. * @param array defines the destination array
  2331. * @param index defines the offset in the destination array
  2332. * @returns the current Vector3
  2333. */
  2334. toArray(array: FloatArray, index?: number): Vector3;
  2335. /**
  2336. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2337. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2338. */
  2339. toQuaternion(): Quaternion;
  2340. /**
  2341. * Adds the given vector to the current Vector3
  2342. * @param otherVector defines the second operand
  2343. * @returns the current updated Vector3
  2344. */
  2345. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2346. /**
  2347. * Adds the given coordinates to the current Vector3
  2348. * @param x defines the x coordinate of the operand
  2349. * @param y defines the y coordinate of the operand
  2350. * @param z defines the z coordinate of the operand
  2351. * @returns the current updated Vector3
  2352. */
  2353. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2354. /**
  2355. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2356. * @param otherVector defines the second operand
  2357. * @returns the resulting Vector3
  2358. */
  2359. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2360. /**
  2361. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2362. * @param otherVector defines the second operand
  2363. * @param result defines the Vector3 object where to store the result
  2364. * @returns the current Vector3
  2365. */
  2366. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2367. /**
  2368. * Subtract the given vector from the current Vector3
  2369. * @param otherVector defines the second operand
  2370. * @returns the current updated Vector3
  2371. */
  2372. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the resulting Vector3
  2377. */
  2378. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2381. * @param otherVector defines the second operand
  2382. * @param result defines the Vector3 object where to store the result
  2383. * @returns the current Vector3
  2384. */
  2385. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2386. /**
  2387. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2388. * @param x defines the x coordinate of the operand
  2389. * @param y defines the y coordinate of the operand
  2390. * @param z defines the z coordinate of the operand
  2391. * @returns the resulting Vector3
  2392. */
  2393. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2394. /**
  2395. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2396. * @param x defines the x coordinate of the operand
  2397. * @param y defines the y coordinate of the operand
  2398. * @param z defines the z coordinate of the operand
  2399. * @param result defines the Vector3 object where to store the result
  2400. * @returns the current Vector3
  2401. */
  2402. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2403. /**
  2404. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2405. * @returns a new Vector3
  2406. */
  2407. negate(): Vector3;
  2408. /**
  2409. * Negate this vector in place
  2410. * @returns this
  2411. */
  2412. negateInPlace(): Vector3;
  2413. /**
  2414. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. negateToRef(result: Vector3): Vector3;
  2419. /**
  2420. * Multiplies the Vector3 coordinates by the float "scale"
  2421. * @param scale defines the multiplier factor
  2422. * @returns the current updated Vector3
  2423. */
  2424. scaleInPlace(scale: number): Vector3;
  2425. /**
  2426. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2427. * @param scale defines the multiplier factor
  2428. * @returns a new Vector3
  2429. */
  2430. scale(scale: number): Vector3;
  2431. /**
  2432. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2433. * @param scale defines the multiplier factor
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the current Vector3
  2436. */
  2437. scaleToRef(scale: number, result: Vector3): Vector3;
  2438. /**
  2439. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2440. * @param scale defines the scale factor
  2441. * @param result defines the Vector3 object where to store the result
  2442. * @returns the unmodified current Vector3
  2443. */
  2444. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2445. /**
  2446. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2447. * @param otherVector defines the second operand
  2448. * @returns true if both vectors are equals
  2449. */
  2450. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2451. /**
  2452. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2453. * @param otherVector defines the second operand
  2454. * @param epsilon defines the minimal distance to define values as equals
  2455. * @returns true if both vectors are distant less than epsilon
  2456. */
  2457. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2458. /**
  2459. * Returns true if the current Vector3 coordinates equals the given floats
  2460. * @param x defines the x coordinate of the operand
  2461. * @param y defines the y coordinate of the operand
  2462. * @param z defines the z coordinate of the operand
  2463. * @returns true if both vectors are equals
  2464. */
  2465. equalsToFloats(x: number, y: number, z: number): boolean;
  2466. /**
  2467. * Multiplies the current Vector3 coordinates by the given ones
  2468. * @param otherVector defines the second operand
  2469. * @returns the current updated Vector3
  2470. */
  2471. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2472. /**
  2473. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2474. * @param otherVector defines the second operand
  2475. * @returns the new Vector3
  2476. */
  2477. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2478. /**
  2479. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2480. * @param otherVector defines the second operand
  2481. * @param result defines the Vector3 object where to store the result
  2482. * @returns the current Vector3
  2483. */
  2484. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2485. /**
  2486. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2487. * @param x defines the x coordinate of the operand
  2488. * @param y defines the y coordinate of the operand
  2489. * @param z defines the z coordinate of the operand
  2490. * @returns the new Vector3
  2491. */
  2492. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2493. /**
  2494. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2495. * @param otherVector defines the second operand
  2496. * @returns the new Vector3
  2497. */
  2498. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2499. /**
  2500. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2501. * @param otherVector defines the second operand
  2502. * @param result defines the Vector3 object where to store the result
  2503. * @returns the current Vector3
  2504. */
  2505. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2506. /**
  2507. * Divides the current Vector3 coordinates by the given ones.
  2508. * @param otherVector defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. divideInPlace(otherVector: Vector3): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2514. * @param other defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2520. * @param other defines the second operand
  2521. * @returns the current updated Vector3
  2522. */
  2523. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2526. * @param x defines the x coordinate of the operand
  2527. * @param y defines the y coordinate of the operand
  2528. * @param z defines the z coordinate of the operand
  2529. * @returns the current updated Vector3
  2530. */
  2531. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2532. /**
  2533. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2534. * @param x defines the x coordinate of the operand
  2535. * @param y defines the y coordinate of the operand
  2536. * @param z defines the z coordinate of the operand
  2537. * @returns the current updated Vector3
  2538. */
  2539. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2540. /**
  2541. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2542. * Check if is non uniform within a certain amount of decimal places to account for this
  2543. * @param epsilon the amount the values can differ
  2544. * @returns if the the vector is non uniform to a certain number of decimal places
  2545. */
  2546. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2547. /**
  2548. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2549. */
  2550. get isNonUniform(): boolean;
  2551. /**
  2552. * Gets a new Vector3 from current Vector3 floored values
  2553. * @returns a new Vector3
  2554. */
  2555. floor(): Vector3;
  2556. /**
  2557. * Gets a new Vector3 from current Vector3 floored values
  2558. * @returns a new Vector3
  2559. */
  2560. fract(): Vector3;
  2561. /**
  2562. * Gets the length of the Vector3
  2563. * @returns the length of the Vector3
  2564. */
  2565. length(): number;
  2566. /**
  2567. * Gets the squared length of the Vector3
  2568. * @returns squared length of the Vector3
  2569. */
  2570. lengthSquared(): number;
  2571. /**
  2572. * Normalize the current Vector3.
  2573. * Please note that this is an in place operation.
  2574. * @returns the current updated Vector3
  2575. */
  2576. normalize(): Vector3;
  2577. /**
  2578. * Reorders the x y z properties of the vector in place
  2579. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2580. * @returns the current updated vector
  2581. */
  2582. reorderInPlace(order: string): this;
  2583. /**
  2584. * Rotates the vector around 0,0,0 by a quaternion
  2585. * @param quaternion the rotation quaternion
  2586. * @param result vector to store the result
  2587. * @returns the resulting vector
  2588. */
  2589. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2590. /**
  2591. * Rotates a vector around a given point
  2592. * @param quaternion the rotation quaternion
  2593. * @param point the point to rotate around
  2594. * @param result vector to store the result
  2595. * @returns the resulting vector
  2596. */
  2597. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2598. /**
  2599. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2600. * The cross product is then orthogonal to both current and "other"
  2601. * @param other defines the right operand
  2602. * @returns the cross product
  2603. */
  2604. cross(other: Vector3): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 with the given input length.
  2607. * Please note that this is an in place operation.
  2608. * @param len the length of the vector
  2609. * @returns the current updated Vector3
  2610. */
  2611. normalizeFromLength(len: number): Vector3;
  2612. /**
  2613. * Normalize the current Vector3 to a new vector
  2614. * @returns the new Vector3
  2615. */
  2616. normalizeToNew(): Vector3;
  2617. /**
  2618. * Normalize the current Vector3 to the reference
  2619. * @param reference define the Vector3 to update
  2620. * @returns the updated Vector3
  2621. */
  2622. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2623. /**
  2624. * Creates a new Vector3 copied from the current Vector3
  2625. * @returns the new Vector3
  2626. */
  2627. clone(): Vector3;
  2628. /**
  2629. * Copies the given vector coordinates to the current Vector3 ones
  2630. * @param source defines the source Vector3
  2631. * @returns the current updated Vector3
  2632. */
  2633. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Copies the given floats to the current Vector3 coordinates
  2636. * @param x defines the x coordinate of the operand
  2637. * @param y defines the y coordinate of the operand
  2638. * @param z defines the z coordinate of the operand
  2639. * @returns the current updated Vector3
  2640. */
  2641. copyFromFloats(x: number, y: number, z: number): Vector3;
  2642. /**
  2643. * Copies the given floats to the current Vector3 coordinates
  2644. * @param x defines the x coordinate of the operand
  2645. * @param y defines the y coordinate of the operand
  2646. * @param z defines the z coordinate of the operand
  2647. * @returns the current updated Vector3
  2648. */
  2649. set(x: number, y: number, z: number): Vector3;
  2650. /**
  2651. * Copies the given float to the current Vector3 coordinates
  2652. * @param v defines the x, y and z coordinates of the operand
  2653. * @returns the current updated Vector3
  2654. */
  2655. setAll(v: number): Vector3;
  2656. /**
  2657. * Get the clip factor between two vectors
  2658. * @param vector0 defines the first operand
  2659. * @param vector1 defines the second operand
  2660. * @param axis defines the axis to use
  2661. * @param size defines the size along the axis
  2662. * @returns the clip factor
  2663. */
  2664. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2665. /**
  2666. * Get angle between two vectors
  2667. * @param vector0 angle between vector0 and vector1
  2668. * @param vector1 angle between vector0 and vector1
  2669. * @param normal direction of the normal
  2670. * @return the angle between vector0 and vector1
  2671. */
  2672. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2673. /**
  2674. * Returns a new Vector3 set from the index "offset" of the given array
  2675. * @param array defines the source array
  2676. * @param offset defines the offset in the source array
  2677. * @returns the new Vector3
  2678. */
  2679. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2680. /**
  2681. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2682. * @param array defines the source array
  2683. * @param offset defines the offset in the source array
  2684. * @returns the new Vector3
  2685. * @deprecated Please use FromArray instead.
  2686. */
  2687. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2688. /**
  2689. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2690. * @param array defines the source array
  2691. * @param offset defines the offset in the source array
  2692. * @param result defines the Vector3 where to store the result
  2693. */
  2694. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2695. /**
  2696. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2697. * @param array defines the source array
  2698. * @param offset defines the offset in the source array
  2699. * @param result defines the Vector3 where to store the result
  2700. * @deprecated Please use FromArrayToRef instead.
  2701. */
  2702. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2703. /**
  2704. * Sets the given vector "result" with the given floats.
  2705. * @param x defines the x coordinate of the source
  2706. * @param y defines the y coordinate of the source
  2707. * @param z defines the z coordinate of the source
  2708. * @param result defines the Vector3 where to store the result
  2709. */
  2710. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2711. /**
  2712. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2713. * @returns a new empty Vector3
  2714. */
  2715. static Zero(): Vector3;
  2716. /**
  2717. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2718. * @returns a new unit Vector3
  2719. */
  2720. static One(): Vector3;
  2721. /**
  2722. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2723. * @returns a new up Vector3
  2724. */
  2725. static Up(): Vector3;
  2726. /**
  2727. * Gets a up Vector3 that must not be updated
  2728. */
  2729. static get UpReadOnly(): DeepImmutable<Vector3>;
  2730. /**
  2731. * Gets a zero Vector3 that must not be updated
  2732. */
  2733. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2734. /**
  2735. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2736. * @returns a new down Vector3
  2737. */
  2738. static Down(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2741. * @returns a new forward Vector3
  2742. */
  2743. static Forward(): Vector3;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2746. * @returns a new forward Vector3
  2747. */
  2748. static Backward(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2751. * @returns a new right Vector3
  2752. */
  2753. static Right(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2756. * @returns a new left Vector3
  2757. */
  2758. static Left(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2761. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2762. * @param vector defines the Vector3 to transform
  2763. * @param transformation defines the transformation matrix
  2764. * @returns the transformed Vector3
  2765. */
  2766. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2767. /**
  2768. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2769. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2770. * @param vector defines the Vector3 to transform
  2771. * @param transformation defines the transformation matrix
  2772. * @param result defines the Vector3 where to store the result
  2773. */
  2774. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2775. /**
  2776. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2777. * This method computes tranformed coordinates only, not transformed direction vectors
  2778. * @param x define the x coordinate of the source vector
  2779. * @param y define the y coordinate of the source vector
  2780. * @param z define the z coordinate of the source vector
  2781. * @param transformation defines the transformation matrix
  2782. * @param result defines the Vector3 where to store the result
  2783. */
  2784. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2785. /**
  2786. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2787. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @returns the new Vector3
  2791. */
  2792. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2793. /**
  2794. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2795. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2796. * @param vector defines the Vector3 to transform
  2797. * @param transformation defines the transformation matrix
  2798. * @param result defines the Vector3 where to store the result
  2799. */
  2800. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2801. /**
  2802. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2803. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2804. * @param x define the x coordinate of the source vector
  2805. * @param y define the y coordinate of the source vector
  2806. * @param z define the z coordinate of the source vector
  2807. * @param transformation defines the transformation matrix
  2808. * @param result defines the Vector3 where to store the result
  2809. */
  2810. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2811. /**
  2812. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2813. * @param value1 defines the first control point
  2814. * @param value2 defines the second control point
  2815. * @param value3 defines the third control point
  2816. * @param value4 defines the fourth control point
  2817. * @param amount defines the amount on the spline to use
  2818. * @returns the new Vector3
  2819. */
  2820. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2821. /**
  2822. * 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"
  2823. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2824. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2825. * @param value defines the current value
  2826. * @param min defines the lower range value
  2827. * @param max defines the upper range value
  2828. * @returns the new Vector3
  2829. */
  2830. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2831. /**
  2832. * 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"
  2833. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2834. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2835. * @param value defines the current value
  2836. * @param min defines the lower range value
  2837. * @param max defines the upper range value
  2838. * @param result defines the Vector3 where to store the result
  2839. */
  2840. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2841. /**
  2842. * Checks if a given vector is inside a specific range
  2843. * @param v defines the vector to test
  2844. * @param min defines the minimum range
  2845. * @param max defines the maximum range
  2846. */
  2847. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2848. /**
  2849. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2850. * @param value1 defines the first control point
  2851. * @param tangent1 defines the first tangent vector
  2852. * @param value2 defines the second control point
  2853. * @param tangent2 defines the second tangent vector
  2854. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2855. * @returns the new Vector3
  2856. */
  2857. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2858. /**
  2859. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2860. * @param start defines the start value
  2861. * @param end defines the end value
  2862. * @param amount max defines amount between both (between 0 and 1)
  2863. * @returns the new Vector3
  2864. */
  2865. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2866. /**
  2867. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2868. * @param start defines the start value
  2869. * @param end defines the end value
  2870. * @param amount max defines amount between both (between 0 and 1)
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2874. /**
  2875. * Returns the dot product (float) between the vectors "left" and "right"
  2876. * @param left defines the left operand
  2877. * @param right defines the right operand
  2878. * @returns the dot product
  2879. */
  2880. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2881. /**
  2882. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2883. * The cross product is then orthogonal to both "left" and "right"
  2884. * @param left defines the left operand
  2885. * @param right defines the right operand
  2886. * @returns the cross product
  2887. */
  2888. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2889. /**
  2890. * Sets the given vector "result" with the cross product of "left" and "right"
  2891. * The cross product is then orthogonal to both "left" and "right"
  2892. * @param left defines the left operand
  2893. * @param right defines the right operand
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2897. /**
  2898. * Returns a new Vector3 as the normalization of the given vector
  2899. * @param vector defines the Vector3 to normalize
  2900. * @returns the new Vector3
  2901. */
  2902. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2903. /**
  2904. * Sets the given vector "result" with the normalization of the given first vector
  2905. * @param vector defines the Vector3 to normalize
  2906. * @param result defines the Vector3 where to store the result
  2907. */
  2908. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2909. /**
  2910. * Project a Vector3 onto screen space
  2911. * @param vector defines the Vector3 to project
  2912. * @param world defines the world matrix to use
  2913. * @param transform defines the transform (view x projection) matrix to use
  2914. * @param viewport defines the screen viewport to use
  2915. * @returns the new Vector3
  2916. */
  2917. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2918. /** @hidden */
  2919. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2920. /**
  2921. * Unproject from screen space to object space
  2922. * @param source defines the screen space Vector3 to use
  2923. * @param viewportWidth defines the current width of the viewport
  2924. * @param viewportHeight defines the current height of the viewport
  2925. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2926. * @param transform defines the transform (view x projection) matrix to use
  2927. * @returns the new Vector3
  2928. */
  2929. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2930. /**
  2931. * Unproject from screen space to object space
  2932. * @param source defines the screen space Vector3 to use
  2933. * @param viewportWidth defines the current width of the viewport
  2934. * @param viewportHeight defines the current height of the viewport
  2935. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2936. * @param view defines the view matrix to use
  2937. * @param projection defines the projection matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @param result defines the Vector3 where to store the result
  2950. */
  2951. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param sourceX defines the screen space x coordinate to use
  2955. * @param sourceY defines the screen space y coordinate to use
  2956. * @param sourceZ defines the screen space z coordinate to use
  2957. * @param viewportWidth defines the current width of the viewport
  2958. * @param viewportHeight defines the current height of the viewport
  2959. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2960. * @param view defines the view matrix to use
  2961. * @param projection defines the projection matrix to use
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2965. /**
  2966. * Gets the minimal coordinate values between two Vector3
  2967. * @param left defines the first operand
  2968. * @param right defines the second operand
  2969. * @returns the new Vector3
  2970. */
  2971. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2972. /**
  2973. * Gets the maximal coordinate values between two Vector3
  2974. * @param left defines the first operand
  2975. * @param right defines the second operand
  2976. * @returns the new Vector3
  2977. */
  2978. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2979. /**
  2980. * Returns the distance between the vectors "value1" and "value2"
  2981. * @param value1 defines the first operand
  2982. * @param value2 defines the second operand
  2983. * @returns the distance
  2984. */
  2985. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2986. /**
  2987. * Returns the squared distance between the vectors "value1" and "value2"
  2988. * @param value1 defines the first operand
  2989. * @param value2 defines the second operand
  2990. * @returns the squared distance
  2991. */
  2992. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2993. /**
  2994. * Returns a new Vector3 located at the center between "value1" and "value2"
  2995. * @param value1 defines the first operand
  2996. * @param value2 defines the second operand
  2997. * @returns the new Vector3
  2998. */
  2999. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3000. /**
  3001. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3002. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3003. * to something in order to rotate it from its local system to the given target system
  3004. * Note: axis1, axis2 and axis3 are normalized during this operation
  3005. * @param axis1 defines the first axis
  3006. * @param axis2 defines the second axis
  3007. * @param axis3 defines the third axis
  3008. * @returns a new Vector3
  3009. */
  3010. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3013. * @param axis1 defines the first axis
  3014. * @param axis2 defines the second axis
  3015. * @param axis3 defines the third axis
  3016. * @param ref defines the Vector3 where to store the result
  3017. */
  3018. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3019. }
  3020. /**
  3021. * Vector4 class created for EulerAngle class conversion to Quaternion
  3022. */
  3023. export class Vector4 {
  3024. /** x value of the vector */
  3025. x: number;
  3026. /** y value of the vector */
  3027. y: number;
  3028. /** z value of the vector */
  3029. z: number;
  3030. /** w value of the vector */
  3031. w: number;
  3032. /**
  3033. * Creates a Vector4 object from the given floats.
  3034. * @param x x value of the vector
  3035. * @param y y value of the vector
  3036. * @param z z value of the vector
  3037. * @param w w value of the vector
  3038. */
  3039. constructor(
  3040. /** x value of the vector */
  3041. x: number,
  3042. /** y value of the vector */
  3043. y: number,
  3044. /** z value of the vector */
  3045. z: number,
  3046. /** w value of the vector */
  3047. w: number);
  3048. /**
  3049. * Returns the string with the Vector4 coordinates.
  3050. * @returns a string containing all the vector values
  3051. */
  3052. toString(): string;
  3053. /**
  3054. * Returns the string "Vector4".
  3055. * @returns "Vector4"
  3056. */
  3057. getClassName(): string;
  3058. /**
  3059. * Returns the Vector4 hash code.
  3060. * @returns a unique hash code
  3061. */
  3062. getHashCode(): number;
  3063. /**
  3064. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3065. * @returns the resulting array
  3066. */
  3067. asArray(): number[];
  3068. /**
  3069. * Populates the given array from the given index with the Vector4 coordinates.
  3070. * @param array array to populate
  3071. * @param index index of the array to start at (default: 0)
  3072. * @returns the Vector4.
  3073. */
  3074. toArray(array: FloatArray, index?: number): Vector4;
  3075. /**
  3076. * Adds the given vector to the current Vector4.
  3077. * @param otherVector the vector to add
  3078. * @returns the updated Vector4.
  3079. */
  3080. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3081. /**
  3082. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3083. * @param otherVector the vector to add
  3084. * @returns the resulting vector
  3085. */
  3086. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3087. /**
  3088. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3089. * @param otherVector the vector to add
  3090. * @param result the vector to store the result
  3091. * @returns the current Vector4.
  3092. */
  3093. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3094. /**
  3095. * Subtract in place the given vector from the current Vector4.
  3096. * @param otherVector the vector to subtract
  3097. * @returns the updated Vector4.
  3098. */
  3099. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3100. /**
  3101. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3102. * @param otherVector the vector to add
  3103. * @returns the new vector with the result
  3104. */
  3105. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3106. /**
  3107. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3108. * @param otherVector the vector to subtract
  3109. * @param result the vector to store the result
  3110. * @returns the current Vector4.
  3111. */
  3112. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3113. /**
  3114. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3115. */
  3116. /**
  3117. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3118. * @param x value to subtract
  3119. * @param y value to subtract
  3120. * @param z value to subtract
  3121. * @param w value to subtract
  3122. * @returns new vector containing the result
  3123. */
  3124. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3125. /**
  3126. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3127. * @param x value to subtract
  3128. * @param y value to subtract
  3129. * @param z value to subtract
  3130. * @param w value to subtract
  3131. * @param result the vector to store the result in
  3132. * @returns the current Vector4.
  3133. */
  3134. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3135. /**
  3136. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3137. * @returns a new vector with the negated values
  3138. */
  3139. negate(): Vector4;
  3140. /**
  3141. * Negate this vector in place
  3142. * @returns this
  3143. */
  3144. negateInPlace(): Vector4;
  3145. /**
  3146. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3147. * @param result defines the Vector3 object where to store the result
  3148. * @returns the current Vector4
  3149. */
  3150. negateToRef(result: Vector4): Vector4;
  3151. /**
  3152. * Multiplies the current Vector4 coordinates by scale (float).
  3153. * @param scale the number to scale with
  3154. * @returns the updated Vector4.
  3155. */
  3156. scaleInPlace(scale: number): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3159. * @param scale the number to scale with
  3160. * @returns a new vector with the result
  3161. */
  3162. scale(scale: number): Vector4;
  3163. /**
  3164. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3165. * @param scale the number to scale with
  3166. * @param result a vector to store the result in
  3167. * @returns the current Vector4.
  3168. */
  3169. scaleToRef(scale: number, result: Vector4): Vector4;
  3170. /**
  3171. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3172. * @param scale defines the scale factor
  3173. * @param result defines the Vector4 object where to store the result
  3174. * @returns the unmodified current Vector4
  3175. */
  3176. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3179. * @param otherVector the vector to compare against
  3180. * @returns true if they are equal
  3181. */
  3182. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3183. /**
  3184. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3185. * @param otherVector vector to compare against
  3186. * @param epsilon (Default: very small number)
  3187. * @returns true if they are equal
  3188. */
  3189. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3190. /**
  3191. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3192. * @param x x value to compare against
  3193. * @param y y value to compare against
  3194. * @param z z value to compare against
  3195. * @param w w value to compare against
  3196. * @returns true if equal
  3197. */
  3198. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3199. /**
  3200. * Multiplies in place the current Vector4 by the given one.
  3201. * @param otherVector vector to multiple with
  3202. * @returns the updated Vector4.
  3203. */
  3204. multiplyInPlace(otherVector: Vector4): Vector4;
  3205. /**
  3206. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3207. * @param otherVector vector to multiple with
  3208. * @returns resulting new vector
  3209. */
  3210. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3211. /**
  3212. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3213. * @param otherVector vector to multiple with
  3214. * @param result vector to store the result
  3215. * @returns the current Vector4.
  3216. */
  3217. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3218. /**
  3219. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3220. * @param x x value multiply with
  3221. * @param y y value multiply with
  3222. * @param z z value multiply with
  3223. * @param w w value multiply with
  3224. * @returns resulting new vector
  3225. */
  3226. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3227. /**
  3228. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3229. * @param otherVector vector to devide with
  3230. * @returns resulting new vector
  3231. */
  3232. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3235. * @param otherVector vector to devide with
  3236. * @param result vector to store the result
  3237. * @returns the current Vector4.
  3238. */
  3239. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3240. /**
  3241. * Divides the current Vector3 coordinates by the given ones.
  3242. * @param otherVector vector to devide with
  3243. * @returns the updated Vector3.
  3244. */
  3245. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3246. /**
  3247. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3248. * @param other defines the second operand
  3249. * @returns the current updated Vector4
  3250. */
  3251. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3254. * @param other defines the second operand
  3255. * @returns the current updated Vector4
  3256. */
  3257. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Gets a new Vector4 from current Vector4 floored values
  3260. * @returns a new Vector4
  3261. */
  3262. floor(): Vector4;
  3263. /**
  3264. * Gets a new Vector4 from current Vector3 floored values
  3265. * @returns a new Vector4
  3266. */
  3267. fract(): Vector4;
  3268. /**
  3269. * Returns the Vector4 length (float).
  3270. * @returns the length
  3271. */
  3272. length(): number;
  3273. /**
  3274. * Returns the Vector4 squared length (float).
  3275. * @returns the length squared
  3276. */
  3277. lengthSquared(): number;
  3278. /**
  3279. * Normalizes in place the Vector4.
  3280. * @returns the updated Vector4.
  3281. */
  3282. normalize(): Vector4;
  3283. /**
  3284. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3285. * @returns this converted to a new vector3
  3286. */
  3287. toVector3(): Vector3;
  3288. /**
  3289. * Returns a new Vector4 copied from the current one.
  3290. * @returns the new cloned vector
  3291. */
  3292. clone(): Vector4;
  3293. /**
  3294. * Updates the current Vector4 with the given one coordinates.
  3295. * @param source the source vector to copy from
  3296. * @returns the updated Vector4.
  3297. */
  3298. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3299. /**
  3300. * Updates the current Vector4 coordinates with the given floats.
  3301. * @param x float to copy from
  3302. * @param y float to copy from
  3303. * @param z float to copy from
  3304. * @param w float to copy from
  3305. * @returns the updated Vector4.
  3306. */
  3307. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3308. /**
  3309. * Updates the current Vector4 coordinates with the given floats.
  3310. * @param x float to set from
  3311. * @param y float to set from
  3312. * @param z float to set from
  3313. * @param w float to set from
  3314. * @returns the updated Vector4.
  3315. */
  3316. set(x: number, y: number, z: number, w: number): Vector4;
  3317. /**
  3318. * Copies the given float to the current Vector3 coordinates
  3319. * @param v defines the x, y, z and w coordinates of the operand
  3320. * @returns the current updated Vector3
  3321. */
  3322. setAll(v: number): Vector4;
  3323. /**
  3324. * Returns a new Vector4 set from the starting index of the given array.
  3325. * @param array the array to pull values from
  3326. * @param offset the offset into the array to start at
  3327. * @returns the new vector
  3328. */
  3329. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3330. /**
  3331. * Updates the given vector "result" from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @param result the vector to store the result in
  3335. */
  3336. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given Float32Array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" coordinates from the given floats.
  3346. * @param x float to set from
  3347. * @param y float to set from
  3348. * @param z float to set from
  3349. * @param w float to set from
  3350. * @param result the vector to the floats in
  3351. */
  3352. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3353. /**
  3354. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3355. * @returns the new vector
  3356. */
  3357. static Zero(): Vector4;
  3358. /**
  3359. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3360. * @returns the new vector
  3361. */
  3362. static One(): Vector4;
  3363. /**
  3364. * Returns a new normalized Vector4 from the given one.
  3365. * @param vector the vector to normalize
  3366. * @returns the vector
  3367. */
  3368. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3369. /**
  3370. * Updates the given vector "result" from the normalization of the given one.
  3371. * @param vector the vector to normalize
  3372. * @param result the vector to store the result in
  3373. */
  3374. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3375. /**
  3376. * Returns a vector with the minimum values from the left and right vectors
  3377. * @param left left vector to minimize
  3378. * @param right right vector to minimize
  3379. * @returns a new vector with the minimum of the left and right vector values
  3380. */
  3381. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3382. /**
  3383. * Returns a vector with the maximum values from the left and right vectors
  3384. * @param left left vector to maximize
  3385. * @param right right vector to maximize
  3386. * @returns a new vector with the maximum of the left and right vector values
  3387. */
  3388. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns the distance (float) between the vectors "value1" and "value2".
  3391. * @param value1 value to calulate the distance between
  3392. * @param value2 value to calulate the distance between
  3393. * @return the distance between the two vectors
  3394. */
  3395. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3396. /**
  3397. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors squared
  3401. */
  3402. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the center between
  3406. * @param value2 value to calulate the center between
  3407. * @return the center between the two vectors
  3408. */
  3409. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3412. * This methods computes transformed normalized direction vectors only.
  3413. * @param vector the vector to transform
  3414. * @param transformation the transformation matrix to apply
  3415. * @returns the new vector
  3416. */
  3417. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3418. /**
  3419. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3420. * This methods computes transformed normalized direction vectors only.
  3421. * @param vector the vector to transform
  3422. * @param transformation the transformation matrix to apply
  3423. * @param result the vector to store the result in
  3424. */
  3425. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3426. /**
  3427. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3428. * This methods computes transformed normalized direction vectors only.
  3429. * @param x value to transform
  3430. * @param y value to transform
  3431. * @param z value to transform
  3432. * @param w value to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the results in
  3435. */
  3436. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Creates a new Vector4 from a Vector3
  3439. * @param source defines the source data
  3440. * @param w defines the 4th component (default is 0)
  3441. * @returns a new Vector4
  3442. */
  3443. static FromVector3(source: Vector3, w?: number): Vector4;
  3444. }
  3445. /**
  3446. * Class used to store quaternion data
  3447. * @see https://en.wikipedia.org/wiki/Quaternion
  3448. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3449. */
  3450. export class Quaternion {
  3451. /** defines the first component (0 by default) */
  3452. x: number;
  3453. /** defines the second component (0 by default) */
  3454. y: number;
  3455. /** defines the third component (0 by default) */
  3456. z: number;
  3457. /** defines the fourth component (1.0 by default) */
  3458. w: number;
  3459. /**
  3460. * Creates a new Quaternion from the given floats
  3461. * @param x defines the first component (0 by default)
  3462. * @param y defines the second component (0 by default)
  3463. * @param z defines the third component (0 by default)
  3464. * @param w defines the fourth component (1.0 by default)
  3465. */
  3466. constructor(
  3467. /** defines the first component (0 by default) */
  3468. x?: number,
  3469. /** defines the second component (0 by default) */
  3470. y?: number,
  3471. /** defines the third component (0 by default) */
  3472. z?: number,
  3473. /** defines the fourth component (1.0 by default) */
  3474. w?: number);
  3475. /**
  3476. * Gets a string representation for the current quaternion
  3477. * @returns a string with the Quaternion coordinates
  3478. */
  3479. toString(): string;
  3480. /**
  3481. * Gets the class name of the quaternion
  3482. * @returns the string "Quaternion"
  3483. */
  3484. getClassName(): string;
  3485. /**
  3486. * Gets a hash code for this quaternion
  3487. * @returns the quaternion hash code
  3488. */
  3489. getHashCode(): number;
  3490. /**
  3491. * Copy the quaternion to an array
  3492. * @returns a new array populated with 4 elements from the quaternion coordinates
  3493. */
  3494. asArray(): number[];
  3495. /**
  3496. * Check if two quaternions are equals
  3497. * @param otherQuaternion defines the second operand
  3498. * @return true if the current quaternion and the given one coordinates are strictly equals
  3499. */
  3500. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3501. /**
  3502. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3503. * @param otherQuaternion defines the other quaternion
  3504. * @param epsilon defines the minimal distance to consider equality
  3505. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3506. */
  3507. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. get m(): DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module BABYLON {
  4617. /**
  4618. * Defines potential orientation for back face culling
  4619. */
  4620. export enum Orientation {
  4621. /**
  4622. * Clockwise
  4623. */
  4624. CW = 0,
  4625. /** Counter clockwise */
  4626. CCW = 1
  4627. }
  4628. /** Class used to represent a Bezier curve */
  4629. export class BezierCurve {
  4630. /**
  4631. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4632. * @param t defines the time
  4633. * @param x1 defines the left coordinate on X axis
  4634. * @param y1 defines the left coordinate on Y axis
  4635. * @param x2 defines the right coordinate on X axis
  4636. * @param y2 defines the right coordinate on Y axis
  4637. * @returns the interpolated value
  4638. */
  4639. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4640. }
  4641. /**
  4642. * Defines angle representation
  4643. */
  4644. export class Angle {
  4645. private _radians;
  4646. /**
  4647. * Creates an Angle object of "radians" radians (float).
  4648. * @param radians the angle in radians
  4649. */
  4650. constructor(radians: number);
  4651. /**
  4652. * Get value in degrees
  4653. * @returns the Angle value in degrees (float)
  4654. */
  4655. degrees(): number;
  4656. /**
  4657. * Get value in radians
  4658. * @returns the Angle value in radians (float)
  4659. */
  4660. radians(): number;
  4661. /**
  4662. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4663. * @param a defines first vector
  4664. * @param b defines second vector
  4665. * @returns a new Angle
  4666. */
  4667. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4668. /**
  4669. * Gets a new Angle object from the given float in radians
  4670. * @param radians defines the angle value in radians
  4671. * @returns a new Angle
  4672. */
  4673. static FromRadians(radians: number): Angle;
  4674. /**
  4675. * Gets a new Angle object from the given float in degrees
  4676. * @param degrees defines the angle value in degrees
  4677. * @returns a new Angle
  4678. */
  4679. static FromDegrees(degrees: number): Angle;
  4680. }
  4681. /**
  4682. * This represents an arc in a 2d space.
  4683. */
  4684. export class Arc2 {
  4685. /** Defines the start point of the arc */
  4686. startPoint: Vector2;
  4687. /** Defines the mid point of the arc */
  4688. midPoint: Vector2;
  4689. /** Defines the end point of the arc */
  4690. endPoint: Vector2;
  4691. /**
  4692. * Defines the center point of the arc.
  4693. */
  4694. centerPoint: Vector2;
  4695. /**
  4696. * Defines the radius of the arc.
  4697. */
  4698. radius: number;
  4699. /**
  4700. * Defines the angle of the arc (from mid point to end point).
  4701. */
  4702. angle: Angle;
  4703. /**
  4704. * Defines the start angle of the arc (from start point to middle point).
  4705. */
  4706. startAngle: Angle;
  4707. /**
  4708. * Defines the orientation of the arc (clock wise/counter clock wise).
  4709. */
  4710. orientation: Orientation;
  4711. /**
  4712. * Creates an Arc object from the three given points : start, middle and end.
  4713. * @param startPoint Defines the start point of the arc
  4714. * @param midPoint Defines the midlle point of the arc
  4715. * @param endPoint Defines the end point of the arc
  4716. */
  4717. constructor(
  4718. /** Defines the start point of the arc */
  4719. startPoint: Vector2,
  4720. /** Defines the mid point of the arc */
  4721. midPoint: Vector2,
  4722. /** Defines the end point of the arc */
  4723. endPoint: Vector2);
  4724. }
  4725. /**
  4726. * Represents a 2D path made up of multiple 2D points
  4727. */
  4728. export class Path2 {
  4729. private _points;
  4730. private _length;
  4731. /**
  4732. * If the path start and end point are the same
  4733. */
  4734. closed: boolean;
  4735. /**
  4736. * Creates a Path2 object from the starting 2D coordinates x and y.
  4737. * @param x the starting points x value
  4738. * @param y the starting points y value
  4739. */
  4740. constructor(x: number, y: number);
  4741. /**
  4742. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4743. * @param x the added points x value
  4744. * @param y the added points y value
  4745. * @returns the updated Path2.
  4746. */
  4747. addLineTo(x: number, y: number): Path2;
  4748. /**
  4749. * 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.
  4750. * @param midX middle point x value
  4751. * @param midY middle point y value
  4752. * @param endX end point x value
  4753. * @param endY end point y value
  4754. * @param numberOfSegments (default: 36)
  4755. * @returns the updated Path2.
  4756. */
  4757. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4758. /**
  4759. * Closes the Path2.
  4760. * @returns the Path2.
  4761. */
  4762. close(): Path2;
  4763. /**
  4764. * Gets the sum of the distance between each sequential point in the path
  4765. * @returns the Path2 total length (float).
  4766. */
  4767. length(): number;
  4768. /**
  4769. * Gets the points which construct the path
  4770. * @returns the Path2 internal array of points.
  4771. */
  4772. getPoints(): Vector2[];
  4773. /**
  4774. * Retreives the point at the distance aways from the starting point
  4775. * @param normalizedLengthPosition the length along the path to retreive the point from
  4776. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4777. */
  4778. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4779. /**
  4780. * Creates a new path starting from an x and y position
  4781. * @param x starting x value
  4782. * @param y starting y value
  4783. * @returns a new Path2 starting at the coordinates (x, y).
  4784. */
  4785. static StartingAt(x: number, y: number): Path2;
  4786. }
  4787. /**
  4788. * Represents a 3D path made up of multiple 3D points
  4789. */
  4790. export class Path3D {
  4791. /**
  4792. * an array of Vector3, the curve axis of the Path3D
  4793. */
  4794. path: Vector3[];
  4795. private _curve;
  4796. private _distances;
  4797. private _tangents;
  4798. private _normals;
  4799. private _binormals;
  4800. private _raw;
  4801. private _alignTangentsWithPath;
  4802. private readonly _pointAtData;
  4803. /**
  4804. * new Path3D(path, normal, raw)
  4805. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4806. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4807. * @param path an array of Vector3, the curve axis of the Path3D
  4808. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4809. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4810. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4811. */
  4812. constructor(
  4813. /**
  4814. * an array of Vector3, the curve axis of the Path3D
  4815. */
  4816. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4817. /**
  4818. * Returns the Path3D array of successive Vector3 designing its curve.
  4819. * @returns the Path3D array of successive Vector3 designing its curve.
  4820. */
  4821. getCurve(): Vector3[];
  4822. /**
  4823. * Returns the Path3D array of successive Vector3 designing its curve.
  4824. * @returns the Path3D array of successive Vector3 designing its curve.
  4825. */
  4826. getPoints(): Vector3[];
  4827. /**
  4828. * @returns the computed length (float) of the path.
  4829. */
  4830. length(): number;
  4831. /**
  4832. * Returns an array populated with tangent vectors on each Path3D curve point.
  4833. * @returns an array populated with tangent vectors on each Path3D curve point.
  4834. */
  4835. getTangents(): Vector3[];
  4836. /**
  4837. * Returns an array populated with normal vectors on each Path3D curve point.
  4838. * @returns an array populated with normal vectors on each Path3D curve point.
  4839. */
  4840. getNormals(): Vector3[];
  4841. /**
  4842. * Returns an array populated with binormal vectors on each Path3D curve point.
  4843. * @returns an array populated with binormal vectors on each Path3D curve point.
  4844. */
  4845. getBinormals(): Vector3[];
  4846. /**
  4847. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4848. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4849. */
  4850. getDistances(): number[];
  4851. /**
  4852. * Returns an interpolated point along this path
  4853. * @param position the position of the point along this path, from 0.0 to 1.0
  4854. * @returns a new Vector3 as the point
  4855. */
  4856. getPointAt(position: number): Vector3;
  4857. /**
  4858. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4859. * @param position the position of the point along this path, from 0.0 to 1.0
  4860. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4861. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4862. */
  4863. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4864. /**
  4865. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4866. * @param position the position of the point along this path, from 0.0 to 1.0
  4867. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4868. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4869. */
  4870. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4871. /**
  4872. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4873. * @param position the position of the point along this path, from 0.0 to 1.0
  4874. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4875. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4876. */
  4877. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4878. /**
  4879. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4882. */
  4883. getDistanceAt(position: number): number;
  4884. /**
  4885. * Returns the array index of the previous point of an interpolated point along this path
  4886. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4887. * @returns the array index
  4888. */
  4889. getPreviousPointIndexAt(position: number): number;
  4890. /**
  4891. * 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)
  4892. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4893. * @returns the sub position
  4894. */
  4895. getSubPositionAt(position: number): number;
  4896. /**
  4897. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4898. * @param target the vector of which to get the closest position to
  4899. * @returns the position of the closest virtual point on this path to the target vector
  4900. */
  4901. getClosestPositionTo(target: Vector3): number;
  4902. /**
  4903. * Returns a sub path (slice) of this path
  4904. * @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
  4905. * @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
  4906. * @returns a sub path (slice) of this path
  4907. */
  4908. slice(start?: number, end?: number): Path3D;
  4909. /**
  4910. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4911. * @param path path which all values are copied into the curves points
  4912. * @param firstNormal which should be projected onto the curve
  4913. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4914. * @returns the same object updated.
  4915. */
  4916. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4917. private _compute;
  4918. private _getFirstNonNullVector;
  4919. private _getLastNonNullVector;
  4920. private _normalVector;
  4921. /**
  4922. * Updates the point at data for an interpolated point along this curve
  4923. * @param position the position of the point along this curve, from 0.0 to 1.0
  4924. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4925. * @returns the (updated) point at data
  4926. */
  4927. private _updatePointAtData;
  4928. /**
  4929. * Updates the point at data from the specified parameters
  4930. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4931. * @param point the interpolated point
  4932. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4933. */
  4934. private _setPointAtData;
  4935. /**
  4936. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4937. */
  4938. private _updateInterpolationMatrix;
  4939. }
  4940. /**
  4941. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4942. * A Curve3 is designed from a series of successive Vector3.
  4943. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4944. */
  4945. export class Curve3 {
  4946. private _points;
  4947. private _length;
  4948. /**
  4949. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4950. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4951. * @param v1 (Vector3) the control point
  4952. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4953. * @param nbPoints (integer) the wanted number of points in the curve
  4954. * @returns the created Curve3
  4955. */
  4956. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4957. /**
  4958. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4959. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4960. * @param v1 (Vector3) the first control point
  4961. * @param v2 (Vector3) the second control point
  4962. * @param v3 (Vector3) the end point of the Cubic Bezier
  4963. * @param nbPoints (integer) the wanted number of points in the curve
  4964. * @returns the created Curve3
  4965. */
  4966. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4967. /**
  4968. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4969. * @param p1 (Vector3) the origin point of the Hermite Spline
  4970. * @param t1 (Vector3) the tangent vector at the origin point
  4971. * @param p2 (Vector3) the end point of the Hermite Spline
  4972. * @param t2 (Vector3) the tangent vector at the end point
  4973. * @param nbPoints (integer) the wanted number of points in the curve
  4974. * @returns the created Curve3
  4975. */
  4976. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4977. /**
  4978. * Returns a Curve3 object along a CatmullRom Spline curve :
  4979. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4980. * @param nbPoints (integer) the wanted number of points between each curve control points
  4981. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4985. /**
  4986. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4987. * A Curve3 is designed from a series of successive Vector3.
  4988. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4989. * @param points points which make up the curve
  4990. */
  4991. constructor(points: Vector3[]);
  4992. /**
  4993. * @returns the Curve3 stored array of successive Vector3
  4994. */
  4995. getPoints(): Vector3[];
  4996. /**
  4997. * @returns the computed length (float) of the curve.
  4998. */
  4999. length(): number;
  5000. /**
  5001. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5002. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5003. * curveA and curveB keep unchanged.
  5004. * @param curve the curve to continue from this curve
  5005. * @returns the newly constructed curve
  5006. */
  5007. continue(curve: DeepImmutable<Curve3>): Curve3;
  5008. private _computeLength;
  5009. }
  5010. }
  5011. declare module BABYLON {
  5012. /**
  5013. * This represents the main contract an easing function should follow.
  5014. * Easing functions are used throughout the animation system.
  5015. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5016. */
  5017. export interface IEasingFunction {
  5018. /**
  5019. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5020. * of the easing function.
  5021. * The link below provides some of the most common examples of easing functions.
  5022. * @see https://easings.net/
  5023. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5024. * @returns the corresponding value on the curve defined by the easing function
  5025. */
  5026. ease(gradient: number): number;
  5027. }
  5028. /**
  5029. * Base class used for every default easing function.
  5030. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5031. */
  5032. export class EasingFunction implements IEasingFunction {
  5033. /**
  5034. * Interpolation follows the mathematical formula associated with the easing function.
  5035. */
  5036. static readonly EASINGMODE_EASEIN: number;
  5037. /**
  5038. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5039. */
  5040. static readonly EASINGMODE_EASEOUT: number;
  5041. /**
  5042. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5043. */
  5044. static readonly EASINGMODE_EASEINOUT: number;
  5045. private _easingMode;
  5046. /**
  5047. * Sets the easing mode of the current function.
  5048. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5049. */
  5050. setEasingMode(easingMode: number): void;
  5051. /**
  5052. * Gets the current easing mode.
  5053. * @returns the easing mode
  5054. */
  5055. getEasingMode(): number;
  5056. /**
  5057. * @hidden
  5058. */
  5059. easeInCore(gradient: number): number;
  5060. /**
  5061. * Given an input gradient between 0 and 1, this returns the corresponding value
  5062. * of the easing function.
  5063. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5064. * @returns the corresponding value on the curve defined by the easing function
  5065. */
  5066. ease(gradient: number): number;
  5067. }
  5068. /**
  5069. * Easing function with a circle shape (see link below).
  5070. * @see https://easings.net/#easeInCirc
  5071. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5072. */
  5073. export class CircleEase extends EasingFunction implements IEasingFunction {
  5074. /** @hidden */
  5075. easeInCore(gradient: number): number;
  5076. }
  5077. /**
  5078. * Easing function with a ease back shape (see link below).
  5079. * @see https://easings.net/#easeInBack
  5080. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5081. */
  5082. export class BackEase extends EasingFunction implements IEasingFunction {
  5083. /** Defines the amplitude of the function */
  5084. amplitude: number;
  5085. /**
  5086. * Instantiates a back ease easing
  5087. * @see https://easings.net/#easeInBack
  5088. * @param amplitude Defines the amplitude of the function
  5089. */
  5090. constructor(
  5091. /** Defines the amplitude of the function */
  5092. amplitude?: number);
  5093. /** @hidden */
  5094. easeInCore(gradient: number): number;
  5095. }
  5096. /**
  5097. * Easing function with a bouncing shape (see link below).
  5098. * @see https://easings.net/#easeInBounce
  5099. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5100. */
  5101. export class BounceEase extends EasingFunction implements IEasingFunction {
  5102. /** Defines the number of bounces */
  5103. bounces: number;
  5104. /** Defines the amplitude of the bounce */
  5105. bounciness: number;
  5106. /**
  5107. * Instantiates a bounce easing
  5108. * @see https://easings.net/#easeInBounce
  5109. * @param bounces Defines the number of bounces
  5110. * @param bounciness Defines the amplitude of the bounce
  5111. */
  5112. constructor(
  5113. /** Defines the number of bounces */
  5114. bounces?: number,
  5115. /** Defines the amplitude of the bounce */
  5116. bounciness?: number);
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a power of 3 shape (see link below).
  5122. * @see https://easings.net/#easeInCubic
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class CubicEase extends EasingFunction implements IEasingFunction {
  5126. /** @hidden */
  5127. easeInCore(gradient: number): number;
  5128. }
  5129. /**
  5130. * Easing function with an elastic shape (see link below).
  5131. * @see https://easings.net/#easeInElastic
  5132. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5133. */
  5134. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5135. /** Defines the number of oscillations*/
  5136. oscillations: number;
  5137. /** Defines the amplitude of the oscillations*/
  5138. springiness: number;
  5139. /**
  5140. * Instantiates an elastic easing function
  5141. * @see https://easings.net/#easeInElastic
  5142. * @param oscillations Defines the number of oscillations
  5143. * @param springiness Defines the amplitude of the oscillations
  5144. */
  5145. constructor(
  5146. /** Defines the number of oscillations*/
  5147. oscillations?: number,
  5148. /** Defines the amplitude of the oscillations*/
  5149. springiness?: number);
  5150. /** @hidden */
  5151. easeInCore(gradient: number): number;
  5152. }
  5153. /**
  5154. * Easing function with an exponential shape (see link below).
  5155. * @see https://easings.net/#easeInExpo
  5156. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5157. */
  5158. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5159. /** Defines the exponent of the function */
  5160. exponent: number;
  5161. /**
  5162. * Instantiates an exponential easing function
  5163. * @see https://easings.net/#easeInExpo
  5164. * @param exponent Defines the exponent of the function
  5165. */
  5166. constructor(
  5167. /** Defines the exponent of the function */
  5168. exponent?: number);
  5169. /** @hidden */
  5170. easeInCore(gradient: number): number;
  5171. }
  5172. /**
  5173. * Easing function with a power shape (see link below).
  5174. * @see https://easings.net/#easeInQuad
  5175. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5176. */
  5177. export class PowerEase extends EasingFunction implements IEasingFunction {
  5178. /** Defines the power of the function */
  5179. power: number;
  5180. /**
  5181. * Instantiates an power base easing function
  5182. * @see https://easings.net/#easeInQuad
  5183. * @param power Defines the power of the function
  5184. */
  5185. constructor(
  5186. /** Defines the power of the function */
  5187. power?: number);
  5188. /** @hidden */
  5189. easeInCore(gradient: number): number;
  5190. }
  5191. /**
  5192. * Easing function with a power of 2 shape (see link below).
  5193. * @see https://easings.net/#easeInQuad
  5194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5195. */
  5196. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5197. /** @hidden */
  5198. easeInCore(gradient: number): number;
  5199. }
  5200. /**
  5201. * Easing function with a power of 4 shape (see link below).
  5202. * @see https://easings.net/#easeInQuart
  5203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5204. */
  5205. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 5 shape (see link below).
  5211. * @see https://easings.net/#easeInQuint
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a sin shape (see link below).
  5220. * @see https://easings.net/#easeInSine
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class SineEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a bezier shape (see link below).
  5229. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5233. /** Defines the x component of the start tangent in the bezier curve */
  5234. x1: number;
  5235. /** Defines the y component of the start tangent in the bezier curve */
  5236. y1: number;
  5237. /** Defines the x component of the end tangent in the bezier curve */
  5238. x2: number;
  5239. /** Defines the y component of the end tangent in the bezier curve */
  5240. y2: number;
  5241. /**
  5242. * Instantiates a bezier function
  5243. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5244. * @param x1 Defines the x component of the start tangent in the bezier curve
  5245. * @param y1 Defines the y component of the start tangent in the bezier curve
  5246. * @param x2 Defines the x component of the end tangent in the bezier curve
  5247. * @param y2 Defines the y component of the end tangent in the bezier curve
  5248. */
  5249. constructor(
  5250. /** Defines the x component of the start tangent in the bezier curve */
  5251. x1?: number,
  5252. /** Defines the y component of the start tangent in the bezier curve */
  5253. y1?: number,
  5254. /** Defines the x component of the end tangent in the bezier curve */
  5255. x2?: number,
  5256. /** Defines the y component of the end tangent in the bezier curve */
  5257. y2?: number);
  5258. /** @hidden */
  5259. easeInCore(gradient: number): number;
  5260. }
  5261. }
  5262. declare module BABYLON {
  5263. /**
  5264. * Class used to hold a RBG color
  5265. */
  5266. export class Color3 {
  5267. /**
  5268. * Defines the red component (between 0 and 1, default is 0)
  5269. */
  5270. r: number;
  5271. /**
  5272. * Defines the green component (between 0 and 1, default is 0)
  5273. */
  5274. g: number;
  5275. /**
  5276. * Defines the blue component (between 0 and 1, default is 0)
  5277. */
  5278. b: number;
  5279. /**
  5280. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5281. * @param r defines the red component (between 0 and 1, default is 0)
  5282. * @param g defines the green component (between 0 and 1, default is 0)
  5283. * @param b defines the blue component (between 0 and 1, default is 0)
  5284. */
  5285. constructor(
  5286. /**
  5287. * Defines the red component (between 0 and 1, default is 0)
  5288. */
  5289. r?: number,
  5290. /**
  5291. * Defines the green component (between 0 and 1, default is 0)
  5292. */
  5293. g?: number,
  5294. /**
  5295. * Defines the blue component (between 0 and 1, default is 0)
  5296. */
  5297. b?: number);
  5298. /**
  5299. * Creates a string with the Color3 current values
  5300. * @returns the string representation of the Color3 object
  5301. */
  5302. toString(): string;
  5303. /**
  5304. * Returns the string "Color3"
  5305. * @returns "Color3"
  5306. */
  5307. getClassName(): string;
  5308. /**
  5309. * Compute the Color3 hash code
  5310. * @returns an unique number that can be used to hash Color3 objects
  5311. */
  5312. getHashCode(): number;
  5313. /**
  5314. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5315. * @param array defines the array where to store the r,g,b components
  5316. * @param index defines an optional index in the target array to define where to start storing values
  5317. * @returns the current Color3 object
  5318. */
  5319. toArray(array: FloatArray, index?: number): Color3;
  5320. /**
  5321. * Returns a new Color4 object from the current Color3 and the given alpha
  5322. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5323. * @returns a new Color4 object
  5324. */
  5325. toColor4(alpha?: number): Color4;
  5326. /**
  5327. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5328. * @returns the new array
  5329. */
  5330. asArray(): number[];
  5331. /**
  5332. * Returns the luminance value
  5333. * @returns a float value
  5334. */
  5335. toLuminance(): number;
  5336. /**
  5337. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5338. * @param otherColor defines the second operand
  5339. * @returns the new Color3 object
  5340. */
  5341. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5342. /**
  5343. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5344. * @param otherColor defines the second operand
  5345. * @param result defines the Color3 object where to store the result
  5346. * @returns the current Color3
  5347. */
  5348. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5349. /**
  5350. * Determines equality between Color3 objects
  5351. * @param otherColor defines the second operand
  5352. * @returns true if the rgb values are equal to the given ones
  5353. */
  5354. equals(otherColor: DeepImmutable<Color3>): boolean;
  5355. /**
  5356. * Determines equality between the current Color3 object and a set of r,b,g values
  5357. * @param r defines the red component to check
  5358. * @param g defines the green component to check
  5359. * @param b defines the blue component to check
  5360. * @returns true if the rgb values are equal to the given ones
  5361. */
  5362. equalsFloats(r: number, g: number, b: number): boolean;
  5363. /**
  5364. * Multiplies in place each rgb value by scale
  5365. * @param scale defines the scaling factor
  5366. * @returns the updated Color3
  5367. */
  5368. scale(scale: number): Color3;
  5369. /**
  5370. * Multiplies the rgb values by scale and stores the result into "result"
  5371. * @param scale defines the scaling factor
  5372. * @param result defines the Color3 object where to store the result
  5373. * @returns the unmodified current Color3
  5374. */
  5375. scaleToRef(scale: number, result: Color3): Color3;
  5376. /**
  5377. * Scale the current Color3 values by a factor and add the result to a given Color3
  5378. * @param scale defines the scale factor
  5379. * @param result defines color to store the result into
  5380. * @returns the unmodified current Color3
  5381. */
  5382. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5383. /**
  5384. * Clamps the rgb values by the min and max values and stores the result into "result"
  5385. * @param min defines minimum clamping value (default is 0)
  5386. * @param max defines maximum clamping value (default is 1)
  5387. * @param result defines color to store the result into
  5388. * @returns the original Color3
  5389. */
  5390. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5391. /**
  5392. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5393. * @param otherColor defines the second operand
  5394. * @returns the new Color3
  5395. */
  5396. add(otherColor: DeepImmutable<Color3>): Color3;
  5397. /**
  5398. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5399. * @param otherColor defines the second operand
  5400. * @param result defines Color3 object to store the result into
  5401. * @returns the unmodified current Color3
  5402. */
  5403. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5404. /**
  5405. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5406. * @param otherColor defines the second operand
  5407. * @returns the new Color3
  5408. */
  5409. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5410. /**
  5411. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5412. * @param otherColor defines the second operand
  5413. * @param result defines Color3 object to store the result into
  5414. * @returns the unmodified current Color3
  5415. */
  5416. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5417. /**
  5418. * Copy the current object
  5419. * @returns a new Color3 copied the current one
  5420. */
  5421. clone(): Color3;
  5422. /**
  5423. * Copies the rgb values from the source in the current Color3
  5424. * @param source defines the source Color3 object
  5425. * @returns the updated Color3 object
  5426. */
  5427. copyFrom(source: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Updates the Color3 rgb values from the given floats
  5430. * @param r defines the red component to read from
  5431. * @param g defines the green component to read from
  5432. * @param b defines the blue component to read from
  5433. * @returns the current Color3 object
  5434. */
  5435. copyFromFloats(r: number, g: number, b: number): Color3;
  5436. /**
  5437. * Updates the Color3 rgb values from the given floats
  5438. * @param r defines the red component to read from
  5439. * @param g defines the green component to read from
  5440. * @param b defines the blue component to read from
  5441. * @returns the current Color3 object
  5442. */
  5443. set(r: number, g: number, b: number): Color3;
  5444. /**
  5445. * Compute the Color3 hexadecimal code as a string
  5446. * @returns a string containing the hexadecimal representation of the Color3 object
  5447. */
  5448. toHexString(): string;
  5449. /**
  5450. * Computes a new Color3 converted from the current one to linear space
  5451. * @returns a new Color3 object
  5452. */
  5453. toLinearSpace(): Color3;
  5454. /**
  5455. * Converts current color in rgb space to HSV values
  5456. * @returns a new color3 representing the HSV values
  5457. */
  5458. toHSV(): Color3;
  5459. /**
  5460. * Converts current color in rgb space to HSV values
  5461. * @param result defines the Color3 where to store the HSV values
  5462. */
  5463. toHSVToRef(result: Color3): void;
  5464. /**
  5465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5466. * @param convertedColor defines the Color3 object where to store the linear space version
  5467. * @returns the unmodified Color3
  5468. */
  5469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5470. /**
  5471. * Computes a new Color3 converted from the current one to gamma space
  5472. * @returns a new Color3 object
  5473. */
  5474. toGammaSpace(): Color3;
  5475. /**
  5476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5477. * @param convertedColor defines the Color3 object where to store the gamma space version
  5478. * @returns the unmodified Color3
  5479. */
  5480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5481. private static _BlackReadOnly;
  5482. /**
  5483. * Convert Hue, saturation and value to a Color3 (RGB)
  5484. * @param hue defines the hue
  5485. * @param saturation defines the saturation
  5486. * @param value defines the value
  5487. * @param result defines the Color3 where to store the RGB values
  5488. */
  5489. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5490. /**
  5491. * Creates a new Color3 from the string containing valid hexadecimal values
  5492. * @param hex defines a string containing valid hexadecimal values
  5493. * @returns a new Color3 object
  5494. */
  5495. static FromHexString(hex: string): Color3;
  5496. /**
  5497. * Creates a new Color3 from the starting index of the given array
  5498. * @param array defines the source array
  5499. * @param offset defines an offset in the source array
  5500. * @returns a new Color3 object
  5501. */
  5502. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5503. /**
  5504. * Creates a new Color3 from integer values (< 256)
  5505. * @param r defines the red component to read from (value between 0 and 255)
  5506. * @param g defines the green component to read from (value between 0 and 255)
  5507. * @param b defines the blue component to read from (value between 0 and 255)
  5508. * @returns a new Color3 object
  5509. */
  5510. static FromInts(r: number, g: number, b: number): Color3;
  5511. /**
  5512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5513. * @param start defines the start Color3 value
  5514. * @param end defines the end Color3 value
  5515. * @param amount defines the gradient value between start and end
  5516. * @returns a new Color3 object
  5517. */
  5518. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5519. /**
  5520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5521. * @param left defines the start value
  5522. * @param right defines the end value
  5523. * @param amount defines the gradient factor
  5524. * @param result defines the Color3 object where to store the result
  5525. */
  5526. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5527. /**
  5528. * Returns a Color3 value containing a red color
  5529. * @returns a new Color3 object
  5530. */
  5531. static Red(): Color3;
  5532. /**
  5533. * Returns a Color3 value containing a green color
  5534. * @returns a new Color3 object
  5535. */
  5536. static Green(): Color3;
  5537. /**
  5538. * Returns a Color3 value containing a blue color
  5539. * @returns a new Color3 object
  5540. */
  5541. static Blue(): Color3;
  5542. /**
  5543. * Returns a Color3 value containing a black color
  5544. * @returns a new Color3 object
  5545. */
  5546. static Black(): Color3;
  5547. /**
  5548. * Gets a Color3 value containing a black color that must not be updated
  5549. */
  5550. static get BlackReadOnly(): DeepImmutable<Color3>;
  5551. /**
  5552. * Returns a Color3 value containing a white color
  5553. * @returns a new Color3 object
  5554. */
  5555. static White(): Color3;
  5556. /**
  5557. * Returns a Color3 value containing a purple color
  5558. * @returns a new Color3 object
  5559. */
  5560. static Purple(): Color3;
  5561. /**
  5562. * Returns a Color3 value containing a magenta color
  5563. * @returns a new Color3 object
  5564. */
  5565. static Magenta(): Color3;
  5566. /**
  5567. * Returns a Color3 value containing a yellow color
  5568. * @returns a new Color3 object
  5569. */
  5570. static Yellow(): Color3;
  5571. /**
  5572. * Returns a Color3 value containing a gray color
  5573. * @returns a new Color3 object
  5574. */
  5575. static Gray(): Color3;
  5576. /**
  5577. * Returns a Color3 value containing a teal color
  5578. * @returns a new Color3 object
  5579. */
  5580. static Teal(): Color3;
  5581. /**
  5582. * Returns a Color3 value containing a random color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Random(): Color3;
  5586. }
  5587. /**
  5588. * Class used to hold a RBGA color
  5589. */
  5590. export class Color4 {
  5591. /**
  5592. * Defines the red component (between 0 and 1, default is 0)
  5593. */
  5594. r: number;
  5595. /**
  5596. * Defines the green component (between 0 and 1, default is 0)
  5597. */
  5598. g: number;
  5599. /**
  5600. * Defines the blue component (between 0 and 1, default is 0)
  5601. */
  5602. b: number;
  5603. /**
  5604. * Defines the alpha component (between 0 and 1, default is 1)
  5605. */
  5606. a: number;
  5607. /**
  5608. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5609. * @param r defines the red component (between 0 and 1, default is 0)
  5610. * @param g defines the green component (between 0 and 1, default is 0)
  5611. * @param b defines the blue component (between 0 and 1, default is 0)
  5612. * @param a defines the alpha component (between 0 and 1, default is 1)
  5613. */
  5614. constructor(
  5615. /**
  5616. * Defines the red component (between 0 and 1, default is 0)
  5617. */
  5618. r?: number,
  5619. /**
  5620. * Defines the green component (between 0 and 1, default is 0)
  5621. */
  5622. g?: number,
  5623. /**
  5624. * Defines the blue component (between 0 and 1, default is 0)
  5625. */
  5626. b?: number,
  5627. /**
  5628. * Defines the alpha component (between 0 and 1, default is 1)
  5629. */
  5630. a?: number);
  5631. /**
  5632. * Adds in place the given Color4 values to the current Color4 object
  5633. * @param right defines the second operand
  5634. * @returns the current updated Color4 object
  5635. */
  5636. addInPlace(right: DeepImmutable<Color4>): Color4;
  5637. /**
  5638. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5639. * @returns the new array
  5640. */
  5641. asArray(): number[];
  5642. /**
  5643. * Stores from the starting index in the given array the Color4 successive values
  5644. * @param array defines the array where to store the r,g,b components
  5645. * @param index defines an optional index in the target array to define where to start storing values
  5646. * @returns the current Color4 object
  5647. */
  5648. toArray(array: number[], index?: number): Color4;
  5649. /**
  5650. * Determines equality between Color4 objects
  5651. * @param otherColor defines the second operand
  5652. * @returns true if the rgba values are equal to the given ones
  5653. */
  5654. equals(otherColor: DeepImmutable<Color4>): boolean;
  5655. /**
  5656. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5657. * @param right defines the second operand
  5658. * @returns a new Color4 object
  5659. */
  5660. add(right: DeepImmutable<Color4>): Color4;
  5661. /**
  5662. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5663. * @param right defines the second operand
  5664. * @returns a new Color4 object
  5665. */
  5666. subtract(right: DeepImmutable<Color4>): Color4;
  5667. /**
  5668. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5669. * @param right defines the second operand
  5670. * @param result defines the Color4 object where to store the result
  5671. * @returns the current Color4 object
  5672. */
  5673. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5674. /**
  5675. * Creates a new Color4 with the current Color4 values multiplied by scale
  5676. * @param scale defines the scaling factor to apply
  5677. * @returns a new Color4 object
  5678. */
  5679. scale(scale: number): Color4;
  5680. /**
  5681. * Multiplies the current Color4 values by scale and stores the result in "result"
  5682. * @param scale defines the scaling factor to apply
  5683. * @param result defines the Color4 object where to store the result
  5684. * @returns the current unmodified Color4
  5685. */
  5686. scaleToRef(scale: number, result: Color4): Color4;
  5687. /**
  5688. * Scale the current Color4 values by a factor and add the result to a given Color4
  5689. * @param scale defines the scale factor
  5690. * @param result defines the Color4 object where to store the result
  5691. * @returns the unmodified current Color4
  5692. */
  5693. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5694. /**
  5695. * Clamps the rgb values by the min and max values and stores the result into "result"
  5696. * @param min defines minimum clamping value (default is 0)
  5697. * @param max defines maximum clamping value (default is 1)
  5698. * @param result defines color to store the result into.
  5699. * @returns the cuurent Color4
  5700. */
  5701. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5702. /**
  5703. * Multipy an Color4 value by another and return a new Color4 object
  5704. * @param color defines the Color4 value to multiply by
  5705. * @returns a new Color4 object
  5706. */
  5707. multiply(color: Color4): Color4;
  5708. /**
  5709. * Multipy a Color4 value by another and push the result in a reference value
  5710. * @param color defines the Color4 value to multiply by
  5711. * @param result defines the Color4 to fill the result in
  5712. * @returns the result Color4
  5713. */
  5714. multiplyToRef(color: Color4, result: Color4): Color4;
  5715. /**
  5716. * Creates a string with the Color4 current values
  5717. * @returns the string representation of the Color4 object
  5718. */
  5719. toString(): string;
  5720. /**
  5721. * Returns the string "Color4"
  5722. * @returns "Color4"
  5723. */
  5724. getClassName(): string;
  5725. /**
  5726. * Compute the Color4 hash code
  5727. * @returns an unique number that can be used to hash Color4 objects
  5728. */
  5729. getHashCode(): number;
  5730. /**
  5731. * Creates a new Color4 copied from the current one
  5732. * @returns a new Color4 object
  5733. */
  5734. clone(): Color4;
  5735. /**
  5736. * Copies the given Color4 values into the current one
  5737. * @param source defines the source Color4 object
  5738. * @returns the current updated Color4 object
  5739. */
  5740. copyFrom(source: Color4): Color4;
  5741. /**
  5742. * Copies the given float values into the current one
  5743. * @param r defines the red component to read from
  5744. * @param g defines the green component to read from
  5745. * @param b defines the blue component to read from
  5746. * @param a defines the alpha component to read from
  5747. * @returns the current updated Color4 object
  5748. */
  5749. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5750. /**
  5751. * Copies the given float values into the current one
  5752. * @param r defines the red component to read from
  5753. * @param g defines the green component to read from
  5754. * @param b defines the blue component to read from
  5755. * @param a defines the alpha component to read from
  5756. * @returns the current updated Color4 object
  5757. */
  5758. set(r: number, g: number, b: number, a: number): Color4;
  5759. /**
  5760. * Compute the Color4 hexadecimal code as a string
  5761. * @returns a string containing the hexadecimal representation of the Color4 object
  5762. */
  5763. toHexString(): string;
  5764. /**
  5765. * Computes a new Color4 converted from the current one to linear space
  5766. * @returns a new Color4 object
  5767. */
  5768. toLinearSpace(): Color4;
  5769. /**
  5770. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5771. * @param convertedColor defines the Color4 object where to store the linear space version
  5772. * @returns the unmodified Color4
  5773. */
  5774. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5775. /**
  5776. * Computes a new Color4 converted from the current one to gamma space
  5777. * @returns a new Color4 object
  5778. */
  5779. toGammaSpace(): Color4;
  5780. /**
  5781. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5782. * @param convertedColor defines the Color4 object where to store the gamma space version
  5783. * @returns the unmodified Color4
  5784. */
  5785. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5786. /**
  5787. * Creates a new Color4 from the string containing valid hexadecimal values
  5788. * @param hex defines a string containing valid hexadecimal values
  5789. * @returns a new Color4 object
  5790. */
  5791. static FromHexString(hex: string): Color4;
  5792. /**
  5793. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5794. * @param left defines the start value
  5795. * @param right defines the end value
  5796. * @param amount defines the gradient factor
  5797. * @returns a new Color4 object
  5798. */
  5799. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5800. /**
  5801. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5802. * @param left defines the start value
  5803. * @param right defines the end value
  5804. * @param amount defines the gradient factor
  5805. * @param result defines the Color4 object where to store data
  5806. */
  5807. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5808. /**
  5809. * Creates a new Color4 from a Color3 and an alpha value
  5810. * @param color3 defines the source Color3 to read from
  5811. * @param alpha defines the alpha component (1.0 by default)
  5812. * @returns a new Color4 object
  5813. */
  5814. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5815. /**
  5816. * Creates a new Color4 from the starting index element of the given array
  5817. * @param array defines the source array to read from
  5818. * @param offset defines the offset in the source array
  5819. * @returns a new Color4 object
  5820. */
  5821. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5822. /**
  5823. * Creates a new Color3 from integer values (< 256)
  5824. * @param r defines the red component to read from (value between 0 and 255)
  5825. * @param g defines the green component to read from (value between 0 and 255)
  5826. * @param b defines the blue component to read from (value between 0 and 255)
  5827. * @param a defines the alpha component to read from (value between 0 and 255)
  5828. * @returns a new Color3 object
  5829. */
  5830. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5831. /**
  5832. * Check the content of a given array and convert it to an array containing RGBA data
  5833. * If the original array was already containing count * 4 values then it is returned directly
  5834. * @param colors defines the array to check
  5835. * @param count defines the number of RGBA data to expect
  5836. * @returns an array containing count * 4 values (RGBA)
  5837. */
  5838. static CheckColors4(colors: number[], count: number): number[];
  5839. }
  5840. /**
  5841. * @hidden
  5842. */
  5843. export class TmpColors {
  5844. static Color3: Color3[];
  5845. static Color4: Color4[];
  5846. }
  5847. }
  5848. declare module BABYLON {
  5849. /**
  5850. * Defines an interface which represents an animation key frame
  5851. */
  5852. export interface IAnimationKey {
  5853. /**
  5854. * Frame of the key frame
  5855. */
  5856. frame: number;
  5857. /**
  5858. * Value at the specifies key frame
  5859. */
  5860. value: any;
  5861. /**
  5862. * The input tangent for the cubic hermite spline
  5863. */
  5864. inTangent?: any;
  5865. /**
  5866. * The output tangent for the cubic hermite spline
  5867. */
  5868. outTangent?: any;
  5869. /**
  5870. * The animation interpolation type
  5871. */
  5872. interpolation?: AnimationKeyInterpolation;
  5873. }
  5874. /**
  5875. * Enum for the animation key frame interpolation type
  5876. */
  5877. export enum AnimationKeyInterpolation {
  5878. /**
  5879. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5880. */
  5881. STEP = 1
  5882. }
  5883. }
  5884. declare module BABYLON {
  5885. /**
  5886. * Represents the range of an animation
  5887. */
  5888. export class AnimationRange {
  5889. /**The name of the animation range**/
  5890. name: string;
  5891. /**The starting frame of the animation */
  5892. from: number;
  5893. /**The ending frame of the animation*/
  5894. to: number;
  5895. /**
  5896. * Initializes the range of an animation
  5897. * @param name The name of the animation range
  5898. * @param from The starting frame of the animation
  5899. * @param to The ending frame of the animation
  5900. */
  5901. constructor(
  5902. /**The name of the animation range**/
  5903. name: string,
  5904. /**The starting frame of the animation */
  5905. from: number,
  5906. /**The ending frame of the animation*/
  5907. to: number);
  5908. /**
  5909. * Makes a copy of the animation range
  5910. * @returns A copy of the animation range
  5911. */
  5912. clone(): AnimationRange;
  5913. }
  5914. }
  5915. declare module BABYLON {
  5916. /**
  5917. * Composed of a frame, and an action function
  5918. */
  5919. export class AnimationEvent {
  5920. /** The frame for which the event is triggered **/
  5921. frame: number;
  5922. /** The event to perform when triggered **/
  5923. action: (currentFrame: number) => void;
  5924. /** Specifies if the event should be triggered only once**/
  5925. onlyOnce?: boolean | undefined;
  5926. /**
  5927. * Specifies if the animation event is done
  5928. */
  5929. isDone: boolean;
  5930. /**
  5931. * Initializes the animation event
  5932. * @param frame The frame for which the event is triggered
  5933. * @param action The event to perform when triggered
  5934. * @param onlyOnce Specifies if the event should be triggered only once
  5935. */
  5936. constructor(
  5937. /** The frame for which the event is triggered **/
  5938. frame: number,
  5939. /** The event to perform when triggered **/
  5940. action: (currentFrame: number) => void,
  5941. /** Specifies if the event should be triggered only once**/
  5942. onlyOnce?: boolean | undefined);
  5943. /** @hidden */
  5944. _clone(): AnimationEvent;
  5945. }
  5946. }
  5947. declare module BABYLON {
  5948. /**
  5949. * Interface used to define a behavior
  5950. */
  5951. export interface Behavior<T> {
  5952. /** gets or sets behavior's name */
  5953. name: string;
  5954. /**
  5955. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5956. */
  5957. init(): void;
  5958. /**
  5959. * Called when the behavior is attached to a target
  5960. * @param target defines the target where the behavior is attached to
  5961. */
  5962. attach(target: T): void;
  5963. /**
  5964. * Called when the behavior is detached from its target
  5965. */
  5966. detach(): void;
  5967. }
  5968. /**
  5969. * Interface implemented by classes supporting behaviors
  5970. */
  5971. export interface IBehaviorAware<T> {
  5972. /**
  5973. * Attach a behavior
  5974. * @param behavior defines the behavior to attach
  5975. * @returns the current host
  5976. */
  5977. addBehavior(behavior: Behavior<T>): T;
  5978. /**
  5979. * Remove a behavior from the current object
  5980. * @param behavior defines the behavior to detach
  5981. * @returns the current host
  5982. */
  5983. removeBehavior(behavior: Behavior<T>): T;
  5984. /**
  5985. * Gets a behavior using its name to search
  5986. * @param name defines the name to search
  5987. * @returns the behavior or null if not found
  5988. */
  5989. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5990. }
  5991. }
  5992. declare module BABYLON {
  5993. /**
  5994. * Defines an array and its length.
  5995. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5996. */
  5997. export interface ISmartArrayLike<T> {
  5998. /**
  5999. * The data of the array.
  6000. */
  6001. data: Array<T>;
  6002. /**
  6003. * The active length of the array.
  6004. */
  6005. length: number;
  6006. }
  6007. /**
  6008. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6009. */
  6010. export class SmartArray<T> implements ISmartArrayLike<T> {
  6011. /**
  6012. * The full set of data from the array.
  6013. */
  6014. data: Array<T>;
  6015. /**
  6016. * The active length of the array.
  6017. */
  6018. length: number;
  6019. protected _id: number;
  6020. /**
  6021. * Instantiates a Smart Array.
  6022. * @param capacity defines the default capacity of the array.
  6023. */
  6024. constructor(capacity: number);
  6025. /**
  6026. * Pushes a value at the end of the active data.
  6027. * @param value defines the object to push in the array.
  6028. */
  6029. push(value: T): void;
  6030. /**
  6031. * Iterates over the active data and apply the lambda to them.
  6032. * @param func defines the action to apply on each value.
  6033. */
  6034. forEach(func: (content: T) => void): void;
  6035. /**
  6036. * Sorts the full sets of data.
  6037. * @param compareFn defines the comparison function to apply.
  6038. */
  6039. sort(compareFn: (a: T, b: T) => number): void;
  6040. /**
  6041. * Resets the active data to an empty array.
  6042. */
  6043. reset(): void;
  6044. /**
  6045. * Releases all the data from the array as well as the array.
  6046. */
  6047. dispose(): void;
  6048. /**
  6049. * Concats the active data with a given array.
  6050. * @param array defines the data to concatenate with.
  6051. */
  6052. concat(array: any): void;
  6053. /**
  6054. * Returns the position of a value in the active data.
  6055. * @param value defines the value to find the index for
  6056. * @returns the index if found in the active data otherwise -1
  6057. */
  6058. indexOf(value: T): number;
  6059. /**
  6060. * Returns whether an element is part of the active data.
  6061. * @param value defines the value to look for
  6062. * @returns true if found in the active data otherwise false
  6063. */
  6064. contains(value: T): boolean;
  6065. private static _GlobalId;
  6066. }
  6067. /**
  6068. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6069. * The data in this array can only be present once
  6070. */
  6071. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6072. private _duplicateId;
  6073. /**
  6074. * Pushes a value at the end of the active data.
  6075. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6076. * @param value defines the object to push in the array.
  6077. */
  6078. push(value: T): void;
  6079. /**
  6080. * Pushes a value at the end of the active data.
  6081. * If the data is already present, it won t be added again
  6082. * @param value defines the object to push in the array.
  6083. * @returns true if added false if it was already present
  6084. */
  6085. pushNoDuplicate(value: T): boolean;
  6086. /**
  6087. * Resets the active data to an empty array.
  6088. */
  6089. reset(): void;
  6090. /**
  6091. * Concats the active data with a given array.
  6092. * This ensures no dupplicate will be present in the result.
  6093. * @param array defines the data to concatenate with.
  6094. */
  6095. concatWithNoDuplicate(array: any): void;
  6096. }
  6097. }
  6098. declare module BABYLON {
  6099. /**
  6100. * @ignore
  6101. * This is a list of all the different input types that are available in the application.
  6102. * Fo instance: ArcRotateCameraGamepadInput...
  6103. */
  6104. export var CameraInputTypes: {};
  6105. /**
  6106. * This is the contract to implement in order to create a new input class.
  6107. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6108. */
  6109. export interface ICameraInput<TCamera extends Camera> {
  6110. /**
  6111. * Defines the camera the input is attached to.
  6112. */
  6113. camera: Nullable<TCamera>;
  6114. /**
  6115. * Gets the class name of the current intput.
  6116. * @returns the class name
  6117. */
  6118. getClassName(): string;
  6119. /**
  6120. * Get the friendly name associated with the input class.
  6121. * @returns the input friendly name
  6122. */
  6123. getSimpleName(): string;
  6124. /**
  6125. * Attach the input controls to a specific dom element to get the input from.
  6126. * @param element Defines the element the controls should be listened from
  6127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6128. */
  6129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6130. /**
  6131. * Detach the current controls from the specified dom element.
  6132. * @param element Defines the element to stop listening the inputs from
  6133. */
  6134. detachControl(element: Nullable<HTMLElement>): void;
  6135. /**
  6136. * Update the current camera state depending on the inputs that have been used this frame.
  6137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6138. */
  6139. checkInputs?: () => void;
  6140. }
  6141. /**
  6142. * Represents a map of input types to input instance or input index to input instance.
  6143. */
  6144. export interface CameraInputsMap<TCamera extends Camera> {
  6145. /**
  6146. * Accessor to the input by input type.
  6147. */
  6148. [name: string]: ICameraInput<TCamera>;
  6149. /**
  6150. * Accessor to the input by input index.
  6151. */
  6152. [idx: number]: ICameraInput<TCamera>;
  6153. }
  6154. /**
  6155. * This represents the input manager used within a camera.
  6156. * It helps dealing with all the different kind of input attached to a camera.
  6157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6158. */
  6159. export class CameraInputsManager<TCamera extends Camera> {
  6160. /**
  6161. * Defines the list of inputs attahed to the camera.
  6162. */
  6163. attached: CameraInputsMap<TCamera>;
  6164. /**
  6165. * Defines the dom element the camera is collecting inputs from.
  6166. * This is null if the controls have not been attached.
  6167. */
  6168. attachedElement: Nullable<HTMLElement>;
  6169. /**
  6170. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6171. */
  6172. noPreventDefault: boolean;
  6173. /**
  6174. * Defined the camera the input manager belongs to.
  6175. */
  6176. camera: TCamera;
  6177. /**
  6178. * Update the current camera state depending on the inputs that have been used this frame.
  6179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6180. */
  6181. checkInputs: () => void;
  6182. /**
  6183. * Instantiate a new Camera Input Manager.
  6184. * @param camera Defines the camera the input manager blongs to
  6185. */
  6186. constructor(camera: TCamera);
  6187. /**
  6188. * Add an input method to a camera
  6189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6190. * @param input camera input method
  6191. */
  6192. add(input: ICameraInput<TCamera>): void;
  6193. /**
  6194. * Remove a specific input method from a camera
  6195. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6196. * @param inputToRemove camera input method
  6197. */
  6198. remove(inputToRemove: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input type from a camera
  6201. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6202. * @param inputType the type of the input to remove
  6203. */
  6204. removeByType(inputType: string): void;
  6205. private _addCheckInputs;
  6206. /**
  6207. * Attach the input controls to the currently attached dom element to listen the events from.
  6208. * @param input Defines the input to attach
  6209. */
  6210. attachInput(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6213. * @param element Defines the dom element to collect the events from
  6214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6215. */
  6216. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6217. /**
  6218. * Detach the current manager inputs controls from a specific dom element.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6221. */
  6222. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6223. /**
  6224. * Rebuild the dynamic inputCheck function from the current list of
  6225. * defined inputs in the manager.
  6226. */
  6227. rebuildInputCheck(): void;
  6228. /**
  6229. * Remove all attached input methods from a camera
  6230. */
  6231. clear(): void;
  6232. /**
  6233. * Serialize the current input manager attached to a camera.
  6234. * This ensures than once parsed,
  6235. * the input associated to the camera will be identical to the current ones
  6236. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6237. */
  6238. serialize(serializedCamera: any): void;
  6239. /**
  6240. * Parses an input manager serialized JSON to restore the previous list of inputs
  6241. * and states associated to a camera.
  6242. * @param parsedCamera Defines the JSON to parse
  6243. */
  6244. parse(parsedCamera: any): void;
  6245. }
  6246. }
  6247. declare module BABYLON {
  6248. /**
  6249. * Class used to store data that will be store in GPU memory
  6250. */
  6251. export class Buffer {
  6252. private _engine;
  6253. private _buffer;
  6254. /** @hidden */
  6255. _data: Nullable<DataArray>;
  6256. private _updatable;
  6257. private _instanced;
  6258. private _divisor;
  6259. /**
  6260. * Gets the byte stride.
  6261. */
  6262. readonly byteStride: number;
  6263. /**
  6264. * Constructor
  6265. * @param engine the engine
  6266. * @param data the data to use for this buffer
  6267. * @param updatable whether the data is updatable
  6268. * @param stride the stride (optional)
  6269. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6270. * @param instanced whether the buffer is instanced (optional)
  6271. * @param useBytes set to true if the stride in in bytes (optional)
  6272. * @param divisor sets an optional divisor for instances (1 by default)
  6273. */
  6274. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6275. /**
  6276. * Create a new VertexBuffer based on the current buffer
  6277. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6278. * @param offset defines offset in the buffer (0 by default)
  6279. * @param size defines the size in floats of attributes (position is 3 for instance)
  6280. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6281. * @param instanced defines if the vertex buffer contains indexed data
  6282. * @param useBytes defines if the offset and stride are in bytes *
  6283. * @param divisor sets an optional divisor for instances (1 by default)
  6284. * @returns the new vertex buffer
  6285. */
  6286. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6287. /**
  6288. * Gets a boolean indicating if the Buffer is updatable?
  6289. * @returns true if the buffer is updatable
  6290. */
  6291. isUpdatable(): boolean;
  6292. /**
  6293. * Gets current buffer's data
  6294. * @returns a DataArray or null
  6295. */
  6296. getData(): Nullable<DataArray>;
  6297. /**
  6298. * Gets underlying native buffer
  6299. * @returns underlying native buffer
  6300. */
  6301. getBuffer(): Nullable<DataBuffer>;
  6302. /**
  6303. * Gets the stride in float32 units (i.e. byte stride / 4).
  6304. * May not be an integer if the byte stride is not divisible by 4.
  6305. * @returns the stride in float32 units
  6306. * @deprecated Please use byteStride instead.
  6307. */
  6308. getStrideSize(): number;
  6309. /**
  6310. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6311. * @param data defines the data to store
  6312. */
  6313. create(data?: Nullable<DataArray>): void;
  6314. /** @hidden */
  6315. _rebuild(): void;
  6316. /**
  6317. * Update current buffer data
  6318. * @param data defines the data to store
  6319. */
  6320. update(data: DataArray): void;
  6321. /**
  6322. * Updates the data directly.
  6323. * @param data the new data
  6324. * @param offset the new offset
  6325. * @param vertexCount the vertex count (optional)
  6326. * @param useBytes set to true if the offset is in bytes
  6327. */
  6328. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6329. /**
  6330. * Release all resources
  6331. */
  6332. dispose(): void;
  6333. }
  6334. /**
  6335. * Specialized buffer used to store vertex data
  6336. */
  6337. export class VertexBuffer {
  6338. /** @hidden */
  6339. _buffer: Buffer;
  6340. private _kind;
  6341. private _size;
  6342. private _ownsBuffer;
  6343. private _instanced;
  6344. private _instanceDivisor;
  6345. /**
  6346. * The byte type.
  6347. */
  6348. static readonly BYTE: number;
  6349. /**
  6350. * The unsigned byte type.
  6351. */
  6352. static readonly UNSIGNED_BYTE: number;
  6353. /**
  6354. * The short type.
  6355. */
  6356. static readonly SHORT: number;
  6357. /**
  6358. * The unsigned short type.
  6359. */
  6360. static readonly UNSIGNED_SHORT: number;
  6361. /**
  6362. * The integer type.
  6363. */
  6364. static readonly INT: number;
  6365. /**
  6366. * The unsigned integer type.
  6367. */
  6368. static readonly UNSIGNED_INT: number;
  6369. /**
  6370. * The float type.
  6371. */
  6372. static readonly FLOAT: number;
  6373. /**
  6374. * Gets or sets the instance divisor when in instanced mode
  6375. */
  6376. get instanceDivisor(): number;
  6377. set instanceDivisor(value: number);
  6378. /**
  6379. * Gets the byte stride.
  6380. */
  6381. readonly byteStride: number;
  6382. /**
  6383. * Gets the byte offset.
  6384. */
  6385. readonly byteOffset: number;
  6386. /**
  6387. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6388. */
  6389. readonly normalized: boolean;
  6390. /**
  6391. * Gets the data type of each component in the array.
  6392. */
  6393. readonly type: number;
  6394. /**
  6395. * Constructor
  6396. * @param engine the engine
  6397. * @param data the data to use for this vertex buffer
  6398. * @param kind the vertex buffer kind
  6399. * @param updatable whether the data is updatable
  6400. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6401. * @param stride the stride (optional)
  6402. * @param instanced whether the buffer is instanced (optional)
  6403. * @param offset the offset of the data (optional)
  6404. * @param size the number of components (optional)
  6405. * @param type the type of the component (optional)
  6406. * @param normalized whether the data contains normalized data (optional)
  6407. * @param useBytes set to true if stride and offset are in bytes (optional)
  6408. * @param divisor defines the instance divisor to use (1 by default)
  6409. */
  6410. 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);
  6411. /** @hidden */
  6412. _rebuild(): void;
  6413. /**
  6414. * Returns the kind of the VertexBuffer (string)
  6415. * @returns a string
  6416. */
  6417. getKind(): string;
  6418. /**
  6419. * Gets a boolean indicating if the VertexBuffer is updatable?
  6420. * @returns true if the buffer is updatable
  6421. */
  6422. isUpdatable(): boolean;
  6423. /**
  6424. * Gets current buffer's data
  6425. * @returns a DataArray or null
  6426. */
  6427. getData(): Nullable<DataArray>;
  6428. /**
  6429. * Gets underlying native buffer
  6430. * @returns underlying native buffer
  6431. */
  6432. getBuffer(): Nullable<DataBuffer>;
  6433. /**
  6434. * Gets the stride in float32 units (i.e. byte stride / 4).
  6435. * May not be an integer if the byte stride is not divisible by 4.
  6436. * @returns the stride in float32 units
  6437. * @deprecated Please use byteStride instead.
  6438. */
  6439. getStrideSize(): number;
  6440. /**
  6441. * Returns the offset as a multiple of the type byte length.
  6442. * @returns the offset in bytes
  6443. * @deprecated Please use byteOffset instead.
  6444. */
  6445. getOffset(): number;
  6446. /**
  6447. * Returns the number of components per vertex attribute (integer)
  6448. * @returns the size in float
  6449. */
  6450. getSize(): number;
  6451. /**
  6452. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6453. * @returns true if this buffer is instanced
  6454. */
  6455. getIsInstanced(): boolean;
  6456. /**
  6457. * Returns the instancing divisor, zero for non-instanced (integer).
  6458. * @returns a number
  6459. */
  6460. getInstanceDivisor(): number;
  6461. /**
  6462. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6463. * @param data defines the data to store
  6464. */
  6465. create(data?: DataArray): void;
  6466. /**
  6467. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6468. * This function will create a new buffer if the current one is not updatable
  6469. * @param data defines the data to store
  6470. */
  6471. update(data: DataArray): void;
  6472. /**
  6473. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6474. * Returns the directly updated WebGLBuffer.
  6475. * @param data the new data
  6476. * @param offset the new offset
  6477. * @param useBytes set to true if the offset is in bytes
  6478. */
  6479. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6480. /**
  6481. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6482. */
  6483. dispose(): void;
  6484. /**
  6485. * Enumerates each value of this vertex buffer as numbers.
  6486. * @param count the number of values to enumerate
  6487. * @param callback the callback function called for each value
  6488. */
  6489. forEach(count: number, callback: (value: number, index: number) => void): void;
  6490. /**
  6491. * Positions
  6492. */
  6493. static readonly PositionKind: string;
  6494. /**
  6495. * Normals
  6496. */
  6497. static readonly NormalKind: string;
  6498. /**
  6499. * Tangents
  6500. */
  6501. static readonly TangentKind: string;
  6502. /**
  6503. * Texture coordinates
  6504. */
  6505. static readonly UVKind: string;
  6506. /**
  6507. * Texture coordinates 2
  6508. */
  6509. static readonly UV2Kind: string;
  6510. /**
  6511. * Texture coordinates 3
  6512. */
  6513. static readonly UV3Kind: string;
  6514. /**
  6515. * Texture coordinates 4
  6516. */
  6517. static readonly UV4Kind: string;
  6518. /**
  6519. * Texture coordinates 5
  6520. */
  6521. static readonly UV5Kind: string;
  6522. /**
  6523. * Texture coordinates 6
  6524. */
  6525. static readonly UV6Kind: string;
  6526. /**
  6527. * Colors
  6528. */
  6529. static readonly ColorKind: string;
  6530. /**
  6531. * Matrix indices (for bones)
  6532. */
  6533. static readonly MatricesIndicesKind: string;
  6534. /**
  6535. * Matrix weights (for bones)
  6536. */
  6537. static readonly MatricesWeightsKind: string;
  6538. /**
  6539. * Additional matrix indices (for bones)
  6540. */
  6541. static readonly MatricesIndicesExtraKind: string;
  6542. /**
  6543. * Additional matrix weights (for bones)
  6544. */
  6545. static readonly MatricesWeightsExtraKind: string;
  6546. /**
  6547. * Deduces the stride given a kind.
  6548. * @param kind The kind string to deduce
  6549. * @returns The deduced stride
  6550. */
  6551. static DeduceStride(kind: string): number;
  6552. /**
  6553. * Gets the byte length of the given type.
  6554. * @param type the type
  6555. * @returns the number of bytes
  6556. */
  6557. static GetTypeByteLength(type: number): number;
  6558. /**
  6559. * Enumerates each value of the given parameters as numbers.
  6560. * @param data the data to enumerate
  6561. * @param byteOffset the byte offset of the data
  6562. * @param byteStride the byte stride of the data
  6563. * @param componentCount the number of components per element
  6564. * @param componentType the type of the component
  6565. * @param count the number of values to enumerate
  6566. * @param normalized whether the data is normalized
  6567. * @param callback the callback function called for each value
  6568. */
  6569. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6570. private static _GetFloatValue;
  6571. }
  6572. }
  6573. declare module BABYLON {
  6574. /**
  6575. * @hidden
  6576. */
  6577. export class IntersectionInfo {
  6578. bu: Nullable<number>;
  6579. bv: Nullable<number>;
  6580. distance: number;
  6581. faceId: number;
  6582. subMeshId: number;
  6583. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6584. }
  6585. }
  6586. declare module BABYLON {
  6587. /**
  6588. * Represens a plane by the equation ax + by + cz + d = 0
  6589. */
  6590. export class Plane {
  6591. private static _TmpMatrix;
  6592. /**
  6593. * Normal of the plane (a,b,c)
  6594. */
  6595. normal: Vector3;
  6596. /**
  6597. * d component of the plane
  6598. */
  6599. d: number;
  6600. /**
  6601. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6602. * @param a a component of the plane
  6603. * @param b b component of the plane
  6604. * @param c c component of the plane
  6605. * @param d d component of the plane
  6606. */
  6607. constructor(a: number, b: number, c: number, d: number);
  6608. /**
  6609. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6610. */
  6611. asArray(): number[];
  6612. /**
  6613. * @returns a new plane copied from the current Plane.
  6614. */
  6615. clone(): Plane;
  6616. /**
  6617. * @returns the string "Plane".
  6618. */
  6619. getClassName(): string;
  6620. /**
  6621. * @returns the Plane hash code.
  6622. */
  6623. getHashCode(): number;
  6624. /**
  6625. * Normalize the current Plane in place.
  6626. * @returns the updated Plane.
  6627. */
  6628. normalize(): Plane;
  6629. /**
  6630. * Applies a transformation the plane and returns the result
  6631. * @param transformation the transformation matrix to be applied to the plane
  6632. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6633. */
  6634. transform(transformation: DeepImmutable<Matrix>): Plane;
  6635. /**
  6636. * Calcualtte the dot product between the point and the plane normal
  6637. * @param point point to calculate the dot product with
  6638. * @returns the dot product (float) of the point coordinates and the plane normal.
  6639. */
  6640. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6641. /**
  6642. * Updates the current Plane from the plane defined by the three given points.
  6643. * @param point1 one of the points used to contruct the plane
  6644. * @param point2 one of the points used to contruct the plane
  6645. * @param point3 one of the points used to contruct the plane
  6646. * @returns the updated Plane.
  6647. */
  6648. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6649. /**
  6650. * Checks if the plane is facing a given direction
  6651. * @param direction the direction to check if the plane is facing
  6652. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6653. * @returns True is the vector "direction" is the same side than the plane normal.
  6654. */
  6655. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6656. /**
  6657. * Calculates the distance to a point
  6658. * @param point point to calculate distance to
  6659. * @returns the signed distance (float) from the given point to the Plane.
  6660. */
  6661. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6662. /**
  6663. * Creates a plane from an array
  6664. * @param array the array to create a plane from
  6665. * @returns a new Plane from the given array.
  6666. */
  6667. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6668. /**
  6669. * Creates a plane from three points
  6670. * @param point1 point used to create the plane
  6671. * @param point2 point used to create the plane
  6672. * @param point3 point used to create the plane
  6673. * @returns a new Plane defined by the three given points.
  6674. */
  6675. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6676. /**
  6677. * Creates a plane from an origin point and a normal
  6678. * @param origin origin of the plane to be constructed
  6679. * @param normal normal of the plane to be constructed
  6680. * @returns a new Plane the normal vector to this plane at the given origin point.
  6681. * Note : the vector "normal" is updated because normalized.
  6682. */
  6683. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6684. /**
  6685. * Calculates the distance from a plane and a point
  6686. * @param origin origin of the plane to be constructed
  6687. * @param normal normal of the plane to be constructed
  6688. * @param point point to calculate distance to
  6689. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6690. */
  6691. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6692. }
  6693. }
  6694. declare module BABYLON {
  6695. /**
  6696. * Class used to store bounding sphere information
  6697. */
  6698. export class BoundingSphere {
  6699. /**
  6700. * Gets the center of the bounding sphere in local space
  6701. */
  6702. readonly center: Vector3;
  6703. /**
  6704. * Radius of the bounding sphere in local space
  6705. */
  6706. radius: number;
  6707. /**
  6708. * Gets the center of the bounding sphere in world space
  6709. */
  6710. readonly centerWorld: Vector3;
  6711. /**
  6712. * Radius of the bounding sphere in world space
  6713. */
  6714. radiusWorld: number;
  6715. /**
  6716. * Gets the minimum vector in local space
  6717. */
  6718. readonly minimum: Vector3;
  6719. /**
  6720. * Gets the maximum vector in local space
  6721. */
  6722. readonly maximum: Vector3;
  6723. private _worldMatrix;
  6724. private static readonly TmpVector3;
  6725. /**
  6726. * Creates a new bounding sphere
  6727. * @param min defines the minimum vector (in local space)
  6728. * @param max defines the maximum vector (in local space)
  6729. * @param worldMatrix defines the new world matrix
  6730. */
  6731. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6732. /**
  6733. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6734. * @param min defines the new minimum vector (in local space)
  6735. * @param max defines the new maximum vector (in local space)
  6736. * @param worldMatrix defines the new world matrix
  6737. */
  6738. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6739. /**
  6740. * Scale the current bounding sphere by applying a scale factor
  6741. * @param factor defines the scale factor to apply
  6742. * @returns the current bounding box
  6743. */
  6744. scale(factor: number): BoundingSphere;
  6745. /**
  6746. * Gets the world matrix of the bounding box
  6747. * @returns a matrix
  6748. */
  6749. getWorldMatrix(): DeepImmutable<Matrix>;
  6750. /** @hidden */
  6751. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Tests if the bounding sphere is intersecting the frustum planes
  6754. * @param frustumPlanes defines the frustum planes to test
  6755. * @returns true if there is an intersection
  6756. */
  6757. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6758. /**
  6759. * Tests if the bounding sphere center is in between the frustum planes.
  6760. * Used for optimistic fast inclusion.
  6761. * @param frustumPlanes defines the frustum planes to test
  6762. * @returns true if the sphere center is in between the frustum planes
  6763. */
  6764. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6765. /**
  6766. * Tests if a point is inside the bounding sphere
  6767. * @param point defines the point to test
  6768. * @returns true if the point is inside the bounding sphere
  6769. */
  6770. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6771. /**
  6772. * Checks if two sphere intersct
  6773. * @param sphere0 sphere 0
  6774. * @param sphere1 sphere 1
  6775. * @returns true if the speres intersect
  6776. */
  6777. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6778. }
  6779. }
  6780. declare module BABYLON {
  6781. /**
  6782. * Class used to store bounding box information
  6783. */
  6784. export class BoundingBox implements ICullable {
  6785. /**
  6786. * Gets the 8 vectors representing the bounding box in local space
  6787. */
  6788. readonly vectors: Vector3[];
  6789. /**
  6790. * Gets the center of the bounding box in local space
  6791. */
  6792. readonly center: Vector3;
  6793. /**
  6794. * Gets the center of the bounding box in world space
  6795. */
  6796. readonly centerWorld: Vector3;
  6797. /**
  6798. * Gets the extend size in local space
  6799. */
  6800. readonly extendSize: Vector3;
  6801. /**
  6802. * Gets the extend size in world space
  6803. */
  6804. readonly extendSizeWorld: Vector3;
  6805. /**
  6806. * Gets the OBB (object bounding box) directions
  6807. */
  6808. readonly directions: Vector3[];
  6809. /**
  6810. * Gets the 8 vectors representing the bounding box in world space
  6811. */
  6812. readonly vectorsWorld: Vector3[];
  6813. /**
  6814. * Gets the minimum vector in world space
  6815. */
  6816. readonly minimumWorld: Vector3;
  6817. /**
  6818. * Gets the maximum vector in world space
  6819. */
  6820. readonly maximumWorld: Vector3;
  6821. /**
  6822. * Gets the minimum vector in local space
  6823. */
  6824. readonly minimum: Vector3;
  6825. /**
  6826. * Gets the maximum vector in local space
  6827. */
  6828. readonly maximum: Vector3;
  6829. private _worldMatrix;
  6830. private static readonly TmpVector3;
  6831. /**
  6832. * @hidden
  6833. */
  6834. _tag: number;
  6835. /**
  6836. * Creates a new bounding box
  6837. * @param min defines the minimum vector (in local space)
  6838. * @param max defines the maximum vector (in local space)
  6839. * @param worldMatrix defines the new world matrix
  6840. */
  6841. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6842. /**
  6843. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6844. * @param min defines the new minimum vector (in local space)
  6845. * @param max defines the new maximum vector (in local space)
  6846. * @param worldMatrix defines the new world matrix
  6847. */
  6848. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6849. /**
  6850. * Scale the current bounding box by applying a scale factor
  6851. * @param factor defines the scale factor to apply
  6852. * @returns the current bounding box
  6853. */
  6854. scale(factor: number): BoundingBox;
  6855. /**
  6856. * Gets the world matrix of the bounding box
  6857. * @returns a matrix
  6858. */
  6859. getWorldMatrix(): DeepImmutable<Matrix>;
  6860. /** @hidden */
  6861. _update(world: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Tests if the bounding box is intersecting the frustum planes
  6864. * @param frustumPlanes defines the frustum planes to test
  6865. * @returns true if there is an intersection
  6866. */
  6867. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6868. /**
  6869. * Tests if the bounding box is entirely inside the frustum planes
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @returns true if there is an inclusion
  6872. */
  6873. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. /**
  6875. * Tests if a point is inside the bounding box
  6876. * @param point defines the point to test
  6877. * @returns true if the point is inside the bounding box
  6878. */
  6879. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6880. /**
  6881. * Tests if the bounding box intersects with a bounding sphere
  6882. * @param sphere defines the sphere to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6886. /**
  6887. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6888. * @param min defines the min vector to use
  6889. * @param max defines the max vector to use
  6890. * @returns true if there is an intersection
  6891. */
  6892. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Tests if two bounding boxes are intersections
  6895. * @param box0 defines the first box to test
  6896. * @param box1 defines the second box to test
  6897. * @returns true if there is an intersection
  6898. */
  6899. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6900. /**
  6901. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6902. * @param minPoint defines the minimum vector of the bounding box
  6903. * @param maxPoint defines the maximum vector of the bounding box
  6904. * @param sphereCenter defines the sphere center
  6905. * @param sphereRadius defines the sphere radius
  6906. * @returns true if there is an intersection
  6907. */
  6908. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6909. /**
  6910. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6911. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6912. * @param frustumPlanes defines the frustum planes to test
  6913. * @return true if there is an inclusion
  6914. */
  6915. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6916. /**
  6917. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6918. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6919. * @param frustumPlanes defines the frustum planes to test
  6920. * @return true if there is an intersection
  6921. */
  6922. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6923. }
  6924. }
  6925. declare module BABYLON {
  6926. /** @hidden */
  6927. export class Collider {
  6928. /** Define if a collision was found */
  6929. collisionFound: boolean;
  6930. /**
  6931. * Define last intersection point in local space
  6932. */
  6933. intersectionPoint: Vector3;
  6934. /**
  6935. * Define last collided mesh
  6936. */
  6937. collidedMesh: Nullable<AbstractMesh>;
  6938. private _collisionPoint;
  6939. private _planeIntersectionPoint;
  6940. private _tempVector;
  6941. private _tempVector2;
  6942. private _tempVector3;
  6943. private _tempVector4;
  6944. private _edge;
  6945. private _baseToVertex;
  6946. private _destinationPoint;
  6947. private _slidePlaneNormal;
  6948. private _displacementVector;
  6949. /** @hidden */
  6950. _radius: Vector3;
  6951. /** @hidden */
  6952. _retry: number;
  6953. private _velocity;
  6954. private _basePoint;
  6955. private _epsilon;
  6956. /** @hidden */
  6957. _velocityWorldLength: number;
  6958. /** @hidden */
  6959. _basePointWorld: Vector3;
  6960. private _velocityWorld;
  6961. private _normalizedVelocity;
  6962. /** @hidden */
  6963. _initialVelocity: Vector3;
  6964. /** @hidden */
  6965. _initialPosition: Vector3;
  6966. private _nearestDistance;
  6967. private _collisionMask;
  6968. get collisionMask(): number;
  6969. set collisionMask(mask: number);
  6970. /**
  6971. * Gets the plane normal used to compute the sliding response (in local space)
  6972. */
  6973. get slidePlaneNormal(): Vector3;
  6974. /** @hidden */
  6975. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6976. /** @hidden */
  6977. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6978. /** @hidden */
  6979. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6980. /** @hidden */
  6981. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6982. /** @hidden */
  6983. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6984. /** @hidden */
  6985. _getResponse(pos: Vector3, vel: Vector3): void;
  6986. }
  6987. }
  6988. declare module BABYLON {
  6989. /**
  6990. * Interface for cullable objects
  6991. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6992. */
  6993. export interface ICullable {
  6994. /**
  6995. * Checks if the object or part of the object is in the frustum
  6996. * @param frustumPlanes Camera near/planes
  6997. * @returns true if the object is in frustum otherwise false
  6998. */
  6999. isInFrustum(frustumPlanes: Plane[]): boolean;
  7000. /**
  7001. * Checks if a cullable object (mesh...) is in the camera frustum
  7002. * Unlike isInFrustum this cheks the full bounding box
  7003. * @param frustumPlanes Camera near/planes
  7004. * @returns true if the object is in frustum otherwise false
  7005. */
  7006. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7007. }
  7008. /**
  7009. * Info for a bounding data of a mesh
  7010. */
  7011. export class BoundingInfo implements ICullable {
  7012. /**
  7013. * Bounding box for the mesh
  7014. */
  7015. readonly boundingBox: BoundingBox;
  7016. /**
  7017. * Bounding sphere for the mesh
  7018. */
  7019. readonly boundingSphere: BoundingSphere;
  7020. private _isLocked;
  7021. private static readonly TmpVector3;
  7022. /**
  7023. * Constructs bounding info
  7024. * @param minimum min vector of the bounding box/sphere
  7025. * @param maximum max vector of the bounding box/sphere
  7026. * @param worldMatrix defines the new world matrix
  7027. */
  7028. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7029. /**
  7030. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7031. * @param min defines the new minimum vector (in local space)
  7032. * @param max defines the new maximum vector (in local space)
  7033. * @param worldMatrix defines the new world matrix
  7034. */
  7035. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7036. /**
  7037. * min vector of the bounding box/sphere
  7038. */
  7039. get minimum(): Vector3;
  7040. /**
  7041. * max vector of the bounding box/sphere
  7042. */
  7043. get maximum(): Vector3;
  7044. /**
  7045. * If the info is locked and won't be updated to avoid perf overhead
  7046. */
  7047. get isLocked(): boolean;
  7048. set isLocked(value: boolean);
  7049. /**
  7050. * Updates the bounding sphere and box
  7051. * @param world world matrix to be used to update
  7052. */
  7053. update(world: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7056. * @param center New center of the bounding info
  7057. * @param extend New extend of the bounding info
  7058. * @returns the current bounding info
  7059. */
  7060. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7061. /**
  7062. * Scale the current bounding info by applying a scale factor
  7063. * @param factor defines the scale factor to apply
  7064. * @returns the current bounding info
  7065. */
  7066. scale(factor: number): BoundingInfo;
  7067. /**
  7068. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7069. * @param frustumPlanes defines the frustum to test
  7070. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7071. * @returns true if the bounding info is in the frustum planes
  7072. */
  7073. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7074. /**
  7075. * Gets the world distance between the min and max points of the bounding box
  7076. */
  7077. get diagonalLength(): number;
  7078. /**
  7079. * Checks if a cullable object (mesh...) is in the camera frustum
  7080. * Unlike isInFrustum this cheks the full bounding box
  7081. * @param frustumPlanes Camera near/planes
  7082. * @returns true if the object is in frustum otherwise false
  7083. */
  7084. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7085. /** @hidden */
  7086. _checkCollision(collider: Collider): boolean;
  7087. /**
  7088. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7089. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7090. * @param point the point to check intersection with
  7091. * @returns if the point intersects
  7092. */
  7093. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7094. /**
  7095. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7096. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7097. * @param boundingInfo the bounding info to check intersection with
  7098. * @param precise if the intersection should be done using OBB
  7099. * @returns if the bounding info intersects
  7100. */
  7101. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7102. }
  7103. }
  7104. declare module BABYLON {
  7105. /**
  7106. * Extracts minimum and maximum values from a list of indexed positions
  7107. * @param positions defines the positions to use
  7108. * @param indices defines the indices to the positions
  7109. * @param indexStart defines the start index
  7110. * @param indexCount defines the end index
  7111. * @param bias defines bias value to add to the result
  7112. * @return minimum and maximum values
  7113. */
  7114. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7115. minimum: Vector3;
  7116. maximum: Vector3;
  7117. };
  7118. /**
  7119. * Extracts minimum and maximum values from a list of positions
  7120. * @param positions defines the positions to use
  7121. * @param start defines the start index in the positions array
  7122. * @param count defines the number of positions to handle
  7123. * @param bias defines bias value to add to the result
  7124. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7125. * @return minimum and maximum values
  7126. */
  7127. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7128. minimum: Vector3;
  7129. maximum: Vector3;
  7130. };
  7131. }
  7132. declare module BABYLON {
  7133. /** @hidden */
  7134. export class WebGLDataBuffer extends DataBuffer {
  7135. private _buffer;
  7136. constructor(resource: WebGLBuffer);
  7137. get underlyingResource(): any;
  7138. }
  7139. }
  7140. declare module BABYLON {
  7141. /** @hidden */
  7142. export class WebGLPipelineContext implements IPipelineContext {
  7143. engine: ThinEngine;
  7144. program: Nullable<WebGLProgram>;
  7145. context?: WebGLRenderingContext;
  7146. vertexShader?: WebGLShader;
  7147. fragmentShader?: WebGLShader;
  7148. isParallelCompiled: boolean;
  7149. onCompiled?: () => void;
  7150. transformFeedback?: WebGLTransformFeedback | null;
  7151. vertexCompilationError: Nullable<string>;
  7152. fragmentCompilationError: Nullable<string>;
  7153. programLinkError: Nullable<string>;
  7154. programValidationError: Nullable<string>;
  7155. get isAsync(): boolean;
  7156. get isReady(): boolean;
  7157. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7158. }
  7159. }
  7160. declare module BABYLON {
  7161. interface ThinEngine {
  7162. /**
  7163. * Create an uniform buffer
  7164. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7165. * @param elements defines the content of the uniform buffer
  7166. * @returns the webGL uniform buffer
  7167. */
  7168. createUniformBuffer(elements: FloatArray): DataBuffer;
  7169. /**
  7170. * Create a dynamic uniform buffer
  7171. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7172. * @param elements defines the content of the uniform buffer
  7173. * @returns the webGL uniform buffer
  7174. */
  7175. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7176. /**
  7177. * Update an existing uniform buffer
  7178. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7179. * @param uniformBuffer defines the target uniform buffer
  7180. * @param elements defines the content to update
  7181. * @param offset defines the offset in the uniform buffer where update should start
  7182. * @param count defines the size of the data to update
  7183. */
  7184. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7185. /**
  7186. * Bind an uniform buffer to the current webGL context
  7187. * @param buffer defines the buffer to bind
  7188. */
  7189. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7190. /**
  7191. * Bind a buffer to the current webGL context at a given location
  7192. * @param buffer defines the buffer to bind
  7193. * @param location defines the index where to bind the buffer
  7194. */
  7195. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7196. /**
  7197. * Bind a specific block at a given index in a specific shader program
  7198. * @param pipelineContext defines the pipeline context to use
  7199. * @param blockName defines the block name
  7200. * @param index defines the index where to bind the block
  7201. */
  7202. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7203. }
  7204. }
  7205. declare module BABYLON {
  7206. /**
  7207. * Uniform buffer objects.
  7208. *
  7209. * Handles blocks of uniform on the GPU.
  7210. *
  7211. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7212. *
  7213. * For more information, please refer to :
  7214. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7215. */
  7216. export class UniformBuffer {
  7217. private _engine;
  7218. private _buffer;
  7219. private _data;
  7220. private _bufferData;
  7221. private _dynamic?;
  7222. private _uniformLocations;
  7223. private _uniformSizes;
  7224. private _uniformLocationPointer;
  7225. private _needSync;
  7226. private _noUBO;
  7227. private _currentEffect;
  7228. /** @hidden */
  7229. _alreadyBound: boolean;
  7230. private static _MAX_UNIFORM_SIZE;
  7231. private static _tempBuffer;
  7232. /**
  7233. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7234. * This is dynamic to allow compat with webgl 1 and 2.
  7235. * You will need to pass the name of the uniform as well as the value.
  7236. */
  7237. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7238. /**
  7239. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7240. * This is dynamic to allow compat with webgl 1 and 2.
  7241. * You will need to pass the name of the uniform as well as the value.
  7242. */
  7243. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7244. /**
  7245. * Lambda to Update a single float in a uniform buffer.
  7246. * This is dynamic to allow compat with webgl 1 and 2.
  7247. * You will need to pass the name of the uniform as well as the value.
  7248. */
  7249. updateFloat: (name: string, x: number) => void;
  7250. /**
  7251. * Lambda to Update a vec2 of float in a uniform buffer.
  7252. * This is dynamic to allow compat with webgl 1 and 2.
  7253. * You will need to pass the name of the uniform as well as the value.
  7254. */
  7255. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7256. /**
  7257. * Lambda to Update a vec3 of float in a uniform buffer.
  7258. * This is dynamic to allow compat with webgl 1 and 2.
  7259. * You will need to pass the name of the uniform as well as the value.
  7260. */
  7261. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7262. /**
  7263. * Lambda to Update a vec4 of float in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7268. /**
  7269. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateMatrix: (name: string, mat: Matrix) => void;
  7274. /**
  7275. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateVector3: (name: string, vector: Vector3) => void;
  7280. /**
  7281. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateVector4: (name: string, vector: Vector4) => void;
  7286. /**
  7287. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7292. /**
  7293. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7298. /**
  7299. * Instantiates a new Uniform buffer objects.
  7300. *
  7301. * Handles blocks of uniform on the GPU.
  7302. *
  7303. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7304. *
  7305. * For more information, please refer to :
  7306. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7307. * @param engine Define the engine the buffer is associated with
  7308. * @param data Define the data contained in the buffer
  7309. * @param dynamic Define if the buffer is updatable
  7310. */
  7311. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7312. /**
  7313. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7314. * or just falling back on setUniformXXX calls.
  7315. */
  7316. get useUbo(): boolean;
  7317. /**
  7318. * Indicates if the WebGL underlying uniform buffer is in sync
  7319. * with the javascript cache data.
  7320. */
  7321. get isSync(): boolean;
  7322. /**
  7323. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7324. * Also, a dynamic UniformBuffer will disable cache verification and always
  7325. * update the underlying WebGL uniform buffer to the GPU.
  7326. * @returns if Dynamic, otherwise false
  7327. */
  7328. isDynamic(): boolean;
  7329. /**
  7330. * The data cache on JS side.
  7331. * @returns the underlying data as a float array
  7332. */
  7333. getData(): Float32Array;
  7334. /**
  7335. * The underlying WebGL Uniform buffer.
  7336. * @returns the webgl buffer
  7337. */
  7338. getBuffer(): Nullable<DataBuffer>;
  7339. /**
  7340. * std140 layout specifies how to align data within an UBO structure.
  7341. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7342. * for specs.
  7343. */
  7344. private _fillAlignment;
  7345. /**
  7346. * Adds an uniform in the buffer.
  7347. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7348. * for the layout to be correct !
  7349. * @param name Name of the uniform, as used in the uniform block in the shader.
  7350. * @param size Data size, or data directly.
  7351. */
  7352. addUniform(name: string, size: number | number[]): void;
  7353. /**
  7354. * Adds a Matrix 4x4 to the uniform buffer.
  7355. * @param name Name of the uniform, as used in the uniform block in the shader.
  7356. * @param mat A 4x4 matrix.
  7357. */
  7358. addMatrix(name: string, mat: Matrix): void;
  7359. /**
  7360. * Adds a vec2 to the uniform buffer.
  7361. * @param name Name of the uniform, as used in the uniform block in the shader.
  7362. * @param x Define the x component value of the vec2
  7363. * @param y Define the y component value of the vec2
  7364. */
  7365. addFloat2(name: string, x: number, y: number): void;
  7366. /**
  7367. * Adds a vec3 to the uniform buffer.
  7368. * @param name Name of the uniform, as used in the uniform block in the shader.
  7369. * @param x Define the x component value of the vec3
  7370. * @param y Define the y component value of the vec3
  7371. * @param z Define the z component value of the vec3
  7372. */
  7373. addFloat3(name: string, x: number, y: number, z: number): void;
  7374. /**
  7375. * Adds a vec3 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param color Define the vec3 from a Color
  7378. */
  7379. addColor3(name: string, color: Color3): void;
  7380. /**
  7381. * Adds a vec4 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param color Define the rgb components from a Color
  7384. * @param alpha Define the a component of the vec4
  7385. */
  7386. addColor4(name: string, color: Color3, alpha: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param vector Define the vec3 components from a Vector
  7391. */
  7392. addVector3(name: string, vector: Vector3): void;
  7393. /**
  7394. * Adds a Matrix 3x3 to the uniform buffer.
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. */
  7397. addMatrix3x3(name: string): void;
  7398. /**
  7399. * Adds a Matrix 2x2 to the uniform buffer.
  7400. * @param name Name of the uniform, as used in the uniform block in the shader.
  7401. */
  7402. addMatrix2x2(name: string): void;
  7403. /**
  7404. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7405. */
  7406. create(): void;
  7407. /** @hidden */
  7408. _rebuild(): void;
  7409. /**
  7410. * Updates the WebGL Uniform Buffer on the GPU.
  7411. * If the `dynamic` flag is set to true, no cache comparison is done.
  7412. * Otherwise, the buffer will be updated only if the cache differs.
  7413. */
  7414. update(): void;
  7415. /**
  7416. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7417. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7418. * @param data Define the flattened data
  7419. * @param size Define the size of the data.
  7420. */
  7421. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7422. private _valueCache;
  7423. private _cacheMatrix;
  7424. private _updateMatrix3x3ForUniform;
  7425. private _updateMatrix3x3ForEffect;
  7426. private _updateMatrix2x2ForEffect;
  7427. private _updateMatrix2x2ForUniform;
  7428. private _updateFloatForEffect;
  7429. private _updateFloatForUniform;
  7430. private _updateFloat2ForEffect;
  7431. private _updateFloat2ForUniform;
  7432. private _updateFloat3ForEffect;
  7433. private _updateFloat3ForUniform;
  7434. private _updateFloat4ForEffect;
  7435. private _updateFloat4ForUniform;
  7436. private _updateMatrixForEffect;
  7437. private _updateMatrixForUniform;
  7438. private _updateVector3ForEffect;
  7439. private _updateVector3ForUniform;
  7440. private _updateVector4ForEffect;
  7441. private _updateVector4ForUniform;
  7442. private _updateColor3ForEffect;
  7443. private _updateColor3ForUniform;
  7444. private _updateColor4ForEffect;
  7445. private _updateColor4ForUniform;
  7446. /**
  7447. * Sets a sampler uniform on the effect.
  7448. * @param name Define the name of the sampler.
  7449. * @param texture Define the texture to set in the sampler
  7450. */
  7451. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7452. /**
  7453. * Directly updates the value of the uniform in the cache AND on the GPU.
  7454. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7455. * @param data Define the flattened data
  7456. */
  7457. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7458. /**
  7459. * Binds this uniform buffer to an effect.
  7460. * @param effect Define the effect to bind the buffer to
  7461. * @param name Name of the uniform block in the shader.
  7462. */
  7463. bindToEffect(effect: Effect, name: string): void;
  7464. /**
  7465. * Disposes the uniform buffer.
  7466. */
  7467. dispose(): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * Enum that determines the text-wrapping mode to use.
  7473. */
  7474. export enum InspectableType {
  7475. /**
  7476. * Checkbox for booleans
  7477. */
  7478. Checkbox = 0,
  7479. /**
  7480. * Sliders for numbers
  7481. */
  7482. Slider = 1,
  7483. /**
  7484. * Vector3
  7485. */
  7486. Vector3 = 2,
  7487. /**
  7488. * Quaternions
  7489. */
  7490. Quaternion = 3,
  7491. /**
  7492. * Color3
  7493. */
  7494. Color3 = 4,
  7495. /**
  7496. * String
  7497. */
  7498. String = 5
  7499. }
  7500. /**
  7501. * Interface used to define custom inspectable properties.
  7502. * This interface is used by the inspector to display custom property grids
  7503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7504. */
  7505. export interface IInspectable {
  7506. /**
  7507. * Gets the label to display
  7508. */
  7509. label: string;
  7510. /**
  7511. * Gets the name of the property to edit
  7512. */
  7513. propertyName: string;
  7514. /**
  7515. * Gets the type of the editor to use
  7516. */
  7517. type: InspectableType;
  7518. /**
  7519. * Gets the minimum value of the property when using in "slider" mode
  7520. */
  7521. min?: number;
  7522. /**
  7523. * Gets the maximum value of the property when using in "slider" mode
  7524. */
  7525. max?: number;
  7526. /**
  7527. * Gets the setp to use when using in "slider" mode
  7528. */
  7529. step?: number;
  7530. }
  7531. }
  7532. declare module BABYLON {
  7533. /**
  7534. * Class used to provide helper for timing
  7535. */
  7536. export class TimingTools {
  7537. /**
  7538. * Polyfill for setImmediate
  7539. * @param action defines the action to execute after the current execution block
  7540. */
  7541. static SetImmediate(action: () => void): void;
  7542. }
  7543. }
  7544. declare module BABYLON {
  7545. /**
  7546. * Class used to enable instatition of objects by class name
  7547. */
  7548. export class InstantiationTools {
  7549. /**
  7550. * Use this object to register external classes like custom textures or material
  7551. * to allow the laoders to instantiate them
  7552. */
  7553. static RegisteredExternalClasses: {
  7554. [key: string]: Object;
  7555. };
  7556. /**
  7557. * Tries to instantiate a new object from a given class name
  7558. * @param className defines the class name to instantiate
  7559. * @returns the new object or null if the system was not able to do the instantiation
  7560. */
  7561. static Instantiate(className: string): any;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Define options used to create a depth texture
  7567. */
  7568. export class DepthTextureCreationOptions {
  7569. /** Specifies whether or not a stencil should be allocated in the texture */
  7570. generateStencil?: boolean;
  7571. /** Specifies whether or not bilinear filtering is enable on the texture */
  7572. bilinearFiltering?: boolean;
  7573. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7574. comparisonFunction?: number;
  7575. /** Specifies if the created texture is a cube texture */
  7576. isCube?: boolean;
  7577. }
  7578. }
  7579. declare module BABYLON {
  7580. interface ThinEngine {
  7581. /**
  7582. * Creates a depth stencil cube texture.
  7583. * This is only available in WebGL 2.
  7584. * @param size The size of face edge in the cube texture.
  7585. * @param options The options defining the cube texture.
  7586. * @returns The cube texture
  7587. */
  7588. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7589. /**
  7590. * Creates a cube texture
  7591. * @param rootUrl defines the url where the files to load is located
  7592. * @param scene defines the current scene
  7593. * @param files defines the list of files to load (1 per face)
  7594. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7595. * @param onLoad defines an optional callback raised when the texture is loaded
  7596. * @param onError defines an optional callback raised if there is an issue to load the texture
  7597. * @param format defines the format of the data
  7598. * @param forcedExtension defines the extension to use to pick the right loader
  7599. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7600. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7601. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7602. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7603. * @returns the cube texture as an InternalTexture
  7604. */
  7605. 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;
  7606. /**
  7607. * Creates a cube texture
  7608. * @param rootUrl defines the url where the files to load is located
  7609. * @param scene defines the current scene
  7610. * @param files defines the list of files to load (1 per face)
  7611. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7612. * @param onLoad defines an optional callback raised when the texture is loaded
  7613. * @param onError defines an optional callback raised if there is an issue to load the texture
  7614. * @param format defines the format of the data
  7615. * @param forcedExtension defines the extension to use to pick the right loader
  7616. * @returns the cube texture as an InternalTexture
  7617. */
  7618. 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;
  7619. /**
  7620. * Creates a cube texture
  7621. * @param rootUrl defines the url where the files to load is located
  7622. * @param scene defines the current scene
  7623. * @param files defines the list of files to load (1 per face)
  7624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7625. * @param onLoad defines an optional callback raised when the texture is loaded
  7626. * @param onError defines an optional callback raised if there is an issue to load the texture
  7627. * @param format defines the format of the data
  7628. * @param forcedExtension defines the extension to use to pick the right loader
  7629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7632. * @returns the cube texture as an InternalTexture
  7633. */
  7634. 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;
  7635. /** @hidden */
  7636. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7637. /** @hidden */
  7638. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7639. /** @hidden */
  7640. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7641. /** @hidden */
  7642. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7643. /**
  7644. * @hidden
  7645. */
  7646. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7647. }
  7648. }
  7649. declare module BABYLON {
  7650. /**
  7651. * Class for creating a cube texture
  7652. */
  7653. export class CubeTexture extends BaseTexture {
  7654. private _delayedOnLoad;
  7655. /**
  7656. * Observable triggered once the texture has been loaded.
  7657. */
  7658. onLoadObservable: Observable<CubeTexture>;
  7659. /**
  7660. * The url of the texture
  7661. */
  7662. url: string;
  7663. /**
  7664. * Gets or sets the center of the bounding box associated with the cube texture.
  7665. * It must define where the camera used to render the texture was set
  7666. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7667. */
  7668. boundingBoxPosition: Vector3;
  7669. private _boundingBoxSize;
  7670. /**
  7671. * Gets or sets the size of the bounding box associated with the cube texture
  7672. * When defined, the cubemap will switch to local mode
  7673. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7674. * @example https://www.babylonjs-playground.com/#RNASML
  7675. */
  7676. set boundingBoxSize(value: Vector3);
  7677. /**
  7678. * Returns the bounding box size
  7679. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7680. */
  7681. get boundingBoxSize(): Vector3;
  7682. protected _rotationY: number;
  7683. /**
  7684. * Sets texture matrix rotation angle around Y axis in radians.
  7685. */
  7686. set rotationY(value: number);
  7687. /**
  7688. * Gets texture matrix rotation angle around Y axis radians.
  7689. */
  7690. get rotationY(): number;
  7691. /**
  7692. * Are mip maps generated for this texture or not.
  7693. */
  7694. get noMipmap(): boolean;
  7695. private _noMipmap;
  7696. private _files;
  7697. protected _forcedExtension: Nullable<string>;
  7698. private _extensions;
  7699. private _textureMatrix;
  7700. private _format;
  7701. private _createPolynomials;
  7702. /** @hidden */
  7703. _prefiltered: boolean;
  7704. /**
  7705. * Creates a cube texture from an array of image urls
  7706. * @param files defines an array of image urls
  7707. * @param scene defines the hosting scene
  7708. * @param noMipmap specifies if mip maps are not used
  7709. * @returns a cube texture
  7710. */
  7711. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7712. /**
  7713. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7714. * @param url defines the url of the prefiltered texture
  7715. * @param scene defines the scene the texture is attached to
  7716. * @param forcedExtension defines the extension of the file if different from the url
  7717. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7718. * @return the prefiltered texture
  7719. */
  7720. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7721. /**
  7722. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7723. * as prefiltered data.
  7724. * @param rootUrl defines the url of the texture or the root name of the six images
  7725. * @param scene defines the scene the texture is attached to
  7726. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7727. * @param noMipmap defines if mipmaps should be created or not
  7728. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7729. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7730. * @param onError defines a callback triggered in case of error during load
  7731. * @param format defines the internal format to use for the texture once loaded
  7732. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7733. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7734. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7735. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7736. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7737. * @return the cube texture
  7738. */
  7739. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7740. /**
  7741. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7742. */
  7743. get isPrefiltered(): boolean;
  7744. /**
  7745. * Get the current class name of the texture useful for serialization or dynamic coding.
  7746. * @returns "CubeTexture"
  7747. */
  7748. getClassName(): string;
  7749. /**
  7750. * Update the url (and optional buffer) of this texture if url was null during construction.
  7751. * @param url the url of the texture
  7752. * @param forcedExtension defines the extension to use
  7753. * @param onLoad callback called when the texture is loaded (defaults to null)
  7754. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7755. */
  7756. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7757. /**
  7758. * Delays loading of the cube texture
  7759. * @param forcedExtension defines the extension to use
  7760. */
  7761. delayLoad(forcedExtension?: string): void;
  7762. /**
  7763. * Returns the reflection texture matrix
  7764. * @returns the reflection texture matrix
  7765. */
  7766. getReflectionTextureMatrix(): Matrix;
  7767. /**
  7768. * Sets the reflection texture matrix
  7769. * @param value Reflection texture matrix
  7770. */
  7771. setReflectionTextureMatrix(value: Matrix): void;
  7772. /**
  7773. * Parses text to create a cube texture
  7774. * @param parsedTexture define the serialized text to read from
  7775. * @param scene defines the hosting scene
  7776. * @param rootUrl defines the root url of the cube texture
  7777. * @returns a cube texture
  7778. */
  7779. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7780. /**
  7781. * Makes a clone, or deep copy, of the cube texture
  7782. * @returns a new cube texture
  7783. */
  7784. clone(): CubeTexture;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Manages the defines for the Material
  7790. */
  7791. export class MaterialDefines {
  7792. /** @hidden */
  7793. protected _keys: string[];
  7794. private _isDirty;
  7795. /** @hidden */
  7796. _renderId: number;
  7797. /** @hidden */
  7798. _areLightsDirty: boolean;
  7799. /** @hidden */
  7800. _areLightsDisposed: boolean;
  7801. /** @hidden */
  7802. _areAttributesDirty: boolean;
  7803. /** @hidden */
  7804. _areTexturesDirty: boolean;
  7805. /** @hidden */
  7806. _areFresnelDirty: boolean;
  7807. /** @hidden */
  7808. _areMiscDirty: boolean;
  7809. /** @hidden */
  7810. _areImageProcessingDirty: boolean;
  7811. /** @hidden */
  7812. _normals: boolean;
  7813. /** @hidden */
  7814. _uvs: boolean;
  7815. /** @hidden */
  7816. _needNormals: boolean;
  7817. /** @hidden */
  7818. _needUVs: boolean;
  7819. [id: string]: any;
  7820. /**
  7821. * Specifies if the material needs to be re-calculated
  7822. */
  7823. get isDirty(): boolean;
  7824. /**
  7825. * Marks the material to indicate that it has been re-calculated
  7826. */
  7827. markAsProcessed(): void;
  7828. /**
  7829. * Marks the material to indicate that it needs to be re-calculated
  7830. */
  7831. markAsUnprocessed(): void;
  7832. /**
  7833. * Marks the material to indicate all of its defines need to be re-calculated
  7834. */
  7835. markAllAsDirty(): void;
  7836. /**
  7837. * Marks the material to indicate that image processing needs to be re-calculated
  7838. */
  7839. markAsImageProcessingDirty(): void;
  7840. /**
  7841. * Marks the material to indicate the lights need to be re-calculated
  7842. * @param disposed Defines whether the light is dirty due to dispose or not
  7843. */
  7844. markAsLightDirty(disposed?: boolean): void;
  7845. /**
  7846. * Marks the attribute state as changed
  7847. */
  7848. markAsAttributesDirty(): void;
  7849. /**
  7850. * Marks the texture state as changed
  7851. */
  7852. markAsTexturesDirty(): void;
  7853. /**
  7854. * Marks the fresnel state as changed
  7855. */
  7856. markAsFresnelDirty(): void;
  7857. /**
  7858. * Marks the misc state as changed
  7859. */
  7860. markAsMiscDirty(): void;
  7861. /**
  7862. * Rebuilds the material defines
  7863. */
  7864. rebuild(): void;
  7865. /**
  7866. * Specifies if two material defines are equal
  7867. * @param other - A material define instance to compare to
  7868. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7869. */
  7870. isEqual(other: MaterialDefines): boolean;
  7871. /**
  7872. * Clones this instance's defines to another instance
  7873. * @param other - material defines to clone values to
  7874. */
  7875. cloneTo(other: MaterialDefines): void;
  7876. /**
  7877. * Resets the material define values
  7878. */
  7879. reset(): void;
  7880. /**
  7881. * Converts the material define values to a string
  7882. * @returns - String of material define information
  7883. */
  7884. toString(): string;
  7885. }
  7886. }
  7887. declare module BABYLON {
  7888. /**
  7889. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7890. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7891. * 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;
  7892. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7893. */
  7894. export class ColorCurves {
  7895. private _dirty;
  7896. private _tempColor;
  7897. private _globalCurve;
  7898. private _highlightsCurve;
  7899. private _midtonesCurve;
  7900. private _shadowsCurve;
  7901. private _positiveCurve;
  7902. private _negativeCurve;
  7903. private _globalHue;
  7904. private _globalDensity;
  7905. private _globalSaturation;
  7906. private _globalExposure;
  7907. /**
  7908. * Gets the global Hue value.
  7909. * 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).
  7910. */
  7911. get globalHue(): number;
  7912. /**
  7913. * Sets the global Hue value.
  7914. * 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).
  7915. */
  7916. set globalHue(value: number);
  7917. /**
  7918. * Gets the global Density value.
  7919. * 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.
  7920. * Values less than zero provide a filter of opposite hue.
  7921. */
  7922. get globalDensity(): number;
  7923. /**
  7924. * Sets the global Density value.
  7925. * 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.
  7926. * Values less than zero provide a filter of opposite hue.
  7927. */
  7928. set globalDensity(value: number);
  7929. /**
  7930. * Gets the global Saturation value.
  7931. * 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.
  7932. */
  7933. get globalSaturation(): number;
  7934. /**
  7935. * Sets the global Saturation value.
  7936. * 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.
  7937. */
  7938. set globalSaturation(value: number);
  7939. /**
  7940. * Gets the global Exposure value.
  7941. * 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.
  7942. */
  7943. get globalExposure(): number;
  7944. /**
  7945. * Sets the global Exposure value.
  7946. * 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.
  7947. */
  7948. set globalExposure(value: number);
  7949. private _highlightsHue;
  7950. private _highlightsDensity;
  7951. private _highlightsSaturation;
  7952. private _highlightsExposure;
  7953. /**
  7954. * Gets the highlights Hue value.
  7955. * 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).
  7956. */
  7957. get highlightsHue(): number;
  7958. /**
  7959. * Sets the highlights Hue value.
  7960. * 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).
  7961. */
  7962. set highlightsHue(value: number);
  7963. /**
  7964. * Gets the highlights Density value.
  7965. * 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.
  7966. * Values less than zero provide a filter of opposite hue.
  7967. */
  7968. get highlightsDensity(): number;
  7969. /**
  7970. * Sets the highlights Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. set highlightsDensity(value: number);
  7975. /**
  7976. * Gets the highlights Saturation value.
  7977. * 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.
  7978. */
  7979. get highlightsSaturation(): number;
  7980. /**
  7981. * Sets the highlights Saturation value.
  7982. * 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.
  7983. */
  7984. set highlightsSaturation(value: number);
  7985. /**
  7986. * Gets the highlights Exposure value.
  7987. * 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.
  7988. */
  7989. get highlightsExposure(): number;
  7990. /**
  7991. * Sets the highlights Exposure value.
  7992. * 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.
  7993. */
  7994. set highlightsExposure(value: number);
  7995. private _midtonesHue;
  7996. private _midtonesDensity;
  7997. private _midtonesSaturation;
  7998. private _midtonesExposure;
  7999. /**
  8000. * Gets the midtones Hue value.
  8001. * 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).
  8002. */
  8003. get midtonesHue(): number;
  8004. /**
  8005. * Sets the midtones Hue value.
  8006. * 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).
  8007. */
  8008. set midtonesHue(value: number);
  8009. /**
  8010. * Gets the midtones Density value.
  8011. * 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.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. get midtonesDensity(): number;
  8015. /**
  8016. * Sets the midtones Density value.
  8017. * 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.
  8018. * Values less than zero provide a filter of opposite hue.
  8019. */
  8020. set midtonesDensity(value: number);
  8021. /**
  8022. * Gets the midtones Saturation value.
  8023. * 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.
  8024. */
  8025. get midtonesSaturation(): number;
  8026. /**
  8027. * Sets the midtones Saturation value.
  8028. * 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.
  8029. */
  8030. set midtonesSaturation(value: number);
  8031. /**
  8032. * Gets the midtones Exposure value.
  8033. * 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.
  8034. */
  8035. get midtonesExposure(): number;
  8036. /**
  8037. * Sets the midtones Exposure value.
  8038. * 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.
  8039. */
  8040. set midtonesExposure(value: number);
  8041. private _shadowsHue;
  8042. private _shadowsDensity;
  8043. private _shadowsSaturation;
  8044. private _shadowsExposure;
  8045. /**
  8046. * Gets the shadows Hue value.
  8047. * 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).
  8048. */
  8049. get shadowsHue(): number;
  8050. /**
  8051. * Sets the shadows Hue value.
  8052. * 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).
  8053. */
  8054. set shadowsHue(value: number);
  8055. /**
  8056. * Gets the shadows Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. get shadowsDensity(): number;
  8061. /**
  8062. * Sets the shadows Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. set shadowsDensity(value: number);
  8067. /**
  8068. * Gets the shadows Saturation value.
  8069. * 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.
  8070. */
  8071. get shadowsSaturation(): number;
  8072. /**
  8073. * Sets the shadows Saturation value.
  8074. * 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.
  8075. */
  8076. set shadowsSaturation(value: number);
  8077. /**
  8078. * Gets the shadows Exposure value.
  8079. * 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.
  8080. */
  8081. get shadowsExposure(): number;
  8082. /**
  8083. * Sets the shadows Exposure value.
  8084. * 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.
  8085. */
  8086. set shadowsExposure(value: number);
  8087. /**
  8088. * Returns the class name
  8089. * @returns The class name
  8090. */
  8091. getClassName(): string;
  8092. /**
  8093. * Binds the color curves to the shader.
  8094. * @param colorCurves The color curve to bind
  8095. * @param effect The effect to bind to
  8096. * @param positiveUniform The positive uniform shader parameter
  8097. * @param neutralUniform The neutral uniform shader parameter
  8098. * @param negativeUniform The negative uniform shader parameter
  8099. */
  8100. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8101. /**
  8102. * Prepare the list of uniforms associated with the ColorCurves effects.
  8103. * @param uniformsList The list of uniforms used in the effect
  8104. */
  8105. static PrepareUniforms(uniformsList: string[]): void;
  8106. /**
  8107. * Returns color grading data based on a hue, density, saturation and exposure value.
  8108. * @param filterHue The hue of the color filter.
  8109. * @param filterDensity The density of the color filter.
  8110. * @param saturation The saturation.
  8111. * @param exposure The exposure.
  8112. * @param result The result data container.
  8113. */
  8114. private getColorGradingDataToRef;
  8115. /**
  8116. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8117. * @param value The input slider value in range [-100,100].
  8118. * @returns Adjusted value.
  8119. */
  8120. private static applyColorGradingSliderNonlinear;
  8121. /**
  8122. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8123. * @param hue The hue (H) input.
  8124. * @param saturation The saturation (S) input.
  8125. * @param brightness The brightness (B) input.
  8126. * @result An RGBA color represented as Vector4.
  8127. */
  8128. private static fromHSBToRef;
  8129. /**
  8130. * Returns a value clamped between min and max
  8131. * @param value The value to clamp
  8132. * @param min The minimum of value
  8133. * @param max The maximum of value
  8134. * @returns The clamped value.
  8135. */
  8136. private static clamp;
  8137. /**
  8138. * Clones the current color curve instance.
  8139. * @return The cloned curves
  8140. */
  8141. clone(): ColorCurves;
  8142. /**
  8143. * Serializes the current color curve instance to a json representation.
  8144. * @return a JSON representation
  8145. */
  8146. serialize(): any;
  8147. /**
  8148. * Parses the color curve from a json representation.
  8149. * @param source the JSON source to parse
  8150. * @return The parsed curves
  8151. */
  8152. static Parse(source: any): ColorCurves;
  8153. }
  8154. }
  8155. declare module BABYLON {
  8156. /**
  8157. * Interface to follow in your material defines to integrate easily the
  8158. * Image proccessing functions.
  8159. * @hidden
  8160. */
  8161. export interface IImageProcessingConfigurationDefines {
  8162. IMAGEPROCESSING: boolean;
  8163. VIGNETTE: boolean;
  8164. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8165. VIGNETTEBLENDMODEOPAQUE: boolean;
  8166. TONEMAPPING: boolean;
  8167. TONEMAPPING_ACES: boolean;
  8168. CONTRAST: boolean;
  8169. EXPOSURE: boolean;
  8170. COLORCURVES: boolean;
  8171. COLORGRADING: boolean;
  8172. COLORGRADING3D: boolean;
  8173. SAMPLER3DGREENDEPTH: boolean;
  8174. SAMPLER3DBGRMAP: boolean;
  8175. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8176. }
  8177. /**
  8178. * @hidden
  8179. */
  8180. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. COLORCURVES: boolean;
  8189. COLORGRADING: boolean;
  8190. COLORGRADING3D: boolean;
  8191. SAMPLER3DGREENDEPTH: boolean;
  8192. SAMPLER3DBGRMAP: boolean;
  8193. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8194. EXPOSURE: boolean;
  8195. constructor();
  8196. }
  8197. /**
  8198. * This groups together the common properties used for image processing either in direct forward pass
  8199. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8200. * or not.
  8201. */
  8202. export class ImageProcessingConfiguration {
  8203. /**
  8204. * Default tone mapping applied in BabylonJS.
  8205. */
  8206. static readonly TONEMAPPING_STANDARD: number;
  8207. /**
  8208. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8209. * to other engines rendering to increase portability.
  8210. */
  8211. static readonly TONEMAPPING_ACES: number;
  8212. /**
  8213. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8214. */
  8215. colorCurves: Nullable<ColorCurves>;
  8216. private _colorCurvesEnabled;
  8217. /**
  8218. * Gets wether the color curves effect is enabled.
  8219. */
  8220. get colorCurvesEnabled(): boolean;
  8221. /**
  8222. * Sets wether the color curves effect is enabled.
  8223. */
  8224. set colorCurvesEnabled(value: boolean);
  8225. private _colorGradingTexture;
  8226. /**
  8227. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8228. */
  8229. get colorGradingTexture(): Nullable<BaseTexture>;
  8230. /**
  8231. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8232. */
  8233. set colorGradingTexture(value: Nullable<BaseTexture>);
  8234. private _colorGradingEnabled;
  8235. /**
  8236. * Gets wether the color grading effect is enabled.
  8237. */
  8238. get colorGradingEnabled(): boolean;
  8239. /**
  8240. * Sets wether the color grading effect is enabled.
  8241. */
  8242. set colorGradingEnabled(value: boolean);
  8243. private _colorGradingWithGreenDepth;
  8244. /**
  8245. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8246. */
  8247. get colorGradingWithGreenDepth(): boolean;
  8248. /**
  8249. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8250. */
  8251. set colorGradingWithGreenDepth(value: boolean);
  8252. private _colorGradingBGR;
  8253. /**
  8254. * Gets wether the color grading texture contains BGR values.
  8255. */
  8256. get colorGradingBGR(): boolean;
  8257. /**
  8258. * Sets wether the color grading texture contains BGR values.
  8259. */
  8260. set colorGradingBGR(value: boolean);
  8261. /** @hidden */
  8262. _exposure: number;
  8263. /**
  8264. * Gets the Exposure used in the effect.
  8265. */
  8266. get exposure(): number;
  8267. /**
  8268. * Sets the Exposure used in the effect.
  8269. */
  8270. set exposure(value: number);
  8271. private _toneMappingEnabled;
  8272. /**
  8273. * Gets wether the tone mapping effect is enabled.
  8274. */
  8275. get toneMappingEnabled(): boolean;
  8276. /**
  8277. * Sets wether the tone mapping effect is enabled.
  8278. */
  8279. set toneMappingEnabled(value: boolean);
  8280. private _toneMappingType;
  8281. /**
  8282. * Gets the type of tone mapping effect.
  8283. */
  8284. get toneMappingType(): number;
  8285. /**
  8286. * Sets the type of tone mapping effect used in BabylonJS.
  8287. */
  8288. set toneMappingType(value: number);
  8289. protected _contrast: number;
  8290. /**
  8291. * Gets the contrast used in the effect.
  8292. */
  8293. get contrast(): number;
  8294. /**
  8295. * Sets the contrast used in the effect.
  8296. */
  8297. set contrast(value: number);
  8298. /**
  8299. * Vignette stretch size.
  8300. */
  8301. vignetteStretch: number;
  8302. /**
  8303. * Vignette centre X Offset.
  8304. */
  8305. vignetteCentreX: number;
  8306. /**
  8307. * Vignette centre Y Offset.
  8308. */
  8309. vignetteCentreY: number;
  8310. /**
  8311. * Vignette weight or intensity of the vignette effect.
  8312. */
  8313. vignetteWeight: number;
  8314. /**
  8315. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8316. * if vignetteEnabled is set to true.
  8317. */
  8318. vignetteColor: Color4;
  8319. /**
  8320. * Camera field of view used by the Vignette effect.
  8321. */
  8322. vignetteCameraFov: number;
  8323. private _vignetteBlendMode;
  8324. /**
  8325. * Gets the vignette blend mode allowing different kind of effect.
  8326. */
  8327. get vignetteBlendMode(): number;
  8328. /**
  8329. * Sets the vignette blend mode allowing different kind of effect.
  8330. */
  8331. set vignetteBlendMode(value: number);
  8332. private _vignetteEnabled;
  8333. /**
  8334. * Gets wether the vignette effect is enabled.
  8335. */
  8336. get vignetteEnabled(): boolean;
  8337. /**
  8338. * Sets wether the vignette effect is enabled.
  8339. */
  8340. set vignetteEnabled(value: boolean);
  8341. private _applyByPostProcess;
  8342. /**
  8343. * Gets wether the image processing is applied through a post process or not.
  8344. */
  8345. get applyByPostProcess(): boolean;
  8346. /**
  8347. * Sets wether the image processing is applied through a post process or not.
  8348. */
  8349. set applyByPostProcess(value: boolean);
  8350. private _isEnabled;
  8351. /**
  8352. * Gets wether the image processing is enabled or not.
  8353. */
  8354. get isEnabled(): boolean;
  8355. /**
  8356. * Sets wether the image processing is enabled or not.
  8357. */
  8358. set isEnabled(value: boolean);
  8359. /**
  8360. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8361. */
  8362. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8363. /**
  8364. * Method called each time the image processing information changes requires to recompile the effect.
  8365. */
  8366. protected _updateParameters(): void;
  8367. /**
  8368. * Gets the current class name.
  8369. * @return "ImageProcessingConfiguration"
  8370. */
  8371. getClassName(): string;
  8372. /**
  8373. * Prepare the list of uniforms associated with the Image Processing effects.
  8374. * @param uniforms The list of uniforms used in the effect
  8375. * @param defines the list of defines currently in use
  8376. */
  8377. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8378. /**
  8379. * Prepare the list of samplers associated with the Image Processing effects.
  8380. * @param samplersList The list of uniforms used in the effect
  8381. * @param defines the list of defines currently in use
  8382. */
  8383. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8384. /**
  8385. * Prepare the list of defines associated to the shader.
  8386. * @param defines the list of defines to complete
  8387. * @param forPostProcess Define if we are currently in post process mode or not
  8388. */
  8389. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8390. /**
  8391. * Returns true if all the image processing information are ready.
  8392. * @returns True if ready, otherwise, false
  8393. */
  8394. isReady(): boolean;
  8395. /**
  8396. * Binds the image processing to the shader.
  8397. * @param effect The effect to bind to
  8398. * @param overrideAspectRatio Override the aspect ratio of the effect
  8399. */
  8400. bind(effect: Effect, overrideAspectRatio?: number): void;
  8401. /**
  8402. * Clones the current image processing instance.
  8403. * @return The cloned image processing
  8404. */
  8405. clone(): ImageProcessingConfiguration;
  8406. /**
  8407. * Serializes the current image processing instance to a json representation.
  8408. * @return a JSON representation
  8409. */
  8410. serialize(): any;
  8411. /**
  8412. * Parses the image processing from a json representation.
  8413. * @param source the JSON source to parse
  8414. * @return The parsed image processing
  8415. */
  8416. static Parse(source: any): ImageProcessingConfiguration;
  8417. private static _VIGNETTEMODE_MULTIPLY;
  8418. private static _VIGNETTEMODE_OPAQUE;
  8419. /**
  8420. * Used to apply the vignette as a mix with the pixel color.
  8421. */
  8422. static get VIGNETTEMODE_MULTIPLY(): number;
  8423. /**
  8424. * Used to apply the vignette as a replacement of the pixel color.
  8425. */
  8426. static get VIGNETTEMODE_OPAQUE(): number;
  8427. }
  8428. }
  8429. declare module BABYLON {
  8430. /** @hidden */
  8431. export var postprocessVertexShader: {
  8432. name: string;
  8433. shader: string;
  8434. };
  8435. }
  8436. declare module BABYLON {
  8437. interface ThinEngine {
  8438. /**
  8439. * Creates a new render target texture
  8440. * @param size defines the size of the texture
  8441. * @param options defines the options used to create the texture
  8442. * @returns a new render target texture stored in an InternalTexture
  8443. */
  8444. createRenderTargetTexture(size: number | {
  8445. width: number;
  8446. height: number;
  8447. layers?: number;
  8448. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8449. /**
  8450. * Creates a depth stencil texture.
  8451. * This is only available in WebGL 2 or with the depth texture extension available.
  8452. * @param size The size of face edge in the texture.
  8453. * @param options The options defining the texture.
  8454. * @returns The texture
  8455. */
  8456. createDepthStencilTexture(size: number | {
  8457. width: number;
  8458. height: number;
  8459. layers?: number;
  8460. }, options: DepthTextureCreationOptions): InternalTexture;
  8461. /** @hidden */
  8462. _createDepthStencilTexture(size: number | {
  8463. width: number;
  8464. height: number;
  8465. layers?: number;
  8466. }, options: DepthTextureCreationOptions): InternalTexture;
  8467. }
  8468. }
  8469. declare module BABYLON {
  8470. /** Defines supported spaces */
  8471. export enum Space {
  8472. /** Local (object) space */
  8473. LOCAL = 0,
  8474. /** World space */
  8475. WORLD = 1,
  8476. /** Bone space */
  8477. BONE = 2
  8478. }
  8479. /** Defines the 3 main axes */
  8480. export class Axis {
  8481. /** X axis */
  8482. static X: Vector3;
  8483. /** Y axis */
  8484. static Y: Vector3;
  8485. /** Z axis */
  8486. static Z: Vector3;
  8487. }
  8488. }
  8489. declare module BABYLON {
  8490. /**
  8491. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8492. * This is the base of the follow, arc rotate cameras and Free camera
  8493. * @see http://doc.babylonjs.com/features/cameras
  8494. */
  8495. export class TargetCamera extends Camera {
  8496. private static _RigCamTransformMatrix;
  8497. private static _TargetTransformMatrix;
  8498. private static _TargetFocalPoint;
  8499. /**
  8500. * Define the current direction the camera is moving to
  8501. */
  8502. cameraDirection: Vector3;
  8503. /**
  8504. * Define the current rotation the camera is rotating to
  8505. */
  8506. cameraRotation: Vector2;
  8507. /**
  8508. * When set, the up vector of the camera will be updated by the rotation of the camera
  8509. */
  8510. updateUpVectorFromRotation: boolean;
  8511. private _tmpQuaternion;
  8512. /**
  8513. * Define the current rotation of the camera
  8514. */
  8515. rotation: Vector3;
  8516. /**
  8517. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8518. */
  8519. rotationQuaternion: Quaternion;
  8520. /**
  8521. * Define the current speed of the camera
  8522. */
  8523. speed: number;
  8524. /**
  8525. * Add constraint to the camera to prevent it to move freely in all directions and
  8526. * around all axis.
  8527. */
  8528. noRotationConstraint: boolean;
  8529. /**
  8530. * Define the current target of the camera as an object or a position.
  8531. */
  8532. lockedTarget: any;
  8533. /** @hidden */
  8534. _currentTarget: Vector3;
  8535. /** @hidden */
  8536. _initialFocalDistance: number;
  8537. /** @hidden */
  8538. _viewMatrix: Matrix;
  8539. /** @hidden */
  8540. _camMatrix: Matrix;
  8541. /** @hidden */
  8542. _cameraTransformMatrix: Matrix;
  8543. /** @hidden */
  8544. _cameraRotationMatrix: Matrix;
  8545. /** @hidden */
  8546. _referencePoint: Vector3;
  8547. /** @hidden */
  8548. _transformedReferencePoint: Vector3;
  8549. protected _globalCurrentTarget: Vector3;
  8550. protected _globalCurrentUpVector: Vector3;
  8551. /** @hidden */
  8552. _reset: () => void;
  8553. private _defaultUp;
  8554. /**
  8555. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8556. * This is the base of the follow, arc rotate cameras and Free camera
  8557. * @see http://doc.babylonjs.com/features/cameras
  8558. * @param name Defines the name of the camera in the scene
  8559. * @param position Defines the start position of the camera in the scene
  8560. * @param scene Defines the scene the camera belongs to
  8561. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8562. */
  8563. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8564. /**
  8565. * Gets the position in front of the camera at a given distance.
  8566. * @param distance The distance from the camera we want the position to be
  8567. * @returns the position
  8568. */
  8569. getFrontPosition(distance: number): Vector3;
  8570. /** @hidden */
  8571. _getLockedTargetPosition(): Nullable<Vector3>;
  8572. private _storedPosition;
  8573. private _storedRotation;
  8574. private _storedRotationQuaternion;
  8575. /**
  8576. * Store current camera state of the camera (fov, position, rotation, etc..)
  8577. * @returns the camera
  8578. */
  8579. storeState(): Camera;
  8580. /**
  8581. * Restored camera state. You must call storeState() first
  8582. * @returns whether it was successful or not
  8583. * @hidden
  8584. */
  8585. _restoreStateValues(): boolean;
  8586. /** @hidden */
  8587. _initCache(): void;
  8588. /** @hidden */
  8589. _updateCache(ignoreParentClass?: boolean): void;
  8590. /** @hidden */
  8591. _isSynchronizedViewMatrix(): boolean;
  8592. /** @hidden */
  8593. _computeLocalCameraSpeed(): number;
  8594. /**
  8595. * Defines the target the camera should look at.
  8596. * @param target Defines the new target as a Vector or a mesh
  8597. */
  8598. setTarget(target: Vector3): void;
  8599. /**
  8600. * Return the current target position of the camera. This value is expressed in local space.
  8601. * @returns the target position
  8602. */
  8603. getTarget(): Vector3;
  8604. /** @hidden */
  8605. _decideIfNeedsToMove(): boolean;
  8606. /** @hidden */
  8607. _updatePosition(): void;
  8608. /** @hidden */
  8609. _checkInputs(): void;
  8610. protected _updateCameraRotationMatrix(): void;
  8611. /**
  8612. * 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)
  8613. * @returns the current camera
  8614. */
  8615. private _rotateUpVectorWithCameraRotationMatrix;
  8616. private _cachedRotationZ;
  8617. private _cachedQuaternionRotationZ;
  8618. /** @hidden */
  8619. _getViewMatrix(): Matrix;
  8620. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8621. /**
  8622. * @hidden
  8623. */
  8624. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8625. /**
  8626. * @hidden
  8627. */
  8628. _updateRigCameras(): void;
  8629. private _getRigCamPositionAndTarget;
  8630. /**
  8631. * Gets the current object class name.
  8632. * @return the class name
  8633. */
  8634. getClassName(): string;
  8635. }
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * Gather the list of keyboard event types as constants.
  8640. */
  8641. export class KeyboardEventTypes {
  8642. /**
  8643. * The keydown event is fired when a key becomes active (pressed).
  8644. */
  8645. static readonly KEYDOWN: number;
  8646. /**
  8647. * The keyup event is fired when a key has been released.
  8648. */
  8649. static readonly KEYUP: number;
  8650. }
  8651. /**
  8652. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8653. */
  8654. export class KeyboardInfo {
  8655. /**
  8656. * Defines the type of event (KeyboardEventTypes)
  8657. */
  8658. type: number;
  8659. /**
  8660. * Defines the related dom event
  8661. */
  8662. event: KeyboardEvent;
  8663. /**
  8664. * Instantiates a new keyboard info.
  8665. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8666. * @param type Defines the type of event (KeyboardEventTypes)
  8667. * @param event Defines the related dom event
  8668. */
  8669. constructor(
  8670. /**
  8671. * Defines the type of event (KeyboardEventTypes)
  8672. */
  8673. type: number,
  8674. /**
  8675. * Defines the related dom event
  8676. */
  8677. event: KeyboardEvent);
  8678. }
  8679. /**
  8680. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8681. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8682. */
  8683. export class KeyboardInfoPre extends KeyboardInfo {
  8684. /**
  8685. * Defines the type of event (KeyboardEventTypes)
  8686. */
  8687. type: number;
  8688. /**
  8689. * Defines the related dom event
  8690. */
  8691. event: KeyboardEvent;
  8692. /**
  8693. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8694. */
  8695. skipOnPointerObservable: boolean;
  8696. /**
  8697. * Instantiates a new keyboard pre info.
  8698. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. }
  8713. declare module BABYLON {
  8714. /**
  8715. * Manage the keyboard inputs to control the movement of a free camera.
  8716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8717. */
  8718. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8719. /**
  8720. * Defines the camera the input is attached to.
  8721. */
  8722. camera: FreeCamera;
  8723. /**
  8724. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8725. */
  8726. keysUp: number[];
  8727. /**
  8728. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8729. */
  8730. keysDown: number[];
  8731. /**
  8732. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8733. */
  8734. keysLeft: number[];
  8735. /**
  8736. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8737. */
  8738. keysRight: number[];
  8739. private _keys;
  8740. private _onCanvasBlurObserver;
  8741. private _onKeyboardObserver;
  8742. private _engine;
  8743. private _scene;
  8744. /**
  8745. * Attach the input controls to a specific dom element to get the input from.
  8746. * @param element Defines the element the controls should be listened from
  8747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8748. */
  8749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8750. /**
  8751. * Detach the current controls from the specified dom element.
  8752. * @param element Defines the element to stop listening the inputs from
  8753. */
  8754. detachControl(element: Nullable<HTMLElement>): void;
  8755. /**
  8756. * Update the current camera state depending on the inputs that have been used this frame.
  8757. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8758. */
  8759. checkInputs(): void;
  8760. /**
  8761. * Gets the class name of the current intput.
  8762. * @returns the class name
  8763. */
  8764. getClassName(): string;
  8765. /** @hidden */
  8766. _onLostFocus(): void;
  8767. /**
  8768. * Get the friendly name associated with the input class.
  8769. * @returns the input friendly name
  8770. */
  8771. getSimpleName(): string;
  8772. }
  8773. }
  8774. declare module BABYLON {
  8775. /**
  8776. * Interface describing all the common properties and methods a shadow light needs to implement.
  8777. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8778. * as well as binding the different shadow properties to the effects.
  8779. */
  8780. export interface IShadowLight extends Light {
  8781. /**
  8782. * The light id in the scene (used in scene.findLighById for instance)
  8783. */
  8784. id: string;
  8785. /**
  8786. * The position the shdow will be casted from.
  8787. */
  8788. position: Vector3;
  8789. /**
  8790. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8791. */
  8792. direction: Vector3;
  8793. /**
  8794. * The transformed position. Position of the light in world space taking parenting in account.
  8795. */
  8796. transformedPosition: Vector3;
  8797. /**
  8798. * The transformed direction. Direction of the light in world space taking parenting in account.
  8799. */
  8800. transformedDirection: Vector3;
  8801. /**
  8802. * The friendly name of the light in the scene.
  8803. */
  8804. name: string;
  8805. /**
  8806. * Defines the shadow projection clipping minimum z value.
  8807. */
  8808. shadowMinZ: number;
  8809. /**
  8810. * Defines the shadow projection clipping maximum z value.
  8811. */
  8812. shadowMaxZ: number;
  8813. /**
  8814. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8815. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8816. */
  8817. computeTransformedInformation(): boolean;
  8818. /**
  8819. * Gets the scene the light belongs to.
  8820. * @returns The scene
  8821. */
  8822. getScene(): Scene;
  8823. /**
  8824. * Callback defining a custom Projection Matrix Builder.
  8825. * This can be used to override the default projection matrix computation.
  8826. */
  8827. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8828. /**
  8829. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8830. * @param matrix The materix to updated with the projection information
  8831. * @param viewMatrix The transform matrix of the light
  8832. * @param renderList The list of mesh to render in the map
  8833. * @returns The current light
  8834. */
  8835. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8836. /**
  8837. * Gets the current depth scale used in ESM.
  8838. * @returns The scale
  8839. */
  8840. getDepthScale(): number;
  8841. /**
  8842. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8843. * @returns true if a cube texture needs to be use
  8844. */
  8845. needCube(): boolean;
  8846. /**
  8847. * Detects if the projection matrix requires to be recomputed this frame.
  8848. * @returns true if it requires to be recomputed otherwise, false.
  8849. */
  8850. needProjectionMatrixCompute(): boolean;
  8851. /**
  8852. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8853. */
  8854. forceProjectionMatrixCompute(): void;
  8855. /**
  8856. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8857. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8858. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8859. */
  8860. getShadowDirection(faceIndex?: number): Vector3;
  8861. /**
  8862. * Gets the minZ used for shadow according to both the scene and the light.
  8863. * @param activeCamera The camera we are returning the min for
  8864. * @returns the depth min z
  8865. */
  8866. getDepthMinZ(activeCamera: Camera): number;
  8867. /**
  8868. * Gets the maxZ used for shadow according to both the scene and the light.
  8869. * @param activeCamera The camera we are returning the max for
  8870. * @returns the depth max z
  8871. */
  8872. getDepthMaxZ(activeCamera: Camera): number;
  8873. }
  8874. /**
  8875. * Base implementation IShadowLight
  8876. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8877. */
  8878. export abstract class ShadowLight extends Light implements IShadowLight {
  8879. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8880. protected _position: Vector3;
  8881. protected _setPosition(value: Vector3): void;
  8882. /**
  8883. * Sets the position the shadow will be casted from. Also use as the light position for both
  8884. * point and spot lights.
  8885. */
  8886. get position(): Vector3;
  8887. /**
  8888. * Sets the position the shadow will be casted from. Also use as the light position for both
  8889. * point and spot lights.
  8890. */
  8891. set position(value: Vector3);
  8892. protected _direction: Vector3;
  8893. protected _setDirection(value: Vector3): void;
  8894. /**
  8895. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8896. * Also use as the light direction on spot and directional lights.
  8897. */
  8898. get direction(): Vector3;
  8899. /**
  8900. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8901. * Also use as the light direction on spot and directional lights.
  8902. */
  8903. set direction(value: Vector3);
  8904. protected _shadowMinZ: number;
  8905. /**
  8906. * Gets the shadow projection clipping minimum z value.
  8907. */
  8908. get shadowMinZ(): number;
  8909. /**
  8910. * Sets the shadow projection clipping minimum z value.
  8911. */
  8912. set shadowMinZ(value: number);
  8913. protected _shadowMaxZ: number;
  8914. /**
  8915. * Sets the shadow projection clipping maximum z value.
  8916. */
  8917. get shadowMaxZ(): number;
  8918. /**
  8919. * Gets the shadow projection clipping maximum z value.
  8920. */
  8921. set shadowMaxZ(value: number);
  8922. /**
  8923. * Callback defining a custom Projection Matrix Builder.
  8924. * This can be used to override the default projection matrix computation.
  8925. */
  8926. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8927. /**
  8928. * The transformed position. Position of the light in world space taking parenting in account.
  8929. */
  8930. transformedPosition: Vector3;
  8931. /**
  8932. * The transformed direction. Direction of the light in world space taking parenting in account.
  8933. */
  8934. transformedDirection: Vector3;
  8935. private _needProjectionMatrixCompute;
  8936. /**
  8937. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8938. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8939. */
  8940. computeTransformedInformation(): boolean;
  8941. /**
  8942. * Return the depth scale used for the shadow map.
  8943. * @returns the depth scale.
  8944. */
  8945. getDepthScale(): number;
  8946. /**
  8947. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8948. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8949. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8950. */
  8951. getShadowDirection(faceIndex?: number): Vector3;
  8952. /**
  8953. * Returns the ShadowLight absolute position in the World.
  8954. * @returns the position vector in world space
  8955. */
  8956. getAbsolutePosition(): Vector3;
  8957. /**
  8958. * Sets the ShadowLight direction toward the passed target.
  8959. * @param target The point to target in local space
  8960. * @returns the updated ShadowLight direction
  8961. */
  8962. setDirectionToTarget(target: Vector3): Vector3;
  8963. /**
  8964. * Returns the light rotation in euler definition.
  8965. * @returns the x y z rotation in local space.
  8966. */
  8967. getRotation(): Vector3;
  8968. /**
  8969. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8970. * @returns true if a cube texture needs to be use
  8971. */
  8972. needCube(): boolean;
  8973. /**
  8974. * Detects if the projection matrix requires to be recomputed this frame.
  8975. * @returns true if it requires to be recomputed otherwise, false.
  8976. */
  8977. needProjectionMatrixCompute(): boolean;
  8978. /**
  8979. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8980. */
  8981. forceProjectionMatrixCompute(): void;
  8982. /** @hidden */
  8983. _initCache(): void;
  8984. /** @hidden */
  8985. _isSynchronized(): boolean;
  8986. /**
  8987. * Computes the world matrix of the node
  8988. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8989. * @returns the world matrix
  8990. */
  8991. computeWorldMatrix(force?: boolean): Matrix;
  8992. /**
  8993. * Gets the minZ used for shadow according to both the scene and the light.
  8994. * @param activeCamera The camera we are returning the min for
  8995. * @returns the depth min z
  8996. */
  8997. getDepthMinZ(activeCamera: Camera): number;
  8998. /**
  8999. * Gets the maxZ used for shadow according to both the scene and the light.
  9000. * @param activeCamera The camera we are returning the max for
  9001. * @returns the depth max z
  9002. */
  9003. getDepthMaxZ(activeCamera: Camera): number;
  9004. /**
  9005. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9006. * @param matrix The materix to updated with the projection information
  9007. * @param viewMatrix The transform matrix of the light
  9008. * @param renderList The list of mesh to render in the map
  9009. * @returns The current light
  9010. */
  9011. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9012. }
  9013. }
  9014. declare module BABYLON {
  9015. /**
  9016. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9017. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9018. */
  9019. export class EffectFallbacks implements IEffectFallbacks {
  9020. private _defines;
  9021. private _currentRank;
  9022. private _maxRank;
  9023. private _mesh;
  9024. /**
  9025. * Removes the fallback from the bound mesh.
  9026. */
  9027. unBindMesh(): void;
  9028. /**
  9029. * Adds a fallback on the specified property.
  9030. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9031. * @param define The name of the define in the shader
  9032. */
  9033. addFallback(rank: number, define: string): void;
  9034. /**
  9035. * Sets the mesh to use CPU skinning when needing to fallback.
  9036. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9037. * @param mesh The mesh to use the fallbacks.
  9038. */
  9039. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9040. /**
  9041. * Checks to see if more fallbacks are still availible.
  9042. */
  9043. get hasMoreFallbacks(): boolean;
  9044. /**
  9045. * Removes the defines that should be removed when falling back.
  9046. * @param currentDefines defines the current define statements for the shader.
  9047. * @param effect defines the current effect we try to compile
  9048. * @returns The resulting defines with defines of the current rank removed.
  9049. */
  9050. reduce(currentDefines: string, effect: Effect): string;
  9051. }
  9052. }
  9053. declare module BABYLON {
  9054. /**
  9055. * "Static Class" containing the most commonly used helper while dealing with material for
  9056. * rendering purpose.
  9057. *
  9058. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9059. *
  9060. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9061. */
  9062. export class MaterialHelper {
  9063. /**
  9064. * Bind the current view position to an effect.
  9065. * @param effect The effect to be bound
  9066. * @param scene The scene the eyes position is used from
  9067. */
  9068. static BindEyePosition(effect: Effect, scene: Scene): void;
  9069. /**
  9070. * Helps preparing the defines values about the UVs in used in the effect.
  9071. * UVs are shared as much as we can accross channels in the shaders.
  9072. * @param texture The texture we are preparing the UVs for
  9073. * @param defines The defines to update
  9074. * @param key The channel key "diffuse", "specular"... used in the shader
  9075. */
  9076. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9077. /**
  9078. * Binds a texture matrix value to its corrsponding uniform
  9079. * @param texture The texture to bind the matrix for
  9080. * @param uniformBuffer The uniform buffer receivin the data
  9081. * @param key The channel key "diffuse", "specular"... used in the shader
  9082. */
  9083. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9084. /**
  9085. * Gets the current status of the fog (should it be enabled?)
  9086. * @param mesh defines the mesh to evaluate for fog support
  9087. * @param scene defines the hosting scene
  9088. * @returns true if fog must be enabled
  9089. */
  9090. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9091. /**
  9092. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9093. * @param mesh defines the current mesh
  9094. * @param scene defines the current scene
  9095. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9096. * @param pointsCloud defines if point cloud rendering has to be turned on
  9097. * @param fogEnabled defines if fog has to be turned on
  9098. * @param alphaTest defines if alpha testing has to be turned on
  9099. * @param defines defines the current list of defines
  9100. */
  9101. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9102. /**
  9103. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9104. * @param scene defines the current scene
  9105. * @param engine defines the current engine
  9106. * @param defines specifies the list of active defines
  9107. * @param useInstances defines if instances have to be turned on
  9108. * @param useClipPlane defines if clip plane have to be turned on
  9109. */
  9110. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9111. /**
  9112. * Prepares the defines for bones
  9113. * @param mesh The mesh containing the geometry data we will draw
  9114. * @param defines The defines to update
  9115. */
  9116. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9117. /**
  9118. * Prepares the defines for morph targets
  9119. * @param mesh The mesh containing the geometry data we will draw
  9120. * @param defines The defines to update
  9121. */
  9122. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9123. /**
  9124. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9125. * @param mesh The mesh containing the geometry data we will draw
  9126. * @param defines The defines to update
  9127. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9128. * @param useBones Precise whether bones should be used or not (override mesh info)
  9129. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9130. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9131. * @returns false if defines are considered not dirty and have not been checked
  9132. */
  9133. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9134. /**
  9135. * Prepares the defines related to multiview
  9136. * @param scene The scene we are intending to draw
  9137. * @param defines The defines to update
  9138. */
  9139. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9140. /**
  9141. * Prepares the defines related to the light information passed in parameter
  9142. * @param scene The scene we are intending to draw
  9143. * @param mesh The mesh the effect is compiling for
  9144. * @param light The light the effect is compiling for
  9145. * @param lightIndex The index of the light
  9146. * @param defines The defines to update
  9147. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9148. * @param state Defines the current state regarding what is needed (normals, etc...)
  9149. */
  9150. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9151. needNormals: boolean;
  9152. needRebuild: boolean;
  9153. shadowEnabled: boolean;
  9154. specularEnabled: boolean;
  9155. lightmapMode: boolean;
  9156. }): void;
  9157. /**
  9158. * Prepares the defines related to the light information passed in parameter
  9159. * @param scene The scene we are intending to draw
  9160. * @param mesh The mesh the effect is compiling for
  9161. * @param defines The defines to update
  9162. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9163. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9164. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9165. * @returns true if normals will be required for the rest of the effect
  9166. */
  9167. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9168. /**
  9169. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9170. * @param lightIndex defines the light index
  9171. * @param uniformsList The uniform list
  9172. * @param samplersList The sampler list
  9173. * @param projectedLightTexture defines if projected texture must be used
  9174. * @param uniformBuffersList defines an optional list of uniform buffers
  9175. */
  9176. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9177. /**
  9178. * Prepares the uniforms and samplers list to be used in the effect
  9179. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9180. * @param samplersList The sampler list
  9181. * @param defines The defines helping in the list generation
  9182. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9183. */
  9184. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9185. /**
  9186. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9187. * @param defines The defines to update while falling back
  9188. * @param fallbacks The authorized effect fallbacks
  9189. * @param maxSimultaneousLights The maximum number of lights allowed
  9190. * @param rank the current rank of the Effect
  9191. * @returns The newly affected rank
  9192. */
  9193. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9194. private static _TmpMorphInfluencers;
  9195. /**
  9196. * Prepares the list of attributes required for morph targets according to the effect defines.
  9197. * @param attribs The current list of supported attribs
  9198. * @param mesh The mesh to prepare the morph targets attributes for
  9199. * @param influencers The number of influencers
  9200. */
  9201. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9202. /**
  9203. * Prepares the list of attributes required for morph targets according to the effect defines.
  9204. * @param attribs The current list of supported attribs
  9205. * @param mesh The mesh to prepare the morph targets attributes for
  9206. * @param defines The current Defines of the effect
  9207. */
  9208. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9209. /**
  9210. * Prepares the list of attributes required for bones according to the effect defines.
  9211. * @param attribs The current list of supported attribs
  9212. * @param mesh The mesh to prepare the bones attributes for
  9213. * @param defines The current Defines of the effect
  9214. * @param fallbacks The current efffect fallback strategy
  9215. */
  9216. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9217. /**
  9218. * Check and prepare the list of attributes required for instances according to the effect defines.
  9219. * @param attribs The current list of supported attribs
  9220. * @param defines The current MaterialDefines of the effect
  9221. */
  9222. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9223. /**
  9224. * Add the list of attributes required for instances to the attribs array.
  9225. * @param attribs The current list of supported attribs
  9226. */
  9227. static PushAttributesForInstances(attribs: string[]): void;
  9228. /**
  9229. * Binds the light information to the effect.
  9230. * @param light The light containing the generator
  9231. * @param effect The effect we are binding the data to
  9232. * @param lightIndex The light index in the effect used to render
  9233. */
  9234. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9235. /**
  9236. * Binds the lights information from the scene to the effect for the given mesh.
  9237. * @param light Light to bind
  9238. * @param lightIndex Light index
  9239. * @param scene The scene where the light belongs to
  9240. * @param effect The effect we are binding the data to
  9241. * @param useSpecular Defines if specular is supported
  9242. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9243. */
  9244. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9245. /**
  9246. * Binds the lights information from the scene to the effect for the given mesh.
  9247. * @param scene The scene the lights belongs to
  9248. * @param mesh The mesh we are binding the information to render
  9249. * @param effect The effect we are binding the data to
  9250. * @param defines The generated defines for the effect
  9251. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9252. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9253. */
  9254. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9255. private static _tempFogColor;
  9256. /**
  9257. * Binds the fog information from the scene to the effect for the given mesh.
  9258. * @param scene The scene the lights belongs to
  9259. * @param mesh The mesh we are binding the information to render
  9260. * @param effect The effect we are binding the data to
  9261. * @param linearSpace Defines if the fog effect is applied in linear space
  9262. */
  9263. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9264. /**
  9265. * Binds the bones information from the mesh to the effect.
  9266. * @param mesh The mesh we are binding the information to render
  9267. * @param effect The effect we are binding the data to
  9268. */
  9269. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9270. /**
  9271. * Binds the morph targets information from the mesh to the effect.
  9272. * @param abstractMesh The mesh we are binding the information to render
  9273. * @param effect The effect we are binding the data to
  9274. */
  9275. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9276. /**
  9277. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9278. * @param defines The generated defines used in the effect
  9279. * @param effect The effect we are binding the data to
  9280. * @param scene The scene we are willing to render with logarithmic scale for
  9281. */
  9282. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9283. /**
  9284. * Binds the clip plane information from the scene to the effect.
  9285. * @param scene The scene the clip plane information are extracted from
  9286. * @param effect The effect we are binding the data to
  9287. */
  9288. static BindClipPlane(effect: Effect, scene: Scene): void;
  9289. }
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var packingFunctions: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /** @hidden */
  9300. export var clipPlaneFragmentDeclaration: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module BABYLON {
  9306. /** @hidden */
  9307. export var clipPlaneFragment: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var shadowMapPixelShader: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var bonesDeclaration: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var morphTargetsVertexGlobalDeclaration: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var morphTargetsVertexDeclaration: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var instancesDeclaration: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var helperFunctions: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var clipPlaneVertexDeclaration: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var morphTargetsVertex: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var instancesVertex: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var bonesVertex: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var clipPlaneVertex: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var shadowMapVertexShader: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var depthBoxBlurPixelShader: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /**
  9405. * Class representing a ray with position and direction
  9406. */
  9407. export class Ray {
  9408. /** origin point */
  9409. origin: Vector3;
  9410. /** direction */
  9411. direction: Vector3;
  9412. /** length of the ray */
  9413. length: number;
  9414. private static readonly TmpVector3;
  9415. private _tmpRay;
  9416. /**
  9417. * Creates a new ray
  9418. * @param origin origin point
  9419. * @param direction direction
  9420. * @param length length of the ray
  9421. */
  9422. constructor(
  9423. /** origin point */
  9424. origin: Vector3,
  9425. /** direction */
  9426. direction: Vector3,
  9427. /** length of the ray */
  9428. length?: number);
  9429. /**
  9430. * Checks if the ray intersects a box
  9431. * @param minimum bound of the box
  9432. * @param maximum bound of the box
  9433. * @param intersectionTreshold extra extend to be added to the box in all direction
  9434. * @returns if the box was hit
  9435. */
  9436. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9437. /**
  9438. * Checks if the ray intersects a box
  9439. * @param box the bounding box to check
  9440. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9441. * @returns if the box was hit
  9442. */
  9443. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9444. /**
  9445. * If the ray hits a sphere
  9446. * @param sphere the bounding sphere to check
  9447. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9448. * @returns true if it hits the sphere
  9449. */
  9450. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9451. /**
  9452. * If the ray hits a triange
  9453. * @param vertex0 triangle vertex
  9454. * @param vertex1 triangle vertex
  9455. * @param vertex2 triangle vertex
  9456. * @returns intersection information if hit
  9457. */
  9458. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9459. /**
  9460. * Checks if ray intersects a plane
  9461. * @param plane the plane to check
  9462. * @returns the distance away it was hit
  9463. */
  9464. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9465. /**
  9466. * Calculate the intercept of a ray on a given axis
  9467. * @param axis to check 'x' | 'y' | 'z'
  9468. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9469. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9470. */
  9471. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9472. /**
  9473. * Checks if ray intersects a mesh
  9474. * @param mesh the mesh to check
  9475. * @param fastCheck if only the bounding box should checked
  9476. * @returns picking info of the intersecton
  9477. */
  9478. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9479. /**
  9480. * Checks if ray intersects a mesh
  9481. * @param meshes the meshes to check
  9482. * @param fastCheck if only the bounding box should checked
  9483. * @param results array to store result in
  9484. * @returns Array of picking infos
  9485. */
  9486. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9487. private _comparePickingInfo;
  9488. private static smallnum;
  9489. private static rayl;
  9490. /**
  9491. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9492. * @param sega the first point of the segment to test the intersection against
  9493. * @param segb the second point of the segment to test the intersection against
  9494. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9495. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9496. */
  9497. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9498. /**
  9499. * Update the ray from viewport position
  9500. * @param x position
  9501. * @param y y position
  9502. * @param viewportWidth viewport width
  9503. * @param viewportHeight viewport height
  9504. * @param world world matrix
  9505. * @param view view matrix
  9506. * @param projection projection matrix
  9507. * @returns this ray updated
  9508. */
  9509. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9510. /**
  9511. * Creates a ray with origin and direction of 0,0,0
  9512. * @returns the new ray
  9513. */
  9514. static Zero(): Ray;
  9515. /**
  9516. * Creates a new ray from screen space and viewport
  9517. * @param x position
  9518. * @param y y position
  9519. * @param viewportWidth viewport width
  9520. * @param viewportHeight viewport height
  9521. * @param world world matrix
  9522. * @param view view matrix
  9523. * @param projection projection matrix
  9524. * @returns new ray
  9525. */
  9526. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9527. /**
  9528. * 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
  9529. * transformed to the given world matrix.
  9530. * @param origin The origin point
  9531. * @param end The end point
  9532. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9533. * @returns the new ray
  9534. */
  9535. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9536. /**
  9537. * Transforms a ray by a matrix
  9538. * @param ray ray to transform
  9539. * @param matrix matrix to apply
  9540. * @returns the resulting new ray
  9541. */
  9542. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9543. /**
  9544. * Transforms a ray by a matrix
  9545. * @param ray ray to transform
  9546. * @param matrix matrix to apply
  9547. * @param result ray to store result in
  9548. */
  9549. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9550. /**
  9551. * Unproject a ray from screen space to object space
  9552. * @param sourceX defines the screen space x coordinate to use
  9553. * @param sourceY defines the screen space y coordinate to use
  9554. * @param viewportWidth defines the current width of the viewport
  9555. * @param viewportHeight defines the current height of the viewport
  9556. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9557. * @param view defines the view matrix to use
  9558. * @param projection defines the projection matrix to use
  9559. */
  9560. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9561. }
  9562. /**
  9563. * Type used to define predicate used to select faces when a mesh intersection is detected
  9564. */
  9565. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9566. interface Scene {
  9567. /** @hidden */
  9568. _tempPickingRay: Nullable<Ray>;
  9569. /** @hidden */
  9570. _cachedRayForTransform: Ray;
  9571. /** @hidden */
  9572. _pickWithRayInverseMatrix: Matrix;
  9573. /** @hidden */
  9574. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9575. /** @hidden */
  9576. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9577. }
  9578. }
  9579. declare module BABYLON {
  9580. /**
  9581. * Groups all the scene component constants in one place to ease maintenance.
  9582. * @hidden
  9583. */
  9584. export class SceneComponentConstants {
  9585. static readonly NAME_EFFECTLAYER: string;
  9586. static readonly NAME_LAYER: string;
  9587. static readonly NAME_LENSFLARESYSTEM: string;
  9588. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9589. static readonly NAME_PARTICLESYSTEM: string;
  9590. static readonly NAME_GAMEPAD: string;
  9591. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9592. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9593. static readonly NAME_DEPTHRENDERER: string;
  9594. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9595. static readonly NAME_SPRITE: string;
  9596. static readonly NAME_OUTLINERENDERER: string;
  9597. static readonly NAME_PROCEDURALTEXTURE: string;
  9598. static readonly NAME_SHADOWGENERATOR: string;
  9599. static readonly NAME_OCTREE: string;
  9600. static readonly NAME_PHYSICSENGINE: string;
  9601. static readonly NAME_AUDIO: string;
  9602. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9603. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9604. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9605. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9606. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9607. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9608. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9609. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9610. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9611. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9612. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9613. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9614. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9615. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9616. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9617. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9618. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9619. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9620. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9621. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9622. static readonly STEP_AFTERRENDER_AUDIO: number;
  9623. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9624. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9625. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9626. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9627. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9628. static readonly STEP_POINTERMOVE_SPRITE: number;
  9629. static readonly STEP_POINTERDOWN_SPRITE: number;
  9630. static readonly STEP_POINTERUP_SPRITE: number;
  9631. }
  9632. /**
  9633. * This represents a scene component.
  9634. *
  9635. * This is used to decouple the dependency the scene is having on the different workloads like
  9636. * layers, post processes...
  9637. */
  9638. export interface ISceneComponent {
  9639. /**
  9640. * The name of the component. Each component must have a unique name.
  9641. */
  9642. name: string;
  9643. /**
  9644. * The scene the component belongs to.
  9645. */
  9646. scene: Scene;
  9647. /**
  9648. * Register the component to one instance of a scene.
  9649. */
  9650. register(): void;
  9651. /**
  9652. * Rebuilds the elements related to this component in case of
  9653. * context lost for instance.
  9654. */
  9655. rebuild(): void;
  9656. /**
  9657. * Disposes the component and the associated ressources.
  9658. */
  9659. dispose(): void;
  9660. }
  9661. /**
  9662. * This represents a SERIALIZABLE scene component.
  9663. *
  9664. * This extends Scene Component to add Serialization methods on top.
  9665. */
  9666. export interface ISceneSerializableComponent extends ISceneComponent {
  9667. /**
  9668. * Adds all the elements from the container to the scene
  9669. * @param container the container holding the elements
  9670. */
  9671. addFromContainer(container: AbstractScene): void;
  9672. /**
  9673. * Removes all the elements in the container from the scene
  9674. * @param container contains the elements to remove
  9675. * @param dispose if the removed element should be disposed (default: false)
  9676. */
  9677. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9678. /**
  9679. * Serializes the component data to the specified json object
  9680. * @param serializationObject The object to serialize to
  9681. */
  9682. serialize(serializationObject: any): void;
  9683. }
  9684. /**
  9685. * Strong typing of a Mesh related stage step action
  9686. */
  9687. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9688. /**
  9689. * Strong typing of a Evaluate Sub Mesh related stage step action
  9690. */
  9691. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9692. /**
  9693. * Strong typing of a Active Mesh related stage step action
  9694. */
  9695. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9696. /**
  9697. * Strong typing of a Camera related stage step action
  9698. */
  9699. export type CameraStageAction = (camera: Camera) => void;
  9700. /**
  9701. * Strong typing of a Camera Frame buffer related stage step action
  9702. */
  9703. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9704. /**
  9705. * Strong typing of a Render Target related stage step action
  9706. */
  9707. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9708. /**
  9709. * Strong typing of a RenderingGroup related stage step action
  9710. */
  9711. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9712. /**
  9713. * Strong typing of a Mesh Render related stage step action
  9714. */
  9715. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9716. /**
  9717. * Strong typing of a simple stage step action
  9718. */
  9719. export type SimpleStageAction = () => void;
  9720. /**
  9721. * Strong typing of a render target action.
  9722. */
  9723. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9724. /**
  9725. * Strong typing of a pointer move action.
  9726. */
  9727. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9728. /**
  9729. * Strong typing of a pointer up/down action.
  9730. */
  9731. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9732. /**
  9733. * Representation of a stage in the scene (Basically a list of ordered steps)
  9734. * @hidden
  9735. */
  9736. export class Stage<T extends Function> extends Array<{
  9737. index: number;
  9738. component: ISceneComponent;
  9739. action: T;
  9740. }> {
  9741. /**
  9742. * Hide ctor from the rest of the world.
  9743. * @param items The items to add.
  9744. */
  9745. private constructor();
  9746. /**
  9747. * Creates a new Stage.
  9748. * @returns A new instance of a Stage
  9749. */
  9750. static Create<T extends Function>(): Stage<T>;
  9751. /**
  9752. * Registers a step in an ordered way in the targeted stage.
  9753. * @param index Defines the position to register the step in
  9754. * @param component Defines the component attached to the step
  9755. * @param action Defines the action to launch during the step
  9756. */
  9757. registerStep(index: number, component: ISceneComponent, action: T): void;
  9758. /**
  9759. * Clears all the steps from the stage.
  9760. */
  9761. clear(): void;
  9762. }
  9763. }
  9764. declare module BABYLON {
  9765. interface Scene {
  9766. /** @hidden */
  9767. _pointerOverSprite: Nullable<Sprite>;
  9768. /** @hidden */
  9769. _pickedDownSprite: Nullable<Sprite>;
  9770. /** @hidden */
  9771. _tempSpritePickingRay: Nullable<Ray>;
  9772. /**
  9773. * All of the sprite managers added to this scene
  9774. * @see http://doc.babylonjs.com/babylon101/sprites
  9775. */
  9776. spriteManagers: Array<ISpriteManager>;
  9777. /**
  9778. * An event triggered when sprites rendering is about to start
  9779. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9780. */
  9781. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9782. /**
  9783. * An event triggered when sprites rendering is done
  9784. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9785. */
  9786. onAfterSpritesRenderingObservable: Observable<Scene>;
  9787. /** @hidden */
  9788. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9789. /** Launch a ray to try to pick a sprite in the scene
  9790. * @param x position on screen
  9791. * @param y position on screen
  9792. * @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
  9793. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9794. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9795. * @returns a PickingInfo
  9796. */
  9797. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9798. /** Use the given ray to pick a sprite in the scene
  9799. * @param ray The ray (in world space) to use to pick meshes
  9800. * @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
  9801. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9802. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9803. * @returns a PickingInfo
  9804. */
  9805. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9806. /** @hidden */
  9807. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9808. /** Launch a ray to try to pick sprites in the scene
  9809. * @param x position on screen
  9810. * @param y position on screen
  9811. * @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
  9812. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9813. * @returns a PickingInfo array
  9814. */
  9815. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9816. /** Use the given ray to pick sprites in the scene
  9817. * @param ray The ray (in world space) to use to pick meshes
  9818. * @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
  9819. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9820. * @returns a PickingInfo array
  9821. */
  9822. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9823. /**
  9824. * Force the sprite under the pointer
  9825. * @param sprite defines the sprite to use
  9826. */
  9827. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9828. /**
  9829. * Gets the sprite under the pointer
  9830. * @returns a Sprite or null if no sprite is under the pointer
  9831. */
  9832. getPointerOverSprite(): Nullable<Sprite>;
  9833. }
  9834. /**
  9835. * Defines the sprite scene component responsible to manage sprites
  9836. * in a given scene.
  9837. */
  9838. export class SpriteSceneComponent implements ISceneComponent {
  9839. /**
  9840. * The component name helpfull to identify the component in the list of scene components.
  9841. */
  9842. readonly name: string;
  9843. /**
  9844. * The scene the component belongs to.
  9845. */
  9846. scene: Scene;
  9847. /** @hidden */
  9848. private _spritePredicate;
  9849. /**
  9850. * Creates a new instance of the component for the given scene
  9851. * @param scene Defines the scene to register the component in
  9852. */
  9853. constructor(scene: Scene);
  9854. /**
  9855. * Registers the component in a given scene
  9856. */
  9857. register(): void;
  9858. /**
  9859. * Rebuilds the elements related to this component in case of
  9860. * context lost for instance.
  9861. */
  9862. rebuild(): void;
  9863. /**
  9864. * Disposes the component and the associated ressources.
  9865. */
  9866. dispose(): void;
  9867. private _pickSpriteButKeepRay;
  9868. private _pointerMove;
  9869. private _pointerDown;
  9870. private _pointerUp;
  9871. }
  9872. }
  9873. declare module BABYLON {
  9874. /** @hidden */
  9875. export var fogFragmentDeclaration: {
  9876. name: string;
  9877. shader: string;
  9878. };
  9879. }
  9880. declare module BABYLON {
  9881. /** @hidden */
  9882. export var fogFragment: {
  9883. name: string;
  9884. shader: string;
  9885. };
  9886. }
  9887. declare module BABYLON {
  9888. /** @hidden */
  9889. export var spritesPixelShader: {
  9890. name: string;
  9891. shader: string;
  9892. };
  9893. }
  9894. declare module BABYLON {
  9895. /** @hidden */
  9896. export var fogVertexDeclaration: {
  9897. name: string;
  9898. shader: string;
  9899. };
  9900. }
  9901. declare module BABYLON {
  9902. /** @hidden */
  9903. export var spritesVertexShader: {
  9904. name: string;
  9905. shader: string;
  9906. };
  9907. }
  9908. declare module BABYLON {
  9909. /**
  9910. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9911. */
  9912. export interface ISpriteManager extends IDisposable {
  9913. /**
  9914. * Restricts the camera to viewing objects with the same layerMask.
  9915. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9916. */
  9917. layerMask: number;
  9918. /**
  9919. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9920. */
  9921. isPickable: boolean;
  9922. /**
  9923. * Specifies the rendering group id for this mesh (0 by default)
  9924. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9925. */
  9926. renderingGroupId: number;
  9927. /**
  9928. * Defines the list of sprites managed by the manager.
  9929. */
  9930. sprites: Array<Sprite>;
  9931. /**
  9932. * Tests the intersection of a sprite with a specific ray.
  9933. * @param ray The ray we are sending to test the collision
  9934. * @param camera The camera space we are sending rays in
  9935. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9936. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9937. * @returns picking info or null.
  9938. */
  9939. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9940. /**
  9941. * Intersects the sprites with a ray
  9942. * @param ray defines the ray to intersect with
  9943. * @param camera defines the current active camera
  9944. * @param predicate defines a predicate used to select candidate sprites
  9945. * @returns null if no hit or a PickingInfo array
  9946. */
  9947. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9948. /**
  9949. * Renders the list of sprites on screen.
  9950. */
  9951. render(): void;
  9952. }
  9953. /**
  9954. * Class used to manage multiple sprites on the same spritesheet
  9955. * @see http://doc.babylonjs.com/babylon101/sprites
  9956. */
  9957. export class SpriteManager implements ISpriteManager {
  9958. /** defines the manager's name */
  9959. name: string;
  9960. /** Gets the list of sprites */
  9961. sprites: Sprite[];
  9962. /** Gets or sets the rendering group id (0 by default) */
  9963. renderingGroupId: number;
  9964. /** Gets or sets camera layer mask */
  9965. layerMask: number;
  9966. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  9967. fogEnabled: boolean;
  9968. /** Gets or sets a boolean indicating if the sprites are pickable */
  9969. isPickable: boolean;
  9970. /** Defines the default width of a cell in the spritesheet */
  9971. cellWidth: number;
  9972. /** Defines the default height of a cell in the spritesheet */
  9973. cellHeight: number;
  9974. /** Associative array from JSON sprite data file */
  9975. private _cellData;
  9976. /** Array of sprite names from JSON sprite data file */
  9977. private _spriteMap;
  9978. /** True when packed cell data from JSON file is ready*/
  9979. private _packedAndReady;
  9980. /**
  9981. * An event triggered when the manager is disposed.
  9982. */
  9983. onDisposeObservable: Observable<SpriteManager>;
  9984. private _onDisposeObserver;
  9985. /**
  9986. * Callback called when the manager is disposed
  9987. */
  9988. set onDispose(callback: () => void);
  9989. private _capacity;
  9990. private _fromPacked;
  9991. private _spriteTexture;
  9992. private _epsilon;
  9993. private _scene;
  9994. private _vertexData;
  9995. private _buffer;
  9996. private _vertexBuffers;
  9997. private _indexBuffer;
  9998. private _effectBase;
  9999. private _effectFog;
  10000. /**
  10001. * Gets or sets the spritesheet texture
  10002. */
  10003. get texture(): Texture;
  10004. set texture(value: Texture);
  10005. private _blendMode;
  10006. /**
  10007. * Blend mode use to render the particle, it can be any of
  10008. * the static Constants.ALPHA_x properties provided in this class.
  10009. * Default value is Constants.ALPHA_COMBINE
  10010. */
  10011. get blendMode(): number;
  10012. set blendMode(blendMode: number);
  10013. /** Disables writing to the depth buffer when rendering the sprites.
  10014. * It can be handy to disable depth writing when using textures without alpha channel
  10015. * and setting some specific blend modes.
  10016. */
  10017. disableDepthWrite: boolean;
  10018. /**
  10019. * Creates a new sprite manager
  10020. * @param name defines the manager's name
  10021. * @param imgUrl defines the sprite sheet url
  10022. * @param capacity defines the maximum allowed number of sprites
  10023. * @param cellSize defines the size of a sprite cell
  10024. * @param scene defines the hosting scene
  10025. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10026. * @param samplingMode defines the smapling mode to use with spritesheet
  10027. * @param fromPacked set to false; do not alter
  10028. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10029. */
  10030. constructor(
  10031. /** defines the manager's name */
  10032. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10033. private _makePacked;
  10034. private _appendSpriteVertex;
  10035. /**
  10036. * Intersects the sprites with a ray
  10037. * @param ray defines the ray to intersect with
  10038. * @param camera defines the current active camera
  10039. * @param predicate defines a predicate used to select candidate sprites
  10040. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10041. * @returns null if no hit or a PickingInfo
  10042. */
  10043. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10044. /**
  10045. * Intersects the sprites with a ray
  10046. * @param ray defines the ray to intersect with
  10047. * @param camera defines the current active camera
  10048. * @param predicate defines a predicate used to select candidate sprites
  10049. * @returns null if no hit or a PickingInfo array
  10050. */
  10051. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10052. /**
  10053. * Render all child sprites
  10054. */
  10055. render(): void;
  10056. /**
  10057. * Release associated resources
  10058. */
  10059. dispose(): void;
  10060. }
  10061. }
  10062. declare module BABYLON {
  10063. /** Interface used by value gradients (color, factor, ...) */
  10064. export interface IValueGradient {
  10065. /**
  10066. * Gets or sets the gradient value (between 0 and 1)
  10067. */
  10068. gradient: number;
  10069. }
  10070. /** Class used to store color4 gradient */
  10071. export class ColorGradient implements IValueGradient {
  10072. /**
  10073. * Gets or sets the gradient value (between 0 and 1)
  10074. */
  10075. gradient: number;
  10076. /**
  10077. * Gets or sets first associated color
  10078. */
  10079. color1: Color4;
  10080. /**
  10081. * Gets or sets second associated color
  10082. */
  10083. color2?: Color4;
  10084. /**
  10085. * Will get a color picked randomly between color1 and color2.
  10086. * If color2 is undefined then color1 will be used
  10087. * @param result defines the target Color4 to store the result in
  10088. */
  10089. getColorToRef(result: Color4): void;
  10090. }
  10091. /** Class used to store color 3 gradient */
  10092. export class Color3Gradient implements IValueGradient {
  10093. /**
  10094. * Gets or sets the gradient value (between 0 and 1)
  10095. */
  10096. gradient: number;
  10097. /**
  10098. * Gets or sets the associated color
  10099. */
  10100. color: Color3;
  10101. }
  10102. /** Class used to store factor gradient */
  10103. export class FactorGradient implements IValueGradient {
  10104. /**
  10105. * Gets or sets the gradient value (between 0 and 1)
  10106. */
  10107. gradient: number;
  10108. /**
  10109. * Gets or sets first associated factor
  10110. */
  10111. factor1: number;
  10112. /**
  10113. * Gets or sets second associated factor
  10114. */
  10115. factor2?: number;
  10116. /**
  10117. * Will get a number picked randomly between factor1 and factor2.
  10118. * If factor2 is undefined then factor1 will be used
  10119. * @returns the picked number
  10120. */
  10121. getFactor(): number;
  10122. }
  10123. /**
  10124. * Helper used to simplify some generic gradient tasks
  10125. */
  10126. export class GradientHelper {
  10127. /**
  10128. * Gets the current gradient from an array of IValueGradient
  10129. * @param ratio defines the current ratio to get
  10130. * @param gradients defines the array of IValueGradient
  10131. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10132. */
  10133. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10134. }
  10135. }
  10136. declare module BABYLON {
  10137. /**
  10138. * Interface for the size containing width and height
  10139. */
  10140. export interface ISize {
  10141. /**
  10142. * Width
  10143. */
  10144. width: number;
  10145. /**
  10146. * Heighht
  10147. */
  10148. height: number;
  10149. }
  10150. /**
  10151. * Size containing widht and height
  10152. */
  10153. export class Size implements ISize {
  10154. /**
  10155. * Width
  10156. */
  10157. width: number;
  10158. /**
  10159. * Height
  10160. */
  10161. height: number;
  10162. /**
  10163. * Creates a Size object from the given width and height (floats).
  10164. * @param width width of the new size
  10165. * @param height height of the new size
  10166. */
  10167. constructor(width: number, height: number);
  10168. /**
  10169. * Returns a string with the Size width and height
  10170. * @returns a string with the Size width and height
  10171. */
  10172. toString(): string;
  10173. /**
  10174. * "Size"
  10175. * @returns the string "Size"
  10176. */
  10177. getClassName(): string;
  10178. /**
  10179. * Returns the Size hash code.
  10180. * @returns a hash code for a unique width and height
  10181. */
  10182. getHashCode(): number;
  10183. /**
  10184. * Updates the current size from the given one.
  10185. * @param src the given size
  10186. */
  10187. copyFrom(src: Size): void;
  10188. /**
  10189. * Updates in place the current Size from the given floats.
  10190. * @param width width of the new size
  10191. * @param height height of the new size
  10192. * @returns the updated Size.
  10193. */
  10194. copyFromFloats(width: number, height: number): Size;
  10195. /**
  10196. * Updates in place the current Size from the given floats.
  10197. * @param width width to set
  10198. * @param height height to set
  10199. * @returns the updated Size.
  10200. */
  10201. set(width: number, height: number): Size;
  10202. /**
  10203. * Multiplies the width and height by numbers
  10204. * @param w factor to multiple the width by
  10205. * @param h factor to multiple the height by
  10206. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10207. */
  10208. multiplyByFloats(w: number, h: number): Size;
  10209. /**
  10210. * Clones the size
  10211. * @returns a new Size copied from the given one.
  10212. */
  10213. clone(): Size;
  10214. /**
  10215. * True if the current Size and the given one width and height are strictly equal.
  10216. * @param other the other size to compare against
  10217. * @returns True if the current Size and the given one width and height are strictly equal.
  10218. */
  10219. equals(other: Size): boolean;
  10220. /**
  10221. * The surface of the Size : width * height (float).
  10222. */
  10223. get surface(): number;
  10224. /**
  10225. * Create a new size of zero
  10226. * @returns a new Size set to (0.0, 0.0)
  10227. */
  10228. static Zero(): Size;
  10229. /**
  10230. * Sums the width and height of two sizes
  10231. * @param otherSize size to add to this size
  10232. * @returns a new Size set as the addition result of the current Size and the given one.
  10233. */
  10234. add(otherSize: Size): Size;
  10235. /**
  10236. * Subtracts the width and height of two
  10237. * @param otherSize size to subtract to this size
  10238. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10239. */
  10240. subtract(otherSize: Size): Size;
  10241. /**
  10242. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10243. * @param start starting size to lerp between
  10244. * @param end end size to lerp between
  10245. * @param amount amount to lerp between the start and end values
  10246. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10247. */
  10248. static Lerp(start: Size, end: Size, amount: number): Size;
  10249. }
  10250. }
  10251. declare module BABYLON {
  10252. interface ThinEngine {
  10253. /**
  10254. * Creates a dynamic texture
  10255. * @param width defines the width of the texture
  10256. * @param height defines the height of the texture
  10257. * @param generateMipMaps defines if the engine should generate the mip levels
  10258. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10259. * @returns the dynamic texture inside an InternalTexture
  10260. */
  10261. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10262. /**
  10263. * Update the content of a dynamic texture
  10264. * @param texture defines the texture to update
  10265. * @param canvas defines the canvas containing the source
  10266. * @param invertY defines if data must be stored with Y axis inverted
  10267. * @param premulAlpha defines if alpha is stored as premultiplied
  10268. * @param format defines the format of the data
  10269. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10270. */
  10271. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10272. }
  10273. }
  10274. declare module BABYLON {
  10275. /**
  10276. * Helper class used to generate a canvas to manipulate images
  10277. */
  10278. export class CanvasGenerator {
  10279. /**
  10280. * Create a new canvas (or offscreen canvas depending on the context)
  10281. * @param width defines the expected width
  10282. * @param height defines the expected height
  10283. * @return a new canvas or offscreen canvas
  10284. */
  10285. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10286. }
  10287. }
  10288. declare module BABYLON {
  10289. /**
  10290. * A class extending Texture allowing drawing on a texture
  10291. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10292. */
  10293. export class DynamicTexture extends Texture {
  10294. private _generateMipMaps;
  10295. private _canvas;
  10296. private _context;
  10297. private _engine;
  10298. /**
  10299. * Creates a DynamicTexture
  10300. * @param name defines the name of the texture
  10301. * @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
  10302. * @param scene defines the scene where you want the texture
  10303. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10304. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10305. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10306. */
  10307. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10308. /**
  10309. * Get the current class name of the texture useful for serialization or dynamic coding.
  10310. * @returns "DynamicTexture"
  10311. */
  10312. getClassName(): string;
  10313. /**
  10314. * Gets the current state of canRescale
  10315. */
  10316. get canRescale(): boolean;
  10317. private _recreate;
  10318. /**
  10319. * Scales the texture
  10320. * @param ratio the scale factor to apply to both width and height
  10321. */
  10322. scale(ratio: number): void;
  10323. /**
  10324. * Resizes the texture
  10325. * @param width the new width
  10326. * @param height the new height
  10327. */
  10328. scaleTo(width: number, height: number): void;
  10329. /**
  10330. * Gets the context of the canvas used by the texture
  10331. * @returns the canvas context of the dynamic texture
  10332. */
  10333. getContext(): CanvasRenderingContext2D;
  10334. /**
  10335. * Clears the texture
  10336. */
  10337. clear(): void;
  10338. /**
  10339. * Updates the texture
  10340. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10341. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10342. */
  10343. update(invertY?: boolean, premulAlpha?: boolean): void;
  10344. /**
  10345. * Draws text onto the texture
  10346. * @param text defines the text to be drawn
  10347. * @param x defines the placement of the text from the left
  10348. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10349. * @param font defines the font to be used with font-style, font-size, font-name
  10350. * @param color defines the color used for the text
  10351. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10352. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10353. * @param update defines whether texture is immediately update (default is true)
  10354. */
  10355. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10356. /**
  10357. * Clones the texture
  10358. * @returns the clone of the texture.
  10359. */
  10360. clone(): DynamicTexture;
  10361. /**
  10362. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10363. * @returns a serialized dynamic texture object
  10364. */
  10365. serialize(): any;
  10366. /** @hidden */
  10367. _rebuild(): void;
  10368. }
  10369. }
  10370. declare module BABYLON {
  10371. interface Engine {
  10372. /**
  10373. * Creates a raw texture
  10374. * @param data defines the data to store in the texture
  10375. * @param width defines the width of the texture
  10376. * @param height defines the height of the texture
  10377. * @param format defines the format of the data
  10378. * @param generateMipMaps defines if the engine should generate the mip levels
  10379. * @param invertY defines if data must be stored with Y axis inverted
  10380. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10381. * @param compression defines the compression used (null by default)
  10382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10383. * @returns the raw texture inside an InternalTexture
  10384. */
  10385. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10386. /**
  10387. * Update a raw texture
  10388. * @param texture defines the texture to update
  10389. * @param data defines the data to store in the texture
  10390. * @param format defines the format of the data
  10391. * @param invertY defines if data must be stored with Y axis inverted
  10392. */
  10393. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10394. /**
  10395. * Update a raw texture
  10396. * @param texture defines the texture to update
  10397. * @param data defines the data to store in the texture
  10398. * @param format defines the format of the data
  10399. * @param invertY defines if data must be stored with Y axis inverted
  10400. * @param compression defines the compression used (null by default)
  10401. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10402. */
  10403. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10404. /**
  10405. * Creates a new raw cube texture
  10406. * @param data defines the array of data to use to create each face
  10407. * @param size defines the size of the textures
  10408. * @param format defines the format of the data
  10409. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10410. * @param generateMipMaps defines if the engine should generate the mip levels
  10411. * @param invertY defines if data must be stored with Y axis inverted
  10412. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10413. * @param compression defines the compression used (null by default)
  10414. * @returns the cube texture as an InternalTexture
  10415. */
  10416. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10417. /**
  10418. * Update a raw cube texture
  10419. * @param texture defines the texture to udpdate
  10420. * @param data defines the data to store
  10421. * @param format defines the data format
  10422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10423. * @param invertY defines if data must be stored with Y axis inverted
  10424. */
  10425. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10426. /**
  10427. * Update a raw cube texture
  10428. * @param texture defines the texture to udpdate
  10429. * @param data defines the data to store
  10430. * @param format defines the data format
  10431. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10432. * @param invertY defines if data must be stored with Y axis inverted
  10433. * @param compression defines the compression used (null by default)
  10434. */
  10435. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10436. /**
  10437. * Update a raw cube texture
  10438. * @param texture defines the texture to udpdate
  10439. * @param data defines the data to store
  10440. * @param format defines the data format
  10441. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10442. * @param invertY defines if data must be stored with Y axis inverted
  10443. * @param compression defines the compression used (null by default)
  10444. * @param level defines which level of the texture to update
  10445. */
  10446. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10447. /**
  10448. * Creates a new raw cube texture from a specified url
  10449. * @param url defines the url where the data is located
  10450. * @param scene defines the current scene
  10451. * @param size defines the size of the textures
  10452. * @param format defines the format of the data
  10453. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10454. * @param noMipmap defines if the engine should avoid generating the mip levels
  10455. * @param callback defines a callback used to extract texture data from loaded data
  10456. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10457. * @param onLoad defines a callback called when texture is loaded
  10458. * @param onError defines a callback called if there is an error
  10459. * @returns the cube texture as an InternalTexture
  10460. */
  10461. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10462. /**
  10463. * Creates a new raw cube texture from a specified url
  10464. * @param url defines the url where the data is located
  10465. * @param scene defines the current scene
  10466. * @param size defines the size of the textures
  10467. * @param format defines the format of the data
  10468. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10469. * @param noMipmap defines if the engine should avoid generating the mip levels
  10470. * @param callback defines a callback used to extract texture data from loaded data
  10471. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10472. * @param onLoad defines a callback called when texture is loaded
  10473. * @param onError defines a callback called if there is an error
  10474. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10475. * @param invertY defines if data must be stored with Y axis inverted
  10476. * @returns the cube texture as an InternalTexture
  10477. */
  10478. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10479. /**
  10480. * Creates a new raw 3D texture
  10481. * @param data defines the data used to create the texture
  10482. * @param width defines the width of the texture
  10483. * @param height defines the height of the texture
  10484. * @param depth defines the depth of the texture
  10485. * @param format defines the format of the texture
  10486. * @param generateMipMaps defines if the engine must generate mip levels
  10487. * @param invertY defines if data must be stored with Y axis inverted
  10488. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10489. * @param compression defines the compressed used (can be null)
  10490. * @param textureType defines the compressed used (can be null)
  10491. * @returns a new raw 3D texture (stored in an InternalTexture)
  10492. */
  10493. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10494. /**
  10495. * Update a raw 3D texture
  10496. * @param texture defines the texture to update
  10497. * @param data defines the data to store
  10498. * @param format defines the data format
  10499. * @param invertY defines if data must be stored with Y axis inverted
  10500. */
  10501. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10502. /**
  10503. * Update a raw 3D texture
  10504. * @param texture defines the texture to update
  10505. * @param data defines the data to store
  10506. * @param format defines the data format
  10507. * @param invertY defines if data must be stored with Y axis inverted
  10508. * @param compression defines the used compression (can be null)
  10509. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10510. */
  10511. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10512. /**
  10513. * Creates a new raw 2D array texture
  10514. * @param data defines the data used to create the texture
  10515. * @param width defines the width of the texture
  10516. * @param height defines the height of the texture
  10517. * @param depth defines the number of layers of the texture
  10518. * @param format defines the format of the texture
  10519. * @param generateMipMaps defines if the engine must generate mip levels
  10520. * @param invertY defines if data must be stored with Y axis inverted
  10521. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10522. * @param compression defines the compressed used (can be null)
  10523. * @param textureType defines the compressed used (can be null)
  10524. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10525. */
  10526. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10527. /**
  10528. * Update a raw 2D array texture
  10529. * @param texture defines the texture to update
  10530. * @param data defines the data to store
  10531. * @param format defines the data format
  10532. * @param invertY defines if data must be stored with Y axis inverted
  10533. */
  10534. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10535. /**
  10536. * Update a raw 2D array texture
  10537. * @param texture defines the texture to update
  10538. * @param data defines the data to store
  10539. * @param format defines the data format
  10540. * @param invertY defines if data must be stored with Y axis inverted
  10541. * @param compression defines the used compression (can be null)
  10542. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10543. */
  10544. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10545. }
  10546. }
  10547. declare module BABYLON {
  10548. /**
  10549. * Raw texture can help creating a texture directly from an array of data.
  10550. * This can be super useful if you either get the data from an uncompressed source or
  10551. * if you wish to create your texture pixel by pixel.
  10552. */
  10553. export class RawTexture extends Texture {
  10554. /**
  10555. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10556. */
  10557. format: number;
  10558. private _engine;
  10559. /**
  10560. * Instantiates a new RawTexture.
  10561. * Raw texture can help creating a texture directly from an array of data.
  10562. * This can be super useful if you either get the data from an uncompressed source or
  10563. * if you wish to create your texture pixel by pixel.
  10564. * @param data define the array of data to use to create the texture
  10565. * @param width define the width of the texture
  10566. * @param height define the height of the texture
  10567. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10568. * @param scene define the scene the texture belongs to
  10569. * @param generateMipMaps define whether mip maps should be generated or not
  10570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10572. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10573. */
  10574. constructor(data: ArrayBufferView, width: number, height: number,
  10575. /**
  10576. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10577. */
  10578. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10579. /**
  10580. * Updates the texture underlying data.
  10581. * @param data Define the new data of the texture
  10582. */
  10583. update(data: ArrayBufferView): void;
  10584. /**
  10585. * Creates a luminance texture from some data.
  10586. * @param data Define the texture data
  10587. * @param width Define the width of the texture
  10588. * @param height Define the height of the texture
  10589. * @param scene Define the scene the texture belongs to
  10590. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10591. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10592. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10593. * @returns the luminance texture
  10594. */
  10595. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10596. /**
  10597. * Creates a luminance alpha texture from some data.
  10598. * @param data Define the texture data
  10599. * @param width Define the width of the texture
  10600. * @param height Define the height of the texture
  10601. * @param scene Define the scene the texture belongs to
  10602. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10603. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10604. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10605. * @returns the luminance alpha texture
  10606. */
  10607. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10608. /**
  10609. * Creates an alpha texture from some data.
  10610. * @param data Define the texture data
  10611. * @param width Define the width of the texture
  10612. * @param height Define the height of the texture
  10613. * @param scene Define the scene the texture belongs to
  10614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10617. * @returns the alpha texture
  10618. */
  10619. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10620. /**
  10621. * Creates a RGB texture from some data.
  10622. * @param data Define the texture data
  10623. * @param width Define the width of the texture
  10624. * @param height Define the height of the texture
  10625. * @param scene Define the scene the texture belongs to
  10626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10629. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10630. * @returns the RGB alpha texture
  10631. */
  10632. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10633. /**
  10634. * Creates a RGBA texture from some data.
  10635. * @param data Define the texture data
  10636. * @param width Define the width of the texture
  10637. * @param height Define the height of the texture
  10638. * @param scene Define the scene the texture belongs to
  10639. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10640. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10641. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10642. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10643. * @returns the RGBA texture
  10644. */
  10645. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10646. /**
  10647. * Creates a R texture from some data.
  10648. * @param data Define the texture data
  10649. * @param width Define the width of the texture
  10650. * @param height Define the height of the texture
  10651. * @param scene Define the scene the texture belongs to
  10652. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10656. * @returns the R texture
  10657. */
  10658. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10659. }
  10660. }
  10661. declare module BABYLON {
  10662. interface AbstractScene {
  10663. /**
  10664. * The list of procedural textures added to the scene
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10666. */
  10667. proceduralTextures: Array<ProceduralTexture>;
  10668. }
  10669. /**
  10670. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10671. * in a given scene.
  10672. */
  10673. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10674. /**
  10675. * The component name helpfull to identify the component in the list of scene components.
  10676. */
  10677. readonly name: string;
  10678. /**
  10679. * The scene the component belongs to.
  10680. */
  10681. scene: Scene;
  10682. /**
  10683. * Creates a new instance of the component for the given scene
  10684. * @param scene Defines the scene to register the component in
  10685. */
  10686. constructor(scene: Scene);
  10687. /**
  10688. * Registers the component in a given scene
  10689. */
  10690. register(): void;
  10691. /**
  10692. * Rebuilds the elements related to this component in case of
  10693. * context lost for instance.
  10694. */
  10695. rebuild(): void;
  10696. /**
  10697. * Disposes the component and the associated ressources.
  10698. */
  10699. dispose(): void;
  10700. private _beforeClear;
  10701. }
  10702. }
  10703. declare module BABYLON {
  10704. interface ThinEngine {
  10705. /**
  10706. * Creates a new render target cube texture
  10707. * @param size defines the size of the texture
  10708. * @param options defines the options used to create the texture
  10709. * @returns a new render target cube texture stored in an InternalTexture
  10710. */
  10711. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10712. }
  10713. }
  10714. declare module BABYLON {
  10715. /** @hidden */
  10716. export var proceduralVertexShader: {
  10717. name: string;
  10718. shader: string;
  10719. };
  10720. }
  10721. declare module BABYLON {
  10722. /**
  10723. * 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.
  10724. * This is the base class of any Procedural texture and contains most of the shareable code.
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10726. */
  10727. export class ProceduralTexture extends Texture {
  10728. isCube: boolean;
  10729. /**
  10730. * Define if the texture is enabled or not (disabled texture will not render)
  10731. */
  10732. isEnabled: boolean;
  10733. /**
  10734. * Define if the texture must be cleared before rendering (default is true)
  10735. */
  10736. autoClear: boolean;
  10737. /**
  10738. * Callback called when the texture is generated
  10739. */
  10740. onGenerated: () => void;
  10741. /**
  10742. * Event raised when the texture is generated
  10743. */
  10744. onGeneratedObservable: Observable<ProceduralTexture>;
  10745. /** @hidden */
  10746. _generateMipMaps: boolean;
  10747. /** @hidden **/
  10748. _effect: Effect;
  10749. /** @hidden */
  10750. _textures: {
  10751. [key: string]: Texture;
  10752. };
  10753. private _size;
  10754. private _currentRefreshId;
  10755. private _frameId;
  10756. private _refreshRate;
  10757. private _vertexBuffers;
  10758. private _indexBuffer;
  10759. private _uniforms;
  10760. private _samplers;
  10761. private _fragment;
  10762. private _floats;
  10763. private _ints;
  10764. private _floatsArrays;
  10765. private _colors3;
  10766. private _colors4;
  10767. private _vectors2;
  10768. private _vectors3;
  10769. private _matrices;
  10770. private _fallbackTexture;
  10771. private _fallbackTextureUsed;
  10772. private _engine;
  10773. private _cachedDefines;
  10774. private _contentUpdateId;
  10775. private _contentData;
  10776. /**
  10777. * Instantiates a new procedural texture.
  10778. * 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.
  10779. * This is the base class of any Procedural texture and contains most of the shareable code.
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10781. * @param name Define the name of the texture
  10782. * @param size Define the size of the texture to create
  10783. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10784. * @param scene Define the scene the texture belongs to
  10785. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10786. * @param generateMipMaps Define if the texture should creates mip maps or not
  10787. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10788. */
  10789. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10790. /**
  10791. * The effect that is created when initializing the post process.
  10792. * @returns The created effect corresponding the the postprocess.
  10793. */
  10794. getEffect(): Effect;
  10795. /**
  10796. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10797. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10798. */
  10799. getContent(): Nullable<ArrayBufferView>;
  10800. private _createIndexBuffer;
  10801. /** @hidden */
  10802. _rebuild(): void;
  10803. /**
  10804. * Resets the texture in order to recreate its associated resources.
  10805. * This can be called in case of context loss
  10806. */
  10807. reset(): void;
  10808. protected _getDefines(): string;
  10809. /**
  10810. * Is the texture ready to be used ? (rendered at least once)
  10811. * @returns true if ready, otherwise, false.
  10812. */
  10813. isReady(): boolean;
  10814. /**
  10815. * Resets the refresh counter of the texture and start bak from scratch.
  10816. * Could be useful to regenerate the texture if it is setup to render only once.
  10817. */
  10818. resetRefreshCounter(): void;
  10819. /**
  10820. * Set the fragment shader to use in order to render the texture.
  10821. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10822. */
  10823. setFragment(fragment: any): void;
  10824. /**
  10825. * Define the refresh rate of the texture or the rendering frequency.
  10826. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10827. */
  10828. get refreshRate(): number;
  10829. set refreshRate(value: number);
  10830. /** @hidden */
  10831. _shouldRender(): boolean;
  10832. /**
  10833. * Get the size the texture is rendering at.
  10834. * @returns the size (texture is always squared)
  10835. */
  10836. getRenderSize(): number;
  10837. /**
  10838. * Resize the texture to new value.
  10839. * @param size Define the new size the texture should have
  10840. * @param generateMipMaps Define whether the new texture should create mip maps
  10841. */
  10842. resize(size: number, generateMipMaps: boolean): void;
  10843. private _checkUniform;
  10844. /**
  10845. * Set a texture in the shader program used to render.
  10846. * @param name Define the name of the uniform samplers as defined in the shader
  10847. * @param texture Define the texture to bind to this sampler
  10848. * @return the texture itself allowing "fluent" like uniform updates
  10849. */
  10850. setTexture(name: string, texture: Texture): ProceduralTexture;
  10851. /**
  10852. * Set a float in the shader.
  10853. * @param name Define the name of the uniform as defined in the shader
  10854. * @param value Define the value to give to the uniform
  10855. * @return the texture itself allowing "fluent" like uniform updates
  10856. */
  10857. setFloat(name: string, value: number): ProceduralTexture;
  10858. /**
  10859. * Set a int in the shader.
  10860. * @param name Define the name of the uniform as defined in the shader
  10861. * @param value Define the value to give to the uniform
  10862. * @return the texture itself allowing "fluent" like uniform updates
  10863. */
  10864. setInt(name: string, value: number): ProceduralTexture;
  10865. /**
  10866. * Set an array of floats in the shader.
  10867. * @param name Define the name of the uniform as defined in the shader
  10868. * @param value Define the value to give to the uniform
  10869. * @return the texture itself allowing "fluent" like uniform updates
  10870. */
  10871. setFloats(name: string, value: number[]): ProceduralTexture;
  10872. /**
  10873. * Set a vec3 in the shader from a Color3.
  10874. * @param name Define the name of the uniform as defined in the shader
  10875. * @param value Define the value to give to the uniform
  10876. * @return the texture itself allowing "fluent" like uniform updates
  10877. */
  10878. setColor3(name: string, value: Color3): ProceduralTexture;
  10879. /**
  10880. * Set a vec4 in the shader from a Color4.
  10881. * @param name Define the name of the uniform as defined in the shader
  10882. * @param value Define the value to give to the uniform
  10883. * @return the texture itself allowing "fluent" like uniform updates
  10884. */
  10885. setColor4(name: string, value: Color4): ProceduralTexture;
  10886. /**
  10887. * Set a vec2 in the shader from a Vector2.
  10888. * @param name Define the name of the uniform as defined in the shader
  10889. * @param value Define the value to give to the uniform
  10890. * @return the texture itself allowing "fluent" like uniform updates
  10891. */
  10892. setVector2(name: string, value: Vector2): ProceduralTexture;
  10893. /**
  10894. * Set a vec3 in the shader from a Vector3.
  10895. * @param name Define the name of the uniform as defined in the shader
  10896. * @param value Define the value to give to the uniform
  10897. * @return the texture itself allowing "fluent" like uniform updates
  10898. */
  10899. setVector3(name: string, value: Vector3): ProceduralTexture;
  10900. /**
  10901. * Set a mat4 in the shader from a MAtrix.
  10902. * @param name Define the name of the uniform as defined in the shader
  10903. * @param value Define the value to give to the uniform
  10904. * @return the texture itself allowing "fluent" like uniform updates
  10905. */
  10906. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10907. /**
  10908. * Render the texture to its associated render target.
  10909. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10910. */
  10911. render(useCameraPostProcess?: boolean): void;
  10912. /**
  10913. * Clone the texture.
  10914. * @returns the cloned texture
  10915. */
  10916. clone(): ProceduralTexture;
  10917. /**
  10918. * Dispose the texture and release its asoociated resources.
  10919. */
  10920. dispose(): void;
  10921. }
  10922. }
  10923. declare module BABYLON {
  10924. /**
  10925. * This represents the base class for particle system in Babylon.
  10926. * 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.
  10927. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10928. * @example https://doc.babylonjs.com/babylon101/particles
  10929. */
  10930. export class BaseParticleSystem {
  10931. /**
  10932. * Source color is added to the destination color without alpha affecting the result
  10933. */
  10934. static BLENDMODE_ONEONE: number;
  10935. /**
  10936. * Blend current color and particle color using particle’s alpha
  10937. */
  10938. static BLENDMODE_STANDARD: number;
  10939. /**
  10940. * Add current color and particle color multiplied by particle’s alpha
  10941. */
  10942. static BLENDMODE_ADD: number;
  10943. /**
  10944. * Multiply current color with particle color
  10945. */
  10946. static BLENDMODE_MULTIPLY: number;
  10947. /**
  10948. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10949. */
  10950. static BLENDMODE_MULTIPLYADD: number;
  10951. /**
  10952. * List of animations used by the particle system.
  10953. */
  10954. animations: Animation[];
  10955. /**
  10956. * The id of the Particle system.
  10957. */
  10958. id: string;
  10959. /**
  10960. * The friendly name of the Particle system.
  10961. */
  10962. name: string;
  10963. /**
  10964. * The rendering group used by the Particle system to chose when to render.
  10965. */
  10966. renderingGroupId: number;
  10967. /**
  10968. * The emitter represents the Mesh or position we are attaching the particle system to.
  10969. */
  10970. emitter: Nullable<AbstractMesh | Vector3>;
  10971. /**
  10972. * The maximum number of particles to emit per frame
  10973. */
  10974. emitRate: number;
  10975. /**
  10976. * If you want to launch only a few particles at once, that can be done, as well.
  10977. */
  10978. manualEmitCount: number;
  10979. /**
  10980. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  10981. */
  10982. updateSpeed: number;
  10983. /**
  10984. * The amount of time the particle system is running (depends of the overall update speed).
  10985. */
  10986. targetStopDuration: number;
  10987. /**
  10988. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  10989. */
  10990. disposeOnStop: boolean;
  10991. /**
  10992. * Minimum power of emitting particles.
  10993. */
  10994. minEmitPower: number;
  10995. /**
  10996. * Maximum power of emitting particles.
  10997. */
  10998. maxEmitPower: number;
  10999. /**
  11000. * Minimum life time of emitting particles.
  11001. */
  11002. minLifeTime: number;
  11003. /**
  11004. * Maximum life time of emitting particles.
  11005. */
  11006. maxLifeTime: number;
  11007. /**
  11008. * Minimum Size of emitting particles.
  11009. */
  11010. minSize: number;
  11011. /**
  11012. * Maximum Size of emitting particles.
  11013. */
  11014. maxSize: number;
  11015. /**
  11016. * Minimum scale of emitting particles on X axis.
  11017. */
  11018. minScaleX: number;
  11019. /**
  11020. * Maximum scale of emitting particles on X axis.
  11021. */
  11022. maxScaleX: number;
  11023. /**
  11024. * Minimum scale of emitting particles on Y axis.
  11025. */
  11026. minScaleY: number;
  11027. /**
  11028. * Maximum scale of emitting particles on Y axis.
  11029. */
  11030. maxScaleY: number;
  11031. /**
  11032. * Gets or sets the minimal initial rotation in radians.
  11033. */
  11034. minInitialRotation: number;
  11035. /**
  11036. * Gets or sets the maximal initial rotation in radians.
  11037. */
  11038. maxInitialRotation: number;
  11039. /**
  11040. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11041. */
  11042. minAngularSpeed: number;
  11043. /**
  11044. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11045. */
  11046. maxAngularSpeed: number;
  11047. /**
  11048. * The texture used to render each particle. (this can be a spritesheet)
  11049. */
  11050. particleTexture: Nullable<Texture>;
  11051. /**
  11052. * The layer mask we are rendering the particles through.
  11053. */
  11054. layerMask: number;
  11055. /**
  11056. * This can help using your own shader to render the particle system.
  11057. * The according effect will be created
  11058. */
  11059. customShader: any;
  11060. /**
  11061. * By default particle system starts as soon as they are created. This prevents the
  11062. * automatic start to happen and let you decide when to start emitting particles.
  11063. */
  11064. preventAutoStart: boolean;
  11065. private _noiseTexture;
  11066. /**
  11067. * Gets or sets a texture used to add random noise to particle positions
  11068. */
  11069. get noiseTexture(): Nullable<ProceduralTexture>;
  11070. set noiseTexture(value: Nullable<ProceduralTexture>);
  11071. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11072. noiseStrength: Vector3;
  11073. /**
  11074. * Callback triggered when the particle animation is ending.
  11075. */
  11076. onAnimationEnd: Nullable<() => void>;
  11077. /**
  11078. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11079. */
  11080. blendMode: number;
  11081. /**
  11082. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11083. * to override the particles.
  11084. */
  11085. forceDepthWrite: boolean;
  11086. /** 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 */
  11087. preWarmCycles: number;
  11088. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11089. preWarmStepOffset: number;
  11090. /**
  11091. * 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)
  11092. */
  11093. spriteCellChangeSpeed: number;
  11094. /**
  11095. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11096. */
  11097. startSpriteCellID: number;
  11098. /**
  11099. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11100. */
  11101. endSpriteCellID: number;
  11102. /**
  11103. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11104. */
  11105. spriteCellWidth: number;
  11106. /**
  11107. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11108. */
  11109. spriteCellHeight: number;
  11110. /**
  11111. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11112. */
  11113. spriteRandomStartCell: boolean;
  11114. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11115. translationPivot: Vector2;
  11116. /** @hidden */
  11117. protected _isAnimationSheetEnabled: boolean;
  11118. /**
  11119. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11120. */
  11121. beginAnimationOnStart: boolean;
  11122. /**
  11123. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11124. */
  11125. beginAnimationFrom: number;
  11126. /**
  11127. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11128. */
  11129. beginAnimationTo: number;
  11130. /**
  11131. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11132. */
  11133. beginAnimationLoop: boolean;
  11134. /**
  11135. * Gets or sets a world offset applied to all particles
  11136. */
  11137. worldOffset: Vector3;
  11138. /**
  11139. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11140. */
  11141. get isAnimationSheetEnabled(): boolean;
  11142. set isAnimationSheetEnabled(value: boolean);
  11143. /**
  11144. * Get hosting scene
  11145. * @returns the scene
  11146. */
  11147. getScene(): Scene;
  11148. /**
  11149. * You can use gravity if you want to give an orientation to your particles.
  11150. */
  11151. gravity: Vector3;
  11152. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11153. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11154. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11155. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11156. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11157. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11158. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11159. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11160. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11161. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11162. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11163. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11164. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11165. /**
  11166. * Defines the delay in milliseconds before starting the system (0 by default)
  11167. */
  11168. startDelay: number;
  11169. /**
  11170. * Gets the current list of drag gradients.
  11171. * You must use addDragGradient and removeDragGradient to udpate this list
  11172. * @returns the list of drag gradients
  11173. */
  11174. getDragGradients(): Nullable<Array<FactorGradient>>;
  11175. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11176. limitVelocityDamping: number;
  11177. /**
  11178. * Gets the current list of limit velocity gradients.
  11179. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11180. * @returns the list of limit velocity gradients
  11181. */
  11182. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11183. /**
  11184. * Gets the current list of color gradients.
  11185. * You must use addColorGradient and removeColorGradient to udpate this list
  11186. * @returns the list of color gradients
  11187. */
  11188. getColorGradients(): Nullable<Array<ColorGradient>>;
  11189. /**
  11190. * Gets the current list of size gradients.
  11191. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11192. * @returns the list of size gradients
  11193. */
  11194. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11195. /**
  11196. * Gets the current list of color remap gradients.
  11197. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11198. * @returns the list of color remap gradients
  11199. */
  11200. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11201. /**
  11202. * Gets the current list of alpha remap gradients.
  11203. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11204. * @returns the list of alpha remap gradients
  11205. */
  11206. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11207. /**
  11208. * Gets the current list of life time gradients.
  11209. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11210. * @returns the list of life time gradients
  11211. */
  11212. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11213. /**
  11214. * Gets the current list of angular speed gradients.
  11215. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11216. * @returns the list of angular speed gradients
  11217. */
  11218. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11219. /**
  11220. * Gets the current list of velocity gradients.
  11221. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11222. * @returns the list of velocity gradients
  11223. */
  11224. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11225. /**
  11226. * Gets the current list of start size gradients.
  11227. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11228. * @returns the list of start size gradients
  11229. */
  11230. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11231. /**
  11232. * Gets the current list of emit rate gradients.
  11233. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11234. * @returns the list of emit rate gradients
  11235. */
  11236. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11237. /**
  11238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11239. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11240. */
  11241. get direction1(): Vector3;
  11242. set direction1(value: Vector3);
  11243. /**
  11244. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11245. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11246. */
  11247. get direction2(): Vector3;
  11248. set direction2(value: Vector3);
  11249. /**
  11250. * 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.
  11251. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11252. */
  11253. get minEmitBox(): Vector3;
  11254. set minEmitBox(value: Vector3);
  11255. /**
  11256. * 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.
  11257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11258. */
  11259. get maxEmitBox(): Vector3;
  11260. set maxEmitBox(value: Vector3);
  11261. /**
  11262. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11263. */
  11264. color1: Color4;
  11265. /**
  11266. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11267. */
  11268. color2: Color4;
  11269. /**
  11270. * Color the particle will have at the end of its lifetime
  11271. */
  11272. colorDead: Color4;
  11273. /**
  11274. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11275. */
  11276. textureMask: Color4;
  11277. /**
  11278. * The particle emitter type defines the emitter used by the particle system.
  11279. * It can be for example box, sphere, or cone...
  11280. */
  11281. particleEmitterType: IParticleEmitterType;
  11282. /** @hidden */
  11283. _isSubEmitter: boolean;
  11284. /**
  11285. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11286. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11287. */
  11288. billboardMode: number;
  11289. protected _isBillboardBased: boolean;
  11290. /**
  11291. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11292. */
  11293. get isBillboardBased(): boolean;
  11294. set isBillboardBased(value: boolean);
  11295. /**
  11296. * The scene the particle system belongs to.
  11297. */
  11298. protected _scene: Scene;
  11299. /**
  11300. * Local cache of defines for image processing.
  11301. */
  11302. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11303. /**
  11304. * Default configuration related to image processing available in the standard Material.
  11305. */
  11306. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11307. /**
  11308. * Gets the image processing configuration used either in this material.
  11309. */
  11310. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11311. /**
  11312. * Sets the Default image processing configuration used either in the this material.
  11313. *
  11314. * If sets to null, the scene one is in use.
  11315. */
  11316. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11317. /**
  11318. * Attaches a new image processing configuration to the Standard Material.
  11319. * @param configuration
  11320. */
  11321. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11322. /** @hidden */
  11323. protected _reset(): void;
  11324. /** @hidden */
  11325. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11326. /**
  11327. * Instantiates a particle system.
  11328. * 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.
  11329. * @param name The name of the particle system
  11330. */
  11331. constructor(name: string);
  11332. /**
  11333. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11334. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11335. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11336. * @returns the emitter
  11337. */
  11338. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11339. /**
  11340. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11341. * @param radius The radius of the hemisphere to emit from
  11342. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11343. * @returns the emitter
  11344. */
  11345. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11346. /**
  11347. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11348. * @param radius The radius of the sphere to emit from
  11349. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11350. * @returns the emitter
  11351. */
  11352. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11353. /**
  11354. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11355. * @param radius The radius of the sphere to emit from
  11356. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11357. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11358. * @returns the emitter
  11359. */
  11360. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11361. /**
  11362. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11363. * @param radius The radius of the emission cylinder
  11364. * @param height The height of the emission cylinder
  11365. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11366. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11367. * @returns the emitter
  11368. */
  11369. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11370. /**
  11371. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11372. * @param radius The radius of the cylinder to emit from
  11373. * @param height The height of the emission cylinder
  11374. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11375. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11376. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11377. * @returns the emitter
  11378. */
  11379. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11380. /**
  11381. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11382. * @param radius The radius of the cone to emit from
  11383. * @param angle The base angle of the cone
  11384. * @returns the emitter
  11385. */
  11386. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11387. /**
  11388. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11391. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11392. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11393. * @returns the emitter
  11394. */
  11395. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11396. }
  11397. }
  11398. declare module BABYLON {
  11399. /**
  11400. * Type of sub emitter
  11401. */
  11402. export enum SubEmitterType {
  11403. /**
  11404. * Attached to the particle over it's lifetime
  11405. */
  11406. ATTACHED = 0,
  11407. /**
  11408. * Created when the particle dies
  11409. */
  11410. END = 1
  11411. }
  11412. /**
  11413. * Sub emitter class used to emit particles from an existing particle
  11414. */
  11415. export class SubEmitter {
  11416. /**
  11417. * the particle system to be used by the sub emitter
  11418. */
  11419. particleSystem: ParticleSystem;
  11420. /**
  11421. * Type of the submitter (Default: END)
  11422. */
  11423. type: SubEmitterType;
  11424. /**
  11425. * 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)
  11426. * Note: This only is supported when using an emitter of type Mesh
  11427. */
  11428. inheritDirection: boolean;
  11429. /**
  11430. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11431. */
  11432. inheritedVelocityAmount: number;
  11433. /**
  11434. * Creates a sub emitter
  11435. * @param particleSystem the particle system to be used by the sub emitter
  11436. */
  11437. constructor(
  11438. /**
  11439. * the particle system to be used by the sub emitter
  11440. */
  11441. particleSystem: ParticleSystem);
  11442. /**
  11443. * Clones the sub emitter
  11444. * @returns the cloned sub emitter
  11445. */
  11446. clone(): SubEmitter;
  11447. /**
  11448. * Serialize current object to a JSON object
  11449. * @returns the serialized object
  11450. */
  11451. serialize(): any;
  11452. /** @hidden */
  11453. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11454. /**
  11455. * Creates a new SubEmitter from a serialized JSON version
  11456. * @param serializationObject defines the JSON object to read from
  11457. * @param scene defines the hosting scene
  11458. * @param rootUrl defines the rootUrl for data loading
  11459. * @returns a new SubEmitter
  11460. */
  11461. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11462. /** Release associated resources */
  11463. dispose(): void;
  11464. }
  11465. }
  11466. declare module BABYLON {
  11467. /** @hidden */
  11468. export var imageProcessingDeclaration: {
  11469. name: string;
  11470. shader: string;
  11471. };
  11472. }
  11473. declare module BABYLON {
  11474. /** @hidden */
  11475. export var imageProcessingFunctions: {
  11476. name: string;
  11477. shader: string;
  11478. };
  11479. }
  11480. declare module BABYLON {
  11481. /** @hidden */
  11482. export var particlesPixelShader: {
  11483. name: string;
  11484. shader: string;
  11485. };
  11486. }
  11487. declare module BABYLON {
  11488. /** @hidden */
  11489. export var particlesVertexShader: {
  11490. name: string;
  11491. shader: string;
  11492. };
  11493. }
  11494. declare module BABYLON {
  11495. /**
  11496. * This represents a particle system in Babylon.
  11497. * 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.
  11498. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11499. * @example https://doc.babylonjs.com/babylon101/particles
  11500. */
  11501. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11502. /**
  11503. * Billboard mode will only apply to Y axis
  11504. */
  11505. static readonly BILLBOARDMODE_Y: number;
  11506. /**
  11507. * Billboard mode will apply to all axes
  11508. */
  11509. static readonly BILLBOARDMODE_ALL: number;
  11510. /**
  11511. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11512. */
  11513. static readonly BILLBOARDMODE_STRETCHED: number;
  11514. /**
  11515. * This function can be defined to provide custom update for active particles.
  11516. * This function will be called instead of regular update (age, position, color, etc.).
  11517. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11518. */
  11519. updateFunction: (particles: Particle[]) => void;
  11520. private _emitterWorldMatrix;
  11521. /**
  11522. * This function can be defined to specify initial direction for every new particle.
  11523. * It by default use the emitterType defined function
  11524. */
  11525. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11526. /**
  11527. * This function can be defined to specify initial position for every new particle.
  11528. * It by default use the emitterType defined function
  11529. */
  11530. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11531. /**
  11532. * @hidden
  11533. */
  11534. _inheritedVelocityOffset: Vector3;
  11535. /**
  11536. * An event triggered when the system is disposed
  11537. */
  11538. onDisposeObservable: Observable<ParticleSystem>;
  11539. private _onDisposeObserver;
  11540. /**
  11541. * Sets a callback that will be triggered when the system is disposed
  11542. */
  11543. set onDispose(callback: () => void);
  11544. private _particles;
  11545. private _epsilon;
  11546. private _capacity;
  11547. private _stockParticles;
  11548. private _newPartsExcess;
  11549. private _vertexData;
  11550. private _vertexBuffer;
  11551. private _vertexBuffers;
  11552. private _spriteBuffer;
  11553. private _indexBuffer;
  11554. private _effect;
  11555. private _customEffect;
  11556. private _cachedDefines;
  11557. private _scaledColorStep;
  11558. private _colorDiff;
  11559. private _scaledDirection;
  11560. private _scaledGravity;
  11561. private _currentRenderId;
  11562. private _alive;
  11563. private _useInstancing;
  11564. private _started;
  11565. private _stopped;
  11566. private _actualFrame;
  11567. private _scaledUpdateSpeed;
  11568. private _vertexBufferSize;
  11569. /** @hidden */
  11570. _currentEmitRateGradient: Nullable<FactorGradient>;
  11571. /** @hidden */
  11572. _currentEmitRate1: number;
  11573. /** @hidden */
  11574. _currentEmitRate2: number;
  11575. /** @hidden */
  11576. _currentStartSizeGradient: Nullable<FactorGradient>;
  11577. /** @hidden */
  11578. _currentStartSize1: number;
  11579. /** @hidden */
  11580. _currentStartSize2: number;
  11581. private readonly _rawTextureWidth;
  11582. private _rampGradientsTexture;
  11583. private _useRampGradients;
  11584. /** Gets or sets a boolean indicating that ramp gradients must be used
  11585. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11586. */
  11587. get useRampGradients(): boolean;
  11588. set useRampGradients(value: boolean);
  11589. /**
  11590. * 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.
  11591. * 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: [])
  11592. */
  11593. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11594. private _subEmitters;
  11595. /**
  11596. * @hidden
  11597. * If the particle systems emitter should be disposed when the particle system is disposed
  11598. */
  11599. _disposeEmitterOnDispose: boolean;
  11600. /**
  11601. * The current active Sub-systems, this property is used by the root particle system only.
  11602. */
  11603. activeSubSystems: Array<ParticleSystem>;
  11604. /**
  11605. * Specifies if the particles are updated in emitter local space or world space
  11606. */
  11607. isLocal: boolean;
  11608. private _rootParticleSystem;
  11609. /**
  11610. * Gets the current list of active particles
  11611. */
  11612. get particles(): Particle[];
  11613. /**
  11614. * Returns the string "ParticleSystem"
  11615. * @returns a string containing the class name
  11616. */
  11617. getClassName(): string;
  11618. /**
  11619. * Instantiates a particle system.
  11620. * 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.
  11621. * @param name The name of the particle system
  11622. * @param capacity The max number of particles alive at the same time
  11623. * @param scene The scene the particle system belongs to
  11624. * @param customEffect a custom effect used to change the way particles are rendered by default
  11625. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11626. * @param epsilon Offset used to render the particles
  11627. */
  11628. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11629. private _addFactorGradient;
  11630. private _removeFactorGradient;
  11631. /**
  11632. * Adds a new life time gradient
  11633. * @param gradient defines the gradient to use (between 0 and 1)
  11634. * @param factor defines the life time factor to affect to the specified gradient
  11635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11636. * @returns the current particle system
  11637. */
  11638. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11639. /**
  11640. * Remove a specific life time gradient
  11641. * @param gradient defines the gradient to remove
  11642. * @returns the current particle system
  11643. */
  11644. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11645. /**
  11646. * Adds a new size gradient
  11647. * @param gradient defines the gradient to use (between 0 and 1)
  11648. * @param factor defines the size factor to affect to the specified gradient
  11649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11650. * @returns the current particle system
  11651. */
  11652. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11653. /**
  11654. * Remove a specific size gradient
  11655. * @param gradient defines the gradient to remove
  11656. * @returns the current particle system
  11657. */
  11658. removeSizeGradient(gradient: number): IParticleSystem;
  11659. /**
  11660. * Adds a new color remap gradient
  11661. * @param gradient defines the gradient to use (between 0 and 1)
  11662. * @param min defines the color remap minimal range
  11663. * @param max defines the color remap maximal range
  11664. * @returns the current particle system
  11665. */
  11666. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11667. /**
  11668. * Remove a specific color remap gradient
  11669. * @param gradient defines the gradient to remove
  11670. * @returns the current particle system
  11671. */
  11672. removeColorRemapGradient(gradient: number): IParticleSystem;
  11673. /**
  11674. * Adds a new alpha remap gradient
  11675. * @param gradient defines the gradient to use (between 0 and 1)
  11676. * @param min defines the alpha remap minimal range
  11677. * @param max defines the alpha remap maximal range
  11678. * @returns the current particle system
  11679. */
  11680. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11681. /**
  11682. * Remove a specific alpha remap gradient
  11683. * @param gradient defines the gradient to remove
  11684. * @returns the current particle system
  11685. */
  11686. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11687. /**
  11688. * Adds a new angular speed gradient
  11689. * @param gradient defines the gradient to use (between 0 and 1)
  11690. * @param factor defines the angular speed to affect to the specified gradient
  11691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11692. * @returns the current particle system
  11693. */
  11694. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11695. /**
  11696. * Remove a specific angular speed gradient
  11697. * @param gradient defines the gradient to remove
  11698. * @returns the current particle system
  11699. */
  11700. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11701. /**
  11702. * Adds a new velocity gradient
  11703. * @param gradient defines the gradient to use (between 0 and 1)
  11704. * @param factor defines the velocity to affect to the specified gradient
  11705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11706. * @returns the current particle system
  11707. */
  11708. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11709. /**
  11710. * Remove a specific velocity gradient
  11711. * @param gradient defines the gradient to remove
  11712. * @returns the current particle system
  11713. */
  11714. removeVelocityGradient(gradient: number): IParticleSystem;
  11715. /**
  11716. * Adds a new limit velocity gradient
  11717. * @param gradient defines the gradient to use (between 0 and 1)
  11718. * @param factor defines the limit velocity value to affect to the specified gradient
  11719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11720. * @returns the current particle system
  11721. */
  11722. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11723. /**
  11724. * Remove a specific limit velocity gradient
  11725. * @param gradient defines the gradient to remove
  11726. * @returns the current particle system
  11727. */
  11728. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11729. /**
  11730. * Adds a new drag gradient
  11731. * @param gradient defines the gradient to use (between 0 and 1)
  11732. * @param factor defines the drag value to affect to the specified gradient
  11733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11734. * @returns the current particle system
  11735. */
  11736. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11737. /**
  11738. * Remove a specific drag gradient
  11739. * @param gradient defines the gradient to remove
  11740. * @returns the current particle system
  11741. */
  11742. removeDragGradient(gradient: number): IParticleSystem;
  11743. /**
  11744. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11745. * @param gradient defines the gradient to use (between 0 and 1)
  11746. * @param factor defines the emit rate value to affect to the specified gradient
  11747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11748. * @returns the current particle system
  11749. */
  11750. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11751. /**
  11752. * Remove a specific emit rate gradient
  11753. * @param gradient defines the gradient to remove
  11754. * @returns the current particle system
  11755. */
  11756. removeEmitRateGradient(gradient: number): IParticleSystem;
  11757. /**
  11758. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11759. * @param gradient defines the gradient to use (between 0 and 1)
  11760. * @param factor defines the start size value to affect to the specified gradient
  11761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11762. * @returns the current particle system
  11763. */
  11764. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11765. /**
  11766. * Remove a specific start size gradient
  11767. * @param gradient defines the gradient to remove
  11768. * @returns the current particle system
  11769. */
  11770. removeStartSizeGradient(gradient: number): IParticleSystem;
  11771. private _createRampGradientTexture;
  11772. /**
  11773. * Gets the current list of ramp gradients.
  11774. * You must use addRampGradient and removeRampGradient to udpate this list
  11775. * @returns the list of ramp gradients
  11776. */
  11777. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11778. /**
  11779. * Adds a new ramp gradient used to remap particle colors
  11780. * @param gradient defines the gradient to use (between 0 and 1)
  11781. * @param color defines the color to affect to the specified gradient
  11782. * @returns the current particle system
  11783. */
  11784. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11785. /**
  11786. * Remove a specific ramp gradient
  11787. * @param gradient defines the gradient to remove
  11788. * @returns the current particle system
  11789. */
  11790. removeRampGradient(gradient: number): ParticleSystem;
  11791. /**
  11792. * Adds a new color gradient
  11793. * @param gradient defines the gradient to use (between 0 and 1)
  11794. * @param color1 defines the color to affect to the specified gradient
  11795. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11796. * @returns this particle system
  11797. */
  11798. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11799. /**
  11800. * Remove a specific color gradient
  11801. * @param gradient defines the gradient to remove
  11802. * @returns this particle system
  11803. */
  11804. removeColorGradient(gradient: number): IParticleSystem;
  11805. private _fetchR;
  11806. protected _reset(): void;
  11807. private _resetEffect;
  11808. private _createVertexBuffers;
  11809. private _createIndexBuffer;
  11810. /**
  11811. * Gets the maximum number of particles active at the same time.
  11812. * @returns The max number of active particles.
  11813. */
  11814. getCapacity(): number;
  11815. /**
  11816. * Gets whether there are still active particles in the system.
  11817. * @returns True if it is alive, otherwise false.
  11818. */
  11819. isAlive(): boolean;
  11820. /**
  11821. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11822. * @returns True if it has been started, otherwise false.
  11823. */
  11824. isStarted(): boolean;
  11825. private _prepareSubEmitterInternalArray;
  11826. /**
  11827. * Starts the particle system and begins to emit
  11828. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11829. */
  11830. start(delay?: number): void;
  11831. /**
  11832. * Stops the particle system.
  11833. * @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.
  11834. */
  11835. stop(stopSubEmitters?: boolean): void;
  11836. /**
  11837. * Remove all active particles
  11838. */
  11839. reset(): void;
  11840. /**
  11841. * @hidden (for internal use only)
  11842. */
  11843. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11844. /**
  11845. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11846. * Its lifetime will start back at 0.
  11847. */
  11848. recycleParticle: (particle: Particle) => void;
  11849. private _stopSubEmitters;
  11850. private _createParticle;
  11851. private _removeFromRoot;
  11852. private _emitFromParticle;
  11853. private _update;
  11854. /** @hidden */
  11855. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11856. /** @hidden */
  11857. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11858. /** @hidden */
  11859. private _getEffect;
  11860. /**
  11861. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11862. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11863. */
  11864. animate(preWarmOnly?: boolean): void;
  11865. private _appendParticleVertices;
  11866. /**
  11867. * Rebuilds the particle system.
  11868. */
  11869. rebuild(): void;
  11870. /**
  11871. * Is this system ready to be used/rendered
  11872. * @return true if the system is ready
  11873. */
  11874. isReady(): boolean;
  11875. private _render;
  11876. /**
  11877. * Renders the particle system in its current state.
  11878. * @returns the current number of particles
  11879. */
  11880. render(): number;
  11881. /**
  11882. * Disposes the particle system and free the associated resources
  11883. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11884. */
  11885. dispose(disposeTexture?: boolean): void;
  11886. /**
  11887. * Clones the particle system.
  11888. * @param name The name of the cloned object
  11889. * @param newEmitter The new emitter to use
  11890. * @returns the cloned particle system
  11891. */
  11892. clone(name: string, newEmitter: any): ParticleSystem;
  11893. /**
  11894. * Serializes the particle system to a JSON object.
  11895. * @returns the JSON object
  11896. */
  11897. serialize(): any;
  11898. /** @hidden */
  11899. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11900. /** @hidden */
  11901. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11902. /**
  11903. * Parses a JSON object to create a particle system.
  11904. * @param parsedParticleSystem The JSON object to parse
  11905. * @param scene The scene to create the particle system in
  11906. * @param rootUrl The root url to use to load external dependencies like texture
  11907. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11908. * @returns the Parsed particle system
  11909. */
  11910. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11911. }
  11912. }
  11913. declare module BABYLON {
  11914. /**
  11915. * A particle represents one of the element emitted by a particle system.
  11916. * This is mainly define by its coordinates, direction, velocity and age.
  11917. */
  11918. export class Particle {
  11919. /**
  11920. * The particle system the particle belongs to.
  11921. */
  11922. particleSystem: ParticleSystem;
  11923. private static _Count;
  11924. /**
  11925. * Unique ID of the particle
  11926. */
  11927. id: number;
  11928. /**
  11929. * The world position of the particle in the scene.
  11930. */
  11931. position: Vector3;
  11932. /**
  11933. * The world direction of the particle in the scene.
  11934. */
  11935. direction: Vector3;
  11936. /**
  11937. * The color of the particle.
  11938. */
  11939. color: Color4;
  11940. /**
  11941. * The color change of the particle per step.
  11942. */
  11943. colorStep: Color4;
  11944. /**
  11945. * Defines how long will the life of the particle be.
  11946. */
  11947. lifeTime: number;
  11948. /**
  11949. * The current age of the particle.
  11950. */
  11951. age: number;
  11952. /**
  11953. * The current size of the particle.
  11954. */
  11955. size: number;
  11956. /**
  11957. * The current scale of the particle.
  11958. */
  11959. scale: Vector2;
  11960. /**
  11961. * The current angle of the particle.
  11962. */
  11963. angle: number;
  11964. /**
  11965. * Defines how fast is the angle changing.
  11966. */
  11967. angularSpeed: number;
  11968. /**
  11969. * Defines the cell index used by the particle to be rendered from a sprite.
  11970. */
  11971. cellIndex: number;
  11972. /**
  11973. * The information required to support color remapping
  11974. */
  11975. remapData: Vector4;
  11976. /** @hidden */
  11977. _randomCellOffset?: number;
  11978. /** @hidden */
  11979. _initialDirection: Nullable<Vector3>;
  11980. /** @hidden */
  11981. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  11982. /** @hidden */
  11983. _initialStartSpriteCellID: number;
  11984. /** @hidden */
  11985. _initialEndSpriteCellID: number;
  11986. /** @hidden */
  11987. _currentColorGradient: Nullable<ColorGradient>;
  11988. /** @hidden */
  11989. _currentColor1: Color4;
  11990. /** @hidden */
  11991. _currentColor2: Color4;
  11992. /** @hidden */
  11993. _currentSizeGradient: Nullable<FactorGradient>;
  11994. /** @hidden */
  11995. _currentSize1: number;
  11996. /** @hidden */
  11997. _currentSize2: number;
  11998. /** @hidden */
  11999. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12000. /** @hidden */
  12001. _currentAngularSpeed1: number;
  12002. /** @hidden */
  12003. _currentAngularSpeed2: number;
  12004. /** @hidden */
  12005. _currentVelocityGradient: Nullable<FactorGradient>;
  12006. /** @hidden */
  12007. _currentVelocity1: number;
  12008. /** @hidden */
  12009. _currentVelocity2: number;
  12010. /** @hidden */
  12011. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12012. /** @hidden */
  12013. _currentLimitVelocity1: number;
  12014. /** @hidden */
  12015. _currentLimitVelocity2: number;
  12016. /** @hidden */
  12017. _currentDragGradient: Nullable<FactorGradient>;
  12018. /** @hidden */
  12019. _currentDrag1: number;
  12020. /** @hidden */
  12021. _currentDrag2: number;
  12022. /** @hidden */
  12023. _randomNoiseCoordinates1: Vector3;
  12024. /** @hidden */
  12025. _randomNoiseCoordinates2: Vector3;
  12026. /** @hidden */
  12027. _localPosition?: Vector3;
  12028. /**
  12029. * Creates a new instance Particle
  12030. * @param particleSystem the particle system the particle belongs to
  12031. */
  12032. constructor(
  12033. /**
  12034. * The particle system the particle belongs to.
  12035. */
  12036. particleSystem: ParticleSystem);
  12037. private updateCellInfoFromSystem;
  12038. /**
  12039. * Defines how the sprite cell index is updated for the particle
  12040. */
  12041. updateCellIndex(): void;
  12042. /** @hidden */
  12043. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12044. /** @hidden */
  12045. _inheritParticleInfoToSubEmitters(): void;
  12046. /** @hidden */
  12047. _reset(): void;
  12048. /**
  12049. * Copy the properties of particle to another one.
  12050. * @param other the particle to copy the information to.
  12051. */
  12052. copyTo(other: Particle): void;
  12053. }
  12054. }
  12055. declare module BABYLON {
  12056. /**
  12057. * Particle emitter represents a volume emitting particles.
  12058. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12059. */
  12060. export interface IParticleEmitterType {
  12061. /**
  12062. * Called by the particle System when the direction is computed for the created particle.
  12063. * @param worldMatrix is the world matrix of the particle system
  12064. * @param directionToUpdate is the direction vector to update with the result
  12065. * @param particle is the particle we are computed the direction for
  12066. * @param isLocal defines if the direction should be set in local space
  12067. */
  12068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12069. /**
  12070. * Called by the particle System when the position is computed for the created particle.
  12071. * @param worldMatrix is the world matrix of the particle system
  12072. * @param positionToUpdate is the position vector to update with the result
  12073. * @param particle is the particle we are computed the position for
  12074. * @param isLocal defines if the position should be set in local space
  12075. */
  12076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12077. /**
  12078. * Clones the current emitter and returns a copy of it
  12079. * @returns the new emitter
  12080. */
  12081. clone(): IParticleEmitterType;
  12082. /**
  12083. * Called by the GPUParticleSystem to setup the update shader
  12084. * @param effect defines the update shader
  12085. */
  12086. applyToShader(effect: Effect): void;
  12087. /**
  12088. * Returns a string to use to update the GPU particles update shader
  12089. * @returns the effect defines string
  12090. */
  12091. getEffectDefines(): string;
  12092. /**
  12093. * Returns a string representing the class name
  12094. * @returns a string containing the class name
  12095. */
  12096. getClassName(): string;
  12097. /**
  12098. * Serializes the particle system to a JSON object.
  12099. * @returns the JSON object
  12100. */
  12101. serialize(): any;
  12102. /**
  12103. * Parse properties from a JSON object
  12104. * @param serializationObject defines the JSON object
  12105. * @param scene defines the hosting scene
  12106. */
  12107. parse(serializationObject: any, scene: Scene): void;
  12108. }
  12109. }
  12110. declare module BABYLON {
  12111. /**
  12112. * Particle emitter emitting particles from the inside of a box.
  12113. * It emits the particles randomly between 2 given directions.
  12114. */
  12115. export class BoxParticleEmitter implements IParticleEmitterType {
  12116. /**
  12117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12118. */
  12119. direction1: Vector3;
  12120. /**
  12121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12122. */
  12123. direction2: Vector3;
  12124. /**
  12125. * 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.
  12126. */
  12127. minEmitBox: Vector3;
  12128. /**
  12129. * 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.
  12130. */
  12131. maxEmitBox: Vector3;
  12132. /**
  12133. * Creates a new instance BoxParticleEmitter
  12134. */
  12135. constructor();
  12136. /**
  12137. * Called by the particle System when the direction is computed for the created particle.
  12138. * @param worldMatrix is the world matrix of the particle system
  12139. * @param directionToUpdate is the direction vector to update with the result
  12140. * @param particle is the particle we are computed the direction for
  12141. * @param isLocal defines if the direction should be set in local space
  12142. */
  12143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12144. /**
  12145. * Called by the particle System when the position is computed for the created particle.
  12146. * @param worldMatrix is the world matrix of the particle system
  12147. * @param positionToUpdate is the position vector to update with the result
  12148. * @param particle is the particle we are computed the position for
  12149. * @param isLocal defines if the position should be set in local space
  12150. */
  12151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12152. /**
  12153. * Clones the current emitter and returns a copy of it
  12154. * @returns the new emitter
  12155. */
  12156. clone(): BoxParticleEmitter;
  12157. /**
  12158. * Called by the GPUParticleSystem to setup the update shader
  12159. * @param effect defines the update shader
  12160. */
  12161. applyToShader(effect: Effect): void;
  12162. /**
  12163. * Returns a string to use to update the GPU particles update shader
  12164. * @returns a string containng the defines string
  12165. */
  12166. getEffectDefines(): string;
  12167. /**
  12168. * Returns the string "BoxParticleEmitter"
  12169. * @returns a string containing the class name
  12170. */
  12171. getClassName(): string;
  12172. /**
  12173. * Serializes the particle system to a JSON object.
  12174. * @returns the JSON object
  12175. */
  12176. serialize(): any;
  12177. /**
  12178. * Parse properties from a JSON object
  12179. * @param serializationObject defines the JSON object
  12180. */
  12181. parse(serializationObject: any): void;
  12182. }
  12183. }
  12184. declare module BABYLON {
  12185. /**
  12186. * Particle emitter emitting particles from the inside of a cone.
  12187. * It emits the particles alongside the cone volume from the base to the particle.
  12188. * The emission direction might be randomized.
  12189. */
  12190. export class ConeParticleEmitter implements IParticleEmitterType {
  12191. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12192. directionRandomizer: number;
  12193. private _radius;
  12194. private _angle;
  12195. private _height;
  12196. /**
  12197. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12198. */
  12199. radiusRange: number;
  12200. /**
  12201. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12202. */
  12203. heightRange: number;
  12204. /**
  12205. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12206. */
  12207. emitFromSpawnPointOnly: boolean;
  12208. /**
  12209. * Gets or sets the radius of the emission cone
  12210. */
  12211. get radius(): number;
  12212. set radius(value: number);
  12213. /**
  12214. * Gets or sets the angle of the emission cone
  12215. */
  12216. get angle(): number;
  12217. set angle(value: number);
  12218. private _buildHeight;
  12219. /**
  12220. * Creates a new instance ConeParticleEmitter
  12221. * @param radius the radius of the emission cone (1 by default)
  12222. * @param angle the cone base angle (PI by default)
  12223. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12224. */
  12225. constructor(radius?: number, angle?: number,
  12226. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12227. directionRandomizer?: number);
  12228. /**
  12229. * Called by the particle System when the direction is computed for the created particle.
  12230. * @param worldMatrix is the world matrix of the particle system
  12231. * @param directionToUpdate is the direction vector to update with the result
  12232. * @param particle is the particle we are computed the direction for
  12233. * @param isLocal defines if the direction should be set in local space
  12234. */
  12235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12236. /**
  12237. * Called by the particle System when the position is computed for the created particle.
  12238. * @param worldMatrix is the world matrix of the particle system
  12239. * @param positionToUpdate is the position vector to update with the result
  12240. * @param particle is the particle we are computed the position for
  12241. * @param isLocal defines if the position should be set in local space
  12242. */
  12243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12244. /**
  12245. * Clones the current emitter and returns a copy of it
  12246. * @returns the new emitter
  12247. */
  12248. clone(): ConeParticleEmitter;
  12249. /**
  12250. * Called by the GPUParticleSystem to setup the update shader
  12251. * @param effect defines the update shader
  12252. */
  12253. applyToShader(effect: Effect): void;
  12254. /**
  12255. * Returns a string to use to update the GPU particles update shader
  12256. * @returns a string containng the defines string
  12257. */
  12258. getEffectDefines(): string;
  12259. /**
  12260. * Returns the string "ConeParticleEmitter"
  12261. * @returns a string containing the class name
  12262. */
  12263. getClassName(): string;
  12264. /**
  12265. * Serializes the particle system to a JSON object.
  12266. * @returns the JSON object
  12267. */
  12268. serialize(): any;
  12269. /**
  12270. * Parse properties from a JSON object
  12271. * @param serializationObject defines the JSON object
  12272. */
  12273. parse(serializationObject: any): void;
  12274. }
  12275. }
  12276. declare module BABYLON {
  12277. /**
  12278. * Particle emitter emitting particles from the inside of a cylinder.
  12279. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12280. */
  12281. export class CylinderParticleEmitter implements IParticleEmitterType {
  12282. /**
  12283. * The radius of the emission cylinder.
  12284. */
  12285. radius: number;
  12286. /**
  12287. * The height of the emission cylinder.
  12288. */
  12289. height: number;
  12290. /**
  12291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12292. */
  12293. radiusRange: number;
  12294. /**
  12295. * How much to randomize the particle direction [0-1].
  12296. */
  12297. directionRandomizer: number;
  12298. /**
  12299. * Creates a new instance CylinderParticleEmitter
  12300. * @param radius the radius of the emission cylinder (1 by default)
  12301. * @param height the height of the emission cylinder (1 by default)
  12302. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12304. */
  12305. constructor(
  12306. /**
  12307. * The radius of the emission cylinder.
  12308. */
  12309. radius?: number,
  12310. /**
  12311. * The height of the emission cylinder.
  12312. */
  12313. height?: number,
  12314. /**
  12315. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12316. */
  12317. radiusRange?: number,
  12318. /**
  12319. * How much to randomize the particle direction [0-1].
  12320. */
  12321. directionRandomizer?: number);
  12322. /**
  12323. * Called by the particle System when the direction is computed for the created particle.
  12324. * @param worldMatrix is the world matrix of the particle system
  12325. * @param directionToUpdate is the direction vector to update with the result
  12326. * @param particle is the particle we are computed the direction for
  12327. * @param isLocal defines if the direction should be set in local space
  12328. */
  12329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12330. /**
  12331. * Called by the particle System when the position is computed for the created particle.
  12332. * @param worldMatrix is the world matrix of the particle system
  12333. * @param positionToUpdate is the position vector to update with the result
  12334. * @param particle is the particle we are computed the position for
  12335. * @param isLocal defines if the position should be set in local space
  12336. */
  12337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12338. /**
  12339. * Clones the current emitter and returns a copy of it
  12340. * @returns the new emitter
  12341. */
  12342. clone(): CylinderParticleEmitter;
  12343. /**
  12344. * Called by the GPUParticleSystem to setup the update shader
  12345. * @param effect defines the update shader
  12346. */
  12347. applyToShader(effect: Effect): void;
  12348. /**
  12349. * Returns a string to use to update the GPU particles update shader
  12350. * @returns a string containng the defines string
  12351. */
  12352. getEffectDefines(): string;
  12353. /**
  12354. * Returns the string "CylinderParticleEmitter"
  12355. * @returns a string containing the class name
  12356. */
  12357. getClassName(): string;
  12358. /**
  12359. * Serializes the particle system to a JSON object.
  12360. * @returns the JSON object
  12361. */
  12362. serialize(): any;
  12363. /**
  12364. * Parse properties from a JSON object
  12365. * @param serializationObject defines the JSON object
  12366. */
  12367. parse(serializationObject: any): void;
  12368. }
  12369. /**
  12370. * Particle emitter emitting particles from the inside of a cylinder.
  12371. * It emits the particles randomly between two vectors.
  12372. */
  12373. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12374. /**
  12375. * The min limit of the emission direction.
  12376. */
  12377. direction1: Vector3;
  12378. /**
  12379. * The max limit of the emission direction.
  12380. */
  12381. direction2: Vector3;
  12382. /**
  12383. * Creates a new instance CylinderDirectedParticleEmitter
  12384. * @param radius the radius of the emission cylinder (1 by default)
  12385. * @param height the height of the emission cylinder (1 by default)
  12386. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12387. * @param direction1 the min limit of the emission direction (up vector by default)
  12388. * @param direction2 the max limit of the emission direction (up vector by default)
  12389. */
  12390. constructor(radius?: number, height?: number, radiusRange?: number,
  12391. /**
  12392. * The min limit of the emission direction.
  12393. */
  12394. direction1?: Vector3,
  12395. /**
  12396. * The max limit of the emission direction.
  12397. */
  12398. direction2?: Vector3);
  12399. /**
  12400. * Called by the particle System when the direction is computed for the created particle.
  12401. * @param worldMatrix is the world matrix of the particle system
  12402. * @param directionToUpdate is the direction vector to update with the result
  12403. * @param particle is the particle we are computed the direction for
  12404. */
  12405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12406. /**
  12407. * Clones the current emitter and returns a copy of it
  12408. * @returns the new emitter
  12409. */
  12410. clone(): CylinderDirectedParticleEmitter;
  12411. /**
  12412. * Called by the GPUParticleSystem to setup the update shader
  12413. * @param effect defines the update shader
  12414. */
  12415. applyToShader(effect: Effect): void;
  12416. /**
  12417. * Returns a string to use to update the GPU particles update shader
  12418. * @returns a string containng the defines string
  12419. */
  12420. getEffectDefines(): string;
  12421. /**
  12422. * Returns the string "CylinderDirectedParticleEmitter"
  12423. * @returns a string containing the class name
  12424. */
  12425. getClassName(): string;
  12426. /**
  12427. * Serializes the particle system to a JSON object.
  12428. * @returns the JSON object
  12429. */
  12430. serialize(): any;
  12431. /**
  12432. * Parse properties from a JSON object
  12433. * @param serializationObject defines the JSON object
  12434. */
  12435. parse(serializationObject: any): void;
  12436. }
  12437. }
  12438. declare module BABYLON {
  12439. /**
  12440. * Particle emitter emitting particles from the inside of a hemisphere.
  12441. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12442. */
  12443. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12444. /**
  12445. * The radius of the emission hemisphere.
  12446. */
  12447. radius: number;
  12448. /**
  12449. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12450. */
  12451. radiusRange: number;
  12452. /**
  12453. * How much to randomize the particle direction [0-1].
  12454. */
  12455. directionRandomizer: number;
  12456. /**
  12457. * Creates a new instance HemisphericParticleEmitter
  12458. * @param radius the radius of the emission hemisphere (1 by default)
  12459. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12460. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12461. */
  12462. constructor(
  12463. /**
  12464. * The radius of the emission hemisphere.
  12465. */
  12466. radius?: number,
  12467. /**
  12468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12469. */
  12470. radiusRange?: number,
  12471. /**
  12472. * How much to randomize the particle direction [0-1].
  12473. */
  12474. directionRandomizer?: number);
  12475. /**
  12476. * Called by the particle System when the direction is computed for the created particle.
  12477. * @param worldMatrix is the world matrix of the particle system
  12478. * @param directionToUpdate is the direction vector to update with the result
  12479. * @param particle is the particle we are computed the direction for
  12480. * @param isLocal defines if the direction should be set in local space
  12481. */
  12482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12483. /**
  12484. * Called by the particle System when the position is computed for the created particle.
  12485. * @param worldMatrix is the world matrix of the particle system
  12486. * @param positionToUpdate is the position vector to update with the result
  12487. * @param particle is the particle we are computed the position for
  12488. * @param isLocal defines if the position should be set in local space
  12489. */
  12490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12491. /**
  12492. * Clones the current emitter and returns a copy of it
  12493. * @returns the new emitter
  12494. */
  12495. clone(): HemisphericParticleEmitter;
  12496. /**
  12497. * Called by the GPUParticleSystem to setup the update shader
  12498. * @param effect defines the update shader
  12499. */
  12500. applyToShader(effect: Effect): void;
  12501. /**
  12502. * Returns a string to use to update the GPU particles update shader
  12503. * @returns a string containng the defines string
  12504. */
  12505. getEffectDefines(): string;
  12506. /**
  12507. * Returns the string "HemisphericParticleEmitter"
  12508. * @returns a string containing the class name
  12509. */
  12510. getClassName(): string;
  12511. /**
  12512. * Serializes the particle system to a JSON object.
  12513. * @returns the JSON object
  12514. */
  12515. serialize(): any;
  12516. /**
  12517. * Parse properties from a JSON object
  12518. * @param serializationObject defines the JSON object
  12519. */
  12520. parse(serializationObject: any): void;
  12521. }
  12522. }
  12523. declare module BABYLON {
  12524. /**
  12525. * Particle emitter emitting particles from a point.
  12526. * It emits the particles randomly between 2 given directions.
  12527. */
  12528. export class PointParticleEmitter implements IParticleEmitterType {
  12529. /**
  12530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12531. */
  12532. direction1: Vector3;
  12533. /**
  12534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12535. */
  12536. direction2: Vector3;
  12537. /**
  12538. * Creates a new instance PointParticleEmitter
  12539. */
  12540. constructor();
  12541. /**
  12542. * Called by the particle System when the direction is computed for the created particle.
  12543. * @param worldMatrix is the world matrix of the particle system
  12544. * @param directionToUpdate is the direction vector to update with the result
  12545. * @param particle is the particle we are computed the direction for
  12546. * @param isLocal defines if the direction should be set in local space
  12547. */
  12548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12549. /**
  12550. * Called by the particle System when the position is computed for the created particle.
  12551. * @param worldMatrix is the world matrix of the particle system
  12552. * @param positionToUpdate is the position vector to update with the result
  12553. * @param particle is the particle we are computed the position for
  12554. * @param isLocal defines if the position should be set in local space
  12555. */
  12556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12557. /**
  12558. * Clones the current emitter and returns a copy of it
  12559. * @returns the new emitter
  12560. */
  12561. clone(): PointParticleEmitter;
  12562. /**
  12563. * Called by the GPUParticleSystem to setup the update shader
  12564. * @param effect defines the update shader
  12565. */
  12566. applyToShader(effect: Effect): void;
  12567. /**
  12568. * Returns a string to use to update the GPU particles update shader
  12569. * @returns a string containng the defines string
  12570. */
  12571. getEffectDefines(): string;
  12572. /**
  12573. * Returns the string "PointParticleEmitter"
  12574. * @returns a string containing the class name
  12575. */
  12576. getClassName(): string;
  12577. /**
  12578. * Serializes the particle system to a JSON object.
  12579. * @returns the JSON object
  12580. */
  12581. serialize(): any;
  12582. /**
  12583. * Parse properties from a JSON object
  12584. * @param serializationObject defines the JSON object
  12585. */
  12586. parse(serializationObject: any): void;
  12587. }
  12588. }
  12589. declare module BABYLON {
  12590. /**
  12591. * Particle emitter emitting particles from the inside of a sphere.
  12592. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12593. */
  12594. export class SphereParticleEmitter implements IParticleEmitterType {
  12595. /**
  12596. * The radius of the emission sphere.
  12597. */
  12598. radius: number;
  12599. /**
  12600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12601. */
  12602. radiusRange: number;
  12603. /**
  12604. * How much to randomize the particle direction [0-1].
  12605. */
  12606. directionRandomizer: number;
  12607. /**
  12608. * Creates a new instance SphereParticleEmitter
  12609. * @param radius the radius of the emission sphere (1 by default)
  12610. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12612. */
  12613. constructor(
  12614. /**
  12615. * The radius of the emission sphere.
  12616. */
  12617. radius?: number,
  12618. /**
  12619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12620. */
  12621. radiusRange?: number,
  12622. /**
  12623. * How much to randomize the particle direction [0-1].
  12624. */
  12625. directionRandomizer?: number);
  12626. /**
  12627. * Called by the particle System when the direction is computed for the created particle.
  12628. * @param worldMatrix is the world matrix of the particle system
  12629. * @param directionToUpdate is the direction vector to update with the result
  12630. * @param particle is the particle we are computed the direction for
  12631. * @param isLocal defines if the direction should be set in local space
  12632. */
  12633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12634. /**
  12635. * Called by the particle System when the position is computed for the created particle.
  12636. * @param worldMatrix is the world matrix of the particle system
  12637. * @param positionToUpdate is the position vector to update with the result
  12638. * @param particle is the particle we are computed the position for
  12639. * @param isLocal defines if the position should be set in local space
  12640. */
  12641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12642. /**
  12643. * Clones the current emitter and returns a copy of it
  12644. * @returns the new emitter
  12645. */
  12646. clone(): SphereParticleEmitter;
  12647. /**
  12648. * Called by the GPUParticleSystem to setup the update shader
  12649. * @param effect defines the update shader
  12650. */
  12651. applyToShader(effect: Effect): void;
  12652. /**
  12653. * Returns a string to use to update the GPU particles update shader
  12654. * @returns a string containng the defines string
  12655. */
  12656. getEffectDefines(): string;
  12657. /**
  12658. * Returns the string "SphereParticleEmitter"
  12659. * @returns a string containing the class name
  12660. */
  12661. getClassName(): string;
  12662. /**
  12663. * Serializes the particle system to a JSON object.
  12664. * @returns the JSON object
  12665. */
  12666. serialize(): any;
  12667. /**
  12668. * Parse properties from a JSON object
  12669. * @param serializationObject defines the JSON object
  12670. */
  12671. parse(serializationObject: any): void;
  12672. }
  12673. /**
  12674. * Particle emitter emitting particles from the inside of a sphere.
  12675. * It emits the particles randomly between two vectors.
  12676. */
  12677. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12678. /**
  12679. * The min limit of the emission direction.
  12680. */
  12681. direction1: Vector3;
  12682. /**
  12683. * The max limit of the emission direction.
  12684. */
  12685. direction2: Vector3;
  12686. /**
  12687. * Creates a new instance SphereDirectedParticleEmitter
  12688. * @param radius the radius of the emission sphere (1 by default)
  12689. * @param direction1 the min limit of the emission direction (up vector by default)
  12690. * @param direction2 the max limit of the emission direction (up vector by default)
  12691. */
  12692. constructor(radius?: number,
  12693. /**
  12694. * The min limit of the emission direction.
  12695. */
  12696. direction1?: Vector3,
  12697. /**
  12698. * The max limit of the emission direction.
  12699. */
  12700. direction2?: Vector3);
  12701. /**
  12702. * Called by the particle System when the direction is computed for the created particle.
  12703. * @param worldMatrix is the world matrix of the particle system
  12704. * @param directionToUpdate is the direction vector to update with the result
  12705. * @param particle is the particle we are computed the direction for
  12706. */
  12707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12708. /**
  12709. * Clones the current emitter and returns a copy of it
  12710. * @returns the new emitter
  12711. */
  12712. clone(): SphereDirectedParticleEmitter;
  12713. /**
  12714. * Called by the GPUParticleSystem to setup the update shader
  12715. * @param effect defines the update shader
  12716. */
  12717. applyToShader(effect: Effect): void;
  12718. /**
  12719. * Returns a string to use to update the GPU particles update shader
  12720. * @returns a string containng the defines string
  12721. */
  12722. getEffectDefines(): string;
  12723. /**
  12724. * Returns the string "SphereDirectedParticleEmitter"
  12725. * @returns a string containing the class name
  12726. */
  12727. getClassName(): string;
  12728. /**
  12729. * Serializes the particle system to a JSON object.
  12730. * @returns the JSON object
  12731. */
  12732. serialize(): any;
  12733. /**
  12734. * Parse properties from a JSON object
  12735. * @param serializationObject defines the JSON object
  12736. */
  12737. parse(serializationObject: any): void;
  12738. }
  12739. }
  12740. declare module BABYLON {
  12741. /**
  12742. * Particle emitter emitting particles from a custom list of positions.
  12743. */
  12744. export class CustomParticleEmitter implements IParticleEmitterType {
  12745. /**
  12746. * Gets or sets the position generator that will create the inital position of each particle.
  12747. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12748. */
  12749. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12750. /**
  12751. * Gets or sets the destination generator that will create the final destination of each particle.
  12752. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12753. */
  12754. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12755. /**
  12756. * Creates a new instance CustomParticleEmitter
  12757. */
  12758. constructor();
  12759. /**
  12760. * Called by the particle System when the direction is computed for the created particle.
  12761. * @param worldMatrix is the world matrix of the particle system
  12762. * @param directionToUpdate is the direction vector to update with the result
  12763. * @param particle is the particle we are computed the direction for
  12764. * @param isLocal defines if the direction should be set in local space
  12765. */
  12766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12767. /**
  12768. * Called by the particle System when the position is computed for the created particle.
  12769. * @param worldMatrix is the world matrix of the particle system
  12770. * @param positionToUpdate is the position vector to update with the result
  12771. * @param particle is the particle we are computed the position for
  12772. * @param isLocal defines if the position should be set in local space
  12773. */
  12774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12775. /**
  12776. * Clones the current emitter and returns a copy of it
  12777. * @returns the new emitter
  12778. */
  12779. clone(): CustomParticleEmitter;
  12780. /**
  12781. * Called by the GPUParticleSystem to setup the update shader
  12782. * @param effect defines the update shader
  12783. */
  12784. applyToShader(effect: Effect): void;
  12785. /**
  12786. * Returns a string to use to update the GPU particles update shader
  12787. * @returns a string containng the defines string
  12788. */
  12789. getEffectDefines(): string;
  12790. /**
  12791. * Returns the string "PointParticleEmitter"
  12792. * @returns a string containing the class name
  12793. */
  12794. getClassName(): string;
  12795. /**
  12796. * Serializes the particle system to a JSON object.
  12797. * @returns the JSON object
  12798. */
  12799. serialize(): any;
  12800. /**
  12801. * Parse properties from a JSON object
  12802. * @param serializationObject defines the JSON object
  12803. */
  12804. parse(serializationObject: any): void;
  12805. }
  12806. }
  12807. declare module BABYLON {
  12808. /**
  12809. * Particle emitter emitting particles from the inside of a box.
  12810. * It emits the particles randomly between 2 given directions.
  12811. */
  12812. export class MeshParticleEmitter implements IParticleEmitterType {
  12813. /** Defines the mesh to use as source */
  12814. mesh?: AbstractMesh | undefined;
  12815. private _indices;
  12816. private _positions;
  12817. private _normals;
  12818. private _storedNormal;
  12819. /**
  12820. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12821. */
  12822. direction1: Vector3;
  12823. /**
  12824. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12825. */
  12826. direction2: Vector3;
  12827. /**
  12828. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12829. */
  12830. useMeshNormalsForDirection: boolean;
  12831. /**
  12832. * Creates a new instance MeshParticleEmitter
  12833. * @param mesh defines the mesh to use as source
  12834. */
  12835. constructor(
  12836. /** Defines the mesh to use as source */
  12837. mesh?: AbstractMesh | undefined);
  12838. /**
  12839. * Called by the particle System when the direction is computed for the created particle.
  12840. * @param worldMatrix is the world matrix of the particle system
  12841. * @param directionToUpdate is the direction vector to update with the result
  12842. * @param particle is the particle we are computed the direction for
  12843. * @param isLocal defines if the direction should be set in local space
  12844. */
  12845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12846. /**
  12847. * Called by the particle System when the position is computed for the created particle.
  12848. * @param worldMatrix is the world matrix of the particle system
  12849. * @param positionToUpdate is the position vector to update with the result
  12850. * @param particle is the particle we are computed the position for
  12851. * @param isLocal defines if the position should be set in local space
  12852. */
  12853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12854. /**
  12855. * Clones the current emitter and returns a copy of it
  12856. * @returns the new emitter
  12857. */
  12858. clone(): MeshParticleEmitter;
  12859. /**
  12860. * Called by the GPUParticleSystem to setup the update shader
  12861. * @param effect defines the update shader
  12862. */
  12863. applyToShader(effect: Effect): void;
  12864. /**
  12865. * Returns a string to use to update the GPU particles update shader
  12866. * @returns a string containng the defines string
  12867. */
  12868. getEffectDefines(): string;
  12869. /**
  12870. * Returns the string "BoxParticleEmitter"
  12871. * @returns a string containing the class name
  12872. */
  12873. getClassName(): string;
  12874. /**
  12875. * Serializes the particle system to a JSON object.
  12876. * @returns the JSON object
  12877. */
  12878. serialize(): any;
  12879. /**
  12880. * Parse properties from a JSON object
  12881. * @param serializationObject defines the JSON object
  12882. * @param scene defines the hosting scene
  12883. */
  12884. parse(serializationObject: any, scene: Scene): void;
  12885. }
  12886. }
  12887. declare module BABYLON {
  12888. /**
  12889. * Interface representing a particle system in Babylon.js.
  12890. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12891. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12892. */
  12893. export interface IParticleSystem {
  12894. /**
  12895. * List of animations used by the particle system.
  12896. */
  12897. animations: Animation[];
  12898. /**
  12899. * The id of the Particle system.
  12900. */
  12901. id: string;
  12902. /**
  12903. * The name of the Particle system.
  12904. */
  12905. name: string;
  12906. /**
  12907. * The emitter represents the Mesh or position we are attaching the particle system to.
  12908. */
  12909. emitter: Nullable<AbstractMesh | Vector3>;
  12910. /**
  12911. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12912. */
  12913. isBillboardBased: boolean;
  12914. /**
  12915. * The rendering group used by the Particle system to chose when to render.
  12916. */
  12917. renderingGroupId: number;
  12918. /**
  12919. * The layer mask we are rendering the particles through.
  12920. */
  12921. layerMask: number;
  12922. /**
  12923. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12924. */
  12925. updateSpeed: number;
  12926. /**
  12927. * The amount of time the particle system is running (depends of the overall update speed).
  12928. */
  12929. targetStopDuration: number;
  12930. /**
  12931. * The texture used to render each particle. (this can be a spritesheet)
  12932. */
  12933. particleTexture: Nullable<Texture>;
  12934. /**
  12935. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12936. */
  12937. blendMode: number;
  12938. /**
  12939. * Minimum life time of emitting particles.
  12940. */
  12941. minLifeTime: number;
  12942. /**
  12943. * Maximum life time of emitting particles.
  12944. */
  12945. maxLifeTime: number;
  12946. /**
  12947. * Minimum Size of emitting particles.
  12948. */
  12949. minSize: number;
  12950. /**
  12951. * Maximum Size of emitting particles.
  12952. */
  12953. maxSize: number;
  12954. /**
  12955. * Minimum scale of emitting particles on X axis.
  12956. */
  12957. minScaleX: number;
  12958. /**
  12959. * Maximum scale of emitting particles on X axis.
  12960. */
  12961. maxScaleX: number;
  12962. /**
  12963. * Minimum scale of emitting particles on Y axis.
  12964. */
  12965. minScaleY: number;
  12966. /**
  12967. * Maximum scale of emitting particles on Y axis.
  12968. */
  12969. maxScaleY: number;
  12970. /**
  12971. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12972. */
  12973. color1: Color4;
  12974. /**
  12975. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12976. */
  12977. color2: Color4;
  12978. /**
  12979. * Color the particle will have at the end of its lifetime.
  12980. */
  12981. colorDead: Color4;
  12982. /**
  12983. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  12984. */
  12985. emitRate: number;
  12986. /**
  12987. * You can use gravity if you want to give an orientation to your particles.
  12988. */
  12989. gravity: Vector3;
  12990. /**
  12991. * Minimum power of emitting particles.
  12992. */
  12993. minEmitPower: number;
  12994. /**
  12995. * Maximum power of emitting particles.
  12996. */
  12997. maxEmitPower: number;
  12998. /**
  12999. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13000. */
  13001. minAngularSpeed: number;
  13002. /**
  13003. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13004. */
  13005. maxAngularSpeed: number;
  13006. /**
  13007. * Gets or sets the minimal initial rotation in radians.
  13008. */
  13009. minInitialRotation: number;
  13010. /**
  13011. * Gets or sets the maximal initial rotation in radians.
  13012. */
  13013. maxInitialRotation: number;
  13014. /**
  13015. * The particle emitter type defines the emitter used by the particle system.
  13016. * It can be for example box, sphere, or cone...
  13017. */
  13018. particleEmitterType: Nullable<IParticleEmitterType>;
  13019. /**
  13020. * Defines the delay in milliseconds before starting the system (0 by default)
  13021. */
  13022. startDelay: number;
  13023. /**
  13024. * 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
  13025. */
  13026. preWarmCycles: number;
  13027. /**
  13028. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13029. */
  13030. preWarmStepOffset: number;
  13031. /**
  13032. * 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)
  13033. */
  13034. spriteCellChangeSpeed: number;
  13035. /**
  13036. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13037. */
  13038. startSpriteCellID: number;
  13039. /**
  13040. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13041. */
  13042. endSpriteCellID: number;
  13043. /**
  13044. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13045. */
  13046. spriteCellWidth: number;
  13047. /**
  13048. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13049. */
  13050. spriteCellHeight: number;
  13051. /**
  13052. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13053. */
  13054. spriteRandomStartCell: boolean;
  13055. /**
  13056. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13057. */
  13058. isAnimationSheetEnabled: boolean;
  13059. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13060. translationPivot: Vector2;
  13061. /**
  13062. * Gets or sets a texture used to add random noise to particle positions
  13063. */
  13064. noiseTexture: Nullable<BaseTexture>;
  13065. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13066. noiseStrength: Vector3;
  13067. /**
  13068. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13069. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13070. */
  13071. billboardMode: number;
  13072. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13073. limitVelocityDamping: number;
  13074. /**
  13075. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13076. */
  13077. beginAnimationOnStart: boolean;
  13078. /**
  13079. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13080. */
  13081. beginAnimationFrom: number;
  13082. /**
  13083. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13084. */
  13085. beginAnimationTo: number;
  13086. /**
  13087. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13088. */
  13089. beginAnimationLoop: boolean;
  13090. /**
  13091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13092. */
  13093. disposeOnStop: boolean;
  13094. /**
  13095. * Specifies if the particles are updated in emitter local space or world space
  13096. */
  13097. isLocal: boolean;
  13098. /**
  13099. * Gets the maximum number of particles active at the same time.
  13100. * @returns The max number of active particles.
  13101. */
  13102. getCapacity(): number;
  13103. /**
  13104. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13105. * @returns True if it has been started, otherwise false.
  13106. */
  13107. isStarted(): boolean;
  13108. /**
  13109. * Animates the particle system for this frame.
  13110. */
  13111. animate(): void;
  13112. /**
  13113. * Renders the particle system in its current state.
  13114. * @returns the current number of particles
  13115. */
  13116. render(): number;
  13117. /**
  13118. * Dispose the particle system and frees its associated resources.
  13119. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13120. */
  13121. dispose(disposeTexture?: boolean): void;
  13122. /**
  13123. * Clones the particle system.
  13124. * @param name The name of the cloned object
  13125. * @param newEmitter The new emitter to use
  13126. * @returns the cloned particle system
  13127. */
  13128. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13129. /**
  13130. * Serializes the particle system to a JSON object.
  13131. * @returns the JSON object
  13132. */
  13133. serialize(): any;
  13134. /**
  13135. * Rebuild the particle system
  13136. */
  13137. rebuild(): void;
  13138. /**
  13139. * Starts the particle system and begins to emit
  13140. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13141. */
  13142. start(delay?: number): void;
  13143. /**
  13144. * Stops the particle system.
  13145. */
  13146. stop(): void;
  13147. /**
  13148. * Remove all active particles
  13149. */
  13150. reset(): void;
  13151. /**
  13152. * Is this system ready to be used/rendered
  13153. * @return true if the system is ready
  13154. */
  13155. isReady(): boolean;
  13156. /**
  13157. * Adds a new color gradient
  13158. * @param gradient defines the gradient to use (between 0 and 1)
  13159. * @param color1 defines the color to affect to the specified gradient
  13160. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13161. * @returns the current particle system
  13162. */
  13163. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13164. /**
  13165. * Remove a specific color gradient
  13166. * @param gradient defines the gradient to remove
  13167. * @returns the current particle system
  13168. */
  13169. removeColorGradient(gradient: number): IParticleSystem;
  13170. /**
  13171. * Adds a new size gradient
  13172. * @param gradient defines the gradient to use (between 0 and 1)
  13173. * @param factor defines the size factor to affect to the specified gradient
  13174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13175. * @returns the current particle system
  13176. */
  13177. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13178. /**
  13179. * Remove a specific size gradient
  13180. * @param gradient defines the gradient to remove
  13181. * @returns the current particle system
  13182. */
  13183. removeSizeGradient(gradient: number): IParticleSystem;
  13184. /**
  13185. * Gets the current list of color gradients.
  13186. * You must use addColorGradient and removeColorGradient to udpate this list
  13187. * @returns the list of color gradients
  13188. */
  13189. getColorGradients(): Nullable<Array<ColorGradient>>;
  13190. /**
  13191. * Gets the current list of size gradients.
  13192. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13193. * @returns the list of size gradients
  13194. */
  13195. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13196. /**
  13197. * Gets the current list of angular speed gradients.
  13198. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13199. * @returns the list of angular speed gradients
  13200. */
  13201. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13202. /**
  13203. * Adds a new angular speed gradient
  13204. * @param gradient defines the gradient to use (between 0 and 1)
  13205. * @param factor defines the angular speed to affect to the specified gradient
  13206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13207. * @returns the current particle system
  13208. */
  13209. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13210. /**
  13211. * Remove a specific angular speed gradient
  13212. * @param gradient defines the gradient to remove
  13213. * @returns the current particle system
  13214. */
  13215. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13216. /**
  13217. * Gets the current list of velocity gradients.
  13218. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13219. * @returns the list of velocity gradients
  13220. */
  13221. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13222. /**
  13223. * Adds a new velocity gradient
  13224. * @param gradient defines the gradient to use (between 0 and 1)
  13225. * @param factor defines the velocity to affect to the specified gradient
  13226. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13227. * @returns the current particle system
  13228. */
  13229. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13230. /**
  13231. * Remove a specific velocity gradient
  13232. * @param gradient defines the gradient to remove
  13233. * @returns the current particle system
  13234. */
  13235. removeVelocityGradient(gradient: number): IParticleSystem;
  13236. /**
  13237. * Gets the current list of limit velocity gradients.
  13238. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13239. * @returns the list of limit velocity gradients
  13240. */
  13241. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13242. /**
  13243. * Adds a new limit velocity gradient
  13244. * @param gradient defines the gradient to use (between 0 and 1)
  13245. * @param factor defines the limit velocity to affect to the specified gradient
  13246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13247. * @returns the current particle system
  13248. */
  13249. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13250. /**
  13251. * Remove a specific limit velocity gradient
  13252. * @param gradient defines the gradient to remove
  13253. * @returns the current particle system
  13254. */
  13255. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13256. /**
  13257. * Adds a new drag gradient
  13258. * @param gradient defines the gradient to use (between 0 and 1)
  13259. * @param factor defines the drag to affect to the specified gradient
  13260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13261. * @returns the current particle system
  13262. */
  13263. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13264. /**
  13265. * Remove a specific drag gradient
  13266. * @param gradient defines the gradient to remove
  13267. * @returns the current particle system
  13268. */
  13269. removeDragGradient(gradient: number): IParticleSystem;
  13270. /**
  13271. * Gets the current list of drag gradients.
  13272. * You must use addDragGradient and removeDragGradient to udpate this list
  13273. * @returns the list of drag gradients
  13274. */
  13275. getDragGradients(): Nullable<Array<FactorGradient>>;
  13276. /**
  13277. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13278. * @param gradient defines the gradient to use (between 0 and 1)
  13279. * @param factor defines the emit rate to affect to the specified gradient
  13280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13281. * @returns the current particle system
  13282. */
  13283. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13284. /**
  13285. * Remove a specific emit rate gradient
  13286. * @param gradient defines the gradient to remove
  13287. * @returns the current particle system
  13288. */
  13289. removeEmitRateGradient(gradient: number): IParticleSystem;
  13290. /**
  13291. * Gets the current list of emit rate gradients.
  13292. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13293. * @returns the list of emit rate gradients
  13294. */
  13295. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13296. /**
  13297. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13298. * @param gradient defines the gradient to use (between 0 and 1)
  13299. * @param factor defines the start size to affect to the specified gradient
  13300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13301. * @returns the current particle system
  13302. */
  13303. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13304. /**
  13305. * Remove a specific start size gradient
  13306. * @param gradient defines the gradient to remove
  13307. * @returns the current particle system
  13308. */
  13309. removeStartSizeGradient(gradient: number): IParticleSystem;
  13310. /**
  13311. * Gets the current list of start size gradients.
  13312. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13313. * @returns the list of start size gradients
  13314. */
  13315. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13316. /**
  13317. * Adds a new life time gradient
  13318. * @param gradient defines the gradient to use (between 0 and 1)
  13319. * @param factor defines the life time factor to affect to the specified gradient
  13320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13321. * @returns the current particle system
  13322. */
  13323. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13324. /**
  13325. * Remove a specific life time gradient
  13326. * @param gradient defines the gradient to remove
  13327. * @returns the current particle system
  13328. */
  13329. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13330. /**
  13331. * Gets the current list of life time gradients.
  13332. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13333. * @returns the list of life time gradients
  13334. */
  13335. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13336. /**
  13337. * Gets the current list of color gradients.
  13338. * You must use addColorGradient and removeColorGradient to udpate this list
  13339. * @returns the list of color gradients
  13340. */
  13341. getColorGradients(): Nullable<Array<ColorGradient>>;
  13342. /**
  13343. * Adds a new ramp gradient used to remap particle colors
  13344. * @param gradient defines the gradient to use (between 0 and 1)
  13345. * @param color defines the color to affect to the specified gradient
  13346. * @returns the current particle system
  13347. */
  13348. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13349. /**
  13350. * Gets the current list of ramp gradients.
  13351. * You must use addRampGradient and removeRampGradient to udpate this list
  13352. * @returns the list of ramp gradients
  13353. */
  13354. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13355. /** Gets or sets a boolean indicating that ramp gradients must be used
  13356. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13357. */
  13358. useRampGradients: boolean;
  13359. /**
  13360. * Adds a new color remap gradient
  13361. * @param gradient defines the gradient to use (between 0 and 1)
  13362. * @param min defines the color remap minimal range
  13363. * @param max defines the color remap maximal range
  13364. * @returns the current particle system
  13365. */
  13366. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13367. /**
  13368. * Gets the current list of color remap gradients.
  13369. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13370. * @returns the list of color remap gradients
  13371. */
  13372. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13373. /**
  13374. * Adds a new alpha remap gradient
  13375. * @param gradient defines the gradient to use (between 0 and 1)
  13376. * @param min defines the alpha remap minimal range
  13377. * @param max defines the alpha remap maximal range
  13378. * @returns the current particle system
  13379. */
  13380. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13381. /**
  13382. * Gets the current list of alpha remap gradients.
  13383. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13384. * @returns the list of alpha remap gradients
  13385. */
  13386. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13387. /**
  13388. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13391. * @returns the emitter
  13392. */
  13393. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13394. /**
  13395. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13396. * @param radius The radius of the hemisphere to emit from
  13397. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13398. * @returns the emitter
  13399. */
  13400. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13401. /**
  13402. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13403. * @param radius The radius of the sphere to emit from
  13404. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13405. * @returns the emitter
  13406. */
  13407. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13408. /**
  13409. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13410. * @param radius The radius of the sphere to emit from
  13411. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13412. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13413. * @returns the emitter
  13414. */
  13415. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13416. /**
  13417. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13418. * @param radius The radius of the emission cylinder
  13419. * @param height The height of the emission cylinder
  13420. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13421. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13422. * @returns the emitter
  13423. */
  13424. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13425. /**
  13426. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13427. * @param radius The radius of the cylinder to emit from
  13428. * @param height The height of the emission cylinder
  13429. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13432. * @returns the emitter
  13433. */
  13434. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13435. /**
  13436. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13437. * @param radius The radius of the cone to emit from
  13438. * @param angle The base angle of the cone
  13439. * @returns the emitter
  13440. */
  13441. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13442. /**
  13443. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13446. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13447. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13448. * @returns the emitter
  13449. */
  13450. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13451. /**
  13452. * Get hosting scene
  13453. * @returns the scene
  13454. */
  13455. getScene(): Scene;
  13456. }
  13457. }
  13458. declare module BABYLON {
  13459. /**
  13460. * 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.
  13461. * @see https://doc.babylonjs.com/how_to/transformnode
  13462. */
  13463. export class TransformNode extends Node {
  13464. /**
  13465. * Object will not rotate to face the camera
  13466. */
  13467. static BILLBOARDMODE_NONE: number;
  13468. /**
  13469. * Object will rotate to face the camera but only on the x axis
  13470. */
  13471. static BILLBOARDMODE_X: number;
  13472. /**
  13473. * Object will rotate to face the camera but only on the y axis
  13474. */
  13475. static BILLBOARDMODE_Y: number;
  13476. /**
  13477. * Object will rotate to face the camera but only on the z axis
  13478. */
  13479. static BILLBOARDMODE_Z: number;
  13480. /**
  13481. * Object will rotate to face the camera
  13482. */
  13483. static BILLBOARDMODE_ALL: number;
  13484. /**
  13485. * Object will rotate to face the camera's position instead of orientation
  13486. */
  13487. static BILLBOARDMODE_USE_POSITION: number;
  13488. private _forward;
  13489. private _forwardInverted;
  13490. private _up;
  13491. private _right;
  13492. private _rightInverted;
  13493. private _position;
  13494. private _rotation;
  13495. private _rotationQuaternion;
  13496. protected _scaling: Vector3;
  13497. protected _isDirty: boolean;
  13498. private _transformToBoneReferal;
  13499. private _isAbsoluteSynced;
  13500. private _billboardMode;
  13501. /**
  13502. * Gets or sets the billboard mode. Default is 0.
  13503. *
  13504. * | Value | Type | Description |
  13505. * | --- | --- | --- |
  13506. * | 0 | BILLBOARDMODE_NONE | |
  13507. * | 1 | BILLBOARDMODE_X | |
  13508. * | 2 | BILLBOARDMODE_Y | |
  13509. * | 4 | BILLBOARDMODE_Z | |
  13510. * | 7 | BILLBOARDMODE_ALL | |
  13511. *
  13512. */
  13513. get billboardMode(): number;
  13514. set billboardMode(value: number);
  13515. private _preserveParentRotationForBillboard;
  13516. /**
  13517. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13518. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13519. */
  13520. get preserveParentRotationForBillboard(): boolean;
  13521. set preserveParentRotationForBillboard(value: boolean);
  13522. /**
  13523. * 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
  13524. */
  13525. scalingDeterminant: number;
  13526. private _infiniteDistance;
  13527. /**
  13528. * Gets or sets the distance of the object to max, often used by skybox
  13529. */
  13530. get infiniteDistance(): boolean;
  13531. set infiniteDistance(value: boolean);
  13532. /**
  13533. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13534. * By default the system will update normals to compensate
  13535. */
  13536. ignoreNonUniformScaling: boolean;
  13537. /**
  13538. * 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
  13539. */
  13540. reIntegrateRotationIntoRotationQuaternion: boolean;
  13541. /** @hidden */
  13542. _poseMatrix: Nullable<Matrix>;
  13543. /** @hidden */
  13544. _localMatrix: Matrix;
  13545. private _usePivotMatrix;
  13546. private _absolutePosition;
  13547. private _absoluteScaling;
  13548. private _absoluteRotationQuaternion;
  13549. private _pivotMatrix;
  13550. private _pivotMatrixInverse;
  13551. protected _postMultiplyPivotMatrix: boolean;
  13552. protected _isWorldMatrixFrozen: boolean;
  13553. /** @hidden */
  13554. _indexInSceneTransformNodesArray: number;
  13555. /**
  13556. * An event triggered after the world matrix is updated
  13557. */
  13558. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13559. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13560. /**
  13561. * Gets a string identifying the name of the class
  13562. * @returns "TransformNode" string
  13563. */
  13564. getClassName(): string;
  13565. /**
  13566. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13567. */
  13568. get position(): Vector3;
  13569. set position(newPosition: Vector3);
  13570. /**
  13571. * 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)).
  13572. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13573. */
  13574. get rotation(): Vector3;
  13575. set rotation(newRotation: Vector3);
  13576. /**
  13577. * 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)).
  13578. */
  13579. get scaling(): Vector3;
  13580. set scaling(newScaling: Vector3);
  13581. /**
  13582. * 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).
  13583. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13584. */
  13585. get rotationQuaternion(): Nullable<Quaternion>;
  13586. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13587. /**
  13588. * The forward direction of that transform in world space.
  13589. */
  13590. get forward(): Vector3;
  13591. /**
  13592. * The up direction of that transform in world space.
  13593. */
  13594. get up(): Vector3;
  13595. /**
  13596. * The right direction of that transform in world space.
  13597. */
  13598. get right(): Vector3;
  13599. /**
  13600. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13601. * @param matrix the matrix to copy the pose from
  13602. * @returns this TransformNode.
  13603. */
  13604. updatePoseMatrix(matrix: Matrix): TransformNode;
  13605. /**
  13606. * Returns the mesh Pose matrix.
  13607. * @returns the pose matrix
  13608. */
  13609. getPoseMatrix(): Matrix;
  13610. /** @hidden */
  13611. _isSynchronized(): boolean;
  13612. /** @hidden */
  13613. _initCache(): void;
  13614. /**
  13615. * Flag the transform node as dirty (Forcing it to update everything)
  13616. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13617. * @returns this transform node
  13618. */
  13619. markAsDirty(property: string): TransformNode;
  13620. /**
  13621. * Returns the current mesh absolute position.
  13622. * Returns a Vector3.
  13623. */
  13624. get absolutePosition(): Vector3;
  13625. /**
  13626. * Returns the current mesh absolute scaling.
  13627. * Returns a Vector3.
  13628. */
  13629. get absoluteScaling(): Vector3;
  13630. /**
  13631. * Returns the current mesh absolute rotation.
  13632. * Returns a Quaternion.
  13633. */
  13634. get absoluteRotationQuaternion(): Quaternion;
  13635. /**
  13636. * Sets a new matrix to apply before all other transformation
  13637. * @param matrix defines the transform matrix
  13638. * @returns the current TransformNode
  13639. */
  13640. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13641. /**
  13642. * Sets a new pivot matrix to the current node
  13643. * @param matrix defines the new pivot matrix to use
  13644. * @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
  13645. * @returns the current TransformNode
  13646. */
  13647. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13648. /**
  13649. * Returns the mesh pivot matrix.
  13650. * Default : Identity.
  13651. * @returns the matrix
  13652. */
  13653. getPivotMatrix(): Matrix;
  13654. /**
  13655. * Instantiate (when possible) or clone that node with its hierarchy
  13656. * @param newParent defines the new parent to use for the instance (or clone)
  13657. * @param options defines options to configure how copy is done
  13658. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13659. * @returns an instance (or a clone) of the current node with its hiearchy
  13660. */
  13661. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13662. doNotInstantiate: boolean;
  13663. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13664. /**
  13665. * Prevents the World matrix to be computed any longer
  13666. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13667. * @returns the TransformNode.
  13668. */
  13669. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13670. /**
  13671. * Allows back the World matrix computation.
  13672. * @returns the TransformNode.
  13673. */
  13674. unfreezeWorldMatrix(): this;
  13675. /**
  13676. * True if the World matrix has been frozen.
  13677. */
  13678. get isWorldMatrixFrozen(): boolean;
  13679. /**
  13680. * Retuns the mesh absolute position in the World.
  13681. * @returns a Vector3.
  13682. */
  13683. getAbsolutePosition(): Vector3;
  13684. /**
  13685. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13686. * @param absolutePosition the absolute position to set
  13687. * @returns the TransformNode.
  13688. */
  13689. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13690. /**
  13691. * Sets the mesh position in its local space.
  13692. * @param vector3 the position to set in localspace
  13693. * @returns the TransformNode.
  13694. */
  13695. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13696. /**
  13697. * Returns the mesh position in the local space from the current World matrix values.
  13698. * @returns a new Vector3.
  13699. */
  13700. getPositionExpressedInLocalSpace(): Vector3;
  13701. /**
  13702. * Translates the mesh along the passed Vector3 in its local space.
  13703. * @param vector3 the distance to translate in localspace
  13704. * @returns the TransformNode.
  13705. */
  13706. locallyTranslate(vector3: Vector3): TransformNode;
  13707. private static _lookAtVectorCache;
  13708. /**
  13709. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13710. * @param targetPoint the position (must be in same space as current mesh) to look at
  13711. * @param yawCor optional yaw (y-axis) correction in radians
  13712. * @param pitchCor optional pitch (x-axis) correction in radians
  13713. * @param rollCor optional roll (z-axis) correction in radians
  13714. * @param space the choosen space of the target
  13715. * @returns the TransformNode.
  13716. */
  13717. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13718. /**
  13719. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13720. * This Vector3 is expressed in the World space.
  13721. * @param localAxis axis to rotate
  13722. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13723. */
  13724. getDirection(localAxis: Vector3): Vector3;
  13725. /**
  13726. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13727. * localAxis is expressed in the mesh local space.
  13728. * result is computed in the Wordl space from the mesh World matrix.
  13729. * @param localAxis axis to rotate
  13730. * @param result the resulting transformnode
  13731. * @returns this TransformNode.
  13732. */
  13733. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13734. /**
  13735. * Sets this transform node rotation to the given local axis.
  13736. * @param localAxis the axis in local space
  13737. * @param yawCor optional yaw (y-axis) correction in radians
  13738. * @param pitchCor optional pitch (x-axis) correction in radians
  13739. * @param rollCor optional roll (z-axis) correction in radians
  13740. * @returns this TransformNode
  13741. */
  13742. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13743. /**
  13744. * Sets a new pivot point to the current node
  13745. * @param point defines the new pivot point to use
  13746. * @param space defines if the point is in world or local space (local by default)
  13747. * @returns the current TransformNode
  13748. */
  13749. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13750. /**
  13751. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13752. * @returns the pivot point
  13753. */
  13754. getPivotPoint(): Vector3;
  13755. /**
  13756. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13757. * @param result the vector3 to store the result
  13758. * @returns this TransformNode.
  13759. */
  13760. getPivotPointToRef(result: Vector3): TransformNode;
  13761. /**
  13762. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13763. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13764. */
  13765. getAbsolutePivotPoint(): Vector3;
  13766. /**
  13767. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13768. * @param result vector3 to store the result
  13769. * @returns this TransformNode.
  13770. */
  13771. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13772. /**
  13773. * Defines the passed node as the parent of the current node.
  13774. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13775. * @see https://doc.babylonjs.com/how_to/parenting
  13776. * @param node the node ot set as the parent
  13777. * @returns this TransformNode.
  13778. */
  13779. setParent(node: Nullable<Node>): TransformNode;
  13780. private _nonUniformScaling;
  13781. /**
  13782. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13783. */
  13784. get nonUniformScaling(): boolean;
  13785. /** @hidden */
  13786. _updateNonUniformScalingState(value: boolean): boolean;
  13787. /**
  13788. * Attach the current TransformNode to another TransformNode associated with a bone
  13789. * @param bone Bone affecting the TransformNode
  13790. * @param affectedTransformNode TransformNode associated with the bone
  13791. * @returns this object
  13792. */
  13793. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13794. /**
  13795. * Detach the transform node if its associated with a bone
  13796. * @returns this object
  13797. */
  13798. detachFromBone(): TransformNode;
  13799. private static _rotationAxisCache;
  13800. /**
  13801. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13802. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13803. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13804. * The passed axis is also normalized.
  13805. * @param axis the axis to rotate around
  13806. * @param amount the amount to rotate in radians
  13807. * @param space Space to rotate in (Default: local)
  13808. * @returns the TransformNode.
  13809. */
  13810. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13811. /**
  13812. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13813. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13814. * The passed axis is also normalized. .
  13815. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13816. * @param point the point to rotate around
  13817. * @param axis the axis to rotate around
  13818. * @param amount the amount to rotate in radians
  13819. * @returns the TransformNode
  13820. */
  13821. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13822. /**
  13823. * Translates the mesh along the axis vector for the passed distance in the given space.
  13824. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13825. * @param axis the axis to translate in
  13826. * @param distance the distance to translate
  13827. * @param space Space to rotate in (Default: local)
  13828. * @returns the TransformNode.
  13829. */
  13830. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13831. /**
  13832. * Adds a rotation step to the mesh current rotation.
  13833. * x, y, z are Euler angles expressed in radians.
  13834. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13835. * This means this rotation is made in the mesh local space only.
  13836. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13837. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13838. * ```javascript
  13839. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13840. * ```
  13841. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13842. * 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.
  13843. * @param x Rotation to add
  13844. * @param y Rotation to add
  13845. * @param z Rotation to add
  13846. * @returns the TransformNode.
  13847. */
  13848. addRotation(x: number, y: number, z: number): TransformNode;
  13849. /**
  13850. * @hidden
  13851. */
  13852. protected _getEffectiveParent(): Nullable<Node>;
  13853. /**
  13854. * Computes the world matrix of the node
  13855. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13856. * @returns the world matrix
  13857. */
  13858. computeWorldMatrix(force?: boolean): Matrix;
  13859. /**
  13860. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13861. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13862. */
  13863. resetLocalMatrix(independentOfChildren?: boolean): void;
  13864. protected _afterComputeWorldMatrix(): void;
  13865. /**
  13866. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13867. * @param func callback function to add
  13868. *
  13869. * @returns the TransformNode.
  13870. */
  13871. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13872. /**
  13873. * Removes a registered callback function.
  13874. * @param func callback function to remove
  13875. * @returns the TransformNode.
  13876. */
  13877. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13878. /**
  13879. * Gets the position of the current mesh in camera space
  13880. * @param camera defines the camera to use
  13881. * @returns a position
  13882. */
  13883. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13884. /**
  13885. * Returns the distance from the mesh to the active camera
  13886. * @param camera defines the camera to use
  13887. * @returns the distance
  13888. */
  13889. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13890. /**
  13891. * Clone the current transform node
  13892. * @param name Name of the new clone
  13893. * @param newParent New parent for the clone
  13894. * @param doNotCloneChildren Do not clone children hierarchy
  13895. * @returns the new transform node
  13896. */
  13897. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13898. /**
  13899. * Serializes the objects information.
  13900. * @param currentSerializationObject defines the object to serialize in
  13901. * @returns the serialized object
  13902. */
  13903. serialize(currentSerializationObject?: any): any;
  13904. /**
  13905. * Returns a new TransformNode object parsed from the source provided.
  13906. * @param parsedTransformNode is the source.
  13907. * @param scene the scne the object belongs to
  13908. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13909. * @returns a new TransformNode object parsed from the source provided.
  13910. */
  13911. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13912. /**
  13913. * Get all child-transformNodes of this node
  13914. * @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
  13915. * @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
  13916. * @returns an array of TransformNode
  13917. */
  13918. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13919. /**
  13920. * Releases resources associated with this transform node.
  13921. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13922. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13923. */
  13924. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13925. /**
  13926. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13927. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13928. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13929. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13930. * @returns the current mesh
  13931. */
  13932. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13933. private _syncAbsoluteScalingAndRotation;
  13934. }
  13935. }
  13936. declare module BABYLON {
  13937. /**
  13938. * Class used to override all child animations of a given target
  13939. */
  13940. export class AnimationPropertiesOverride {
  13941. /**
  13942. * Gets or sets a value indicating if animation blending must be used
  13943. */
  13944. enableBlending: boolean;
  13945. /**
  13946. * Gets or sets the blending speed to use when enableBlending is true
  13947. */
  13948. blendingSpeed: number;
  13949. /**
  13950. * Gets or sets the default loop mode to use
  13951. */
  13952. loopMode: number;
  13953. }
  13954. }
  13955. declare module BABYLON {
  13956. /**
  13957. * Class used to store bone information
  13958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13959. */
  13960. export class Bone extends Node {
  13961. /**
  13962. * defines the bone name
  13963. */
  13964. name: string;
  13965. private static _tmpVecs;
  13966. private static _tmpQuat;
  13967. private static _tmpMats;
  13968. /**
  13969. * Gets the list of child bones
  13970. */
  13971. children: Bone[];
  13972. /** Gets the animations associated with this bone */
  13973. animations: Animation[];
  13974. /**
  13975. * Gets or sets bone length
  13976. */
  13977. length: number;
  13978. /**
  13979. * @hidden Internal only
  13980. * Set this value to map this bone to a different index in the transform matrices
  13981. * Set this value to -1 to exclude the bone from the transform matrices
  13982. */
  13983. _index: Nullable<number>;
  13984. private _skeleton;
  13985. private _localMatrix;
  13986. private _restPose;
  13987. private _baseMatrix;
  13988. private _absoluteTransform;
  13989. private _invertedAbsoluteTransform;
  13990. private _parent;
  13991. private _scalingDeterminant;
  13992. private _worldTransform;
  13993. private _localScaling;
  13994. private _localRotation;
  13995. private _localPosition;
  13996. private _needToDecompose;
  13997. private _needToCompose;
  13998. /** @hidden */
  13999. _linkedTransformNode: Nullable<TransformNode>;
  14000. /** @hidden */
  14001. _waitingTransformNodeId: Nullable<string>;
  14002. /** @hidden */
  14003. get _matrix(): Matrix;
  14004. /** @hidden */
  14005. set _matrix(value: Matrix);
  14006. /**
  14007. * Create a new bone
  14008. * @param name defines the bone name
  14009. * @param skeleton defines the parent skeleton
  14010. * @param parentBone defines the parent (can be null if the bone is the root)
  14011. * @param localMatrix defines the local matrix
  14012. * @param restPose defines the rest pose matrix
  14013. * @param baseMatrix defines the base matrix
  14014. * @param index defines index of the bone in the hiearchy
  14015. */
  14016. constructor(
  14017. /**
  14018. * defines the bone name
  14019. */
  14020. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14021. /**
  14022. * Gets the current object class name.
  14023. * @return the class name
  14024. */
  14025. getClassName(): string;
  14026. /**
  14027. * Gets the parent skeleton
  14028. * @returns a skeleton
  14029. */
  14030. getSkeleton(): Skeleton;
  14031. /**
  14032. * Gets parent bone
  14033. * @returns a bone or null if the bone is the root of the bone hierarchy
  14034. */
  14035. getParent(): Nullable<Bone>;
  14036. /**
  14037. * Returns an array containing the root bones
  14038. * @returns an array containing the root bones
  14039. */
  14040. getChildren(): Array<Bone>;
  14041. /**
  14042. * Gets the node index in matrix array generated for rendering
  14043. * @returns the node index
  14044. */
  14045. getIndex(): number;
  14046. /**
  14047. * Sets the parent bone
  14048. * @param parent defines the parent (can be null if the bone is the root)
  14049. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14050. */
  14051. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14052. /**
  14053. * Gets the local matrix
  14054. * @returns a matrix
  14055. */
  14056. getLocalMatrix(): Matrix;
  14057. /**
  14058. * Gets the base matrix (initial matrix which remains unchanged)
  14059. * @returns a matrix
  14060. */
  14061. getBaseMatrix(): Matrix;
  14062. /**
  14063. * Gets the rest pose matrix
  14064. * @returns a matrix
  14065. */
  14066. getRestPose(): Matrix;
  14067. /**
  14068. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14069. */
  14070. getWorldMatrix(): Matrix;
  14071. /**
  14072. * Sets the local matrix to rest pose matrix
  14073. */
  14074. returnToRest(): void;
  14075. /**
  14076. * Gets the inverse of the absolute transform matrix.
  14077. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14078. * @returns a matrix
  14079. */
  14080. getInvertedAbsoluteTransform(): Matrix;
  14081. /**
  14082. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14083. * @returns a matrix
  14084. */
  14085. getAbsoluteTransform(): Matrix;
  14086. /**
  14087. * Links with the given transform node.
  14088. * The local matrix of this bone is copied from the transform node every frame.
  14089. * @param transformNode defines the transform node to link to
  14090. */
  14091. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14092. /**
  14093. * Gets the node used to drive the bone's transformation
  14094. * @returns a transform node or null
  14095. */
  14096. getTransformNode(): Nullable<TransformNode>;
  14097. /** Gets or sets current position (in local space) */
  14098. get position(): Vector3;
  14099. set position(newPosition: Vector3);
  14100. /** Gets or sets current rotation (in local space) */
  14101. get rotation(): Vector3;
  14102. set rotation(newRotation: Vector3);
  14103. /** Gets or sets current rotation quaternion (in local space) */
  14104. get rotationQuaternion(): Quaternion;
  14105. set rotationQuaternion(newRotation: Quaternion);
  14106. /** Gets or sets current scaling (in local space) */
  14107. get scaling(): Vector3;
  14108. set scaling(newScaling: Vector3);
  14109. /**
  14110. * Gets the animation properties override
  14111. */
  14112. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14113. private _decompose;
  14114. private _compose;
  14115. /**
  14116. * Update the base and local matrices
  14117. * @param matrix defines the new base or local matrix
  14118. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14119. * @param updateLocalMatrix defines if the local matrix should be updated
  14120. */
  14121. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14122. /** @hidden */
  14123. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14124. /**
  14125. * Flag the bone as dirty (Forcing it to update everything)
  14126. */
  14127. markAsDirty(): void;
  14128. /** @hidden */
  14129. _markAsDirtyAndCompose(): void;
  14130. private _markAsDirtyAndDecompose;
  14131. /**
  14132. * Translate the bone in local or world space
  14133. * @param vec The amount to translate the bone
  14134. * @param space The space that the translation is in
  14135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14136. */
  14137. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14138. /**
  14139. * Set the postion of the bone in local or world space
  14140. * @param position The position to set the bone
  14141. * @param space The space that the position is in
  14142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14143. */
  14144. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14145. /**
  14146. * Set the absolute position of the bone (world space)
  14147. * @param position The position to set the bone
  14148. * @param mesh The mesh that this bone is attached to
  14149. */
  14150. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14151. /**
  14152. * Scale the bone on the x, y and z axes (in local space)
  14153. * @param x The amount to scale the bone on the x axis
  14154. * @param y The amount to scale the bone on the y axis
  14155. * @param z The amount to scale the bone on the z axis
  14156. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14157. */
  14158. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14159. /**
  14160. * Set the bone scaling in local space
  14161. * @param scale defines the scaling vector
  14162. */
  14163. setScale(scale: Vector3): void;
  14164. /**
  14165. * Gets the current scaling in local space
  14166. * @returns the current scaling vector
  14167. */
  14168. getScale(): Vector3;
  14169. /**
  14170. * Gets the current scaling in local space and stores it in a target vector
  14171. * @param result defines the target vector
  14172. */
  14173. getScaleToRef(result: Vector3): void;
  14174. /**
  14175. * Set the yaw, pitch, and roll of the bone in local or world space
  14176. * @param yaw The rotation of the bone on the y axis
  14177. * @param pitch The rotation of the bone on the x axis
  14178. * @param roll The rotation of the bone on the z axis
  14179. * @param space The space that the axes of rotation are in
  14180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14181. */
  14182. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14183. /**
  14184. * Add a rotation to the bone on an axis in local or world space
  14185. * @param axis The axis to rotate the bone on
  14186. * @param amount The amount to rotate the bone
  14187. * @param space The space that the axis is in
  14188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14189. */
  14190. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14191. /**
  14192. * Set the rotation of the bone to a particular axis angle in local or world space
  14193. * @param axis The axis to rotate the bone on
  14194. * @param angle The angle that the bone should be rotated to
  14195. * @param space The space that the axis is in
  14196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14197. */
  14198. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14199. /**
  14200. * Set the euler rotation of the bone in local of world space
  14201. * @param rotation The euler rotation that the bone should be set to
  14202. * @param space The space that the rotation is in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. */
  14205. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14206. /**
  14207. * Set the quaternion rotation of the bone in local of world space
  14208. * @param quat The quaternion rotation that the bone should be set to
  14209. * @param space The space that the rotation is in
  14210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14211. */
  14212. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14213. /**
  14214. * Set the rotation matrix of the bone in local of world space
  14215. * @param rotMat The rotation matrix that the bone should be set to
  14216. * @param space The space that the rotation is in
  14217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14218. */
  14219. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14220. private _rotateWithMatrix;
  14221. private _getNegativeRotationToRef;
  14222. /**
  14223. * Get the position of the bone in local or world space
  14224. * @param space The space that the returned position is in
  14225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14226. * @returns The position of the bone
  14227. */
  14228. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14229. /**
  14230. * Copy the position of the bone to a vector3 in local or world space
  14231. * @param space The space that the returned position is in
  14232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14233. * @param result The vector3 to copy the position to
  14234. */
  14235. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14236. /**
  14237. * Get the absolute position of the bone (world space)
  14238. * @param mesh The mesh that this bone is attached to
  14239. * @returns The absolute position of the bone
  14240. */
  14241. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14242. /**
  14243. * Copy the absolute position of the bone (world space) to the result param
  14244. * @param mesh The mesh that this bone is attached to
  14245. * @param result The vector3 to copy the absolute position to
  14246. */
  14247. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14248. /**
  14249. * Compute the absolute transforms of this bone and its children
  14250. */
  14251. computeAbsoluteTransforms(): void;
  14252. /**
  14253. * Get the world direction from an axis that is in the local space of the bone
  14254. * @param localAxis The local direction that is used to compute the world direction
  14255. * @param mesh The mesh that this bone is attached to
  14256. * @returns The world direction
  14257. */
  14258. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14259. /**
  14260. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14261. * @param localAxis The local direction that is used to compute the world direction
  14262. * @param mesh The mesh that this bone is attached to
  14263. * @param result The vector3 that the world direction will be copied to
  14264. */
  14265. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14266. /**
  14267. * Get the euler rotation of the bone in local or world space
  14268. * @param space The space that the rotation should be in
  14269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14270. * @returns The euler rotation
  14271. */
  14272. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14273. /**
  14274. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14275. * @param space The space that the rotation should be in
  14276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14277. * @param result The vector3 that the rotation should be copied to
  14278. */
  14279. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14280. /**
  14281. * Get the quaternion rotation of the bone in either local or world space
  14282. * @param space The space that the rotation should be in
  14283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14284. * @returns The quaternion rotation
  14285. */
  14286. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14287. /**
  14288. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14289. * @param space The space that the rotation should be in
  14290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14291. * @param result The quaternion that the rotation should be copied to
  14292. */
  14293. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14294. /**
  14295. * Get the rotation matrix of the bone in local or world space
  14296. * @param space The space that the rotation should be in
  14297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14298. * @returns The rotation matrix
  14299. */
  14300. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14301. /**
  14302. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14303. * @param space The space that the rotation should be in
  14304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14305. * @param result The quaternion that the rotation should be copied to
  14306. */
  14307. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14308. /**
  14309. * Get the world position of a point that is in the local space of the bone
  14310. * @param position The local position
  14311. * @param mesh The mesh that this bone is attached to
  14312. * @returns The world position
  14313. */
  14314. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14315. /**
  14316. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14317. * @param position The local position
  14318. * @param mesh The mesh that this bone is attached to
  14319. * @param result The vector3 that the world position should be copied to
  14320. */
  14321. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14322. /**
  14323. * Get the local position of a point that is in world space
  14324. * @param position The world position
  14325. * @param mesh The mesh that this bone is attached to
  14326. * @returns The local position
  14327. */
  14328. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14329. /**
  14330. * Get the local position of a point that is in world space and copy it to the result param
  14331. * @param position The world position
  14332. * @param mesh The mesh that this bone is attached to
  14333. * @param result The vector3 that the local position should be copied to
  14334. */
  14335. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14336. }
  14337. }
  14338. declare module BABYLON {
  14339. /**
  14340. * Defines a runtime animation
  14341. */
  14342. export class RuntimeAnimation {
  14343. private _events;
  14344. /**
  14345. * The current frame of the runtime animation
  14346. */
  14347. private _currentFrame;
  14348. /**
  14349. * The animation used by the runtime animation
  14350. */
  14351. private _animation;
  14352. /**
  14353. * The target of the runtime animation
  14354. */
  14355. private _target;
  14356. /**
  14357. * The initiating animatable
  14358. */
  14359. private _host;
  14360. /**
  14361. * The original value of the runtime animation
  14362. */
  14363. private _originalValue;
  14364. /**
  14365. * The original blend value of the runtime animation
  14366. */
  14367. private _originalBlendValue;
  14368. /**
  14369. * The offsets cache of the runtime animation
  14370. */
  14371. private _offsetsCache;
  14372. /**
  14373. * The high limits cache of the runtime animation
  14374. */
  14375. private _highLimitsCache;
  14376. /**
  14377. * Specifies if the runtime animation has been stopped
  14378. */
  14379. private _stopped;
  14380. /**
  14381. * The blending factor of the runtime animation
  14382. */
  14383. private _blendingFactor;
  14384. /**
  14385. * The BabylonJS scene
  14386. */
  14387. private _scene;
  14388. /**
  14389. * The current value of the runtime animation
  14390. */
  14391. private _currentValue;
  14392. /** @hidden */
  14393. _animationState: _IAnimationState;
  14394. /**
  14395. * The active target of the runtime animation
  14396. */
  14397. private _activeTargets;
  14398. private _currentActiveTarget;
  14399. private _directTarget;
  14400. /**
  14401. * The target path of the runtime animation
  14402. */
  14403. private _targetPath;
  14404. /**
  14405. * The weight of the runtime animation
  14406. */
  14407. private _weight;
  14408. /**
  14409. * The ratio offset of the runtime animation
  14410. */
  14411. private _ratioOffset;
  14412. /**
  14413. * The previous delay of the runtime animation
  14414. */
  14415. private _previousDelay;
  14416. /**
  14417. * The previous ratio of the runtime animation
  14418. */
  14419. private _previousRatio;
  14420. private _enableBlending;
  14421. private _keys;
  14422. private _minFrame;
  14423. private _maxFrame;
  14424. private _minValue;
  14425. private _maxValue;
  14426. private _targetIsArray;
  14427. /**
  14428. * Gets the current frame of the runtime animation
  14429. */
  14430. get currentFrame(): number;
  14431. /**
  14432. * Gets the weight of the runtime animation
  14433. */
  14434. get weight(): number;
  14435. /**
  14436. * Gets the current value of the runtime animation
  14437. */
  14438. get currentValue(): any;
  14439. /**
  14440. * Gets the target path of the runtime animation
  14441. */
  14442. get targetPath(): string;
  14443. /**
  14444. * Gets the actual target of the runtime animation
  14445. */
  14446. get target(): any;
  14447. /** @hidden */
  14448. _onLoop: () => void;
  14449. /**
  14450. * Create a new RuntimeAnimation object
  14451. * @param target defines the target of the animation
  14452. * @param animation defines the source animation object
  14453. * @param scene defines the hosting scene
  14454. * @param host defines the initiating Animatable
  14455. */
  14456. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14457. private _preparePath;
  14458. /**
  14459. * Gets the animation from the runtime animation
  14460. */
  14461. get animation(): Animation;
  14462. /**
  14463. * Resets the runtime animation to the beginning
  14464. * @param restoreOriginal defines whether to restore the target property to the original value
  14465. */
  14466. reset(restoreOriginal?: boolean): void;
  14467. /**
  14468. * Specifies if the runtime animation is stopped
  14469. * @returns Boolean specifying if the runtime animation is stopped
  14470. */
  14471. isStopped(): boolean;
  14472. /**
  14473. * Disposes of the runtime animation
  14474. */
  14475. dispose(): void;
  14476. /**
  14477. * Apply the interpolated value to the target
  14478. * @param currentValue defines the value computed by the animation
  14479. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14480. */
  14481. setValue(currentValue: any, weight: number): void;
  14482. private _getOriginalValues;
  14483. private _setValue;
  14484. /**
  14485. * Gets the loop pmode of the runtime animation
  14486. * @returns Loop Mode
  14487. */
  14488. private _getCorrectLoopMode;
  14489. /**
  14490. * Move the current animation to a given frame
  14491. * @param frame defines the frame to move to
  14492. */
  14493. goToFrame(frame: number): void;
  14494. /**
  14495. * @hidden Internal use only
  14496. */
  14497. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14498. /**
  14499. * Execute the current animation
  14500. * @param delay defines the delay to add to the current frame
  14501. * @param from defines the lower bound of the animation range
  14502. * @param to defines the upper bound of the animation range
  14503. * @param loop defines if the current animation must loop
  14504. * @param speedRatio defines the current speed ratio
  14505. * @param weight defines the weight of the animation (default is -1 so no weight)
  14506. * @param onLoop optional callback called when animation loops
  14507. * @returns a boolean indicating if the animation is running
  14508. */
  14509. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14510. }
  14511. }
  14512. declare module BABYLON {
  14513. /**
  14514. * Class used to store an actual running animation
  14515. */
  14516. export class Animatable {
  14517. /** defines the target object */
  14518. target: any;
  14519. /** defines the starting frame number (default is 0) */
  14520. fromFrame: number;
  14521. /** defines the ending frame number (default is 100) */
  14522. toFrame: number;
  14523. /** defines if the animation must loop (default is false) */
  14524. loopAnimation: boolean;
  14525. /** defines a callback to call when animation ends if it is not looping */
  14526. onAnimationEnd?: (() => void) | null | undefined;
  14527. /** defines a callback to call when animation loops */
  14528. onAnimationLoop?: (() => void) | null | undefined;
  14529. private _localDelayOffset;
  14530. private _pausedDelay;
  14531. private _runtimeAnimations;
  14532. private _paused;
  14533. private _scene;
  14534. private _speedRatio;
  14535. private _weight;
  14536. private _syncRoot;
  14537. /**
  14538. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14539. * This will only apply for non looping animation (default is true)
  14540. */
  14541. disposeOnEnd: boolean;
  14542. /**
  14543. * Gets a boolean indicating if the animation has started
  14544. */
  14545. animationStarted: boolean;
  14546. /**
  14547. * Observer raised when the animation ends
  14548. */
  14549. onAnimationEndObservable: Observable<Animatable>;
  14550. /**
  14551. * Observer raised when the animation loops
  14552. */
  14553. onAnimationLoopObservable: Observable<Animatable>;
  14554. /**
  14555. * Gets the root Animatable used to synchronize and normalize animations
  14556. */
  14557. get syncRoot(): Nullable<Animatable>;
  14558. /**
  14559. * Gets the current frame of the first RuntimeAnimation
  14560. * Used to synchronize Animatables
  14561. */
  14562. get masterFrame(): number;
  14563. /**
  14564. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14565. */
  14566. get weight(): number;
  14567. set weight(value: number);
  14568. /**
  14569. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14570. */
  14571. get speedRatio(): number;
  14572. set speedRatio(value: number);
  14573. /**
  14574. * Creates a new Animatable
  14575. * @param scene defines the hosting scene
  14576. * @param target defines the target object
  14577. * @param fromFrame defines the starting frame number (default is 0)
  14578. * @param toFrame defines the ending frame number (default is 100)
  14579. * @param loopAnimation defines if the animation must loop (default is false)
  14580. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14581. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14582. * @param animations defines a group of animation to add to the new Animatable
  14583. * @param onAnimationLoop defines a callback to call when animation loops
  14584. */
  14585. constructor(scene: Scene,
  14586. /** defines the target object */
  14587. target: any,
  14588. /** defines the starting frame number (default is 0) */
  14589. fromFrame?: number,
  14590. /** defines the ending frame number (default is 100) */
  14591. toFrame?: number,
  14592. /** defines if the animation must loop (default is false) */
  14593. loopAnimation?: boolean, speedRatio?: number,
  14594. /** defines a callback to call when animation ends if it is not looping */
  14595. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14596. /** defines a callback to call when animation loops */
  14597. onAnimationLoop?: (() => void) | null | undefined);
  14598. /**
  14599. * Synchronize and normalize current Animatable with a source Animatable
  14600. * This is useful when using animation weights and when animations are not of the same length
  14601. * @param root defines the root Animatable to synchronize with
  14602. * @returns the current Animatable
  14603. */
  14604. syncWith(root: Animatable): Animatable;
  14605. /**
  14606. * Gets the list of runtime animations
  14607. * @returns an array of RuntimeAnimation
  14608. */
  14609. getAnimations(): RuntimeAnimation[];
  14610. /**
  14611. * Adds more animations to the current animatable
  14612. * @param target defines the target of the animations
  14613. * @param animations defines the new animations to add
  14614. */
  14615. appendAnimations(target: any, animations: Animation[]): void;
  14616. /**
  14617. * Gets the source animation for a specific property
  14618. * @param property defines the propertyu to look for
  14619. * @returns null or the source animation for the given property
  14620. */
  14621. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14622. /**
  14623. * Gets the runtime animation for a specific property
  14624. * @param property defines the propertyu to look for
  14625. * @returns null or the runtime animation for the given property
  14626. */
  14627. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14628. /**
  14629. * Resets the animatable to its original state
  14630. */
  14631. reset(): void;
  14632. /**
  14633. * Allows the animatable to blend with current running animations
  14634. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14635. * @param blendingSpeed defines the blending speed to use
  14636. */
  14637. enableBlending(blendingSpeed: number): void;
  14638. /**
  14639. * Disable animation blending
  14640. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14641. */
  14642. disableBlending(): void;
  14643. /**
  14644. * Jump directly to a given frame
  14645. * @param frame defines the frame to jump to
  14646. */
  14647. goToFrame(frame: number): void;
  14648. /**
  14649. * Pause the animation
  14650. */
  14651. pause(): void;
  14652. /**
  14653. * Restart the animation
  14654. */
  14655. restart(): void;
  14656. private _raiseOnAnimationEnd;
  14657. /**
  14658. * Stop and delete the current animation
  14659. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14660. * @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)
  14661. */
  14662. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14663. /**
  14664. * Wait asynchronously for the animation to end
  14665. * @returns a promise which will be fullfilled when the animation ends
  14666. */
  14667. waitAsync(): Promise<Animatable>;
  14668. /** @hidden */
  14669. _animate(delay: number): boolean;
  14670. }
  14671. interface Scene {
  14672. /** @hidden */
  14673. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14674. /** @hidden */
  14675. _processLateAnimationBindingsForMatrices(holder: {
  14676. totalWeight: number;
  14677. animations: RuntimeAnimation[];
  14678. originalValue: Matrix;
  14679. }): any;
  14680. /** @hidden */
  14681. _processLateAnimationBindingsForQuaternions(holder: {
  14682. totalWeight: number;
  14683. animations: RuntimeAnimation[];
  14684. originalValue: Quaternion;
  14685. }, refQuaternion: Quaternion): Quaternion;
  14686. /** @hidden */
  14687. _processLateAnimationBindings(): void;
  14688. /**
  14689. * Will start the animation sequence of a given target
  14690. * @param target defines the target
  14691. * @param from defines from which frame should animation start
  14692. * @param to defines until which frame should animation run.
  14693. * @param weight defines the weight to apply to the animation (1.0 by default)
  14694. * @param loop defines if the animation loops
  14695. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14696. * @param onAnimationEnd defines the function to be executed when the animation ends
  14697. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14698. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14699. * @param onAnimationLoop defines the callback to call when an animation loops
  14700. * @returns the animatable object created for this animation
  14701. */
  14702. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14703. /**
  14704. * Will start the animation sequence of a given target
  14705. * @param target defines the target
  14706. * @param from defines from which frame should animation start
  14707. * @param to defines until which frame should animation run.
  14708. * @param loop defines if the animation loops
  14709. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14710. * @param onAnimationEnd defines the function to be executed when the animation ends
  14711. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14712. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14713. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14714. * @param onAnimationLoop defines the callback to call when an animation loops
  14715. * @returns the animatable object created for this animation
  14716. */
  14717. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14718. /**
  14719. * Will start the animation sequence of a given target and its hierarchy
  14720. * @param target defines the target
  14721. * @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.
  14722. * @param from defines from which frame should animation start
  14723. * @param to defines until which frame should animation run.
  14724. * @param loop defines if the animation loops
  14725. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14726. * @param onAnimationEnd defines the function to be executed when the animation ends
  14727. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14728. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14729. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14730. * @param onAnimationLoop defines the callback to call when an animation loops
  14731. * @returns the list of created animatables
  14732. */
  14733. 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): Animatable[];
  14734. /**
  14735. * Begin a new animation on a given node
  14736. * @param target defines the target where the animation will take place
  14737. * @param animations defines the list of animations to start
  14738. * @param from defines the initial value
  14739. * @param to defines the final value
  14740. * @param loop defines if you want animation to loop (off by default)
  14741. * @param speedRatio defines the speed ratio to apply to all animations
  14742. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14743. * @param onAnimationLoop defines the callback to call when an animation loops
  14744. * @returns the list of created animatables
  14745. */
  14746. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14747. /**
  14748. * Begin a new animation on a given node and its hierarchy
  14749. * @param target defines the root node where the animation will take place
  14750. * @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.
  14751. * @param animations defines the list of animations to start
  14752. * @param from defines the initial value
  14753. * @param to defines the final value
  14754. * @param loop defines if you want animation to loop (off by default)
  14755. * @param speedRatio defines the speed ratio to apply to all animations
  14756. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14757. * @param onAnimationLoop defines the callback to call when an animation loops
  14758. * @returns the list of animatables created for all nodes
  14759. */
  14760. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14761. /**
  14762. * Gets the animatable associated with a specific target
  14763. * @param target defines the target of the animatable
  14764. * @returns the required animatable if found
  14765. */
  14766. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14767. /**
  14768. * Gets all animatables associated with a given target
  14769. * @param target defines the target to look animatables for
  14770. * @returns an array of Animatables
  14771. */
  14772. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14773. /**
  14774. * Stops and removes all animations that have been applied to the scene
  14775. */
  14776. stopAllAnimations(): void;
  14777. /**
  14778. * Gets the current delta time used by animation engine
  14779. */
  14780. deltaTime: number;
  14781. }
  14782. interface Bone {
  14783. /**
  14784. * Copy an animation range from another bone
  14785. * @param source defines the source bone
  14786. * @param rangeName defines the range name to copy
  14787. * @param frameOffset defines the frame offset
  14788. * @param rescaleAsRequired defines if rescaling must be applied if required
  14789. * @param skelDimensionsRatio defines the scaling ratio
  14790. * @returns true if operation was successful
  14791. */
  14792. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14793. }
  14794. }
  14795. declare module BABYLON {
  14796. /**
  14797. * Class used to handle skinning animations
  14798. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14799. */
  14800. export class Skeleton implements IAnimatable {
  14801. /** defines the skeleton name */
  14802. name: string;
  14803. /** defines the skeleton Id */
  14804. id: string;
  14805. /**
  14806. * Defines the list of child bones
  14807. */
  14808. bones: Bone[];
  14809. /**
  14810. * Defines an estimate of the dimension of the skeleton at rest
  14811. */
  14812. dimensionsAtRest: Vector3;
  14813. /**
  14814. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14815. */
  14816. needInitialSkinMatrix: boolean;
  14817. /**
  14818. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14819. */
  14820. overrideMesh: Nullable<AbstractMesh>;
  14821. /**
  14822. * Gets the list of animations attached to this skeleton
  14823. */
  14824. animations: Array<Animation>;
  14825. private _scene;
  14826. private _isDirty;
  14827. private _transformMatrices;
  14828. private _transformMatrixTexture;
  14829. private _meshesWithPoseMatrix;
  14830. private _animatables;
  14831. private _identity;
  14832. private _synchronizedWithMesh;
  14833. private _ranges;
  14834. private _lastAbsoluteTransformsUpdateId;
  14835. private _canUseTextureForBones;
  14836. private _uniqueId;
  14837. /** @hidden */
  14838. _numBonesWithLinkedTransformNode: number;
  14839. /** @hidden */
  14840. _hasWaitingData: Nullable<boolean>;
  14841. /**
  14842. * Specifies if the skeleton should be serialized
  14843. */
  14844. doNotSerialize: boolean;
  14845. private _useTextureToStoreBoneMatrices;
  14846. /**
  14847. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14848. * Please note that this option is not available if the hardware does not support it
  14849. */
  14850. get useTextureToStoreBoneMatrices(): boolean;
  14851. set useTextureToStoreBoneMatrices(value: boolean);
  14852. private _animationPropertiesOverride;
  14853. /**
  14854. * Gets or sets the animation properties override
  14855. */
  14856. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14857. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14858. /**
  14859. * List of inspectable custom properties (used by the Inspector)
  14860. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14861. */
  14862. inspectableCustomProperties: IInspectable[];
  14863. /**
  14864. * An observable triggered before computing the skeleton's matrices
  14865. */
  14866. onBeforeComputeObservable: Observable<Skeleton>;
  14867. /**
  14868. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14869. */
  14870. get isUsingTextureForMatrices(): boolean;
  14871. /**
  14872. * Gets the unique ID of this skeleton
  14873. */
  14874. get uniqueId(): number;
  14875. /**
  14876. * Creates a new skeleton
  14877. * @param name defines the skeleton name
  14878. * @param id defines the skeleton Id
  14879. * @param scene defines the hosting scene
  14880. */
  14881. constructor(
  14882. /** defines the skeleton name */
  14883. name: string,
  14884. /** defines the skeleton Id */
  14885. id: string, scene: Scene);
  14886. /**
  14887. * Gets the current object class name.
  14888. * @return the class name
  14889. */
  14890. getClassName(): string;
  14891. /**
  14892. * Returns an array containing the root bones
  14893. * @returns an array containing the root bones
  14894. */
  14895. getChildren(): Array<Bone>;
  14896. /**
  14897. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14898. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14899. * @returns a Float32Array containing matrices data
  14900. */
  14901. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14902. /**
  14903. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14904. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14905. * @returns a raw texture containing the data
  14906. */
  14907. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14908. /**
  14909. * Gets the current hosting scene
  14910. * @returns a scene object
  14911. */
  14912. getScene(): Scene;
  14913. /**
  14914. * Gets a string representing the current skeleton data
  14915. * @param fullDetails defines a boolean indicating if we want a verbose version
  14916. * @returns a string representing the current skeleton data
  14917. */
  14918. toString(fullDetails?: boolean): string;
  14919. /**
  14920. * Get bone's index searching by name
  14921. * @param name defines bone's name to search for
  14922. * @return the indice of the bone. Returns -1 if not found
  14923. */
  14924. getBoneIndexByName(name: string): number;
  14925. /**
  14926. * Creater a new animation range
  14927. * @param name defines the name of the range
  14928. * @param from defines the start key
  14929. * @param to defines the end key
  14930. */
  14931. createAnimationRange(name: string, from: number, to: number): void;
  14932. /**
  14933. * Delete a specific animation range
  14934. * @param name defines the name of the range
  14935. * @param deleteFrames defines if frames must be removed as well
  14936. */
  14937. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14938. /**
  14939. * Gets a specific animation range
  14940. * @param name defines the name of the range to look for
  14941. * @returns the requested animation range or null if not found
  14942. */
  14943. getAnimationRange(name: string): Nullable<AnimationRange>;
  14944. /**
  14945. * Gets the list of all animation ranges defined on this skeleton
  14946. * @returns an array
  14947. */
  14948. getAnimationRanges(): Nullable<AnimationRange>[];
  14949. /**
  14950. * Copy animation range from a source skeleton.
  14951. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14952. * @param source defines the source skeleton
  14953. * @param name defines the name of the range to copy
  14954. * @param rescaleAsRequired defines if rescaling must be applied if required
  14955. * @returns true if operation was successful
  14956. */
  14957. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  14958. /**
  14959. * Forces the skeleton to go to rest pose
  14960. */
  14961. returnToRest(): void;
  14962. private _getHighestAnimationFrame;
  14963. /**
  14964. * Begin a specific animation range
  14965. * @param name defines the name of the range to start
  14966. * @param loop defines if looping must be turned on (false by default)
  14967. * @param speedRatio defines the speed ratio to apply (1 by default)
  14968. * @param onAnimationEnd defines a callback which will be called when animation will end
  14969. * @returns a new animatable
  14970. */
  14971. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  14972. /** @hidden */
  14973. _markAsDirty(): void;
  14974. /** @hidden */
  14975. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14976. /** @hidden */
  14977. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14978. private _computeTransformMatrices;
  14979. /**
  14980. * Build all resources required to render a skeleton
  14981. */
  14982. prepare(): void;
  14983. /**
  14984. * Gets the list of animatables currently running for this skeleton
  14985. * @returns an array of animatables
  14986. */
  14987. getAnimatables(): IAnimatable[];
  14988. /**
  14989. * Clone the current skeleton
  14990. * @param name defines the name of the new skeleton
  14991. * @param id defines the id of the new skeleton
  14992. * @returns the new skeleton
  14993. */
  14994. clone(name: string, id?: string): Skeleton;
  14995. /**
  14996. * Enable animation blending for this skeleton
  14997. * @param blendingSpeed defines the blending speed to apply
  14998. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14999. */
  15000. enableBlending(blendingSpeed?: number): void;
  15001. /**
  15002. * Releases all resources associated with the current skeleton
  15003. */
  15004. dispose(): void;
  15005. /**
  15006. * Serialize the skeleton in a JSON object
  15007. * @returns a JSON object
  15008. */
  15009. serialize(): any;
  15010. /**
  15011. * Creates a new skeleton from serialized data
  15012. * @param parsedSkeleton defines the serialized data
  15013. * @param scene defines the hosting scene
  15014. * @returns a new skeleton
  15015. */
  15016. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15017. /**
  15018. * Compute all node absolute transforms
  15019. * @param forceUpdate defines if computation must be done even if cache is up to date
  15020. */
  15021. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15022. /**
  15023. * Gets the root pose matrix
  15024. * @returns a matrix
  15025. */
  15026. getPoseMatrix(): Nullable<Matrix>;
  15027. /**
  15028. * Sorts bones per internal index
  15029. */
  15030. sortBones(): void;
  15031. private _sortBones;
  15032. }
  15033. }
  15034. declare module BABYLON {
  15035. /**
  15036. * Creates an instance based on a source mesh.
  15037. */
  15038. export class InstancedMesh extends AbstractMesh {
  15039. private _sourceMesh;
  15040. private _currentLOD;
  15041. /** @hidden */
  15042. _indexInSourceMeshInstanceArray: number;
  15043. constructor(name: string, source: Mesh);
  15044. /**
  15045. * Returns the string "InstancedMesh".
  15046. */
  15047. getClassName(): string;
  15048. /** Gets the list of lights affecting that mesh */
  15049. get lightSources(): Light[];
  15050. _resyncLightSources(): void;
  15051. _resyncLightSource(light: Light): void;
  15052. _removeLightSource(light: Light, dispose: boolean): void;
  15053. /**
  15054. * If the source mesh receives shadows
  15055. */
  15056. get receiveShadows(): boolean;
  15057. /**
  15058. * The material of the source mesh
  15059. */
  15060. get material(): Nullable<Material>;
  15061. /**
  15062. * Visibility of the source mesh
  15063. */
  15064. get visibility(): number;
  15065. /**
  15066. * Skeleton of the source mesh
  15067. */
  15068. get skeleton(): Nullable<Skeleton>;
  15069. /**
  15070. * Rendering ground id of the source mesh
  15071. */
  15072. get renderingGroupId(): number;
  15073. set renderingGroupId(value: number);
  15074. /**
  15075. * Returns the total number of vertices (integer).
  15076. */
  15077. getTotalVertices(): number;
  15078. /**
  15079. * Returns a positive integer : the total number of indices in this mesh geometry.
  15080. * @returns the numner of indices or zero if the mesh has no geometry.
  15081. */
  15082. getTotalIndices(): number;
  15083. /**
  15084. * The source mesh of the instance
  15085. */
  15086. get sourceMesh(): Mesh;
  15087. /**
  15088. * Is this node ready to be used/rendered
  15089. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15090. * @return {boolean} is it ready
  15091. */
  15092. isReady(completeCheck?: boolean): boolean;
  15093. /**
  15094. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15095. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15096. * @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.
  15097. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15098. */
  15099. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15100. /**
  15101. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15102. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15103. * The `data` are either a numeric array either a Float32Array.
  15104. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15105. * 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).
  15106. * Note that a new underlying VertexBuffer object is created each call.
  15107. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15108. *
  15109. * Possible `kind` values :
  15110. * - VertexBuffer.PositionKind
  15111. * - VertexBuffer.UVKind
  15112. * - VertexBuffer.UV2Kind
  15113. * - VertexBuffer.UV3Kind
  15114. * - VertexBuffer.UV4Kind
  15115. * - VertexBuffer.UV5Kind
  15116. * - VertexBuffer.UV6Kind
  15117. * - VertexBuffer.ColorKind
  15118. * - VertexBuffer.MatricesIndicesKind
  15119. * - VertexBuffer.MatricesIndicesExtraKind
  15120. * - VertexBuffer.MatricesWeightsKind
  15121. * - VertexBuffer.MatricesWeightsExtraKind
  15122. *
  15123. * Returns the Mesh.
  15124. */
  15125. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15126. /**
  15127. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15128. * If the mesh has no geometry, it is simply returned as it is.
  15129. * The `data` are either a numeric array either a Float32Array.
  15130. * No new underlying VertexBuffer object is created.
  15131. * 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.
  15132. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15133. *
  15134. * Possible `kind` values :
  15135. * - VertexBuffer.PositionKind
  15136. * - VertexBuffer.UVKind
  15137. * - VertexBuffer.UV2Kind
  15138. * - VertexBuffer.UV3Kind
  15139. * - VertexBuffer.UV4Kind
  15140. * - VertexBuffer.UV5Kind
  15141. * - VertexBuffer.UV6Kind
  15142. * - VertexBuffer.ColorKind
  15143. * - VertexBuffer.MatricesIndicesKind
  15144. * - VertexBuffer.MatricesIndicesExtraKind
  15145. * - VertexBuffer.MatricesWeightsKind
  15146. * - VertexBuffer.MatricesWeightsExtraKind
  15147. *
  15148. * Returns the Mesh.
  15149. */
  15150. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15151. /**
  15152. * Sets the mesh indices.
  15153. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15154. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15155. * This method creates a new index buffer each call.
  15156. * Returns the Mesh.
  15157. */
  15158. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15159. /**
  15160. * Boolean : True if the mesh owns the requested kind of data.
  15161. */
  15162. isVerticesDataPresent(kind: string): boolean;
  15163. /**
  15164. * Returns an array of indices (IndicesArray).
  15165. */
  15166. getIndices(): Nullable<IndicesArray>;
  15167. get _positions(): Nullable<Vector3[]>;
  15168. /**
  15169. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15170. * This means the mesh underlying bounding box and sphere are recomputed.
  15171. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15172. * @returns the current mesh
  15173. */
  15174. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15175. /** @hidden */
  15176. _preActivate(): InstancedMesh;
  15177. /** @hidden */
  15178. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15179. /** @hidden */
  15180. _postActivate(): void;
  15181. getWorldMatrix(): Matrix;
  15182. get isAnInstance(): boolean;
  15183. /**
  15184. * Returns the current associated LOD AbstractMesh.
  15185. */
  15186. getLOD(camera: Camera): AbstractMesh;
  15187. /** @hidden */
  15188. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15189. /** @hidden */
  15190. _syncSubMeshes(): InstancedMesh;
  15191. /** @hidden */
  15192. _generatePointsArray(): boolean;
  15193. /**
  15194. * Creates a new InstancedMesh from the current mesh.
  15195. * - name (string) : the cloned mesh name
  15196. * - newParent (optional Node) : the optional Node to parent the clone to.
  15197. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15198. *
  15199. * Returns the clone.
  15200. */
  15201. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15202. /**
  15203. * Disposes the InstancedMesh.
  15204. * Returns nothing.
  15205. */
  15206. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15207. }
  15208. interface Mesh {
  15209. /**
  15210. * Register a custom buffer that will be instanced
  15211. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15212. * @param kind defines the buffer kind
  15213. * @param stride defines the stride in floats
  15214. */
  15215. registerInstancedBuffer(kind: string, stride: number): void;
  15216. /** @hidden */
  15217. _userInstancedBuffersStorage: {
  15218. data: {
  15219. [key: string]: Float32Array;
  15220. };
  15221. sizes: {
  15222. [key: string]: number;
  15223. };
  15224. vertexBuffers: {
  15225. [key: string]: Nullable<VertexBuffer>;
  15226. };
  15227. strides: {
  15228. [key: string]: number;
  15229. };
  15230. };
  15231. }
  15232. interface AbstractMesh {
  15233. /**
  15234. * Object used to store instanced buffers defined by user
  15235. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15236. */
  15237. instancedBuffers: {
  15238. [key: string]: any;
  15239. };
  15240. }
  15241. }
  15242. declare module BABYLON {
  15243. /**
  15244. * Defines the options associated with the creation of a shader material.
  15245. */
  15246. export interface IShaderMaterialOptions {
  15247. /**
  15248. * Does the material work in alpha blend mode
  15249. */
  15250. needAlphaBlending: boolean;
  15251. /**
  15252. * Does the material work in alpha test mode
  15253. */
  15254. needAlphaTesting: boolean;
  15255. /**
  15256. * The list of attribute names used in the shader
  15257. */
  15258. attributes: string[];
  15259. /**
  15260. * The list of unifrom names used in the shader
  15261. */
  15262. uniforms: string[];
  15263. /**
  15264. * The list of UBO names used in the shader
  15265. */
  15266. uniformBuffers: string[];
  15267. /**
  15268. * The list of sampler names used in the shader
  15269. */
  15270. samplers: string[];
  15271. /**
  15272. * The list of defines used in the shader
  15273. */
  15274. defines: string[];
  15275. }
  15276. /**
  15277. * 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.
  15278. *
  15279. * This returned material effects how the mesh will look based on the code in the shaders.
  15280. *
  15281. * @see http://doc.babylonjs.com/how_to/shader_material
  15282. */
  15283. export class ShaderMaterial extends Material {
  15284. private _shaderPath;
  15285. private _options;
  15286. private _textures;
  15287. private _textureArrays;
  15288. private _floats;
  15289. private _ints;
  15290. private _floatsArrays;
  15291. private _colors3;
  15292. private _colors3Arrays;
  15293. private _colors4;
  15294. private _colors4Arrays;
  15295. private _vectors2;
  15296. private _vectors3;
  15297. private _vectors4;
  15298. private _matrices;
  15299. private _matrixArrays;
  15300. private _matrices3x3;
  15301. private _matrices2x2;
  15302. private _vectors2Arrays;
  15303. private _vectors3Arrays;
  15304. private _vectors4Arrays;
  15305. private _cachedWorldViewMatrix;
  15306. private _cachedWorldViewProjectionMatrix;
  15307. private _renderId;
  15308. private _multiview;
  15309. /**
  15310. * Instantiate a new shader material.
  15311. * 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.
  15312. * This returned material effects how the mesh will look based on the code in the shaders.
  15313. * @see http://doc.babylonjs.com/how_to/shader_material
  15314. * @param name Define the name of the material in the scene
  15315. * @param scene Define the scene the material belongs to
  15316. * @param shaderPath Defines the route to the shader code in one of three ways:
  15317. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15318. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15319. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15320. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15321. * @param options Define the options used to create the shader
  15322. */
  15323. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15324. /**
  15325. * Gets the shader path used to define the shader code
  15326. * It can be modified to trigger a new compilation
  15327. */
  15328. get shaderPath(): any;
  15329. /**
  15330. * Sets the shader path used to define the shader code
  15331. * It can be modified to trigger a new compilation
  15332. */
  15333. set shaderPath(shaderPath: any);
  15334. /**
  15335. * Gets the options used to compile the shader.
  15336. * They can be modified to trigger a new compilation
  15337. */
  15338. get options(): IShaderMaterialOptions;
  15339. /**
  15340. * Gets the current class name of the material e.g. "ShaderMaterial"
  15341. * Mainly use in serialization.
  15342. * @returns the class name
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Specifies if the material will require alpha blending
  15347. * @returns a boolean specifying if alpha blending is needed
  15348. */
  15349. needAlphaBlending(): boolean;
  15350. /**
  15351. * Specifies if this material should be rendered in alpha test mode
  15352. * @returns a boolean specifying if an alpha test is needed.
  15353. */
  15354. needAlphaTesting(): boolean;
  15355. private _checkUniform;
  15356. /**
  15357. * Set a texture in the shader.
  15358. * @param name Define the name of the uniform samplers as defined in the shader
  15359. * @param texture Define the texture to bind to this sampler
  15360. * @return the material itself allowing "fluent" like uniform updates
  15361. */
  15362. setTexture(name: string, texture: Texture): ShaderMaterial;
  15363. /**
  15364. * Set a texture array in the shader.
  15365. * @param name Define the name of the uniform sampler array as defined in the shader
  15366. * @param textures Define the list of textures to bind to this sampler
  15367. * @return the material itself allowing "fluent" like uniform updates
  15368. */
  15369. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15370. /**
  15371. * Set a float in the shader.
  15372. * @param name Define the name of the uniform as defined in the shader
  15373. * @param value Define the value to give to the uniform
  15374. * @return the material itself allowing "fluent" like uniform updates
  15375. */
  15376. setFloat(name: string, value: number): ShaderMaterial;
  15377. /**
  15378. * Set a int in the shader.
  15379. * @param name Define the name of the uniform as defined in the shader
  15380. * @param value Define the value to give to the uniform
  15381. * @return the material itself allowing "fluent" like uniform updates
  15382. */
  15383. setInt(name: string, value: number): ShaderMaterial;
  15384. /**
  15385. * Set an array of floats in the shader.
  15386. * @param name Define the name of the uniform as defined in the shader
  15387. * @param value Define the value to give to the uniform
  15388. * @return the material itself allowing "fluent" like uniform updates
  15389. */
  15390. setFloats(name: string, value: number[]): ShaderMaterial;
  15391. /**
  15392. * Set a vec3 in the shader from a Color3.
  15393. * @param name Define the name of the uniform as defined in the shader
  15394. * @param value Define the value to give to the uniform
  15395. * @return the material itself allowing "fluent" like uniform updates
  15396. */
  15397. setColor3(name: string, value: Color3): ShaderMaterial;
  15398. /**
  15399. * Set a vec3 array in the shader from a Color3 array.
  15400. * @param name Define the name of the uniform as defined in the shader
  15401. * @param value Define the value to give to the uniform
  15402. * @return the material itself allowing "fluent" like uniform updates
  15403. */
  15404. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15405. /**
  15406. * Set a vec4 in the shader from a Color4.
  15407. * @param name Define the name of the uniform as defined in the shader
  15408. * @param value Define the value to give to the uniform
  15409. * @return the material itself allowing "fluent" like uniform updates
  15410. */
  15411. setColor4(name: string, value: Color4): ShaderMaterial;
  15412. /**
  15413. * Set a vec4 array in the shader from a Color4 array.
  15414. * @param name Define the name of the uniform as defined in the shader
  15415. * @param value Define the value to give to the uniform
  15416. * @return the material itself allowing "fluent" like uniform updates
  15417. */
  15418. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15419. /**
  15420. * Set a vec2 in the shader from a Vector2.
  15421. * @param name Define the name of the uniform as defined in the shader
  15422. * @param value Define the value to give to the uniform
  15423. * @return the material itself allowing "fluent" like uniform updates
  15424. */
  15425. setVector2(name: string, value: Vector2): ShaderMaterial;
  15426. /**
  15427. * Set a vec3 in the shader from a Vector3.
  15428. * @param name Define the name of the uniform as defined in the shader
  15429. * @param value Define the value to give to the uniform
  15430. * @return the material itself allowing "fluent" like uniform updates
  15431. */
  15432. setVector3(name: string, value: Vector3): ShaderMaterial;
  15433. /**
  15434. * Set a vec4 in the shader from a Vector4.
  15435. * @param name Define the name of the uniform as defined in the shader
  15436. * @param value Define the value to give to the uniform
  15437. * @return the material itself allowing "fluent" like uniform updates
  15438. */
  15439. setVector4(name: string, value: Vector4): ShaderMaterial;
  15440. /**
  15441. * Set a mat4 in the shader from a Matrix.
  15442. * @param name Define the name of the uniform as defined in the shader
  15443. * @param value Define the value to give to the uniform
  15444. * @return the material itself allowing "fluent" like uniform updates
  15445. */
  15446. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15447. /**
  15448. * Set a float32Array in the shader from a matrix array.
  15449. * @param name Define the name of the uniform as defined in the shader
  15450. * @param value Define the value to give to the uniform
  15451. * @return the material itself allowing "fluent" like uniform updates
  15452. */
  15453. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15454. /**
  15455. * Set a mat3 in the shader from a Float32Array.
  15456. * @param name Define the name of the uniform as defined in the shader
  15457. * @param value Define the value to give to the uniform
  15458. * @return the material itself allowing "fluent" like uniform updates
  15459. */
  15460. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15461. /**
  15462. * Set a mat2 in the shader from a Float32Array.
  15463. * @param name Define the name of the uniform as defined in the shader
  15464. * @param value Define the value to give to the uniform
  15465. * @return the material itself allowing "fluent" like uniform updates
  15466. */
  15467. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15468. /**
  15469. * Set a vec2 array in the shader from a number array.
  15470. * @param name Define the name of the uniform as defined in the shader
  15471. * @param value Define the value to give to the uniform
  15472. * @return the material itself allowing "fluent" like uniform updates
  15473. */
  15474. setArray2(name: string, value: number[]): ShaderMaterial;
  15475. /**
  15476. * Set a vec3 array in the shader from a number array.
  15477. * @param name Define the name of the uniform as defined in the shader
  15478. * @param value Define the value to give to the uniform
  15479. * @return the material itself allowing "fluent" like uniform updates
  15480. */
  15481. setArray3(name: string, value: number[]): ShaderMaterial;
  15482. /**
  15483. * Set a vec4 array in the shader from a number array.
  15484. * @param name Define the name of the uniform as defined in the shader
  15485. * @param value Define the value to give to the uniform
  15486. * @return the material itself allowing "fluent" like uniform updates
  15487. */
  15488. setArray4(name: string, value: number[]): ShaderMaterial;
  15489. private _checkCache;
  15490. /**
  15491. * Specifies that the submesh is ready to be used
  15492. * @param mesh defines the mesh to check
  15493. * @param subMesh defines which submesh to check
  15494. * @param useInstances specifies that instances should be used
  15495. * @returns a boolean indicating that the submesh is ready or not
  15496. */
  15497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15498. /**
  15499. * Checks if the material is ready to render the requested mesh
  15500. * @param mesh Define the mesh to render
  15501. * @param useInstances Define whether or not the material is used with instances
  15502. * @returns true if ready, otherwise false
  15503. */
  15504. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15505. /**
  15506. * Binds the world matrix to the material
  15507. * @param world defines the world transformation matrix
  15508. */
  15509. bindOnlyWorldMatrix(world: Matrix): void;
  15510. /**
  15511. * Binds the material to the mesh
  15512. * @param world defines the world transformation matrix
  15513. * @param mesh defines the mesh to bind the material to
  15514. */
  15515. bind(world: Matrix, mesh?: Mesh): void;
  15516. /**
  15517. * Gets the active textures from the material
  15518. * @returns an array of textures
  15519. */
  15520. getActiveTextures(): BaseTexture[];
  15521. /**
  15522. * Specifies if the material uses a texture
  15523. * @param texture defines the texture to check against the material
  15524. * @returns a boolean specifying if the material uses the texture
  15525. */
  15526. hasTexture(texture: BaseTexture): boolean;
  15527. /**
  15528. * Makes a duplicate of the material, and gives it a new name
  15529. * @param name defines the new name for the duplicated material
  15530. * @returns the cloned material
  15531. */
  15532. clone(name: string): ShaderMaterial;
  15533. /**
  15534. * Disposes the material
  15535. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15536. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15537. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15538. */
  15539. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15540. /**
  15541. * Serializes this material in a JSON representation
  15542. * @returns the serialized material object
  15543. */
  15544. serialize(): any;
  15545. /**
  15546. * Creates a shader material from parsed shader material data
  15547. * @param source defines the JSON represnetation of the material
  15548. * @param scene defines the hosting scene
  15549. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15550. * @returns a new material
  15551. */
  15552. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15553. }
  15554. }
  15555. declare module BABYLON {
  15556. /** @hidden */
  15557. export var colorPixelShader: {
  15558. name: string;
  15559. shader: string;
  15560. };
  15561. }
  15562. declare module BABYLON {
  15563. /** @hidden */
  15564. export var colorVertexShader: {
  15565. name: string;
  15566. shader: string;
  15567. };
  15568. }
  15569. declare module BABYLON {
  15570. /**
  15571. * Line mesh
  15572. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15573. */
  15574. export class LinesMesh extends Mesh {
  15575. /**
  15576. * If vertex color should be applied to the mesh
  15577. */
  15578. readonly useVertexColor?: boolean | undefined;
  15579. /**
  15580. * If vertex alpha should be applied to the mesh
  15581. */
  15582. readonly useVertexAlpha?: boolean | undefined;
  15583. /**
  15584. * Color of the line (Default: White)
  15585. */
  15586. color: Color3;
  15587. /**
  15588. * Alpha of the line (Default: 1)
  15589. */
  15590. alpha: number;
  15591. /**
  15592. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15593. * This margin is expressed in world space coordinates, so its value may vary.
  15594. * Default value is 0.1
  15595. */
  15596. intersectionThreshold: number;
  15597. private _colorShader;
  15598. private color4;
  15599. /**
  15600. * Creates a new LinesMesh
  15601. * @param name defines the name
  15602. * @param scene defines the hosting scene
  15603. * @param parent defines the parent mesh if any
  15604. * @param source defines the optional source LinesMesh used to clone data from
  15605. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15606. * When false, achieved by calling a clone(), also passing False.
  15607. * This will make creation of children, recursive.
  15608. * @param useVertexColor defines if this LinesMesh supports vertex color
  15609. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15610. */
  15611. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15612. /**
  15613. * If vertex color should be applied to the mesh
  15614. */
  15615. useVertexColor?: boolean | undefined,
  15616. /**
  15617. * If vertex alpha should be applied to the mesh
  15618. */
  15619. useVertexAlpha?: boolean | undefined);
  15620. private _addClipPlaneDefine;
  15621. private _removeClipPlaneDefine;
  15622. isReady(): boolean;
  15623. /**
  15624. * Returns the string "LineMesh"
  15625. */
  15626. getClassName(): string;
  15627. /**
  15628. * @hidden
  15629. */
  15630. get material(): Material;
  15631. /**
  15632. * @hidden
  15633. */
  15634. set material(value: Material);
  15635. /**
  15636. * @hidden
  15637. */
  15638. get checkCollisions(): boolean;
  15639. /** @hidden */
  15640. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15641. /** @hidden */
  15642. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15643. /**
  15644. * Disposes of the line mesh
  15645. * @param doNotRecurse If children should be disposed
  15646. */
  15647. dispose(doNotRecurse?: boolean): void;
  15648. /**
  15649. * Returns a new LineMesh object cloned from the current one.
  15650. */
  15651. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15652. /**
  15653. * Creates a new InstancedLinesMesh object from the mesh model.
  15654. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15655. * @param name defines the name of the new instance
  15656. * @returns a new InstancedLinesMesh
  15657. */
  15658. createInstance(name: string): InstancedLinesMesh;
  15659. }
  15660. /**
  15661. * Creates an instance based on a source LinesMesh
  15662. */
  15663. export class InstancedLinesMesh extends InstancedMesh {
  15664. /**
  15665. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15666. * This margin is expressed in world space coordinates, so its value may vary.
  15667. * Initilized with the intersectionThreshold value of the source LinesMesh
  15668. */
  15669. intersectionThreshold: number;
  15670. constructor(name: string, source: LinesMesh);
  15671. /**
  15672. * Returns the string "InstancedLinesMesh".
  15673. */
  15674. getClassName(): string;
  15675. }
  15676. }
  15677. declare module BABYLON {
  15678. /** @hidden */
  15679. export var linePixelShader: {
  15680. name: string;
  15681. shader: string;
  15682. };
  15683. }
  15684. declare module BABYLON {
  15685. /** @hidden */
  15686. export var lineVertexShader: {
  15687. name: string;
  15688. shader: string;
  15689. };
  15690. }
  15691. declare module BABYLON {
  15692. interface AbstractMesh {
  15693. /**
  15694. * Gets the edgesRenderer associated with the mesh
  15695. */
  15696. edgesRenderer: Nullable<EdgesRenderer>;
  15697. }
  15698. interface LinesMesh {
  15699. /**
  15700. * Enables the edge rendering mode on the mesh.
  15701. * This mode makes the mesh edges visible
  15702. * @param epsilon defines the maximal distance between two angles to detect a face
  15703. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15704. * @returns the currentAbstractMesh
  15705. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15706. */
  15707. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15708. }
  15709. interface InstancedLinesMesh {
  15710. /**
  15711. * Enables the edge rendering mode on the mesh.
  15712. * This mode makes the mesh edges visible
  15713. * @param epsilon defines the maximal distance between two angles to detect a face
  15714. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15715. * @returns the current InstancedLinesMesh
  15716. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15717. */
  15718. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15719. }
  15720. /**
  15721. * Defines the minimum contract an Edges renderer should follow.
  15722. */
  15723. export interface IEdgesRenderer extends IDisposable {
  15724. /**
  15725. * Gets or sets a boolean indicating if the edgesRenderer is active
  15726. */
  15727. isEnabled: boolean;
  15728. /**
  15729. * Renders the edges of the attached mesh,
  15730. */
  15731. render(): void;
  15732. /**
  15733. * Checks wether or not the edges renderer is ready to render.
  15734. * @return true if ready, otherwise false.
  15735. */
  15736. isReady(): boolean;
  15737. }
  15738. /**
  15739. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15740. */
  15741. export class EdgesRenderer implements IEdgesRenderer {
  15742. /**
  15743. * Define the size of the edges with an orthographic camera
  15744. */
  15745. edgesWidthScalerForOrthographic: number;
  15746. /**
  15747. * Define the size of the edges with a perspective camera
  15748. */
  15749. edgesWidthScalerForPerspective: number;
  15750. protected _source: AbstractMesh;
  15751. protected _linesPositions: number[];
  15752. protected _linesNormals: number[];
  15753. protected _linesIndices: number[];
  15754. protected _epsilon: number;
  15755. protected _indicesCount: number;
  15756. protected _lineShader: ShaderMaterial;
  15757. protected _ib: DataBuffer;
  15758. protected _buffers: {
  15759. [key: string]: Nullable<VertexBuffer>;
  15760. };
  15761. protected _checkVerticesInsteadOfIndices: boolean;
  15762. private _meshRebuildObserver;
  15763. private _meshDisposeObserver;
  15764. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15765. isEnabled: boolean;
  15766. /**
  15767. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15768. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15769. * @param source Mesh used to create edges
  15770. * @param epsilon sum of angles in adjacency to check for edge
  15771. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15772. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15773. */
  15774. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15775. protected _prepareRessources(): void;
  15776. /** @hidden */
  15777. _rebuild(): void;
  15778. /**
  15779. * Releases the required resources for the edges renderer
  15780. */
  15781. dispose(): void;
  15782. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15783. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15784. /**
  15785. * Checks if the pair of p0 and p1 is en edge
  15786. * @param faceIndex
  15787. * @param edge
  15788. * @param faceNormals
  15789. * @param p0
  15790. * @param p1
  15791. * @private
  15792. */
  15793. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15794. /**
  15795. * push line into the position, normal and index buffer
  15796. * @protected
  15797. */
  15798. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15799. /**
  15800. * Generates lines edges from adjacencjes
  15801. * @private
  15802. */
  15803. _generateEdgesLines(): void;
  15804. /**
  15805. * Checks wether or not the edges renderer is ready to render.
  15806. * @return true if ready, otherwise false.
  15807. */
  15808. isReady(): boolean;
  15809. /**
  15810. * Renders the edges of the attached mesh,
  15811. */
  15812. render(): void;
  15813. }
  15814. /**
  15815. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15816. */
  15817. export class LineEdgesRenderer extends EdgesRenderer {
  15818. /**
  15819. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15820. * @param source LineMesh used to generate edges
  15821. * @param epsilon not important (specified angle for edge detection)
  15822. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15823. */
  15824. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15825. /**
  15826. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15827. */
  15828. _generateEdgesLines(): void;
  15829. }
  15830. }
  15831. declare module BABYLON {
  15832. /**
  15833. * This represents the object necessary to create a rendering group.
  15834. * This is exclusively used and created by the rendering manager.
  15835. * To modify the behavior, you use the available helpers in your scene or meshes.
  15836. * @hidden
  15837. */
  15838. export class RenderingGroup {
  15839. index: number;
  15840. private static _zeroVector;
  15841. private _scene;
  15842. private _opaqueSubMeshes;
  15843. private _transparentSubMeshes;
  15844. private _alphaTestSubMeshes;
  15845. private _depthOnlySubMeshes;
  15846. private _particleSystems;
  15847. private _spriteManagers;
  15848. private _opaqueSortCompareFn;
  15849. private _alphaTestSortCompareFn;
  15850. private _transparentSortCompareFn;
  15851. private _renderOpaque;
  15852. private _renderAlphaTest;
  15853. private _renderTransparent;
  15854. /** @hidden */
  15855. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15856. onBeforeTransparentRendering: () => void;
  15857. /**
  15858. * Set the opaque sort comparison function.
  15859. * If null the sub meshes will be render in the order they were created
  15860. */
  15861. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15862. /**
  15863. * Set the alpha test sort comparison function.
  15864. * If null the sub meshes will be render in the order they were created
  15865. */
  15866. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15867. /**
  15868. * Set the transparent sort comparison function.
  15869. * If null the sub meshes will be render in the order they were created
  15870. */
  15871. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15872. /**
  15873. * Creates a new rendering group.
  15874. * @param index The rendering group index
  15875. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15876. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15877. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15878. */
  15879. 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>);
  15880. /**
  15881. * Render all the sub meshes contained in the group.
  15882. * @param customRenderFunction Used to override the default render behaviour of the group.
  15883. * @returns true if rendered some submeshes.
  15884. */
  15885. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15886. /**
  15887. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15888. * @param subMeshes The submeshes to render
  15889. */
  15890. private renderOpaqueSorted;
  15891. /**
  15892. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15893. * @param subMeshes The submeshes to render
  15894. */
  15895. private renderAlphaTestSorted;
  15896. /**
  15897. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15898. * @param subMeshes The submeshes to render
  15899. */
  15900. private renderTransparentSorted;
  15901. /**
  15902. * Renders the submeshes in a specified order.
  15903. * @param subMeshes The submeshes to sort before render
  15904. * @param sortCompareFn The comparison function use to sort
  15905. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15906. * @param transparent Specifies to activate blending if true
  15907. */
  15908. private static renderSorted;
  15909. /**
  15910. * Renders the submeshes in the order they were dispatched (no sort applied).
  15911. * @param subMeshes The submeshes to render
  15912. */
  15913. private static renderUnsorted;
  15914. /**
  15915. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15916. * are rendered back to front if in the same alpha index.
  15917. *
  15918. * @param a The first submesh
  15919. * @param b The second submesh
  15920. * @returns The result of the comparison
  15921. */
  15922. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15923. /**
  15924. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15925. * are rendered back to front.
  15926. *
  15927. * @param a The first submesh
  15928. * @param b The second submesh
  15929. * @returns The result of the comparison
  15930. */
  15931. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15932. /**
  15933. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15934. * are rendered front to back (prevent overdraw).
  15935. *
  15936. * @param a The first submesh
  15937. * @param b The second submesh
  15938. * @returns The result of the comparison
  15939. */
  15940. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15941. /**
  15942. * Resets the different lists of submeshes to prepare a new frame.
  15943. */
  15944. prepare(): void;
  15945. dispose(): void;
  15946. /**
  15947. * Inserts the submesh in its correct queue depending on its material.
  15948. * @param subMesh The submesh to dispatch
  15949. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15950. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15951. */
  15952. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15953. dispatchSprites(spriteManager: ISpriteManager): void;
  15954. dispatchParticles(particleSystem: IParticleSystem): void;
  15955. private _renderParticles;
  15956. private _renderSprites;
  15957. }
  15958. }
  15959. declare module BABYLON {
  15960. /**
  15961. * Interface describing the different options available in the rendering manager
  15962. * regarding Auto Clear between groups.
  15963. */
  15964. export interface IRenderingManagerAutoClearSetup {
  15965. /**
  15966. * Defines whether or not autoclear is enable.
  15967. */
  15968. autoClear: boolean;
  15969. /**
  15970. * Defines whether or not to autoclear the depth buffer.
  15971. */
  15972. depth: boolean;
  15973. /**
  15974. * Defines whether or not to autoclear the stencil buffer.
  15975. */
  15976. stencil: boolean;
  15977. }
  15978. /**
  15979. * This class is used by the onRenderingGroupObservable
  15980. */
  15981. export class RenderingGroupInfo {
  15982. /**
  15983. * The Scene that being rendered
  15984. */
  15985. scene: Scene;
  15986. /**
  15987. * The camera currently used for the rendering pass
  15988. */
  15989. camera: Nullable<Camera>;
  15990. /**
  15991. * The ID of the renderingGroup being processed
  15992. */
  15993. renderingGroupId: number;
  15994. }
  15995. /**
  15996. * This is the manager responsible of all the rendering for meshes sprites and particles.
  15997. * It is enable to manage the different groups as well as the different necessary sort functions.
  15998. * This should not be used directly aside of the few static configurations
  15999. */
  16000. export class RenderingManager {
  16001. /**
  16002. * The max id used for rendering groups (not included)
  16003. */
  16004. static MAX_RENDERINGGROUPS: number;
  16005. /**
  16006. * The min id used for rendering groups (included)
  16007. */
  16008. static MIN_RENDERINGGROUPS: number;
  16009. /**
  16010. * Used to globally prevent autoclearing scenes.
  16011. */
  16012. static AUTOCLEAR: boolean;
  16013. /**
  16014. * @hidden
  16015. */
  16016. _useSceneAutoClearSetup: boolean;
  16017. private _scene;
  16018. private _renderingGroups;
  16019. private _depthStencilBufferAlreadyCleaned;
  16020. private _autoClearDepthStencil;
  16021. private _customOpaqueSortCompareFn;
  16022. private _customAlphaTestSortCompareFn;
  16023. private _customTransparentSortCompareFn;
  16024. private _renderingGroupInfo;
  16025. /**
  16026. * Instantiates a new rendering group for a particular scene
  16027. * @param scene Defines the scene the groups belongs to
  16028. */
  16029. constructor(scene: Scene);
  16030. private _clearDepthStencilBuffer;
  16031. /**
  16032. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16033. * @hidden
  16034. */
  16035. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16036. /**
  16037. * Resets the different information of the group to prepare a new frame
  16038. * @hidden
  16039. */
  16040. reset(): void;
  16041. /**
  16042. * Dispose and release the group and its associated resources.
  16043. * @hidden
  16044. */
  16045. dispose(): void;
  16046. /**
  16047. * Clear the info related to rendering groups preventing retention points during dispose.
  16048. */
  16049. freeRenderingGroups(): void;
  16050. private _prepareRenderingGroup;
  16051. /**
  16052. * Add a sprite manager to the rendering manager in order to render it this frame.
  16053. * @param spriteManager Define the sprite manager to render
  16054. */
  16055. dispatchSprites(spriteManager: ISpriteManager): void;
  16056. /**
  16057. * Add a particle system to the rendering manager in order to render it this frame.
  16058. * @param particleSystem Define the particle system to render
  16059. */
  16060. dispatchParticles(particleSystem: IParticleSystem): void;
  16061. /**
  16062. * Add a submesh to the manager in order to render it this frame
  16063. * @param subMesh The submesh to dispatch
  16064. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16065. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16066. */
  16067. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16068. /**
  16069. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16070. * This allowed control for front to back rendering or reversly depending of the special needs.
  16071. *
  16072. * @param renderingGroupId The rendering group id corresponding to its index
  16073. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16074. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16075. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16076. */
  16077. 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;
  16078. /**
  16079. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16080. *
  16081. * @param renderingGroupId The rendering group id corresponding to its index
  16082. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16083. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16084. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16085. */
  16086. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16087. /**
  16088. * Gets the current auto clear configuration for one rendering group of the rendering
  16089. * manager.
  16090. * @param index the rendering group index to get the information for
  16091. * @returns The auto clear setup for the requested rendering group
  16092. */
  16093. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16094. }
  16095. }
  16096. declare module BABYLON {
  16097. /**
  16098. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16099. */
  16100. export interface ICustomShaderOptions {
  16101. /**
  16102. * Gets or sets the custom shader name to use
  16103. */
  16104. shaderName: string;
  16105. /**
  16106. * The list of attribute names used in the shader
  16107. */
  16108. attributes?: string[];
  16109. /**
  16110. * The list of unifrom names used in the shader
  16111. */
  16112. uniforms?: string[];
  16113. /**
  16114. * The list of sampler names used in the shader
  16115. */
  16116. samplers?: string[];
  16117. /**
  16118. * The list of defines used in the shader
  16119. */
  16120. defines?: string[];
  16121. }
  16122. /**
  16123. * Interface to implement to create a shadow generator compatible with BJS.
  16124. */
  16125. export interface IShadowGenerator {
  16126. /**
  16127. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16128. * @returns The render target texture if present otherwise, null
  16129. */
  16130. getShadowMap(): Nullable<RenderTargetTexture>;
  16131. /**
  16132. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16133. * @param subMesh The submesh we want to render in the shadow map
  16134. * @param useInstances Defines wether will draw in the map using instances
  16135. * @returns true if ready otherwise, false
  16136. */
  16137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16138. /**
  16139. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16140. * @param defines Defines of the material we want to update
  16141. * @param lightIndex Index of the light in the enabled light list of the material
  16142. */
  16143. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16144. /**
  16145. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16146. * defined in the generator but impacting the effect).
  16147. * It implies the unifroms available on the materials are the standard BJS ones.
  16148. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16149. * @param effect The effect we are binfing the information for
  16150. */
  16151. bindShadowLight(lightIndex: string, effect: Effect): void;
  16152. /**
  16153. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16154. * (eq to shadow prjection matrix * light transform matrix)
  16155. * @returns The transform matrix used to create the shadow map
  16156. */
  16157. getTransformMatrix(): Matrix;
  16158. /**
  16159. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16160. * Cube and 2D textures for instance.
  16161. */
  16162. recreateShadowMap(): void;
  16163. /**
  16164. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16165. * @param onCompiled Callback triggered at the and of the effects compilation
  16166. * @param options Sets of optional options forcing the compilation with different modes
  16167. */
  16168. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16169. useInstances: boolean;
  16170. }>): void;
  16171. /**
  16172. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16173. * @param options Sets of optional options forcing the compilation with different modes
  16174. * @returns A promise that resolves when the compilation completes
  16175. */
  16176. forceCompilationAsync(options?: Partial<{
  16177. useInstances: boolean;
  16178. }>): Promise<void>;
  16179. /**
  16180. * Serializes the shadow generator setup to a json object.
  16181. * @returns The serialized JSON object
  16182. */
  16183. serialize(): any;
  16184. /**
  16185. * Disposes the Shadow map and related Textures and effects.
  16186. */
  16187. dispose(): void;
  16188. }
  16189. /**
  16190. * Default implementation IShadowGenerator.
  16191. * This is the main object responsible of generating shadows in the framework.
  16192. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16193. */
  16194. export class ShadowGenerator implements IShadowGenerator {
  16195. /**
  16196. * Name of the shadow generator class
  16197. */
  16198. static CLASSNAME: string;
  16199. /**
  16200. * Shadow generator mode None: no filtering applied.
  16201. */
  16202. static readonly FILTER_NONE: number;
  16203. /**
  16204. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16205. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16206. */
  16207. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16208. /**
  16209. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16210. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16211. */
  16212. static readonly FILTER_POISSONSAMPLING: number;
  16213. /**
  16214. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16215. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16216. */
  16217. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16218. /**
  16219. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16220. * edge artifacts on steep falloff.
  16221. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16222. */
  16223. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16224. /**
  16225. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16226. * edge artifacts on steep falloff.
  16227. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16228. */
  16229. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16230. /**
  16231. * Shadow generator mode PCF: Percentage Closer Filtering
  16232. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16233. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16234. */
  16235. static readonly FILTER_PCF: number;
  16236. /**
  16237. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16238. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16239. * Contact Hardening
  16240. */
  16241. static readonly FILTER_PCSS: number;
  16242. /**
  16243. * Reserved for PCF and PCSS
  16244. * Highest Quality.
  16245. *
  16246. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16247. *
  16248. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16249. */
  16250. static readonly QUALITY_HIGH: number;
  16251. /**
  16252. * Reserved for PCF and PCSS
  16253. * Good tradeoff for quality/perf cross devices
  16254. *
  16255. * Execute PCF on a 3*3 kernel.
  16256. *
  16257. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16258. */
  16259. static readonly QUALITY_MEDIUM: number;
  16260. /**
  16261. * Reserved for PCF and PCSS
  16262. * The lowest quality but the fastest.
  16263. *
  16264. * Execute PCF on a 1*1 kernel.
  16265. *
  16266. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16267. */
  16268. static readonly QUALITY_LOW: number;
  16269. /** Gets or sets the custom shader name to use */
  16270. customShaderOptions: ICustomShaderOptions;
  16271. /**
  16272. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16273. */
  16274. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16275. /**
  16276. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16277. */
  16278. onAfterShadowMapRenderObservable: Observable<Effect>;
  16279. /**
  16280. * Observable triggered before a mesh is rendered in the shadow map.
  16281. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16282. */
  16283. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16284. /**
  16285. * Observable triggered after a mesh is rendered in the shadow map.
  16286. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16287. */
  16288. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16289. protected _bias: number;
  16290. /**
  16291. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16292. */
  16293. get bias(): number;
  16294. /**
  16295. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16296. */
  16297. set bias(bias: number);
  16298. protected _normalBias: number;
  16299. /**
  16300. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16301. */
  16302. get normalBias(): number;
  16303. /**
  16304. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16305. */
  16306. set normalBias(normalBias: number);
  16307. protected _blurBoxOffset: number;
  16308. /**
  16309. * Gets the blur box offset: offset applied during the blur pass.
  16310. * Only useful if useKernelBlur = false
  16311. */
  16312. get blurBoxOffset(): number;
  16313. /**
  16314. * Sets the blur box offset: offset applied during the blur pass.
  16315. * Only useful if useKernelBlur = false
  16316. */
  16317. set blurBoxOffset(value: number);
  16318. protected _blurScale: number;
  16319. /**
  16320. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16321. * 2 means half of the size.
  16322. */
  16323. get blurScale(): number;
  16324. /**
  16325. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16326. * 2 means half of the size.
  16327. */
  16328. set blurScale(value: number);
  16329. protected _blurKernel: number;
  16330. /**
  16331. * Gets the blur kernel: kernel size of the blur pass.
  16332. * Only useful if useKernelBlur = true
  16333. */
  16334. get blurKernel(): number;
  16335. /**
  16336. * Sets the blur kernel: kernel size of the blur pass.
  16337. * Only useful if useKernelBlur = true
  16338. */
  16339. set blurKernel(value: number);
  16340. protected _useKernelBlur: boolean;
  16341. /**
  16342. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16343. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16344. */
  16345. get useKernelBlur(): boolean;
  16346. /**
  16347. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16348. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16349. */
  16350. set useKernelBlur(value: boolean);
  16351. protected _depthScale: number;
  16352. /**
  16353. * Gets the depth scale used in ESM mode.
  16354. */
  16355. get depthScale(): number;
  16356. /**
  16357. * Sets the depth scale used in ESM mode.
  16358. * This can override the scale stored on the light.
  16359. */
  16360. set depthScale(value: number);
  16361. protected _validateFilter(filter: number): number;
  16362. protected _filter: number;
  16363. /**
  16364. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16365. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16366. */
  16367. get filter(): number;
  16368. /**
  16369. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16370. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16371. */
  16372. set filter(value: number);
  16373. /**
  16374. * Gets if the current filter is set to Poisson Sampling.
  16375. */
  16376. get usePoissonSampling(): boolean;
  16377. /**
  16378. * Sets the current filter to Poisson Sampling.
  16379. */
  16380. set usePoissonSampling(value: boolean);
  16381. /**
  16382. * Gets if the current filter is set to ESM.
  16383. */
  16384. get useExponentialShadowMap(): boolean;
  16385. /**
  16386. * Sets the current filter is to ESM.
  16387. */
  16388. set useExponentialShadowMap(value: boolean);
  16389. /**
  16390. * Gets if the current filter is set to filtered ESM.
  16391. */
  16392. get useBlurExponentialShadowMap(): boolean;
  16393. /**
  16394. * Gets if the current filter is set to filtered ESM.
  16395. */
  16396. set useBlurExponentialShadowMap(value: boolean);
  16397. /**
  16398. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16399. * exponential to prevent steep falloff artifacts).
  16400. */
  16401. get useCloseExponentialShadowMap(): boolean;
  16402. /**
  16403. * Sets the current filter to "close ESM" (using the inverse of the
  16404. * exponential to prevent steep falloff artifacts).
  16405. */
  16406. set useCloseExponentialShadowMap(value: boolean);
  16407. /**
  16408. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16409. * exponential to prevent steep falloff artifacts).
  16410. */
  16411. get useBlurCloseExponentialShadowMap(): boolean;
  16412. /**
  16413. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16414. * exponential to prevent steep falloff artifacts).
  16415. */
  16416. set useBlurCloseExponentialShadowMap(value: boolean);
  16417. /**
  16418. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16419. */
  16420. get usePercentageCloserFiltering(): boolean;
  16421. /**
  16422. * Sets the current filter to "PCF" (percentage closer filtering).
  16423. */
  16424. set usePercentageCloserFiltering(value: boolean);
  16425. protected _filteringQuality: number;
  16426. /**
  16427. * Gets the PCF or PCSS Quality.
  16428. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16429. */
  16430. get filteringQuality(): number;
  16431. /**
  16432. * Sets the PCF or PCSS Quality.
  16433. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16434. */
  16435. set filteringQuality(filteringQuality: number);
  16436. /**
  16437. * Gets if the current filter is set to "PCSS" (contact hardening).
  16438. */
  16439. get useContactHardeningShadow(): boolean;
  16440. /**
  16441. * Sets the current filter to "PCSS" (contact hardening).
  16442. */
  16443. set useContactHardeningShadow(value: boolean);
  16444. protected _contactHardeningLightSizeUVRatio: number;
  16445. /**
  16446. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16447. * Using a ratio helps keeping shape stability independently of the map size.
  16448. *
  16449. * It does not account for the light projection as it was having too much
  16450. * instability during the light setup or during light position changes.
  16451. *
  16452. * Only valid if useContactHardeningShadow is true.
  16453. */
  16454. get contactHardeningLightSizeUVRatio(): number;
  16455. /**
  16456. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16457. * Using a ratio helps keeping shape stability independently of the map size.
  16458. *
  16459. * It does not account for the light projection as it was having too much
  16460. * instability during the light setup or during light position changes.
  16461. *
  16462. * Only valid if useContactHardeningShadow is true.
  16463. */
  16464. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16465. protected _darkness: number;
  16466. /** Gets or sets the actual darkness of a shadow */
  16467. get darkness(): number;
  16468. set darkness(value: number);
  16469. /**
  16470. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16471. * 0 means strongest and 1 would means no shadow.
  16472. * @returns the darkness.
  16473. */
  16474. getDarkness(): number;
  16475. /**
  16476. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16477. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16478. * @returns the shadow generator allowing fluent coding.
  16479. */
  16480. setDarkness(darkness: number): ShadowGenerator;
  16481. protected _transparencyShadow: boolean;
  16482. /** Gets or sets the ability to have transparent shadow */
  16483. get transparencyShadow(): boolean;
  16484. set transparencyShadow(value: boolean);
  16485. /**
  16486. * Sets the ability to have transparent shadow (boolean).
  16487. * @param transparent True if transparent else False
  16488. * @returns the shadow generator allowing fluent coding
  16489. */
  16490. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16491. protected _shadowMap: Nullable<RenderTargetTexture>;
  16492. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16493. /**
  16494. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16495. * @returns The render target texture if present otherwise, null
  16496. */
  16497. getShadowMap(): Nullable<RenderTargetTexture>;
  16498. /**
  16499. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16500. * @returns The render target texture if the shadow map is present otherwise, null
  16501. */
  16502. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16503. /**
  16504. * Gets the class name of that object
  16505. * @returns "ShadowGenerator"
  16506. */
  16507. getClassName(): string;
  16508. /**
  16509. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16510. * @param mesh Mesh to add
  16511. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16512. * @returns the Shadow Generator itself
  16513. */
  16514. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16515. /**
  16516. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16517. * @param mesh Mesh to remove
  16518. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16519. * @returns the Shadow Generator itself
  16520. */
  16521. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16522. /**
  16523. * Controls the extent to which the shadows fade out at the edge of the frustum
  16524. */
  16525. frustumEdgeFalloff: number;
  16526. protected _light: IShadowLight;
  16527. /**
  16528. * Returns the associated light object.
  16529. * @returns the light generating the shadow
  16530. */
  16531. getLight(): IShadowLight;
  16532. /**
  16533. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16534. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16535. * It might on the other hand introduce peter panning.
  16536. */
  16537. forceBackFacesOnly: boolean;
  16538. protected _scene: Scene;
  16539. protected _lightDirection: Vector3;
  16540. protected _effect: Effect;
  16541. protected _viewMatrix: Matrix;
  16542. protected _projectionMatrix: Matrix;
  16543. protected _transformMatrix: Matrix;
  16544. protected _cachedPosition: Vector3;
  16545. protected _cachedDirection: Vector3;
  16546. protected _cachedDefines: string;
  16547. protected _currentRenderID: number;
  16548. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16549. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16550. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16551. protected _blurPostProcesses: PostProcess[];
  16552. protected _mapSize: number;
  16553. protected _currentFaceIndex: number;
  16554. protected _currentFaceIndexCache: number;
  16555. protected _textureType: number;
  16556. protected _defaultTextureMatrix: Matrix;
  16557. protected _storedUniqueId: Nullable<number>;
  16558. /** @hidden */
  16559. static _SceneComponentInitialization: (scene: Scene) => void;
  16560. /**
  16561. * Creates a ShadowGenerator object.
  16562. * A ShadowGenerator is the required tool to use the shadows.
  16563. * Each light casting shadows needs to use its own ShadowGenerator.
  16564. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16565. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16566. * @param light The light object generating the shadows.
  16567. * @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.
  16568. */
  16569. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16570. protected _initializeGenerator(): void;
  16571. protected _createTargetRenderTexture(): void;
  16572. protected _initializeShadowMap(): void;
  16573. protected _initializeBlurRTTAndPostProcesses(): void;
  16574. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16575. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16576. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16577. protected _applyFilterValues(): void;
  16578. /**
  16579. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16580. * @param onCompiled Callback triggered at the and of the effects compilation
  16581. * @param options Sets of optional options forcing the compilation with different modes
  16582. */
  16583. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16584. useInstances: boolean;
  16585. }>): void;
  16586. /**
  16587. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16588. * @param options Sets of optional options forcing the compilation with different modes
  16589. * @returns A promise that resolves when the compilation completes
  16590. */
  16591. forceCompilationAsync(options?: Partial<{
  16592. useInstances: boolean;
  16593. }>): Promise<void>;
  16594. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16595. /**
  16596. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16597. * @param subMesh The submesh we want to render in the shadow map
  16598. * @param useInstances Defines wether will draw in the map using instances
  16599. * @returns true if ready otherwise, false
  16600. */
  16601. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16602. /**
  16603. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16604. * @param defines Defines of the material we want to update
  16605. * @param lightIndex Index of the light in the enabled light list of the material
  16606. */
  16607. prepareDefines(defines: any, lightIndex: number): void;
  16608. /**
  16609. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16610. * defined in the generator but impacting the effect).
  16611. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16612. * @param effect The effect we are binfing the information for
  16613. */
  16614. bindShadowLight(lightIndex: string, effect: Effect): void;
  16615. /**
  16616. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16617. * (eq to shadow prjection matrix * light transform matrix)
  16618. * @returns The transform matrix used to create the shadow map
  16619. */
  16620. getTransformMatrix(): Matrix;
  16621. /**
  16622. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16623. * Cube and 2D textures for instance.
  16624. */
  16625. recreateShadowMap(): void;
  16626. protected _disposeBlurPostProcesses(): void;
  16627. protected _disposeRTTandPostProcesses(): void;
  16628. /**
  16629. * Disposes the ShadowGenerator.
  16630. * Returns nothing.
  16631. */
  16632. dispose(): void;
  16633. /**
  16634. * Serializes the shadow generator setup to a json object.
  16635. * @returns The serialized JSON object
  16636. */
  16637. serialize(): any;
  16638. /**
  16639. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16640. * @param parsedShadowGenerator The JSON object to parse
  16641. * @param scene The scene to create the shadow map for
  16642. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16643. * @returns The parsed shadow generator
  16644. */
  16645. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16646. }
  16647. }
  16648. declare module BABYLON {
  16649. /**
  16650. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16651. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16652. * 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.
  16653. */
  16654. export abstract class Light extends Node {
  16655. /**
  16656. * Falloff Default: light is falling off following the material specification:
  16657. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16658. */
  16659. static readonly FALLOFF_DEFAULT: number;
  16660. /**
  16661. * Falloff Physical: light is falling off following the inverse squared distance law.
  16662. */
  16663. static readonly FALLOFF_PHYSICAL: number;
  16664. /**
  16665. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16666. * to enhance interoperability with other engines.
  16667. */
  16668. static readonly FALLOFF_GLTF: number;
  16669. /**
  16670. * Falloff Standard: light is falling off like in the standard material
  16671. * to enhance interoperability with other materials.
  16672. */
  16673. static readonly FALLOFF_STANDARD: number;
  16674. /**
  16675. * If every light affecting the material is in this lightmapMode,
  16676. * material.lightmapTexture adds or multiplies
  16677. * (depends on material.useLightmapAsShadowmap)
  16678. * after every other light calculations.
  16679. */
  16680. static readonly LIGHTMAP_DEFAULT: number;
  16681. /**
  16682. * material.lightmapTexture as only diffuse lighting from this light
  16683. * adds only specular lighting from this light
  16684. * adds dynamic shadows
  16685. */
  16686. static readonly LIGHTMAP_SPECULAR: number;
  16687. /**
  16688. * material.lightmapTexture as only lighting
  16689. * no light calculation from this light
  16690. * only adds dynamic shadows from this light
  16691. */
  16692. static readonly LIGHTMAP_SHADOWSONLY: number;
  16693. /**
  16694. * Each light type uses the default quantity according to its type:
  16695. * point/spot lights use luminous intensity
  16696. * directional lights use illuminance
  16697. */
  16698. static readonly INTENSITYMODE_AUTOMATIC: number;
  16699. /**
  16700. * lumen (lm)
  16701. */
  16702. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16703. /**
  16704. * candela (lm/sr)
  16705. */
  16706. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16707. /**
  16708. * lux (lm/m^2)
  16709. */
  16710. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16711. /**
  16712. * nit (cd/m^2)
  16713. */
  16714. static readonly INTENSITYMODE_LUMINANCE: number;
  16715. /**
  16716. * Light type const id of the point light.
  16717. */
  16718. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16719. /**
  16720. * Light type const id of the directional light.
  16721. */
  16722. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16723. /**
  16724. * Light type const id of the spot light.
  16725. */
  16726. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16727. /**
  16728. * Light type const id of the hemispheric light.
  16729. */
  16730. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16731. /**
  16732. * Diffuse gives the basic color to an object.
  16733. */
  16734. diffuse: Color3;
  16735. /**
  16736. * Specular produces a highlight color on an object.
  16737. * Note: This is note affecting PBR materials.
  16738. */
  16739. specular: Color3;
  16740. /**
  16741. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16742. * falling off base on range or angle.
  16743. * This can be set to any values in Light.FALLOFF_x.
  16744. *
  16745. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16746. * other types of materials.
  16747. */
  16748. falloffType: number;
  16749. /**
  16750. * Strength of the light.
  16751. * Note: By default it is define in the framework own unit.
  16752. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16753. */
  16754. intensity: number;
  16755. private _range;
  16756. protected _inverseSquaredRange: number;
  16757. /**
  16758. * Defines how far from the source the light is impacting in scene units.
  16759. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16760. */
  16761. get range(): number;
  16762. /**
  16763. * Defines how far from the source the light is impacting in scene units.
  16764. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16765. */
  16766. set range(value: number);
  16767. /**
  16768. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16769. * of light.
  16770. */
  16771. private _photometricScale;
  16772. private _intensityMode;
  16773. /**
  16774. * Gets the photometric scale used to interpret the intensity.
  16775. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16776. */
  16777. get intensityMode(): number;
  16778. /**
  16779. * Sets the photometric scale used to interpret the intensity.
  16780. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16781. */
  16782. set intensityMode(value: number);
  16783. private _radius;
  16784. /**
  16785. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16786. */
  16787. get radius(): number;
  16788. /**
  16789. * sets the light radius used by PBR Materials to simulate soft area lights.
  16790. */
  16791. set radius(value: number);
  16792. private _renderPriority;
  16793. /**
  16794. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16795. * exceeding the number allowed of the materials.
  16796. */
  16797. renderPriority: number;
  16798. private _shadowEnabled;
  16799. /**
  16800. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16801. * the current shadow generator.
  16802. */
  16803. get shadowEnabled(): boolean;
  16804. /**
  16805. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16806. * the current shadow generator.
  16807. */
  16808. set shadowEnabled(value: boolean);
  16809. private _includedOnlyMeshes;
  16810. /**
  16811. * Gets the only meshes impacted by this light.
  16812. */
  16813. get includedOnlyMeshes(): AbstractMesh[];
  16814. /**
  16815. * Sets the only meshes impacted by this light.
  16816. */
  16817. set includedOnlyMeshes(value: AbstractMesh[]);
  16818. private _excludedMeshes;
  16819. /**
  16820. * Gets the meshes not impacted by this light.
  16821. */
  16822. get excludedMeshes(): AbstractMesh[];
  16823. /**
  16824. * Sets the meshes not impacted by this light.
  16825. */
  16826. set excludedMeshes(value: AbstractMesh[]);
  16827. private _excludeWithLayerMask;
  16828. /**
  16829. * Gets the layer id use to find what meshes are not impacted by the light.
  16830. * Inactive if 0
  16831. */
  16832. get excludeWithLayerMask(): number;
  16833. /**
  16834. * Sets the layer id use to find what meshes are not impacted by the light.
  16835. * Inactive if 0
  16836. */
  16837. set excludeWithLayerMask(value: number);
  16838. private _includeOnlyWithLayerMask;
  16839. /**
  16840. * Gets the layer id use to find what meshes are impacted by the light.
  16841. * Inactive if 0
  16842. */
  16843. get includeOnlyWithLayerMask(): number;
  16844. /**
  16845. * Sets the layer id use to find what meshes are impacted by the light.
  16846. * Inactive if 0
  16847. */
  16848. set includeOnlyWithLayerMask(value: number);
  16849. private _lightmapMode;
  16850. /**
  16851. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16852. */
  16853. get lightmapMode(): number;
  16854. /**
  16855. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16856. */
  16857. set lightmapMode(value: number);
  16858. /**
  16859. * Shadow generator associted to the light.
  16860. * @hidden Internal use only.
  16861. */
  16862. _shadowGenerator: Nullable<IShadowGenerator>;
  16863. /**
  16864. * @hidden Internal use only.
  16865. */
  16866. _excludedMeshesIds: string[];
  16867. /**
  16868. * @hidden Internal use only.
  16869. */
  16870. _includedOnlyMeshesIds: string[];
  16871. /**
  16872. * The current light unifom buffer.
  16873. * @hidden Internal use only.
  16874. */
  16875. _uniformBuffer: UniformBuffer;
  16876. /** @hidden */
  16877. _renderId: number;
  16878. /**
  16879. * Creates a Light object in the scene.
  16880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16881. * @param name The firendly name of the light
  16882. * @param scene The scene the light belongs too
  16883. */
  16884. constructor(name: string, scene: Scene);
  16885. protected abstract _buildUniformLayout(): void;
  16886. /**
  16887. * Sets the passed Effect "effect" with the Light information.
  16888. * @param effect The effect to update
  16889. * @param lightIndex The index of the light in the effect to update
  16890. * @returns The light
  16891. */
  16892. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16893. /**
  16894. * Sets the passed Effect "effect" with the Light textures.
  16895. * @param effect The effect to update
  16896. * @param lightIndex The index of the light in the effect to update
  16897. * @returns The light
  16898. */
  16899. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16900. /**
  16901. * Binds the lights information from the scene to the effect for the given mesh.
  16902. * @param lightIndex Light index
  16903. * @param scene The scene where the light belongs to
  16904. * @param effect The effect we are binding the data to
  16905. * @param useSpecular Defines if specular is supported
  16906. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16907. */
  16908. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16909. /**
  16910. * Sets the passed Effect "effect" with the Light information.
  16911. * @param effect The effect to update
  16912. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16913. * @returns The light
  16914. */
  16915. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16916. /**
  16917. * Returns the string "Light".
  16918. * @returns the class name
  16919. */
  16920. getClassName(): string;
  16921. /** @hidden */
  16922. readonly _isLight: boolean;
  16923. /**
  16924. * Converts the light information to a readable string for debug purpose.
  16925. * @param fullDetails Supports for multiple levels of logging within scene loading
  16926. * @returns the human readable light info
  16927. */
  16928. toString(fullDetails?: boolean): string;
  16929. /** @hidden */
  16930. protected _syncParentEnabledState(): void;
  16931. /**
  16932. * Set the enabled state of this node.
  16933. * @param value - the new enabled state
  16934. */
  16935. setEnabled(value: boolean): void;
  16936. /**
  16937. * Returns the Light associated shadow generator if any.
  16938. * @return the associated shadow generator.
  16939. */
  16940. getShadowGenerator(): Nullable<IShadowGenerator>;
  16941. /**
  16942. * Returns a Vector3, the absolute light position in the World.
  16943. * @returns the world space position of the light
  16944. */
  16945. getAbsolutePosition(): Vector3;
  16946. /**
  16947. * Specifies if the light will affect the passed mesh.
  16948. * @param mesh The mesh to test against the light
  16949. * @return true the mesh is affected otherwise, false.
  16950. */
  16951. canAffectMesh(mesh: AbstractMesh): boolean;
  16952. /**
  16953. * Sort function to order lights for rendering.
  16954. * @param a First Light object to compare to second.
  16955. * @param b Second Light object to compare first.
  16956. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16957. */
  16958. static CompareLightsPriority(a: Light, b: Light): number;
  16959. /**
  16960. * Releases resources associated with this node.
  16961. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16962. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16963. */
  16964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16965. /**
  16966. * Returns the light type ID (integer).
  16967. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16968. */
  16969. getTypeID(): number;
  16970. /**
  16971. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16972. * @returns the scaled intensity in intensity mode unit
  16973. */
  16974. getScaledIntensity(): number;
  16975. /**
  16976. * Returns a new Light object, named "name", from the current one.
  16977. * @param name The name of the cloned light
  16978. * @returns the new created light
  16979. */
  16980. clone(name: string): Nullable<Light>;
  16981. /**
  16982. * Serializes the current light into a Serialization object.
  16983. * @returns the serialized object.
  16984. */
  16985. serialize(): any;
  16986. /**
  16987. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16988. * This new light is named "name" and added to the passed scene.
  16989. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16990. * @param name The friendly name of the light
  16991. * @param scene The scene the new light will belong to
  16992. * @returns the constructor function
  16993. */
  16994. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16995. /**
  16996. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16997. * @param parsedLight The JSON representation of the light
  16998. * @param scene The scene to create the parsed light in
  16999. * @returns the created light after parsing
  17000. */
  17001. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17002. private _hookArrayForExcluded;
  17003. private _hookArrayForIncludedOnly;
  17004. private _resyncMeshes;
  17005. /**
  17006. * Forces the meshes to update their light related information in their rendering used effects
  17007. * @hidden Internal Use Only
  17008. */
  17009. _markMeshesAsLightDirty(): void;
  17010. /**
  17011. * Recomputes the cached photometric scale if needed.
  17012. */
  17013. private _computePhotometricScale;
  17014. /**
  17015. * Returns the Photometric Scale according to the light type and intensity mode.
  17016. */
  17017. private _getPhotometricScale;
  17018. /**
  17019. * Reorder the light in the scene according to their defined priority.
  17020. * @hidden Internal Use Only
  17021. */
  17022. _reorderLightsInScene(): void;
  17023. /**
  17024. * Prepares the list of defines specific to the light type.
  17025. * @param defines the list of defines
  17026. * @param lightIndex defines the index of the light for the effect
  17027. */
  17028. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17029. }
  17030. }
  17031. declare module BABYLON {
  17032. /**
  17033. * Interface used to define Action
  17034. */
  17035. export interface IAction {
  17036. /**
  17037. * Trigger for the action
  17038. */
  17039. trigger: number;
  17040. /** Options of the trigger */
  17041. triggerOptions: any;
  17042. /**
  17043. * Gets the trigger parameters
  17044. * @returns the trigger parameters
  17045. */
  17046. getTriggerParameter(): any;
  17047. /**
  17048. * Internal only - executes current action event
  17049. * @hidden
  17050. */
  17051. _executeCurrent(evt?: ActionEvent): void;
  17052. /**
  17053. * Serialize placeholder for child classes
  17054. * @param parent of child
  17055. * @returns the serialized object
  17056. */
  17057. serialize(parent: any): any;
  17058. /**
  17059. * Internal only
  17060. * @hidden
  17061. */
  17062. _prepare(): void;
  17063. /**
  17064. * Internal only - manager for action
  17065. * @hidden
  17066. */
  17067. _actionManager: AbstractActionManager;
  17068. /**
  17069. * Adds action to chain of actions, may be a DoNothingAction
  17070. * @param action defines the next action to execute
  17071. * @returns The action passed in
  17072. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17073. */
  17074. then(action: IAction): IAction;
  17075. }
  17076. /**
  17077. * The action to be carried out following a trigger
  17078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17079. */
  17080. export class Action implements IAction {
  17081. /** the trigger, with or without parameters, for the action */
  17082. triggerOptions: any;
  17083. /**
  17084. * Trigger for the action
  17085. */
  17086. trigger: number;
  17087. /**
  17088. * Internal only - manager for action
  17089. * @hidden
  17090. */
  17091. _actionManager: ActionManager;
  17092. private _nextActiveAction;
  17093. private _child;
  17094. private _condition?;
  17095. private _triggerParameter;
  17096. /**
  17097. * An event triggered prior to action being executed.
  17098. */
  17099. onBeforeExecuteObservable: Observable<Action>;
  17100. /**
  17101. * Creates a new Action
  17102. * @param triggerOptions the trigger, with or without parameters, for the action
  17103. * @param condition an optional determinant of action
  17104. */
  17105. constructor(
  17106. /** the trigger, with or without parameters, for the action */
  17107. triggerOptions: any, condition?: Condition);
  17108. /**
  17109. * Internal only
  17110. * @hidden
  17111. */
  17112. _prepare(): void;
  17113. /**
  17114. * Gets the trigger parameters
  17115. * @returns the trigger parameters
  17116. */
  17117. getTriggerParameter(): any;
  17118. /**
  17119. * Internal only - executes current action event
  17120. * @hidden
  17121. */
  17122. _executeCurrent(evt?: ActionEvent): void;
  17123. /**
  17124. * Execute placeholder for child classes
  17125. * @param evt optional action event
  17126. */
  17127. execute(evt?: ActionEvent): void;
  17128. /**
  17129. * Skips to next active action
  17130. */
  17131. skipToNextActiveAction(): void;
  17132. /**
  17133. * Adds action to chain of actions, may be a DoNothingAction
  17134. * @param action defines the next action to execute
  17135. * @returns The action passed in
  17136. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17137. */
  17138. then(action: Action): Action;
  17139. /**
  17140. * Internal only
  17141. * @hidden
  17142. */
  17143. _getProperty(propertyPath: string): string;
  17144. /**
  17145. * Internal only
  17146. * @hidden
  17147. */
  17148. _getEffectiveTarget(target: any, propertyPath: string): any;
  17149. /**
  17150. * Serialize placeholder for child classes
  17151. * @param parent of child
  17152. * @returns the serialized object
  17153. */
  17154. serialize(parent: any): any;
  17155. /**
  17156. * Internal only called by serialize
  17157. * @hidden
  17158. */
  17159. protected _serialize(serializedAction: any, parent?: any): any;
  17160. /**
  17161. * Internal only
  17162. * @hidden
  17163. */
  17164. static _SerializeValueAsString: (value: any) => string;
  17165. /**
  17166. * Internal only
  17167. * @hidden
  17168. */
  17169. static _GetTargetProperty: (target: Node | Scene) => {
  17170. name: string;
  17171. targetType: string;
  17172. value: string;
  17173. };
  17174. }
  17175. }
  17176. declare module BABYLON {
  17177. /**
  17178. * A Condition applied to an Action
  17179. */
  17180. export class Condition {
  17181. /**
  17182. * Internal only - manager for action
  17183. * @hidden
  17184. */
  17185. _actionManager: ActionManager;
  17186. /**
  17187. * Internal only
  17188. * @hidden
  17189. */
  17190. _evaluationId: number;
  17191. /**
  17192. * Internal only
  17193. * @hidden
  17194. */
  17195. _currentResult: boolean;
  17196. /**
  17197. * Creates a new Condition
  17198. * @param actionManager the manager of the action the condition is applied to
  17199. */
  17200. constructor(actionManager: ActionManager);
  17201. /**
  17202. * Check if the current condition is valid
  17203. * @returns a boolean
  17204. */
  17205. isValid(): boolean;
  17206. /**
  17207. * Internal only
  17208. * @hidden
  17209. */
  17210. _getProperty(propertyPath: string): string;
  17211. /**
  17212. * Internal only
  17213. * @hidden
  17214. */
  17215. _getEffectiveTarget(target: any, propertyPath: string): any;
  17216. /**
  17217. * Serialize placeholder for child classes
  17218. * @returns the serialized object
  17219. */
  17220. serialize(): any;
  17221. /**
  17222. * Internal only
  17223. * @hidden
  17224. */
  17225. protected _serialize(serializedCondition: any): any;
  17226. }
  17227. /**
  17228. * Defines specific conditional operators as extensions of Condition
  17229. */
  17230. export class ValueCondition extends Condition {
  17231. /** path to specify the property of the target the conditional operator uses */
  17232. propertyPath: string;
  17233. /** the value compared by the conditional operator against the current value of the property */
  17234. value: any;
  17235. /** the conditional operator, default ValueCondition.IsEqual */
  17236. operator: number;
  17237. /**
  17238. * Internal only
  17239. * @hidden
  17240. */
  17241. private static _IsEqual;
  17242. /**
  17243. * Internal only
  17244. * @hidden
  17245. */
  17246. private static _IsDifferent;
  17247. /**
  17248. * Internal only
  17249. * @hidden
  17250. */
  17251. private static _IsGreater;
  17252. /**
  17253. * Internal only
  17254. * @hidden
  17255. */
  17256. private static _IsLesser;
  17257. /**
  17258. * returns the number for IsEqual
  17259. */
  17260. static get IsEqual(): number;
  17261. /**
  17262. * Returns the number for IsDifferent
  17263. */
  17264. static get IsDifferent(): number;
  17265. /**
  17266. * Returns the number for IsGreater
  17267. */
  17268. static get IsGreater(): number;
  17269. /**
  17270. * Returns the number for IsLesser
  17271. */
  17272. static get IsLesser(): number;
  17273. /**
  17274. * Internal only The action manager for the condition
  17275. * @hidden
  17276. */
  17277. _actionManager: ActionManager;
  17278. /**
  17279. * Internal only
  17280. * @hidden
  17281. */
  17282. private _target;
  17283. /**
  17284. * Internal only
  17285. * @hidden
  17286. */
  17287. private _effectiveTarget;
  17288. /**
  17289. * Internal only
  17290. * @hidden
  17291. */
  17292. private _property;
  17293. /**
  17294. * Creates a new ValueCondition
  17295. * @param actionManager manager for the action the condition applies to
  17296. * @param target for the action
  17297. * @param propertyPath path to specify the property of the target the conditional operator uses
  17298. * @param value the value compared by the conditional operator against the current value of the property
  17299. * @param operator the conditional operator, default ValueCondition.IsEqual
  17300. */
  17301. constructor(actionManager: ActionManager, target: any,
  17302. /** path to specify the property of the target the conditional operator uses */
  17303. propertyPath: string,
  17304. /** the value compared by the conditional operator against the current value of the property */
  17305. value: any,
  17306. /** the conditional operator, default ValueCondition.IsEqual */
  17307. operator?: number);
  17308. /**
  17309. * Compares the given value with the property value for the specified conditional operator
  17310. * @returns the result of the comparison
  17311. */
  17312. isValid(): boolean;
  17313. /**
  17314. * Serialize the ValueCondition into a JSON compatible object
  17315. * @returns serialization object
  17316. */
  17317. serialize(): any;
  17318. /**
  17319. * Gets the name of the conditional operator for the ValueCondition
  17320. * @param operator the conditional operator
  17321. * @returns the name
  17322. */
  17323. static GetOperatorName(operator: number): string;
  17324. }
  17325. /**
  17326. * Defines a predicate condition as an extension of Condition
  17327. */
  17328. export class PredicateCondition extends Condition {
  17329. /** defines the predicate function used to validate the condition */
  17330. predicate: () => boolean;
  17331. /**
  17332. * Internal only - manager for action
  17333. * @hidden
  17334. */
  17335. _actionManager: ActionManager;
  17336. /**
  17337. * Creates a new PredicateCondition
  17338. * @param actionManager manager for the action the condition applies to
  17339. * @param predicate defines the predicate function used to validate the condition
  17340. */
  17341. constructor(actionManager: ActionManager,
  17342. /** defines the predicate function used to validate the condition */
  17343. predicate: () => boolean);
  17344. /**
  17345. * @returns the validity of the predicate condition
  17346. */
  17347. isValid(): boolean;
  17348. }
  17349. /**
  17350. * Defines a state condition as an extension of Condition
  17351. */
  17352. export class StateCondition extends Condition {
  17353. /** Value to compare with target state */
  17354. value: string;
  17355. /**
  17356. * Internal only - manager for action
  17357. * @hidden
  17358. */
  17359. _actionManager: ActionManager;
  17360. /**
  17361. * Internal only
  17362. * @hidden
  17363. */
  17364. private _target;
  17365. /**
  17366. * Creates a new StateCondition
  17367. * @param actionManager manager for the action the condition applies to
  17368. * @param target of the condition
  17369. * @param value to compare with target state
  17370. */
  17371. constructor(actionManager: ActionManager, target: any,
  17372. /** Value to compare with target state */
  17373. value: string);
  17374. /**
  17375. * Gets a boolean indicating if the current condition is met
  17376. * @returns the validity of the state
  17377. */
  17378. isValid(): boolean;
  17379. /**
  17380. * Serialize the StateCondition into a JSON compatible object
  17381. * @returns serialization object
  17382. */
  17383. serialize(): any;
  17384. }
  17385. }
  17386. declare module BABYLON {
  17387. /**
  17388. * This defines an action responsible to toggle a boolean once triggered.
  17389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17390. */
  17391. export class SwitchBooleanAction extends Action {
  17392. /**
  17393. * The path to the boolean property in the target object
  17394. */
  17395. propertyPath: string;
  17396. private _target;
  17397. private _effectiveTarget;
  17398. private _property;
  17399. /**
  17400. * Instantiate the action
  17401. * @param triggerOptions defines the trigger options
  17402. * @param target defines the object containing the boolean
  17403. * @param propertyPath defines the path to the boolean property in the target object
  17404. * @param condition defines the trigger related conditions
  17405. */
  17406. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17407. /** @hidden */
  17408. _prepare(): void;
  17409. /**
  17410. * Execute the action toggle the boolean value.
  17411. */
  17412. execute(): void;
  17413. /**
  17414. * Serializes the actions and its related information.
  17415. * @param parent defines the object to serialize in
  17416. * @returns the serialized object
  17417. */
  17418. serialize(parent: any): any;
  17419. }
  17420. /**
  17421. * This defines an action responsible to set a the state field of the target
  17422. * to a desired value once triggered.
  17423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17424. */
  17425. export class SetStateAction extends Action {
  17426. /**
  17427. * The value to store in the state field.
  17428. */
  17429. value: string;
  17430. private _target;
  17431. /**
  17432. * Instantiate the action
  17433. * @param triggerOptions defines the trigger options
  17434. * @param target defines the object containing the state property
  17435. * @param value defines the value to store in the state field
  17436. * @param condition defines the trigger related conditions
  17437. */
  17438. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17439. /**
  17440. * Execute the action and store the value on the target state property.
  17441. */
  17442. execute(): void;
  17443. /**
  17444. * Serializes the actions and its related information.
  17445. * @param parent defines the object to serialize in
  17446. * @returns the serialized object
  17447. */
  17448. serialize(parent: any): any;
  17449. }
  17450. /**
  17451. * This defines an action responsible to set a property of the target
  17452. * to a desired value once triggered.
  17453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17454. */
  17455. export class SetValueAction extends Action {
  17456. /**
  17457. * The path of the property to set in the target.
  17458. */
  17459. propertyPath: string;
  17460. /**
  17461. * The value to set in the property
  17462. */
  17463. value: any;
  17464. private _target;
  17465. private _effectiveTarget;
  17466. private _property;
  17467. /**
  17468. * Instantiate the action
  17469. * @param triggerOptions defines the trigger options
  17470. * @param target defines the object containing the property
  17471. * @param propertyPath defines the path of the property to set in the target
  17472. * @param value defines the value to set in the property
  17473. * @param condition defines the trigger related conditions
  17474. */
  17475. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17476. /** @hidden */
  17477. _prepare(): void;
  17478. /**
  17479. * Execute the action and set the targetted property to the desired value.
  17480. */
  17481. execute(): void;
  17482. /**
  17483. * Serializes the actions and its related information.
  17484. * @param parent defines the object to serialize in
  17485. * @returns the serialized object
  17486. */
  17487. serialize(parent: any): any;
  17488. }
  17489. /**
  17490. * This defines an action responsible to increment the target value
  17491. * to a desired value once triggered.
  17492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17493. */
  17494. export class IncrementValueAction extends Action {
  17495. /**
  17496. * The path of the property to increment in the target.
  17497. */
  17498. propertyPath: string;
  17499. /**
  17500. * The value we should increment the property by.
  17501. */
  17502. value: any;
  17503. private _target;
  17504. private _effectiveTarget;
  17505. private _property;
  17506. /**
  17507. * Instantiate the action
  17508. * @param triggerOptions defines the trigger options
  17509. * @param target defines the object containing the property
  17510. * @param propertyPath defines the path of the property to increment in the target
  17511. * @param value defines the value value we should increment the property by
  17512. * @param condition defines the trigger related conditions
  17513. */
  17514. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17515. /** @hidden */
  17516. _prepare(): void;
  17517. /**
  17518. * Execute the action and increment the target of the value amount.
  17519. */
  17520. execute(): void;
  17521. /**
  17522. * Serializes the actions and its related information.
  17523. * @param parent defines the object to serialize in
  17524. * @returns the serialized object
  17525. */
  17526. serialize(parent: any): any;
  17527. }
  17528. /**
  17529. * This defines an action responsible to start an animation once triggered.
  17530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17531. */
  17532. export class PlayAnimationAction extends Action {
  17533. /**
  17534. * Where the animation should start (animation frame)
  17535. */
  17536. from: number;
  17537. /**
  17538. * Where the animation should stop (animation frame)
  17539. */
  17540. to: number;
  17541. /**
  17542. * Define if the animation should loop or stop after the first play.
  17543. */
  17544. loop?: boolean;
  17545. private _target;
  17546. /**
  17547. * Instantiate the action
  17548. * @param triggerOptions defines the trigger options
  17549. * @param target defines the target animation or animation name
  17550. * @param from defines from where the animation should start (animation frame)
  17551. * @param end defines where the animation should stop (animation frame)
  17552. * @param loop defines if the animation should loop or stop after the first play
  17553. * @param condition defines the trigger related conditions
  17554. */
  17555. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17556. /** @hidden */
  17557. _prepare(): void;
  17558. /**
  17559. * Execute the action and play the animation.
  17560. */
  17561. execute(): void;
  17562. /**
  17563. * Serializes the actions and its related information.
  17564. * @param parent defines the object to serialize in
  17565. * @returns the serialized object
  17566. */
  17567. serialize(parent: any): any;
  17568. }
  17569. /**
  17570. * This defines an action responsible to stop an animation once triggered.
  17571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17572. */
  17573. export class StopAnimationAction extends Action {
  17574. private _target;
  17575. /**
  17576. * Instantiate the action
  17577. * @param triggerOptions defines the trigger options
  17578. * @param target defines the target animation or animation name
  17579. * @param condition defines the trigger related conditions
  17580. */
  17581. constructor(triggerOptions: any, target: any, condition?: Condition);
  17582. /** @hidden */
  17583. _prepare(): void;
  17584. /**
  17585. * Execute the action and stop the animation.
  17586. */
  17587. execute(): void;
  17588. /**
  17589. * Serializes the actions and its related information.
  17590. * @param parent defines the object to serialize in
  17591. * @returns the serialized object
  17592. */
  17593. serialize(parent: any): any;
  17594. }
  17595. /**
  17596. * This defines an action responsible that does nothing once triggered.
  17597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17598. */
  17599. export class DoNothingAction extends Action {
  17600. /**
  17601. * Instantiate the action
  17602. * @param triggerOptions defines the trigger options
  17603. * @param condition defines the trigger related conditions
  17604. */
  17605. constructor(triggerOptions?: any, condition?: Condition);
  17606. /**
  17607. * Execute the action and do nothing.
  17608. */
  17609. execute(): void;
  17610. /**
  17611. * Serializes the actions and its related information.
  17612. * @param parent defines the object to serialize in
  17613. * @returns the serialized object
  17614. */
  17615. serialize(parent: any): any;
  17616. }
  17617. /**
  17618. * This defines an action responsible to trigger several actions once triggered.
  17619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17620. */
  17621. export class CombineAction extends Action {
  17622. /**
  17623. * The list of aggregated animations to run.
  17624. */
  17625. children: Action[];
  17626. /**
  17627. * Instantiate the action
  17628. * @param triggerOptions defines the trigger options
  17629. * @param children defines the list of aggregated animations to run
  17630. * @param condition defines the trigger related conditions
  17631. */
  17632. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17633. /** @hidden */
  17634. _prepare(): void;
  17635. /**
  17636. * Execute the action and executes all the aggregated actions.
  17637. */
  17638. execute(evt: ActionEvent): void;
  17639. /**
  17640. * Serializes the actions and its related information.
  17641. * @param parent defines the object to serialize in
  17642. * @returns the serialized object
  17643. */
  17644. serialize(parent: any): any;
  17645. }
  17646. /**
  17647. * This defines an action responsible to run code (external event) once triggered.
  17648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17649. */
  17650. export class ExecuteCodeAction extends Action {
  17651. /**
  17652. * The callback function to run.
  17653. */
  17654. func: (evt: ActionEvent) => void;
  17655. /**
  17656. * Instantiate the action
  17657. * @param triggerOptions defines the trigger options
  17658. * @param func defines the callback function to run
  17659. * @param condition defines the trigger related conditions
  17660. */
  17661. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17662. /**
  17663. * Execute the action and run the attached code.
  17664. */
  17665. execute(evt: ActionEvent): void;
  17666. }
  17667. /**
  17668. * This defines an action responsible to set the parent property of the target once triggered.
  17669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17670. */
  17671. export class SetParentAction extends Action {
  17672. private _parent;
  17673. private _target;
  17674. /**
  17675. * Instantiate the action
  17676. * @param triggerOptions defines the trigger options
  17677. * @param target defines the target containing the parent property
  17678. * @param parent defines from where the animation should start (animation frame)
  17679. * @param condition defines the trigger related conditions
  17680. */
  17681. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17682. /** @hidden */
  17683. _prepare(): void;
  17684. /**
  17685. * Execute the action and set the parent property.
  17686. */
  17687. execute(): void;
  17688. /**
  17689. * Serializes the actions and its related information.
  17690. * @param parent defines the object to serialize in
  17691. * @returns the serialized object
  17692. */
  17693. serialize(parent: any): any;
  17694. }
  17695. }
  17696. declare module BABYLON {
  17697. /**
  17698. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17699. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17701. */
  17702. export class ActionManager extends AbstractActionManager {
  17703. /**
  17704. * Nothing
  17705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17706. */
  17707. static readonly NothingTrigger: number;
  17708. /**
  17709. * On pick
  17710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17711. */
  17712. static readonly OnPickTrigger: number;
  17713. /**
  17714. * On left pick
  17715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17716. */
  17717. static readonly OnLeftPickTrigger: number;
  17718. /**
  17719. * On right pick
  17720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17721. */
  17722. static readonly OnRightPickTrigger: number;
  17723. /**
  17724. * On center pick
  17725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17726. */
  17727. static readonly OnCenterPickTrigger: number;
  17728. /**
  17729. * On pick down
  17730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17731. */
  17732. static readonly OnPickDownTrigger: number;
  17733. /**
  17734. * On double pick
  17735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17736. */
  17737. static readonly OnDoublePickTrigger: number;
  17738. /**
  17739. * On pick up
  17740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17741. */
  17742. static readonly OnPickUpTrigger: number;
  17743. /**
  17744. * On pick out.
  17745. * This trigger will only be raised if you also declared a OnPickDown
  17746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17747. */
  17748. static readonly OnPickOutTrigger: number;
  17749. /**
  17750. * On long press
  17751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17752. */
  17753. static readonly OnLongPressTrigger: number;
  17754. /**
  17755. * On pointer over
  17756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17757. */
  17758. static readonly OnPointerOverTrigger: number;
  17759. /**
  17760. * On pointer out
  17761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17762. */
  17763. static readonly OnPointerOutTrigger: number;
  17764. /**
  17765. * On every frame
  17766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17767. */
  17768. static readonly OnEveryFrameTrigger: number;
  17769. /**
  17770. * On intersection enter
  17771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17772. */
  17773. static readonly OnIntersectionEnterTrigger: number;
  17774. /**
  17775. * On intersection exit
  17776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17777. */
  17778. static readonly OnIntersectionExitTrigger: number;
  17779. /**
  17780. * On key down
  17781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17782. */
  17783. static readonly OnKeyDownTrigger: number;
  17784. /**
  17785. * On key up
  17786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17787. */
  17788. static readonly OnKeyUpTrigger: number;
  17789. private _scene;
  17790. /**
  17791. * Creates a new action manager
  17792. * @param scene defines the hosting scene
  17793. */
  17794. constructor(scene: Scene);
  17795. /**
  17796. * Releases all associated resources
  17797. */
  17798. dispose(): void;
  17799. /**
  17800. * Gets hosting scene
  17801. * @returns the hosting scene
  17802. */
  17803. getScene(): Scene;
  17804. /**
  17805. * Does this action manager handles actions of any of the given triggers
  17806. * @param triggers defines the triggers to be tested
  17807. * @return a boolean indicating whether one (or more) of the triggers is handled
  17808. */
  17809. hasSpecificTriggers(triggers: number[]): boolean;
  17810. /**
  17811. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17812. * speed.
  17813. * @param triggerA defines the trigger to be tested
  17814. * @param triggerB defines the trigger to be tested
  17815. * @return a boolean indicating whether one (or more) of the triggers is handled
  17816. */
  17817. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17818. /**
  17819. * Does this action manager handles actions of a given trigger
  17820. * @param trigger defines the trigger to be tested
  17821. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17822. * @return whether the trigger is handled
  17823. */
  17824. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17825. /**
  17826. * Does this action manager has pointer triggers
  17827. */
  17828. get hasPointerTriggers(): boolean;
  17829. /**
  17830. * Does this action manager has pick triggers
  17831. */
  17832. get hasPickTriggers(): boolean;
  17833. /**
  17834. * Registers an action to this action manager
  17835. * @param action defines the action to be registered
  17836. * @return the action amended (prepared) after registration
  17837. */
  17838. registerAction(action: IAction): Nullable<IAction>;
  17839. /**
  17840. * Unregisters an action to this action manager
  17841. * @param action defines the action to be unregistered
  17842. * @return a boolean indicating whether the action has been unregistered
  17843. */
  17844. unregisterAction(action: IAction): Boolean;
  17845. /**
  17846. * Process a specific trigger
  17847. * @param trigger defines the trigger to process
  17848. * @param evt defines the event details to be processed
  17849. */
  17850. processTrigger(trigger: number, evt?: IActionEvent): void;
  17851. /** @hidden */
  17852. _getEffectiveTarget(target: any, propertyPath: string): any;
  17853. /** @hidden */
  17854. _getProperty(propertyPath: string): string;
  17855. /**
  17856. * Serialize this manager to a JSON object
  17857. * @param name defines the property name to store this manager
  17858. * @returns a JSON representation of this manager
  17859. */
  17860. serialize(name: string): any;
  17861. /**
  17862. * Creates a new ActionManager from a JSON data
  17863. * @param parsedActions defines the JSON data to read from
  17864. * @param object defines the hosting mesh
  17865. * @param scene defines the hosting scene
  17866. */
  17867. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17868. /**
  17869. * Get a trigger name by index
  17870. * @param trigger defines the trigger index
  17871. * @returns a trigger name
  17872. */
  17873. static GetTriggerName(trigger: number): string;
  17874. }
  17875. }
  17876. declare module BABYLON {
  17877. /**
  17878. * Class used to represent a sprite
  17879. * @see http://doc.babylonjs.com/babylon101/sprites
  17880. */
  17881. export class Sprite {
  17882. /** defines the name */
  17883. name: string;
  17884. /** Gets or sets the current world position */
  17885. position: Vector3;
  17886. /** Gets or sets the main color */
  17887. color: Color4;
  17888. /** Gets or sets the width */
  17889. width: number;
  17890. /** Gets or sets the height */
  17891. height: number;
  17892. /** Gets or sets rotation angle */
  17893. angle: number;
  17894. /** Gets or sets the cell index in the sprite sheet */
  17895. cellIndex: number;
  17896. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17897. cellRef: string;
  17898. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17899. invertU: number;
  17900. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17901. invertV: number;
  17902. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17903. disposeWhenFinishedAnimating: boolean;
  17904. /** Gets the list of attached animations */
  17905. animations: Animation[];
  17906. /** Gets or sets a boolean indicating if the sprite can be picked */
  17907. isPickable: boolean;
  17908. /**
  17909. * Gets or sets the associated action manager
  17910. */
  17911. actionManager: Nullable<ActionManager>;
  17912. private _animationStarted;
  17913. private _loopAnimation;
  17914. private _fromIndex;
  17915. private _toIndex;
  17916. private _delay;
  17917. private _direction;
  17918. private _manager;
  17919. private _time;
  17920. private _onAnimationEnd;
  17921. /**
  17922. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17923. */
  17924. isVisible: boolean;
  17925. /**
  17926. * Gets or sets the sprite size
  17927. */
  17928. get size(): number;
  17929. set size(value: number);
  17930. /**
  17931. * Creates a new Sprite
  17932. * @param name defines the name
  17933. * @param manager defines the manager
  17934. */
  17935. constructor(
  17936. /** defines the name */
  17937. name: string, manager: ISpriteManager);
  17938. /**
  17939. * Starts an animation
  17940. * @param from defines the initial key
  17941. * @param to defines the end key
  17942. * @param loop defines if the animation must loop
  17943. * @param delay defines the start delay (in ms)
  17944. * @param onAnimationEnd defines a callback to call when animation ends
  17945. */
  17946. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17947. /** Stops current animation (if any) */
  17948. stopAnimation(): void;
  17949. /** @hidden */
  17950. _animate(deltaTime: number): void;
  17951. /** Release associated resources */
  17952. dispose(): void;
  17953. }
  17954. }
  17955. declare module BABYLON {
  17956. /**
  17957. * Information about the result of picking within a scene
  17958. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  17959. */
  17960. export class PickingInfo {
  17961. /** @hidden */
  17962. _pickingUnavailable: boolean;
  17963. /**
  17964. * If the pick collided with an object
  17965. */
  17966. hit: boolean;
  17967. /**
  17968. * Distance away where the pick collided
  17969. */
  17970. distance: number;
  17971. /**
  17972. * The location of pick collision
  17973. */
  17974. pickedPoint: Nullable<Vector3>;
  17975. /**
  17976. * The mesh corresponding the the pick collision
  17977. */
  17978. pickedMesh: Nullable<AbstractMesh>;
  17979. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  17980. bu: number;
  17981. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  17982. bv: number;
  17983. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  17984. faceId: number;
  17985. /** Id of the the submesh that was picked */
  17986. subMeshId: number;
  17987. /** If a sprite was picked, this will be the sprite the pick collided with */
  17988. pickedSprite: Nullable<Sprite>;
  17989. /**
  17990. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  17991. */
  17992. originMesh: Nullable<AbstractMesh>;
  17993. /**
  17994. * The ray that was used to perform the picking.
  17995. */
  17996. ray: Nullable<Ray>;
  17997. /**
  17998. * Gets the normal correspodning to the face the pick collided with
  17999. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18000. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18001. * @returns The normal correspodning to the face the pick collided with
  18002. */
  18003. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18004. /**
  18005. * Gets the texture coordinates of where the pick occured
  18006. * @returns the vector containing the coordnates of the texture
  18007. */
  18008. getTextureCoordinates(): Nullable<Vector2>;
  18009. }
  18010. }
  18011. declare module BABYLON {
  18012. /**
  18013. * Gather the list of pointer event types as constants.
  18014. */
  18015. export class PointerEventTypes {
  18016. /**
  18017. * 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.
  18018. */
  18019. static readonly POINTERDOWN: number;
  18020. /**
  18021. * The pointerup event is fired when a pointer is no longer active.
  18022. */
  18023. static readonly POINTERUP: number;
  18024. /**
  18025. * The pointermove event is fired when a pointer changes coordinates.
  18026. */
  18027. static readonly POINTERMOVE: number;
  18028. /**
  18029. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18030. */
  18031. static readonly POINTERWHEEL: number;
  18032. /**
  18033. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18034. */
  18035. static readonly POINTERPICK: number;
  18036. /**
  18037. * The pointertap event is fired when a the object has been touched and released without drag.
  18038. */
  18039. static readonly POINTERTAP: number;
  18040. /**
  18041. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18042. */
  18043. static readonly POINTERDOUBLETAP: number;
  18044. }
  18045. /**
  18046. * Base class of pointer info types.
  18047. */
  18048. export class PointerInfoBase {
  18049. /**
  18050. * Defines the type of event (PointerEventTypes)
  18051. */
  18052. type: number;
  18053. /**
  18054. * Defines the related dom event
  18055. */
  18056. event: PointerEvent | MouseWheelEvent;
  18057. /**
  18058. * Instantiates the base class of pointers info.
  18059. * @param type Defines the type of event (PointerEventTypes)
  18060. * @param event Defines the related dom event
  18061. */
  18062. constructor(
  18063. /**
  18064. * Defines the type of event (PointerEventTypes)
  18065. */
  18066. type: number,
  18067. /**
  18068. * Defines the related dom event
  18069. */
  18070. event: PointerEvent | MouseWheelEvent);
  18071. }
  18072. /**
  18073. * This class is used to store pointer related info for the onPrePointerObservable event.
  18074. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18075. */
  18076. export class PointerInfoPre extends PointerInfoBase {
  18077. /**
  18078. * Ray from a pointer if availible (eg. 6dof controller)
  18079. */
  18080. ray: Nullable<Ray>;
  18081. /**
  18082. * Defines the local position of the pointer on the canvas.
  18083. */
  18084. localPosition: Vector2;
  18085. /**
  18086. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18087. */
  18088. skipOnPointerObservable: boolean;
  18089. /**
  18090. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18091. * @param type Defines the type of event (PointerEventTypes)
  18092. * @param event Defines the related dom event
  18093. * @param localX Defines the local x coordinates of the pointer when the event occured
  18094. * @param localY Defines the local y coordinates of the pointer when the event occured
  18095. */
  18096. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18097. }
  18098. /**
  18099. * This type contains all the data related to a pointer event in Babylon.js.
  18100. * 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.
  18101. */
  18102. export class PointerInfo extends PointerInfoBase {
  18103. /**
  18104. * Defines the picking info associated to the info (if any)\
  18105. */
  18106. pickInfo: Nullable<PickingInfo>;
  18107. /**
  18108. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18109. * @param type Defines the type of event (PointerEventTypes)
  18110. * @param event Defines the related dom event
  18111. * @param pickInfo Defines the picking info associated to the info (if any)\
  18112. */
  18113. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18114. /**
  18115. * Defines the picking info associated to the info (if any)\
  18116. */
  18117. pickInfo: Nullable<PickingInfo>);
  18118. }
  18119. /**
  18120. * Data relating to a touch event on the screen.
  18121. */
  18122. export interface PointerTouch {
  18123. /**
  18124. * X coordinate of touch.
  18125. */
  18126. x: number;
  18127. /**
  18128. * Y coordinate of touch.
  18129. */
  18130. y: number;
  18131. /**
  18132. * Id of touch. Unique for each finger.
  18133. */
  18134. pointerId: number;
  18135. /**
  18136. * Event type passed from DOM.
  18137. */
  18138. type: any;
  18139. }
  18140. }
  18141. declare module BABYLON {
  18142. /**
  18143. * Manage the mouse inputs to control the movement of a free camera.
  18144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18145. */
  18146. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18147. /**
  18148. * Define if touch is enabled in the mouse input
  18149. */
  18150. touchEnabled: boolean;
  18151. /**
  18152. * Defines the camera the input is attached to.
  18153. */
  18154. camera: FreeCamera;
  18155. /**
  18156. * Defines the buttons associated with the input to handle camera move.
  18157. */
  18158. buttons: number[];
  18159. /**
  18160. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18161. */
  18162. angularSensibility: number;
  18163. private _pointerInput;
  18164. private _onMouseMove;
  18165. private _observer;
  18166. private previousPosition;
  18167. /**
  18168. * Observable for when a pointer move event occurs containing the move offset
  18169. */
  18170. onPointerMovedObservable: Observable<{
  18171. offsetX: number;
  18172. offsetY: number;
  18173. }>;
  18174. /**
  18175. * @hidden
  18176. * If the camera should be rotated automatically based on pointer movement
  18177. */
  18178. _allowCameraRotation: boolean;
  18179. /**
  18180. * Manage the mouse inputs to control the movement of a free camera.
  18181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18182. * @param touchEnabled Defines if touch is enabled or not
  18183. */
  18184. constructor(
  18185. /**
  18186. * Define if touch is enabled in the mouse input
  18187. */
  18188. touchEnabled?: boolean);
  18189. /**
  18190. * Attach the input controls to a specific dom element to get the input from.
  18191. * @param element Defines the element the controls should be listened from
  18192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18193. */
  18194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18195. /**
  18196. * Called on JS contextmenu event.
  18197. * Override this method to provide functionality.
  18198. */
  18199. protected onContextMenu(evt: PointerEvent): void;
  18200. /**
  18201. * Detach the current controls from the specified dom element.
  18202. * @param element Defines the element to stop listening the inputs from
  18203. */
  18204. detachControl(element: Nullable<HTMLElement>): void;
  18205. /**
  18206. * Gets the class name of the current intput.
  18207. * @returns the class name
  18208. */
  18209. getClassName(): string;
  18210. /**
  18211. * Get the friendly name associated with the input class.
  18212. * @returns the input friendly name
  18213. */
  18214. getSimpleName(): string;
  18215. }
  18216. }
  18217. declare module BABYLON {
  18218. /**
  18219. * Manage the touch inputs to control the movement of a free camera.
  18220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18221. */
  18222. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18223. /**
  18224. * Defines the camera the input is attached to.
  18225. */
  18226. camera: FreeCamera;
  18227. /**
  18228. * Defines the touch sensibility for rotation.
  18229. * The higher the faster.
  18230. */
  18231. touchAngularSensibility: number;
  18232. /**
  18233. * Defines the touch sensibility for move.
  18234. * The higher the faster.
  18235. */
  18236. touchMoveSensibility: number;
  18237. private _offsetX;
  18238. private _offsetY;
  18239. private _pointerPressed;
  18240. private _pointerInput;
  18241. private _observer;
  18242. private _onLostFocus;
  18243. /**
  18244. * Attach the input controls to a specific dom element to get the input from.
  18245. * @param element Defines the element the controls should be listened from
  18246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18247. */
  18248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18249. /**
  18250. * Detach the current controls from the specified dom element.
  18251. * @param element Defines the element to stop listening the inputs from
  18252. */
  18253. detachControl(element: Nullable<HTMLElement>): void;
  18254. /**
  18255. * Update the current camera state depending on the inputs that have been used this frame.
  18256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18257. */
  18258. checkInputs(): void;
  18259. /**
  18260. * Gets the class name of the current intput.
  18261. * @returns the class name
  18262. */
  18263. getClassName(): string;
  18264. /**
  18265. * Get the friendly name associated with the input class.
  18266. * @returns the input friendly name
  18267. */
  18268. getSimpleName(): string;
  18269. }
  18270. }
  18271. declare module BABYLON {
  18272. /**
  18273. * Default Inputs manager for the FreeCamera.
  18274. * It groups all the default supported inputs for ease of use.
  18275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18276. */
  18277. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18278. /**
  18279. * @hidden
  18280. */
  18281. _mouseInput: Nullable<FreeCameraMouseInput>;
  18282. /**
  18283. * Instantiates a new FreeCameraInputsManager.
  18284. * @param camera Defines the camera the inputs belong to
  18285. */
  18286. constructor(camera: FreeCamera);
  18287. /**
  18288. * Add keyboard input support to the input manager.
  18289. * @returns the current input manager
  18290. */
  18291. addKeyboard(): FreeCameraInputsManager;
  18292. /**
  18293. * Add mouse input support to the input manager.
  18294. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18295. * @returns the current input manager
  18296. */
  18297. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18298. /**
  18299. * Removes the mouse input support from the manager
  18300. * @returns the current input manager
  18301. */
  18302. removeMouse(): FreeCameraInputsManager;
  18303. /**
  18304. * Add touch input support to the input manager.
  18305. * @returns the current input manager
  18306. */
  18307. addTouch(): FreeCameraInputsManager;
  18308. /**
  18309. * Remove all attached input methods from a camera
  18310. */
  18311. clear(): void;
  18312. }
  18313. }
  18314. declare module BABYLON {
  18315. /**
  18316. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18317. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18318. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18319. */
  18320. export class FreeCamera extends TargetCamera {
  18321. /**
  18322. * Define the collision ellipsoid of the camera.
  18323. * This is helpful to simulate a camera body like the player body around the camera
  18324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18325. */
  18326. ellipsoid: Vector3;
  18327. /**
  18328. * Define an offset for the position of the ellipsoid around the camera.
  18329. * This can be helpful to determine the center of the body near the gravity center of the body
  18330. * instead of its head.
  18331. */
  18332. ellipsoidOffset: Vector3;
  18333. /**
  18334. * Enable or disable collisions of the camera with the rest of the scene objects.
  18335. */
  18336. checkCollisions: boolean;
  18337. /**
  18338. * Enable or disable gravity on the camera.
  18339. */
  18340. applyGravity: boolean;
  18341. /**
  18342. * Define the input manager associated to the camera.
  18343. */
  18344. inputs: FreeCameraInputsManager;
  18345. /**
  18346. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18347. * Higher values reduce sensitivity.
  18348. */
  18349. get angularSensibility(): number;
  18350. /**
  18351. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18352. * Higher values reduce sensitivity.
  18353. */
  18354. set angularSensibility(value: number);
  18355. /**
  18356. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18357. */
  18358. get keysUp(): number[];
  18359. set keysUp(value: number[]);
  18360. /**
  18361. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18362. */
  18363. get keysDown(): number[];
  18364. set keysDown(value: number[]);
  18365. /**
  18366. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18367. */
  18368. get keysLeft(): number[];
  18369. set keysLeft(value: number[]);
  18370. /**
  18371. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18372. */
  18373. get keysRight(): number[];
  18374. set keysRight(value: number[]);
  18375. /**
  18376. * Event raised when the camera collide with a mesh in the scene.
  18377. */
  18378. onCollide: (collidedMesh: AbstractMesh) => void;
  18379. private _collider;
  18380. private _needMoveForGravity;
  18381. private _oldPosition;
  18382. private _diffPosition;
  18383. private _newPosition;
  18384. /** @hidden */
  18385. _localDirection: Vector3;
  18386. /** @hidden */
  18387. _transformedDirection: Vector3;
  18388. /**
  18389. * Instantiates a Free Camera.
  18390. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18391. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18392. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18393. * @param name Define the name of the camera in the scene
  18394. * @param position Define the start position of the camera in the scene
  18395. * @param scene Define the scene the camera belongs to
  18396. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18397. */
  18398. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18399. /**
  18400. * Attached controls to the current camera.
  18401. * @param element Defines the element the controls should be listened from
  18402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18403. */
  18404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18405. /**
  18406. * Detach the current controls from the camera.
  18407. * The camera will stop reacting to inputs.
  18408. * @param element Defines the element to stop listening the inputs from
  18409. */
  18410. detachControl(element: HTMLElement): void;
  18411. private _collisionMask;
  18412. /**
  18413. * Define a collision mask to limit the list of object the camera can collide with
  18414. */
  18415. get collisionMask(): number;
  18416. set collisionMask(mask: number);
  18417. /** @hidden */
  18418. _collideWithWorld(displacement: Vector3): void;
  18419. private _onCollisionPositionChange;
  18420. /** @hidden */
  18421. _checkInputs(): void;
  18422. /** @hidden */
  18423. _decideIfNeedsToMove(): boolean;
  18424. /** @hidden */
  18425. _updatePosition(): void;
  18426. /**
  18427. * Destroy the camera and release the current resources hold by it.
  18428. */
  18429. dispose(): void;
  18430. /**
  18431. * Gets the current object class name.
  18432. * @return the class name
  18433. */
  18434. getClassName(): string;
  18435. }
  18436. }
  18437. declare module BABYLON {
  18438. /**
  18439. * Represents a gamepad control stick position
  18440. */
  18441. export class StickValues {
  18442. /**
  18443. * The x component of the control stick
  18444. */
  18445. x: number;
  18446. /**
  18447. * The y component of the control stick
  18448. */
  18449. y: number;
  18450. /**
  18451. * Initializes the gamepad x and y control stick values
  18452. * @param x The x component of the gamepad control stick value
  18453. * @param y The y component of the gamepad control stick value
  18454. */
  18455. constructor(
  18456. /**
  18457. * The x component of the control stick
  18458. */
  18459. x: number,
  18460. /**
  18461. * The y component of the control stick
  18462. */
  18463. y: number);
  18464. }
  18465. /**
  18466. * An interface which manages callbacks for gamepad button changes
  18467. */
  18468. export interface GamepadButtonChanges {
  18469. /**
  18470. * Called when a gamepad has been changed
  18471. */
  18472. changed: boolean;
  18473. /**
  18474. * Called when a gamepad press event has been triggered
  18475. */
  18476. pressChanged: boolean;
  18477. /**
  18478. * Called when a touch event has been triggered
  18479. */
  18480. touchChanged: boolean;
  18481. /**
  18482. * Called when a value has changed
  18483. */
  18484. valueChanged: boolean;
  18485. }
  18486. /**
  18487. * Represents a gamepad
  18488. */
  18489. export class Gamepad {
  18490. /**
  18491. * The id of the gamepad
  18492. */
  18493. id: string;
  18494. /**
  18495. * The index of the gamepad
  18496. */
  18497. index: number;
  18498. /**
  18499. * The browser gamepad
  18500. */
  18501. browserGamepad: any;
  18502. /**
  18503. * Specifies what type of gamepad this represents
  18504. */
  18505. type: number;
  18506. private _leftStick;
  18507. private _rightStick;
  18508. /** @hidden */
  18509. _isConnected: boolean;
  18510. private _leftStickAxisX;
  18511. private _leftStickAxisY;
  18512. private _rightStickAxisX;
  18513. private _rightStickAxisY;
  18514. /**
  18515. * Triggered when the left control stick has been changed
  18516. */
  18517. private _onleftstickchanged;
  18518. /**
  18519. * Triggered when the right control stick has been changed
  18520. */
  18521. private _onrightstickchanged;
  18522. /**
  18523. * Represents a gamepad controller
  18524. */
  18525. static GAMEPAD: number;
  18526. /**
  18527. * Represents a generic controller
  18528. */
  18529. static GENERIC: number;
  18530. /**
  18531. * Represents an XBox controller
  18532. */
  18533. static XBOX: number;
  18534. /**
  18535. * Represents a pose-enabled controller
  18536. */
  18537. static POSE_ENABLED: number;
  18538. /**
  18539. * Represents an Dual Shock controller
  18540. */
  18541. static DUALSHOCK: number;
  18542. /**
  18543. * Specifies whether the left control stick should be Y-inverted
  18544. */
  18545. protected _invertLeftStickY: boolean;
  18546. /**
  18547. * Specifies if the gamepad has been connected
  18548. */
  18549. get isConnected(): boolean;
  18550. /**
  18551. * Initializes the gamepad
  18552. * @param id The id of the gamepad
  18553. * @param index The index of the gamepad
  18554. * @param browserGamepad The browser gamepad
  18555. * @param leftStickX The x component of the left joystick
  18556. * @param leftStickY The y component of the left joystick
  18557. * @param rightStickX The x component of the right joystick
  18558. * @param rightStickY The y component of the right joystick
  18559. */
  18560. constructor(
  18561. /**
  18562. * The id of the gamepad
  18563. */
  18564. id: string,
  18565. /**
  18566. * The index of the gamepad
  18567. */
  18568. index: number,
  18569. /**
  18570. * The browser gamepad
  18571. */
  18572. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18573. /**
  18574. * Callback triggered when the left joystick has changed
  18575. * @param callback
  18576. */
  18577. onleftstickchanged(callback: (values: StickValues) => void): void;
  18578. /**
  18579. * Callback triggered when the right joystick has changed
  18580. * @param callback
  18581. */
  18582. onrightstickchanged(callback: (values: StickValues) => void): void;
  18583. /**
  18584. * Gets the left joystick
  18585. */
  18586. get leftStick(): StickValues;
  18587. /**
  18588. * Sets the left joystick values
  18589. */
  18590. set leftStick(newValues: StickValues);
  18591. /**
  18592. * Gets the right joystick
  18593. */
  18594. get rightStick(): StickValues;
  18595. /**
  18596. * Sets the right joystick value
  18597. */
  18598. set rightStick(newValues: StickValues);
  18599. /**
  18600. * Updates the gamepad joystick positions
  18601. */
  18602. update(): void;
  18603. /**
  18604. * Disposes the gamepad
  18605. */
  18606. dispose(): void;
  18607. }
  18608. /**
  18609. * Represents a generic gamepad
  18610. */
  18611. export class GenericPad extends Gamepad {
  18612. private _buttons;
  18613. private _onbuttondown;
  18614. private _onbuttonup;
  18615. /**
  18616. * Observable triggered when a button has been pressed
  18617. */
  18618. onButtonDownObservable: Observable<number>;
  18619. /**
  18620. * Observable triggered when a button has been released
  18621. */
  18622. onButtonUpObservable: Observable<number>;
  18623. /**
  18624. * Callback triggered when a button has been pressed
  18625. * @param callback Called when a button has been pressed
  18626. */
  18627. onbuttondown(callback: (buttonPressed: number) => void): void;
  18628. /**
  18629. * Callback triggered when a button has been released
  18630. * @param callback Called when a button has been released
  18631. */
  18632. onbuttonup(callback: (buttonReleased: number) => void): void;
  18633. /**
  18634. * Initializes the generic gamepad
  18635. * @param id The id of the generic gamepad
  18636. * @param index The index of the generic gamepad
  18637. * @param browserGamepad The browser gamepad
  18638. */
  18639. constructor(id: string, index: number, browserGamepad: any);
  18640. private _setButtonValue;
  18641. /**
  18642. * Updates the generic gamepad
  18643. */
  18644. update(): void;
  18645. /**
  18646. * Disposes the generic gamepad
  18647. */
  18648. dispose(): void;
  18649. }
  18650. }
  18651. declare module BABYLON {
  18652. /**
  18653. * Defines the types of pose enabled controllers that are supported
  18654. */
  18655. export enum PoseEnabledControllerType {
  18656. /**
  18657. * HTC Vive
  18658. */
  18659. VIVE = 0,
  18660. /**
  18661. * Oculus Rift
  18662. */
  18663. OCULUS = 1,
  18664. /**
  18665. * Windows mixed reality
  18666. */
  18667. WINDOWS = 2,
  18668. /**
  18669. * Samsung gear VR
  18670. */
  18671. GEAR_VR = 3,
  18672. /**
  18673. * Google Daydream
  18674. */
  18675. DAYDREAM = 4,
  18676. /**
  18677. * Generic
  18678. */
  18679. GENERIC = 5
  18680. }
  18681. /**
  18682. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18683. */
  18684. export interface MutableGamepadButton {
  18685. /**
  18686. * Value of the button/trigger
  18687. */
  18688. value: number;
  18689. /**
  18690. * If the button/trigger is currently touched
  18691. */
  18692. touched: boolean;
  18693. /**
  18694. * If the button/trigger is currently pressed
  18695. */
  18696. pressed: boolean;
  18697. }
  18698. /**
  18699. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18700. * @hidden
  18701. */
  18702. export interface ExtendedGamepadButton extends GamepadButton {
  18703. /**
  18704. * If the button/trigger is currently pressed
  18705. */
  18706. readonly pressed: boolean;
  18707. /**
  18708. * If the button/trigger is currently touched
  18709. */
  18710. readonly touched: boolean;
  18711. /**
  18712. * Value of the button/trigger
  18713. */
  18714. readonly value: number;
  18715. }
  18716. /** @hidden */
  18717. export interface _GamePadFactory {
  18718. /**
  18719. * Returns whether or not the current gamepad can be created for this type of controller.
  18720. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18721. * @returns true if it can be created, otherwise false
  18722. */
  18723. canCreate(gamepadInfo: any): boolean;
  18724. /**
  18725. * Creates a new instance of the Gamepad.
  18726. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18727. * @returns the new gamepad instance
  18728. */
  18729. create(gamepadInfo: any): Gamepad;
  18730. }
  18731. /**
  18732. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18733. */
  18734. export class PoseEnabledControllerHelper {
  18735. /** @hidden */
  18736. static _ControllerFactories: _GamePadFactory[];
  18737. /** @hidden */
  18738. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18739. /**
  18740. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18741. * @param vrGamepad the gamepad to initialized
  18742. * @returns a vr controller of the type the gamepad identified as
  18743. */
  18744. static InitiateController(vrGamepad: any): Gamepad;
  18745. }
  18746. /**
  18747. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18748. */
  18749. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18750. /**
  18751. * If the controller is used in a webXR session
  18752. */
  18753. isXR: boolean;
  18754. private _deviceRoomPosition;
  18755. private _deviceRoomRotationQuaternion;
  18756. /**
  18757. * The device position in babylon space
  18758. */
  18759. devicePosition: Vector3;
  18760. /**
  18761. * The device rotation in babylon space
  18762. */
  18763. deviceRotationQuaternion: Quaternion;
  18764. /**
  18765. * The scale factor of the device in babylon space
  18766. */
  18767. deviceScaleFactor: number;
  18768. /**
  18769. * (Likely devicePosition should be used instead) The device position in its room space
  18770. */
  18771. position: Vector3;
  18772. /**
  18773. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18774. */
  18775. rotationQuaternion: Quaternion;
  18776. /**
  18777. * The type of controller (Eg. Windows mixed reality)
  18778. */
  18779. controllerType: PoseEnabledControllerType;
  18780. protected _calculatedPosition: Vector3;
  18781. private _calculatedRotation;
  18782. /**
  18783. * The raw pose from the device
  18784. */
  18785. rawPose: DevicePose;
  18786. private _trackPosition;
  18787. private _maxRotationDistFromHeadset;
  18788. private _draggedRoomRotation;
  18789. /**
  18790. * @hidden
  18791. */
  18792. _disableTrackPosition(fixedPosition: Vector3): void;
  18793. /**
  18794. * Internal, the mesh attached to the controller
  18795. * @hidden
  18796. */
  18797. _mesh: Nullable<AbstractMesh>;
  18798. private _poseControlledCamera;
  18799. private _leftHandSystemQuaternion;
  18800. /**
  18801. * Internal, matrix used to convert room space to babylon space
  18802. * @hidden
  18803. */
  18804. _deviceToWorld: Matrix;
  18805. /**
  18806. * Node to be used when casting a ray from the controller
  18807. * @hidden
  18808. */
  18809. _pointingPoseNode: Nullable<TransformNode>;
  18810. /**
  18811. * Name of the child mesh that can be used to cast a ray from the controller
  18812. */
  18813. static readonly POINTING_POSE: string;
  18814. /**
  18815. * Creates a new PoseEnabledController from a gamepad
  18816. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18817. */
  18818. constructor(browserGamepad: any);
  18819. private _workingMatrix;
  18820. /**
  18821. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18822. */
  18823. update(): void;
  18824. /**
  18825. * Updates only the pose device and mesh without doing any button event checking
  18826. */
  18827. protected _updatePoseAndMesh(): void;
  18828. /**
  18829. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18830. * @param poseData raw pose fromthe device
  18831. */
  18832. updateFromDevice(poseData: DevicePose): void;
  18833. /**
  18834. * @hidden
  18835. */
  18836. _meshAttachedObservable: Observable<AbstractMesh>;
  18837. /**
  18838. * Attaches a mesh to the controller
  18839. * @param mesh the mesh to be attached
  18840. */
  18841. attachToMesh(mesh: AbstractMesh): void;
  18842. /**
  18843. * Attaches the controllers mesh to a camera
  18844. * @param camera the camera the mesh should be attached to
  18845. */
  18846. attachToPoseControlledCamera(camera: TargetCamera): void;
  18847. /**
  18848. * Disposes of the controller
  18849. */
  18850. dispose(): void;
  18851. /**
  18852. * The mesh that is attached to the controller
  18853. */
  18854. get mesh(): Nullable<AbstractMesh>;
  18855. /**
  18856. * Gets the ray of the controller in the direction the controller is pointing
  18857. * @param length the length the resulting ray should be
  18858. * @returns a ray in the direction the controller is pointing
  18859. */
  18860. getForwardRay(length?: number): Ray;
  18861. }
  18862. }
  18863. declare module BABYLON {
  18864. /**
  18865. * Defines the WebVRController object that represents controllers tracked in 3D space
  18866. */
  18867. export abstract class WebVRController extends PoseEnabledController {
  18868. /**
  18869. * Internal, the default controller model for the controller
  18870. */
  18871. protected _defaultModel: Nullable<AbstractMesh>;
  18872. /**
  18873. * Fired when the trigger state has changed
  18874. */
  18875. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18876. /**
  18877. * Fired when the main button state has changed
  18878. */
  18879. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18880. /**
  18881. * Fired when the secondary button state has changed
  18882. */
  18883. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18884. /**
  18885. * Fired when the pad state has changed
  18886. */
  18887. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18888. /**
  18889. * Fired when controllers stick values have changed
  18890. */
  18891. onPadValuesChangedObservable: Observable<StickValues>;
  18892. /**
  18893. * Array of button availible on the controller
  18894. */
  18895. protected _buttons: Array<MutableGamepadButton>;
  18896. private _onButtonStateChange;
  18897. /**
  18898. * Fired when a controller button's state has changed
  18899. * @param callback the callback containing the button that was modified
  18900. */
  18901. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18902. /**
  18903. * X and Y axis corresponding to the controllers joystick
  18904. */
  18905. pad: StickValues;
  18906. /**
  18907. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18908. */
  18909. hand: string;
  18910. /**
  18911. * The default controller model for the controller
  18912. */
  18913. get defaultModel(): Nullable<AbstractMesh>;
  18914. /**
  18915. * Creates a new WebVRController from a gamepad
  18916. * @param vrGamepad the gamepad that the WebVRController should be created from
  18917. */
  18918. constructor(vrGamepad: any);
  18919. /**
  18920. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18921. */
  18922. update(): void;
  18923. /**
  18924. * Function to be called when a button is modified
  18925. */
  18926. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18927. /**
  18928. * Loads a mesh and attaches it to the controller
  18929. * @param scene the scene the mesh should be added to
  18930. * @param meshLoaded callback for when the mesh has been loaded
  18931. */
  18932. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18933. private _setButtonValue;
  18934. private _changes;
  18935. private _checkChanges;
  18936. /**
  18937. * Disposes of th webVRCOntroller
  18938. */
  18939. dispose(): void;
  18940. }
  18941. }
  18942. declare module BABYLON {
  18943. /**
  18944. * The HemisphericLight simulates the ambient environment light,
  18945. * so the passed direction is the light reflection direction, not the incoming direction.
  18946. */
  18947. export class HemisphericLight extends Light {
  18948. /**
  18949. * The groundColor is the light in the opposite direction to the one specified during creation.
  18950. * 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.
  18951. */
  18952. groundColor: Color3;
  18953. /**
  18954. * The light reflection direction, not the incoming direction.
  18955. */
  18956. direction: Vector3;
  18957. /**
  18958. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  18959. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  18960. * The HemisphericLight can't cast shadows.
  18961. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18962. * @param name The friendly name of the light
  18963. * @param direction The direction of the light reflection
  18964. * @param scene The scene the light belongs to
  18965. */
  18966. constructor(name: string, direction: Vector3, scene: Scene);
  18967. protected _buildUniformLayout(): void;
  18968. /**
  18969. * Returns the string "HemisphericLight".
  18970. * @return The class name
  18971. */
  18972. getClassName(): string;
  18973. /**
  18974. * Sets the HemisphericLight direction towards the passed target (Vector3).
  18975. * Returns the updated direction.
  18976. * @param target The target the direction should point to
  18977. * @return The computed direction
  18978. */
  18979. setDirectionToTarget(target: Vector3): Vector3;
  18980. /**
  18981. * Returns the shadow generator associated to the light.
  18982. * @returns Always null for hemispheric lights because it does not support shadows.
  18983. */
  18984. getShadowGenerator(): Nullable<IShadowGenerator>;
  18985. /**
  18986. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  18987. * @param effect The effect to update
  18988. * @param lightIndex The index of the light in the effect to update
  18989. * @returns The hemispheric light
  18990. */
  18991. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  18992. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  18993. /**
  18994. * Computes the world matrix of the node
  18995. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  18996. * @param useWasUpdatedFlag defines a reserved property
  18997. * @returns the world matrix
  18998. */
  18999. computeWorldMatrix(): Matrix;
  19000. /**
  19001. * Returns the integer 3.
  19002. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19003. */
  19004. getTypeID(): number;
  19005. /**
  19006. * Prepares the list of defines specific to the light type.
  19007. * @param defines the list of defines
  19008. * @param lightIndex defines the index of the light for the effect
  19009. */
  19010. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19011. }
  19012. }
  19013. declare module BABYLON {
  19014. /** @hidden */
  19015. export var vrMultiviewToSingleviewPixelShader: {
  19016. name: string;
  19017. shader: string;
  19018. };
  19019. }
  19020. declare module BABYLON {
  19021. /**
  19022. * Renders to multiple views with a single draw call
  19023. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19024. */
  19025. export class MultiviewRenderTarget extends RenderTargetTexture {
  19026. /**
  19027. * Creates a multiview render target
  19028. * @param scene scene used with the render target
  19029. * @param size the size of the render target (used for each view)
  19030. */
  19031. constructor(scene: Scene, size?: number | {
  19032. width: number;
  19033. height: number;
  19034. } | {
  19035. ratio: number;
  19036. });
  19037. /**
  19038. * @hidden
  19039. * @param faceIndex the face index, if its a cube texture
  19040. */
  19041. _bindFrameBuffer(faceIndex?: number): void;
  19042. /**
  19043. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19044. * @returns the view count
  19045. */
  19046. getViewCount(): number;
  19047. }
  19048. }
  19049. declare module BABYLON {
  19050. /**
  19051. * Represents a camera frustum
  19052. */
  19053. export class Frustum {
  19054. /**
  19055. * Gets the planes representing the frustum
  19056. * @param transform matrix to be applied to the returned planes
  19057. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19058. */
  19059. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19060. /**
  19061. * Gets the near frustum plane transformed by the transform matrix
  19062. * @param transform transformation matrix to be applied to the resulting frustum plane
  19063. * @param frustumPlane the resuling frustum plane
  19064. */
  19065. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19066. /**
  19067. * Gets the far frustum plane transformed by the transform matrix
  19068. * @param transform transformation matrix to be applied to the resulting frustum plane
  19069. * @param frustumPlane the resuling frustum plane
  19070. */
  19071. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19072. /**
  19073. * Gets the left frustum plane transformed by the transform matrix
  19074. * @param transform transformation matrix to be applied to the resulting frustum plane
  19075. * @param frustumPlane the resuling frustum plane
  19076. */
  19077. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19078. /**
  19079. * Gets the right frustum plane transformed by the transform matrix
  19080. * @param transform transformation matrix to be applied to the resulting frustum plane
  19081. * @param frustumPlane the resuling frustum plane
  19082. */
  19083. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19084. /**
  19085. * Gets the top frustum plane transformed by the transform matrix
  19086. * @param transform transformation matrix to be applied to the resulting frustum plane
  19087. * @param frustumPlane the resuling frustum plane
  19088. */
  19089. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19090. /**
  19091. * Gets the bottom frustum plane transformed by the transform matrix
  19092. * @param transform transformation matrix to be applied to the resulting frustum plane
  19093. * @param frustumPlane the resuling frustum plane
  19094. */
  19095. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19096. /**
  19097. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19098. * @param transform transformation matrix to be applied to the resulting frustum planes
  19099. * @param frustumPlanes the resuling frustum planes
  19100. */
  19101. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19102. }
  19103. }
  19104. declare module BABYLON {
  19105. interface Engine {
  19106. /**
  19107. * Creates a new multiview render target
  19108. * @param width defines the width of the texture
  19109. * @param height defines the height of the texture
  19110. * @returns the created multiview texture
  19111. */
  19112. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19113. /**
  19114. * Binds a multiview framebuffer to be drawn to
  19115. * @param multiviewTexture texture to bind
  19116. */
  19117. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19118. }
  19119. interface Camera {
  19120. /**
  19121. * @hidden
  19122. * 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)
  19123. */
  19124. _useMultiviewToSingleView: boolean;
  19125. /**
  19126. * @hidden
  19127. * 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)
  19128. */
  19129. _multiviewTexture: Nullable<RenderTargetTexture>;
  19130. /**
  19131. * @hidden
  19132. * ensures the multiview texture of the camera exists and has the specified width/height
  19133. * @param width height to set on the multiview texture
  19134. * @param height width to set on the multiview texture
  19135. */
  19136. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19137. }
  19138. interface Scene {
  19139. /** @hidden */
  19140. _transformMatrixR: Matrix;
  19141. /** @hidden */
  19142. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19143. /** @hidden */
  19144. _createMultiviewUbo(): void;
  19145. /** @hidden */
  19146. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19147. /** @hidden */
  19148. _renderMultiviewToSingleView(camera: Camera): void;
  19149. }
  19150. }
  19151. declare module BABYLON {
  19152. /**
  19153. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19154. * This will not be used for webXR as it supports displaying texture arrays directly
  19155. */
  19156. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19157. /**
  19158. * Initializes a VRMultiviewToSingleview
  19159. * @param name name of the post process
  19160. * @param camera camera to be applied to
  19161. * @param scaleFactor scaling factor to the size of the output texture
  19162. */
  19163. constructor(name: string, camera: Camera, scaleFactor: number);
  19164. }
  19165. }
  19166. declare module BABYLON {
  19167. /**
  19168. * Interface used to define additional presentation attributes
  19169. */
  19170. export interface IVRPresentationAttributes {
  19171. /**
  19172. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19173. */
  19174. highRefreshRate: boolean;
  19175. /**
  19176. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19177. */
  19178. foveationLevel: number;
  19179. }
  19180. interface Engine {
  19181. /** @hidden */
  19182. _vrDisplay: any;
  19183. /** @hidden */
  19184. _vrSupported: boolean;
  19185. /** @hidden */
  19186. _oldSize: Size;
  19187. /** @hidden */
  19188. _oldHardwareScaleFactor: number;
  19189. /** @hidden */
  19190. _vrExclusivePointerMode: boolean;
  19191. /** @hidden */
  19192. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19193. /** @hidden */
  19194. _onVRDisplayPointerRestricted: () => void;
  19195. /** @hidden */
  19196. _onVRDisplayPointerUnrestricted: () => void;
  19197. /** @hidden */
  19198. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19199. /** @hidden */
  19200. _onVrDisplayDisconnect: Nullable<() => void>;
  19201. /** @hidden */
  19202. _onVrDisplayPresentChange: Nullable<() => void>;
  19203. /**
  19204. * Observable signaled when VR display mode changes
  19205. */
  19206. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19207. /**
  19208. * Observable signaled when VR request present is complete
  19209. */
  19210. onVRRequestPresentComplete: Observable<boolean>;
  19211. /**
  19212. * Observable signaled when VR request present starts
  19213. */
  19214. onVRRequestPresentStart: Observable<Engine>;
  19215. /**
  19216. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19217. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19218. */
  19219. isInVRExclusivePointerMode: boolean;
  19220. /**
  19221. * Gets a boolean indicating if a webVR device was detected
  19222. * @returns true if a webVR device was detected
  19223. */
  19224. isVRDevicePresent(): boolean;
  19225. /**
  19226. * Gets the current webVR device
  19227. * @returns the current webVR device (or null)
  19228. */
  19229. getVRDevice(): any;
  19230. /**
  19231. * Initializes a webVR display and starts listening to display change events
  19232. * The onVRDisplayChangedObservable will be notified upon these changes
  19233. * @returns A promise containing a VRDisplay and if vr is supported
  19234. */
  19235. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19236. /** @hidden */
  19237. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19238. /**
  19239. * Gets or sets the presentation attributes used to configure VR rendering
  19240. */
  19241. vrPresentationAttributes?: IVRPresentationAttributes;
  19242. /**
  19243. * Call this function to switch to webVR mode
  19244. * Will do nothing if webVR is not supported or if there is no webVR device
  19245. * @param options the webvr options provided to the camera. mainly used for multiview
  19246. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19247. */
  19248. enableVR(options: WebVROptions): void;
  19249. /** @hidden */
  19250. _onVRFullScreenTriggered(): void;
  19251. }
  19252. }
  19253. declare module BABYLON {
  19254. /**
  19255. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19256. * IMPORTANT!! The data is right-hand data.
  19257. * @export
  19258. * @interface DevicePose
  19259. */
  19260. export interface DevicePose {
  19261. /**
  19262. * The position of the device, values in array are [x,y,z].
  19263. */
  19264. readonly position: Nullable<Float32Array>;
  19265. /**
  19266. * The linearVelocity of the device, values in array are [x,y,z].
  19267. */
  19268. readonly linearVelocity: Nullable<Float32Array>;
  19269. /**
  19270. * The linearAcceleration of the device, values in array are [x,y,z].
  19271. */
  19272. readonly linearAcceleration: Nullable<Float32Array>;
  19273. /**
  19274. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19275. */
  19276. readonly orientation: Nullable<Float32Array>;
  19277. /**
  19278. * The angularVelocity of the device, values in array are [x,y,z].
  19279. */
  19280. readonly angularVelocity: Nullable<Float32Array>;
  19281. /**
  19282. * The angularAcceleration of the device, values in array are [x,y,z].
  19283. */
  19284. readonly angularAcceleration: Nullable<Float32Array>;
  19285. }
  19286. /**
  19287. * Interface representing a pose controlled object in Babylon.
  19288. * A pose controlled object has both regular pose values as well as pose values
  19289. * from an external device such as a VR head mounted display
  19290. */
  19291. export interface PoseControlled {
  19292. /**
  19293. * The position of the object in babylon space.
  19294. */
  19295. position: Vector3;
  19296. /**
  19297. * The rotation quaternion of the object in babylon space.
  19298. */
  19299. rotationQuaternion: Quaternion;
  19300. /**
  19301. * The position of the device in babylon space.
  19302. */
  19303. devicePosition?: Vector3;
  19304. /**
  19305. * The rotation quaternion of the device in babylon space.
  19306. */
  19307. deviceRotationQuaternion: Quaternion;
  19308. /**
  19309. * The raw pose coming from the device.
  19310. */
  19311. rawPose: Nullable<DevicePose>;
  19312. /**
  19313. * The scale of the device to be used when translating from device space to babylon space.
  19314. */
  19315. deviceScaleFactor: number;
  19316. /**
  19317. * Updates the poseControlled values based on the input device pose.
  19318. * @param poseData the pose data to update the object with
  19319. */
  19320. updateFromDevice(poseData: DevicePose): void;
  19321. }
  19322. /**
  19323. * Set of options to customize the webVRCamera
  19324. */
  19325. export interface WebVROptions {
  19326. /**
  19327. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19328. */
  19329. trackPosition?: boolean;
  19330. /**
  19331. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19332. */
  19333. positionScale?: number;
  19334. /**
  19335. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19336. */
  19337. displayName?: string;
  19338. /**
  19339. * Should the native controller meshes be initialized. (default: true)
  19340. */
  19341. controllerMeshes?: boolean;
  19342. /**
  19343. * Creating a default HemiLight only on controllers. (default: true)
  19344. */
  19345. defaultLightingOnControllers?: boolean;
  19346. /**
  19347. * If you don't want to use the default VR button of the helper. (default: false)
  19348. */
  19349. useCustomVRButton?: boolean;
  19350. /**
  19351. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19352. */
  19353. customVRButton?: HTMLButtonElement;
  19354. /**
  19355. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19356. */
  19357. rayLength?: number;
  19358. /**
  19359. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19360. */
  19361. defaultHeight?: number;
  19362. /**
  19363. * If multiview should be used if availible (default: false)
  19364. */
  19365. useMultiview?: boolean;
  19366. }
  19367. /**
  19368. * This represents a WebVR camera.
  19369. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19370. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19371. */
  19372. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19373. private webVROptions;
  19374. /**
  19375. * @hidden
  19376. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19377. */
  19378. _vrDevice: any;
  19379. /**
  19380. * The rawPose of the vrDevice.
  19381. */
  19382. rawPose: Nullable<DevicePose>;
  19383. private _onVREnabled;
  19384. private _specsVersion;
  19385. private _attached;
  19386. private _frameData;
  19387. protected _descendants: Array<Node>;
  19388. private _deviceRoomPosition;
  19389. /** @hidden */
  19390. _deviceRoomRotationQuaternion: Quaternion;
  19391. private _standingMatrix;
  19392. /**
  19393. * Represents device position in babylon space.
  19394. */
  19395. devicePosition: Vector3;
  19396. /**
  19397. * Represents device rotation in babylon space.
  19398. */
  19399. deviceRotationQuaternion: Quaternion;
  19400. /**
  19401. * The scale of the device to be used when translating from device space to babylon space.
  19402. */
  19403. deviceScaleFactor: number;
  19404. private _deviceToWorld;
  19405. private _worldToDevice;
  19406. /**
  19407. * References to the webVR controllers for the vrDevice.
  19408. */
  19409. controllers: Array<WebVRController>;
  19410. /**
  19411. * Emits an event when a controller is attached.
  19412. */
  19413. onControllersAttachedObservable: Observable<WebVRController[]>;
  19414. /**
  19415. * Emits an event when a controller's mesh has been loaded;
  19416. */
  19417. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19418. /**
  19419. * Emits an event when the HMD's pose has been updated.
  19420. */
  19421. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19422. private _poseSet;
  19423. /**
  19424. * If the rig cameras be used as parent instead of this camera.
  19425. */
  19426. rigParenting: boolean;
  19427. private _lightOnControllers;
  19428. private _defaultHeight?;
  19429. /**
  19430. * Instantiates a WebVRFreeCamera.
  19431. * @param name The name of the WebVRFreeCamera
  19432. * @param position The starting anchor position for the camera
  19433. * @param scene The scene the camera belongs to
  19434. * @param webVROptions a set of customizable options for the webVRCamera
  19435. */
  19436. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19437. /**
  19438. * Gets the device distance from the ground in meters.
  19439. * @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.
  19440. */
  19441. deviceDistanceToRoomGround(): number;
  19442. /**
  19443. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19444. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19445. */
  19446. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19447. /**
  19448. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19449. * @returns A promise with a boolean set to if the standing matrix is supported.
  19450. */
  19451. useStandingMatrixAsync(): Promise<boolean>;
  19452. /**
  19453. * Disposes the camera
  19454. */
  19455. dispose(): void;
  19456. /**
  19457. * Gets a vrController by name.
  19458. * @param name The name of the controller to retreive
  19459. * @returns the controller matching the name specified or null if not found
  19460. */
  19461. getControllerByName(name: string): Nullable<WebVRController>;
  19462. private _leftController;
  19463. /**
  19464. * The controller corresponding to the users left hand.
  19465. */
  19466. get leftController(): Nullable<WebVRController>;
  19467. private _rightController;
  19468. /**
  19469. * The controller corresponding to the users right hand.
  19470. */
  19471. get rightController(): Nullable<WebVRController>;
  19472. /**
  19473. * Casts a ray forward from the vrCamera's gaze.
  19474. * @param length Length of the ray (default: 100)
  19475. * @returns the ray corresponding to the gaze
  19476. */
  19477. getForwardRay(length?: number): Ray;
  19478. /**
  19479. * @hidden
  19480. * Updates the camera based on device's frame data
  19481. */
  19482. _checkInputs(): void;
  19483. /**
  19484. * Updates the poseControlled values based on the input device pose.
  19485. * @param poseData Pose coming from the device
  19486. */
  19487. updateFromDevice(poseData: DevicePose): void;
  19488. private _htmlElementAttached;
  19489. private _detachIfAttached;
  19490. /**
  19491. * WebVR's attach control will start broadcasting frames to the device.
  19492. * Note that in certain browsers (chrome for example) this function must be called
  19493. * within a user-interaction callback. Example:
  19494. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19495. *
  19496. * @param element html element to attach the vrDevice to
  19497. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19498. */
  19499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19500. /**
  19501. * Detaches the camera from the html element and disables VR
  19502. *
  19503. * @param element html element to detach from
  19504. */
  19505. detachControl(element: HTMLElement): void;
  19506. /**
  19507. * @returns the name of this class
  19508. */
  19509. getClassName(): string;
  19510. /**
  19511. * Calls resetPose on the vrDisplay
  19512. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19513. */
  19514. resetToCurrentRotation(): void;
  19515. /**
  19516. * @hidden
  19517. * Updates the rig cameras (left and right eye)
  19518. */
  19519. _updateRigCameras(): void;
  19520. private _workingVector;
  19521. private _oneVector;
  19522. private _workingMatrix;
  19523. private updateCacheCalled;
  19524. private _correctPositionIfNotTrackPosition;
  19525. /**
  19526. * @hidden
  19527. * Updates the cached values of the camera
  19528. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19529. */
  19530. _updateCache(ignoreParentClass?: boolean): void;
  19531. /**
  19532. * @hidden
  19533. * Get current device position in babylon world
  19534. */
  19535. _computeDevicePosition(): void;
  19536. /**
  19537. * Updates the current device position and rotation in the babylon world
  19538. */
  19539. update(): void;
  19540. /**
  19541. * @hidden
  19542. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19543. * @returns an identity matrix
  19544. */
  19545. _getViewMatrix(): Matrix;
  19546. private _tmpMatrix;
  19547. /**
  19548. * This function is called by the two RIG cameras.
  19549. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19550. * @hidden
  19551. */
  19552. _getWebVRViewMatrix(): Matrix;
  19553. /** @hidden */
  19554. _getWebVRProjectionMatrix(): Matrix;
  19555. private _onGamepadConnectedObserver;
  19556. private _onGamepadDisconnectedObserver;
  19557. private _updateCacheWhenTrackingDisabledObserver;
  19558. /**
  19559. * Initializes the controllers and their meshes
  19560. */
  19561. initControllers(): void;
  19562. }
  19563. }
  19564. declare module BABYLON {
  19565. /**
  19566. * Size options for a post process
  19567. */
  19568. export type PostProcessOptions = {
  19569. width: number;
  19570. height: number;
  19571. };
  19572. /**
  19573. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19574. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19575. */
  19576. export class PostProcess {
  19577. /** Name of the PostProcess. */
  19578. name: string;
  19579. /**
  19580. * Gets or sets the unique id of the post process
  19581. */
  19582. uniqueId: number;
  19583. /**
  19584. * Width of the texture to apply the post process on
  19585. */
  19586. width: number;
  19587. /**
  19588. * Height of the texture to apply the post process on
  19589. */
  19590. height: number;
  19591. /**
  19592. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19593. * @hidden
  19594. */
  19595. _outputTexture: Nullable<InternalTexture>;
  19596. /**
  19597. * Sampling mode used by the shader
  19598. * See https://doc.babylonjs.com/classes/3.1/texture
  19599. */
  19600. renderTargetSamplingMode: number;
  19601. /**
  19602. * Clear color to use when screen clearing
  19603. */
  19604. clearColor: Color4;
  19605. /**
  19606. * If the buffer needs to be cleared before applying the post process. (default: true)
  19607. * Should be set to false if shader will overwrite all previous pixels.
  19608. */
  19609. autoClear: boolean;
  19610. /**
  19611. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19612. */
  19613. alphaMode: number;
  19614. /**
  19615. * Sets the setAlphaBlendConstants of the babylon engine
  19616. */
  19617. alphaConstants: Color4;
  19618. /**
  19619. * Animations to be used for the post processing
  19620. */
  19621. animations: Animation[];
  19622. /**
  19623. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19624. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19625. */
  19626. enablePixelPerfectMode: boolean;
  19627. /**
  19628. * Force the postprocess to be applied without taking in account viewport
  19629. */
  19630. forceFullscreenViewport: boolean;
  19631. /**
  19632. * List of inspectable custom properties (used by the Inspector)
  19633. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19634. */
  19635. inspectableCustomProperties: IInspectable[];
  19636. /**
  19637. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19638. *
  19639. * | Value | Type | Description |
  19640. * | ----- | ----------------------------------- | ----------- |
  19641. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19642. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19643. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19644. *
  19645. */
  19646. scaleMode: number;
  19647. /**
  19648. * Force textures to be a power of two (default: false)
  19649. */
  19650. alwaysForcePOT: boolean;
  19651. private _samples;
  19652. /**
  19653. * Number of sample textures (default: 1)
  19654. */
  19655. get samples(): number;
  19656. set samples(n: number);
  19657. /**
  19658. * Modify the scale of the post process to be the same as the viewport (default: false)
  19659. */
  19660. adaptScaleToCurrentViewport: boolean;
  19661. private _camera;
  19662. private _scene;
  19663. private _engine;
  19664. private _options;
  19665. private _reusable;
  19666. private _textureType;
  19667. private _textureFormat;
  19668. /**
  19669. * Smart array of input and output textures for the post process.
  19670. * @hidden
  19671. */
  19672. _textures: SmartArray<InternalTexture>;
  19673. /**
  19674. * The index in _textures that corresponds to the output texture.
  19675. * @hidden
  19676. */
  19677. _currentRenderTextureInd: number;
  19678. private _effect;
  19679. private _samplers;
  19680. private _fragmentUrl;
  19681. private _vertexUrl;
  19682. private _parameters;
  19683. private _scaleRatio;
  19684. protected _indexParameters: any;
  19685. private _shareOutputWithPostProcess;
  19686. private _texelSize;
  19687. private _forcedOutputTexture;
  19688. /**
  19689. * Returns the fragment url or shader name used in the post process.
  19690. * @returns the fragment url or name in the shader store.
  19691. */
  19692. getEffectName(): string;
  19693. /**
  19694. * An event triggered when the postprocess is activated.
  19695. */
  19696. onActivateObservable: Observable<Camera>;
  19697. private _onActivateObserver;
  19698. /**
  19699. * A function that is added to the onActivateObservable
  19700. */
  19701. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19702. /**
  19703. * An event triggered when the postprocess changes its size.
  19704. */
  19705. onSizeChangedObservable: Observable<PostProcess>;
  19706. private _onSizeChangedObserver;
  19707. /**
  19708. * A function that is added to the onSizeChangedObservable
  19709. */
  19710. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19711. /**
  19712. * An event triggered when the postprocess applies its effect.
  19713. */
  19714. onApplyObservable: Observable<Effect>;
  19715. private _onApplyObserver;
  19716. /**
  19717. * A function that is added to the onApplyObservable
  19718. */
  19719. set onApply(callback: (effect: Effect) => void);
  19720. /**
  19721. * An event triggered before rendering the postprocess
  19722. */
  19723. onBeforeRenderObservable: Observable<Effect>;
  19724. private _onBeforeRenderObserver;
  19725. /**
  19726. * A function that is added to the onBeforeRenderObservable
  19727. */
  19728. set onBeforeRender(callback: (effect: Effect) => void);
  19729. /**
  19730. * An event triggered after rendering the postprocess
  19731. */
  19732. onAfterRenderObservable: Observable<Effect>;
  19733. private _onAfterRenderObserver;
  19734. /**
  19735. * A function that is added to the onAfterRenderObservable
  19736. */
  19737. set onAfterRender(callback: (efect: Effect) => void);
  19738. /**
  19739. * 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
  19740. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19741. */
  19742. get inputTexture(): InternalTexture;
  19743. set inputTexture(value: InternalTexture);
  19744. /**
  19745. * Gets the camera which post process is applied to.
  19746. * @returns The camera the post process is applied to.
  19747. */
  19748. getCamera(): Camera;
  19749. /**
  19750. * Gets the texel size of the postprocess.
  19751. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19752. */
  19753. get texelSize(): Vector2;
  19754. /**
  19755. * Creates a new instance PostProcess
  19756. * @param name The name of the PostProcess.
  19757. * @param fragmentUrl The url of the fragment shader to be used.
  19758. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19759. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19760. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19761. * @param camera The camera to apply the render pass to.
  19762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19763. * @param engine The engine which the post process will be applied. (default: current engine)
  19764. * @param reusable If the post process can be reused on the same frame. (default: false)
  19765. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19766. * @param textureType Type of textures used when performing the post process. (default: 0)
  19767. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19768. * @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
  19769. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19770. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19771. */
  19772. constructor(
  19773. /** Name of the PostProcess. */
  19774. 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);
  19775. /**
  19776. * Gets a string idenfifying the name of the class
  19777. * @returns "PostProcess" string
  19778. */
  19779. getClassName(): string;
  19780. /**
  19781. * Gets the engine which this post process belongs to.
  19782. * @returns The engine the post process was enabled with.
  19783. */
  19784. getEngine(): Engine;
  19785. /**
  19786. * The effect that is created when initializing the post process.
  19787. * @returns The created effect corresponding the the postprocess.
  19788. */
  19789. getEffect(): Effect;
  19790. /**
  19791. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19792. * @param postProcess The post process to share the output with.
  19793. * @returns This post process.
  19794. */
  19795. shareOutputWith(postProcess: PostProcess): PostProcess;
  19796. /**
  19797. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19798. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19799. */
  19800. useOwnOutput(): void;
  19801. /**
  19802. * Updates the effect with the current post process compile time values and recompiles the shader.
  19803. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19804. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19805. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19806. * @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
  19807. * @param onCompiled Called when the shader has been compiled.
  19808. * @param onError Called if there is an error when compiling a shader.
  19809. */
  19810. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19811. /**
  19812. * The post process is reusable if it can be used multiple times within one frame.
  19813. * @returns If the post process is reusable
  19814. */
  19815. isReusable(): boolean;
  19816. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19817. markTextureDirty(): void;
  19818. /**
  19819. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19820. * 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.
  19821. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19822. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19823. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19824. * @returns The target texture that was bound to be written to.
  19825. */
  19826. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19827. /**
  19828. * If the post process is supported.
  19829. */
  19830. get isSupported(): boolean;
  19831. /**
  19832. * The aspect ratio of the output texture.
  19833. */
  19834. get aspectRatio(): number;
  19835. /**
  19836. * Get a value indicating if the post-process is ready to be used
  19837. * @returns true if the post-process is ready (shader is compiled)
  19838. */
  19839. isReady(): boolean;
  19840. /**
  19841. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19842. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19843. */
  19844. apply(): Nullable<Effect>;
  19845. private _disposeTextures;
  19846. /**
  19847. * Disposes the post process.
  19848. * @param camera The camera to dispose the post process on.
  19849. */
  19850. dispose(camera?: Camera): void;
  19851. }
  19852. }
  19853. declare module BABYLON {
  19854. /** @hidden */
  19855. export var kernelBlurVaryingDeclaration: {
  19856. name: string;
  19857. shader: string;
  19858. };
  19859. }
  19860. declare module BABYLON {
  19861. /** @hidden */
  19862. export var kernelBlurFragment: {
  19863. name: string;
  19864. shader: string;
  19865. };
  19866. }
  19867. declare module BABYLON {
  19868. /** @hidden */
  19869. export var kernelBlurFragment2: {
  19870. name: string;
  19871. shader: string;
  19872. };
  19873. }
  19874. declare module BABYLON {
  19875. /** @hidden */
  19876. export var kernelBlurPixelShader: {
  19877. name: string;
  19878. shader: string;
  19879. };
  19880. }
  19881. declare module BABYLON {
  19882. /** @hidden */
  19883. export var kernelBlurVertex: {
  19884. name: string;
  19885. shader: string;
  19886. };
  19887. }
  19888. declare module BABYLON {
  19889. /** @hidden */
  19890. export var kernelBlurVertexShader: {
  19891. name: string;
  19892. shader: string;
  19893. };
  19894. }
  19895. declare module BABYLON {
  19896. /**
  19897. * The Blur Post Process which blurs an image based on a kernel and direction.
  19898. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19899. */
  19900. export class BlurPostProcess extends PostProcess {
  19901. /** The direction in which to blur the image. */
  19902. direction: Vector2;
  19903. private blockCompilation;
  19904. protected _kernel: number;
  19905. protected _idealKernel: number;
  19906. protected _packedFloat: boolean;
  19907. private _staticDefines;
  19908. /**
  19909. * Sets the length in pixels of the blur sample region
  19910. */
  19911. set kernel(v: number);
  19912. /**
  19913. * Gets the length in pixels of the blur sample region
  19914. */
  19915. get kernel(): number;
  19916. /**
  19917. * Sets wether or not the blur needs to unpack/repack floats
  19918. */
  19919. set packedFloat(v: boolean);
  19920. /**
  19921. * Gets wether or not the blur is unpacking/repacking floats
  19922. */
  19923. get packedFloat(): boolean;
  19924. /**
  19925. * Creates a new instance BlurPostProcess
  19926. * @param name The name of the effect.
  19927. * @param direction The direction in which to blur the image.
  19928. * @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.
  19929. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19930. * @param camera The camera to apply the render pass to.
  19931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19932. * @param engine The engine which the post process will be applied. (default: current engine)
  19933. * @param reusable If the post process can be reused on the same frame. (default: false)
  19934. * @param textureType Type of textures used when performing the post process. (default: 0)
  19935. * @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)
  19936. */
  19937. constructor(name: string,
  19938. /** The direction in which to blur the image. */
  19939. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19940. /**
  19941. * Updates the effect with the current post process compile time values and recompiles the shader.
  19942. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19943. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19944. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19945. * @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
  19946. * @param onCompiled Called when the shader has been compiled.
  19947. * @param onError Called if there is an error when compiling a shader.
  19948. */
  19949. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19950. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19951. /**
  19952. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19953. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19954. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19955. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19956. * The gaps between physical kernels are compensated for in the weighting of the samples
  19957. * @param idealKernel Ideal blur kernel.
  19958. * @return Nearest best kernel.
  19959. */
  19960. protected _nearestBestKernel(idealKernel: number): number;
  19961. /**
  19962. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19963. * @param x The point on the Gaussian distribution to sample.
  19964. * @return the value of the Gaussian function at x.
  19965. */
  19966. protected _gaussianWeight(x: number): number;
  19967. /**
  19968. * Generates a string that can be used as a floating point number in GLSL.
  19969. * @param x Value to print.
  19970. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19971. * @return GLSL float string.
  19972. */
  19973. protected _glslFloat(x: number, decimalFigures?: number): string;
  19974. }
  19975. }
  19976. declare module BABYLON {
  19977. /**
  19978. * Mirror texture can be used to simulate the view from a mirror in a scene.
  19979. * It will dynamically be rendered every frame to adapt to the camera point of view.
  19980. * You can then easily use it as a reflectionTexture on a flat surface.
  19981. * In case the surface is not a plane, please consider relying on reflection probes.
  19982. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19983. */
  19984. export class MirrorTexture extends RenderTargetTexture {
  19985. private scene;
  19986. /**
  19987. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  19988. * 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.
  19989. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19990. */
  19991. mirrorPlane: Plane;
  19992. /**
  19993. * Define the blur ratio used to blur the reflection if needed.
  19994. */
  19995. set blurRatio(value: number);
  19996. get blurRatio(): number;
  19997. /**
  19998. * Define the adaptive blur kernel used to blur the reflection if needed.
  19999. * This will autocompute the closest best match for the `blurKernel`
  20000. */
  20001. set adaptiveBlurKernel(value: number);
  20002. /**
  20003. * Define the blur kernel used to blur the reflection if needed.
  20004. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20005. */
  20006. set blurKernel(value: number);
  20007. /**
  20008. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20009. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20010. */
  20011. set blurKernelX(value: number);
  20012. get blurKernelX(): number;
  20013. /**
  20014. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20015. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20016. */
  20017. set blurKernelY(value: number);
  20018. get blurKernelY(): number;
  20019. private _autoComputeBlurKernel;
  20020. protected _onRatioRescale(): void;
  20021. private _updateGammaSpace;
  20022. private _imageProcessingConfigChangeObserver;
  20023. private _transformMatrix;
  20024. private _mirrorMatrix;
  20025. private _savedViewMatrix;
  20026. private _blurX;
  20027. private _blurY;
  20028. private _adaptiveBlurKernel;
  20029. private _blurKernelX;
  20030. private _blurKernelY;
  20031. private _blurRatio;
  20032. /**
  20033. * Instantiates a Mirror Texture.
  20034. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20035. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20036. * You can then easily use it as a reflectionTexture on a flat surface.
  20037. * In case the surface is not a plane, please consider relying on reflection probes.
  20038. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20039. * @param name
  20040. * @param size
  20041. * @param scene
  20042. * @param generateMipMaps
  20043. * @param type
  20044. * @param samplingMode
  20045. * @param generateDepthBuffer
  20046. */
  20047. constructor(name: string, size: number | {
  20048. width: number;
  20049. height: number;
  20050. } | {
  20051. ratio: number;
  20052. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20053. private _preparePostProcesses;
  20054. /**
  20055. * Clone the mirror texture.
  20056. * @returns the cloned texture
  20057. */
  20058. clone(): MirrorTexture;
  20059. /**
  20060. * Serialize the texture to a JSON representation you could use in Parse later on
  20061. * @returns the serialized JSON representation
  20062. */
  20063. serialize(): any;
  20064. /**
  20065. * Dispose the texture and release its associated resources.
  20066. */
  20067. dispose(): void;
  20068. }
  20069. }
  20070. declare module BABYLON {
  20071. /**
  20072. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20073. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20074. */
  20075. export class Texture extends BaseTexture {
  20076. /**
  20077. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20078. */
  20079. static SerializeBuffers: boolean;
  20080. /** @hidden */
  20081. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20082. /** @hidden */
  20083. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20084. /** @hidden */
  20085. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20086. /** nearest is mag = nearest and min = nearest and mip = linear */
  20087. static readonly NEAREST_SAMPLINGMODE: number;
  20088. /** nearest is mag = nearest and min = nearest and mip = linear */
  20089. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20090. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20091. static readonly BILINEAR_SAMPLINGMODE: number;
  20092. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20093. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20094. /** Trilinear is mag = linear and min = linear and mip = linear */
  20095. static readonly TRILINEAR_SAMPLINGMODE: number;
  20096. /** Trilinear is mag = linear and min = linear and mip = linear */
  20097. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20098. /** mag = nearest and min = nearest and mip = nearest */
  20099. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20100. /** mag = nearest and min = linear and mip = nearest */
  20101. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20102. /** mag = nearest and min = linear and mip = linear */
  20103. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20104. /** mag = nearest and min = linear and mip = none */
  20105. static readonly NEAREST_LINEAR: number;
  20106. /** mag = nearest and min = nearest and mip = none */
  20107. static readonly NEAREST_NEAREST: number;
  20108. /** mag = linear and min = nearest and mip = nearest */
  20109. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20110. /** mag = linear and min = nearest and mip = linear */
  20111. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20112. /** mag = linear and min = linear and mip = none */
  20113. static readonly LINEAR_LINEAR: number;
  20114. /** mag = linear and min = nearest and mip = none */
  20115. static readonly LINEAR_NEAREST: number;
  20116. /** Explicit coordinates mode */
  20117. static readonly EXPLICIT_MODE: number;
  20118. /** Spherical coordinates mode */
  20119. static readonly SPHERICAL_MODE: number;
  20120. /** Planar coordinates mode */
  20121. static readonly PLANAR_MODE: number;
  20122. /** Cubic coordinates mode */
  20123. static readonly CUBIC_MODE: number;
  20124. /** Projection coordinates mode */
  20125. static readonly PROJECTION_MODE: number;
  20126. /** Inverse Cubic coordinates mode */
  20127. static readonly SKYBOX_MODE: number;
  20128. /** Inverse Cubic coordinates mode */
  20129. static readonly INVCUBIC_MODE: number;
  20130. /** Equirectangular coordinates mode */
  20131. static readonly EQUIRECTANGULAR_MODE: number;
  20132. /** Equirectangular Fixed coordinates mode */
  20133. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20134. /** Equirectangular Fixed Mirrored coordinates mode */
  20135. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20136. /** Texture is not repeating outside of 0..1 UVs */
  20137. static readonly CLAMP_ADDRESSMODE: number;
  20138. /** Texture is repeating outside of 0..1 UVs */
  20139. static readonly WRAP_ADDRESSMODE: number;
  20140. /** Texture is repeating and mirrored */
  20141. static readonly MIRROR_ADDRESSMODE: number;
  20142. /**
  20143. * 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
  20144. */
  20145. static UseSerializedUrlIfAny: boolean;
  20146. /**
  20147. * Define the url of the texture.
  20148. */
  20149. url: Nullable<string>;
  20150. /**
  20151. * Define an offset on the texture to offset the u coordinates of the UVs
  20152. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20153. */
  20154. uOffset: number;
  20155. /**
  20156. * Define an offset on the texture to offset the v coordinates of the UVs
  20157. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20158. */
  20159. vOffset: number;
  20160. /**
  20161. * Define an offset on the texture to scale the u coordinates of the UVs
  20162. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20163. */
  20164. uScale: number;
  20165. /**
  20166. * Define an offset on the texture to scale the v coordinates of the UVs
  20167. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20168. */
  20169. vScale: number;
  20170. /**
  20171. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20172. * @see http://doc.babylonjs.com/how_to/more_materials
  20173. */
  20174. uAng: number;
  20175. /**
  20176. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20177. * @see http://doc.babylonjs.com/how_to/more_materials
  20178. */
  20179. vAng: number;
  20180. /**
  20181. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20182. * @see http://doc.babylonjs.com/how_to/more_materials
  20183. */
  20184. wAng: number;
  20185. /**
  20186. * Defines the center of rotation (U)
  20187. */
  20188. uRotationCenter: number;
  20189. /**
  20190. * Defines the center of rotation (V)
  20191. */
  20192. vRotationCenter: number;
  20193. /**
  20194. * Defines the center of rotation (W)
  20195. */
  20196. wRotationCenter: number;
  20197. /**
  20198. * Are mip maps generated for this texture or not.
  20199. */
  20200. get noMipmap(): boolean;
  20201. /**
  20202. * List of inspectable custom properties (used by the Inspector)
  20203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20204. */
  20205. inspectableCustomProperties: Nullable<IInspectable[]>;
  20206. private _noMipmap;
  20207. /** @hidden */
  20208. _invertY: boolean;
  20209. private _rowGenerationMatrix;
  20210. private _cachedTextureMatrix;
  20211. private _projectionModeMatrix;
  20212. private _t0;
  20213. private _t1;
  20214. private _t2;
  20215. private _cachedUOffset;
  20216. private _cachedVOffset;
  20217. private _cachedUScale;
  20218. private _cachedVScale;
  20219. private _cachedUAng;
  20220. private _cachedVAng;
  20221. private _cachedWAng;
  20222. private _cachedProjectionMatrixId;
  20223. private _cachedCoordinatesMode;
  20224. /** @hidden */
  20225. protected _initialSamplingMode: number;
  20226. /** @hidden */
  20227. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20228. private _deleteBuffer;
  20229. protected _format: Nullable<number>;
  20230. private _delayedOnLoad;
  20231. private _delayedOnError;
  20232. private _mimeType?;
  20233. /**
  20234. * Observable triggered once the texture has been loaded.
  20235. */
  20236. onLoadObservable: Observable<Texture>;
  20237. protected _isBlocking: boolean;
  20238. /**
  20239. * Is the texture preventing material to render while loading.
  20240. * If false, a default texture will be used instead of the loading one during the preparation step.
  20241. */
  20242. set isBlocking(value: boolean);
  20243. get isBlocking(): boolean;
  20244. /**
  20245. * Get the current sampling mode associated with the texture.
  20246. */
  20247. get samplingMode(): number;
  20248. /**
  20249. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20250. */
  20251. get invertY(): boolean;
  20252. /**
  20253. * Instantiates a new texture.
  20254. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20255. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20256. * @param url defines the url of the picture to load as a texture
  20257. * @param scene defines the scene or engine the texture will belong to
  20258. * @param noMipmap defines if the texture will require mip maps or not
  20259. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20260. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20261. * @param onLoad defines a callback triggered when the texture has been loaded
  20262. * @param onError defines a callback triggered when an error occurred during the loading session
  20263. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20264. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20265. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20266. * @param mimeType defines an optional mime type information
  20267. */
  20268. 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);
  20269. /**
  20270. * Update the url (and optional buffer) of this texture if url was null during construction.
  20271. * @param url the url of the texture
  20272. * @param buffer the buffer of the texture (defaults to null)
  20273. * @param onLoad callback called when the texture is loaded (defaults to null)
  20274. */
  20275. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20276. /**
  20277. * Finish the loading sequence of a texture flagged as delayed load.
  20278. * @hidden
  20279. */
  20280. delayLoad(): void;
  20281. private _prepareRowForTextureGeneration;
  20282. /**
  20283. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20284. * @returns the transform matrix of the texture.
  20285. */
  20286. getTextureMatrix(uBase?: number): Matrix;
  20287. /**
  20288. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20289. * @returns The reflection texture transform
  20290. */
  20291. getReflectionTextureMatrix(): Matrix;
  20292. /**
  20293. * Clones the texture.
  20294. * @returns the cloned texture
  20295. */
  20296. clone(): Texture;
  20297. /**
  20298. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20299. * @returns The JSON representation of the texture
  20300. */
  20301. serialize(): any;
  20302. /**
  20303. * Get the current class name of the texture useful for serialization or dynamic coding.
  20304. * @returns "Texture"
  20305. */
  20306. getClassName(): string;
  20307. /**
  20308. * Dispose the texture and release its associated resources.
  20309. */
  20310. dispose(): void;
  20311. /**
  20312. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20313. * @param parsedTexture Define the JSON representation of the texture
  20314. * @param scene Define the scene the parsed texture should be instantiated in
  20315. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20316. * @returns The parsed texture if successful
  20317. */
  20318. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20319. /**
  20320. * Creates a texture from its base 64 representation.
  20321. * @param data Define the base64 payload without the data: prefix
  20322. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20323. * @param scene Define the scene the texture should belong to
  20324. * @param noMipmap Forces the texture to not create mip map information if true
  20325. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20326. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20327. * @param onLoad define a callback triggered when the texture has been loaded
  20328. * @param onError define a callback triggered when an error occurred during the loading session
  20329. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20330. * @returns the created texture
  20331. */
  20332. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20333. /**
  20334. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20335. * @param data Define the base64 payload without the data: prefix
  20336. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20337. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20338. * @param scene Define the scene the texture should belong to
  20339. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20340. * @param noMipmap Forces the texture to not create mip map information if true
  20341. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20342. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20343. * @param onLoad define a callback triggered when the texture has been loaded
  20344. * @param onError define a callback triggered when an error occurred during the loading session
  20345. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20346. * @returns the created texture
  20347. */
  20348. 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;
  20349. }
  20350. }
  20351. declare module BABYLON {
  20352. /**
  20353. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20354. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20355. */
  20356. export class PostProcessManager {
  20357. private _scene;
  20358. private _indexBuffer;
  20359. private _vertexBuffers;
  20360. /**
  20361. * Creates a new instance PostProcess
  20362. * @param scene The scene that the post process is associated with.
  20363. */
  20364. constructor(scene: Scene);
  20365. private _prepareBuffers;
  20366. private _buildIndexBuffer;
  20367. /**
  20368. * Rebuilds the vertex buffers of the manager.
  20369. * @hidden
  20370. */
  20371. _rebuild(): void;
  20372. /**
  20373. * Prepares a frame to be run through a post process.
  20374. * @param sourceTexture The input texture to the post procesess. (default: null)
  20375. * @param postProcesses An array of post processes to be run. (default: null)
  20376. * @returns True if the post processes were able to be run.
  20377. * @hidden
  20378. */
  20379. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20380. /**
  20381. * Manually render a set of post processes to a texture.
  20382. * @param postProcesses An array of post processes to be run.
  20383. * @param targetTexture The target texture to render to.
  20384. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20385. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20386. * @param lodLevel defines which lod of the texture to render to
  20387. */
  20388. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20389. /**
  20390. * Finalize the result of the output of the postprocesses.
  20391. * @param doNotPresent If true the result will not be displayed to the screen.
  20392. * @param targetTexture The target texture to render to.
  20393. * @param faceIndex The index of the face to bind the target texture to.
  20394. * @param postProcesses The array of post processes to render.
  20395. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20396. * @hidden
  20397. */
  20398. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20399. /**
  20400. * Disposes of the post process manager.
  20401. */
  20402. dispose(): void;
  20403. }
  20404. }
  20405. declare module BABYLON {
  20406. /**
  20407. * This Helps creating a texture that will be created from a camera in your scene.
  20408. * It is basically a dynamic texture that could be used to create special effects for instance.
  20409. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20410. */
  20411. export class RenderTargetTexture extends Texture {
  20412. isCube: boolean;
  20413. /**
  20414. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20415. */
  20416. static readonly REFRESHRATE_RENDER_ONCE: number;
  20417. /**
  20418. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20419. */
  20420. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20421. /**
  20422. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20423. * the central point of your effect and can save a lot of performances.
  20424. */
  20425. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20426. /**
  20427. * Use this predicate to dynamically define the list of mesh you want to render.
  20428. * If set, the renderList property will be overwritten.
  20429. */
  20430. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20431. private _renderList;
  20432. /**
  20433. * Use this list to define the list of mesh you want to render.
  20434. */
  20435. get renderList(): Nullable<Array<AbstractMesh>>;
  20436. set renderList(value: Nullable<Array<AbstractMesh>>);
  20437. /**
  20438. * Use this function to overload the renderList array at rendering time.
  20439. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20440. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20441. * the cube (if the RTT is a cube, else layerOrFace=0).
  20442. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20443. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20444. * hold dummy elements!
  20445. */
  20446. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20447. private _hookArray;
  20448. /**
  20449. * Define if particles should be rendered in your texture.
  20450. */
  20451. renderParticles: boolean;
  20452. /**
  20453. * Define if sprites should be rendered in your texture.
  20454. */
  20455. renderSprites: boolean;
  20456. /**
  20457. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20458. */
  20459. coordinatesMode: number;
  20460. /**
  20461. * Define the camera used to render the texture.
  20462. */
  20463. activeCamera: Nullable<Camera>;
  20464. /**
  20465. * Override the render function of the texture with your own one.
  20466. */
  20467. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20468. /**
  20469. * Define if camera post processes should be use while rendering the texture.
  20470. */
  20471. useCameraPostProcesses: boolean;
  20472. /**
  20473. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20474. */
  20475. ignoreCameraViewport: boolean;
  20476. private _postProcessManager;
  20477. private _postProcesses;
  20478. private _resizeObserver;
  20479. /**
  20480. * An event triggered when the texture is unbind.
  20481. */
  20482. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20483. /**
  20484. * An event triggered when the texture is unbind.
  20485. */
  20486. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20487. private _onAfterUnbindObserver;
  20488. /**
  20489. * Set a after unbind callback in the texture.
  20490. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20491. */
  20492. set onAfterUnbind(callback: () => void);
  20493. /**
  20494. * An event triggered before rendering the texture
  20495. */
  20496. onBeforeRenderObservable: Observable<number>;
  20497. private _onBeforeRenderObserver;
  20498. /**
  20499. * Set a before render callback in the texture.
  20500. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20501. */
  20502. set onBeforeRender(callback: (faceIndex: number) => void);
  20503. /**
  20504. * An event triggered after rendering the texture
  20505. */
  20506. onAfterRenderObservable: Observable<number>;
  20507. private _onAfterRenderObserver;
  20508. /**
  20509. * Set a after render callback in the texture.
  20510. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20511. */
  20512. set onAfterRender(callback: (faceIndex: number) => void);
  20513. /**
  20514. * An event triggered after the texture clear
  20515. */
  20516. onClearObservable: Observable<Engine>;
  20517. private _onClearObserver;
  20518. /**
  20519. * Set a clear callback in the texture.
  20520. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20521. */
  20522. set onClear(callback: (Engine: Engine) => void);
  20523. /**
  20524. * An event triggered when the texture is resized.
  20525. */
  20526. onResizeObservable: Observable<RenderTargetTexture>;
  20527. /**
  20528. * Define the clear color of the Render Target if it should be different from the scene.
  20529. */
  20530. clearColor: Color4;
  20531. protected _size: number | {
  20532. width: number;
  20533. height: number;
  20534. layers?: number;
  20535. };
  20536. protected _initialSizeParameter: number | {
  20537. width: number;
  20538. height: number;
  20539. } | {
  20540. ratio: number;
  20541. };
  20542. protected _sizeRatio: Nullable<number>;
  20543. /** @hidden */
  20544. _generateMipMaps: boolean;
  20545. protected _renderingManager: RenderingManager;
  20546. /** @hidden */
  20547. _waitingRenderList: string[];
  20548. protected _doNotChangeAspectRatio: boolean;
  20549. protected _currentRefreshId: number;
  20550. protected _refreshRate: number;
  20551. protected _textureMatrix: Matrix;
  20552. protected _samples: number;
  20553. protected _renderTargetOptions: RenderTargetCreationOptions;
  20554. /**
  20555. * Gets render target creation options that were used.
  20556. */
  20557. get renderTargetOptions(): RenderTargetCreationOptions;
  20558. protected _engine: Engine;
  20559. protected _onRatioRescale(): void;
  20560. /**
  20561. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20562. * It must define where the camera used to render the texture is set
  20563. */
  20564. boundingBoxPosition: Vector3;
  20565. private _boundingBoxSize;
  20566. /**
  20567. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20568. * When defined, the cubemap will switch to local mode
  20569. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20570. * @example https://www.babylonjs-playground.com/#RNASML
  20571. */
  20572. set boundingBoxSize(value: Vector3);
  20573. get boundingBoxSize(): Vector3;
  20574. /**
  20575. * In case the RTT has been created with a depth texture, get the associated
  20576. * depth texture.
  20577. * Otherwise, return null.
  20578. */
  20579. get depthStencilTexture(): Nullable<InternalTexture>;
  20580. /**
  20581. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20582. * or used a shadow, depth texture...
  20583. * @param name The friendly name of the texture
  20584. * @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)
  20585. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20586. * @param generateMipMaps True if mip maps need to be generated after render.
  20587. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20588. * @param type The type of the buffer in the RTT (int, half float, float...)
  20589. * @param isCube True if a cube texture needs to be created
  20590. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20591. * @param generateDepthBuffer True to generate a depth buffer
  20592. * @param generateStencilBuffer True to generate a stencil buffer
  20593. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20594. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20595. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20596. */
  20597. constructor(name: string, size: number | {
  20598. width: number;
  20599. height: number;
  20600. layers?: number;
  20601. } | {
  20602. ratio: number;
  20603. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20604. /**
  20605. * Creates a depth stencil texture.
  20606. * This is only available in WebGL 2 or with the depth texture extension available.
  20607. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20608. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20609. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20610. */
  20611. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20612. private _processSizeParameter;
  20613. /**
  20614. * Define the number of samples to use in case of MSAA.
  20615. * It defaults to one meaning no MSAA has been enabled.
  20616. */
  20617. get samples(): number;
  20618. set samples(value: number);
  20619. /**
  20620. * Resets the refresh counter of the texture and start bak from scratch.
  20621. * Could be useful to regenerate the texture if it is setup to render only once.
  20622. */
  20623. resetRefreshCounter(): void;
  20624. /**
  20625. * Define the refresh rate of the texture or the rendering frequency.
  20626. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20627. */
  20628. get refreshRate(): number;
  20629. set refreshRate(value: number);
  20630. /**
  20631. * Adds a post process to the render target rendering passes.
  20632. * @param postProcess define the post process to add
  20633. */
  20634. addPostProcess(postProcess: PostProcess): void;
  20635. /**
  20636. * Clear all the post processes attached to the render target
  20637. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20638. */
  20639. clearPostProcesses(dispose?: boolean): void;
  20640. /**
  20641. * Remove one of the post process from the list of attached post processes to the texture
  20642. * @param postProcess define the post process to remove from the list
  20643. */
  20644. removePostProcess(postProcess: PostProcess): void;
  20645. /** @hidden */
  20646. _shouldRender(): boolean;
  20647. /**
  20648. * Gets the actual render size of the texture.
  20649. * @returns the width of the render size
  20650. */
  20651. getRenderSize(): number;
  20652. /**
  20653. * Gets the actual render width of the texture.
  20654. * @returns the width of the render size
  20655. */
  20656. getRenderWidth(): number;
  20657. /**
  20658. * Gets the actual render height of the texture.
  20659. * @returns the height of the render size
  20660. */
  20661. getRenderHeight(): number;
  20662. /**
  20663. * Gets the actual number of layers of the texture.
  20664. * @returns the number of layers
  20665. */
  20666. getRenderLayers(): number;
  20667. /**
  20668. * Get if the texture can be rescaled or not.
  20669. */
  20670. get canRescale(): boolean;
  20671. /**
  20672. * Resize the texture using a ratio.
  20673. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20674. */
  20675. scale(ratio: number): void;
  20676. /**
  20677. * Get the texture reflection matrix used to rotate/transform the reflection.
  20678. * @returns the reflection matrix
  20679. */
  20680. getReflectionTextureMatrix(): Matrix;
  20681. /**
  20682. * Resize the texture to a new desired size.
  20683. * Be carrefull as it will recreate all the data in the new texture.
  20684. * @param size Define the new size. It can be:
  20685. * - a number for squared texture,
  20686. * - an object containing { width: number, height: number }
  20687. * - or an object containing a ratio { ratio: number }
  20688. */
  20689. resize(size: number | {
  20690. width: number;
  20691. height: number;
  20692. } | {
  20693. ratio: number;
  20694. }): void;
  20695. private _defaultRenderListPrepared;
  20696. /**
  20697. * Renders all the objects from the render list into the texture.
  20698. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20699. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20700. */
  20701. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20702. private _bestReflectionRenderTargetDimension;
  20703. private _prepareRenderingManager;
  20704. /**
  20705. * @hidden
  20706. * @param faceIndex face index to bind to if this is a cubetexture
  20707. * @param layer defines the index of the texture to bind in the array
  20708. */
  20709. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20710. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20711. private renderToTarget;
  20712. /**
  20713. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20714. * This allowed control for front to back rendering or reversly depending of the special needs.
  20715. *
  20716. * @param renderingGroupId The rendering group id corresponding to its index
  20717. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20718. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20719. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20720. */
  20721. 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;
  20722. /**
  20723. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20724. *
  20725. * @param renderingGroupId The rendering group id corresponding to its index
  20726. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20727. */
  20728. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20729. /**
  20730. * Clones the texture.
  20731. * @returns the cloned texture
  20732. */
  20733. clone(): RenderTargetTexture;
  20734. /**
  20735. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20736. * @returns The JSON representation of the texture
  20737. */
  20738. serialize(): any;
  20739. /**
  20740. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20741. */
  20742. disposeFramebufferObjects(): void;
  20743. /**
  20744. * Dispose the texture and release its associated resources.
  20745. */
  20746. dispose(): void;
  20747. /** @hidden */
  20748. _rebuild(): void;
  20749. /**
  20750. * Clear the info related to rendering groups preventing retention point in material dispose.
  20751. */
  20752. freeRenderingGroups(): void;
  20753. /**
  20754. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20755. * @returns the view count
  20756. */
  20757. getViewCount(): number;
  20758. }
  20759. }
  20760. declare module BABYLON {
  20761. /**
  20762. * Options for compiling materials.
  20763. */
  20764. export interface IMaterialCompilationOptions {
  20765. /**
  20766. * Defines whether clip planes are enabled.
  20767. */
  20768. clipPlane: boolean;
  20769. /**
  20770. * Defines whether instances are enabled.
  20771. */
  20772. useInstances: boolean;
  20773. }
  20774. /**
  20775. * Base class for the main features of a material in Babylon.js
  20776. */
  20777. export class Material implements IAnimatable {
  20778. /**
  20779. * Returns the triangle fill mode
  20780. */
  20781. static readonly TriangleFillMode: number;
  20782. /**
  20783. * Returns the wireframe mode
  20784. */
  20785. static readonly WireFrameFillMode: number;
  20786. /**
  20787. * Returns the point fill mode
  20788. */
  20789. static readonly PointFillMode: number;
  20790. /**
  20791. * Returns the point list draw mode
  20792. */
  20793. static readonly PointListDrawMode: number;
  20794. /**
  20795. * Returns the line list draw mode
  20796. */
  20797. static readonly LineListDrawMode: number;
  20798. /**
  20799. * Returns the line loop draw mode
  20800. */
  20801. static readonly LineLoopDrawMode: number;
  20802. /**
  20803. * Returns the line strip draw mode
  20804. */
  20805. static readonly LineStripDrawMode: number;
  20806. /**
  20807. * Returns the triangle strip draw mode
  20808. */
  20809. static readonly TriangleStripDrawMode: number;
  20810. /**
  20811. * Returns the triangle fan draw mode
  20812. */
  20813. static readonly TriangleFanDrawMode: number;
  20814. /**
  20815. * Stores the clock-wise side orientation
  20816. */
  20817. static readonly ClockWiseSideOrientation: number;
  20818. /**
  20819. * Stores the counter clock-wise side orientation
  20820. */
  20821. static readonly CounterClockWiseSideOrientation: number;
  20822. /**
  20823. * The dirty texture flag value
  20824. */
  20825. static readonly TextureDirtyFlag: number;
  20826. /**
  20827. * The dirty light flag value
  20828. */
  20829. static readonly LightDirtyFlag: number;
  20830. /**
  20831. * The dirty fresnel flag value
  20832. */
  20833. static readonly FresnelDirtyFlag: number;
  20834. /**
  20835. * The dirty attribute flag value
  20836. */
  20837. static readonly AttributesDirtyFlag: number;
  20838. /**
  20839. * The dirty misc flag value
  20840. */
  20841. static readonly MiscDirtyFlag: number;
  20842. /**
  20843. * The all dirty flag value
  20844. */
  20845. static readonly AllDirtyFlag: number;
  20846. /**
  20847. * The ID of the material
  20848. */
  20849. id: string;
  20850. /**
  20851. * Gets or sets the unique id of the material
  20852. */
  20853. uniqueId: number;
  20854. /**
  20855. * The name of the material
  20856. */
  20857. name: string;
  20858. /**
  20859. * Gets or sets user defined metadata
  20860. */
  20861. metadata: any;
  20862. /**
  20863. * For internal use only. Please do not use.
  20864. */
  20865. reservedDataStore: any;
  20866. /**
  20867. * Specifies if the ready state should be checked on each call
  20868. */
  20869. checkReadyOnEveryCall: boolean;
  20870. /**
  20871. * Specifies if the ready state should be checked once
  20872. */
  20873. checkReadyOnlyOnce: boolean;
  20874. /**
  20875. * The state of the material
  20876. */
  20877. state: string;
  20878. /**
  20879. * The alpha value of the material
  20880. */
  20881. protected _alpha: number;
  20882. /**
  20883. * List of inspectable custom properties (used by the Inspector)
  20884. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20885. */
  20886. inspectableCustomProperties: IInspectable[];
  20887. /**
  20888. * Sets the alpha value of the material
  20889. */
  20890. set alpha(value: number);
  20891. /**
  20892. * Gets the alpha value of the material
  20893. */
  20894. get alpha(): number;
  20895. /**
  20896. * Specifies if back face culling is enabled
  20897. */
  20898. protected _backFaceCulling: boolean;
  20899. /**
  20900. * Sets the back-face culling state
  20901. */
  20902. set backFaceCulling(value: boolean);
  20903. /**
  20904. * Gets the back-face culling state
  20905. */
  20906. get backFaceCulling(): boolean;
  20907. /**
  20908. * Stores the value for side orientation
  20909. */
  20910. sideOrientation: number;
  20911. /**
  20912. * Callback triggered when the material is compiled
  20913. */
  20914. onCompiled: Nullable<(effect: Effect) => void>;
  20915. /**
  20916. * Callback triggered when an error occurs
  20917. */
  20918. onError: Nullable<(effect: Effect, errors: string) => void>;
  20919. /**
  20920. * Callback triggered to get the render target textures
  20921. */
  20922. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20923. /**
  20924. * Gets a boolean indicating that current material needs to register RTT
  20925. */
  20926. get hasRenderTargetTextures(): boolean;
  20927. /**
  20928. * Specifies if the material should be serialized
  20929. */
  20930. doNotSerialize: boolean;
  20931. /**
  20932. * @hidden
  20933. */
  20934. _storeEffectOnSubMeshes: boolean;
  20935. /**
  20936. * Stores the animations for the material
  20937. */
  20938. animations: Nullable<Array<Animation>>;
  20939. /**
  20940. * An event triggered when the material is disposed
  20941. */
  20942. onDisposeObservable: Observable<Material>;
  20943. /**
  20944. * An observer which watches for dispose events
  20945. */
  20946. private _onDisposeObserver;
  20947. private _onUnBindObservable;
  20948. /**
  20949. * Called during a dispose event
  20950. */
  20951. set onDispose(callback: () => void);
  20952. private _onBindObservable;
  20953. /**
  20954. * An event triggered when the material is bound
  20955. */
  20956. get onBindObservable(): Observable<AbstractMesh>;
  20957. /**
  20958. * An observer which watches for bind events
  20959. */
  20960. private _onBindObserver;
  20961. /**
  20962. * Called during a bind event
  20963. */
  20964. set onBind(callback: (Mesh: AbstractMesh) => void);
  20965. /**
  20966. * An event triggered when the material is unbound
  20967. */
  20968. get onUnBindObservable(): Observable<Material>;
  20969. /**
  20970. * Stores the value of the alpha mode
  20971. */
  20972. private _alphaMode;
  20973. /**
  20974. * Sets the value of the alpha mode.
  20975. *
  20976. * | Value | Type | Description |
  20977. * | --- | --- | --- |
  20978. * | 0 | ALPHA_DISABLE | |
  20979. * | 1 | ALPHA_ADD | |
  20980. * | 2 | ALPHA_COMBINE | |
  20981. * | 3 | ALPHA_SUBTRACT | |
  20982. * | 4 | ALPHA_MULTIPLY | |
  20983. * | 5 | ALPHA_MAXIMIZED | |
  20984. * | 6 | ALPHA_ONEONE | |
  20985. * | 7 | ALPHA_PREMULTIPLIED | |
  20986. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20987. * | 9 | ALPHA_INTERPOLATE | |
  20988. * | 10 | ALPHA_SCREENMODE | |
  20989. *
  20990. */
  20991. set alphaMode(value: number);
  20992. /**
  20993. * Gets the value of the alpha mode
  20994. */
  20995. get alphaMode(): number;
  20996. /**
  20997. * Stores the state of the need depth pre-pass value
  20998. */
  20999. private _needDepthPrePass;
  21000. /**
  21001. * Sets the need depth pre-pass value
  21002. */
  21003. set needDepthPrePass(value: boolean);
  21004. /**
  21005. * Gets the depth pre-pass value
  21006. */
  21007. get needDepthPrePass(): boolean;
  21008. /**
  21009. * Specifies if depth writing should be disabled
  21010. */
  21011. disableDepthWrite: boolean;
  21012. /**
  21013. * Specifies if depth writing should be forced
  21014. */
  21015. forceDepthWrite: boolean;
  21016. /**
  21017. * Specifies the depth function that should be used. 0 means the default engine function
  21018. */
  21019. depthFunction: number;
  21020. /**
  21021. * Specifies if there should be a separate pass for culling
  21022. */
  21023. separateCullingPass: boolean;
  21024. /**
  21025. * Stores the state specifing if fog should be enabled
  21026. */
  21027. private _fogEnabled;
  21028. /**
  21029. * Sets the state for enabling fog
  21030. */
  21031. set fogEnabled(value: boolean);
  21032. /**
  21033. * Gets the value of the fog enabled state
  21034. */
  21035. get fogEnabled(): boolean;
  21036. /**
  21037. * Stores the size of points
  21038. */
  21039. pointSize: number;
  21040. /**
  21041. * Stores the z offset value
  21042. */
  21043. zOffset: number;
  21044. /**
  21045. * Gets a value specifying if wireframe mode is enabled
  21046. */
  21047. get wireframe(): boolean;
  21048. /**
  21049. * Sets the state of wireframe mode
  21050. */
  21051. set wireframe(value: boolean);
  21052. /**
  21053. * Gets the value specifying if point clouds are enabled
  21054. */
  21055. get pointsCloud(): boolean;
  21056. /**
  21057. * Sets the state of point cloud mode
  21058. */
  21059. set pointsCloud(value: boolean);
  21060. /**
  21061. * Gets the material fill mode
  21062. */
  21063. get fillMode(): number;
  21064. /**
  21065. * Sets the material fill mode
  21066. */
  21067. set fillMode(value: number);
  21068. /**
  21069. * @hidden
  21070. * Stores the effects for the material
  21071. */
  21072. _effect: Nullable<Effect>;
  21073. /**
  21074. * Specifies if uniform buffers should be used
  21075. */
  21076. private _useUBO;
  21077. /**
  21078. * Stores a reference to the scene
  21079. */
  21080. private _scene;
  21081. /**
  21082. * Stores the fill mode state
  21083. */
  21084. private _fillMode;
  21085. /**
  21086. * Specifies if the depth write state should be cached
  21087. */
  21088. private _cachedDepthWriteState;
  21089. /**
  21090. * Specifies if the depth function state should be cached
  21091. */
  21092. private _cachedDepthFunctionState;
  21093. /**
  21094. * Stores the uniform buffer
  21095. */
  21096. protected _uniformBuffer: UniformBuffer;
  21097. /** @hidden */
  21098. _indexInSceneMaterialArray: number;
  21099. /** @hidden */
  21100. meshMap: Nullable<{
  21101. [id: string]: AbstractMesh | undefined;
  21102. }>;
  21103. /**
  21104. * Creates a material instance
  21105. * @param name defines the name of the material
  21106. * @param scene defines the scene to reference
  21107. * @param doNotAdd specifies if the material should be added to the scene
  21108. */
  21109. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21110. /**
  21111. * Returns a string representation of the current material
  21112. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21113. * @returns a string with material information
  21114. */
  21115. toString(fullDetails?: boolean): string;
  21116. /**
  21117. * Gets the class name of the material
  21118. * @returns a string with the class name of the material
  21119. */
  21120. getClassName(): string;
  21121. /**
  21122. * Specifies if updates for the material been locked
  21123. */
  21124. get isFrozen(): boolean;
  21125. /**
  21126. * Locks updates for the material
  21127. */
  21128. freeze(): void;
  21129. /**
  21130. * Unlocks updates for the material
  21131. */
  21132. unfreeze(): void;
  21133. /**
  21134. * Specifies if the material is ready to be used
  21135. * @param mesh defines the mesh to check
  21136. * @param useInstances specifies if instances should be used
  21137. * @returns a boolean indicating if the material is ready to be used
  21138. */
  21139. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21140. /**
  21141. * Specifies that the submesh is ready to be used
  21142. * @param mesh defines the mesh to check
  21143. * @param subMesh defines which submesh to check
  21144. * @param useInstances specifies that instances should be used
  21145. * @returns a boolean indicating that the submesh is ready or not
  21146. */
  21147. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21148. /**
  21149. * Returns the material effect
  21150. * @returns the effect associated with the material
  21151. */
  21152. getEffect(): Nullable<Effect>;
  21153. /**
  21154. * Returns the current scene
  21155. * @returns a Scene
  21156. */
  21157. getScene(): Scene;
  21158. /**
  21159. * Specifies if the material will require alpha blending
  21160. * @returns a boolean specifying if alpha blending is needed
  21161. */
  21162. needAlphaBlending(): boolean;
  21163. /**
  21164. * Specifies if the mesh will require alpha blending
  21165. * @param mesh defines the mesh to check
  21166. * @returns a boolean specifying if alpha blending is needed for the mesh
  21167. */
  21168. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21169. /**
  21170. * Specifies if this material should be rendered in alpha test mode
  21171. * @returns a boolean specifying if an alpha test is needed.
  21172. */
  21173. needAlphaTesting(): boolean;
  21174. /**
  21175. * Gets the texture used for the alpha test
  21176. * @returns the texture to use for alpha testing
  21177. */
  21178. getAlphaTestTexture(): Nullable<BaseTexture>;
  21179. /**
  21180. * Marks the material to indicate that it needs to be re-calculated
  21181. */
  21182. markDirty(): void;
  21183. /** @hidden */
  21184. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21185. /**
  21186. * Binds the material to the mesh
  21187. * @param world defines the world transformation matrix
  21188. * @param mesh defines the mesh to bind the material to
  21189. */
  21190. bind(world: Matrix, mesh?: Mesh): void;
  21191. /**
  21192. * Binds the submesh to the material
  21193. * @param world defines the world transformation matrix
  21194. * @param mesh defines the mesh containing the submesh
  21195. * @param subMesh defines the submesh to bind the material to
  21196. */
  21197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21198. /**
  21199. * Binds the world matrix to the material
  21200. * @param world defines the world transformation matrix
  21201. */
  21202. bindOnlyWorldMatrix(world: Matrix): void;
  21203. /**
  21204. * Binds the scene's uniform buffer to the effect.
  21205. * @param effect defines the effect to bind to the scene uniform buffer
  21206. * @param sceneUbo defines the uniform buffer storing scene data
  21207. */
  21208. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21209. /**
  21210. * Binds the view matrix to the effect
  21211. * @param effect defines the effect to bind the view matrix to
  21212. */
  21213. bindView(effect: Effect): void;
  21214. /**
  21215. * Binds the view projection matrix to the effect
  21216. * @param effect defines the effect to bind the view projection matrix to
  21217. */
  21218. bindViewProjection(effect: Effect): void;
  21219. /**
  21220. * Specifies if material alpha testing should be turned on for the mesh
  21221. * @param mesh defines the mesh to check
  21222. */
  21223. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21224. /**
  21225. * Processes to execute after binding the material to a mesh
  21226. * @param mesh defines the rendered mesh
  21227. */
  21228. protected _afterBind(mesh?: Mesh): void;
  21229. /**
  21230. * Unbinds the material from the mesh
  21231. */
  21232. unbind(): void;
  21233. /**
  21234. * Gets the active textures from the material
  21235. * @returns an array of textures
  21236. */
  21237. getActiveTextures(): BaseTexture[];
  21238. /**
  21239. * Specifies if the material uses a texture
  21240. * @param texture defines the texture to check against the material
  21241. * @returns a boolean specifying if the material uses the texture
  21242. */
  21243. hasTexture(texture: BaseTexture): boolean;
  21244. /**
  21245. * Makes a duplicate of the material, and gives it a new name
  21246. * @param name defines the new name for the duplicated material
  21247. * @returns the cloned material
  21248. */
  21249. clone(name: string): Nullable<Material>;
  21250. /**
  21251. * Gets the meshes bound to the material
  21252. * @returns an array of meshes bound to the material
  21253. */
  21254. getBindedMeshes(): AbstractMesh[];
  21255. /**
  21256. * Force shader compilation
  21257. * @param mesh defines the mesh associated with this material
  21258. * @param onCompiled defines a function to execute once the material is compiled
  21259. * @param options defines the options to configure the compilation
  21260. * @param onError defines a function to execute if the material fails compiling
  21261. */
  21262. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21263. /**
  21264. * Force shader compilation
  21265. * @param mesh defines the mesh that will use this material
  21266. * @param options defines additional options for compiling the shaders
  21267. * @returns a promise that resolves when the compilation completes
  21268. */
  21269. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21270. private static readonly _AllDirtyCallBack;
  21271. private static readonly _ImageProcessingDirtyCallBack;
  21272. private static readonly _TextureDirtyCallBack;
  21273. private static readonly _FresnelDirtyCallBack;
  21274. private static readonly _MiscDirtyCallBack;
  21275. private static readonly _LightsDirtyCallBack;
  21276. private static readonly _AttributeDirtyCallBack;
  21277. private static _FresnelAndMiscDirtyCallBack;
  21278. private static _TextureAndMiscDirtyCallBack;
  21279. private static readonly _DirtyCallbackArray;
  21280. private static readonly _RunDirtyCallBacks;
  21281. /**
  21282. * Marks a define in the material to indicate that it needs to be re-computed
  21283. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21284. */
  21285. markAsDirty(flag: number): void;
  21286. /**
  21287. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21288. * @param func defines a function which checks material defines against the submeshes
  21289. */
  21290. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21291. /**
  21292. * Indicates that we need to re-calculated for all submeshes
  21293. */
  21294. protected _markAllSubMeshesAsAllDirty(): void;
  21295. /**
  21296. * Indicates that image processing needs to be re-calculated for all submeshes
  21297. */
  21298. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21299. /**
  21300. * Indicates that textures need to be re-calculated for all submeshes
  21301. */
  21302. protected _markAllSubMeshesAsTexturesDirty(): void;
  21303. /**
  21304. * Indicates that fresnel needs to be re-calculated for all submeshes
  21305. */
  21306. protected _markAllSubMeshesAsFresnelDirty(): void;
  21307. /**
  21308. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21309. */
  21310. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21311. /**
  21312. * Indicates that lights need to be re-calculated for all submeshes
  21313. */
  21314. protected _markAllSubMeshesAsLightsDirty(): void;
  21315. /**
  21316. * Indicates that attributes need to be re-calculated for all submeshes
  21317. */
  21318. protected _markAllSubMeshesAsAttributesDirty(): void;
  21319. /**
  21320. * Indicates that misc needs to be re-calculated for all submeshes
  21321. */
  21322. protected _markAllSubMeshesAsMiscDirty(): void;
  21323. /**
  21324. * Indicates that textures and misc need to be re-calculated for all submeshes
  21325. */
  21326. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21327. /**
  21328. * Disposes the material
  21329. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21330. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21331. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21332. */
  21333. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21334. /** @hidden */
  21335. private releaseVertexArrayObject;
  21336. /**
  21337. * Serializes this material
  21338. * @returns the serialized material object
  21339. */
  21340. serialize(): any;
  21341. /**
  21342. * Creates a material from parsed material data
  21343. * @param parsedMaterial defines parsed material data
  21344. * @param scene defines the hosting scene
  21345. * @param rootUrl defines the root URL to use to load textures
  21346. * @returns a new material
  21347. */
  21348. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21349. }
  21350. }
  21351. declare module BABYLON {
  21352. /**
  21353. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21354. * separate meshes. This can be use to improve performances.
  21355. * @see http://doc.babylonjs.com/how_to/multi_materials
  21356. */
  21357. export class MultiMaterial extends Material {
  21358. private _subMaterials;
  21359. /**
  21360. * Gets or Sets the list of Materials used within the multi material.
  21361. * They need to be ordered according to the submeshes order in the associated mesh
  21362. */
  21363. get subMaterials(): Nullable<Material>[];
  21364. set subMaterials(value: Nullable<Material>[]);
  21365. /**
  21366. * Function used to align with Node.getChildren()
  21367. * @returns the list of Materials used within the multi material
  21368. */
  21369. getChildren(): Nullable<Material>[];
  21370. /**
  21371. * Instantiates a new Multi Material
  21372. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21373. * separate meshes. This can be use to improve performances.
  21374. * @see http://doc.babylonjs.com/how_to/multi_materials
  21375. * @param name Define the name in the scene
  21376. * @param scene Define the scene the material belongs to
  21377. */
  21378. constructor(name: string, scene: Scene);
  21379. private _hookArray;
  21380. /**
  21381. * Get one of the submaterial by its index in the submaterials array
  21382. * @param index The index to look the sub material at
  21383. * @returns The Material if the index has been defined
  21384. */
  21385. getSubMaterial(index: number): Nullable<Material>;
  21386. /**
  21387. * Get the list of active textures for the whole sub materials list.
  21388. * @returns All the textures that will be used during the rendering
  21389. */
  21390. getActiveTextures(): BaseTexture[];
  21391. /**
  21392. * Gets the current class name of the material e.g. "MultiMaterial"
  21393. * Mainly use in serialization.
  21394. * @returns the class name
  21395. */
  21396. getClassName(): string;
  21397. /**
  21398. * Checks if the material is ready to render the requested sub mesh
  21399. * @param mesh Define the mesh the submesh belongs to
  21400. * @param subMesh Define the sub mesh to look readyness for
  21401. * @param useInstances Define whether or not the material is used with instances
  21402. * @returns true if ready, otherwise false
  21403. */
  21404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21405. /**
  21406. * Clones the current material and its related sub materials
  21407. * @param name Define the name of the newly cloned material
  21408. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21409. * @returns the cloned material
  21410. */
  21411. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21412. /**
  21413. * Serializes the materials into a JSON representation.
  21414. * @returns the JSON representation
  21415. */
  21416. serialize(): any;
  21417. /**
  21418. * Dispose the material and release its associated resources
  21419. * @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)
  21420. * @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)
  21421. * @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)
  21422. */
  21423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21424. /**
  21425. * Creates a MultiMaterial from parsed MultiMaterial data.
  21426. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21427. * @param scene defines the hosting scene
  21428. * @returns a new MultiMaterial
  21429. */
  21430. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21431. }
  21432. }
  21433. declare module BABYLON {
  21434. /**
  21435. * Base class for submeshes
  21436. */
  21437. export class BaseSubMesh {
  21438. /** @hidden */
  21439. _materialDefines: Nullable<MaterialDefines>;
  21440. /** @hidden */
  21441. _materialEffect: Nullable<Effect>;
  21442. /**
  21443. * Gets material defines used by the effect associated to the sub mesh
  21444. */
  21445. get materialDefines(): Nullable<MaterialDefines>;
  21446. /**
  21447. * Sets material defines used by the effect associated to the sub mesh
  21448. */
  21449. set materialDefines(defines: Nullable<MaterialDefines>);
  21450. /**
  21451. * Gets associated effect
  21452. */
  21453. get effect(): Nullable<Effect>;
  21454. /**
  21455. * Sets associated effect (effect used to render this submesh)
  21456. * @param effect defines the effect to associate with
  21457. * @param defines defines the set of defines used to compile this effect
  21458. */
  21459. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21460. }
  21461. /**
  21462. * Defines a subdivision inside a mesh
  21463. */
  21464. export class SubMesh extends BaseSubMesh implements ICullable {
  21465. /** the material index to use */
  21466. materialIndex: number;
  21467. /** vertex index start */
  21468. verticesStart: number;
  21469. /** vertices count */
  21470. verticesCount: number;
  21471. /** index start */
  21472. indexStart: number;
  21473. /** indices count */
  21474. indexCount: number;
  21475. /** @hidden */
  21476. _linesIndexCount: number;
  21477. private _mesh;
  21478. private _renderingMesh;
  21479. private _boundingInfo;
  21480. private _linesIndexBuffer;
  21481. /** @hidden */
  21482. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21483. /** @hidden */
  21484. _trianglePlanes: Plane[];
  21485. /** @hidden */
  21486. _lastColliderTransformMatrix: Nullable<Matrix>;
  21487. /** @hidden */
  21488. _renderId: number;
  21489. /** @hidden */
  21490. _alphaIndex: number;
  21491. /** @hidden */
  21492. _distanceToCamera: number;
  21493. /** @hidden */
  21494. _id: number;
  21495. private _currentMaterial;
  21496. /**
  21497. * Add a new submesh to a mesh
  21498. * @param materialIndex defines the material index to use
  21499. * @param verticesStart defines vertex index start
  21500. * @param verticesCount defines vertices count
  21501. * @param indexStart defines index start
  21502. * @param indexCount defines indices count
  21503. * @param mesh defines the parent mesh
  21504. * @param renderingMesh defines an optional rendering mesh
  21505. * @param createBoundingBox defines if bounding box should be created for this submesh
  21506. * @returns the new submesh
  21507. */
  21508. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21509. /**
  21510. * Creates a new submesh
  21511. * @param materialIndex defines the material index to use
  21512. * @param verticesStart defines vertex index start
  21513. * @param verticesCount defines vertices count
  21514. * @param indexStart defines index start
  21515. * @param indexCount defines indices count
  21516. * @param mesh defines the parent mesh
  21517. * @param renderingMesh defines an optional rendering mesh
  21518. * @param createBoundingBox defines if bounding box should be created for this submesh
  21519. */
  21520. constructor(
  21521. /** the material index to use */
  21522. materialIndex: number,
  21523. /** vertex index start */
  21524. verticesStart: number,
  21525. /** vertices count */
  21526. verticesCount: number,
  21527. /** index start */
  21528. indexStart: number,
  21529. /** indices count */
  21530. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21531. /**
  21532. * Returns true if this submesh covers the entire parent mesh
  21533. * @ignorenaming
  21534. */
  21535. get IsGlobal(): boolean;
  21536. /**
  21537. * Returns the submesh BoudingInfo object
  21538. * @returns current bounding info (or mesh's one if the submesh is global)
  21539. */
  21540. getBoundingInfo(): BoundingInfo;
  21541. /**
  21542. * Sets the submesh BoundingInfo
  21543. * @param boundingInfo defines the new bounding info to use
  21544. * @returns the SubMesh
  21545. */
  21546. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21547. /**
  21548. * Returns the mesh of the current submesh
  21549. * @return the parent mesh
  21550. */
  21551. getMesh(): AbstractMesh;
  21552. /**
  21553. * Returns the rendering mesh of the submesh
  21554. * @returns the rendering mesh (could be different from parent mesh)
  21555. */
  21556. getRenderingMesh(): Mesh;
  21557. /**
  21558. * Returns the submesh material
  21559. * @returns null or the current material
  21560. */
  21561. getMaterial(): Nullable<Material>;
  21562. /**
  21563. * Sets a new updated BoundingInfo object to the submesh
  21564. * @param data defines an optional position array to use to determine the bounding info
  21565. * @returns the SubMesh
  21566. */
  21567. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21568. /** @hidden */
  21569. _checkCollision(collider: Collider): boolean;
  21570. /**
  21571. * Updates the submesh BoundingInfo
  21572. * @param world defines the world matrix to use to update the bounding info
  21573. * @returns the submesh
  21574. */
  21575. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21576. /**
  21577. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21578. * @param frustumPlanes defines the frustum planes
  21579. * @returns true if the submesh is intersecting with the frustum
  21580. */
  21581. isInFrustum(frustumPlanes: Plane[]): boolean;
  21582. /**
  21583. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21584. * @param frustumPlanes defines the frustum planes
  21585. * @returns true if the submesh is inside the frustum
  21586. */
  21587. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21588. /**
  21589. * Renders the submesh
  21590. * @param enableAlphaMode defines if alpha needs to be used
  21591. * @returns the submesh
  21592. */
  21593. render(enableAlphaMode: boolean): SubMesh;
  21594. /**
  21595. * @hidden
  21596. */
  21597. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21598. /**
  21599. * Checks if the submesh intersects with a ray
  21600. * @param ray defines the ray to test
  21601. * @returns true is the passed ray intersects the submesh bounding box
  21602. */
  21603. canIntersects(ray: Ray): boolean;
  21604. /**
  21605. * Intersects current submesh with a ray
  21606. * @param ray defines the ray to test
  21607. * @param positions defines mesh's positions array
  21608. * @param indices defines mesh's indices array
  21609. * @param fastCheck defines if only bounding info should be used
  21610. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21611. * @returns intersection info or null if no intersection
  21612. */
  21613. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21614. /** @hidden */
  21615. private _intersectLines;
  21616. /** @hidden */
  21617. private _intersectUnIndexedLines;
  21618. /** @hidden */
  21619. private _intersectTriangles;
  21620. /** @hidden */
  21621. private _intersectUnIndexedTriangles;
  21622. /** @hidden */
  21623. _rebuild(): void;
  21624. /**
  21625. * Creates a new submesh from the passed mesh
  21626. * @param newMesh defines the new hosting mesh
  21627. * @param newRenderingMesh defines an optional rendering mesh
  21628. * @returns the new submesh
  21629. */
  21630. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21631. /**
  21632. * Release associated resources
  21633. */
  21634. dispose(): void;
  21635. /**
  21636. * Gets the class name
  21637. * @returns the string "SubMesh".
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Creates a new submesh from indices data
  21642. * @param materialIndex the index of the main mesh material
  21643. * @param startIndex the index where to start the copy in the mesh indices array
  21644. * @param indexCount the number of indices to copy then from the startIndex
  21645. * @param mesh the main mesh to create the submesh from
  21646. * @param renderingMesh the optional rendering mesh
  21647. * @returns a new submesh
  21648. */
  21649. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21650. }
  21651. }
  21652. declare module BABYLON {
  21653. /**
  21654. * Class used to represent data loading progression
  21655. */
  21656. export class SceneLoaderFlags {
  21657. private static _ForceFullSceneLoadingForIncremental;
  21658. private static _ShowLoadingScreen;
  21659. private static _CleanBoneMatrixWeights;
  21660. private static _loggingLevel;
  21661. /**
  21662. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21663. */
  21664. static get ForceFullSceneLoadingForIncremental(): boolean;
  21665. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21666. /**
  21667. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21668. */
  21669. static get ShowLoadingScreen(): boolean;
  21670. static set ShowLoadingScreen(value: boolean);
  21671. /**
  21672. * Defines the current logging level (while loading the scene)
  21673. * @ignorenaming
  21674. */
  21675. static get loggingLevel(): number;
  21676. static set loggingLevel(value: number);
  21677. /**
  21678. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21679. */
  21680. static get CleanBoneMatrixWeights(): boolean;
  21681. static set CleanBoneMatrixWeights(value: boolean);
  21682. }
  21683. }
  21684. declare module BABYLON {
  21685. /**
  21686. * Class used to store geometry data (vertex buffers + index buffer)
  21687. */
  21688. export class Geometry implements IGetSetVerticesData {
  21689. /**
  21690. * Gets or sets the ID of the geometry
  21691. */
  21692. id: string;
  21693. /**
  21694. * Gets or sets the unique ID of the geometry
  21695. */
  21696. uniqueId: number;
  21697. /**
  21698. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21699. */
  21700. delayLoadState: number;
  21701. /**
  21702. * Gets the file containing the data to load when running in delay load state
  21703. */
  21704. delayLoadingFile: Nullable<string>;
  21705. /**
  21706. * Callback called when the geometry is updated
  21707. */
  21708. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21709. private _scene;
  21710. private _engine;
  21711. private _meshes;
  21712. private _totalVertices;
  21713. /** @hidden */
  21714. _indices: IndicesArray;
  21715. /** @hidden */
  21716. _vertexBuffers: {
  21717. [key: string]: VertexBuffer;
  21718. };
  21719. private _isDisposed;
  21720. private _extend;
  21721. private _boundingBias;
  21722. /** @hidden */
  21723. _delayInfo: Array<string>;
  21724. private _indexBuffer;
  21725. private _indexBufferIsUpdatable;
  21726. /** @hidden */
  21727. _boundingInfo: Nullable<BoundingInfo>;
  21728. /** @hidden */
  21729. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21730. /** @hidden */
  21731. _softwareSkinningFrameId: number;
  21732. private _vertexArrayObjects;
  21733. private _updatable;
  21734. /** @hidden */
  21735. _positions: Nullable<Vector3[]>;
  21736. /**
  21737. * 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
  21738. */
  21739. get boundingBias(): Vector2;
  21740. /**
  21741. * 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
  21742. */
  21743. set boundingBias(value: Vector2);
  21744. /**
  21745. * Static function used to attach a new empty geometry to a mesh
  21746. * @param mesh defines the mesh to attach the geometry to
  21747. * @returns the new Geometry
  21748. */
  21749. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21750. /**
  21751. * Creates a new geometry
  21752. * @param id defines the unique ID
  21753. * @param scene defines the hosting scene
  21754. * @param vertexData defines the VertexData used to get geometry data
  21755. * @param updatable defines if geometry must be updatable (false by default)
  21756. * @param mesh defines the mesh that will be associated with the geometry
  21757. */
  21758. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21759. /**
  21760. * Gets the current extend of the geometry
  21761. */
  21762. get extend(): {
  21763. minimum: Vector3;
  21764. maximum: Vector3;
  21765. };
  21766. /**
  21767. * Gets the hosting scene
  21768. * @returns the hosting Scene
  21769. */
  21770. getScene(): Scene;
  21771. /**
  21772. * Gets the hosting engine
  21773. * @returns the hosting Engine
  21774. */
  21775. getEngine(): Engine;
  21776. /**
  21777. * Defines if the geometry is ready to use
  21778. * @returns true if the geometry is ready to be used
  21779. */
  21780. isReady(): boolean;
  21781. /**
  21782. * Gets a value indicating that the geometry should not be serialized
  21783. */
  21784. get doNotSerialize(): boolean;
  21785. /** @hidden */
  21786. _rebuild(): void;
  21787. /**
  21788. * Affects all geometry data in one call
  21789. * @param vertexData defines the geometry data
  21790. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21791. */
  21792. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21793. /**
  21794. * Set specific vertex data
  21795. * @param kind defines the data kind (Position, normal, etc...)
  21796. * @param data defines the vertex data to use
  21797. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21798. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21799. */
  21800. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21801. /**
  21802. * Removes a specific vertex data
  21803. * @param kind defines the data kind (Position, normal, etc...)
  21804. */
  21805. removeVerticesData(kind: string): void;
  21806. /**
  21807. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21808. * @param buffer defines the vertex buffer to use
  21809. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21810. */
  21811. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21812. /**
  21813. * Update a specific vertex buffer
  21814. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21815. * It will do nothing if the buffer is not updatable
  21816. * @param kind defines the data kind (Position, normal, etc...)
  21817. * @param data defines the data to use
  21818. * @param offset defines the offset in the target buffer where to store the data
  21819. * @param useBytes set to true if the offset is in bytes
  21820. */
  21821. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21822. /**
  21823. * Update a specific vertex buffer
  21824. * This function will create a new buffer if the current one is not updatable
  21825. * @param kind defines the data kind (Position, normal, etc...)
  21826. * @param data defines the data to use
  21827. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21828. */
  21829. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21830. private _updateBoundingInfo;
  21831. /** @hidden */
  21832. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21833. /**
  21834. * Gets total number of vertices
  21835. * @returns the total number of vertices
  21836. */
  21837. getTotalVertices(): number;
  21838. /**
  21839. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21840. * @param kind defines the data kind (Position, normal, etc...)
  21841. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21843. * @returns a float array containing vertex data
  21844. */
  21845. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21846. /**
  21847. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21848. * @param kind defines the data kind (Position, normal, etc...)
  21849. * @returns true if the vertex buffer with the specified kind is updatable
  21850. */
  21851. isVertexBufferUpdatable(kind: string): boolean;
  21852. /**
  21853. * Gets a specific vertex buffer
  21854. * @param kind defines the data kind (Position, normal, etc...)
  21855. * @returns a VertexBuffer
  21856. */
  21857. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21858. /**
  21859. * Returns all vertex buffers
  21860. * @return an object holding all vertex buffers indexed by kind
  21861. */
  21862. getVertexBuffers(): Nullable<{
  21863. [key: string]: VertexBuffer;
  21864. }>;
  21865. /**
  21866. * Gets a boolean indicating if specific vertex buffer is present
  21867. * @param kind defines the data kind (Position, normal, etc...)
  21868. * @returns true if data is present
  21869. */
  21870. isVerticesDataPresent(kind: string): boolean;
  21871. /**
  21872. * Gets a list of all attached data kinds (Position, normal, etc...)
  21873. * @returns a list of string containing all kinds
  21874. */
  21875. getVerticesDataKinds(): string[];
  21876. /**
  21877. * Update index buffer
  21878. * @param indices defines the indices to store in the index buffer
  21879. * @param offset defines the offset in the target buffer where to store the data
  21880. * @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)
  21881. */
  21882. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21883. /**
  21884. * Creates a new index buffer
  21885. * @param indices defines the indices to store in the index buffer
  21886. * @param totalVertices defines the total number of vertices (could be null)
  21887. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21888. */
  21889. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21890. /**
  21891. * Return the total number of indices
  21892. * @returns the total number of indices
  21893. */
  21894. getTotalIndices(): number;
  21895. /**
  21896. * Gets the index buffer array
  21897. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21898. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21899. * @returns the index buffer array
  21900. */
  21901. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21902. /**
  21903. * Gets the index buffer
  21904. * @return the index buffer
  21905. */
  21906. getIndexBuffer(): Nullable<DataBuffer>;
  21907. /** @hidden */
  21908. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21909. /**
  21910. * Release the associated resources for a specific mesh
  21911. * @param mesh defines the source mesh
  21912. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21913. */
  21914. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21915. /**
  21916. * Apply current geometry to a given mesh
  21917. * @param mesh defines the mesh to apply geometry to
  21918. */
  21919. applyToMesh(mesh: Mesh): void;
  21920. private _updateExtend;
  21921. private _applyToMesh;
  21922. private notifyUpdate;
  21923. /**
  21924. * Load the geometry if it was flagged as delay loaded
  21925. * @param scene defines the hosting scene
  21926. * @param onLoaded defines a callback called when the geometry is loaded
  21927. */
  21928. load(scene: Scene, onLoaded?: () => void): void;
  21929. private _queueLoad;
  21930. /**
  21931. * Invert the geometry to move from a right handed system to a left handed one.
  21932. */
  21933. toLeftHanded(): void;
  21934. /** @hidden */
  21935. _resetPointsArrayCache(): void;
  21936. /** @hidden */
  21937. _generatePointsArray(): boolean;
  21938. /**
  21939. * Gets a value indicating if the geometry is disposed
  21940. * @returns true if the geometry was disposed
  21941. */
  21942. isDisposed(): boolean;
  21943. private _disposeVertexArrayObjects;
  21944. /**
  21945. * Free all associated resources
  21946. */
  21947. dispose(): void;
  21948. /**
  21949. * Clone the current geometry into a new geometry
  21950. * @param id defines the unique ID of the new geometry
  21951. * @returns a new geometry object
  21952. */
  21953. copy(id: string): Geometry;
  21954. /**
  21955. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21956. * @return a JSON representation of the current geometry data (without the vertices data)
  21957. */
  21958. serialize(): any;
  21959. private toNumberArray;
  21960. /**
  21961. * Serialize all vertices data into a JSON oject
  21962. * @returns a JSON representation of the current geometry data
  21963. */
  21964. serializeVerticeData(): any;
  21965. /**
  21966. * Extracts a clone of a mesh geometry
  21967. * @param mesh defines the source mesh
  21968. * @param id defines the unique ID of the new geometry object
  21969. * @returns the new geometry object
  21970. */
  21971. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21972. /**
  21973. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21974. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21975. * Be aware Math.random() could cause collisions, but:
  21976. * "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"
  21977. * @returns a string containing a new GUID
  21978. */
  21979. static RandomId(): string;
  21980. /** @hidden */
  21981. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21982. private static _CleanMatricesWeights;
  21983. /**
  21984. * Create a new geometry from persisted data (Using .babylon file format)
  21985. * @param parsedVertexData defines the persisted data
  21986. * @param scene defines the hosting scene
  21987. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21988. * @returns the new geometry object
  21989. */
  21990. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21991. }
  21992. }
  21993. declare module BABYLON {
  21994. /**
  21995. * Define an interface for all classes that will get and set the data on vertices
  21996. */
  21997. export interface IGetSetVerticesData {
  21998. /**
  21999. * Gets a boolean indicating if specific vertex data is present
  22000. * @param kind defines the vertex data kind to use
  22001. * @returns true is data kind is present
  22002. */
  22003. isVerticesDataPresent(kind: string): boolean;
  22004. /**
  22005. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22006. * @param kind defines the data kind (Position, normal, etc...)
  22007. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22008. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22009. * @returns a float array containing vertex data
  22010. */
  22011. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22012. /**
  22013. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22014. * @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.
  22015. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22016. * @returns the indices array or an empty array if the mesh has no geometry
  22017. */
  22018. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22019. /**
  22020. * Set specific vertex data
  22021. * @param kind defines the data kind (Position, normal, etc...)
  22022. * @param data defines the vertex data to use
  22023. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22024. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22025. */
  22026. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22027. /**
  22028. * Update a specific associated vertex buffer
  22029. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22030. * - VertexBuffer.PositionKind
  22031. * - VertexBuffer.UVKind
  22032. * - VertexBuffer.UV2Kind
  22033. * - VertexBuffer.UV3Kind
  22034. * - VertexBuffer.UV4Kind
  22035. * - VertexBuffer.UV5Kind
  22036. * - VertexBuffer.UV6Kind
  22037. * - VertexBuffer.ColorKind
  22038. * - VertexBuffer.MatricesIndicesKind
  22039. * - VertexBuffer.MatricesIndicesExtraKind
  22040. * - VertexBuffer.MatricesWeightsKind
  22041. * - VertexBuffer.MatricesWeightsExtraKind
  22042. * @param data defines the data source
  22043. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22044. * @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)
  22045. */
  22046. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22047. /**
  22048. * Creates a new index buffer
  22049. * @param indices defines the indices to store in the index buffer
  22050. * @param totalVertices defines the total number of vertices (could be null)
  22051. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22052. */
  22053. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22054. }
  22055. /**
  22056. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22057. */
  22058. export class VertexData {
  22059. /**
  22060. * Mesh side orientation : usually the external or front surface
  22061. */
  22062. static readonly FRONTSIDE: number;
  22063. /**
  22064. * Mesh side orientation : usually the internal or back surface
  22065. */
  22066. static readonly BACKSIDE: number;
  22067. /**
  22068. * Mesh side orientation : both internal and external or front and back surfaces
  22069. */
  22070. static readonly DOUBLESIDE: number;
  22071. /**
  22072. * Mesh side orientation : by default, `FRONTSIDE`
  22073. */
  22074. static readonly DEFAULTSIDE: number;
  22075. /**
  22076. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22077. */
  22078. positions: Nullable<FloatArray>;
  22079. /**
  22080. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22081. */
  22082. normals: Nullable<FloatArray>;
  22083. /**
  22084. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22085. */
  22086. tangents: Nullable<FloatArray>;
  22087. /**
  22088. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22089. */
  22090. uvs: Nullable<FloatArray>;
  22091. /**
  22092. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22093. */
  22094. uvs2: Nullable<FloatArray>;
  22095. /**
  22096. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22097. */
  22098. uvs3: Nullable<FloatArray>;
  22099. /**
  22100. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22101. */
  22102. uvs4: Nullable<FloatArray>;
  22103. /**
  22104. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22105. */
  22106. uvs5: Nullable<FloatArray>;
  22107. /**
  22108. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22109. */
  22110. uvs6: Nullable<FloatArray>;
  22111. /**
  22112. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22113. */
  22114. colors: Nullable<FloatArray>;
  22115. /**
  22116. * 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).
  22117. */
  22118. matricesIndices: Nullable<FloatArray>;
  22119. /**
  22120. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22121. */
  22122. matricesWeights: Nullable<FloatArray>;
  22123. /**
  22124. * An array extending the number of possible indices
  22125. */
  22126. matricesIndicesExtra: Nullable<FloatArray>;
  22127. /**
  22128. * An array extending the number of possible weights when the number of indices is extended
  22129. */
  22130. matricesWeightsExtra: Nullable<FloatArray>;
  22131. /**
  22132. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22133. */
  22134. indices: Nullable<IndicesArray>;
  22135. /**
  22136. * Uses the passed data array to set the set the values for the specified kind of data
  22137. * @param data a linear array of floating numbers
  22138. * @param kind the type of data that is being set, eg positions, colors etc
  22139. */
  22140. set(data: FloatArray, kind: string): void;
  22141. /**
  22142. * Associates the vertexData to the passed Mesh.
  22143. * Sets it as updatable or not (default `false`)
  22144. * @param mesh the mesh the vertexData is applied to
  22145. * @param updatable when used and having the value true allows new data to update the vertexData
  22146. * @returns the VertexData
  22147. */
  22148. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22149. /**
  22150. * Associates the vertexData to the passed Geometry.
  22151. * Sets it as updatable or not (default `false`)
  22152. * @param geometry the geometry the vertexData is applied to
  22153. * @param updatable when used and having the value true allows new data to update the vertexData
  22154. * @returns VertexData
  22155. */
  22156. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22157. /**
  22158. * Updates the associated mesh
  22159. * @param mesh the mesh to be updated
  22160. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22161. * @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
  22162. * @returns VertexData
  22163. */
  22164. updateMesh(mesh: Mesh): VertexData;
  22165. /**
  22166. * Updates the associated geometry
  22167. * @param geometry the geometry to be updated
  22168. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22169. * @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
  22170. * @returns VertexData.
  22171. */
  22172. updateGeometry(geometry: Geometry): VertexData;
  22173. private _applyTo;
  22174. private _update;
  22175. /**
  22176. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22177. * @param matrix the transforming matrix
  22178. * @returns the VertexData
  22179. */
  22180. transform(matrix: Matrix): VertexData;
  22181. /**
  22182. * Merges the passed VertexData into the current one
  22183. * @param other the VertexData to be merged into the current one
  22184. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22185. * @returns the modified VertexData
  22186. */
  22187. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22188. private _mergeElement;
  22189. private _validate;
  22190. /**
  22191. * Serializes the VertexData
  22192. * @returns a serialized object
  22193. */
  22194. serialize(): any;
  22195. /**
  22196. * Extracts the vertexData from a mesh
  22197. * @param mesh the mesh from which to extract the VertexData
  22198. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22199. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22200. * @returns the object VertexData associated to the passed mesh
  22201. */
  22202. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22203. /**
  22204. * Extracts the vertexData from the geometry
  22205. * @param geometry the geometry from which to extract the VertexData
  22206. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22207. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22208. * @returns the object VertexData associated to the passed mesh
  22209. */
  22210. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22211. private static _ExtractFrom;
  22212. /**
  22213. * Creates the VertexData for a Ribbon
  22214. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22215. * * pathArray array of paths, each of which an array of successive Vector3
  22216. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22217. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22218. * * 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
  22219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22220. * * 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)
  22221. * * 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)
  22222. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22223. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22224. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22225. * @returns the VertexData of the ribbon
  22226. */
  22227. static CreateRibbon(options: {
  22228. pathArray: Vector3[][];
  22229. closeArray?: boolean;
  22230. closePath?: boolean;
  22231. offset?: number;
  22232. sideOrientation?: number;
  22233. frontUVs?: Vector4;
  22234. backUVs?: Vector4;
  22235. invertUV?: boolean;
  22236. uvs?: Vector2[];
  22237. colors?: Color4[];
  22238. }): VertexData;
  22239. /**
  22240. * Creates the VertexData for a box
  22241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22242. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22243. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22244. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22245. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22246. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22247. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22248. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22249. * * 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)
  22250. * * 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)
  22251. * @returns the VertexData of the box
  22252. */
  22253. static CreateBox(options: {
  22254. size?: number;
  22255. width?: number;
  22256. height?: number;
  22257. depth?: number;
  22258. faceUV?: Vector4[];
  22259. faceColors?: Color4[];
  22260. sideOrientation?: number;
  22261. frontUVs?: Vector4;
  22262. backUVs?: Vector4;
  22263. }): VertexData;
  22264. /**
  22265. * Creates the VertexData for a tiled box
  22266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22267. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22268. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22269. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22270. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22271. * @returns the VertexData of the box
  22272. */
  22273. static CreateTiledBox(options: {
  22274. pattern?: number;
  22275. width?: number;
  22276. height?: number;
  22277. depth?: number;
  22278. tileSize?: number;
  22279. tileWidth?: number;
  22280. tileHeight?: number;
  22281. alignHorizontal?: number;
  22282. alignVertical?: number;
  22283. faceUV?: Vector4[];
  22284. faceColors?: Color4[];
  22285. sideOrientation?: number;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for a tiled plane
  22289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22290. * * pattern a limited pattern arrangement depending on the number
  22291. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22292. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22293. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22295. * * 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)
  22296. * * 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)
  22297. * @returns the VertexData of the tiled plane
  22298. */
  22299. static CreateTiledPlane(options: {
  22300. pattern?: number;
  22301. tileSize?: number;
  22302. tileWidth?: number;
  22303. tileHeight?: number;
  22304. size?: number;
  22305. width?: number;
  22306. height?: number;
  22307. alignHorizontal?: number;
  22308. alignVertical?: number;
  22309. sideOrientation?: number;
  22310. frontUVs?: Vector4;
  22311. backUVs?: Vector4;
  22312. }): VertexData;
  22313. /**
  22314. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22315. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22316. * * segments sets the number of horizontal strips optional, default 32
  22317. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22318. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22319. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22320. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22321. * * 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
  22322. * * 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
  22323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22324. * * 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)
  22325. * * 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)
  22326. * @returns the VertexData of the ellipsoid
  22327. */
  22328. static CreateSphere(options: {
  22329. segments?: number;
  22330. diameter?: number;
  22331. diameterX?: number;
  22332. diameterY?: number;
  22333. diameterZ?: number;
  22334. arc?: number;
  22335. slice?: number;
  22336. sideOrientation?: number;
  22337. frontUVs?: Vector4;
  22338. backUVs?: Vector4;
  22339. }): VertexData;
  22340. /**
  22341. * Creates the VertexData for a cylinder, cone or prism
  22342. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22343. * * height sets the height (y direction) of the cylinder, optional, default 2
  22344. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22345. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22346. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22347. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22348. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22349. * * 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
  22350. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22351. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22352. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22353. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22355. * * 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)
  22356. * * 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)
  22357. * @returns the VertexData of the cylinder, cone or prism
  22358. */
  22359. static CreateCylinder(options: {
  22360. height?: number;
  22361. diameterTop?: number;
  22362. diameterBottom?: number;
  22363. diameter?: number;
  22364. tessellation?: number;
  22365. subdivisions?: number;
  22366. arc?: number;
  22367. faceColors?: Color4[];
  22368. faceUV?: Vector4[];
  22369. hasRings?: boolean;
  22370. enclose?: boolean;
  22371. sideOrientation?: number;
  22372. frontUVs?: Vector4;
  22373. backUVs?: Vector4;
  22374. }): VertexData;
  22375. /**
  22376. * Creates the VertexData for a torus
  22377. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22378. * * diameter the diameter of the torus, optional default 1
  22379. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22380. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22382. * * 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)
  22383. * * 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)
  22384. * @returns the VertexData of the torus
  22385. */
  22386. static CreateTorus(options: {
  22387. diameter?: number;
  22388. thickness?: number;
  22389. tessellation?: number;
  22390. sideOrientation?: number;
  22391. frontUVs?: Vector4;
  22392. backUVs?: Vector4;
  22393. }): VertexData;
  22394. /**
  22395. * Creates the VertexData of the LineSystem
  22396. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22397. * - lines an array of lines, each line being an array of successive Vector3
  22398. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22399. * @returns the VertexData of the LineSystem
  22400. */
  22401. static CreateLineSystem(options: {
  22402. lines: Vector3[][];
  22403. colors?: Nullable<Color4[][]>;
  22404. }): VertexData;
  22405. /**
  22406. * Create the VertexData for a DashedLines
  22407. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22408. * - points an array successive Vector3
  22409. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22410. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22411. * - dashNb the intended total number of dashes, optional, default 200
  22412. * @returns the VertexData for the DashedLines
  22413. */
  22414. static CreateDashedLines(options: {
  22415. points: Vector3[];
  22416. dashSize?: number;
  22417. gapSize?: number;
  22418. dashNb?: number;
  22419. }): VertexData;
  22420. /**
  22421. * Creates the VertexData for a Ground
  22422. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22423. * - width the width (x direction) of the ground, optional, default 1
  22424. * - height the height (z direction) of the ground, optional, default 1
  22425. * - subdivisions the number of subdivisions per side, optional, default 1
  22426. * @returns the VertexData of the Ground
  22427. */
  22428. static CreateGround(options: {
  22429. width?: number;
  22430. height?: number;
  22431. subdivisions?: number;
  22432. subdivisionsX?: number;
  22433. subdivisionsY?: number;
  22434. }): VertexData;
  22435. /**
  22436. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22437. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22438. * * xmin the ground minimum X coordinate, optional, default -1
  22439. * * zmin the ground minimum Z coordinate, optional, default -1
  22440. * * xmax the ground maximum X coordinate, optional, default 1
  22441. * * zmax the ground maximum Z coordinate, optional, default 1
  22442. * * 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}
  22443. * * 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}
  22444. * @returns the VertexData of the TiledGround
  22445. */
  22446. static CreateTiledGround(options: {
  22447. xmin: number;
  22448. zmin: number;
  22449. xmax: number;
  22450. zmax: number;
  22451. subdivisions?: {
  22452. w: number;
  22453. h: number;
  22454. };
  22455. precision?: {
  22456. w: number;
  22457. h: number;
  22458. };
  22459. }): VertexData;
  22460. /**
  22461. * Creates the VertexData of the Ground designed from a heightmap
  22462. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22463. * * width the width (x direction) of the ground
  22464. * * height the height (z direction) of the ground
  22465. * * subdivisions the number of subdivisions per side
  22466. * * minHeight the minimum altitude on the ground, optional, default 0
  22467. * * maxHeight the maximum altitude on the ground, optional default 1
  22468. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22469. * * buffer the array holding the image color data
  22470. * * bufferWidth the width of image
  22471. * * bufferHeight the height of image
  22472. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22473. * @returns the VertexData of the Ground designed from a heightmap
  22474. */
  22475. static CreateGroundFromHeightMap(options: {
  22476. width: number;
  22477. height: number;
  22478. subdivisions: number;
  22479. minHeight: number;
  22480. maxHeight: number;
  22481. colorFilter: Color3;
  22482. buffer: Uint8Array;
  22483. bufferWidth: number;
  22484. bufferHeight: number;
  22485. alphaFilter: number;
  22486. }): VertexData;
  22487. /**
  22488. * Creates the VertexData for a Plane
  22489. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22490. * * size sets the width and height of the plane to the value of size, optional default 1
  22491. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22492. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22493. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22494. * * 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)
  22495. * * 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)
  22496. * @returns the VertexData of the box
  22497. */
  22498. static CreatePlane(options: {
  22499. size?: number;
  22500. width?: number;
  22501. height?: number;
  22502. sideOrientation?: number;
  22503. frontUVs?: Vector4;
  22504. backUVs?: Vector4;
  22505. }): VertexData;
  22506. /**
  22507. * Creates the VertexData of the Disc or regular Polygon
  22508. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22509. * * radius the radius of the disc, optional default 0.5
  22510. * * tessellation the number of polygon sides, optional, default 64
  22511. * * 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
  22512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22513. * * 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)
  22514. * * 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)
  22515. * @returns the VertexData of the box
  22516. */
  22517. static CreateDisc(options: {
  22518. radius?: number;
  22519. tessellation?: number;
  22520. arc?: number;
  22521. sideOrientation?: number;
  22522. frontUVs?: Vector4;
  22523. backUVs?: Vector4;
  22524. }): VertexData;
  22525. /**
  22526. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22527. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22528. * @param polygon a mesh built from polygonTriangulation.build()
  22529. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22530. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22531. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22532. * @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)
  22533. * @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)
  22534. * @returns the VertexData of the Polygon
  22535. */
  22536. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22537. /**
  22538. * Creates the VertexData of the IcoSphere
  22539. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22540. * * radius the radius of the IcoSphere, optional default 1
  22541. * * radiusX allows stretching in the x direction, optional, default radius
  22542. * * radiusY allows stretching in the y direction, optional, default radius
  22543. * * radiusZ allows stretching in the z direction, optional, default radius
  22544. * * flat when true creates a flat shaded mesh, optional, default true
  22545. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22547. * * 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)
  22548. * * 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)
  22549. * @returns the VertexData of the IcoSphere
  22550. */
  22551. static CreateIcoSphere(options: {
  22552. radius?: number;
  22553. radiusX?: number;
  22554. radiusY?: number;
  22555. radiusZ?: number;
  22556. flat?: boolean;
  22557. subdivisions?: number;
  22558. sideOrientation?: number;
  22559. frontUVs?: Vector4;
  22560. backUVs?: Vector4;
  22561. }): VertexData;
  22562. /**
  22563. * Creates the VertexData for a Polyhedron
  22564. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22565. * * type provided types are:
  22566. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22567. * * 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)
  22568. * * size the size of the IcoSphere, optional default 1
  22569. * * sizeX allows stretching in the x direction, optional, default size
  22570. * * sizeY allows stretching in the y direction, optional, default size
  22571. * * sizeZ allows stretching in the z direction, optional, default size
  22572. * * 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
  22573. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22574. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22575. * * flat when true creates a flat shaded mesh, optional, default true
  22576. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22578. * * 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)
  22579. * * 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)
  22580. * @returns the VertexData of the Polyhedron
  22581. */
  22582. static CreatePolyhedron(options: {
  22583. type?: number;
  22584. size?: number;
  22585. sizeX?: number;
  22586. sizeY?: number;
  22587. sizeZ?: number;
  22588. custom?: any;
  22589. faceUV?: Vector4[];
  22590. faceColors?: Color4[];
  22591. flat?: boolean;
  22592. sideOrientation?: number;
  22593. frontUVs?: Vector4;
  22594. backUVs?: Vector4;
  22595. }): VertexData;
  22596. /**
  22597. * Creates the VertexData for a TorusKnot
  22598. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22599. * * radius the radius of the torus knot, optional, default 2
  22600. * * tube the thickness of the tube, optional, default 0.5
  22601. * * radialSegments the number of sides on each tube segments, optional, default 32
  22602. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22603. * * p the number of windings around the z axis, optional, default 2
  22604. * * q the number of windings around the x axis, optional, default 3
  22605. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22606. * * 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)
  22607. * * 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)
  22608. * @returns the VertexData of the Torus Knot
  22609. */
  22610. static CreateTorusKnot(options: {
  22611. radius?: number;
  22612. tube?: number;
  22613. radialSegments?: number;
  22614. tubularSegments?: number;
  22615. p?: number;
  22616. q?: number;
  22617. sideOrientation?: number;
  22618. frontUVs?: Vector4;
  22619. backUVs?: Vector4;
  22620. }): VertexData;
  22621. /**
  22622. * Compute normals for given positions and indices
  22623. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22624. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22625. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22626. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22627. * * facetNormals : optional array of facet normals (vector3)
  22628. * * facetPositions : optional array of facet positions (vector3)
  22629. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22630. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22631. * * bInfo : optional bounding info, required for facetPartitioning computation
  22632. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22633. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22634. * * useRightHandedSystem: optional boolean to for right handed system computation
  22635. * * depthSort : optional boolean to enable the facet depth sort computation
  22636. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22637. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22638. */
  22639. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22640. facetNormals?: any;
  22641. facetPositions?: any;
  22642. facetPartitioning?: any;
  22643. ratio?: number;
  22644. bInfo?: any;
  22645. bbSize?: Vector3;
  22646. subDiv?: any;
  22647. useRightHandedSystem?: boolean;
  22648. depthSort?: boolean;
  22649. distanceTo?: Vector3;
  22650. depthSortedFacets?: any;
  22651. }): void;
  22652. /** @hidden */
  22653. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22654. /**
  22655. * Applies VertexData created from the imported parameters to the geometry
  22656. * @param parsedVertexData the parsed data from an imported file
  22657. * @param geometry the geometry to apply the VertexData to
  22658. */
  22659. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22660. }
  22661. }
  22662. declare module BABYLON {
  22663. /**
  22664. * Defines a target to use with MorphTargetManager
  22665. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22666. */
  22667. export class MorphTarget implements IAnimatable {
  22668. /** defines the name of the target */
  22669. name: string;
  22670. /**
  22671. * Gets or sets the list of animations
  22672. */
  22673. animations: Animation[];
  22674. private _scene;
  22675. private _positions;
  22676. private _normals;
  22677. private _tangents;
  22678. private _uvs;
  22679. private _influence;
  22680. private _uniqueId;
  22681. /**
  22682. * Observable raised when the influence changes
  22683. */
  22684. onInfluenceChanged: Observable<boolean>;
  22685. /** @hidden */
  22686. _onDataLayoutChanged: Observable<void>;
  22687. /**
  22688. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22689. */
  22690. get influence(): number;
  22691. set influence(influence: number);
  22692. /**
  22693. * Gets or sets the id of the morph Target
  22694. */
  22695. id: string;
  22696. private _animationPropertiesOverride;
  22697. /**
  22698. * Gets or sets the animation properties override
  22699. */
  22700. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22701. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22702. /**
  22703. * Creates a new MorphTarget
  22704. * @param name defines the name of the target
  22705. * @param influence defines the influence to use
  22706. * @param scene defines the scene the morphtarget belongs to
  22707. */
  22708. constructor(
  22709. /** defines the name of the target */
  22710. name: string, influence?: number, scene?: Nullable<Scene>);
  22711. /**
  22712. * Gets the unique ID of this manager
  22713. */
  22714. get uniqueId(): number;
  22715. /**
  22716. * Gets a boolean defining if the target contains position data
  22717. */
  22718. get hasPositions(): boolean;
  22719. /**
  22720. * Gets a boolean defining if the target contains normal data
  22721. */
  22722. get hasNormals(): boolean;
  22723. /**
  22724. * Gets a boolean defining if the target contains tangent data
  22725. */
  22726. get hasTangents(): boolean;
  22727. /**
  22728. * Gets a boolean defining if the target contains texture coordinates data
  22729. */
  22730. get hasUVs(): boolean;
  22731. /**
  22732. * Affects position data to this target
  22733. * @param data defines the position data to use
  22734. */
  22735. setPositions(data: Nullable<FloatArray>): void;
  22736. /**
  22737. * Gets the position data stored in this target
  22738. * @returns a FloatArray containing the position data (or null if not present)
  22739. */
  22740. getPositions(): Nullable<FloatArray>;
  22741. /**
  22742. * Affects normal data to this target
  22743. * @param data defines the normal data to use
  22744. */
  22745. setNormals(data: Nullable<FloatArray>): void;
  22746. /**
  22747. * Gets the normal data stored in this target
  22748. * @returns a FloatArray containing the normal data (or null if not present)
  22749. */
  22750. getNormals(): Nullable<FloatArray>;
  22751. /**
  22752. * Affects tangent data to this target
  22753. * @param data defines the tangent data to use
  22754. */
  22755. setTangents(data: Nullable<FloatArray>): void;
  22756. /**
  22757. * Gets the tangent data stored in this target
  22758. * @returns a FloatArray containing the tangent data (or null if not present)
  22759. */
  22760. getTangents(): Nullable<FloatArray>;
  22761. /**
  22762. * Affects texture coordinates data to this target
  22763. * @param data defines the texture coordinates data to use
  22764. */
  22765. setUVs(data: Nullable<FloatArray>): void;
  22766. /**
  22767. * Gets the texture coordinates data stored in this target
  22768. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22769. */
  22770. getUVs(): Nullable<FloatArray>;
  22771. /**
  22772. * Clone the current target
  22773. * @returns a new MorphTarget
  22774. */
  22775. clone(): MorphTarget;
  22776. /**
  22777. * Serializes the current target into a Serialization object
  22778. * @returns the serialized object
  22779. */
  22780. serialize(): any;
  22781. /**
  22782. * Returns the string "MorphTarget"
  22783. * @returns "MorphTarget"
  22784. */
  22785. getClassName(): string;
  22786. /**
  22787. * Creates a new target from serialized data
  22788. * @param serializationObject defines the serialized data to use
  22789. * @returns a new MorphTarget
  22790. */
  22791. static Parse(serializationObject: any): MorphTarget;
  22792. /**
  22793. * Creates a MorphTarget from mesh data
  22794. * @param mesh defines the source mesh
  22795. * @param name defines the name to use for the new target
  22796. * @param influence defines the influence to attach to the target
  22797. * @returns a new MorphTarget
  22798. */
  22799. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22800. }
  22801. }
  22802. declare module BABYLON {
  22803. /**
  22804. * This class is used to deform meshes using morphing between different targets
  22805. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22806. */
  22807. export class MorphTargetManager {
  22808. private _targets;
  22809. private _targetInfluenceChangedObservers;
  22810. private _targetDataLayoutChangedObservers;
  22811. private _activeTargets;
  22812. private _scene;
  22813. private _influences;
  22814. private _supportsNormals;
  22815. private _supportsTangents;
  22816. private _supportsUVs;
  22817. private _vertexCount;
  22818. private _uniqueId;
  22819. private _tempInfluences;
  22820. /**
  22821. * Gets or sets a boolean indicating if normals must be morphed
  22822. */
  22823. enableNormalMorphing: boolean;
  22824. /**
  22825. * Gets or sets a boolean indicating if tangents must be morphed
  22826. */
  22827. enableTangentMorphing: boolean;
  22828. /**
  22829. * Gets or sets a boolean indicating if UV must be morphed
  22830. */
  22831. enableUVMorphing: boolean;
  22832. /**
  22833. * Creates a new MorphTargetManager
  22834. * @param scene defines the current scene
  22835. */
  22836. constructor(scene?: Nullable<Scene>);
  22837. /**
  22838. * Gets the unique ID of this manager
  22839. */
  22840. get uniqueId(): number;
  22841. /**
  22842. * Gets the number of vertices handled by this manager
  22843. */
  22844. get vertexCount(): number;
  22845. /**
  22846. * Gets a boolean indicating if this manager supports morphing of normals
  22847. */
  22848. get supportsNormals(): boolean;
  22849. /**
  22850. * Gets a boolean indicating if this manager supports morphing of tangents
  22851. */
  22852. get supportsTangents(): boolean;
  22853. /**
  22854. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22855. */
  22856. get supportsUVs(): boolean;
  22857. /**
  22858. * Gets the number of targets stored in this manager
  22859. */
  22860. get numTargets(): number;
  22861. /**
  22862. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22863. */
  22864. get numInfluencers(): number;
  22865. /**
  22866. * Gets the list of influences (one per target)
  22867. */
  22868. get influences(): Float32Array;
  22869. /**
  22870. * Gets the active target at specified index. An active target is a target with an influence > 0
  22871. * @param index defines the index to check
  22872. * @returns the requested target
  22873. */
  22874. getActiveTarget(index: number): MorphTarget;
  22875. /**
  22876. * Gets the target at specified index
  22877. * @param index defines the index to check
  22878. * @returns the requested target
  22879. */
  22880. getTarget(index: number): MorphTarget;
  22881. /**
  22882. * Add a new target to this manager
  22883. * @param target defines the target to add
  22884. */
  22885. addTarget(target: MorphTarget): void;
  22886. /**
  22887. * Removes a target from the manager
  22888. * @param target defines the target to remove
  22889. */
  22890. removeTarget(target: MorphTarget): void;
  22891. /**
  22892. * Clone the current manager
  22893. * @returns a new MorphTargetManager
  22894. */
  22895. clone(): MorphTargetManager;
  22896. /**
  22897. * Serializes the current manager into a Serialization object
  22898. * @returns the serialized object
  22899. */
  22900. serialize(): any;
  22901. private _syncActiveTargets;
  22902. /**
  22903. * Syncrhonize the targets with all the meshes using this morph target manager
  22904. */
  22905. synchronize(): void;
  22906. /**
  22907. * Creates a new MorphTargetManager from serialized data
  22908. * @param serializationObject defines the serialized data
  22909. * @param scene defines the hosting scene
  22910. * @returns the new MorphTargetManager
  22911. */
  22912. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22913. }
  22914. }
  22915. declare module BABYLON {
  22916. /**
  22917. * Class used to represent a specific level of detail of a mesh
  22918. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22919. */
  22920. export class MeshLODLevel {
  22921. /** Defines the distance where this level should start being displayed */
  22922. distance: number;
  22923. /** Defines the mesh to use to render this level */
  22924. mesh: Nullable<Mesh>;
  22925. /**
  22926. * Creates a new LOD level
  22927. * @param distance defines the distance where this level should star being displayed
  22928. * @param mesh defines the mesh to use to render this level
  22929. */
  22930. constructor(
  22931. /** Defines the distance where this level should start being displayed */
  22932. distance: number,
  22933. /** Defines the mesh to use to render this level */
  22934. mesh: Nullable<Mesh>);
  22935. }
  22936. }
  22937. declare module BABYLON {
  22938. /**
  22939. * Mesh representing the gorund
  22940. */
  22941. export class GroundMesh extends Mesh {
  22942. /** If octree should be generated */
  22943. generateOctree: boolean;
  22944. private _heightQuads;
  22945. /** @hidden */
  22946. _subdivisionsX: number;
  22947. /** @hidden */
  22948. _subdivisionsY: number;
  22949. /** @hidden */
  22950. _width: number;
  22951. /** @hidden */
  22952. _height: number;
  22953. /** @hidden */
  22954. _minX: number;
  22955. /** @hidden */
  22956. _maxX: number;
  22957. /** @hidden */
  22958. _minZ: number;
  22959. /** @hidden */
  22960. _maxZ: number;
  22961. constructor(name: string, scene: Scene);
  22962. /**
  22963. * "GroundMesh"
  22964. * @returns "GroundMesh"
  22965. */
  22966. getClassName(): string;
  22967. /**
  22968. * The minimum of x and y subdivisions
  22969. */
  22970. get subdivisions(): number;
  22971. /**
  22972. * X subdivisions
  22973. */
  22974. get subdivisionsX(): number;
  22975. /**
  22976. * Y subdivisions
  22977. */
  22978. get subdivisionsY(): number;
  22979. /**
  22980. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22981. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22982. * @param chunksCount the number of subdivisions for x and y
  22983. * @param octreeBlocksSize (Default: 32)
  22984. */
  22985. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22986. /**
  22987. * Returns a height (y) value in the Worl system :
  22988. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22989. * @param x x coordinate
  22990. * @param z z coordinate
  22991. * @returns the ground y position if (x, z) are outside the ground surface.
  22992. */
  22993. getHeightAtCoordinates(x: number, z: number): number;
  22994. /**
  22995. * Returns a normalized vector (Vector3) orthogonal to the ground
  22996. * at the ground coordinates (x, z) expressed in the World system.
  22997. * @param x x coordinate
  22998. * @param z z coordinate
  22999. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23000. */
  23001. getNormalAtCoordinates(x: number, z: number): Vector3;
  23002. /**
  23003. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23004. * at the ground coordinates (x, z) expressed in the World system.
  23005. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23006. * @param x x coordinate
  23007. * @param z z coordinate
  23008. * @param ref vector to store the result
  23009. * @returns the GroundMesh.
  23010. */
  23011. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23012. /**
  23013. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23014. * if the ground has been updated.
  23015. * This can be used in the render loop.
  23016. * @returns the GroundMesh.
  23017. */
  23018. updateCoordinateHeights(): GroundMesh;
  23019. private _getFacetAt;
  23020. private _initHeightQuads;
  23021. private _computeHeightQuads;
  23022. /**
  23023. * Serializes this ground mesh
  23024. * @param serializationObject object to write serialization to
  23025. */
  23026. serialize(serializationObject: any): void;
  23027. /**
  23028. * Parses a serialized ground mesh
  23029. * @param parsedMesh the serialized mesh
  23030. * @param scene the scene to create the ground mesh in
  23031. * @returns the created ground mesh
  23032. */
  23033. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23034. }
  23035. }
  23036. declare module BABYLON {
  23037. /**
  23038. * Interface for Physics-Joint data
  23039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23040. */
  23041. export interface PhysicsJointData {
  23042. /**
  23043. * The main pivot of the joint
  23044. */
  23045. mainPivot?: Vector3;
  23046. /**
  23047. * The connected pivot of the joint
  23048. */
  23049. connectedPivot?: Vector3;
  23050. /**
  23051. * The main axis of the joint
  23052. */
  23053. mainAxis?: Vector3;
  23054. /**
  23055. * The connected axis of the joint
  23056. */
  23057. connectedAxis?: Vector3;
  23058. /**
  23059. * The collision of the joint
  23060. */
  23061. collision?: boolean;
  23062. /**
  23063. * Native Oimo/Cannon/Energy data
  23064. */
  23065. nativeParams?: any;
  23066. }
  23067. /**
  23068. * This is a holder class for the physics joint created by the physics plugin
  23069. * It holds a set of functions to control the underlying joint
  23070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23071. */
  23072. export class PhysicsJoint {
  23073. /**
  23074. * The type of the physics joint
  23075. */
  23076. type: number;
  23077. /**
  23078. * The data for the physics joint
  23079. */
  23080. jointData: PhysicsJointData;
  23081. private _physicsJoint;
  23082. protected _physicsPlugin: IPhysicsEnginePlugin;
  23083. /**
  23084. * Initializes the physics joint
  23085. * @param type The type of the physics joint
  23086. * @param jointData The data for the physics joint
  23087. */
  23088. constructor(
  23089. /**
  23090. * The type of the physics joint
  23091. */
  23092. type: number,
  23093. /**
  23094. * The data for the physics joint
  23095. */
  23096. jointData: PhysicsJointData);
  23097. /**
  23098. * Gets the physics joint
  23099. */
  23100. get physicsJoint(): any;
  23101. /**
  23102. * Sets the physics joint
  23103. */
  23104. set physicsJoint(newJoint: any);
  23105. /**
  23106. * Sets the physics plugin
  23107. */
  23108. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23109. /**
  23110. * Execute a function that is physics-plugin specific.
  23111. * @param {Function} func the function that will be executed.
  23112. * It accepts two parameters: the physics world and the physics joint
  23113. */
  23114. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23115. /**
  23116. * Distance-Joint type
  23117. */
  23118. static DistanceJoint: number;
  23119. /**
  23120. * Hinge-Joint type
  23121. */
  23122. static HingeJoint: number;
  23123. /**
  23124. * Ball-and-Socket joint type
  23125. */
  23126. static BallAndSocketJoint: number;
  23127. /**
  23128. * Wheel-Joint type
  23129. */
  23130. static WheelJoint: number;
  23131. /**
  23132. * Slider-Joint type
  23133. */
  23134. static SliderJoint: number;
  23135. /**
  23136. * Prismatic-Joint type
  23137. */
  23138. static PrismaticJoint: number;
  23139. /**
  23140. * Universal-Joint type
  23141. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23142. */
  23143. static UniversalJoint: number;
  23144. /**
  23145. * Hinge-Joint 2 type
  23146. */
  23147. static Hinge2Joint: number;
  23148. /**
  23149. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23150. */
  23151. static PointToPointJoint: number;
  23152. /**
  23153. * Spring-Joint type
  23154. */
  23155. static SpringJoint: number;
  23156. /**
  23157. * Lock-Joint type
  23158. */
  23159. static LockJoint: number;
  23160. }
  23161. /**
  23162. * A class representing a physics distance joint
  23163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23164. */
  23165. export class DistanceJoint extends PhysicsJoint {
  23166. /**
  23167. *
  23168. * @param jointData The data for the Distance-Joint
  23169. */
  23170. constructor(jointData: DistanceJointData);
  23171. /**
  23172. * Update the predefined distance.
  23173. * @param maxDistance The maximum preferred distance
  23174. * @param minDistance The minimum preferred distance
  23175. */
  23176. updateDistance(maxDistance: number, minDistance?: number): void;
  23177. }
  23178. /**
  23179. * Represents a Motor-Enabled Joint
  23180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23181. */
  23182. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23183. /**
  23184. * Initializes the Motor-Enabled Joint
  23185. * @param type The type of the joint
  23186. * @param jointData The physica joint data for the joint
  23187. */
  23188. constructor(type: number, jointData: PhysicsJointData);
  23189. /**
  23190. * Set the motor values.
  23191. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23192. * @param force the force to apply
  23193. * @param maxForce max force for this motor.
  23194. */
  23195. setMotor(force?: number, maxForce?: number): void;
  23196. /**
  23197. * Set the motor's limits.
  23198. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23199. * @param upperLimit The upper limit of the motor
  23200. * @param lowerLimit The lower limit of the motor
  23201. */
  23202. setLimit(upperLimit: number, lowerLimit?: number): void;
  23203. }
  23204. /**
  23205. * This class represents a single physics Hinge-Joint
  23206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23207. */
  23208. export class HingeJoint extends MotorEnabledJoint {
  23209. /**
  23210. * Initializes the Hinge-Joint
  23211. * @param jointData The joint data for the Hinge-Joint
  23212. */
  23213. constructor(jointData: PhysicsJointData);
  23214. /**
  23215. * Set the motor values.
  23216. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23217. * @param {number} force the force to apply
  23218. * @param {number} maxForce max force for this motor.
  23219. */
  23220. setMotor(force?: number, maxForce?: number): void;
  23221. /**
  23222. * Set the motor's limits.
  23223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23224. * @param upperLimit The upper limit of the motor
  23225. * @param lowerLimit The lower limit of the motor
  23226. */
  23227. setLimit(upperLimit: number, lowerLimit?: number): void;
  23228. }
  23229. /**
  23230. * This class represents a dual hinge physics joint (same as wheel joint)
  23231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23232. */
  23233. export class Hinge2Joint extends MotorEnabledJoint {
  23234. /**
  23235. * Initializes the Hinge2-Joint
  23236. * @param jointData The joint data for the Hinge2-Joint
  23237. */
  23238. constructor(jointData: PhysicsJointData);
  23239. /**
  23240. * Set the motor values.
  23241. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23242. * @param {number} targetSpeed the speed the motor is to reach
  23243. * @param {number} maxForce max force for this motor.
  23244. * @param {motorIndex} the motor's index, 0 or 1.
  23245. */
  23246. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23247. /**
  23248. * Set the motor limits.
  23249. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23250. * @param {number} upperLimit the upper limit
  23251. * @param {number} lowerLimit lower limit
  23252. * @param {motorIndex} the motor's index, 0 or 1.
  23253. */
  23254. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23255. }
  23256. /**
  23257. * Interface for a motor enabled joint
  23258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23259. */
  23260. export interface IMotorEnabledJoint {
  23261. /**
  23262. * Physics joint
  23263. */
  23264. physicsJoint: any;
  23265. /**
  23266. * Sets the motor of the motor-enabled joint
  23267. * @param force The force of the motor
  23268. * @param maxForce The maximum force of the motor
  23269. * @param motorIndex The index of the motor
  23270. */
  23271. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23272. /**
  23273. * Sets the limit of the motor
  23274. * @param upperLimit The upper limit of the motor
  23275. * @param lowerLimit The lower limit of the motor
  23276. * @param motorIndex The index of the motor
  23277. */
  23278. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23279. }
  23280. /**
  23281. * Joint data for a Distance-Joint
  23282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23283. */
  23284. export interface DistanceJointData extends PhysicsJointData {
  23285. /**
  23286. * Max distance the 2 joint objects can be apart
  23287. */
  23288. maxDistance: number;
  23289. }
  23290. /**
  23291. * Joint data from a spring joint
  23292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23293. */
  23294. export interface SpringJointData extends PhysicsJointData {
  23295. /**
  23296. * Length of the spring
  23297. */
  23298. length: number;
  23299. /**
  23300. * Stiffness of the spring
  23301. */
  23302. stiffness: number;
  23303. /**
  23304. * Damping of the spring
  23305. */
  23306. damping: number;
  23307. /** this callback will be called when applying the force to the impostors. */
  23308. forceApplicationCallback: () => void;
  23309. }
  23310. }
  23311. declare module BABYLON {
  23312. /**
  23313. * Holds the data for the raycast result
  23314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23315. */
  23316. export class PhysicsRaycastResult {
  23317. private _hasHit;
  23318. private _hitDistance;
  23319. private _hitNormalWorld;
  23320. private _hitPointWorld;
  23321. private _rayFromWorld;
  23322. private _rayToWorld;
  23323. /**
  23324. * Gets if there was a hit
  23325. */
  23326. get hasHit(): boolean;
  23327. /**
  23328. * Gets the distance from the hit
  23329. */
  23330. get hitDistance(): number;
  23331. /**
  23332. * Gets the hit normal/direction in the world
  23333. */
  23334. get hitNormalWorld(): Vector3;
  23335. /**
  23336. * Gets the hit point in the world
  23337. */
  23338. get hitPointWorld(): Vector3;
  23339. /**
  23340. * Gets the ray "start point" of the ray in the world
  23341. */
  23342. get rayFromWorld(): Vector3;
  23343. /**
  23344. * Gets the ray "end point" of the ray in the world
  23345. */
  23346. get rayToWorld(): Vector3;
  23347. /**
  23348. * Sets the hit data (normal & point in world space)
  23349. * @param hitNormalWorld defines the normal in world space
  23350. * @param hitPointWorld defines the point in world space
  23351. */
  23352. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23353. /**
  23354. * Sets the distance from the start point to the hit point
  23355. * @param distance
  23356. */
  23357. setHitDistance(distance: number): void;
  23358. /**
  23359. * Calculates the distance manually
  23360. */
  23361. calculateHitDistance(): void;
  23362. /**
  23363. * Resets all the values to default
  23364. * @param from The from point on world space
  23365. * @param to The to point on world space
  23366. */
  23367. reset(from?: Vector3, to?: Vector3): void;
  23368. }
  23369. /**
  23370. * Interface for the size containing width and height
  23371. */
  23372. interface IXYZ {
  23373. /**
  23374. * X
  23375. */
  23376. x: number;
  23377. /**
  23378. * Y
  23379. */
  23380. y: number;
  23381. /**
  23382. * Z
  23383. */
  23384. z: number;
  23385. }
  23386. }
  23387. declare module BABYLON {
  23388. /**
  23389. * Interface used to describe a physics joint
  23390. */
  23391. export interface PhysicsImpostorJoint {
  23392. /** Defines the main impostor to which the joint is linked */
  23393. mainImpostor: PhysicsImpostor;
  23394. /** Defines the impostor that is connected to the main impostor using this joint */
  23395. connectedImpostor: PhysicsImpostor;
  23396. /** Defines the joint itself */
  23397. joint: PhysicsJoint;
  23398. }
  23399. /** @hidden */
  23400. export interface IPhysicsEnginePlugin {
  23401. world: any;
  23402. name: string;
  23403. setGravity(gravity: Vector3): void;
  23404. setTimeStep(timeStep: number): void;
  23405. getTimeStep(): number;
  23406. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23407. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23408. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23409. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23410. removePhysicsBody(impostor: PhysicsImpostor): void;
  23411. generateJoint(joint: PhysicsImpostorJoint): void;
  23412. removeJoint(joint: PhysicsImpostorJoint): void;
  23413. isSupported(): boolean;
  23414. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23415. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23416. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23417. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23418. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23420. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23421. getBodyMass(impostor: PhysicsImpostor): number;
  23422. getBodyFriction(impostor: PhysicsImpostor): number;
  23423. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23424. getBodyRestitution(impostor: PhysicsImpostor): number;
  23425. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23426. getBodyPressure?(impostor: PhysicsImpostor): number;
  23427. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23428. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23429. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23430. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23431. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23432. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23433. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23434. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23435. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23436. sleepBody(impostor: PhysicsImpostor): void;
  23437. wakeUpBody(impostor: PhysicsImpostor): void;
  23438. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23439. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23440. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23441. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23442. getRadius(impostor: PhysicsImpostor): number;
  23443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23444. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23445. dispose(): void;
  23446. }
  23447. /**
  23448. * Interface used to define a physics engine
  23449. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23450. */
  23451. export interface IPhysicsEngine {
  23452. /**
  23453. * Gets the gravity vector used by the simulation
  23454. */
  23455. gravity: Vector3;
  23456. /**
  23457. * Sets the gravity vector used by the simulation
  23458. * @param gravity defines the gravity vector to use
  23459. */
  23460. setGravity(gravity: Vector3): void;
  23461. /**
  23462. * Set the time step of the physics engine.
  23463. * Default is 1/60.
  23464. * To slow it down, enter 1/600 for example.
  23465. * To speed it up, 1/30
  23466. * @param newTimeStep the new timestep to apply to this world.
  23467. */
  23468. setTimeStep(newTimeStep: number): void;
  23469. /**
  23470. * Get the time step of the physics engine.
  23471. * @returns the current time step
  23472. */
  23473. getTimeStep(): number;
  23474. /**
  23475. * Set the sub time step of the physics engine.
  23476. * Default is 0 meaning there is no sub steps
  23477. * To increase physics resolution precision, set a small value (like 1 ms)
  23478. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23479. */
  23480. setSubTimeStep(subTimeStep: number): void;
  23481. /**
  23482. * Get the sub time step of the physics engine.
  23483. * @returns the current sub time step
  23484. */
  23485. getSubTimeStep(): number;
  23486. /**
  23487. * Release all resources
  23488. */
  23489. dispose(): void;
  23490. /**
  23491. * Gets the name of the current physics plugin
  23492. * @returns the name of the plugin
  23493. */
  23494. getPhysicsPluginName(): string;
  23495. /**
  23496. * Adding a new impostor for the impostor tracking.
  23497. * This will be done by the impostor itself.
  23498. * @param impostor the impostor to add
  23499. */
  23500. addImpostor(impostor: PhysicsImpostor): void;
  23501. /**
  23502. * Remove an impostor from the engine.
  23503. * This impostor and its mesh will not longer be updated by the physics engine.
  23504. * @param impostor the impostor to remove
  23505. */
  23506. removeImpostor(impostor: PhysicsImpostor): void;
  23507. /**
  23508. * Add a joint to the physics engine
  23509. * @param mainImpostor defines the main impostor to which the joint is added.
  23510. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23511. * @param joint defines the joint that will connect both impostors.
  23512. */
  23513. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23514. /**
  23515. * Removes a joint from the simulation
  23516. * @param mainImpostor defines the impostor used with the joint
  23517. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23518. * @param joint defines the joint to remove
  23519. */
  23520. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23521. /**
  23522. * Gets the current plugin used to run the simulation
  23523. * @returns current plugin
  23524. */
  23525. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23526. /**
  23527. * Gets the list of physic impostors
  23528. * @returns an array of PhysicsImpostor
  23529. */
  23530. getImpostors(): Array<PhysicsImpostor>;
  23531. /**
  23532. * Gets the impostor for a physics enabled object
  23533. * @param object defines the object impersonated by the impostor
  23534. * @returns the PhysicsImpostor or null if not found
  23535. */
  23536. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23537. /**
  23538. * Gets the impostor for a physics body object
  23539. * @param body defines physics body used by the impostor
  23540. * @returns the PhysicsImpostor or null if not found
  23541. */
  23542. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23543. /**
  23544. * Does a raycast in the physics world
  23545. * @param from when should the ray start?
  23546. * @param to when should the ray end?
  23547. * @returns PhysicsRaycastResult
  23548. */
  23549. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23550. /**
  23551. * Called by the scene. No need to call it.
  23552. * @param delta defines the timespam between frames
  23553. */
  23554. _step(delta: number): void;
  23555. }
  23556. }
  23557. declare module BABYLON {
  23558. /**
  23559. * The interface for the physics imposter parameters
  23560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23561. */
  23562. export interface PhysicsImpostorParameters {
  23563. /**
  23564. * The mass of the physics imposter
  23565. */
  23566. mass: number;
  23567. /**
  23568. * The friction of the physics imposter
  23569. */
  23570. friction?: number;
  23571. /**
  23572. * The coefficient of restitution of the physics imposter
  23573. */
  23574. restitution?: number;
  23575. /**
  23576. * The native options of the physics imposter
  23577. */
  23578. nativeOptions?: any;
  23579. /**
  23580. * Specifies if the parent should be ignored
  23581. */
  23582. ignoreParent?: boolean;
  23583. /**
  23584. * Specifies if bi-directional transformations should be disabled
  23585. */
  23586. disableBidirectionalTransformation?: boolean;
  23587. /**
  23588. * The pressure inside the physics imposter, soft object only
  23589. */
  23590. pressure?: number;
  23591. /**
  23592. * The stiffness the physics imposter, soft object only
  23593. */
  23594. stiffness?: number;
  23595. /**
  23596. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23597. */
  23598. velocityIterations?: number;
  23599. /**
  23600. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23601. */
  23602. positionIterations?: number;
  23603. /**
  23604. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23605. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23606. * Add to fix multiple points
  23607. */
  23608. fixedPoints?: number;
  23609. /**
  23610. * The collision margin around a soft object
  23611. */
  23612. margin?: number;
  23613. /**
  23614. * The collision margin around a soft object
  23615. */
  23616. damping?: number;
  23617. /**
  23618. * The path for a rope based on an extrusion
  23619. */
  23620. path?: any;
  23621. /**
  23622. * The shape of an extrusion used for a rope based on an extrusion
  23623. */
  23624. shape?: any;
  23625. }
  23626. /**
  23627. * Interface for a physics-enabled object
  23628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23629. */
  23630. export interface IPhysicsEnabledObject {
  23631. /**
  23632. * The position of the physics-enabled object
  23633. */
  23634. position: Vector3;
  23635. /**
  23636. * The rotation of the physics-enabled object
  23637. */
  23638. rotationQuaternion: Nullable<Quaternion>;
  23639. /**
  23640. * The scale of the physics-enabled object
  23641. */
  23642. scaling: Vector3;
  23643. /**
  23644. * The rotation of the physics-enabled object
  23645. */
  23646. rotation?: Vector3;
  23647. /**
  23648. * The parent of the physics-enabled object
  23649. */
  23650. parent?: any;
  23651. /**
  23652. * The bounding info of the physics-enabled object
  23653. * @returns The bounding info of the physics-enabled object
  23654. */
  23655. getBoundingInfo(): BoundingInfo;
  23656. /**
  23657. * Computes the world matrix
  23658. * @param force Specifies if the world matrix should be computed by force
  23659. * @returns A world matrix
  23660. */
  23661. computeWorldMatrix(force: boolean): Matrix;
  23662. /**
  23663. * Gets the world matrix
  23664. * @returns A world matrix
  23665. */
  23666. getWorldMatrix?(): Matrix;
  23667. /**
  23668. * Gets the child meshes
  23669. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23670. * @returns An array of abstract meshes
  23671. */
  23672. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23673. /**
  23674. * Gets the vertex data
  23675. * @param kind The type of vertex data
  23676. * @returns A nullable array of numbers, or a float32 array
  23677. */
  23678. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23679. /**
  23680. * Gets the indices from the mesh
  23681. * @returns A nullable array of index arrays
  23682. */
  23683. getIndices?(): Nullable<IndicesArray>;
  23684. /**
  23685. * Gets the scene from the mesh
  23686. * @returns the indices array or null
  23687. */
  23688. getScene?(): Scene;
  23689. /**
  23690. * Gets the absolute position from the mesh
  23691. * @returns the absolute position
  23692. */
  23693. getAbsolutePosition(): Vector3;
  23694. /**
  23695. * Gets the absolute pivot point from the mesh
  23696. * @returns the absolute pivot point
  23697. */
  23698. getAbsolutePivotPoint(): Vector3;
  23699. /**
  23700. * Rotates the mesh
  23701. * @param axis The axis of rotation
  23702. * @param amount The amount of rotation
  23703. * @param space The space of the rotation
  23704. * @returns The rotation transform node
  23705. */
  23706. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23707. /**
  23708. * Translates the mesh
  23709. * @param axis The axis of translation
  23710. * @param distance The distance of translation
  23711. * @param space The space of the translation
  23712. * @returns The transform node
  23713. */
  23714. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23715. /**
  23716. * Sets the absolute position of the mesh
  23717. * @param absolutePosition The absolute position of the mesh
  23718. * @returns The transform node
  23719. */
  23720. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23721. /**
  23722. * Gets the class name of the mesh
  23723. * @returns The class name
  23724. */
  23725. getClassName(): string;
  23726. }
  23727. /**
  23728. * Represents a physics imposter
  23729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23730. */
  23731. export class PhysicsImpostor {
  23732. /**
  23733. * The physics-enabled object used as the physics imposter
  23734. */
  23735. object: IPhysicsEnabledObject;
  23736. /**
  23737. * The type of the physics imposter
  23738. */
  23739. type: number;
  23740. private _options;
  23741. private _scene?;
  23742. /**
  23743. * The default object size of the imposter
  23744. */
  23745. static DEFAULT_OBJECT_SIZE: Vector3;
  23746. /**
  23747. * The identity quaternion of the imposter
  23748. */
  23749. static IDENTITY_QUATERNION: Quaternion;
  23750. /** @hidden */
  23751. _pluginData: any;
  23752. private _physicsEngine;
  23753. private _physicsBody;
  23754. private _bodyUpdateRequired;
  23755. private _onBeforePhysicsStepCallbacks;
  23756. private _onAfterPhysicsStepCallbacks;
  23757. /** @hidden */
  23758. _onPhysicsCollideCallbacks: Array<{
  23759. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23760. otherImpostors: Array<PhysicsImpostor>;
  23761. }>;
  23762. private _deltaPosition;
  23763. private _deltaRotation;
  23764. private _deltaRotationConjugated;
  23765. /** @hidden */
  23766. _isFromLine: boolean;
  23767. private _parent;
  23768. private _isDisposed;
  23769. private static _tmpVecs;
  23770. private static _tmpQuat;
  23771. /**
  23772. * Specifies if the physics imposter is disposed
  23773. */
  23774. get isDisposed(): boolean;
  23775. /**
  23776. * Gets the mass of the physics imposter
  23777. */
  23778. get mass(): number;
  23779. set mass(value: number);
  23780. /**
  23781. * Gets the coefficient of friction
  23782. */
  23783. get friction(): number;
  23784. /**
  23785. * Sets the coefficient of friction
  23786. */
  23787. set friction(value: number);
  23788. /**
  23789. * Gets the coefficient of restitution
  23790. */
  23791. get restitution(): number;
  23792. /**
  23793. * Sets the coefficient of restitution
  23794. */
  23795. set restitution(value: number);
  23796. /**
  23797. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23798. */
  23799. get pressure(): number;
  23800. /**
  23801. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23802. */
  23803. set pressure(value: number);
  23804. /**
  23805. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23806. */
  23807. get stiffness(): number;
  23808. /**
  23809. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23810. */
  23811. set stiffness(value: number);
  23812. /**
  23813. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23814. */
  23815. get velocityIterations(): number;
  23816. /**
  23817. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23818. */
  23819. set velocityIterations(value: number);
  23820. /**
  23821. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23822. */
  23823. get positionIterations(): number;
  23824. /**
  23825. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23826. */
  23827. set positionIterations(value: number);
  23828. /**
  23829. * The unique id of the physics imposter
  23830. * set by the physics engine when adding this impostor to the array
  23831. */
  23832. uniqueId: number;
  23833. /**
  23834. * @hidden
  23835. */
  23836. soft: boolean;
  23837. /**
  23838. * @hidden
  23839. */
  23840. segments: number;
  23841. private _joints;
  23842. /**
  23843. * Initializes the physics imposter
  23844. * @param object The physics-enabled object used as the physics imposter
  23845. * @param type The type of the physics imposter
  23846. * @param _options The options for the physics imposter
  23847. * @param _scene The Babylon scene
  23848. */
  23849. constructor(
  23850. /**
  23851. * The physics-enabled object used as the physics imposter
  23852. */
  23853. object: IPhysicsEnabledObject,
  23854. /**
  23855. * The type of the physics imposter
  23856. */
  23857. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23858. /**
  23859. * This function will completly initialize this impostor.
  23860. * It will create a new body - but only if this mesh has no parent.
  23861. * If it has, this impostor will not be used other than to define the impostor
  23862. * of the child mesh.
  23863. * @hidden
  23864. */
  23865. _init(): void;
  23866. private _getPhysicsParent;
  23867. /**
  23868. * Should a new body be generated.
  23869. * @returns boolean specifying if body initialization is required
  23870. */
  23871. isBodyInitRequired(): boolean;
  23872. /**
  23873. * Sets the updated scaling
  23874. * @param updated Specifies if the scaling is updated
  23875. */
  23876. setScalingUpdated(): void;
  23877. /**
  23878. * Force a regeneration of this or the parent's impostor's body.
  23879. * Use under cautious - This will remove all joints already implemented.
  23880. */
  23881. forceUpdate(): void;
  23882. /**
  23883. * Gets the body that holds this impostor. Either its own, or its parent.
  23884. */
  23885. get physicsBody(): any;
  23886. /**
  23887. * Get the parent of the physics imposter
  23888. * @returns Physics imposter or null
  23889. */
  23890. get parent(): Nullable<PhysicsImpostor>;
  23891. /**
  23892. * Sets the parent of the physics imposter
  23893. */
  23894. set parent(value: Nullable<PhysicsImpostor>);
  23895. /**
  23896. * Set the physics body. Used mainly by the physics engine/plugin
  23897. */
  23898. set physicsBody(physicsBody: any);
  23899. /**
  23900. * Resets the update flags
  23901. */
  23902. resetUpdateFlags(): void;
  23903. /**
  23904. * Gets the object extend size
  23905. * @returns the object extend size
  23906. */
  23907. getObjectExtendSize(): Vector3;
  23908. /**
  23909. * Gets the object center
  23910. * @returns The object center
  23911. */
  23912. getObjectCenter(): Vector3;
  23913. /**
  23914. * Get a specific parameter from the options parameters
  23915. * @param paramName The object parameter name
  23916. * @returns The object parameter
  23917. */
  23918. getParam(paramName: string): any;
  23919. /**
  23920. * Sets a specific parameter in the options given to the physics plugin
  23921. * @param paramName The parameter name
  23922. * @param value The value of the parameter
  23923. */
  23924. setParam(paramName: string, value: number): void;
  23925. /**
  23926. * Specifically change the body's mass option. Won't recreate the physics body object
  23927. * @param mass The mass of the physics imposter
  23928. */
  23929. setMass(mass: number): void;
  23930. /**
  23931. * Gets the linear velocity
  23932. * @returns linear velocity or null
  23933. */
  23934. getLinearVelocity(): Nullable<Vector3>;
  23935. /**
  23936. * Sets the linear velocity
  23937. * @param velocity linear velocity or null
  23938. */
  23939. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23940. /**
  23941. * Gets the angular velocity
  23942. * @returns angular velocity or null
  23943. */
  23944. getAngularVelocity(): Nullable<Vector3>;
  23945. /**
  23946. * Sets the angular velocity
  23947. * @param velocity The velocity or null
  23948. */
  23949. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23950. /**
  23951. * Execute a function with the physics plugin native code
  23952. * Provide a function the will have two variables - the world object and the physics body object
  23953. * @param func The function to execute with the physics plugin native code
  23954. */
  23955. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23956. /**
  23957. * Register a function that will be executed before the physics world is stepping forward
  23958. * @param func The function to execute before the physics world is stepped forward
  23959. */
  23960. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23961. /**
  23962. * Unregister a function that will be executed before the physics world is stepping forward
  23963. * @param func The function to execute before the physics world is stepped forward
  23964. */
  23965. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23966. /**
  23967. * Register a function that will be executed after the physics step
  23968. * @param func The function to execute after physics step
  23969. */
  23970. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23971. /**
  23972. * Unregisters a function that will be executed after the physics step
  23973. * @param func The function to execute after physics step
  23974. */
  23975. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23976. /**
  23977. * register a function that will be executed when this impostor collides against a different body
  23978. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23979. * @param func Callback that is executed on collision
  23980. */
  23981. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23982. /**
  23983. * Unregisters the physics imposter on contact
  23984. * @param collideAgainst The physics object to collide against
  23985. * @param func Callback to execute on collision
  23986. */
  23987. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23988. private _tmpQuat;
  23989. private _tmpQuat2;
  23990. /**
  23991. * Get the parent rotation
  23992. * @returns The parent rotation
  23993. */
  23994. getParentsRotation(): Quaternion;
  23995. /**
  23996. * this function is executed by the physics engine.
  23997. */
  23998. beforeStep: () => void;
  23999. /**
  24000. * this function is executed by the physics engine
  24001. */
  24002. afterStep: () => void;
  24003. /**
  24004. * Legacy collision detection event support
  24005. */
  24006. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24007. /**
  24008. * event and body object due to cannon's event-based architecture.
  24009. */
  24010. onCollide: (e: {
  24011. body: any;
  24012. }) => void;
  24013. /**
  24014. * Apply a force
  24015. * @param force The force to apply
  24016. * @param contactPoint The contact point for the force
  24017. * @returns The physics imposter
  24018. */
  24019. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24020. /**
  24021. * Apply an impulse
  24022. * @param force The impulse force
  24023. * @param contactPoint The contact point for the impulse force
  24024. * @returns The physics imposter
  24025. */
  24026. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24027. /**
  24028. * A help function to create a joint
  24029. * @param otherImpostor A physics imposter used to create a joint
  24030. * @param jointType The type of joint
  24031. * @param jointData The data for the joint
  24032. * @returns The physics imposter
  24033. */
  24034. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24035. /**
  24036. * Add a joint to this impostor with a different impostor
  24037. * @param otherImpostor A physics imposter used to add a joint
  24038. * @param joint The joint to add
  24039. * @returns The physics imposter
  24040. */
  24041. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24042. /**
  24043. * Add an anchor to a cloth impostor
  24044. * @param otherImpostor rigid impostor to anchor to
  24045. * @param width ratio across width from 0 to 1
  24046. * @param height ratio up height from 0 to 1
  24047. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24048. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24049. * @returns impostor the soft imposter
  24050. */
  24051. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24052. /**
  24053. * Add a hook to a rope impostor
  24054. * @param otherImpostor rigid impostor to anchor to
  24055. * @param length ratio across rope from 0 to 1
  24056. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24057. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24058. * @returns impostor the rope imposter
  24059. */
  24060. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24061. /**
  24062. * Will keep this body still, in a sleep mode.
  24063. * @returns the physics imposter
  24064. */
  24065. sleep(): PhysicsImpostor;
  24066. /**
  24067. * Wake the body up.
  24068. * @returns The physics imposter
  24069. */
  24070. wakeUp(): PhysicsImpostor;
  24071. /**
  24072. * Clones the physics imposter
  24073. * @param newObject The physics imposter clones to this physics-enabled object
  24074. * @returns A nullable physics imposter
  24075. */
  24076. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24077. /**
  24078. * Disposes the physics imposter
  24079. */
  24080. dispose(): void;
  24081. /**
  24082. * Sets the delta position
  24083. * @param position The delta position amount
  24084. */
  24085. setDeltaPosition(position: Vector3): void;
  24086. /**
  24087. * Sets the delta rotation
  24088. * @param rotation The delta rotation amount
  24089. */
  24090. setDeltaRotation(rotation: Quaternion): void;
  24091. /**
  24092. * Gets the box size of the physics imposter and stores the result in the input parameter
  24093. * @param result Stores the box size
  24094. * @returns The physics imposter
  24095. */
  24096. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24097. /**
  24098. * Gets the radius of the physics imposter
  24099. * @returns Radius of the physics imposter
  24100. */
  24101. getRadius(): number;
  24102. /**
  24103. * Sync a bone with this impostor
  24104. * @param bone The bone to sync to the impostor.
  24105. * @param boneMesh The mesh that the bone is influencing.
  24106. * @param jointPivot The pivot of the joint / bone in local space.
  24107. * @param distToJoint Optional distance from the impostor to the joint.
  24108. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24109. */
  24110. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24111. /**
  24112. * Sync impostor to a bone
  24113. * @param bone The bone that the impostor will be synced to.
  24114. * @param boneMesh The mesh that the bone is influencing.
  24115. * @param jointPivot The pivot of the joint / bone in local space.
  24116. * @param distToJoint Optional distance from the impostor to the joint.
  24117. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24118. * @param boneAxis Optional vector3 axis the bone is aligned with
  24119. */
  24120. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24121. /**
  24122. * No-Imposter type
  24123. */
  24124. static NoImpostor: number;
  24125. /**
  24126. * Sphere-Imposter type
  24127. */
  24128. static SphereImpostor: number;
  24129. /**
  24130. * Box-Imposter type
  24131. */
  24132. static BoxImpostor: number;
  24133. /**
  24134. * Plane-Imposter type
  24135. */
  24136. static PlaneImpostor: number;
  24137. /**
  24138. * Mesh-imposter type
  24139. */
  24140. static MeshImpostor: number;
  24141. /**
  24142. * Capsule-Impostor type (Ammo.js plugin only)
  24143. */
  24144. static CapsuleImpostor: number;
  24145. /**
  24146. * Cylinder-Imposter type
  24147. */
  24148. static CylinderImpostor: number;
  24149. /**
  24150. * Particle-Imposter type
  24151. */
  24152. static ParticleImpostor: number;
  24153. /**
  24154. * Heightmap-Imposter type
  24155. */
  24156. static HeightmapImpostor: number;
  24157. /**
  24158. * ConvexHull-Impostor type (Ammo.js plugin only)
  24159. */
  24160. static ConvexHullImpostor: number;
  24161. /**
  24162. * Custom-Imposter type (Ammo.js plugin only)
  24163. */
  24164. static CustomImpostor: number;
  24165. /**
  24166. * Rope-Imposter type
  24167. */
  24168. static RopeImpostor: number;
  24169. /**
  24170. * Cloth-Imposter type
  24171. */
  24172. static ClothImpostor: number;
  24173. /**
  24174. * Softbody-Imposter type
  24175. */
  24176. static SoftbodyImpostor: number;
  24177. }
  24178. }
  24179. declare module BABYLON {
  24180. /**
  24181. * @hidden
  24182. **/
  24183. export class _CreationDataStorage {
  24184. closePath?: boolean;
  24185. closeArray?: boolean;
  24186. idx: number[];
  24187. dashSize: number;
  24188. gapSize: number;
  24189. path3D: Path3D;
  24190. pathArray: Vector3[][];
  24191. arc: number;
  24192. radius: number;
  24193. cap: number;
  24194. tessellation: number;
  24195. }
  24196. /**
  24197. * @hidden
  24198. **/
  24199. class _InstanceDataStorage {
  24200. visibleInstances: any;
  24201. batchCache: _InstancesBatch;
  24202. instancesBufferSize: number;
  24203. instancesBuffer: Nullable<Buffer>;
  24204. instancesData: Float32Array;
  24205. overridenInstanceCount: number;
  24206. isFrozen: boolean;
  24207. previousBatch: Nullable<_InstancesBatch>;
  24208. hardwareInstancedRendering: boolean;
  24209. sideOrientation: number;
  24210. manualUpdate: boolean;
  24211. }
  24212. /**
  24213. * @hidden
  24214. **/
  24215. export class _InstancesBatch {
  24216. mustReturn: boolean;
  24217. visibleInstances: Nullable<InstancedMesh[]>[];
  24218. renderSelf: boolean[];
  24219. hardwareInstancedRendering: boolean[];
  24220. }
  24221. /**
  24222. * Class used to represent renderable models
  24223. */
  24224. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24225. /**
  24226. * Mesh side orientation : usually the external or front surface
  24227. */
  24228. static readonly FRONTSIDE: number;
  24229. /**
  24230. * Mesh side orientation : usually the internal or back surface
  24231. */
  24232. static readonly BACKSIDE: number;
  24233. /**
  24234. * Mesh side orientation : both internal and external or front and back surfaces
  24235. */
  24236. static readonly DOUBLESIDE: number;
  24237. /**
  24238. * Mesh side orientation : by default, `FRONTSIDE`
  24239. */
  24240. static readonly DEFAULTSIDE: number;
  24241. /**
  24242. * Mesh cap setting : no cap
  24243. */
  24244. static readonly NO_CAP: number;
  24245. /**
  24246. * Mesh cap setting : one cap at the beginning of the mesh
  24247. */
  24248. static readonly CAP_START: number;
  24249. /**
  24250. * Mesh cap setting : one cap at the end of the mesh
  24251. */
  24252. static readonly CAP_END: number;
  24253. /**
  24254. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24255. */
  24256. static readonly CAP_ALL: number;
  24257. /**
  24258. * Mesh pattern setting : no flip or rotate
  24259. */
  24260. static readonly NO_FLIP: number;
  24261. /**
  24262. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24263. */
  24264. static readonly FLIP_TILE: number;
  24265. /**
  24266. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24267. */
  24268. static readonly ROTATE_TILE: number;
  24269. /**
  24270. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24271. */
  24272. static readonly FLIP_ROW: number;
  24273. /**
  24274. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24275. */
  24276. static readonly ROTATE_ROW: number;
  24277. /**
  24278. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24279. */
  24280. static readonly FLIP_N_ROTATE_TILE: number;
  24281. /**
  24282. * Mesh pattern setting : rotate pattern and rotate
  24283. */
  24284. static readonly FLIP_N_ROTATE_ROW: number;
  24285. /**
  24286. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24287. */
  24288. static readonly CENTER: number;
  24289. /**
  24290. * Mesh tile positioning : part tiles on left
  24291. */
  24292. static readonly LEFT: number;
  24293. /**
  24294. * Mesh tile positioning : part tiles on right
  24295. */
  24296. static readonly RIGHT: number;
  24297. /**
  24298. * Mesh tile positioning : part tiles on top
  24299. */
  24300. static readonly TOP: number;
  24301. /**
  24302. * Mesh tile positioning : part tiles on bottom
  24303. */
  24304. static readonly BOTTOM: number;
  24305. /**
  24306. * Gets the default side orientation.
  24307. * @param orientation the orientation to value to attempt to get
  24308. * @returns the default orientation
  24309. * @hidden
  24310. */
  24311. static _GetDefaultSideOrientation(orientation?: number): number;
  24312. private _internalMeshDataInfo;
  24313. /**
  24314. * An event triggered before rendering the mesh
  24315. */
  24316. get onBeforeRenderObservable(): Observable<Mesh>;
  24317. /**
  24318. * An event triggered before binding the mesh
  24319. */
  24320. get onBeforeBindObservable(): Observable<Mesh>;
  24321. /**
  24322. * An event triggered after rendering the mesh
  24323. */
  24324. get onAfterRenderObservable(): Observable<Mesh>;
  24325. /**
  24326. * An event triggered before drawing the mesh
  24327. */
  24328. get onBeforeDrawObservable(): Observable<Mesh>;
  24329. private _onBeforeDrawObserver;
  24330. /**
  24331. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24332. */
  24333. set onBeforeDraw(callback: () => void);
  24334. get hasInstances(): boolean;
  24335. /**
  24336. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24337. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24338. */
  24339. delayLoadState: number;
  24340. /**
  24341. * Gets the list of instances created from this mesh
  24342. * it is not supposed to be modified manually.
  24343. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24344. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24345. */
  24346. instances: InstancedMesh[];
  24347. /**
  24348. * Gets the file containing delay loading data for this mesh
  24349. */
  24350. delayLoadingFile: string;
  24351. /** @hidden */
  24352. _binaryInfo: any;
  24353. /**
  24354. * User defined function used to change how LOD level selection is done
  24355. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24356. */
  24357. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24358. /**
  24359. * Gets or sets the morph target manager
  24360. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24361. */
  24362. get morphTargetManager(): Nullable<MorphTargetManager>;
  24363. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24364. /** @hidden */
  24365. _creationDataStorage: Nullable<_CreationDataStorage>;
  24366. /** @hidden */
  24367. _geometry: Nullable<Geometry>;
  24368. /** @hidden */
  24369. _delayInfo: Array<string>;
  24370. /** @hidden */
  24371. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24372. /** @hidden */
  24373. _instanceDataStorage: _InstanceDataStorage;
  24374. private _effectiveMaterial;
  24375. /** @hidden */
  24376. _shouldGenerateFlatShading: boolean;
  24377. /** @hidden */
  24378. _originalBuilderSideOrientation: number;
  24379. /**
  24380. * Use this property to change the original side orientation defined at construction time
  24381. */
  24382. overrideMaterialSideOrientation: Nullable<number>;
  24383. /**
  24384. * Gets the source mesh (the one used to clone this one from)
  24385. */
  24386. get source(): Nullable<Mesh>;
  24387. /**
  24388. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24389. */
  24390. get isUnIndexed(): boolean;
  24391. set isUnIndexed(value: boolean);
  24392. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24393. get worldMatrixInstancedBuffer(): Float32Array;
  24394. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24395. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24396. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24397. /**
  24398. * @constructor
  24399. * @param name The value used by scene.getMeshByName() to do a lookup.
  24400. * @param scene The scene to add this mesh to.
  24401. * @param parent The parent of this mesh, if it has one
  24402. * @param source An optional Mesh from which geometry is shared, cloned.
  24403. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24404. * When false, achieved by calling a clone(), also passing False.
  24405. * This will make creation of children, recursive.
  24406. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24407. */
  24408. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24409. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24410. doNotInstantiate: boolean;
  24411. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24412. /**
  24413. * Gets the class name
  24414. * @returns the string "Mesh".
  24415. */
  24416. getClassName(): string;
  24417. /** @hidden */
  24418. get _isMesh(): boolean;
  24419. /**
  24420. * Returns a description of this mesh
  24421. * @param fullDetails define if full details about this mesh must be used
  24422. * @returns a descriptive string representing this mesh
  24423. */
  24424. toString(fullDetails?: boolean): string;
  24425. /** @hidden */
  24426. _unBindEffect(): void;
  24427. /**
  24428. * Gets a boolean indicating if this mesh has LOD
  24429. */
  24430. get hasLODLevels(): boolean;
  24431. /**
  24432. * Gets the list of MeshLODLevel associated with the current mesh
  24433. * @returns an array of MeshLODLevel
  24434. */
  24435. getLODLevels(): MeshLODLevel[];
  24436. private _sortLODLevels;
  24437. /**
  24438. * Add a mesh as LOD level triggered at the given distance.
  24439. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24440. * @param distance The distance from the center of the object to show this level
  24441. * @param mesh The mesh to be added as LOD level (can be null)
  24442. * @return This mesh (for chaining)
  24443. */
  24444. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24445. /**
  24446. * Returns the LOD level mesh at the passed distance or null if not found.
  24447. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24448. * @param distance The distance from the center of the object to show this level
  24449. * @returns a Mesh or `null`
  24450. */
  24451. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24452. /**
  24453. * Remove a mesh from the LOD array
  24454. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24455. * @param mesh defines the mesh to be removed
  24456. * @return This mesh (for chaining)
  24457. */
  24458. removeLODLevel(mesh: Mesh): Mesh;
  24459. /**
  24460. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24461. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24462. * @param camera defines the camera to use to compute distance
  24463. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24464. * @return This mesh (for chaining)
  24465. */
  24466. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24467. /**
  24468. * Gets the mesh internal Geometry object
  24469. */
  24470. get geometry(): Nullable<Geometry>;
  24471. /**
  24472. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24473. * @returns the total number of vertices
  24474. */
  24475. getTotalVertices(): number;
  24476. /**
  24477. * Returns the content of an associated vertex buffer
  24478. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24479. * - VertexBuffer.PositionKind
  24480. * - VertexBuffer.UVKind
  24481. * - VertexBuffer.UV2Kind
  24482. * - VertexBuffer.UV3Kind
  24483. * - VertexBuffer.UV4Kind
  24484. * - VertexBuffer.UV5Kind
  24485. * - VertexBuffer.UV6Kind
  24486. * - VertexBuffer.ColorKind
  24487. * - VertexBuffer.MatricesIndicesKind
  24488. * - VertexBuffer.MatricesIndicesExtraKind
  24489. * - VertexBuffer.MatricesWeightsKind
  24490. * - VertexBuffer.MatricesWeightsExtraKind
  24491. * @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
  24492. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24493. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24494. */
  24495. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24496. /**
  24497. * Returns the mesh VertexBuffer object from the requested `kind`
  24498. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24499. * - VertexBuffer.PositionKind
  24500. * - VertexBuffer.NormalKind
  24501. * - VertexBuffer.UVKind
  24502. * - VertexBuffer.UV2Kind
  24503. * - VertexBuffer.UV3Kind
  24504. * - VertexBuffer.UV4Kind
  24505. * - VertexBuffer.UV5Kind
  24506. * - VertexBuffer.UV6Kind
  24507. * - VertexBuffer.ColorKind
  24508. * - VertexBuffer.MatricesIndicesKind
  24509. * - VertexBuffer.MatricesIndicesExtraKind
  24510. * - VertexBuffer.MatricesWeightsKind
  24511. * - VertexBuffer.MatricesWeightsExtraKind
  24512. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24513. */
  24514. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24515. /**
  24516. * Tests if a specific vertex buffer is associated with this mesh
  24517. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24518. * - VertexBuffer.PositionKind
  24519. * - VertexBuffer.NormalKind
  24520. * - VertexBuffer.UVKind
  24521. * - VertexBuffer.UV2Kind
  24522. * - VertexBuffer.UV3Kind
  24523. * - VertexBuffer.UV4Kind
  24524. * - VertexBuffer.UV5Kind
  24525. * - VertexBuffer.UV6Kind
  24526. * - VertexBuffer.ColorKind
  24527. * - VertexBuffer.MatricesIndicesKind
  24528. * - VertexBuffer.MatricesIndicesExtraKind
  24529. * - VertexBuffer.MatricesWeightsKind
  24530. * - VertexBuffer.MatricesWeightsExtraKind
  24531. * @returns a boolean
  24532. */
  24533. isVerticesDataPresent(kind: string): boolean;
  24534. /**
  24535. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24536. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24537. * - VertexBuffer.PositionKind
  24538. * - VertexBuffer.UVKind
  24539. * - VertexBuffer.UV2Kind
  24540. * - VertexBuffer.UV3Kind
  24541. * - VertexBuffer.UV4Kind
  24542. * - VertexBuffer.UV5Kind
  24543. * - VertexBuffer.UV6Kind
  24544. * - VertexBuffer.ColorKind
  24545. * - VertexBuffer.MatricesIndicesKind
  24546. * - VertexBuffer.MatricesIndicesExtraKind
  24547. * - VertexBuffer.MatricesWeightsKind
  24548. * - VertexBuffer.MatricesWeightsExtraKind
  24549. * @returns a boolean
  24550. */
  24551. isVertexBufferUpdatable(kind: string): boolean;
  24552. /**
  24553. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24554. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24555. * - VertexBuffer.PositionKind
  24556. * - VertexBuffer.NormalKind
  24557. * - VertexBuffer.UVKind
  24558. * - VertexBuffer.UV2Kind
  24559. * - VertexBuffer.UV3Kind
  24560. * - VertexBuffer.UV4Kind
  24561. * - VertexBuffer.UV5Kind
  24562. * - VertexBuffer.UV6Kind
  24563. * - VertexBuffer.ColorKind
  24564. * - VertexBuffer.MatricesIndicesKind
  24565. * - VertexBuffer.MatricesIndicesExtraKind
  24566. * - VertexBuffer.MatricesWeightsKind
  24567. * - VertexBuffer.MatricesWeightsExtraKind
  24568. * @returns an array of strings
  24569. */
  24570. getVerticesDataKinds(): string[];
  24571. /**
  24572. * Returns a positive integer : the total number of indices in this mesh geometry.
  24573. * @returns the numner of indices or zero if the mesh has no geometry.
  24574. */
  24575. getTotalIndices(): number;
  24576. /**
  24577. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24578. * @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.
  24579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24580. * @returns the indices array or an empty array if the mesh has no geometry
  24581. */
  24582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24583. get isBlocked(): boolean;
  24584. /**
  24585. * Determine if the current mesh is ready to be rendered
  24586. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24587. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24588. * @returns true if all associated assets are ready (material, textures, shaders)
  24589. */
  24590. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24591. /**
  24592. * 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.
  24593. */
  24594. get areNormalsFrozen(): boolean;
  24595. /**
  24596. * 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.
  24597. * @returns the current mesh
  24598. */
  24599. freezeNormals(): Mesh;
  24600. /**
  24601. * 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
  24602. * @returns the current mesh
  24603. */
  24604. unfreezeNormals(): Mesh;
  24605. /**
  24606. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24607. */
  24608. set overridenInstanceCount(count: number);
  24609. /** @hidden */
  24610. _preActivate(): Mesh;
  24611. /** @hidden */
  24612. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24613. /** @hidden */
  24614. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24615. /**
  24616. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24617. * This means the mesh underlying bounding box and sphere are recomputed.
  24618. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24619. * @returns the current mesh
  24620. */
  24621. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24622. /** @hidden */
  24623. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24624. /**
  24625. * This function will subdivide the mesh into multiple submeshes
  24626. * @param count defines the expected number of submeshes
  24627. */
  24628. subdivide(count: number): void;
  24629. /**
  24630. * Copy a FloatArray into a specific associated vertex buffer
  24631. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24632. * - VertexBuffer.PositionKind
  24633. * - VertexBuffer.UVKind
  24634. * - VertexBuffer.UV2Kind
  24635. * - VertexBuffer.UV3Kind
  24636. * - VertexBuffer.UV4Kind
  24637. * - VertexBuffer.UV5Kind
  24638. * - VertexBuffer.UV6Kind
  24639. * - VertexBuffer.ColorKind
  24640. * - VertexBuffer.MatricesIndicesKind
  24641. * - VertexBuffer.MatricesIndicesExtraKind
  24642. * - VertexBuffer.MatricesWeightsKind
  24643. * - VertexBuffer.MatricesWeightsExtraKind
  24644. * @param data defines the data source
  24645. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24646. * @param stride defines the data stride size (can be null)
  24647. * @returns the current mesh
  24648. */
  24649. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24650. /**
  24651. * Delete a vertex buffer associated with this mesh
  24652. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24653. * - VertexBuffer.PositionKind
  24654. * - VertexBuffer.UVKind
  24655. * - VertexBuffer.UV2Kind
  24656. * - VertexBuffer.UV3Kind
  24657. * - VertexBuffer.UV4Kind
  24658. * - VertexBuffer.UV5Kind
  24659. * - VertexBuffer.UV6Kind
  24660. * - VertexBuffer.ColorKind
  24661. * - VertexBuffer.MatricesIndicesKind
  24662. * - VertexBuffer.MatricesIndicesExtraKind
  24663. * - VertexBuffer.MatricesWeightsKind
  24664. * - VertexBuffer.MatricesWeightsExtraKind
  24665. */
  24666. removeVerticesData(kind: string): void;
  24667. /**
  24668. * Flags an associated vertex buffer as updatable
  24669. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24670. * - VertexBuffer.PositionKind
  24671. * - VertexBuffer.UVKind
  24672. * - VertexBuffer.UV2Kind
  24673. * - VertexBuffer.UV3Kind
  24674. * - VertexBuffer.UV4Kind
  24675. * - VertexBuffer.UV5Kind
  24676. * - VertexBuffer.UV6Kind
  24677. * - VertexBuffer.ColorKind
  24678. * - VertexBuffer.MatricesIndicesKind
  24679. * - VertexBuffer.MatricesIndicesExtraKind
  24680. * - VertexBuffer.MatricesWeightsKind
  24681. * - VertexBuffer.MatricesWeightsExtraKind
  24682. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24683. */
  24684. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24685. /**
  24686. * Sets the mesh global Vertex Buffer
  24687. * @param buffer defines the buffer to use
  24688. * @returns the current mesh
  24689. */
  24690. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24691. /**
  24692. * Update a specific associated vertex buffer
  24693. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24694. * - VertexBuffer.PositionKind
  24695. * - VertexBuffer.UVKind
  24696. * - VertexBuffer.UV2Kind
  24697. * - VertexBuffer.UV3Kind
  24698. * - VertexBuffer.UV4Kind
  24699. * - VertexBuffer.UV5Kind
  24700. * - VertexBuffer.UV6Kind
  24701. * - VertexBuffer.ColorKind
  24702. * - VertexBuffer.MatricesIndicesKind
  24703. * - VertexBuffer.MatricesIndicesExtraKind
  24704. * - VertexBuffer.MatricesWeightsKind
  24705. * - VertexBuffer.MatricesWeightsExtraKind
  24706. * @param data defines the data source
  24707. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24708. * @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)
  24709. * @returns the current mesh
  24710. */
  24711. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24712. /**
  24713. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24714. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24715. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24716. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24717. * @returns the current mesh
  24718. */
  24719. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24720. /**
  24721. * Creates a un-shared specific occurence of the geometry for the mesh.
  24722. * @returns the current mesh
  24723. */
  24724. makeGeometryUnique(): Mesh;
  24725. /**
  24726. * Set the index buffer of this mesh
  24727. * @param indices defines the source data
  24728. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24729. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24730. * @returns the current mesh
  24731. */
  24732. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24733. /**
  24734. * Update the current index buffer
  24735. * @param indices defines the source data
  24736. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24737. * @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)
  24738. * @returns the current mesh
  24739. */
  24740. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24741. /**
  24742. * Invert the geometry to move from a right handed system to a left handed one.
  24743. * @returns the current mesh
  24744. */
  24745. toLeftHanded(): Mesh;
  24746. /** @hidden */
  24747. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24748. /** @hidden */
  24749. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24750. /**
  24751. * Registers for this mesh a javascript function called just before the rendering process
  24752. * @param func defines the function to call before rendering this mesh
  24753. * @returns the current mesh
  24754. */
  24755. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24756. /**
  24757. * Disposes a previously registered javascript function called before the rendering
  24758. * @param func defines the function to remove
  24759. * @returns the current mesh
  24760. */
  24761. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24762. /**
  24763. * Registers for this mesh a javascript function called just after the rendering is complete
  24764. * @param func defines the function to call after rendering this mesh
  24765. * @returns the current mesh
  24766. */
  24767. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24768. /**
  24769. * Disposes a previously registered javascript function called after the rendering.
  24770. * @param func defines the function to remove
  24771. * @returns the current mesh
  24772. */
  24773. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24774. /** @hidden */
  24775. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24776. /** @hidden */
  24777. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24778. /** @hidden */
  24779. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24780. /** @hidden */
  24781. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24782. /** @hidden */
  24783. _rebuild(): void;
  24784. /** @hidden */
  24785. _freeze(): void;
  24786. /** @hidden */
  24787. _unFreeze(): void;
  24788. /**
  24789. * 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
  24790. * @param subMesh defines the subMesh to render
  24791. * @param enableAlphaMode defines if alpha mode can be changed
  24792. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24793. * @returns the current mesh
  24794. */
  24795. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24796. private _onBeforeDraw;
  24797. /**
  24798. * Renormalize the mesh and patch it up if there are no weights
  24799. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24800. * However in the case of zero weights then we set just a single influence to 1.
  24801. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24802. */
  24803. cleanMatrixWeights(): void;
  24804. private normalizeSkinFourWeights;
  24805. private normalizeSkinWeightsAndExtra;
  24806. /**
  24807. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24808. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24809. * the user know there was an issue with importing the mesh
  24810. * @returns a validation object with skinned, valid and report string
  24811. */
  24812. validateSkinning(): {
  24813. skinned: boolean;
  24814. valid: boolean;
  24815. report: string;
  24816. };
  24817. /** @hidden */
  24818. _checkDelayState(): Mesh;
  24819. private _queueLoad;
  24820. /**
  24821. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24822. * A mesh is in the frustum if its bounding box intersects the frustum
  24823. * @param frustumPlanes defines the frustum to test
  24824. * @returns true if the mesh is in the frustum planes
  24825. */
  24826. isInFrustum(frustumPlanes: Plane[]): boolean;
  24827. /**
  24828. * Sets the mesh material by the material or multiMaterial `id` property
  24829. * @param id is a string identifying the material or the multiMaterial
  24830. * @returns the current mesh
  24831. */
  24832. setMaterialByID(id: string): Mesh;
  24833. /**
  24834. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24835. * @returns an array of IAnimatable
  24836. */
  24837. getAnimatables(): IAnimatable[];
  24838. /**
  24839. * Modifies the mesh geometry according to the passed transformation matrix.
  24840. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24841. * The mesh normals are modified using the same transformation.
  24842. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24843. * @param transform defines the transform matrix to use
  24844. * @see http://doc.babylonjs.com/resources/baking_transformations
  24845. * @returns the current mesh
  24846. */
  24847. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24848. /**
  24849. * Modifies the mesh geometry according to its own current World Matrix.
  24850. * The mesh World Matrix is then reset.
  24851. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24852. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24853. * @see http://doc.babylonjs.com/resources/baking_transformations
  24854. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24855. * @returns the current mesh
  24856. */
  24857. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24858. /** @hidden */
  24859. get _positions(): Nullable<Vector3[]>;
  24860. /** @hidden */
  24861. _resetPointsArrayCache(): Mesh;
  24862. /** @hidden */
  24863. _generatePointsArray(): boolean;
  24864. /**
  24865. * Returns a new Mesh object generated from the current mesh properties.
  24866. * This method must not get confused with createInstance()
  24867. * @param name is a string, the name given to the new mesh
  24868. * @param newParent can be any Node object (default `null`)
  24869. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24870. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24871. * @returns a new mesh
  24872. */
  24873. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24874. /**
  24875. * Releases resources associated with this mesh.
  24876. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24877. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24878. */
  24879. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24880. /** @hidden */
  24881. _disposeInstanceSpecificData(): void;
  24882. /**
  24883. * Modifies the mesh geometry according to a displacement map.
  24884. * 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.
  24885. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24886. * @param url is a string, the URL from the image file is to be downloaded.
  24887. * @param minHeight is the lower limit of the displacement.
  24888. * @param maxHeight is the upper limit of the displacement.
  24889. * @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.
  24890. * @param uvOffset is an optional vector2 used to offset UV.
  24891. * @param uvScale is an optional vector2 used to scale UV.
  24892. * @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.
  24893. * @returns the Mesh.
  24894. */
  24895. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24896. /**
  24897. * Modifies the mesh geometry according to a displacementMap buffer.
  24898. * 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.
  24899. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24900. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24901. * @param heightMapWidth is the width of the buffer image.
  24902. * @param heightMapHeight is the height of the buffer image.
  24903. * @param minHeight is the lower limit of the displacement.
  24904. * @param maxHeight is the upper limit of the displacement.
  24905. * @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.
  24906. * @param uvOffset is an optional vector2 used to offset UV.
  24907. * @param uvScale is an optional vector2 used to scale UV.
  24908. * @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.
  24909. * @returns the Mesh.
  24910. */
  24911. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24912. /**
  24913. * Modify the mesh to get a flat shading rendering.
  24914. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24915. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24916. * @returns current mesh
  24917. */
  24918. convertToFlatShadedMesh(): Mesh;
  24919. /**
  24920. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24921. * In other words, more vertices, no more indices and a single bigger VBO.
  24922. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24923. * @returns current mesh
  24924. */
  24925. convertToUnIndexedMesh(): Mesh;
  24926. /**
  24927. * Inverses facet orientations.
  24928. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24929. * @param flipNormals will also inverts the normals
  24930. * @returns current mesh
  24931. */
  24932. flipFaces(flipNormals?: boolean): Mesh;
  24933. /**
  24934. * Increase the number of facets and hence vertices in a mesh
  24935. * Vertex normals are interpolated from existing vertex normals
  24936. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24937. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24938. */
  24939. increaseVertices(numberPerEdge: number): void;
  24940. /**
  24941. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24942. * This will undo any application of covertToFlatShadedMesh
  24943. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24944. */
  24945. forceSharedVertices(): void;
  24946. /** @hidden */
  24947. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24948. /** @hidden */
  24949. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24950. /**
  24951. * Creates a new InstancedMesh object from the mesh model.
  24952. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24953. * @param name defines the name of the new instance
  24954. * @returns a new InstancedMesh
  24955. */
  24956. createInstance(name: string): InstancedMesh;
  24957. /**
  24958. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24959. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24960. * @returns the current mesh
  24961. */
  24962. synchronizeInstances(): Mesh;
  24963. /**
  24964. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24965. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24966. * This should be used together with the simplification to avoid disappearing triangles.
  24967. * @param successCallback an optional success callback to be called after the optimization finished.
  24968. * @returns the current mesh
  24969. */
  24970. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24971. /**
  24972. * Serialize current mesh
  24973. * @param serializationObject defines the object which will receive the serialization data
  24974. */
  24975. serialize(serializationObject: any): void;
  24976. /** @hidden */
  24977. _syncGeometryWithMorphTargetManager(): void;
  24978. /** @hidden */
  24979. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24980. /**
  24981. * Returns a new Mesh object parsed from the source provided.
  24982. * @param parsedMesh is the source
  24983. * @param scene defines the hosting scene
  24984. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24985. * @returns a new Mesh
  24986. */
  24987. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24988. /**
  24989. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24990. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24991. * @param name defines the name of the mesh to create
  24992. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24993. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24994. * @param closePath creates a seam between the first and the last points of each path of the path array
  24995. * @param offset is taken in account only if the `pathArray` is containing a single path
  24996. * @param scene defines the hosting scene
  24997. * @param updatable defines if the mesh must be flagged as updatable
  24998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24999. * @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)
  25000. * @returns a new Mesh
  25001. */
  25002. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25003. /**
  25004. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25005. * @param name defines the name of the mesh to create
  25006. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25007. * @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
  25008. * @param scene defines the hosting scene
  25009. * @param updatable defines if the mesh must be flagged as updatable
  25010. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25011. * @returns a new Mesh
  25012. */
  25013. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25014. /**
  25015. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25016. * @param name defines the name of the mesh to create
  25017. * @param size sets the size (float) of each box side (default 1)
  25018. * @param scene defines the hosting scene
  25019. * @param updatable defines if the mesh must be flagged as updatable
  25020. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25021. * @returns a new Mesh
  25022. */
  25023. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25024. /**
  25025. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25026. * @param name defines the name of the mesh to create
  25027. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25028. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25029. * @param scene defines the hosting scene
  25030. * @param updatable defines if the mesh must be flagged as updatable
  25031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25032. * @returns a new Mesh
  25033. */
  25034. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25035. /**
  25036. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25037. * @param name defines the name of the mesh to create
  25038. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25039. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25040. * @param scene defines the hosting scene
  25041. * @returns a new Mesh
  25042. */
  25043. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25044. /**
  25045. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25046. * @param name defines the name of the mesh to create
  25047. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25048. * @param diameterTop set the top cap diameter (floats, default 1)
  25049. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25050. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25051. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25052. * @param scene defines the hosting scene
  25053. * @param updatable defines if the mesh must be flagged as updatable
  25054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25055. * @returns a new Mesh
  25056. */
  25057. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25058. /**
  25059. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25060. * @param name defines the name of the mesh to create
  25061. * @param diameter sets the diameter size (float) of the torus (default 1)
  25062. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25063. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25064. * @param scene defines the hosting scene
  25065. * @param updatable defines if the mesh must be flagged as updatable
  25066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25067. * @returns a new Mesh
  25068. */
  25069. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25070. /**
  25071. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25072. * @param name defines the name of the mesh to create
  25073. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25074. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25075. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25076. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25077. * @param p the number of windings on X axis (positive integers, default 2)
  25078. * @param q the number of windings on Y axis (positive integers, default 3)
  25079. * @param scene defines the hosting scene
  25080. * @param updatable defines if the mesh must be flagged as updatable
  25081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25082. * @returns a new Mesh
  25083. */
  25084. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25085. /**
  25086. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25087. * @param name defines the name of the mesh to create
  25088. * @param points is an array successive Vector3
  25089. * @param scene defines the hosting scene
  25090. * @param updatable defines if the mesh must be flagged as updatable
  25091. * @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).
  25092. * @returns a new Mesh
  25093. */
  25094. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25095. /**
  25096. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25097. * @param name defines the name of the mesh to create
  25098. * @param points is an array successive Vector3
  25099. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25100. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25101. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25102. * @param scene defines the hosting scene
  25103. * @param updatable defines if the mesh must be flagged as updatable
  25104. * @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)
  25105. * @returns a new Mesh
  25106. */
  25107. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25108. /**
  25109. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25110. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25111. * 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.
  25112. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25113. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25114. * Remember you can only change the shape positions, not their number when updating a polygon.
  25115. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25116. * @param name defines the name of the mesh to create
  25117. * @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
  25118. * @param scene defines the hosting scene
  25119. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25120. * @param updatable defines if the mesh must be flagged as updatable
  25121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25122. * @param earcutInjection can be used to inject your own earcut reference
  25123. * @returns a new Mesh
  25124. */
  25125. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25126. /**
  25127. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25128. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25129. * @param name defines the name of the mesh to create
  25130. * @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
  25131. * @param depth defines the height of extrusion
  25132. * @param scene defines the hosting scene
  25133. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25134. * @param updatable defines if the mesh must be flagged as updatable
  25135. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25136. * @param earcutInjection can be used to inject your own earcut reference
  25137. * @returns a new Mesh
  25138. */
  25139. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25140. /**
  25141. * Creates an extruded shape mesh.
  25142. * 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
  25143. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25144. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25145. * @param name defines the name of the mesh to create
  25146. * @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
  25147. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25148. * @param scale is the value to scale the shape
  25149. * @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
  25150. * @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
  25151. * @param scene defines the hosting scene
  25152. * @param updatable defines if the mesh must be flagged as updatable
  25153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25154. * @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)
  25155. * @returns a new Mesh
  25156. */
  25157. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25158. /**
  25159. * Creates an custom extruded shape mesh.
  25160. * The custom extrusion is a parametric shape.
  25161. * It has no predefined shape. Its final shape will depend on the input parameters.
  25162. * Please consider using the same method from the MeshBuilder class instead
  25163. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25164. * @param name defines the name of the mesh to create
  25165. * @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
  25166. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25167. * @param scaleFunction is a custom Javascript function called on each path point
  25168. * @param rotationFunction is a custom Javascript function called on each path point
  25169. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25170. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25171. * @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
  25172. * @param scene defines the hosting scene
  25173. * @param updatable defines if the mesh must be flagged as updatable
  25174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25175. * @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)
  25176. * @returns a new Mesh
  25177. */
  25178. 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;
  25179. /**
  25180. * Creates lathe mesh.
  25181. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25182. * Please consider using the same method from the MeshBuilder class instead
  25183. * @param name defines the name of the mesh to create
  25184. * @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
  25185. * @param radius is the radius value of the lathe
  25186. * @param tessellation is the side number of the lathe.
  25187. * @param scene defines the hosting scene
  25188. * @param updatable defines if the mesh must be flagged as updatable
  25189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25190. * @returns a new Mesh
  25191. */
  25192. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25193. /**
  25194. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25195. * @param name defines the name of the mesh to create
  25196. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25197. * @param scene defines the hosting scene
  25198. * @param updatable defines if the mesh must be flagged as updatable
  25199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25200. * @returns a new Mesh
  25201. */
  25202. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25203. /**
  25204. * Creates a ground mesh.
  25205. * Please consider using the same method from the MeshBuilder class instead
  25206. * @param name defines the name of the mesh to create
  25207. * @param width set the width of the ground
  25208. * @param height set the height of the ground
  25209. * @param subdivisions sets the number of subdivisions per side
  25210. * @param scene defines the hosting scene
  25211. * @param updatable defines if the mesh must be flagged as updatable
  25212. * @returns a new Mesh
  25213. */
  25214. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25215. /**
  25216. * Creates a tiled ground mesh.
  25217. * Please consider using the same method from the MeshBuilder class instead
  25218. * @param name defines the name of the mesh to create
  25219. * @param xmin set the ground minimum X coordinate
  25220. * @param zmin set the ground minimum Y coordinate
  25221. * @param xmax set the ground maximum X coordinate
  25222. * @param zmax set the ground maximum Z coordinate
  25223. * @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
  25224. * @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
  25225. * @param scene defines the hosting scene
  25226. * @param updatable defines if the mesh must be flagged as updatable
  25227. * @returns a new Mesh
  25228. */
  25229. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25230. w: number;
  25231. h: number;
  25232. }, precision: {
  25233. w: number;
  25234. h: number;
  25235. }, scene: Scene, updatable?: boolean): Mesh;
  25236. /**
  25237. * Creates a ground mesh from a height map.
  25238. * Please consider using the same method from the MeshBuilder class instead
  25239. * @see http://doc.babylonjs.com/babylon101/height_map
  25240. * @param name defines the name of the mesh to create
  25241. * @param url sets the URL of the height map image resource
  25242. * @param width set the ground width size
  25243. * @param height set the ground height size
  25244. * @param subdivisions sets the number of subdivision per side
  25245. * @param minHeight is the minimum altitude on the ground
  25246. * @param maxHeight is the maximum altitude on the ground
  25247. * @param scene defines the hosting scene
  25248. * @param updatable defines if the mesh must be flagged as updatable
  25249. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25250. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25251. * @returns a new Mesh
  25252. */
  25253. 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;
  25254. /**
  25255. * Creates a tube mesh.
  25256. * The tube is a parametric shape.
  25257. * It has no predefined shape. Its final shape will depend on the input parameters.
  25258. * Please consider using the same method from the MeshBuilder class instead
  25259. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25260. * @param name defines the name of the mesh to create
  25261. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25262. * @param radius sets the tube radius size
  25263. * @param tessellation is the number of sides on the tubular surface
  25264. * @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
  25265. * @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
  25266. * @param scene defines the hosting scene
  25267. * @param updatable defines if the mesh must be flagged as updatable
  25268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25269. * @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)
  25270. * @returns a new Mesh
  25271. */
  25272. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25273. (i: number, distance: number): number;
  25274. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25275. /**
  25276. * Creates a polyhedron mesh.
  25277. * Please consider using the same method from the MeshBuilder class instead.
  25278. * * 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
  25279. * * The parameter `size` (positive float, default 1) sets the polygon size
  25280. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25281. * * 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`
  25282. * * 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
  25283. * * 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)`)
  25284. * * 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
  25285. * * 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
  25286. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25287. * * 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
  25288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25289. * @param name defines the name of the mesh to create
  25290. * @param options defines the options used to create the mesh
  25291. * @param scene defines the hosting scene
  25292. * @returns a new Mesh
  25293. */
  25294. static CreatePolyhedron(name: string, options: {
  25295. type?: number;
  25296. size?: number;
  25297. sizeX?: number;
  25298. sizeY?: number;
  25299. sizeZ?: number;
  25300. custom?: any;
  25301. faceUV?: Vector4[];
  25302. faceColors?: Color4[];
  25303. updatable?: boolean;
  25304. sideOrientation?: number;
  25305. }, scene: Scene): Mesh;
  25306. /**
  25307. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25308. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25309. * * 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`)
  25310. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25311. * * 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
  25312. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25313. * * 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
  25314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25315. * @param name defines the name of the mesh
  25316. * @param options defines the options used to create the mesh
  25317. * @param scene defines the hosting scene
  25318. * @returns a new Mesh
  25319. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25320. */
  25321. static CreateIcoSphere(name: string, options: {
  25322. radius?: number;
  25323. flat?: boolean;
  25324. subdivisions?: number;
  25325. sideOrientation?: number;
  25326. updatable?: boolean;
  25327. }, scene: Scene): Mesh;
  25328. /**
  25329. * Creates a decal mesh.
  25330. * Please consider using the same method from the MeshBuilder class instead.
  25331. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25332. * @param name defines the name of the mesh
  25333. * @param sourceMesh defines the mesh receiving the decal
  25334. * @param position sets the position of the decal in world coordinates
  25335. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25336. * @param size sets the decal scaling
  25337. * @param angle sets the angle to rotate the decal
  25338. * @returns a new Mesh
  25339. */
  25340. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25341. /**
  25342. * Prepare internal position array for software CPU skinning
  25343. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25344. */
  25345. setPositionsForCPUSkinning(): Float32Array;
  25346. /**
  25347. * Prepare internal normal array for software CPU skinning
  25348. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25349. */
  25350. setNormalsForCPUSkinning(): Float32Array;
  25351. /**
  25352. * Updates the vertex buffer by applying transformation from the bones
  25353. * @param skeleton defines the skeleton to apply to current mesh
  25354. * @returns the current mesh
  25355. */
  25356. applySkeleton(skeleton: Skeleton): Mesh;
  25357. /**
  25358. * 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
  25359. * @param meshes defines the list of meshes to scan
  25360. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25361. */
  25362. static MinMax(meshes: AbstractMesh[]): {
  25363. min: Vector3;
  25364. max: Vector3;
  25365. };
  25366. /**
  25367. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25368. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25369. * @returns a vector3
  25370. */
  25371. static Center(meshesOrMinMaxVector: {
  25372. min: Vector3;
  25373. max: Vector3;
  25374. } | AbstractMesh[]): Vector3;
  25375. /**
  25376. * Merge the array of meshes into a single mesh for performance reasons.
  25377. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25378. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25379. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25380. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25381. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25382. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25383. * @returns a new mesh
  25384. */
  25385. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25386. /** @hidden */
  25387. addInstance(instance: InstancedMesh): void;
  25388. /** @hidden */
  25389. removeInstance(instance: InstancedMesh): void;
  25390. }
  25391. }
  25392. declare module BABYLON {
  25393. /**
  25394. * This is the base class of all the camera used in the application.
  25395. * @see http://doc.babylonjs.com/features/cameras
  25396. */
  25397. export class Camera extends Node {
  25398. /** @hidden */
  25399. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25400. /**
  25401. * This is the default projection mode used by the cameras.
  25402. * It helps recreating a feeling of perspective and better appreciate depth.
  25403. * This is the best way to simulate real life cameras.
  25404. */
  25405. static readonly PERSPECTIVE_CAMERA: number;
  25406. /**
  25407. * This helps creating camera with an orthographic mode.
  25408. * 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.
  25409. */
  25410. static readonly ORTHOGRAPHIC_CAMERA: number;
  25411. /**
  25412. * This is the default FOV mode for perspective cameras.
  25413. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25414. */
  25415. static readonly FOVMODE_VERTICAL_FIXED: number;
  25416. /**
  25417. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25418. */
  25419. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25420. /**
  25421. * This specifies ther is no need for a camera rig.
  25422. * Basically only one eye is rendered corresponding to the camera.
  25423. */
  25424. static readonly RIG_MODE_NONE: number;
  25425. /**
  25426. * Simulates a camera Rig with one blue eye and one red eye.
  25427. * This can be use with 3d blue and red glasses.
  25428. */
  25429. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25430. /**
  25431. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25432. */
  25433. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25434. /**
  25435. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25436. */
  25437. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25438. /**
  25439. * Defines that both eyes of the camera will be rendered over under each other.
  25440. */
  25441. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25442. /**
  25443. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25444. */
  25445. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25446. /**
  25447. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25448. */
  25449. static readonly RIG_MODE_VR: number;
  25450. /**
  25451. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25452. */
  25453. static readonly RIG_MODE_WEBVR: number;
  25454. /**
  25455. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25456. */
  25457. static readonly RIG_MODE_CUSTOM: number;
  25458. /**
  25459. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25460. */
  25461. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25462. /**
  25463. * Define the input manager associated with the camera.
  25464. */
  25465. inputs: CameraInputsManager<Camera>;
  25466. /** @hidden */
  25467. _position: Vector3;
  25468. /**
  25469. * Define the current local position of the camera in the scene
  25470. */
  25471. get position(): Vector3;
  25472. set position(newPosition: Vector3);
  25473. /**
  25474. * The vector the camera should consider as up.
  25475. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25476. */
  25477. upVector: Vector3;
  25478. /**
  25479. * Define the current limit on the left side for an orthographic camera
  25480. * In scene unit
  25481. */
  25482. orthoLeft: Nullable<number>;
  25483. /**
  25484. * Define the current limit on the right side for an orthographic camera
  25485. * In scene unit
  25486. */
  25487. orthoRight: Nullable<number>;
  25488. /**
  25489. * Define the current limit on the bottom side for an orthographic camera
  25490. * In scene unit
  25491. */
  25492. orthoBottom: Nullable<number>;
  25493. /**
  25494. * Define the current limit on the top side for an orthographic camera
  25495. * In scene unit
  25496. */
  25497. orthoTop: Nullable<number>;
  25498. /**
  25499. * Field Of View is set in Radians. (default is 0.8)
  25500. */
  25501. fov: number;
  25502. /**
  25503. * Define the minimum distance the camera can see from.
  25504. * This is important to note that the depth buffer are not infinite and the closer it starts
  25505. * the more your scene might encounter depth fighting issue.
  25506. */
  25507. minZ: number;
  25508. /**
  25509. * Define the maximum distance the camera can see to.
  25510. * This is important to note that the depth buffer are not infinite and the further it end
  25511. * the more your scene might encounter depth fighting issue.
  25512. */
  25513. maxZ: number;
  25514. /**
  25515. * Define the default inertia of the camera.
  25516. * This helps giving a smooth feeling to the camera movement.
  25517. */
  25518. inertia: number;
  25519. /**
  25520. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25521. */
  25522. mode: number;
  25523. /**
  25524. * Define whether the camera is intermediate.
  25525. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25526. */
  25527. isIntermediate: boolean;
  25528. /**
  25529. * Define the viewport of the camera.
  25530. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25531. */
  25532. viewport: Viewport;
  25533. /**
  25534. * Restricts the camera to viewing objects with the same layerMask.
  25535. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25536. */
  25537. layerMask: number;
  25538. /**
  25539. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25540. */
  25541. fovMode: number;
  25542. /**
  25543. * Rig mode of the camera.
  25544. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25545. * This is normally controlled byt the camera themselves as internal use.
  25546. */
  25547. cameraRigMode: number;
  25548. /**
  25549. * Defines the distance between both "eyes" in case of a RIG
  25550. */
  25551. interaxialDistance: number;
  25552. /**
  25553. * Defines if stereoscopic rendering is done side by side or over under.
  25554. */
  25555. isStereoscopicSideBySide: boolean;
  25556. /**
  25557. * 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
  25558. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25559. * else in the scene. (Eg. security camera)
  25560. *
  25561. * 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)
  25562. */
  25563. customRenderTargets: RenderTargetTexture[];
  25564. /**
  25565. * When set, the camera will render to this render target instead of the default canvas
  25566. *
  25567. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25568. */
  25569. outputRenderTarget: Nullable<RenderTargetTexture>;
  25570. /**
  25571. * Observable triggered when the camera view matrix has changed.
  25572. */
  25573. onViewMatrixChangedObservable: Observable<Camera>;
  25574. /**
  25575. * Observable triggered when the camera Projection matrix has changed.
  25576. */
  25577. onProjectionMatrixChangedObservable: Observable<Camera>;
  25578. /**
  25579. * Observable triggered when the inputs have been processed.
  25580. */
  25581. onAfterCheckInputsObservable: Observable<Camera>;
  25582. /**
  25583. * Observable triggered when reset has been called and applied to the camera.
  25584. */
  25585. onRestoreStateObservable: Observable<Camera>;
  25586. /**
  25587. * Is this camera a part of a rig system?
  25588. */
  25589. isRigCamera: boolean;
  25590. /**
  25591. * If isRigCamera set to true this will be set with the parent camera.
  25592. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25593. */
  25594. rigParent?: Camera;
  25595. /** @hidden */
  25596. _cameraRigParams: any;
  25597. /** @hidden */
  25598. _rigCameras: Camera[];
  25599. /** @hidden */
  25600. _rigPostProcess: Nullable<PostProcess>;
  25601. protected _webvrViewMatrix: Matrix;
  25602. /** @hidden */
  25603. _skipRendering: boolean;
  25604. /** @hidden */
  25605. _projectionMatrix: Matrix;
  25606. /** @hidden */
  25607. _postProcesses: Nullable<PostProcess>[];
  25608. /** @hidden */
  25609. _activeMeshes: SmartArray<AbstractMesh>;
  25610. protected _globalPosition: Vector3;
  25611. /** @hidden */
  25612. _computedViewMatrix: Matrix;
  25613. private _doNotComputeProjectionMatrix;
  25614. private _transformMatrix;
  25615. private _frustumPlanes;
  25616. private _refreshFrustumPlanes;
  25617. private _storedFov;
  25618. private _stateStored;
  25619. /**
  25620. * Instantiates a new camera object.
  25621. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25622. * @see http://doc.babylonjs.com/features/cameras
  25623. * @param name Defines the name of the camera in the scene
  25624. * @param position Defines the position of the camera
  25625. * @param scene Defines the scene the camera belongs too
  25626. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25627. */
  25628. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25629. /**
  25630. * Store current camera state (fov, position, etc..)
  25631. * @returns the camera
  25632. */
  25633. storeState(): Camera;
  25634. /**
  25635. * Restores the camera state values if it has been stored. You must call storeState() first
  25636. */
  25637. protected _restoreStateValues(): boolean;
  25638. /**
  25639. * Restored camera state. You must call storeState() first.
  25640. * @returns true if restored and false otherwise
  25641. */
  25642. restoreState(): boolean;
  25643. /**
  25644. * Gets the class name of the camera.
  25645. * @returns the class name
  25646. */
  25647. getClassName(): string;
  25648. /** @hidden */
  25649. readonly _isCamera: boolean;
  25650. /**
  25651. * Gets a string representation of the camera useful for debug purpose.
  25652. * @param fullDetails Defines that a more verboe level of logging is required
  25653. * @returns the string representation
  25654. */
  25655. toString(fullDetails?: boolean): string;
  25656. /**
  25657. * Gets the current world space position of the camera.
  25658. */
  25659. get globalPosition(): Vector3;
  25660. /**
  25661. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25662. * @returns the active meshe list
  25663. */
  25664. getActiveMeshes(): SmartArray<AbstractMesh>;
  25665. /**
  25666. * Check whether a mesh is part of the current active mesh list of the camera
  25667. * @param mesh Defines the mesh to check
  25668. * @returns true if active, false otherwise
  25669. */
  25670. isActiveMesh(mesh: Mesh): boolean;
  25671. /**
  25672. * Is this camera ready to be used/rendered
  25673. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25674. * @return true if the camera is ready
  25675. */
  25676. isReady(completeCheck?: boolean): boolean;
  25677. /** @hidden */
  25678. _initCache(): void;
  25679. /** @hidden */
  25680. _updateCache(ignoreParentClass?: boolean): void;
  25681. /** @hidden */
  25682. _isSynchronized(): boolean;
  25683. /** @hidden */
  25684. _isSynchronizedViewMatrix(): boolean;
  25685. /** @hidden */
  25686. _isSynchronizedProjectionMatrix(): boolean;
  25687. /**
  25688. * Attach the input controls to a specific dom element to get the input from.
  25689. * @param element Defines the element the controls should be listened from
  25690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25691. */
  25692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25693. /**
  25694. * Detach the current controls from the specified dom element.
  25695. * @param element Defines the element to stop listening the inputs from
  25696. */
  25697. detachControl(element: HTMLElement): void;
  25698. /**
  25699. * Update the camera state according to the different inputs gathered during the frame.
  25700. */
  25701. update(): void;
  25702. /** @hidden */
  25703. _checkInputs(): void;
  25704. /** @hidden */
  25705. get rigCameras(): Camera[];
  25706. /**
  25707. * Gets the post process used by the rig cameras
  25708. */
  25709. get rigPostProcess(): Nullable<PostProcess>;
  25710. /**
  25711. * Internal, gets the first post proces.
  25712. * @returns the first post process to be run on this camera.
  25713. */
  25714. _getFirstPostProcess(): Nullable<PostProcess>;
  25715. private _cascadePostProcessesToRigCams;
  25716. /**
  25717. * Attach a post process to the camera.
  25718. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25719. * @param postProcess The post process to attach to the camera
  25720. * @param insertAt The position of the post process in case several of them are in use in the scene
  25721. * @returns the position the post process has been inserted at
  25722. */
  25723. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25724. /**
  25725. * Detach a post process to the camera.
  25726. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25727. * @param postProcess The post process to detach from the camera
  25728. */
  25729. detachPostProcess(postProcess: PostProcess): void;
  25730. /**
  25731. * Gets the current world matrix of the camera
  25732. */
  25733. getWorldMatrix(): Matrix;
  25734. /** @hidden */
  25735. _getViewMatrix(): Matrix;
  25736. /**
  25737. * Gets the current view matrix of the camera.
  25738. * @param force forces the camera to recompute the matrix without looking at the cached state
  25739. * @returns the view matrix
  25740. */
  25741. getViewMatrix(force?: boolean): Matrix;
  25742. /**
  25743. * Freeze the projection matrix.
  25744. * It will prevent the cache check of the camera projection compute and can speed up perf
  25745. * if no parameter of the camera are meant to change
  25746. * @param projection Defines manually a projection if necessary
  25747. */
  25748. freezeProjectionMatrix(projection?: Matrix): void;
  25749. /**
  25750. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25751. */
  25752. unfreezeProjectionMatrix(): void;
  25753. /**
  25754. * Gets the current projection matrix of the camera.
  25755. * @param force forces the camera to recompute the matrix without looking at the cached state
  25756. * @returns the projection matrix
  25757. */
  25758. getProjectionMatrix(force?: boolean): Matrix;
  25759. /**
  25760. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25761. * @returns a Matrix
  25762. */
  25763. getTransformationMatrix(): Matrix;
  25764. private _updateFrustumPlanes;
  25765. /**
  25766. * Checks if a cullable object (mesh...) is in the camera frustum
  25767. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25768. * @param target The object to check
  25769. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25770. * @returns true if the object is in frustum otherwise false
  25771. */
  25772. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25773. /**
  25774. * Checks if a cullable object (mesh...) is in the camera frustum
  25775. * Unlike isInFrustum this cheks the full bounding box
  25776. * @param target The object to check
  25777. * @returns true if the object is in frustum otherwise false
  25778. */
  25779. isCompletelyInFrustum(target: ICullable): boolean;
  25780. /**
  25781. * Gets a ray in the forward direction from the camera.
  25782. * @param length Defines the length of the ray to create
  25783. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25784. * @param origin Defines the start point of the ray which defaults to the camera position
  25785. * @returns the forward ray
  25786. */
  25787. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25788. /**
  25789. * Releases resources associated with this node.
  25790. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25791. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25792. */
  25793. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25794. /** @hidden */
  25795. _isLeftCamera: boolean;
  25796. /**
  25797. * Gets the left camera of a rig setup in case of Rigged Camera
  25798. */
  25799. get isLeftCamera(): boolean;
  25800. /** @hidden */
  25801. _isRightCamera: boolean;
  25802. /**
  25803. * Gets the right camera of a rig setup in case of Rigged Camera
  25804. */
  25805. get isRightCamera(): boolean;
  25806. /**
  25807. * Gets the left camera of a rig setup in case of Rigged Camera
  25808. */
  25809. get leftCamera(): Nullable<FreeCamera>;
  25810. /**
  25811. * Gets the right camera of a rig setup in case of Rigged Camera
  25812. */
  25813. get rightCamera(): Nullable<FreeCamera>;
  25814. /**
  25815. * Gets the left camera target of a rig setup in case of Rigged Camera
  25816. * @returns the target position
  25817. */
  25818. getLeftTarget(): Nullable<Vector3>;
  25819. /**
  25820. * Gets the right camera target of a rig setup in case of Rigged Camera
  25821. * @returns the target position
  25822. */
  25823. getRightTarget(): Nullable<Vector3>;
  25824. /**
  25825. * @hidden
  25826. */
  25827. setCameraRigMode(mode: number, rigParams: any): void;
  25828. /** @hidden */
  25829. static _setStereoscopicRigMode(camera: Camera): void;
  25830. /** @hidden */
  25831. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25832. /** @hidden */
  25833. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25834. /** @hidden */
  25835. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25836. /** @hidden */
  25837. _getVRProjectionMatrix(): Matrix;
  25838. protected _updateCameraRotationMatrix(): void;
  25839. protected _updateWebVRCameraRotationMatrix(): void;
  25840. /**
  25841. * This function MUST be overwritten by the different WebVR cameras available.
  25842. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25843. * @hidden
  25844. */
  25845. _getWebVRProjectionMatrix(): Matrix;
  25846. /**
  25847. * This function MUST be overwritten by the different WebVR cameras available.
  25848. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25849. * @hidden
  25850. */
  25851. _getWebVRViewMatrix(): Matrix;
  25852. /** @hidden */
  25853. setCameraRigParameter(name: string, value: any): void;
  25854. /**
  25855. * needs to be overridden by children so sub has required properties to be copied
  25856. * @hidden
  25857. */
  25858. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25859. /**
  25860. * May need to be overridden by children
  25861. * @hidden
  25862. */
  25863. _updateRigCameras(): void;
  25864. /** @hidden */
  25865. _setupInputs(): void;
  25866. /**
  25867. * Serialiaze the camera setup to a json represention
  25868. * @returns the JSON representation
  25869. */
  25870. serialize(): any;
  25871. /**
  25872. * Clones the current camera.
  25873. * @param name The cloned camera name
  25874. * @returns the cloned camera
  25875. */
  25876. clone(name: string): Camera;
  25877. /**
  25878. * Gets the direction of the camera relative to a given local axis.
  25879. * @param localAxis Defines the reference axis to provide a relative direction.
  25880. * @return the direction
  25881. */
  25882. getDirection(localAxis: Vector3): Vector3;
  25883. /**
  25884. * Returns the current camera absolute rotation
  25885. */
  25886. get absoluteRotation(): Quaternion;
  25887. /**
  25888. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25889. * @param localAxis Defines the reference axis to provide a relative direction.
  25890. * @param result Defines the vector to store the result in
  25891. */
  25892. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25893. /**
  25894. * Gets a camera constructor for a given camera type
  25895. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25896. * @param name The name of the camera the result will be able to instantiate
  25897. * @param scene The scene the result will construct the camera in
  25898. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25899. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25900. * @returns a factory method to construc the camera
  25901. */
  25902. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25903. /**
  25904. * Compute the world matrix of the camera.
  25905. * @returns the camera world matrix
  25906. */
  25907. computeWorldMatrix(): Matrix;
  25908. /**
  25909. * Parse a JSON and creates the camera from the parsed information
  25910. * @param parsedCamera The JSON to parse
  25911. * @param scene The scene to instantiate the camera in
  25912. * @returns the newly constructed camera
  25913. */
  25914. static Parse(parsedCamera: any, scene: Scene): Camera;
  25915. }
  25916. }
  25917. declare module BABYLON {
  25918. /**
  25919. * Class containing static functions to help procedurally build meshes
  25920. */
  25921. export class DiscBuilder {
  25922. /**
  25923. * Creates a plane polygonal mesh. By default, this is a disc
  25924. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25925. * * 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
  25926. * * 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
  25927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25928. * * 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
  25929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25930. * @param name defines the name of the mesh
  25931. * @param options defines the options used to create the mesh
  25932. * @param scene defines the hosting scene
  25933. * @returns the plane polygonal mesh
  25934. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25935. */
  25936. static CreateDisc(name: string, options: {
  25937. radius?: number;
  25938. tessellation?: number;
  25939. arc?: number;
  25940. updatable?: boolean;
  25941. sideOrientation?: number;
  25942. frontUVs?: Vector4;
  25943. backUVs?: Vector4;
  25944. }, scene?: Nullable<Scene>): Mesh;
  25945. }
  25946. }
  25947. declare module BABYLON {
  25948. /**
  25949. * This represents all the required information to add a fresnel effect on a material:
  25950. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25951. */
  25952. export class FresnelParameters {
  25953. private _isEnabled;
  25954. /**
  25955. * Define if the fresnel effect is enable or not.
  25956. */
  25957. get isEnabled(): boolean;
  25958. set isEnabled(value: boolean);
  25959. /**
  25960. * Define the color used on edges (grazing angle)
  25961. */
  25962. leftColor: Color3;
  25963. /**
  25964. * Define the color used on center
  25965. */
  25966. rightColor: Color3;
  25967. /**
  25968. * Define bias applied to computed fresnel term
  25969. */
  25970. bias: number;
  25971. /**
  25972. * Defined the power exponent applied to fresnel term
  25973. */
  25974. power: number;
  25975. /**
  25976. * Clones the current fresnel and its valuues
  25977. * @returns a clone fresnel configuration
  25978. */
  25979. clone(): FresnelParameters;
  25980. /**
  25981. * Serializes the current fresnel parameters to a JSON representation.
  25982. * @return the JSON serialization
  25983. */
  25984. serialize(): any;
  25985. /**
  25986. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25987. * @param parsedFresnelParameters Define the JSON representation
  25988. * @returns the parsed parameters
  25989. */
  25990. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25991. }
  25992. }
  25993. declare module BABYLON {
  25994. /**
  25995. * Base class of materials working in push mode in babylon JS
  25996. * @hidden
  25997. */
  25998. export class PushMaterial extends Material {
  25999. protected _activeEffect: Effect;
  26000. protected _normalMatrix: Matrix;
  26001. /**
  26002. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26003. * This means that the material can keep using a previous shader while a new one is being compiled.
  26004. * This is mostly used when shader parallel compilation is supported (true by default)
  26005. */
  26006. allowShaderHotSwapping: boolean;
  26007. constructor(name: string, scene: Scene);
  26008. getEffect(): Effect;
  26009. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26010. /**
  26011. * Binds the given world matrix to the active effect
  26012. *
  26013. * @param world the matrix to bind
  26014. */
  26015. bindOnlyWorldMatrix(world: Matrix): void;
  26016. /**
  26017. * Binds the given normal matrix to the active effect
  26018. *
  26019. * @param normalMatrix the matrix to bind
  26020. */
  26021. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26022. bind(world: Matrix, mesh?: Mesh): void;
  26023. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26024. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26025. }
  26026. }
  26027. declare module BABYLON {
  26028. /**
  26029. * This groups all the flags used to control the materials channel.
  26030. */
  26031. export class MaterialFlags {
  26032. private static _DiffuseTextureEnabled;
  26033. /**
  26034. * Are diffuse textures enabled in the application.
  26035. */
  26036. static get DiffuseTextureEnabled(): boolean;
  26037. static set DiffuseTextureEnabled(value: boolean);
  26038. private static _AmbientTextureEnabled;
  26039. /**
  26040. * Are ambient textures enabled in the application.
  26041. */
  26042. static get AmbientTextureEnabled(): boolean;
  26043. static set AmbientTextureEnabled(value: boolean);
  26044. private static _OpacityTextureEnabled;
  26045. /**
  26046. * Are opacity textures enabled in the application.
  26047. */
  26048. static get OpacityTextureEnabled(): boolean;
  26049. static set OpacityTextureEnabled(value: boolean);
  26050. private static _ReflectionTextureEnabled;
  26051. /**
  26052. * Are reflection textures enabled in the application.
  26053. */
  26054. static get ReflectionTextureEnabled(): boolean;
  26055. static set ReflectionTextureEnabled(value: boolean);
  26056. private static _EmissiveTextureEnabled;
  26057. /**
  26058. * Are emissive textures enabled in the application.
  26059. */
  26060. static get EmissiveTextureEnabled(): boolean;
  26061. static set EmissiveTextureEnabled(value: boolean);
  26062. private static _SpecularTextureEnabled;
  26063. /**
  26064. * Are specular textures enabled in the application.
  26065. */
  26066. static get SpecularTextureEnabled(): boolean;
  26067. static set SpecularTextureEnabled(value: boolean);
  26068. private static _BumpTextureEnabled;
  26069. /**
  26070. * Are bump textures enabled in the application.
  26071. */
  26072. static get BumpTextureEnabled(): boolean;
  26073. static set BumpTextureEnabled(value: boolean);
  26074. private static _LightmapTextureEnabled;
  26075. /**
  26076. * Are lightmap textures enabled in the application.
  26077. */
  26078. static get LightmapTextureEnabled(): boolean;
  26079. static set LightmapTextureEnabled(value: boolean);
  26080. private static _RefractionTextureEnabled;
  26081. /**
  26082. * Are refraction textures enabled in the application.
  26083. */
  26084. static get RefractionTextureEnabled(): boolean;
  26085. static set RefractionTextureEnabled(value: boolean);
  26086. private static _ColorGradingTextureEnabled;
  26087. /**
  26088. * Are color grading textures enabled in the application.
  26089. */
  26090. static get ColorGradingTextureEnabled(): boolean;
  26091. static set ColorGradingTextureEnabled(value: boolean);
  26092. private static _FresnelEnabled;
  26093. /**
  26094. * Are fresnels enabled in the application.
  26095. */
  26096. static get FresnelEnabled(): boolean;
  26097. static set FresnelEnabled(value: boolean);
  26098. private static _ClearCoatTextureEnabled;
  26099. /**
  26100. * Are clear coat textures enabled in the application.
  26101. */
  26102. static get ClearCoatTextureEnabled(): boolean;
  26103. static set ClearCoatTextureEnabled(value: boolean);
  26104. private static _ClearCoatBumpTextureEnabled;
  26105. /**
  26106. * Are clear coat bump textures enabled in the application.
  26107. */
  26108. static get ClearCoatBumpTextureEnabled(): boolean;
  26109. static set ClearCoatBumpTextureEnabled(value: boolean);
  26110. private static _ClearCoatTintTextureEnabled;
  26111. /**
  26112. * Are clear coat tint textures enabled in the application.
  26113. */
  26114. static get ClearCoatTintTextureEnabled(): boolean;
  26115. static set ClearCoatTintTextureEnabled(value: boolean);
  26116. private static _SheenTextureEnabled;
  26117. /**
  26118. * Are sheen textures enabled in the application.
  26119. */
  26120. static get SheenTextureEnabled(): boolean;
  26121. static set SheenTextureEnabled(value: boolean);
  26122. private static _AnisotropicTextureEnabled;
  26123. /**
  26124. * Are anisotropic textures enabled in the application.
  26125. */
  26126. static get AnisotropicTextureEnabled(): boolean;
  26127. static set AnisotropicTextureEnabled(value: boolean);
  26128. private static _ThicknessTextureEnabled;
  26129. /**
  26130. * Are thickness textures enabled in the application.
  26131. */
  26132. static get ThicknessTextureEnabled(): boolean;
  26133. static set ThicknessTextureEnabled(value: boolean);
  26134. }
  26135. }
  26136. declare module BABYLON {
  26137. /** @hidden */
  26138. export var defaultFragmentDeclaration: {
  26139. name: string;
  26140. shader: string;
  26141. };
  26142. }
  26143. declare module BABYLON {
  26144. /** @hidden */
  26145. export var defaultUboDeclaration: {
  26146. name: string;
  26147. shader: string;
  26148. };
  26149. }
  26150. declare module BABYLON {
  26151. /** @hidden */
  26152. export var lightFragmentDeclaration: {
  26153. name: string;
  26154. shader: string;
  26155. };
  26156. }
  26157. declare module BABYLON {
  26158. /** @hidden */
  26159. export var lightUboDeclaration: {
  26160. name: string;
  26161. shader: string;
  26162. };
  26163. }
  26164. declare module BABYLON {
  26165. /** @hidden */
  26166. export var lightsFragmentFunctions: {
  26167. name: string;
  26168. shader: string;
  26169. };
  26170. }
  26171. declare module BABYLON {
  26172. /** @hidden */
  26173. export var shadowsFragmentFunctions: {
  26174. name: string;
  26175. shader: string;
  26176. };
  26177. }
  26178. declare module BABYLON {
  26179. /** @hidden */
  26180. export var fresnelFunction: {
  26181. name: string;
  26182. shader: string;
  26183. };
  26184. }
  26185. declare module BABYLON {
  26186. /** @hidden */
  26187. export var reflectionFunction: {
  26188. name: string;
  26189. shader: string;
  26190. };
  26191. }
  26192. declare module BABYLON {
  26193. /** @hidden */
  26194. export var bumpFragmentFunctions: {
  26195. name: string;
  26196. shader: string;
  26197. };
  26198. }
  26199. declare module BABYLON {
  26200. /** @hidden */
  26201. export var logDepthDeclaration: {
  26202. name: string;
  26203. shader: string;
  26204. };
  26205. }
  26206. declare module BABYLON {
  26207. /** @hidden */
  26208. export var bumpFragment: {
  26209. name: string;
  26210. shader: string;
  26211. };
  26212. }
  26213. declare module BABYLON {
  26214. /** @hidden */
  26215. export var depthPrePass: {
  26216. name: string;
  26217. shader: string;
  26218. };
  26219. }
  26220. declare module BABYLON {
  26221. /** @hidden */
  26222. export var lightFragment: {
  26223. name: string;
  26224. shader: string;
  26225. };
  26226. }
  26227. declare module BABYLON {
  26228. /** @hidden */
  26229. export var logDepthFragment: {
  26230. name: string;
  26231. shader: string;
  26232. };
  26233. }
  26234. declare module BABYLON {
  26235. /** @hidden */
  26236. export var defaultPixelShader: {
  26237. name: string;
  26238. shader: string;
  26239. };
  26240. }
  26241. declare module BABYLON {
  26242. /** @hidden */
  26243. export var defaultVertexDeclaration: {
  26244. name: string;
  26245. shader: string;
  26246. };
  26247. }
  26248. declare module BABYLON {
  26249. /** @hidden */
  26250. export var bumpVertexDeclaration: {
  26251. name: string;
  26252. shader: string;
  26253. };
  26254. }
  26255. declare module BABYLON {
  26256. /** @hidden */
  26257. export var bumpVertex: {
  26258. name: string;
  26259. shader: string;
  26260. };
  26261. }
  26262. declare module BABYLON {
  26263. /** @hidden */
  26264. export var fogVertex: {
  26265. name: string;
  26266. shader: string;
  26267. };
  26268. }
  26269. declare module BABYLON {
  26270. /** @hidden */
  26271. export var shadowsVertex: {
  26272. name: string;
  26273. shader: string;
  26274. };
  26275. }
  26276. declare module BABYLON {
  26277. /** @hidden */
  26278. export var pointCloudVertex: {
  26279. name: string;
  26280. shader: string;
  26281. };
  26282. }
  26283. declare module BABYLON {
  26284. /** @hidden */
  26285. export var logDepthVertex: {
  26286. name: string;
  26287. shader: string;
  26288. };
  26289. }
  26290. declare module BABYLON {
  26291. /** @hidden */
  26292. export var defaultVertexShader: {
  26293. name: string;
  26294. shader: string;
  26295. };
  26296. }
  26297. declare module BABYLON {
  26298. /** @hidden */
  26299. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26300. MAINUV1: boolean;
  26301. MAINUV2: boolean;
  26302. DIFFUSE: boolean;
  26303. DIFFUSEDIRECTUV: number;
  26304. AMBIENT: boolean;
  26305. AMBIENTDIRECTUV: number;
  26306. OPACITY: boolean;
  26307. OPACITYDIRECTUV: number;
  26308. OPACITYRGB: boolean;
  26309. REFLECTION: boolean;
  26310. EMISSIVE: boolean;
  26311. EMISSIVEDIRECTUV: number;
  26312. SPECULAR: boolean;
  26313. SPECULARDIRECTUV: number;
  26314. BUMP: boolean;
  26315. BUMPDIRECTUV: number;
  26316. PARALLAX: boolean;
  26317. PARALLAXOCCLUSION: boolean;
  26318. SPECULAROVERALPHA: boolean;
  26319. CLIPPLANE: boolean;
  26320. CLIPPLANE2: boolean;
  26321. CLIPPLANE3: boolean;
  26322. CLIPPLANE4: boolean;
  26323. CLIPPLANE5: boolean;
  26324. CLIPPLANE6: boolean;
  26325. ALPHATEST: boolean;
  26326. DEPTHPREPASS: boolean;
  26327. ALPHAFROMDIFFUSE: boolean;
  26328. POINTSIZE: boolean;
  26329. FOG: boolean;
  26330. SPECULARTERM: boolean;
  26331. DIFFUSEFRESNEL: boolean;
  26332. OPACITYFRESNEL: boolean;
  26333. REFLECTIONFRESNEL: boolean;
  26334. REFRACTIONFRESNEL: boolean;
  26335. EMISSIVEFRESNEL: boolean;
  26336. FRESNEL: boolean;
  26337. NORMAL: boolean;
  26338. UV1: boolean;
  26339. UV2: boolean;
  26340. VERTEXCOLOR: boolean;
  26341. VERTEXALPHA: boolean;
  26342. NUM_BONE_INFLUENCERS: number;
  26343. BonesPerMesh: number;
  26344. BONETEXTURE: boolean;
  26345. INSTANCES: boolean;
  26346. GLOSSINESS: boolean;
  26347. ROUGHNESS: boolean;
  26348. EMISSIVEASILLUMINATION: boolean;
  26349. LINKEMISSIVEWITHDIFFUSE: boolean;
  26350. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26351. LIGHTMAP: boolean;
  26352. LIGHTMAPDIRECTUV: number;
  26353. OBJECTSPACE_NORMALMAP: boolean;
  26354. USELIGHTMAPASSHADOWMAP: boolean;
  26355. REFLECTIONMAP_3D: boolean;
  26356. REFLECTIONMAP_SPHERICAL: boolean;
  26357. REFLECTIONMAP_PLANAR: boolean;
  26358. REFLECTIONMAP_CUBIC: boolean;
  26359. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26360. REFLECTIONMAP_PROJECTION: boolean;
  26361. REFLECTIONMAP_SKYBOX: boolean;
  26362. REFLECTIONMAP_EXPLICIT: boolean;
  26363. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26364. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26365. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26366. INVERTCUBICMAP: boolean;
  26367. LOGARITHMICDEPTH: boolean;
  26368. REFRACTION: boolean;
  26369. REFRACTIONMAP_3D: boolean;
  26370. REFLECTIONOVERALPHA: boolean;
  26371. TWOSIDEDLIGHTING: boolean;
  26372. SHADOWFLOAT: boolean;
  26373. MORPHTARGETS: boolean;
  26374. MORPHTARGETS_NORMAL: boolean;
  26375. MORPHTARGETS_TANGENT: boolean;
  26376. MORPHTARGETS_UV: boolean;
  26377. NUM_MORPH_INFLUENCERS: number;
  26378. NONUNIFORMSCALING: boolean;
  26379. PREMULTIPLYALPHA: boolean;
  26380. IMAGEPROCESSING: boolean;
  26381. VIGNETTE: boolean;
  26382. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26383. VIGNETTEBLENDMODEOPAQUE: boolean;
  26384. TONEMAPPING: boolean;
  26385. TONEMAPPING_ACES: boolean;
  26386. CONTRAST: boolean;
  26387. COLORCURVES: boolean;
  26388. COLORGRADING: boolean;
  26389. COLORGRADING3D: boolean;
  26390. SAMPLER3DGREENDEPTH: boolean;
  26391. SAMPLER3DBGRMAP: boolean;
  26392. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26393. MULTIVIEW: boolean;
  26394. /**
  26395. * If the reflection texture on this material is in linear color space
  26396. * @hidden
  26397. */
  26398. IS_REFLECTION_LINEAR: boolean;
  26399. /**
  26400. * If the refraction texture on this material is in linear color space
  26401. * @hidden
  26402. */
  26403. IS_REFRACTION_LINEAR: boolean;
  26404. EXPOSURE: boolean;
  26405. constructor();
  26406. setReflectionMode(modeToEnable: string): void;
  26407. }
  26408. /**
  26409. * This is the default material used in Babylon. It is the best trade off between quality
  26410. * and performances.
  26411. * @see http://doc.babylonjs.com/babylon101/materials
  26412. */
  26413. export class StandardMaterial extends PushMaterial {
  26414. private _diffuseTexture;
  26415. /**
  26416. * The basic texture of the material as viewed under a light.
  26417. */
  26418. diffuseTexture: Nullable<BaseTexture>;
  26419. private _ambientTexture;
  26420. /**
  26421. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26422. */
  26423. ambientTexture: Nullable<BaseTexture>;
  26424. private _opacityTexture;
  26425. /**
  26426. * Define the transparency of the material from a texture.
  26427. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26428. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26429. */
  26430. opacityTexture: Nullable<BaseTexture>;
  26431. private _reflectionTexture;
  26432. /**
  26433. * Define the texture used to display the reflection.
  26434. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26435. */
  26436. reflectionTexture: Nullable<BaseTexture>;
  26437. private _emissiveTexture;
  26438. /**
  26439. * Define texture of the material as if self lit.
  26440. * This will be mixed in the final result even in the absence of light.
  26441. */
  26442. emissiveTexture: Nullable<BaseTexture>;
  26443. private _specularTexture;
  26444. /**
  26445. * Define how the color and intensity of the highlight given by the light in the material.
  26446. */
  26447. specularTexture: Nullable<BaseTexture>;
  26448. private _bumpTexture;
  26449. /**
  26450. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26451. * 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.
  26452. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26453. */
  26454. bumpTexture: Nullable<BaseTexture>;
  26455. private _lightmapTexture;
  26456. /**
  26457. * Complex lighting can be computationally expensive to compute at runtime.
  26458. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26459. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26460. */
  26461. lightmapTexture: Nullable<BaseTexture>;
  26462. private _refractionTexture;
  26463. /**
  26464. * Define the texture used to display the refraction.
  26465. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26466. */
  26467. refractionTexture: Nullable<BaseTexture>;
  26468. /**
  26469. * The color of the material lit by the environmental background lighting.
  26470. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26471. */
  26472. ambientColor: Color3;
  26473. /**
  26474. * The basic color of the material as viewed under a light.
  26475. */
  26476. diffuseColor: Color3;
  26477. /**
  26478. * Define how the color and intensity of the highlight given by the light in the material.
  26479. */
  26480. specularColor: Color3;
  26481. /**
  26482. * Define the color of the material as if self lit.
  26483. * This will be mixed in the final result even in the absence of light.
  26484. */
  26485. emissiveColor: Color3;
  26486. /**
  26487. * Defines how sharp are the highlights in the material.
  26488. * The bigger the value the sharper giving a more glossy feeling to the result.
  26489. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26490. */
  26491. specularPower: number;
  26492. private _useAlphaFromDiffuseTexture;
  26493. /**
  26494. * Does the transparency come from the diffuse texture alpha channel.
  26495. */
  26496. useAlphaFromDiffuseTexture: boolean;
  26497. private _useEmissiveAsIllumination;
  26498. /**
  26499. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26500. */
  26501. useEmissiveAsIllumination: boolean;
  26502. private _linkEmissiveWithDiffuse;
  26503. /**
  26504. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26505. * the emissive level when the final color is close to one.
  26506. */
  26507. linkEmissiveWithDiffuse: boolean;
  26508. private _useSpecularOverAlpha;
  26509. /**
  26510. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26511. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26512. */
  26513. useSpecularOverAlpha: boolean;
  26514. private _useReflectionOverAlpha;
  26515. /**
  26516. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26517. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26518. */
  26519. useReflectionOverAlpha: boolean;
  26520. private _disableLighting;
  26521. /**
  26522. * Does lights from the scene impacts this material.
  26523. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26524. */
  26525. disableLighting: boolean;
  26526. private _useObjectSpaceNormalMap;
  26527. /**
  26528. * Allows using an object space normal map (instead of tangent space).
  26529. */
  26530. useObjectSpaceNormalMap: boolean;
  26531. private _useParallax;
  26532. /**
  26533. * Is parallax enabled or not.
  26534. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26535. */
  26536. useParallax: boolean;
  26537. private _useParallaxOcclusion;
  26538. /**
  26539. * Is parallax occlusion enabled or not.
  26540. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26541. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26542. */
  26543. useParallaxOcclusion: boolean;
  26544. /**
  26545. * 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.
  26546. */
  26547. parallaxScaleBias: number;
  26548. private _roughness;
  26549. /**
  26550. * Helps to define how blurry the reflections should appears in the material.
  26551. */
  26552. roughness: number;
  26553. /**
  26554. * In case of refraction, define the value of the index of refraction.
  26555. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26556. */
  26557. indexOfRefraction: number;
  26558. /**
  26559. * Invert the refraction texture alongside the y axis.
  26560. * It can be useful with procedural textures or probe for instance.
  26561. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26562. */
  26563. invertRefractionY: boolean;
  26564. /**
  26565. * Defines the alpha limits in alpha test mode.
  26566. */
  26567. alphaCutOff: number;
  26568. private _useLightmapAsShadowmap;
  26569. /**
  26570. * In case of light mapping, define whether the map contains light or shadow informations.
  26571. */
  26572. useLightmapAsShadowmap: boolean;
  26573. private _diffuseFresnelParameters;
  26574. /**
  26575. * Define the diffuse fresnel parameters of the material.
  26576. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26577. */
  26578. diffuseFresnelParameters: FresnelParameters;
  26579. private _opacityFresnelParameters;
  26580. /**
  26581. * Define the opacity fresnel parameters of the material.
  26582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26583. */
  26584. opacityFresnelParameters: FresnelParameters;
  26585. private _reflectionFresnelParameters;
  26586. /**
  26587. * Define the reflection fresnel parameters of the material.
  26588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26589. */
  26590. reflectionFresnelParameters: FresnelParameters;
  26591. private _refractionFresnelParameters;
  26592. /**
  26593. * Define the refraction fresnel parameters of the material.
  26594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26595. */
  26596. refractionFresnelParameters: FresnelParameters;
  26597. private _emissiveFresnelParameters;
  26598. /**
  26599. * Define the emissive fresnel parameters of the material.
  26600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26601. */
  26602. emissiveFresnelParameters: FresnelParameters;
  26603. private _useReflectionFresnelFromSpecular;
  26604. /**
  26605. * If true automatically deducts the fresnels values from the material specularity.
  26606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26607. */
  26608. useReflectionFresnelFromSpecular: boolean;
  26609. private _useGlossinessFromSpecularMapAlpha;
  26610. /**
  26611. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26612. */
  26613. useGlossinessFromSpecularMapAlpha: boolean;
  26614. private _maxSimultaneousLights;
  26615. /**
  26616. * Defines the maximum number of lights that can be used in the material
  26617. */
  26618. maxSimultaneousLights: number;
  26619. private _invertNormalMapX;
  26620. /**
  26621. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26622. */
  26623. invertNormalMapX: boolean;
  26624. private _invertNormalMapY;
  26625. /**
  26626. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26627. */
  26628. invertNormalMapY: boolean;
  26629. private _twoSidedLighting;
  26630. /**
  26631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26632. */
  26633. twoSidedLighting: boolean;
  26634. /**
  26635. * Default configuration related to image processing available in the standard Material.
  26636. */
  26637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26638. /**
  26639. * Gets the image processing configuration used either in this material.
  26640. */
  26641. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26642. /**
  26643. * Sets the Default image processing configuration used either in the this material.
  26644. *
  26645. * If sets to null, the scene one is in use.
  26646. */
  26647. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26648. /**
  26649. * Keep track of the image processing observer to allow dispose and replace.
  26650. */
  26651. private _imageProcessingObserver;
  26652. /**
  26653. * Attaches a new image processing configuration to the Standard Material.
  26654. * @param configuration
  26655. */
  26656. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26657. /**
  26658. * Gets wether the color curves effect is enabled.
  26659. */
  26660. get cameraColorCurvesEnabled(): boolean;
  26661. /**
  26662. * Sets wether the color curves effect is enabled.
  26663. */
  26664. set cameraColorCurvesEnabled(value: boolean);
  26665. /**
  26666. * Gets wether the color grading effect is enabled.
  26667. */
  26668. get cameraColorGradingEnabled(): boolean;
  26669. /**
  26670. * Gets wether the color grading effect is enabled.
  26671. */
  26672. set cameraColorGradingEnabled(value: boolean);
  26673. /**
  26674. * Gets wether tonemapping is enabled or not.
  26675. */
  26676. get cameraToneMappingEnabled(): boolean;
  26677. /**
  26678. * Sets wether tonemapping is enabled or not
  26679. */
  26680. set cameraToneMappingEnabled(value: boolean);
  26681. /**
  26682. * The camera exposure used on this material.
  26683. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26684. * This corresponds to a photographic exposure.
  26685. */
  26686. get cameraExposure(): number;
  26687. /**
  26688. * The camera exposure used on this material.
  26689. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26690. * This corresponds to a photographic exposure.
  26691. */
  26692. set cameraExposure(value: number);
  26693. /**
  26694. * Gets The camera contrast used on this material.
  26695. */
  26696. get cameraContrast(): number;
  26697. /**
  26698. * Sets The camera contrast used on this material.
  26699. */
  26700. set cameraContrast(value: number);
  26701. /**
  26702. * Gets the Color Grading 2D Lookup Texture.
  26703. */
  26704. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26705. /**
  26706. * Sets the Color Grading 2D Lookup Texture.
  26707. */
  26708. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26709. /**
  26710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26712. * 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;
  26713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26714. */
  26715. get cameraColorCurves(): Nullable<ColorCurves>;
  26716. /**
  26717. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26718. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26719. * 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;
  26720. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26721. */
  26722. set cameraColorCurves(value: Nullable<ColorCurves>);
  26723. /**
  26724. * Custom callback helping to override the default shader used in the material.
  26725. */
  26726. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26727. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26728. protected _worldViewProjectionMatrix: Matrix;
  26729. protected _globalAmbientColor: Color3;
  26730. protected _useLogarithmicDepth: boolean;
  26731. protected _rebuildInParallel: boolean;
  26732. /**
  26733. * Instantiates a new standard material.
  26734. * This is the default material used in Babylon. It is the best trade off between quality
  26735. * and performances.
  26736. * @see http://doc.babylonjs.com/babylon101/materials
  26737. * @param name Define the name of the material in the scene
  26738. * @param scene Define the scene the material belong to
  26739. */
  26740. constructor(name: string, scene: Scene);
  26741. /**
  26742. * Gets a boolean indicating that current material needs to register RTT
  26743. */
  26744. get hasRenderTargetTextures(): boolean;
  26745. /**
  26746. * Gets the current class name of the material e.g. "StandardMaterial"
  26747. * Mainly use in serialization.
  26748. * @returns the class name
  26749. */
  26750. getClassName(): string;
  26751. /**
  26752. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26753. * You can try switching to logarithmic depth.
  26754. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26755. */
  26756. get useLogarithmicDepth(): boolean;
  26757. set useLogarithmicDepth(value: boolean);
  26758. /**
  26759. * Specifies if the material will require alpha blending
  26760. * @returns a boolean specifying if alpha blending is needed
  26761. */
  26762. needAlphaBlending(): boolean;
  26763. /**
  26764. * Specifies if this material should be rendered in alpha test mode
  26765. * @returns a boolean specifying if an alpha test is needed.
  26766. */
  26767. needAlphaTesting(): boolean;
  26768. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26769. /**
  26770. * Get the texture used for alpha test purpose.
  26771. * @returns the diffuse texture in case of the standard material.
  26772. */
  26773. getAlphaTestTexture(): Nullable<BaseTexture>;
  26774. /**
  26775. * Get if the submesh is ready to be used and all its information available.
  26776. * Child classes can use it to update shaders
  26777. * @param mesh defines the mesh to check
  26778. * @param subMesh defines which submesh to check
  26779. * @param useInstances specifies that instances should be used
  26780. * @returns a boolean indicating that the submesh is ready or not
  26781. */
  26782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26783. /**
  26784. * Builds the material UBO layouts.
  26785. * Used internally during the effect preparation.
  26786. */
  26787. buildUniformLayout(): void;
  26788. /**
  26789. * Unbinds the material from the mesh
  26790. */
  26791. unbind(): void;
  26792. /**
  26793. * Binds the submesh to this material by preparing the effect and shader to draw
  26794. * @param world defines the world transformation matrix
  26795. * @param mesh defines the mesh containing the submesh
  26796. * @param subMesh defines the submesh to bind the material to
  26797. */
  26798. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26799. /**
  26800. * Get the list of animatables in the material.
  26801. * @returns the list of animatables object used in the material
  26802. */
  26803. getAnimatables(): IAnimatable[];
  26804. /**
  26805. * Gets the active textures from the material
  26806. * @returns an array of textures
  26807. */
  26808. getActiveTextures(): BaseTexture[];
  26809. /**
  26810. * Specifies if the material uses a texture
  26811. * @param texture defines the texture to check against the material
  26812. * @returns a boolean specifying if the material uses the texture
  26813. */
  26814. hasTexture(texture: BaseTexture): boolean;
  26815. /**
  26816. * Disposes the material
  26817. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26818. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26819. */
  26820. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26821. /**
  26822. * Makes a duplicate of the material, and gives it a new name
  26823. * @param name defines the new name for the duplicated material
  26824. * @returns the cloned material
  26825. */
  26826. clone(name: string): StandardMaterial;
  26827. /**
  26828. * Serializes this material in a JSON representation
  26829. * @returns the serialized material object
  26830. */
  26831. serialize(): any;
  26832. /**
  26833. * Creates a standard material from parsed material data
  26834. * @param source defines the JSON representation of the material
  26835. * @param scene defines the hosting scene
  26836. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26837. * @returns a new standard material
  26838. */
  26839. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26840. /**
  26841. * Are diffuse textures enabled in the application.
  26842. */
  26843. static get DiffuseTextureEnabled(): boolean;
  26844. static set DiffuseTextureEnabled(value: boolean);
  26845. /**
  26846. * Are ambient textures enabled in the application.
  26847. */
  26848. static get AmbientTextureEnabled(): boolean;
  26849. static set AmbientTextureEnabled(value: boolean);
  26850. /**
  26851. * Are opacity textures enabled in the application.
  26852. */
  26853. static get OpacityTextureEnabled(): boolean;
  26854. static set OpacityTextureEnabled(value: boolean);
  26855. /**
  26856. * Are reflection textures enabled in the application.
  26857. */
  26858. static get ReflectionTextureEnabled(): boolean;
  26859. static set ReflectionTextureEnabled(value: boolean);
  26860. /**
  26861. * Are emissive textures enabled in the application.
  26862. */
  26863. static get EmissiveTextureEnabled(): boolean;
  26864. static set EmissiveTextureEnabled(value: boolean);
  26865. /**
  26866. * Are specular textures enabled in the application.
  26867. */
  26868. static get SpecularTextureEnabled(): boolean;
  26869. static set SpecularTextureEnabled(value: boolean);
  26870. /**
  26871. * Are bump textures enabled in the application.
  26872. */
  26873. static get BumpTextureEnabled(): boolean;
  26874. static set BumpTextureEnabled(value: boolean);
  26875. /**
  26876. * Are lightmap textures enabled in the application.
  26877. */
  26878. static get LightmapTextureEnabled(): boolean;
  26879. static set LightmapTextureEnabled(value: boolean);
  26880. /**
  26881. * Are refraction textures enabled in the application.
  26882. */
  26883. static get RefractionTextureEnabled(): boolean;
  26884. static set RefractionTextureEnabled(value: boolean);
  26885. /**
  26886. * Are color grading textures enabled in the application.
  26887. */
  26888. static get ColorGradingTextureEnabled(): boolean;
  26889. static set ColorGradingTextureEnabled(value: boolean);
  26890. /**
  26891. * Are fresnels enabled in the application.
  26892. */
  26893. static get FresnelEnabled(): boolean;
  26894. static set FresnelEnabled(value: boolean);
  26895. }
  26896. }
  26897. declare module BABYLON {
  26898. /**
  26899. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26900. *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.
  26901. * The SPS is also a particle system. It provides some methods to manage the particles.
  26902. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26903. *
  26904. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26905. */
  26906. export class SolidParticleSystem implements IDisposable {
  26907. /**
  26908. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26909. * Example : var p = SPS.particles[i];
  26910. */
  26911. particles: SolidParticle[];
  26912. /**
  26913. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26914. */
  26915. nbParticles: number;
  26916. /**
  26917. * If the particles must ever face the camera (default false). Useful for planar particles.
  26918. */
  26919. billboard: boolean;
  26920. /**
  26921. * Recompute normals when adding a shape
  26922. */
  26923. recomputeNormals: boolean;
  26924. /**
  26925. * This a counter ofr your own usage. It's not set by any SPS functions.
  26926. */
  26927. counter: number;
  26928. /**
  26929. * The SPS name. This name is also given to the underlying mesh.
  26930. */
  26931. name: string;
  26932. /**
  26933. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26934. */
  26935. mesh: Mesh;
  26936. /**
  26937. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26938. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26939. */
  26940. vars: any;
  26941. /**
  26942. * This array is populated when the SPS is set as 'pickable'.
  26943. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26944. * Each element of this array is an object `{idx: int, faceId: int}`.
  26945. * `idx` is the picked particle index in the `SPS.particles` array
  26946. * `faceId` is the picked face index counted within this particle.
  26947. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26948. */
  26949. pickedParticles: {
  26950. idx: number;
  26951. faceId: number;
  26952. }[];
  26953. /**
  26954. * This array is populated when `enableDepthSort` is set to true.
  26955. * Each element of this array is an instance of the class DepthSortedParticle.
  26956. */
  26957. depthSortedParticles: DepthSortedParticle[];
  26958. /**
  26959. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26960. * @hidden
  26961. */
  26962. _bSphereOnly: boolean;
  26963. /**
  26964. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26965. * @hidden
  26966. */
  26967. _bSphereRadiusFactor: number;
  26968. private _scene;
  26969. private _positions;
  26970. private _indices;
  26971. private _normals;
  26972. private _colors;
  26973. private _uvs;
  26974. private _indices32;
  26975. private _positions32;
  26976. private _normals32;
  26977. private _fixedNormal32;
  26978. private _colors32;
  26979. private _uvs32;
  26980. private _index;
  26981. private _updatable;
  26982. private _pickable;
  26983. private _isVisibilityBoxLocked;
  26984. private _alwaysVisible;
  26985. private _depthSort;
  26986. private _expandable;
  26987. private _shapeCounter;
  26988. private _copy;
  26989. private _color;
  26990. private _computeParticleColor;
  26991. private _computeParticleTexture;
  26992. private _computeParticleRotation;
  26993. private _computeParticleVertex;
  26994. private _computeBoundingBox;
  26995. private _depthSortParticles;
  26996. private _camera;
  26997. private _mustUnrotateFixedNormals;
  26998. private _particlesIntersect;
  26999. private _needs32Bits;
  27000. private _isNotBuilt;
  27001. private _lastParticleId;
  27002. private _idxOfId;
  27003. private _multimaterialEnabled;
  27004. private _useModelMaterial;
  27005. private _indicesByMaterial;
  27006. private _materialIndexes;
  27007. private _depthSortFunction;
  27008. private _materialSortFunction;
  27009. private _materials;
  27010. private _multimaterial;
  27011. private _materialIndexesById;
  27012. private _defaultMaterial;
  27013. private _autoUpdateSubMeshes;
  27014. /**
  27015. * Creates a SPS (Solid Particle System) object.
  27016. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27017. * @param scene (Scene) is the scene in which the SPS is added.
  27018. * @param options defines the options of the sps e.g.
  27019. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27020. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27021. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27022. * * 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.
  27023. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27024. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27025. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27026. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27027. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27028. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27029. */
  27030. constructor(name: string, scene: Scene, options?: {
  27031. updatable?: boolean;
  27032. isPickable?: boolean;
  27033. enableDepthSort?: boolean;
  27034. particleIntersection?: boolean;
  27035. boundingSphereOnly?: boolean;
  27036. bSphereRadiusFactor?: number;
  27037. expandable?: boolean;
  27038. useModelMaterial?: boolean;
  27039. enableMultiMaterial?: boolean;
  27040. });
  27041. /**
  27042. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27043. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27044. * @returns the created mesh
  27045. */
  27046. buildMesh(): Mesh;
  27047. /**
  27048. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27049. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27050. * Thus the particles generated from `digest()` have their property `position` set yet.
  27051. * @param mesh ( Mesh ) is the mesh to be digested
  27052. * @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
  27053. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27054. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27055. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27056. * @returns the current SPS
  27057. */
  27058. digest(mesh: Mesh, options?: {
  27059. facetNb?: number;
  27060. number?: number;
  27061. delta?: number;
  27062. storage?: [];
  27063. }): SolidParticleSystem;
  27064. /**
  27065. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27066. * @hidden
  27067. */
  27068. private _unrotateFixedNormals;
  27069. /**
  27070. * Resets the temporary working copy particle
  27071. * @hidden
  27072. */
  27073. private _resetCopy;
  27074. /**
  27075. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27076. * @param p the current index in the positions array to be updated
  27077. * @param ind the current index in the indices array
  27078. * @param shape a Vector3 array, the shape geometry
  27079. * @param positions the positions array to be updated
  27080. * @param meshInd the shape indices array
  27081. * @param indices the indices array to be updated
  27082. * @param meshUV the shape uv array
  27083. * @param uvs the uv array to be updated
  27084. * @param meshCol the shape color array
  27085. * @param colors the color array to be updated
  27086. * @param meshNor the shape normals array
  27087. * @param normals the normals array to be updated
  27088. * @param idx the particle index
  27089. * @param idxInShape the particle index in its shape
  27090. * @param options the addShape() method passed options
  27091. * @model the particle model
  27092. * @hidden
  27093. */
  27094. private _meshBuilder;
  27095. /**
  27096. * Returns a shape Vector3 array from positions float array
  27097. * @param positions float array
  27098. * @returns a vector3 array
  27099. * @hidden
  27100. */
  27101. private _posToShape;
  27102. /**
  27103. * Returns a shapeUV array from a float uvs (array deep copy)
  27104. * @param uvs as a float array
  27105. * @returns a shapeUV array
  27106. * @hidden
  27107. */
  27108. private _uvsToShapeUV;
  27109. /**
  27110. * Adds a new particle object in the particles array
  27111. * @param idx particle index in particles array
  27112. * @param id particle id
  27113. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27114. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27115. * @param model particle ModelShape object
  27116. * @param shapeId model shape identifier
  27117. * @param idxInShape index of the particle in the current model
  27118. * @param bInfo model bounding info object
  27119. * @param storage target storage array, if any
  27120. * @hidden
  27121. */
  27122. private _addParticle;
  27123. /**
  27124. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27125. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27126. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27127. * @param nb (positive integer) the number of particles to be created from this model
  27128. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27129. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27130. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27131. * @returns the number of shapes in the system
  27132. */
  27133. addShape(mesh: Mesh, nb: number, options?: {
  27134. positionFunction?: any;
  27135. vertexFunction?: any;
  27136. storage?: [];
  27137. }): number;
  27138. /**
  27139. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27140. * @hidden
  27141. */
  27142. private _rebuildParticle;
  27143. /**
  27144. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27145. * @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.
  27146. * @returns the SPS.
  27147. */
  27148. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27149. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27150. * Returns an array with the removed particles.
  27151. * 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.
  27152. * The SPS can't be empty so at least one particle needs to remain in place.
  27153. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27154. * @param start index of the first particle to remove
  27155. * @param end index of the last particle to remove (included)
  27156. * @returns an array populated with the removed particles
  27157. */
  27158. removeParticles(start: number, end: number): SolidParticle[];
  27159. /**
  27160. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27161. * @param solidParticleArray an array populated with Solid Particles objects
  27162. * @returns the SPS
  27163. */
  27164. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27165. /**
  27166. * Creates a new particle and modifies the SPS mesh geometry :
  27167. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27168. * - calls _addParticle() to populate the particle array
  27169. * factorized code from addShape() and insertParticlesFromArray()
  27170. * @param idx particle index in the particles array
  27171. * @param i particle index in its shape
  27172. * @param modelShape particle ModelShape object
  27173. * @param shape shape vertex array
  27174. * @param meshInd shape indices array
  27175. * @param meshUV shape uv array
  27176. * @param meshCol shape color array
  27177. * @param meshNor shape normals array
  27178. * @param bbInfo shape bounding info
  27179. * @param storage target particle storage
  27180. * @options addShape() passed options
  27181. * @hidden
  27182. */
  27183. private _insertNewParticle;
  27184. /**
  27185. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27186. * This method calls `updateParticle()` for each particle of the SPS.
  27187. * For an animated SPS, it is usually called within the render loop.
  27188. * 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.
  27189. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27190. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27191. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27192. * @returns the SPS.
  27193. */
  27194. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27195. /**
  27196. * Disposes the SPS.
  27197. */
  27198. dispose(): void;
  27199. /**
  27200. * Returns a SolidParticle object from its identifier : particle.id
  27201. * @param id (integer) the particle Id
  27202. * @returns the searched particle or null if not found in the SPS.
  27203. */
  27204. getParticleById(id: number): Nullable<SolidParticle>;
  27205. /**
  27206. * Returns a new array populated with the particles having the passed shapeId.
  27207. * @param shapeId (integer) the shape identifier
  27208. * @returns a new solid particle array
  27209. */
  27210. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27211. /**
  27212. * Populates the passed array "ref" with the particles having the passed shapeId.
  27213. * @param shapeId the shape identifier
  27214. * @returns the SPS
  27215. * @param ref
  27216. */
  27217. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27218. /**
  27219. * Computes the required SubMeshes according the materials assigned to the particles.
  27220. * @returns the solid particle system.
  27221. * Does nothing if called before the SPS mesh is built.
  27222. */
  27223. computeSubMeshes(): SolidParticleSystem;
  27224. /**
  27225. * Sorts the solid particles by material when MultiMaterial is enabled.
  27226. * Updates the indices32 array.
  27227. * Updates the indicesByMaterial array.
  27228. * Updates the mesh indices array.
  27229. * @returns the SPS
  27230. * @hidden
  27231. */
  27232. private _sortParticlesByMaterial;
  27233. /**
  27234. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27235. * @hidden
  27236. */
  27237. private _setMaterialIndexesById;
  27238. /**
  27239. * Returns an array with unique values of Materials from the passed array
  27240. * @param array the material array to be checked and filtered
  27241. * @hidden
  27242. */
  27243. private _filterUniqueMaterialId;
  27244. /**
  27245. * Sets a new Standard Material as _defaultMaterial if not already set.
  27246. * @hidden
  27247. */
  27248. private _setDefaultMaterial;
  27249. /**
  27250. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27252. * @returns the SPS.
  27253. */
  27254. refreshVisibleSize(): SolidParticleSystem;
  27255. /**
  27256. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27257. * @param size the size (float) of the visibility box
  27258. * note : this doesn't lock the SPS mesh bounding box.
  27259. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27260. */
  27261. setVisibilityBox(size: number): void;
  27262. /**
  27263. * Gets whether the SPS as always visible or not
  27264. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27265. */
  27266. get isAlwaysVisible(): boolean;
  27267. /**
  27268. * Sets the SPS as always visible or not
  27269. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27270. */
  27271. set isAlwaysVisible(val: boolean);
  27272. /**
  27273. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27274. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27275. */
  27276. set isVisibilityBoxLocked(val: boolean);
  27277. /**
  27278. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27279. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27280. */
  27281. get isVisibilityBoxLocked(): boolean;
  27282. /**
  27283. * Tells to `setParticles()` to compute the particle rotations or not.
  27284. * Default value : true. The SPS is faster when it's set to false.
  27285. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27286. */
  27287. set computeParticleRotation(val: boolean);
  27288. /**
  27289. * Tells to `setParticles()` to compute the particle colors or not.
  27290. * Default value : true. The SPS is faster when it's set to false.
  27291. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27292. */
  27293. set computeParticleColor(val: boolean);
  27294. set computeParticleTexture(val: boolean);
  27295. /**
  27296. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27297. * Default value : false. The SPS is faster when it's set to false.
  27298. * Note : the particle custom vertex positions aren't stored values.
  27299. */
  27300. set computeParticleVertex(val: boolean);
  27301. /**
  27302. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27303. */
  27304. set computeBoundingBox(val: boolean);
  27305. /**
  27306. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27307. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27308. * Default : `true`
  27309. */
  27310. set depthSortParticles(val: boolean);
  27311. /**
  27312. * Gets if `setParticles()` computes the particle rotations or not.
  27313. * Default value : true. The SPS is faster when it's set to false.
  27314. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27315. */
  27316. get computeParticleRotation(): boolean;
  27317. /**
  27318. * Gets if `setParticles()` computes the particle colors or not.
  27319. * Default value : true. The SPS is faster when it's set to false.
  27320. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27321. */
  27322. get computeParticleColor(): boolean;
  27323. /**
  27324. * Gets if `setParticles()` computes the particle textures or not.
  27325. * Default value : true. The SPS is faster when it's set to false.
  27326. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27327. */
  27328. get computeParticleTexture(): boolean;
  27329. /**
  27330. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27331. * Default value : false. The SPS is faster when it's set to false.
  27332. * Note : the particle custom vertex positions aren't stored values.
  27333. */
  27334. get computeParticleVertex(): boolean;
  27335. /**
  27336. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27337. */
  27338. get computeBoundingBox(): boolean;
  27339. /**
  27340. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27341. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27342. * Default : `true`
  27343. */
  27344. get depthSortParticles(): boolean;
  27345. /**
  27346. * Gets if the SPS is created as expandable at construction time.
  27347. * Default : `false`
  27348. */
  27349. get expandable(): boolean;
  27350. /**
  27351. * Gets if the SPS supports the Multi Materials
  27352. */
  27353. get multimaterialEnabled(): boolean;
  27354. /**
  27355. * Gets if the SPS uses the model materials for its own multimaterial.
  27356. */
  27357. get useModelMaterial(): boolean;
  27358. /**
  27359. * The SPS used material array.
  27360. */
  27361. get materials(): Material[];
  27362. /**
  27363. * Sets the SPS MultiMaterial from the passed materials.
  27364. * Note : the passed array is internally copied and not used then by reference.
  27365. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27366. */
  27367. setMultiMaterial(materials: Material[]): void;
  27368. /**
  27369. * The SPS computed multimaterial object
  27370. */
  27371. get multimaterial(): MultiMaterial;
  27372. set multimaterial(mm: MultiMaterial);
  27373. /**
  27374. * If the subMeshes must be updated on the next call to setParticles()
  27375. */
  27376. get autoUpdateSubMeshes(): boolean;
  27377. set autoUpdateSubMeshes(val: boolean);
  27378. /**
  27379. * This function does nothing. It may be overwritten to set all the particle first values.
  27380. * The SPS doesn't call this function, you may have to call it by your own.
  27381. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27382. */
  27383. initParticles(): void;
  27384. /**
  27385. * This function does nothing. It may be overwritten to recycle a particle.
  27386. * The SPS doesn't call this function, you may have to call it by your own.
  27387. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27388. * @param particle The particle to recycle
  27389. * @returns the recycled particle
  27390. */
  27391. recycleParticle(particle: SolidParticle): SolidParticle;
  27392. /**
  27393. * Updates a particle : this function should be overwritten by the user.
  27394. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27395. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27396. * @example : just set a particle position or velocity and recycle conditions
  27397. * @param particle The particle to update
  27398. * @returns the updated particle
  27399. */
  27400. updateParticle(particle: SolidParticle): SolidParticle;
  27401. /**
  27402. * Updates a vertex of a particle : it can be overwritten by the user.
  27403. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27404. * @param particle the current particle
  27405. * @param vertex the current index of the current particle
  27406. * @param pt the index of the current vertex in the particle shape
  27407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27408. * @example : just set a vertex particle position
  27409. * @returns the updated vertex
  27410. */
  27411. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27412. /**
  27413. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27414. * This does nothing and may be overwritten by the user.
  27415. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27416. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27417. * @param update the boolean update value actually passed to setParticles()
  27418. */
  27419. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27420. /**
  27421. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27422. * This will be passed three parameters.
  27423. * This does nothing and may be overwritten by the user.
  27424. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27425. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27426. * @param update the boolean update value actually passed to setParticles()
  27427. */
  27428. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27429. }
  27430. }
  27431. declare module BABYLON {
  27432. /**
  27433. * Represents one particle of a solid particle system.
  27434. */
  27435. export class SolidParticle {
  27436. /**
  27437. * particle global index
  27438. */
  27439. idx: number;
  27440. /**
  27441. * particle identifier
  27442. */
  27443. id: number;
  27444. /**
  27445. * The color of the particle
  27446. */
  27447. color: Nullable<Color4>;
  27448. /**
  27449. * The world space position of the particle.
  27450. */
  27451. position: Vector3;
  27452. /**
  27453. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27454. */
  27455. rotation: Vector3;
  27456. /**
  27457. * The world space rotation quaternion of the particle.
  27458. */
  27459. rotationQuaternion: Nullable<Quaternion>;
  27460. /**
  27461. * The scaling of the particle.
  27462. */
  27463. scaling: Vector3;
  27464. /**
  27465. * The uvs of the particle.
  27466. */
  27467. uvs: Vector4;
  27468. /**
  27469. * The current speed of the particle.
  27470. */
  27471. velocity: Vector3;
  27472. /**
  27473. * The pivot point in the particle local space.
  27474. */
  27475. pivot: Vector3;
  27476. /**
  27477. * Must the particle be translated from its pivot point in its local space ?
  27478. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27479. * Default : false
  27480. */
  27481. translateFromPivot: boolean;
  27482. /**
  27483. * Is the particle active or not ?
  27484. */
  27485. alive: boolean;
  27486. /**
  27487. * Is the particle visible or not ?
  27488. */
  27489. isVisible: boolean;
  27490. /**
  27491. * Index of this particle in the global "positions" array (Internal use)
  27492. * @hidden
  27493. */
  27494. _pos: number;
  27495. /**
  27496. * @hidden Index of this particle in the global "indices" array (Internal use)
  27497. */
  27498. _ind: number;
  27499. /**
  27500. * @hidden ModelShape of this particle (Internal use)
  27501. */
  27502. _model: ModelShape;
  27503. /**
  27504. * ModelShape id of this particle
  27505. */
  27506. shapeId: number;
  27507. /**
  27508. * Index of the particle in its shape id
  27509. */
  27510. idxInShape: number;
  27511. /**
  27512. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27513. */
  27514. _modelBoundingInfo: BoundingInfo;
  27515. /**
  27516. * @hidden Particle BoundingInfo object (Internal use)
  27517. */
  27518. _boundingInfo: BoundingInfo;
  27519. /**
  27520. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27521. */
  27522. _sps: SolidParticleSystem;
  27523. /**
  27524. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27525. */
  27526. _stillInvisible: boolean;
  27527. /**
  27528. * @hidden Last computed particle rotation matrix
  27529. */
  27530. _rotationMatrix: number[];
  27531. /**
  27532. * Parent particle Id, if any.
  27533. * Default null.
  27534. */
  27535. parentId: Nullable<number>;
  27536. /**
  27537. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27538. */
  27539. materialIndex: Nullable<number>;
  27540. /**
  27541. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27542. * The possible values are :
  27543. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27544. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27545. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27546. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27547. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27548. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27549. * */
  27550. cullingStrategy: number;
  27551. /**
  27552. * @hidden Internal global position in the SPS.
  27553. */
  27554. _globalPosition: Vector3;
  27555. /**
  27556. * Creates a Solid Particle object.
  27557. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27558. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27559. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27560. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27561. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27562. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27563. * @param shapeId (integer) is the model shape identifier in the SPS.
  27564. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27565. * @param sps defines the sps it is associated to
  27566. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27567. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27568. */
  27569. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27570. /**
  27571. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27572. * @param target the particle target
  27573. * @returns the current particle
  27574. */
  27575. copyToRef(target: SolidParticle): SolidParticle;
  27576. /**
  27577. * Legacy support, changed scale to scaling
  27578. */
  27579. get scale(): Vector3;
  27580. /**
  27581. * Legacy support, changed scale to scaling
  27582. */
  27583. set scale(scale: Vector3);
  27584. /**
  27585. * Legacy support, changed quaternion to rotationQuaternion
  27586. */
  27587. get quaternion(): Nullable<Quaternion>;
  27588. /**
  27589. * Legacy support, changed quaternion to rotationQuaternion
  27590. */
  27591. set quaternion(q: Nullable<Quaternion>);
  27592. /**
  27593. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27594. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27595. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27596. * @returns true if it intersects
  27597. */
  27598. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27599. /**
  27600. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27601. * A particle is in the frustum if its bounding box intersects the frustum
  27602. * @param frustumPlanes defines the frustum to test
  27603. * @returns true if the particle is in the frustum planes
  27604. */
  27605. isInFrustum(frustumPlanes: Plane[]): boolean;
  27606. /**
  27607. * get the rotation matrix of the particle
  27608. * @hidden
  27609. */
  27610. getRotationMatrix(m: Matrix): void;
  27611. }
  27612. /**
  27613. * Represents the shape of the model used by one particle of a solid particle system.
  27614. * SPS internal tool, don't use it manually.
  27615. */
  27616. export class ModelShape {
  27617. /**
  27618. * The shape id
  27619. * @hidden
  27620. */
  27621. shapeID: number;
  27622. /**
  27623. * flat array of model positions (internal use)
  27624. * @hidden
  27625. */
  27626. _shape: Vector3[];
  27627. /**
  27628. * flat array of model UVs (internal use)
  27629. * @hidden
  27630. */
  27631. _shapeUV: number[];
  27632. /**
  27633. * color array of the model
  27634. * @hidden
  27635. */
  27636. _shapeColors: number[];
  27637. /**
  27638. * indices array of the model
  27639. * @hidden
  27640. */
  27641. _indices: number[];
  27642. /**
  27643. * normals array of the model
  27644. * @hidden
  27645. */
  27646. _normals: number[];
  27647. /**
  27648. * length of the shape in the model indices array (internal use)
  27649. * @hidden
  27650. */
  27651. _indicesLength: number;
  27652. /**
  27653. * Custom position function (internal use)
  27654. * @hidden
  27655. */
  27656. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27657. /**
  27658. * Custom vertex function (internal use)
  27659. * @hidden
  27660. */
  27661. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27662. /**
  27663. * Model material (internal use)
  27664. * @hidden
  27665. */
  27666. _material: Nullable<Material>;
  27667. /**
  27668. * 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.
  27669. * SPS internal tool, don't use it manually.
  27670. * @hidden
  27671. */
  27672. 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>);
  27673. }
  27674. /**
  27675. * Represents a Depth Sorted Particle in the solid particle system.
  27676. * @hidden
  27677. */
  27678. export class DepthSortedParticle {
  27679. /**
  27680. * Index of the particle in the "indices" array
  27681. */
  27682. ind: number;
  27683. /**
  27684. * Length of the particle shape in the "indices" array
  27685. */
  27686. indicesLength: number;
  27687. /**
  27688. * Squared distance from the particle to the camera
  27689. */
  27690. sqDistance: number;
  27691. /**
  27692. * Material index when used with MultiMaterials
  27693. */
  27694. materialIndex: number;
  27695. /**
  27696. * Creates a new sorted particle
  27697. * @param materialIndex
  27698. */
  27699. constructor(ind: number, indLength: number, materialIndex: number);
  27700. }
  27701. }
  27702. declare module BABYLON {
  27703. /**
  27704. * @hidden
  27705. */
  27706. export class _MeshCollisionData {
  27707. _checkCollisions: boolean;
  27708. _collisionMask: number;
  27709. _collisionGroup: number;
  27710. _collider: Nullable<Collider>;
  27711. _oldPositionForCollisions: Vector3;
  27712. _diffPositionForCollisions: Vector3;
  27713. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27714. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27715. }
  27716. }
  27717. declare module BABYLON {
  27718. /** @hidden */
  27719. class _FacetDataStorage {
  27720. facetPositions: Vector3[];
  27721. facetNormals: Vector3[];
  27722. facetPartitioning: number[][];
  27723. facetNb: number;
  27724. partitioningSubdivisions: number;
  27725. partitioningBBoxRatio: number;
  27726. facetDataEnabled: boolean;
  27727. facetParameters: any;
  27728. bbSize: Vector3;
  27729. subDiv: {
  27730. max: number;
  27731. X: number;
  27732. Y: number;
  27733. Z: number;
  27734. };
  27735. facetDepthSort: boolean;
  27736. facetDepthSortEnabled: boolean;
  27737. depthSortedIndices: IndicesArray;
  27738. depthSortedFacets: {
  27739. ind: number;
  27740. sqDistance: number;
  27741. }[];
  27742. facetDepthSortFunction: (f1: {
  27743. ind: number;
  27744. sqDistance: number;
  27745. }, f2: {
  27746. ind: number;
  27747. sqDistance: number;
  27748. }) => number;
  27749. facetDepthSortFrom: Vector3;
  27750. facetDepthSortOrigin: Vector3;
  27751. invertedMatrix: Matrix;
  27752. }
  27753. /**
  27754. * @hidden
  27755. **/
  27756. class _InternalAbstractMeshDataInfo {
  27757. _hasVertexAlpha: boolean;
  27758. _useVertexColors: boolean;
  27759. _numBoneInfluencers: number;
  27760. _applyFog: boolean;
  27761. _receiveShadows: boolean;
  27762. _facetData: _FacetDataStorage;
  27763. _visibility: number;
  27764. _skeleton: Nullable<Skeleton>;
  27765. _layerMask: number;
  27766. _computeBonesUsingShaders: boolean;
  27767. _isActive: boolean;
  27768. _onlyForInstances: boolean;
  27769. _isActiveIntermediate: boolean;
  27770. _onlyForInstancesIntermediate: boolean;
  27771. _actAsRegularMesh: boolean;
  27772. }
  27773. /**
  27774. * Class used to store all common mesh properties
  27775. */
  27776. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27777. /** No occlusion */
  27778. static OCCLUSION_TYPE_NONE: number;
  27779. /** Occlusion set to optimisitic */
  27780. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27781. /** Occlusion set to strict */
  27782. static OCCLUSION_TYPE_STRICT: number;
  27783. /** Use an accurante occlusion algorithm */
  27784. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27785. /** Use a conservative occlusion algorithm */
  27786. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27787. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27788. * Test order :
  27789. * Is the bounding sphere outside the frustum ?
  27790. * If not, are the bounding box vertices outside the frustum ?
  27791. * It not, then the cullable object is in the frustum.
  27792. */
  27793. static readonly CULLINGSTRATEGY_STANDARD: number;
  27794. /** Culling strategy : Bounding Sphere Only.
  27795. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27796. * It's also less accurate than the standard because some not visible objects can still be selected.
  27797. * Test : is the bounding sphere outside the frustum ?
  27798. * If not, then the cullable object is in the frustum.
  27799. */
  27800. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27801. /** Culling strategy : Optimistic Inclusion.
  27802. * This in an inclusion test first, then the standard exclusion test.
  27803. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27804. * 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.
  27805. * Anyway, it's as accurate as the standard strategy.
  27806. * Test :
  27807. * Is the cullable object bounding sphere center in the frustum ?
  27808. * If not, apply the default culling strategy.
  27809. */
  27810. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27811. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27812. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27813. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27814. * 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.
  27815. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27816. * Test :
  27817. * Is the cullable object bounding sphere center in the frustum ?
  27818. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27819. */
  27820. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27821. /**
  27822. * No billboard
  27823. */
  27824. static get BILLBOARDMODE_NONE(): number;
  27825. /** Billboard on X axis */
  27826. static get BILLBOARDMODE_X(): number;
  27827. /** Billboard on Y axis */
  27828. static get BILLBOARDMODE_Y(): number;
  27829. /** Billboard on Z axis */
  27830. static get BILLBOARDMODE_Z(): number;
  27831. /** Billboard on all axes */
  27832. static get BILLBOARDMODE_ALL(): number;
  27833. /** Billboard on using position instead of orientation */
  27834. static get BILLBOARDMODE_USE_POSITION(): number;
  27835. /** @hidden */
  27836. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27837. /**
  27838. * The culling strategy to use to check whether the mesh must be rendered or not.
  27839. * This value can be changed at any time and will be used on the next render mesh selection.
  27840. * The possible values are :
  27841. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27842. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27843. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27844. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27845. * Please read each static variable documentation to get details about the culling process.
  27846. * */
  27847. cullingStrategy: number;
  27848. /**
  27849. * Gets the number of facets in the mesh
  27850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27851. */
  27852. get facetNb(): number;
  27853. /**
  27854. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27856. */
  27857. get partitioningSubdivisions(): number;
  27858. set partitioningSubdivisions(nb: number);
  27859. /**
  27860. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27861. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27863. */
  27864. get partitioningBBoxRatio(): number;
  27865. set partitioningBBoxRatio(ratio: number);
  27866. /**
  27867. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27868. * Works only for updatable meshes.
  27869. * Doesn't work with multi-materials
  27870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27871. */
  27872. get mustDepthSortFacets(): boolean;
  27873. set mustDepthSortFacets(sort: boolean);
  27874. /**
  27875. * The location (Vector3) where the facet depth sort must be computed from.
  27876. * By default, the active camera position.
  27877. * Used only when facet depth sort is enabled
  27878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27879. */
  27880. get facetDepthSortFrom(): Vector3;
  27881. set facetDepthSortFrom(location: Vector3);
  27882. /**
  27883. * gets a boolean indicating if facetData is enabled
  27884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27885. */
  27886. get isFacetDataEnabled(): boolean;
  27887. /** @hidden */
  27888. _updateNonUniformScalingState(value: boolean): boolean;
  27889. /**
  27890. * An event triggered when this mesh collides with another one
  27891. */
  27892. onCollideObservable: Observable<AbstractMesh>;
  27893. /** Set a function to call when this mesh collides with another one */
  27894. set onCollide(callback: () => void);
  27895. /**
  27896. * An event triggered when the collision's position changes
  27897. */
  27898. onCollisionPositionChangeObservable: Observable<Vector3>;
  27899. /** Set a function to call when the collision's position changes */
  27900. set onCollisionPositionChange(callback: () => void);
  27901. /**
  27902. * An event triggered when material is changed
  27903. */
  27904. onMaterialChangedObservable: Observable<AbstractMesh>;
  27905. /**
  27906. * Gets or sets the orientation for POV movement & rotation
  27907. */
  27908. definedFacingForward: boolean;
  27909. /** @hidden */
  27910. _occlusionQuery: Nullable<WebGLQuery>;
  27911. /** @hidden */
  27912. _renderingGroup: Nullable<RenderingGroup>;
  27913. /**
  27914. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27915. */
  27916. get visibility(): number;
  27917. /**
  27918. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27919. */
  27920. set visibility(value: number);
  27921. /** Gets or sets the alpha index used to sort transparent meshes
  27922. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27923. */
  27924. alphaIndex: number;
  27925. /**
  27926. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27927. */
  27928. isVisible: boolean;
  27929. /**
  27930. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27931. */
  27932. isPickable: boolean;
  27933. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27934. showSubMeshesBoundingBox: boolean;
  27935. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27936. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27937. */
  27938. isBlocker: boolean;
  27939. /**
  27940. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27941. */
  27942. enablePointerMoveEvents: boolean;
  27943. /**
  27944. * Specifies the rendering group id for this mesh (0 by default)
  27945. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27946. */
  27947. renderingGroupId: number;
  27948. private _material;
  27949. /** Gets or sets current material */
  27950. get material(): Nullable<Material>;
  27951. set material(value: Nullable<Material>);
  27952. /**
  27953. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27954. * @see http://doc.babylonjs.com/babylon101/shadows
  27955. */
  27956. get receiveShadows(): boolean;
  27957. set receiveShadows(value: boolean);
  27958. /** Defines color to use when rendering outline */
  27959. outlineColor: Color3;
  27960. /** Define width to use when rendering outline */
  27961. outlineWidth: number;
  27962. /** Defines color to use when rendering overlay */
  27963. overlayColor: Color3;
  27964. /** Defines alpha to use when rendering overlay */
  27965. overlayAlpha: number;
  27966. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27967. get hasVertexAlpha(): boolean;
  27968. set hasVertexAlpha(value: boolean);
  27969. /** 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) */
  27970. get useVertexColors(): boolean;
  27971. set useVertexColors(value: boolean);
  27972. /**
  27973. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27974. */
  27975. get computeBonesUsingShaders(): boolean;
  27976. set computeBonesUsingShaders(value: boolean);
  27977. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27978. get numBoneInfluencers(): number;
  27979. set numBoneInfluencers(value: number);
  27980. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27981. get applyFog(): boolean;
  27982. set applyFog(value: boolean);
  27983. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27984. useOctreeForRenderingSelection: boolean;
  27985. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27986. useOctreeForPicking: boolean;
  27987. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27988. useOctreeForCollisions: boolean;
  27989. /**
  27990. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27991. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27992. */
  27993. get layerMask(): number;
  27994. set layerMask(value: number);
  27995. /**
  27996. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27997. */
  27998. alwaysSelectAsActiveMesh: boolean;
  27999. /**
  28000. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28001. */
  28002. doNotSyncBoundingInfo: boolean;
  28003. /**
  28004. * Gets or sets the current action manager
  28005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28006. */
  28007. actionManager: Nullable<AbstractActionManager>;
  28008. private _meshCollisionData;
  28009. /**
  28010. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28011. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28012. */
  28013. ellipsoid: Vector3;
  28014. /**
  28015. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28017. */
  28018. ellipsoidOffset: Vector3;
  28019. /**
  28020. * Gets or sets a collision mask used to mask collisions (default is -1).
  28021. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28022. */
  28023. get collisionMask(): number;
  28024. set collisionMask(mask: number);
  28025. /**
  28026. * Gets or sets the current collision group mask (-1 by default).
  28027. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28028. */
  28029. get collisionGroup(): number;
  28030. set collisionGroup(mask: number);
  28031. /**
  28032. * Defines edge width used when edgesRenderer is enabled
  28033. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28034. */
  28035. edgesWidth: number;
  28036. /**
  28037. * Defines edge color used when edgesRenderer is enabled
  28038. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28039. */
  28040. edgesColor: Color4;
  28041. /** @hidden */
  28042. _edgesRenderer: Nullable<IEdgesRenderer>;
  28043. /** @hidden */
  28044. _masterMesh: Nullable<AbstractMesh>;
  28045. /** @hidden */
  28046. _boundingInfo: Nullable<BoundingInfo>;
  28047. /** @hidden */
  28048. _renderId: number;
  28049. /**
  28050. * Gets or sets the list of subMeshes
  28051. * @see http://doc.babylonjs.com/how_to/multi_materials
  28052. */
  28053. subMeshes: SubMesh[];
  28054. /** @hidden */
  28055. _intersectionsInProgress: AbstractMesh[];
  28056. /** @hidden */
  28057. _unIndexed: boolean;
  28058. /** @hidden */
  28059. _lightSources: Light[];
  28060. /** Gets the list of lights affecting that mesh */
  28061. get lightSources(): Light[];
  28062. /** @hidden */
  28063. get _positions(): Nullable<Vector3[]>;
  28064. /** @hidden */
  28065. _waitingData: {
  28066. lods: Nullable<any>;
  28067. actions: Nullable<any>;
  28068. freezeWorldMatrix: Nullable<boolean>;
  28069. };
  28070. /** @hidden */
  28071. _bonesTransformMatrices: Nullable<Float32Array>;
  28072. /** @hidden */
  28073. _transformMatrixTexture: Nullable<RawTexture>;
  28074. /**
  28075. * Gets or sets a skeleton to apply skining transformations
  28076. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28077. */
  28078. set skeleton(value: Nullable<Skeleton>);
  28079. get skeleton(): Nullable<Skeleton>;
  28080. /**
  28081. * An event triggered when the mesh is rebuilt.
  28082. */
  28083. onRebuildObservable: Observable<AbstractMesh>;
  28084. /**
  28085. * Creates a new AbstractMesh
  28086. * @param name defines the name of the mesh
  28087. * @param scene defines the hosting scene
  28088. */
  28089. constructor(name: string, scene?: Nullable<Scene>);
  28090. /**
  28091. * Returns the string "AbstractMesh"
  28092. * @returns "AbstractMesh"
  28093. */
  28094. getClassName(): string;
  28095. /**
  28096. * Gets a string representation of the current mesh
  28097. * @param fullDetails defines a boolean indicating if full details must be included
  28098. * @returns a string representation of the current mesh
  28099. */
  28100. toString(fullDetails?: boolean): string;
  28101. /**
  28102. * @hidden
  28103. */
  28104. protected _getEffectiveParent(): Nullable<Node>;
  28105. /** @hidden */
  28106. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28107. /** @hidden */
  28108. _rebuild(): void;
  28109. /** @hidden */
  28110. _resyncLightSources(): void;
  28111. /** @hidden */
  28112. _resyncLightSource(light: Light): void;
  28113. /** @hidden */
  28114. _unBindEffect(): void;
  28115. /** @hidden */
  28116. _removeLightSource(light: Light, dispose: boolean): void;
  28117. private _markSubMeshesAsDirty;
  28118. /** @hidden */
  28119. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28120. /** @hidden */
  28121. _markSubMeshesAsAttributesDirty(): void;
  28122. /** @hidden */
  28123. _markSubMeshesAsMiscDirty(): void;
  28124. /**
  28125. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28126. */
  28127. get scaling(): Vector3;
  28128. set scaling(newScaling: Vector3);
  28129. /**
  28130. * Returns true if the mesh is blocked. Implemented by child classes
  28131. */
  28132. get isBlocked(): boolean;
  28133. /**
  28134. * Returns the mesh itself by default. Implemented by child classes
  28135. * @param camera defines the camera to use to pick the right LOD level
  28136. * @returns the currentAbstractMesh
  28137. */
  28138. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28139. /**
  28140. * Returns 0 by default. Implemented by child classes
  28141. * @returns an integer
  28142. */
  28143. getTotalVertices(): number;
  28144. /**
  28145. * Returns a positive integer : the total number of indices in this mesh geometry.
  28146. * @returns the numner of indices or zero if the mesh has no geometry.
  28147. */
  28148. getTotalIndices(): number;
  28149. /**
  28150. * Returns null by default. Implemented by child classes
  28151. * @returns null
  28152. */
  28153. getIndices(): Nullable<IndicesArray>;
  28154. /**
  28155. * Returns the array of the requested vertex data kind. Implemented by child classes
  28156. * @param kind defines the vertex data kind to use
  28157. * @returns null
  28158. */
  28159. getVerticesData(kind: string): Nullable<FloatArray>;
  28160. /**
  28161. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28162. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28163. * Note that a new underlying VertexBuffer object is created each call.
  28164. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28165. * @param kind defines vertex data kind:
  28166. * * VertexBuffer.PositionKind
  28167. * * VertexBuffer.UVKind
  28168. * * VertexBuffer.UV2Kind
  28169. * * VertexBuffer.UV3Kind
  28170. * * VertexBuffer.UV4Kind
  28171. * * VertexBuffer.UV5Kind
  28172. * * VertexBuffer.UV6Kind
  28173. * * VertexBuffer.ColorKind
  28174. * * VertexBuffer.MatricesIndicesKind
  28175. * * VertexBuffer.MatricesIndicesExtraKind
  28176. * * VertexBuffer.MatricesWeightsKind
  28177. * * VertexBuffer.MatricesWeightsExtraKind
  28178. * @param data defines the data source
  28179. * @param updatable defines if the data must be flagged as updatable (or static)
  28180. * @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
  28181. * @returns the current mesh
  28182. */
  28183. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28184. /**
  28185. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28186. * If the mesh has no geometry, it is simply returned as it is.
  28187. * @param kind defines vertex data kind:
  28188. * * VertexBuffer.PositionKind
  28189. * * VertexBuffer.UVKind
  28190. * * VertexBuffer.UV2Kind
  28191. * * VertexBuffer.UV3Kind
  28192. * * VertexBuffer.UV4Kind
  28193. * * VertexBuffer.UV5Kind
  28194. * * VertexBuffer.UV6Kind
  28195. * * VertexBuffer.ColorKind
  28196. * * VertexBuffer.MatricesIndicesKind
  28197. * * VertexBuffer.MatricesIndicesExtraKind
  28198. * * VertexBuffer.MatricesWeightsKind
  28199. * * VertexBuffer.MatricesWeightsExtraKind
  28200. * @param data defines the data source
  28201. * @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
  28202. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28203. * @returns the current mesh
  28204. */
  28205. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28206. /**
  28207. * Sets the mesh indices,
  28208. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28209. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28210. * @param totalVertices Defines the total number of vertices
  28211. * @returns the current mesh
  28212. */
  28213. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28214. /**
  28215. * Gets a boolean indicating if specific vertex data is present
  28216. * @param kind defines the vertex data kind to use
  28217. * @returns true is data kind is present
  28218. */
  28219. isVerticesDataPresent(kind: string): boolean;
  28220. /**
  28221. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28222. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28223. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28224. * @returns a BoundingInfo
  28225. */
  28226. getBoundingInfo(): BoundingInfo;
  28227. /**
  28228. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28229. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28230. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28231. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28232. * @returns the current mesh
  28233. */
  28234. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28235. /**
  28236. * Overwrite the current bounding info
  28237. * @param boundingInfo defines the new bounding info
  28238. * @returns the current mesh
  28239. */
  28240. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28241. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28242. get useBones(): boolean;
  28243. /** @hidden */
  28244. _preActivate(): void;
  28245. /** @hidden */
  28246. _preActivateForIntermediateRendering(renderId: number): void;
  28247. /** @hidden */
  28248. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28249. /** @hidden */
  28250. _postActivate(): void;
  28251. /** @hidden */
  28252. _freeze(): void;
  28253. /** @hidden */
  28254. _unFreeze(): void;
  28255. /**
  28256. * Gets the current world matrix
  28257. * @returns a Matrix
  28258. */
  28259. getWorldMatrix(): Matrix;
  28260. /** @hidden */
  28261. _getWorldMatrixDeterminant(): number;
  28262. /**
  28263. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28264. */
  28265. get isAnInstance(): boolean;
  28266. /**
  28267. * Gets a boolean indicating if this mesh has instances
  28268. */
  28269. get hasInstances(): boolean;
  28270. /**
  28271. * Perform relative position change from the point of view of behind the front of the mesh.
  28272. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28273. * Supports definition of mesh facing forward or backward
  28274. * @param amountRight defines the distance on the right axis
  28275. * @param amountUp defines the distance on the up axis
  28276. * @param amountForward defines the distance on the forward axis
  28277. * @returns the current mesh
  28278. */
  28279. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28280. /**
  28281. * Calculate relative position change from the point of view of behind the front of the mesh.
  28282. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28283. * Supports definition of mesh facing forward or backward
  28284. * @param amountRight defines the distance on the right axis
  28285. * @param amountUp defines the distance on the up axis
  28286. * @param amountForward defines the distance on the forward axis
  28287. * @returns the new displacement vector
  28288. */
  28289. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28290. /**
  28291. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28292. * Supports definition of mesh facing forward or backward
  28293. * @param flipBack defines the flip
  28294. * @param twirlClockwise defines the twirl
  28295. * @param tiltRight defines the tilt
  28296. * @returns the current mesh
  28297. */
  28298. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28299. /**
  28300. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28301. * Supports definition of mesh facing forward or backward.
  28302. * @param flipBack defines the flip
  28303. * @param twirlClockwise defines the twirl
  28304. * @param tiltRight defines the tilt
  28305. * @returns the new rotation vector
  28306. */
  28307. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28308. /**
  28309. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28310. * This means the mesh underlying bounding box and sphere are recomputed.
  28311. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28312. * @returns the current mesh
  28313. */
  28314. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28315. /** @hidden */
  28316. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28317. /** @hidden */
  28318. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28319. /** @hidden */
  28320. _updateBoundingInfo(): AbstractMesh;
  28321. /** @hidden */
  28322. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28323. /** @hidden */
  28324. protected _afterComputeWorldMatrix(): void;
  28325. /** @hidden */
  28326. get _effectiveMesh(): AbstractMesh;
  28327. /**
  28328. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28329. * A mesh is in the frustum if its bounding box intersects the frustum
  28330. * @param frustumPlanes defines the frustum to test
  28331. * @returns true if the mesh is in the frustum planes
  28332. */
  28333. isInFrustum(frustumPlanes: Plane[]): boolean;
  28334. /**
  28335. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28336. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28337. * @param frustumPlanes defines the frustum to test
  28338. * @returns true if the mesh is completely in the frustum planes
  28339. */
  28340. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28341. /**
  28342. * True if the mesh intersects another mesh or a SolidParticle object
  28343. * @param mesh defines a target mesh or SolidParticle to test
  28344. * @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)
  28345. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28346. * @returns true if there is an intersection
  28347. */
  28348. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28349. /**
  28350. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28351. * @param point defines the point to test
  28352. * @returns true if there is an intersection
  28353. */
  28354. intersectsPoint(point: Vector3): boolean;
  28355. /**
  28356. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28357. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28358. */
  28359. get checkCollisions(): boolean;
  28360. set checkCollisions(collisionEnabled: boolean);
  28361. /**
  28362. * Gets Collider object used to compute collisions (not physics)
  28363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28364. */
  28365. get collider(): Nullable<Collider>;
  28366. /**
  28367. * Move the mesh using collision engine
  28368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28369. * @param displacement defines the requested displacement vector
  28370. * @returns the current mesh
  28371. */
  28372. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28373. private _onCollisionPositionChange;
  28374. /** @hidden */
  28375. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28376. /** @hidden */
  28377. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28378. /** @hidden */
  28379. _checkCollision(collider: Collider): AbstractMesh;
  28380. /** @hidden */
  28381. _generatePointsArray(): boolean;
  28382. /**
  28383. * Checks if the passed Ray intersects with the mesh
  28384. * @param ray defines the ray to use
  28385. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28386. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28387. * @returns the picking info
  28388. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28389. */
  28390. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28391. /**
  28392. * Clones the current mesh
  28393. * @param name defines the mesh name
  28394. * @param newParent defines the new mesh parent
  28395. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28396. * @returns the new mesh
  28397. */
  28398. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28399. /**
  28400. * Disposes all the submeshes of the current meshnp
  28401. * @returns the current mesh
  28402. */
  28403. releaseSubMeshes(): AbstractMesh;
  28404. /**
  28405. * Releases resources associated with this abstract mesh.
  28406. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28407. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28408. */
  28409. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28410. /**
  28411. * Adds the passed mesh as a child to the current mesh
  28412. * @param mesh defines the child mesh
  28413. * @returns the current mesh
  28414. */
  28415. addChild(mesh: AbstractMesh): AbstractMesh;
  28416. /**
  28417. * Removes the passed mesh from the current mesh children list
  28418. * @param mesh defines the child mesh
  28419. * @returns the current mesh
  28420. */
  28421. removeChild(mesh: AbstractMesh): AbstractMesh;
  28422. /** @hidden */
  28423. private _initFacetData;
  28424. /**
  28425. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28426. * This method can be called within the render loop.
  28427. * 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
  28428. * @returns the current mesh
  28429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28430. */
  28431. updateFacetData(): AbstractMesh;
  28432. /**
  28433. * Returns the facetLocalNormals array.
  28434. * The normals are expressed in the mesh local spac
  28435. * @returns an array of Vector3
  28436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28437. */
  28438. getFacetLocalNormals(): Vector3[];
  28439. /**
  28440. * Returns the facetLocalPositions array.
  28441. * The facet positions are expressed in the mesh local space
  28442. * @returns an array of Vector3
  28443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28444. */
  28445. getFacetLocalPositions(): Vector3[];
  28446. /**
  28447. * Returns the facetLocalPartioning array
  28448. * @returns an array of array of numbers
  28449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28450. */
  28451. getFacetLocalPartitioning(): number[][];
  28452. /**
  28453. * Returns the i-th facet position in the world system.
  28454. * This method allocates a new Vector3 per call
  28455. * @param i defines the facet index
  28456. * @returns a new Vector3
  28457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28458. */
  28459. getFacetPosition(i: number): Vector3;
  28460. /**
  28461. * Sets the reference Vector3 with the i-th facet position in the world system
  28462. * @param i defines the facet index
  28463. * @param ref defines the target vector
  28464. * @returns the current mesh
  28465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28466. */
  28467. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28468. /**
  28469. * Returns the i-th facet normal in the world system.
  28470. * This method allocates a new Vector3 per call
  28471. * @param i defines the facet index
  28472. * @returns a new Vector3
  28473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28474. */
  28475. getFacetNormal(i: number): Vector3;
  28476. /**
  28477. * Sets the reference Vector3 with the i-th facet normal in the world system
  28478. * @param i defines the facet index
  28479. * @param ref defines the target vector
  28480. * @returns the current mesh
  28481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28482. */
  28483. getFacetNormalToRef(i: number, ref: Vector3): this;
  28484. /**
  28485. * 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)
  28486. * @param x defines x coordinate
  28487. * @param y defines y coordinate
  28488. * @param z defines z coordinate
  28489. * @returns the array of facet indexes
  28490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28491. */
  28492. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28493. /**
  28494. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28495. * @param projected sets as the (x,y,z) world projection on the facet
  28496. * @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
  28497. * @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
  28498. * @param x defines x coordinate
  28499. * @param y defines y coordinate
  28500. * @param z defines z coordinate
  28501. * @returns the face index if found (or null instead)
  28502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28503. */
  28504. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28505. /**
  28506. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28507. * @param projected sets as the (x,y,z) local projection on the facet
  28508. * @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
  28509. * @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
  28510. * @param x defines x coordinate
  28511. * @param y defines y coordinate
  28512. * @param z defines z coordinate
  28513. * @returns the face index if found (or null instead)
  28514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28515. */
  28516. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28517. /**
  28518. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28519. * @returns the parameters
  28520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28521. */
  28522. getFacetDataParameters(): any;
  28523. /**
  28524. * Disables the feature FacetData and frees the related memory
  28525. * @returns the current mesh
  28526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28527. */
  28528. disableFacetData(): AbstractMesh;
  28529. /**
  28530. * Updates the AbstractMesh indices array
  28531. * @param indices defines the data source
  28532. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28533. * @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)
  28534. * @returns the current mesh
  28535. */
  28536. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28537. /**
  28538. * Creates new normals data for the mesh
  28539. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28540. * @returns the current mesh
  28541. */
  28542. createNormals(updatable: boolean): AbstractMesh;
  28543. /**
  28544. * Align the mesh with a normal
  28545. * @param normal defines the normal to use
  28546. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28547. * @returns the current mesh
  28548. */
  28549. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28550. /** @hidden */
  28551. _checkOcclusionQuery(): boolean;
  28552. /**
  28553. * Disables the mesh edge rendering mode
  28554. * @returns the currentAbstractMesh
  28555. */
  28556. disableEdgesRendering(): AbstractMesh;
  28557. /**
  28558. * Enables the edge rendering mode on the mesh.
  28559. * This mode makes the mesh edges visible
  28560. * @param epsilon defines the maximal distance between two angles to detect a face
  28561. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28562. * @returns the currentAbstractMesh
  28563. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28564. */
  28565. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28566. }
  28567. }
  28568. declare module BABYLON {
  28569. /**
  28570. * Interface used to define ActionEvent
  28571. */
  28572. export interface IActionEvent {
  28573. /** The mesh or sprite that triggered the action */
  28574. source: any;
  28575. /** The X mouse cursor position at the time of the event */
  28576. pointerX: number;
  28577. /** The Y mouse cursor position at the time of the event */
  28578. pointerY: number;
  28579. /** The mesh that is currently pointed at (can be null) */
  28580. meshUnderPointer: Nullable<AbstractMesh>;
  28581. /** the original (browser) event that triggered the ActionEvent */
  28582. sourceEvent?: any;
  28583. /** additional data for the event */
  28584. additionalData?: any;
  28585. }
  28586. /**
  28587. * ActionEvent is the event being sent when an action is triggered.
  28588. */
  28589. export class ActionEvent implements IActionEvent {
  28590. /** The mesh or sprite that triggered the action */
  28591. source: any;
  28592. /** The X mouse cursor position at the time of the event */
  28593. pointerX: number;
  28594. /** The Y mouse cursor position at the time of the event */
  28595. pointerY: number;
  28596. /** The mesh that is currently pointed at (can be null) */
  28597. meshUnderPointer: Nullable<AbstractMesh>;
  28598. /** the original (browser) event that triggered the ActionEvent */
  28599. sourceEvent?: any;
  28600. /** additional data for the event */
  28601. additionalData?: any;
  28602. /**
  28603. * Creates a new ActionEvent
  28604. * @param source The mesh or sprite that triggered the action
  28605. * @param pointerX The X mouse cursor position at the time of the event
  28606. * @param pointerY The Y mouse cursor position at the time of the event
  28607. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28608. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28609. * @param additionalData additional data for the event
  28610. */
  28611. constructor(
  28612. /** The mesh or sprite that triggered the action */
  28613. source: any,
  28614. /** The X mouse cursor position at the time of the event */
  28615. pointerX: number,
  28616. /** The Y mouse cursor position at the time of the event */
  28617. pointerY: number,
  28618. /** The mesh that is currently pointed at (can be null) */
  28619. meshUnderPointer: Nullable<AbstractMesh>,
  28620. /** the original (browser) event that triggered the ActionEvent */
  28621. sourceEvent?: any,
  28622. /** additional data for the event */
  28623. additionalData?: any);
  28624. /**
  28625. * Helper function to auto-create an ActionEvent from a source mesh.
  28626. * @param source The source mesh that triggered the event
  28627. * @param evt The original (browser) event
  28628. * @param additionalData additional data for the event
  28629. * @returns the new ActionEvent
  28630. */
  28631. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28632. /**
  28633. * Helper function to auto-create an ActionEvent from a source sprite
  28634. * @param source The source sprite that triggered the event
  28635. * @param scene Scene associated with the sprite
  28636. * @param evt The original (browser) event
  28637. * @param additionalData additional data for the event
  28638. * @returns the new ActionEvent
  28639. */
  28640. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28641. /**
  28642. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28643. * @param scene the scene where the event occurred
  28644. * @param evt The original (browser) event
  28645. * @returns the new ActionEvent
  28646. */
  28647. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28648. /**
  28649. * Helper function to auto-create an ActionEvent from a primitive
  28650. * @param prim defines the target primitive
  28651. * @param pointerPos defines the pointer position
  28652. * @param evt The original (browser) event
  28653. * @param additionalData additional data for the event
  28654. * @returns the new ActionEvent
  28655. */
  28656. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28657. }
  28658. }
  28659. declare module BABYLON {
  28660. /**
  28661. * Abstract class used to decouple action Manager from scene and meshes.
  28662. * Do not instantiate.
  28663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28664. */
  28665. export abstract class AbstractActionManager implements IDisposable {
  28666. /** Gets the list of active triggers */
  28667. static Triggers: {
  28668. [key: string]: number;
  28669. };
  28670. /** Gets the cursor to use when hovering items */
  28671. hoverCursor: string;
  28672. /** Gets the list of actions */
  28673. actions: IAction[];
  28674. /**
  28675. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28676. */
  28677. isRecursive: boolean;
  28678. /**
  28679. * Releases all associated resources
  28680. */
  28681. abstract dispose(): void;
  28682. /**
  28683. * Does this action manager has pointer triggers
  28684. */
  28685. abstract get hasPointerTriggers(): boolean;
  28686. /**
  28687. * Does this action manager has pick triggers
  28688. */
  28689. abstract get hasPickTriggers(): boolean;
  28690. /**
  28691. * Process a specific trigger
  28692. * @param trigger defines the trigger to process
  28693. * @param evt defines the event details to be processed
  28694. */
  28695. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28696. /**
  28697. * Does this action manager handles actions of any of the given triggers
  28698. * @param triggers defines the triggers to be tested
  28699. * @return a boolean indicating whether one (or more) of the triggers is handled
  28700. */
  28701. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28702. /**
  28703. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28704. * speed.
  28705. * @param triggerA defines the trigger to be tested
  28706. * @param triggerB defines the trigger to be tested
  28707. * @return a boolean indicating whether one (or more) of the triggers is handled
  28708. */
  28709. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28710. /**
  28711. * Does this action manager handles actions of a given trigger
  28712. * @param trigger defines the trigger to be tested
  28713. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28714. * @return whether the trigger is handled
  28715. */
  28716. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28717. /**
  28718. * Serialize this manager to a JSON object
  28719. * @param name defines the property name to store this manager
  28720. * @returns a JSON representation of this manager
  28721. */
  28722. abstract serialize(name: string): any;
  28723. /**
  28724. * Registers an action to this action manager
  28725. * @param action defines the action to be registered
  28726. * @return the action amended (prepared) after registration
  28727. */
  28728. abstract registerAction(action: IAction): Nullable<IAction>;
  28729. /**
  28730. * Unregisters an action to this action manager
  28731. * @param action defines the action to be unregistered
  28732. * @return a boolean indicating whether the action has been unregistered
  28733. */
  28734. abstract unregisterAction(action: IAction): Boolean;
  28735. /**
  28736. * Does exist one action manager with at least one trigger
  28737. **/
  28738. static get HasTriggers(): boolean;
  28739. /**
  28740. * Does exist one action manager with at least one pick trigger
  28741. **/
  28742. static get HasPickTriggers(): boolean;
  28743. /**
  28744. * Does exist one action manager that handles actions of a given trigger
  28745. * @param trigger defines the trigger to be tested
  28746. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28747. **/
  28748. static HasSpecificTrigger(trigger: number): boolean;
  28749. }
  28750. }
  28751. declare module BABYLON {
  28752. /**
  28753. * Defines how a node can be built from a string name.
  28754. */
  28755. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28756. /**
  28757. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28758. */
  28759. export class Node implements IBehaviorAware<Node> {
  28760. /** @hidden */
  28761. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28762. private static _NodeConstructors;
  28763. /**
  28764. * Add a new node constructor
  28765. * @param type defines the type name of the node to construct
  28766. * @param constructorFunc defines the constructor function
  28767. */
  28768. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28769. /**
  28770. * Returns a node constructor based on type name
  28771. * @param type defines the type name
  28772. * @param name defines the new node name
  28773. * @param scene defines the hosting scene
  28774. * @param options defines optional options to transmit to constructors
  28775. * @returns the new constructor or null
  28776. */
  28777. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28778. /**
  28779. * Gets or sets the name of the node
  28780. */
  28781. name: string;
  28782. /**
  28783. * Gets or sets the id of the node
  28784. */
  28785. id: string;
  28786. /**
  28787. * Gets or sets the unique id of the node
  28788. */
  28789. uniqueId: number;
  28790. /**
  28791. * Gets or sets a string used to store user defined state for the node
  28792. */
  28793. state: string;
  28794. /**
  28795. * Gets or sets an object used to store user defined information for the node
  28796. */
  28797. metadata: any;
  28798. /**
  28799. * For internal use only. Please do not use.
  28800. */
  28801. reservedDataStore: any;
  28802. /**
  28803. * List of inspectable custom properties (used by the Inspector)
  28804. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28805. */
  28806. inspectableCustomProperties: IInspectable[];
  28807. private _doNotSerialize;
  28808. /**
  28809. * Gets or sets a boolean used to define if the node must be serialized
  28810. */
  28811. get doNotSerialize(): boolean;
  28812. set doNotSerialize(value: boolean);
  28813. /** @hidden */
  28814. _isDisposed: boolean;
  28815. /**
  28816. * Gets a list of Animations associated with the node
  28817. */
  28818. animations: Animation[];
  28819. protected _ranges: {
  28820. [name: string]: Nullable<AnimationRange>;
  28821. };
  28822. /**
  28823. * Callback raised when the node is ready to be used
  28824. */
  28825. onReady: Nullable<(node: Node) => void>;
  28826. private _isEnabled;
  28827. private _isParentEnabled;
  28828. private _isReady;
  28829. /** @hidden */
  28830. _currentRenderId: number;
  28831. private _parentUpdateId;
  28832. /** @hidden */
  28833. _childUpdateId: number;
  28834. /** @hidden */
  28835. _waitingParentId: Nullable<string>;
  28836. /** @hidden */
  28837. _scene: Scene;
  28838. /** @hidden */
  28839. _cache: any;
  28840. private _parentNode;
  28841. private _children;
  28842. /** @hidden */
  28843. _worldMatrix: Matrix;
  28844. /** @hidden */
  28845. _worldMatrixDeterminant: number;
  28846. /** @hidden */
  28847. _worldMatrixDeterminantIsDirty: boolean;
  28848. /** @hidden */
  28849. private _sceneRootNodesIndex;
  28850. /**
  28851. * Gets a boolean indicating if the node has been disposed
  28852. * @returns true if the node was disposed
  28853. */
  28854. isDisposed(): boolean;
  28855. /**
  28856. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28857. * @see https://doc.babylonjs.com/how_to/parenting
  28858. */
  28859. set parent(parent: Nullable<Node>);
  28860. get parent(): Nullable<Node>;
  28861. /** @hidden */
  28862. _addToSceneRootNodes(): void;
  28863. /** @hidden */
  28864. _removeFromSceneRootNodes(): void;
  28865. private _animationPropertiesOverride;
  28866. /**
  28867. * Gets or sets the animation properties override
  28868. */
  28869. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28870. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28871. /**
  28872. * Gets a string idenfifying the name of the class
  28873. * @returns "Node" string
  28874. */
  28875. getClassName(): string;
  28876. /** @hidden */
  28877. readonly _isNode: boolean;
  28878. /**
  28879. * An event triggered when the mesh is disposed
  28880. */
  28881. onDisposeObservable: Observable<Node>;
  28882. private _onDisposeObserver;
  28883. /**
  28884. * Sets a callback that will be raised when the node will be disposed
  28885. */
  28886. set onDispose(callback: () => void);
  28887. /**
  28888. * Creates a new Node
  28889. * @param name the name and id to be given to this node
  28890. * @param scene the scene this node will be added to
  28891. */
  28892. constructor(name: string, scene?: Nullable<Scene>);
  28893. /**
  28894. * Gets the scene of the node
  28895. * @returns a scene
  28896. */
  28897. getScene(): Scene;
  28898. /**
  28899. * Gets the engine of the node
  28900. * @returns a Engine
  28901. */
  28902. getEngine(): Engine;
  28903. private _behaviors;
  28904. /**
  28905. * Attach a behavior to the node
  28906. * @see http://doc.babylonjs.com/features/behaviour
  28907. * @param behavior defines the behavior to attach
  28908. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28909. * @returns the current Node
  28910. */
  28911. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28912. /**
  28913. * Remove an attached behavior
  28914. * @see http://doc.babylonjs.com/features/behaviour
  28915. * @param behavior defines the behavior to attach
  28916. * @returns the current Node
  28917. */
  28918. removeBehavior(behavior: Behavior<Node>): Node;
  28919. /**
  28920. * Gets the list of attached behaviors
  28921. * @see http://doc.babylonjs.com/features/behaviour
  28922. */
  28923. get behaviors(): Behavior<Node>[];
  28924. /**
  28925. * Gets an attached behavior by name
  28926. * @param name defines the name of the behavior to look for
  28927. * @see http://doc.babylonjs.com/features/behaviour
  28928. * @returns null if behavior was not found else the requested behavior
  28929. */
  28930. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28931. /**
  28932. * Returns the latest update of the World matrix
  28933. * @returns a Matrix
  28934. */
  28935. getWorldMatrix(): Matrix;
  28936. /** @hidden */
  28937. _getWorldMatrixDeterminant(): number;
  28938. /**
  28939. * Returns directly the latest state of the mesh World matrix.
  28940. * A Matrix is returned.
  28941. */
  28942. get worldMatrixFromCache(): Matrix;
  28943. /** @hidden */
  28944. _initCache(): void;
  28945. /** @hidden */
  28946. updateCache(force?: boolean): void;
  28947. /** @hidden */
  28948. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28949. /** @hidden */
  28950. _updateCache(ignoreParentClass?: boolean): void;
  28951. /** @hidden */
  28952. _isSynchronized(): boolean;
  28953. /** @hidden */
  28954. _markSyncedWithParent(): void;
  28955. /** @hidden */
  28956. isSynchronizedWithParent(): boolean;
  28957. /** @hidden */
  28958. isSynchronized(): boolean;
  28959. /**
  28960. * Is this node ready to be used/rendered
  28961. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28962. * @return true if the node is ready
  28963. */
  28964. isReady(completeCheck?: boolean): boolean;
  28965. /**
  28966. * Is this node enabled?
  28967. * 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
  28968. * @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
  28969. * @return whether this node (and its parent) is enabled
  28970. */
  28971. isEnabled(checkAncestors?: boolean): boolean;
  28972. /** @hidden */
  28973. protected _syncParentEnabledState(): void;
  28974. /**
  28975. * Set the enabled state of this node
  28976. * @param value defines the new enabled state
  28977. */
  28978. setEnabled(value: boolean): void;
  28979. /**
  28980. * Is this node a descendant of the given node?
  28981. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28982. * @param ancestor defines the parent node to inspect
  28983. * @returns a boolean indicating if this node is a descendant of the given node
  28984. */
  28985. isDescendantOf(ancestor: Node): boolean;
  28986. /** @hidden */
  28987. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28988. /**
  28989. * Will return all nodes that have this node as ascendant
  28990. * @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
  28991. * @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
  28992. * @return all children nodes of all types
  28993. */
  28994. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28995. /**
  28996. * Get all child-meshes of this node
  28997. * @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)
  28998. * @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
  28999. * @returns an array of AbstractMesh
  29000. */
  29001. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29002. /**
  29003. * Get all direct children of this node
  29004. * @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
  29005. * @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)
  29006. * @returns an array of Node
  29007. */
  29008. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29009. /** @hidden */
  29010. _setReady(state: boolean): void;
  29011. /**
  29012. * Get an animation by name
  29013. * @param name defines the name of the animation to look for
  29014. * @returns null if not found else the requested animation
  29015. */
  29016. getAnimationByName(name: string): Nullable<Animation>;
  29017. /**
  29018. * Creates an animation range for this node
  29019. * @param name defines the name of the range
  29020. * @param from defines the starting key
  29021. * @param to defines the end key
  29022. */
  29023. createAnimationRange(name: string, from: number, to: number): void;
  29024. /**
  29025. * Delete a specific animation range
  29026. * @param name defines the name of the range to delete
  29027. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29028. */
  29029. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29030. /**
  29031. * Get an animation range by name
  29032. * @param name defines the name of the animation range to look for
  29033. * @returns null if not found else the requested animation range
  29034. */
  29035. getAnimationRange(name: string): Nullable<AnimationRange>;
  29036. /**
  29037. * Gets the list of all animation ranges defined on this node
  29038. * @returns an array
  29039. */
  29040. getAnimationRanges(): Nullable<AnimationRange>[];
  29041. /**
  29042. * Will start the animation sequence
  29043. * @param name defines the range frames for animation sequence
  29044. * @param loop defines if the animation should loop (false by default)
  29045. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29046. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29047. * @returns the object created for this animation. If range does not exist, it will return null
  29048. */
  29049. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29050. /**
  29051. * Serialize animation ranges into a JSON compatible object
  29052. * @returns serialization object
  29053. */
  29054. serializeAnimationRanges(): any;
  29055. /**
  29056. * Computes the world matrix of the node
  29057. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29058. * @returns the world matrix
  29059. */
  29060. computeWorldMatrix(force?: boolean): Matrix;
  29061. /**
  29062. * Releases resources associated with this node.
  29063. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29064. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29065. */
  29066. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29067. /**
  29068. * Parse animation range data from a serialization object and store them into a given node
  29069. * @param node defines where to store the animation ranges
  29070. * @param parsedNode defines the serialization object to read data from
  29071. * @param scene defines the hosting scene
  29072. */
  29073. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29074. /**
  29075. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29076. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29077. * @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
  29078. * @returns the new bounding vectors
  29079. */
  29080. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29081. min: Vector3;
  29082. max: Vector3;
  29083. };
  29084. }
  29085. }
  29086. declare module BABYLON {
  29087. /**
  29088. * @hidden
  29089. */
  29090. export class _IAnimationState {
  29091. key: number;
  29092. repeatCount: number;
  29093. workValue?: any;
  29094. loopMode?: number;
  29095. offsetValue?: any;
  29096. highLimitValue?: any;
  29097. }
  29098. /**
  29099. * Class used to store any kind of animation
  29100. */
  29101. export class Animation {
  29102. /**Name of the animation */
  29103. name: string;
  29104. /**Property to animate */
  29105. targetProperty: string;
  29106. /**The frames per second of the animation */
  29107. framePerSecond: number;
  29108. /**The data type of the animation */
  29109. dataType: number;
  29110. /**The loop mode of the animation */
  29111. loopMode?: number | undefined;
  29112. /**Specifies if blending should be enabled */
  29113. enableBlending?: boolean | undefined;
  29114. /**
  29115. * Use matrix interpolation instead of using direct key value when animating matrices
  29116. */
  29117. static AllowMatricesInterpolation: boolean;
  29118. /**
  29119. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29120. */
  29121. static AllowMatrixDecomposeForInterpolation: boolean;
  29122. /**
  29123. * Stores the key frames of the animation
  29124. */
  29125. private _keys;
  29126. /**
  29127. * Stores the easing function of the animation
  29128. */
  29129. private _easingFunction;
  29130. /**
  29131. * @hidden Internal use only
  29132. */
  29133. _runtimeAnimations: RuntimeAnimation[];
  29134. /**
  29135. * The set of event that will be linked to this animation
  29136. */
  29137. private _events;
  29138. /**
  29139. * Stores an array of target property paths
  29140. */
  29141. targetPropertyPath: string[];
  29142. /**
  29143. * Stores the blending speed of the animation
  29144. */
  29145. blendingSpeed: number;
  29146. /**
  29147. * Stores the animation ranges for the animation
  29148. */
  29149. private _ranges;
  29150. /**
  29151. * @hidden Internal use
  29152. */
  29153. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29154. /**
  29155. * Sets up an animation
  29156. * @param property The property to animate
  29157. * @param animationType The animation type to apply
  29158. * @param framePerSecond The frames per second of the animation
  29159. * @param easingFunction The easing function used in the animation
  29160. * @returns The created animation
  29161. */
  29162. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29163. /**
  29164. * Create and start an animation on a node
  29165. * @param name defines the name of the global animation that will be run on all nodes
  29166. * @param node defines the root node where the animation will take place
  29167. * @param targetProperty defines property to animate
  29168. * @param framePerSecond defines the number of frame per second yo use
  29169. * @param totalFrame defines the number of frames in total
  29170. * @param from defines the initial value
  29171. * @param to defines the final value
  29172. * @param loopMode defines which loop mode you want to use (off by default)
  29173. * @param easingFunction defines the easing function to use (linear by default)
  29174. * @param onAnimationEnd defines the callback to call when animation end
  29175. * @returns the animatable created for this animation
  29176. */
  29177. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29178. /**
  29179. * Create and start an animation on a node and its descendants
  29180. * @param name defines the name of the global animation that will be run on all nodes
  29181. * @param node defines the root node where the animation will take place
  29182. * @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
  29183. * @param targetProperty defines property to animate
  29184. * @param framePerSecond defines the number of frame per second to use
  29185. * @param totalFrame defines the number of frames in total
  29186. * @param from defines the initial value
  29187. * @param to defines the final value
  29188. * @param loopMode defines which loop mode you want to use (off by default)
  29189. * @param easingFunction defines the easing function to use (linear by default)
  29190. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29191. * @returns the list of animatables created for all nodes
  29192. * @example https://www.babylonjs-playground.com/#MH0VLI
  29193. */
  29194. 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[]>;
  29195. /**
  29196. * Creates a new animation, merges it with the existing animations and starts it
  29197. * @param name Name of the animation
  29198. * @param node Node which contains the scene that begins the animations
  29199. * @param targetProperty Specifies which property to animate
  29200. * @param framePerSecond The frames per second of the animation
  29201. * @param totalFrame The total number of frames
  29202. * @param from The frame at the beginning of the animation
  29203. * @param to The frame at the end of the animation
  29204. * @param loopMode Specifies the loop mode of the animation
  29205. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29206. * @param onAnimationEnd Callback to run once the animation is complete
  29207. * @returns Nullable animation
  29208. */
  29209. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29210. /**
  29211. * Transition property of an host to the target Value
  29212. * @param property The property to transition
  29213. * @param targetValue The target Value of the property
  29214. * @param host The object where the property to animate belongs
  29215. * @param scene Scene used to run the animation
  29216. * @param frameRate Framerate (in frame/s) to use
  29217. * @param transition The transition type we want to use
  29218. * @param duration The duration of the animation, in milliseconds
  29219. * @param onAnimationEnd Callback trigger at the end of the animation
  29220. * @returns Nullable animation
  29221. */
  29222. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29223. /**
  29224. * Return the array of runtime animations currently using this animation
  29225. */
  29226. get runtimeAnimations(): RuntimeAnimation[];
  29227. /**
  29228. * Specifies if any of the runtime animations are currently running
  29229. */
  29230. get hasRunningRuntimeAnimations(): boolean;
  29231. /**
  29232. * Initializes the animation
  29233. * @param name Name of the animation
  29234. * @param targetProperty Property to animate
  29235. * @param framePerSecond The frames per second of the animation
  29236. * @param dataType The data type of the animation
  29237. * @param loopMode The loop mode of the animation
  29238. * @param enableBlending Specifies if blending should be enabled
  29239. */
  29240. constructor(
  29241. /**Name of the animation */
  29242. name: string,
  29243. /**Property to animate */
  29244. targetProperty: string,
  29245. /**The frames per second of the animation */
  29246. framePerSecond: number,
  29247. /**The data type of the animation */
  29248. dataType: number,
  29249. /**The loop mode of the animation */
  29250. loopMode?: number | undefined,
  29251. /**Specifies if blending should be enabled */
  29252. enableBlending?: boolean | undefined);
  29253. /**
  29254. * Converts the animation to a string
  29255. * @param fullDetails support for multiple levels of logging within scene loading
  29256. * @returns String form of the animation
  29257. */
  29258. toString(fullDetails?: boolean): string;
  29259. /**
  29260. * Add an event to this animation
  29261. * @param event Event to add
  29262. */
  29263. addEvent(event: AnimationEvent): void;
  29264. /**
  29265. * Remove all events found at the given frame
  29266. * @param frame The frame to remove events from
  29267. */
  29268. removeEvents(frame: number): void;
  29269. /**
  29270. * Retrieves all the events from the animation
  29271. * @returns Events from the animation
  29272. */
  29273. getEvents(): AnimationEvent[];
  29274. /**
  29275. * Creates an animation range
  29276. * @param name Name of the animation range
  29277. * @param from Starting frame of the animation range
  29278. * @param to Ending frame of the animation
  29279. */
  29280. createRange(name: string, from: number, to: number): void;
  29281. /**
  29282. * Deletes an animation range by name
  29283. * @param name Name of the animation range to delete
  29284. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29285. */
  29286. deleteRange(name: string, deleteFrames?: boolean): void;
  29287. /**
  29288. * Gets the animation range by name, or null if not defined
  29289. * @param name Name of the animation range
  29290. * @returns Nullable animation range
  29291. */
  29292. getRange(name: string): Nullable<AnimationRange>;
  29293. /**
  29294. * Gets the key frames from the animation
  29295. * @returns The key frames of the animation
  29296. */
  29297. getKeys(): Array<IAnimationKey>;
  29298. /**
  29299. * Gets the highest frame rate of the animation
  29300. * @returns Highest frame rate of the animation
  29301. */
  29302. getHighestFrame(): number;
  29303. /**
  29304. * Gets the easing function of the animation
  29305. * @returns Easing function of the animation
  29306. */
  29307. getEasingFunction(): IEasingFunction;
  29308. /**
  29309. * Sets the easing function of the animation
  29310. * @param easingFunction A custom mathematical formula for animation
  29311. */
  29312. setEasingFunction(easingFunction: EasingFunction): void;
  29313. /**
  29314. * Interpolates a scalar linearly
  29315. * @param startValue Start value of the animation curve
  29316. * @param endValue End value of the animation curve
  29317. * @param gradient Scalar amount to interpolate
  29318. * @returns Interpolated scalar value
  29319. */
  29320. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29321. /**
  29322. * Interpolates a scalar cubically
  29323. * @param startValue Start value of the animation curve
  29324. * @param outTangent End tangent of the animation
  29325. * @param endValue End value of the animation curve
  29326. * @param inTangent Start tangent of the animation curve
  29327. * @param gradient Scalar amount to interpolate
  29328. * @returns Interpolated scalar value
  29329. */
  29330. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29331. /**
  29332. * Interpolates a quaternion using a spherical linear interpolation
  29333. * @param startValue Start value of the animation curve
  29334. * @param endValue End value of the animation curve
  29335. * @param gradient Scalar amount to interpolate
  29336. * @returns Interpolated quaternion value
  29337. */
  29338. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29339. /**
  29340. * Interpolates a quaternion cubically
  29341. * @param startValue Start value of the animation curve
  29342. * @param outTangent End tangent of the animation curve
  29343. * @param endValue End value of the animation curve
  29344. * @param inTangent Start tangent of the animation curve
  29345. * @param gradient Scalar amount to interpolate
  29346. * @returns Interpolated quaternion value
  29347. */
  29348. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29349. /**
  29350. * Interpolates a Vector3 linearl
  29351. * @param startValue Start value of the animation curve
  29352. * @param endValue End value of the animation curve
  29353. * @param gradient Scalar amount to interpolate
  29354. * @returns Interpolated scalar value
  29355. */
  29356. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29357. /**
  29358. * Interpolates a Vector3 cubically
  29359. * @param startValue Start value of the animation curve
  29360. * @param outTangent End tangent of the animation
  29361. * @param endValue End value of the animation curve
  29362. * @param inTangent Start tangent of the animation curve
  29363. * @param gradient Scalar amount to interpolate
  29364. * @returns InterpolatedVector3 value
  29365. */
  29366. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29367. /**
  29368. * Interpolates a Vector2 linearly
  29369. * @param startValue Start value of the animation curve
  29370. * @param endValue End value of the animation curve
  29371. * @param gradient Scalar amount to interpolate
  29372. * @returns Interpolated Vector2 value
  29373. */
  29374. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29375. /**
  29376. * Interpolates a Vector2 cubically
  29377. * @param startValue Start value of the animation curve
  29378. * @param outTangent End tangent of the animation
  29379. * @param endValue End value of the animation curve
  29380. * @param inTangent Start tangent of the animation curve
  29381. * @param gradient Scalar amount to interpolate
  29382. * @returns Interpolated Vector2 value
  29383. */
  29384. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29385. /**
  29386. * Interpolates a size linearly
  29387. * @param startValue Start value of the animation curve
  29388. * @param endValue End value of the animation curve
  29389. * @param gradient Scalar amount to interpolate
  29390. * @returns Interpolated Size value
  29391. */
  29392. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29393. /**
  29394. * Interpolates a Color3 linearly
  29395. * @param startValue Start value of the animation curve
  29396. * @param endValue End value of the animation curve
  29397. * @param gradient Scalar amount to interpolate
  29398. * @returns Interpolated Color3 value
  29399. */
  29400. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29401. /**
  29402. * Interpolates a Color4 linearly
  29403. * @param startValue Start value of the animation curve
  29404. * @param endValue End value of the animation curve
  29405. * @param gradient Scalar amount to interpolate
  29406. * @returns Interpolated Color3 value
  29407. */
  29408. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29409. /**
  29410. * @hidden Internal use only
  29411. */
  29412. _getKeyValue(value: any): any;
  29413. /**
  29414. * @hidden Internal use only
  29415. */
  29416. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29417. /**
  29418. * Defines the function to use to interpolate matrices
  29419. * @param startValue defines the start matrix
  29420. * @param endValue defines the end matrix
  29421. * @param gradient defines the gradient between both matrices
  29422. * @param result defines an optional target matrix where to store the interpolation
  29423. * @returns the interpolated matrix
  29424. */
  29425. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29426. /**
  29427. * Makes a copy of the animation
  29428. * @returns Cloned animation
  29429. */
  29430. clone(): Animation;
  29431. /**
  29432. * Sets the key frames of the animation
  29433. * @param values The animation key frames to set
  29434. */
  29435. setKeys(values: Array<IAnimationKey>): void;
  29436. /**
  29437. * Serializes the animation to an object
  29438. * @returns Serialized object
  29439. */
  29440. serialize(): any;
  29441. /**
  29442. * Float animation type
  29443. */
  29444. static readonly ANIMATIONTYPE_FLOAT: number;
  29445. /**
  29446. * Vector3 animation type
  29447. */
  29448. static readonly ANIMATIONTYPE_VECTOR3: number;
  29449. /**
  29450. * Quaternion animation type
  29451. */
  29452. static readonly ANIMATIONTYPE_QUATERNION: number;
  29453. /**
  29454. * Matrix animation type
  29455. */
  29456. static readonly ANIMATIONTYPE_MATRIX: number;
  29457. /**
  29458. * Color3 animation type
  29459. */
  29460. static readonly ANIMATIONTYPE_COLOR3: number;
  29461. /**
  29462. * Color3 animation type
  29463. */
  29464. static readonly ANIMATIONTYPE_COLOR4: number;
  29465. /**
  29466. * Vector2 animation type
  29467. */
  29468. static readonly ANIMATIONTYPE_VECTOR2: number;
  29469. /**
  29470. * Size animation type
  29471. */
  29472. static readonly ANIMATIONTYPE_SIZE: number;
  29473. /**
  29474. * Relative Loop Mode
  29475. */
  29476. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29477. /**
  29478. * Cycle Loop Mode
  29479. */
  29480. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29481. /**
  29482. * Constant Loop Mode
  29483. */
  29484. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29485. /** @hidden */
  29486. static _UniversalLerp(left: any, right: any, amount: number): any;
  29487. /**
  29488. * Parses an animation object and creates an animation
  29489. * @param parsedAnimation Parsed animation object
  29490. * @returns Animation object
  29491. */
  29492. static Parse(parsedAnimation: any): Animation;
  29493. /**
  29494. * Appends the serialized animations from the source animations
  29495. * @param source Source containing the animations
  29496. * @param destination Target to store the animations
  29497. */
  29498. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29499. }
  29500. }
  29501. declare module BABYLON {
  29502. /**
  29503. * Interface containing an array of animations
  29504. */
  29505. export interface IAnimatable {
  29506. /**
  29507. * Array of animations
  29508. */
  29509. animations: Nullable<Array<Animation>>;
  29510. }
  29511. }
  29512. declare module BABYLON {
  29513. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29514. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29515. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29516. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29517. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29518. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29519. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29520. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29521. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29522. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29523. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29524. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29525. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29526. /**
  29527. * Decorator used to define property that can be serialized as reference to a camera
  29528. * @param sourceName defines the name of the property to decorate
  29529. */
  29530. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29531. /**
  29532. * Class used to help serialization objects
  29533. */
  29534. export class SerializationHelper {
  29535. /** @hidden */
  29536. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29537. /** @hidden */
  29538. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29539. /** @hidden */
  29540. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29541. /** @hidden */
  29542. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29543. /**
  29544. * Appends the serialized animations from the source animations
  29545. * @param source Source containing the animations
  29546. * @param destination Target to store the animations
  29547. */
  29548. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29549. /**
  29550. * Static function used to serialized a specific entity
  29551. * @param entity defines the entity to serialize
  29552. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29553. * @returns a JSON compatible object representing the serialization of the entity
  29554. */
  29555. static Serialize<T>(entity: T, serializationObject?: any): any;
  29556. /**
  29557. * Creates a new entity from a serialization data object
  29558. * @param creationFunction defines a function used to instanciated the new entity
  29559. * @param source defines the source serialization data
  29560. * @param scene defines the hosting scene
  29561. * @param rootUrl defines the root url for resources
  29562. * @returns a new entity
  29563. */
  29564. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29565. /**
  29566. * Clones an object
  29567. * @param creationFunction defines the function used to instanciate the new object
  29568. * @param source defines the source object
  29569. * @returns the cloned object
  29570. */
  29571. static Clone<T>(creationFunction: () => T, source: T): T;
  29572. /**
  29573. * Instanciates a new object based on a source one (some data will be shared between both object)
  29574. * @param creationFunction defines the function used to instanciate the new object
  29575. * @param source defines the source object
  29576. * @returns the new object
  29577. */
  29578. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29579. }
  29580. }
  29581. declare module BABYLON {
  29582. /**
  29583. * Class used to manipulate GUIDs
  29584. */
  29585. export class GUID {
  29586. /**
  29587. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29588. * Be aware Math.random() could cause collisions, but:
  29589. * "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"
  29590. * @returns a pseudo random id
  29591. */
  29592. static RandomId(): string;
  29593. }
  29594. }
  29595. declare module BABYLON {
  29596. /**
  29597. * Base class of all the textures in babylon.
  29598. * It groups all the common properties the materials, post process, lights... might need
  29599. * in order to make a correct use of the texture.
  29600. */
  29601. export class BaseTexture implements IAnimatable {
  29602. /**
  29603. * Default anisotropic filtering level for the application.
  29604. * It is set to 4 as a good tradeoff between perf and quality.
  29605. */
  29606. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29607. /**
  29608. * Gets or sets the unique id of the texture
  29609. */
  29610. uniqueId: number;
  29611. /**
  29612. * Define the name of the texture.
  29613. */
  29614. name: string;
  29615. /**
  29616. * Gets or sets an object used to store user defined information.
  29617. */
  29618. metadata: any;
  29619. /**
  29620. * For internal use only. Please do not use.
  29621. */
  29622. reservedDataStore: any;
  29623. private _hasAlpha;
  29624. /**
  29625. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29626. */
  29627. set hasAlpha(value: boolean);
  29628. get hasAlpha(): boolean;
  29629. /**
  29630. * Defines if the alpha value should be determined via the rgb values.
  29631. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29632. */
  29633. getAlphaFromRGB: boolean;
  29634. /**
  29635. * Intensity or strength of the texture.
  29636. * It is commonly used by materials to fine tune the intensity of the texture
  29637. */
  29638. level: number;
  29639. /**
  29640. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29641. * This is part of the texture as textures usually maps to one uv set.
  29642. */
  29643. coordinatesIndex: number;
  29644. private _coordinatesMode;
  29645. /**
  29646. * How a texture is mapped.
  29647. *
  29648. * | Value | Type | Description |
  29649. * | ----- | ----------------------------------- | ----------- |
  29650. * | 0 | EXPLICIT_MODE | |
  29651. * | 1 | SPHERICAL_MODE | |
  29652. * | 2 | PLANAR_MODE | |
  29653. * | 3 | CUBIC_MODE | |
  29654. * | 4 | PROJECTION_MODE | |
  29655. * | 5 | SKYBOX_MODE | |
  29656. * | 6 | INVCUBIC_MODE | |
  29657. * | 7 | EQUIRECTANGULAR_MODE | |
  29658. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29659. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29660. */
  29661. set coordinatesMode(value: number);
  29662. get coordinatesMode(): number;
  29663. /**
  29664. * | Value | Type | Description |
  29665. * | ----- | ------------------ | ----------- |
  29666. * | 0 | CLAMP_ADDRESSMODE | |
  29667. * | 1 | WRAP_ADDRESSMODE | |
  29668. * | 2 | MIRROR_ADDRESSMODE | |
  29669. */
  29670. wrapU: number;
  29671. /**
  29672. * | Value | Type | Description |
  29673. * | ----- | ------------------ | ----------- |
  29674. * | 0 | CLAMP_ADDRESSMODE | |
  29675. * | 1 | WRAP_ADDRESSMODE | |
  29676. * | 2 | MIRROR_ADDRESSMODE | |
  29677. */
  29678. wrapV: number;
  29679. /**
  29680. * | Value | Type | Description |
  29681. * | ----- | ------------------ | ----------- |
  29682. * | 0 | CLAMP_ADDRESSMODE | |
  29683. * | 1 | WRAP_ADDRESSMODE | |
  29684. * | 2 | MIRROR_ADDRESSMODE | |
  29685. */
  29686. wrapR: number;
  29687. /**
  29688. * With compliant hardware and browser (supporting anisotropic filtering)
  29689. * this defines the level of anisotropic filtering in the texture.
  29690. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29691. */
  29692. anisotropicFilteringLevel: number;
  29693. /**
  29694. * Define if the texture is a cube texture or if false a 2d texture.
  29695. */
  29696. get isCube(): boolean;
  29697. set isCube(value: boolean);
  29698. /**
  29699. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29700. */
  29701. get is3D(): boolean;
  29702. set is3D(value: boolean);
  29703. /**
  29704. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29705. */
  29706. get is2DArray(): boolean;
  29707. set is2DArray(value: boolean);
  29708. /**
  29709. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29710. * HDR texture are usually stored in linear space.
  29711. * This only impacts the PBR and Background materials
  29712. */
  29713. gammaSpace: boolean;
  29714. /**
  29715. * Gets or sets whether or not the texture contains RGBD data.
  29716. */
  29717. get isRGBD(): boolean;
  29718. set isRGBD(value: boolean);
  29719. /**
  29720. * Is Z inverted in the texture (useful in a cube texture).
  29721. */
  29722. invertZ: boolean;
  29723. /**
  29724. * Are mip maps generated for this texture or not.
  29725. */
  29726. get noMipmap(): boolean;
  29727. /**
  29728. * @hidden
  29729. */
  29730. lodLevelInAlpha: boolean;
  29731. /**
  29732. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29733. */
  29734. get lodGenerationOffset(): number;
  29735. set lodGenerationOffset(value: number);
  29736. /**
  29737. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29738. */
  29739. get lodGenerationScale(): number;
  29740. set lodGenerationScale(value: number);
  29741. /**
  29742. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29743. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29744. * average roughness values.
  29745. */
  29746. get linearSpecularLOD(): boolean;
  29747. set linearSpecularLOD(value: boolean);
  29748. /**
  29749. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29750. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29751. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29752. */
  29753. get irradianceTexture(): Nullable<BaseTexture>;
  29754. set irradianceTexture(value: Nullable<BaseTexture>);
  29755. /**
  29756. * Define if the texture is a render target.
  29757. */
  29758. isRenderTarget: boolean;
  29759. /**
  29760. * Define the unique id of the texture in the scene.
  29761. */
  29762. get uid(): string;
  29763. /**
  29764. * Return a string representation of the texture.
  29765. * @returns the texture as a string
  29766. */
  29767. toString(): string;
  29768. /**
  29769. * Get the class name of the texture.
  29770. * @returns "BaseTexture"
  29771. */
  29772. getClassName(): string;
  29773. /**
  29774. * Define the list of animation attached to the texture.
  29775. */
  29776. animations: Animation[];
  29777. /**
  29778. * An event triggered when the texture is disposed.
  29779. */
  29780. onDisposeObservable: Observable<BaseTexture>;
  29781. private _onDisposeObserver;
  29782. /**
  29783. * Callback triggered when the texture has been disposed.
  29784. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29785. */
  29786. set onDispose(callback: () => void);
  29787. /**
  29788. * Define the current state of the loading sequence when in delayed load mode.
  29789. */
  29790. delayLoadState: number;
  29791. private _scene;
  29792. /** @hidden */
  29793. _texture: Nullable<InternalTexture>;
  29794. private _uid;
  29795. /**
  29796. * Define if the texture is preventinga material to render or not.
  29797. * If not and the texture is not ready, the engine will use a default black texture instead.
  29798. */
  29799. get isBlocking(): boolean;
  29800. /**
  29801. * Instantiates a new BaseTexture.
  29802. * Base class of all the textures in babylon.
  29803. * It groups all the common properties the materials, post process, lights... might need
  29804. * in order to make a correct use of the texture.
  29805. * @param scene Define the scene the texture blongs to
  29806. */
  29807. constructor(scene: Nullable<Scene>);
  29808. /**
  29809. * Get the scene the texture belongs to.
  29810. * @returns the scene or null if undefined
  29811. */
  29812. getScene(): Nullable<Scene>;
  29813. /**
  29814. * Get the texture transform matrix used to offset tile the texture for istance.
  29815. * @returns the transformation matrix
  29816. */
  29817. getTextureMatrix(): Matrix;
  29818. /**
  29819. * Get the texture reflection matrix used to rotate/transform the reflection.
  29820. * @returns the reflection matrix
  29821. */
  29822. getReflectionTextureMatrix(): Matrix;
  29823. /**
  29824. * Get the underlying lower level texture from Babylon.
  29825. * @returns the insternal texture
  29826. */
  29827. getInternalTexture(): Nullable<InternalTexture>;
  29828. /**
  29829. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29830. * @returns true if ready or not blocking
  29831. */
  29832. isReadyOrNotBlocking(): boolean;
  29833. /**
  29834. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29835. * @returns true if fully ready
  29836. */
  29837. isReady(): boolean;
  29838. private _cachedSize;
  29839. /**
  29840. * Get the size of the texture.
  29841. * @returns the texture size.
  29842. */
  29843. getSize(): ISize;
  29844. /**
  29845. * Get the base size of the texture.
  29846. * It can be different from the size if the texture has been resized for POT for instance
  29847. * @returns the base size
  29848. */
  29849. getBaseSize(): ISize;
  29850. /**
  29851. * Update the sampling mode of the texture.
  29852. * Default is Trilinear mode.
  29853. *
  29854. * | Value | Type | Description |
  29855. * | ----- | ------------------ | ----------- |
  29856. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29857. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29858. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29859. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29860. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29861. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29862. * | 7 | NEAREST_LINEAR | |
  29863. * | 8 | NEAREST_NEAREST | |
  29864. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29865. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29866. * | 11 | LINEAR_LINEAR | |
  29867. * | 12 | LINEAR_NEAREST | |
  29868. *
  29869. * > _mag_: magnification filter (close to the viewer)
  29870. * > _min_: minification filter (far from the viewer)
  29871. * > _mip_: filter used between mip map levels
  29872. *@param samplingMode Define the new sampling mode of the texture
  29873. */
  29874. updateSamplingMode(samplingMode: number): void;
  29875. /**
  29876. * Scales the texture if is `canRescale()`
  29877. * @param ratio the resize factor we want to use to rescale
  29878. */
  29879. scale(ratio: number): void;
  29880. /**
  29881. * Get if the texture can rescale.
  29882. */
  29883. get canRescale(): boolean;
  29884. /** @hidden */
  29885. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29886. /** @hidden */
  29887. _rebuild(): void;
  29888. /**
  29889. * Triggers the load sequence in delayed load mode.
  29890. */
  29891. delayLoad(): void;
  29892. /**
  29893. * Clones the texture.
  29894. * @returns the cloned texture
  29895. */
  29896. clone(): Nullable<BaseTexture>;
  29897. /**
  29898. * Get the texture underlying type (INT, FLOAT...)
  29899. */
  29900. get textureType(): number;
  29901. /**
  29902. * Get the texture underlying format (RGB, RGBA...)
  29903. */
  29904. get textureFormat(): number;
  29905. /**
  29906. * Indicates that textures need to be re-calculated for all materials
  29907. */
  29908. protected _markAllSubMeshesAsTexturesDirty(): void;
  29909. /**
  29910. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29911. * This will returns an RGBA array buffer containing either in values (0-255) or
  29912. * float values (0-1) depending of the underlying buffer type.
  29913. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29914. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29915. * @param buffer defines a user defined buffer to fill with data (can be null)
  29916. * @returns The Array buffer containing the pixels data.
  29917. */
  29918. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29919. /**
  29920. * Release and destroy the underlying lower level texture aka internalTexture.
  29921. */
  29922. releaseInternalTexture(): void;
  29923. /** @hidden */
  29924. get _lodTextureHigh(): Nullable<BaseTexture>;
  29925. /** @hidden */
  29926. get _lodTextureMid(): Nullable<BaseTexture>;
  29927. /** @hidden */
  29928. get _lodTextureLow(): Nullable<BaseTexture>;
  29929. /**
  29930. * Dispose the texture and release its associated resources.
  29931. */
  29932. dispose(): void;
  29933. /**
  29934. * Serialize the texture into a JSON representation that can be parsed later on.
  29935. * @returns the JSON representation of the texture
  29936. */
  29937. serialize(): any;
  29938. /**
  29939. * Helper function to be called back once a list of texture contains only ready textures.
  29940. * @param textures Define the list of textures to wait for
  29941. * @param callback Define the callback triggered once the entire list will be ready
  29942. */
  29943. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29944. }
  29945. }
  29946. declare module BABYLON {
  29947. /**
  29948. * Options to be used when creating an effect.
  29949. */
  29950. export interface IEffectCreationOptions {
  29951. /**
  29952. * Atrributes that will be used in the shader.
  29953. */
  29954. attributes: string[];
  29955. /**
  29956. * Uniform varible names that will be set in the shader.
  29957. */
  29958. uniformsNames: string[];
  29959. /**
  29960. * Uniform buffer variable names that will be set in the shader.
  29961. */
  29962. uniformBuffersNames: string[];
  29963. /**
  29964. * Sampler texture variable names that will be set in the shader.
  29965. */
  29966. samplers: string[];
  29967. /**
  29968. * Define statements that will be set in the shader.
  29969. */
  29970. defines: any;
  29971. /**
  29972. * Possible fallbacks for this effect to improve performance when needed.
  29973. */
  29974. fallbacks: Nullable<IEffectFallbacks>;
  29975. /**
  29976. * Callback that will be called when the shader is compiled.
  29977. */
  29978. onCompiled: Nullable<(effect: Effect) => void>;
  29979. /**
  29980. * Callback that will be called if an error occurs during shader compilation.
  29981. */
  29982. onError: Nullable<(effect: Effect, errors: string) => void>;
  29983. /**
  29984. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29985. */
  29986. indexParameters?: any;
  29987. /**
  29988. * Max number of lights that can be used in the shader.
  29989. */
  29990. maxSimultaneousLights?: number;
  29991. /**
  29992. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29993. */
  29994. transformFeedbackVaryings?: Nullable<string[]>;
  29995. }
  29996. /**
  29997. * Effect containing vertex and fragment shader that can be executed on an object.
  29998. */
  29999. export class Effect implements IDisposable {
  30000. /**
  30001. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30002. */
  30003. static ShadersRepository: string;
  30004. /**
  30005. * Name of the effect.
  30006. */
  30007. name: any;
  30008. /**
  30009. * String container all the define statements that should be set on the shader.
  30010. */
  30011. defines: string;
  30012. /**
  30013. * Callback that will be called when the shader is compiled.
  30014. */
  30015. onCompiled: Nullable<(effect: Effect) => void>;
  30016. /**
  30017. * Callback that will be called if an error occurs during shader compilation.
  30018. */
  30019. onError: Nullable<(effect: Effect, errors: string) => void>;
  30020. /**
  30021. * Callback that will be called when effect is bound.
  30022. */
  30023. onBind: Nullable<(effect: Effect) => void>;
  30024. /**
  30025. * Unique ID of the effect.
  30026. */
  30027. uniqueId: number;
  30028. /**
  30029. * Observable that will be called when the shader is compiled.
  30030. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30031. */
  30032. onCompileObservable: Observable<Effect>;
  30033. /**
  30034. * Observable that will be called if an error occurs during shader compilation.
  30035. */
  30036. onErrorObservable: Observable<Effect>;
  30037. /** @hidden */
  30038. _onBindObservable: Nullable<Observable<Effect>>;
  30039. /**
  30040. * @hidden
  30041. * Specifies if the effect was previously ready
  30042. */
  30043. _wasPreviouslyReady: boolean;
  30044. /**
  30045. * Observable that will be called when effect is bound.
  30046. */
  30047. get onBindObservable(): Observable<Effect>;
  30048. /** @hidden */
  30049. _bonesComputationForcedToCPU: boolean;
  30050. private static _uniqueIdSeed;
  30051. private _engine;
  30052. private _uniformBuffersNames;
  30053. private _uniformsNames;
  30054. private _samplerList;
  30055. private _samplers;
  30056. private _isReady;
  30057. private _compilationError;
  30058. private _allFallbacksProcessed;
  30059. private _attributesNames;
  30060. private _attributes;
  30061. private _attributeLocationByName;
  30062. private _uniforms;
  30063. /**
  30064. * Key for the effect.
  30065. * @hidden
  30066. */
  30067. _key: string;
  30068. private _indexParameters;
  30069. private _fallbacks;
  30070. private _vertexSourceCode;
  30071. private _fragmentSourceCode;
  30072. private _vertexSourceCodeOverride;
  30073. private _fragmentSourceCodeOverride;
  30074. private _transformFeedbackVaryings;
  30075. /**
  30076. * Compiled shader to webGL program.
  30077. * @hidden
  30078. */
  30079. _pipelineContext: Nullable<IPipelineContext>;
  30080. private _valueCache;
  30081. private static _baseCache;
  30082. /**
  30083. * Instantiates an effect.
  30084. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30085. * @param baseName Name of the effect.
  30086. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30087. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30088. * @param samplers List of sampler variables that will be passed to the shader.
  30089. * @param engine Engine to be used to render the effect
  30090. * @param defines Define statements to be added to the shader.
  30091. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30092. * @param onCompiled Callback that will be called when the shader is compiled.
  30093. * @param onError Callback that will be called if an error occurs during shader compilation.
  30094. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30095. */
  30096. 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);
  30097. private _useFinalCode;
  30098. /**
  30099. * Unique key for this effect
  30100. */
  30101. get key(): string;
  30102. /**
  30103. * If the effect has been compiled and prepared.
  30104. * @returns if the effect is compiled and prepared.
  30105. */
  30106. isReady(): boolean;
  30107. private _isReadyInternal;
  30108. /**
  30109. * The engine the effect was initialized with.
  30110. * @returns the engine.
  30111. */
  30112. getEngine(): Engine;
  30113. /**
  30114. * The pipeline context for this effect
  30115. * @returns the associated pipeline context
  30116. */
  30117. getPipelineContext(): Nullable<IPipelineContext>;
  30118. /**
  30119. * The set of names of attribute variables for the shader.
  30120. * @returns An array of attribute names.
  30121. */
  30122. getAttributesNames(): string[];
  30123. /**
  30124. * Returns the attribute at the given index.
  30125. * @param index The index of the attribute.
  30126. * @returns The location of the attribute.
  30127. */
  30128. getAttributeLocation(index: number): number;
  30129. /**
  30130. * Returns the attribute based on the name of the variable.
  30131. * @param name of the attribute to look up.
  30132. * @returns the attribute location.
  30133. */
  30134. getAttributeLocationByName(name: string): number;
  30135. /**
  30136. * The number of attributes.
  30137. * @returns the numnber of attributes.
  30138. */
  30139. getAttributesCount(): number;
  30140. /**
  30141. * Gets the index of a uniform variable.
  30142. * @param uniformName of the uniform to look up.
  30143. * @returns the index.
  30144. */
  30145. getUniformIndex(uniformName: string): number;
  30146. /**
  30147. * Returns the attribute based on the name of the variable.
  30148. * @param uniformName of the uniform to look up.
  30149. * @returns the location of the uniform.
  30150. */
  30151. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30152. /**
  30153. * Returns an array of sampler variable names
  30154. * @returns The array of sampler variable neames.
  30155. */
  30156. getSamplers(): string[];
  30157. /**
  30158. * The error from the last compilation.
  30159. * @returns the error string.
  30160. */
  30161. getCompilationError(): string;
  30162. /**
  30163. * Gets a boolean indicating that all fallbacks were used during compilation
  30164. * @returns true if all fallbacks were used
  30165. */
  30166. allFallbacksProcessed(): boolean;
  30167. /**
  30168. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30169. * @param func The callback to be used.
  30170. */
  30171. executeWhenCompiled(func: (effect: Effect) => void): void;
  30172. private _checkIsReady;
  30173. private _loadShader;
  30174. /**
  30175. * Recompiles the webGL program
  30176. * @param vertexSourceCode The source code for the vertex shader.
  30177. * @param fragmentSourceCode The source code for the fragment shader.
  30178. * @param onCompiled Callback called when completed.
  30179. * @param onError Callback called on error.
  30180. * @hidden
  30181. */
  30182. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30183. /**
  30184. * Prepares the effect
  30185. * @hidden
  30186. */
  30187. _prepareEffect(): void;
  30188. private _processCompilationErrors;
  30189. /**
  30190. * Checks if the effect is supported. (Must be called after compilation)
  30191. */
  30192. get isSupported(): boolean;
  30193. /**
  30194. * Binds a texture to the engine to be used as output of the shader.
  30195. * @param channel Name of the output variable.
  30196. * @param texture Texture to bind.
  30197. * @hidden
  30198. */
  30199. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30200. /**
  30201. * Sets a texture on the engine to be used in the shader.
  30202. * @param channel Name of the sampler variable.
  30203. * @param texture Texture to set.
  30204. */
  30205. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30206. /**
  30207. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30208. * @param channel Name of the sampler variable.
  30209. * @param texture Texture to set.
  30210. */
  30211. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30212. /**
  30213. * Sets an array of textures on the engine to be used in the shader.
  30214. * @param channel Name of the variable.
  30215. * @param textures Textures to set.
  30216. */
  30217. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30218. /**
  30219. * 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)
  30220. * @param channel Name of the sampler variable.
  30221. * @param postProcess Post process to get the input texture from.
  30222. */
  30223. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30224. /**
  30225. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30226. * 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)
  30227. * @param channel Name of the sampler variable.
  30228. * @param postProcess Post process to get the output texture from.
  30229. */
  30230. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30231. /** @hidden */
  30232. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30233. /** @hidden */
  30234. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30235. /** @hidden */
  30236. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30237. /** @hidden */
  30238. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30239. /**
  30240. * Binds a buffer to a uniform.
  30241. * @param buffer Buffer to bind.
  30242. * @param name Name of the uniform variable to bind to.
  30243. */
  30244. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30245. /**
  30246. * Binds block to a uniform.
  30247. * @param blockName Name of the block to bind.
  30248. * @param index Index to bind.
  30249. */
  30250. bindUniformBlock(blockName: string, index: number): void;
  30251. /**
  30252. * Sets an interger value on a uniform variable.
  30253. * @param uniformName Name of the variable.
  30254. * @param value Value to be set.
  30255. * @returns this effect.
  30256. */
  30257. setInt(uniformName: string, value: number): Effect;
  30258. /**
  30259. * Sets an int array on a uniform variable.
  30260. * @param uniformName Name of the variable.
  30261. * @param array array to be set.
  30262. * @returns this effect.
  30263. */
  30264. setIntArray(uniformName: string, array: Int32Array): Effect;
  30265. /**
  30266. * 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)
  30267. * @param uniformName Name of the variable.
  30268. * @param array array to be set.
  30269. * @returns this effect.
  30270. */
  30271. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30272. /**
  30273. * 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)
  30274. * @param uniformName Name of the variable.
  30275. * @param array array to be set.
  30276. * @returns this effect.
  30277. */
  30278. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30279. /**
  30280. * 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)
  30281. * @param uniformName Name of the variable.
  30282. * @param array array to be set.
  30283. * @returns this effect.
  30284. */
  30285. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30286. /**
  30287. * Sets an float array on a uniform variable.
  30288. * @param uniformName Name of the variable.
  30289. * @param array array to be set.
  30290. * @returns this effect.
  30291. */
  30292. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30293. /**
  30294. * 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)
  30295. * @param uniformName Name of the variable.
  30296. * @param array array to be set.
  30297. * @returns this effect.
  30298. */
  30299. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30300. /**
  30301. * 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)
  30302. * @param uniformName Name of the variable.
  30303. * @param array array to be set.
  30304. * @returns this effect.
  30305. */
  30306. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30307. /**
  30308. * 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)
  30309. * @param uniformName Name of the variable.
  30310. * @param array array to be set.
  30311. * @returns this effect.
  30312. */
  30313. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30314. /**
  30315. * Sets an array on a uniform variable.
  30316. * @param uniformName Name of the variable.
  30317. * @param array array to be set.
  30318. * @returns this effect.
  30319. */
  30320. setArray(uniformName: string, array: number[]): Effect;
  30321. /**
  30322. * 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)
  30323. * @param uniformName Name of the variable.
  30324. * @param array array to be set.
  30325. * @returns this effect.
  30326. */
  30327. setArray2(uniformName: string, array: number[]): Effect;
  30328. /**
  30329. * 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)
  30330. * @param uniformName Name of the variable.
  30331. * @param array array to be set.
  30332. * @returns this effect.
  30333. */
  30334. setArray3(uniformName: string, array: number[]): Effect;
  30335. /**
  30336. * 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)
  30337. * @param uniformName Name of the variable.
  30338. * @param array array to be set.
  30339. * @returns this effect.
  30340. */
  30341. setArray4(uniformName: string, array: number[]): Effect;
  30342. /**
  30343. * Sets matrices on a uniform variable.
  30344. * @param uniformName Name of the variable.
  30345. * @param matrices matrices to be set.
  30346. * @returns this effect.
  30347. */
  30348. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30349. /**
  30350. * Sets matrix on a uniform variable.
  30351. * @param uniformName Name of the variable.
  30352. * @param matrix matrix to be set.
  30353. * @returns this effect.
  30354. */
  30355. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30356. /**
  30357. * 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)
  30358. * @param uniformName Name of the variable.
  30359. * @param matrix matrix to be set.
  30360. * @returns this effect.
  30361. */
  30362. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30363. /**
  30364. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30365. * @param uniformName Name of the variable.
  30366. * @param matrix matrix to be set.
  30367. * @returns this effect.
  30368. */
  30369. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30370. /**
  30371. * Sets a float on a uniform variable.
  30372. * @param uniformName Name of the variable.
  30373. * @param value value to be set.
  30374. * @returns this effect.
  30375. */
  30376. setFloat(uniformName: string, value: number): Effect;
  30377. /**
  30378. * Sets a boolean on a uniform variable.
  30379. * @param uniformName Name of the variable.
  30380. * @param bool value to be set.
  30381. * @returns this effect.
  30382. */
  30383. setBool(uniformName: string, bool: boolean): Effect;
  30384. /**
  30385. * Sets a Vector2 on a uniform variable.
  30386. * @param uniformName Name of the variable.
  30387. * @param vector2 vector2 to be set.
  30388. * @returns this effect.
  30389. */
  30390. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30391. /**
  30392. * Sets a float2 on a uniform variable.
  30393. * @param uniformName Name of the variable.
  30394. * @param x First float in float2.
  30395. * @param y Second float in float2.
  30396. * @returns this effect.
  30397. */
  30398. setFloat2(uniformName: string, x: number, y: number): Effect;
  30399. /**
  30400. * Sets a Vector3 on a uniform variable.
  30401. * @param uniformName Name of the variable.
  30402. * @param vector3 Value to be set.
  30403. * @returns this effect.
  30404. */
  30405. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30406. /**
  30407. * Sets a float3 on a uniform variable.
  30408. * @param uniformName Name of the variable.
  30409. * @param x First float in float3.
  30410. * @param y Second float in float3.
  30411. * @param z Third float in float3.
  30412. * @returns this effect.
  30413. */
  30414. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30415. /**
  30416. * Sets a Vector4 on a uniform variable.
  30417. * @param uniformName Name of the variable.
  30418. * @param vector4 Value to be set.
  30419. * @returns this effect.
  30420. */
  30421. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30422. /**
  30423. * Sets a float4 on a uniform variable.
  30424. * @param uniformName Name of the variable.
  30425. * @param x First float in float4.
  30426. * @param y Second float in float4.
  30427. * @param z Third float in float4.
  30428. * @param w Fourth float in float4.
  30429. * @returns this effect.
  30430. */
  30431. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30432. /**
  30433. * Sets a Color3 on a uniform variable.
  30434. * @param uniformName Name of the variable.
  30435. * @param color3 Value to be set.
  30436. * @returns this effect.
  30437. */
  30438. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30439. /**
  30440. * Sets a Color4 on a uniform variable.
  30441. * @param uniformName Name of the variable.
  30442. * @param color3 Value to be set.
  30443. * @param alpha Alpha value to be set.
  30444. * @returns this effect.
  30445. */
  30446. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30447. /**
  30448. * Sets a Color4 on a uniform variable
  30449. * @param uniformName defines the name of the variable
  30450. * @param color4 defines the value to be set
  30451. * @returns this effect.
  30452. */
  30453. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30454. /** Release all associated resources */
  30455. dispose(): void;
  30456. /**
  30457. * This function will add a new shader to the shader store
  30458. * @param name the name of the shader
  30459. * @param pixelShader optional pixel shader content
  30460. * @param vertexShader optional vertex shader content
  30461. */
  30462. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30463. /**
  30464. * Store of each shader (The can be looked up using effect.key)
  30465. */
  30466. static ShadersStore: {
  30467. [key: string]: string;
  30468. };
  30469. /**
  30470. * Store of each included file for a shader (The can be looked up using effect.key)
  30471. */
  30472. static IncludesShadersStore: {
  30473. [key: string]: string;
  30474. };
  30475. /**
  30476. * Resets the cache of effects.
  30477. */
  30478. static ResetCache(): void;
  30479. }
  30480. }
  30481. declare module BABYLON {
  30482. /**
  30483. * Interface used to describe the capabilities of the engine relatively to the current browser
  30484. */
  30485. export interface EngineCapabilities {
  30486. /** Maximum textures units per fragment shader */
  30487. maxTexturesImageUnits: number;
  30488. /** Maximum texture units per vertex shader */
  30489. maxVertexTextureImageUnits: number;
  30490. /** Maximum textures units in the entire pipeline */
  30491. maxCombinedTexturesImageUnits: number;
  30492. /** Maximum texture size */
  30493. maxTextureSize: number;
  30494. /** Maximum texture samples */
  30495. maxSamples?: number;
  30496. /** Maximum cube texture size */
  30497. maxCubemapTextureSize: number;
  30498. /** Maximum render texture size */
  30499. maxRenderTextureSize: number;
  30500. /** Maximum number of vertex attributes */
  30501. maxVertexAttribs: number;
  30502. /** Maximum number of varyings */
  30503. maxVaryingVectors: number;
  30504. /** Maximum number of uniforms per vertex shader */
  30505. maxVertexUniformVectors: number;
  30506. /** Maximum number of uniforms per fragment shader */
  30507. maxFragmentUniformVectors: number;
  30508. /** Defines if standard derivates (dx/dy) are supported */
  30509. standardDerivatives: boolean;
  30510. /** Defines if s3tc texture compression is supported */
  30511. s3tc?: WEBGL_compressed_texture_s3tc;
  30512. /** Defines if pvrtc texture compression is supported */
  30513. pvrtc: any;
  30514. /** Defines if etc1 texture compression is supported */
  30515. etc1: any;
  30516. /** Defines if etc2 texture compression is supported */
  30517. etc2: any;
  30518. /** Defines if astc texture compression is supported */
  30519. astc: any;
  30520. /** Defines if float textures are supported */
  30521. textureFloat: boolean;
  30522. /** Defines if vertex array objects are supported */
  30523. vertexArrayObject: boolean;
  30524. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30525. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30526. /** Gets the maximum level of anisotropy supported */
  30527. maxAnisotropy: number;
  30528. /** Defines if instancing is supported */
  30529. instancedArrays: boolean;
  30530. /** Defines if 32 bits indices are supported */
  30531. uintIndices: boolean;
  30532. /** Defines if high precision shaders are supported */
  30533. highPrecisionShaderSupported: boolean;
  30534. /** Defines if depth reading in the fragment shader is supported */
  30535. fragmentDepthSupported: boolean;
  30536. /** Defines if float texture linear filtering is supported*/
  30537. textureFloatLinearFiltering: boolean;
  30538. /** Defines if rendering to float textures is supported */
  30539. textureFloatRender: boolean;
  30540. /** Defines if half float textures are supported*/
  30541. textureHalfFloat: boolean;
  30542. /** Defines if half float texture linear filtering is supported*/
  30543. textureHalfFloatLinearFiltering: boolean;
  30544. /** Defines if rendering to half float textures is supported */
  30545. textureHalfFloatRender: boolean;
  30546. /** Defines if textureLOD shader command is supported */
  30547. textureLOD: boolean;
  30548. /** Defines if draw buffers extension is supported */
  30549. drawBuffersExtension: boolean;
  30550. /** Defines if depth textures are supported */
  30551. depthTextureExtension: boolean;
  30552. /** Defines if float color buffer are supported */
  30553. colorBufferFloat: boolean;
  30554. /** Gets disjoint timer query extension (null if not supported) */
  30555. timerQuery?: EXT_disjoint_timer_query;
  30556. /** Defines if timestamp can be used with timer query */
  30557. canUseTimestampForTimerQuery: boolean;
  30558. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30559. multiview?: any;
  30560. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30561. oculusMultiview?: any;
  30562. /** Function used to let the system compiles shaders in background */
  30563. parallelShaderCompile?: {
  30564. COMPLETION_STATUS_KHR: number;
  30565. };
  30566. /** Max number of texture samples for MSAA */
  30567. maxMSAASamples: number;
  30568. /** Defines if the blend min max extension is supported */
  30569. blendMinMax: boolean;
  30570. }
  30571. }
  30572. declare module BABYLON {
  30573. /**
  30574. * @hidden
  30575. **/
  30576. export class DepthCullingState {
  30577. private _isDepthTestDirty;
  30578. private _isDepthMaskDirty;
  30579. private _isDepthFuncDirty;
  30580. private _isCullFaceDirty;
  30581. private _isCullDirty;
  30582. private _isZOffsetDirty;
  30583. private _isFrontFaceDirty;
  30584. private _depthTest;
  30585. private _depthMask;
  30586. private _depthFunc;
  30587. private _cull;
  30588. private _cullFace;
  30589. private _zOffset;
  30590. private _frontFace;
  30591. /**
  30592. * Initializes the state.
  30593. */
  30594. constructor();
  30595. get isDirty(): boolean;
  30596. get zOffset(): number;
  30597. set zOffset(value: number);
  30598. get cullFace(): Nullable<number>;
  30599. set cullFace(value: Nullable<number>);
  30600. get cull(): Nullable<boolean>;
  30601. set cull(value: Nullable<boolean>);
  30602. get depthFunc(): Nullable<number>;
  30603. set depthFunc(value: Nullable<number>);
  30604. get depthMask(): boolean;
  30605. set depthMask(value: boolean);
  30606. get depthTest(): boolean;
  30607. set depthTest(value: boolean);
  30608. get frontFace(): Nullable<number>;
  30609. set frontFace(value: Nullable<number>);
  30610. reset(): void;
  30611. apply(gl: WebGLRenderingContext): void;
  30612. }
  30613. }
  30614. declare module BABYLON {
  30615. /**
  30616. * @hidden
  30617. **/
  30618. export class StencilState {
  30619. /** 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 */
  30620. static readonly ALWAYS: number;
  30621. /** Passed to stencilOperation to specify that stencil value must be kept */
  30622. static readonly KEEP: number;
  30623. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30624. static readonly REPLACE: number;
  30625. private _isStencilTestDirty;
  30626. private _isStencilMaskDirty;
  30627. private _isStencilFuncDirty;
  30628. private _isStencilOpDirty;
  30629. private _stencilTest;
  30630. private _stencilMask;
  30631. private _stencilFunc;
  30632. private _stencilFuncRef;
  30633. private _stencilFuncMask;
  30634. private _stencilOpStencilFail;
  30635. private _stencilOpDepthFail;
  30636. private _stencilOpStencilDepthPass;
  30637. get isDirty(): boolean;
  30638. get stencilFunc(): number;
  30639. set stencilFunc(value: number);
  30640. get stencilFuncRef(): number;
  30641. set stencilFuncRef(value: number);
  30642. get stencilFuncMask(): number;
  30643. set stencilFuncMask(value: number);
  30644. get stencilOpStencilFail(): number;
  30645. set stencilOpStencilFail(value: number);
  30646. get stencilOpDepthFail(): number;
  30647. set stencilOpDepthFail(value: number);
  30648. get stencilOpStencilDepthPass(): number;
  30649. set stencilOpStencilDepthPass(value: number);
  30650. get stencilMask(): number;
  30651. set stencilMask(value: number);
  30652. get stencilTest(): boolean;
  30653. set stencilTest(value: boolean);
  30654. constructor();
  30655. reset(): void;
  30656. apply(gl: WebGLRenderingContext): void;
  30657. }
  30658. }
  30659. declare module BABYLON {
  30660. /**
  30661. * @hidden
  30662. **/
  30663. export class AlphaState {
  30664. private _isAlphaBlendDirty;
  30665. private _isBlendFunctionParametersDirty;
  30666. private _isBlendEquationParametersDirty;
  30667. private _isBlendConstantsDirty;
  30668. private _alphaBlend;
  30669. private _blendFunctionParameters;
  30670. private _blendEquationParameters;
  30671. private _blendConstants;
  30672. /**
  30673. * Initializes the state.
  30674. */
  30675. constructor();
  30676. get isDirty(): boolean;
  30677. get alphaBlend(): boolean;
  30678. set alphaBlend(value: boolean);
  30679. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30680. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30681. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30682. reset(): void;
  30683. apply(gl: WebGLRenderingContext): void;
  30684. }
  30685. }
  30686. declare module BABYLON {
  30687. /** @hidden */
  30688. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30689. attributeProcessor(attribute: string): string;
  30690. varyingProcessor(varying: string, isFragment: boolean): string;
  30691. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30692. }
  30693. }
  30694. declare module BABYLON {
  30695. /**
  30696. * Interface for attribute information associated with buffer instanciation
  30697. */
  30698. export interface InstancingAttributeInfo {
  30699. /**
  30700. * Name of the GLSL attribute
  30701. * if attribute index is not specified, this is used to retrieve the index from the effect
  30702. */
  30703. attributeName: string;
  30704. /**
  30705. * Index/offset of the attribute in the vertex shader
  30706. * if not specified, this will be computes from the name.
  30707. */
  30708. index?: number;
  30709. /**
  30710. * size of the attribute, 1, 2, 3 or 4
  30711. */
  30712. attributeSize: number;
  30713. /**
  30714. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30715. */
  30716. offset: number;
  30717. /**
  30718. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30719. * default to 1
  30720. */
  30721. divisor?: number;
  30722. /**
  30723. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30724. * default is FLOAT
  30725. */
  30726. attributeType?: number;
  30727. /**
  30728. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30729. */
  30730. normalized?: boolean;
  30731. }
  30732. }
  30733. declare module BABYLON {
  30734. interface ThinEngine {
  30735. /**
  30736. * Update a video texture
  30737. * @param texture defines the texture to update
  30738. * @param video defines the video element to use
  30739. * @param invertY defines if data must be stored with Y axis inverted
  30740. */
  30741. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30742. }
  30743. }
  30744. declare module BABYLON {
  30745. /**
  30746. * Settings for finer control over video usage
  30747. */
  30748. export interface VideoTextureSettings {
  30749. /**
  30750. * Applies `autoplay` to video, if specified
  30751. */
  30752. autoPlay?: boolean;
  30753. /**
  30754. * Applies `loop` to video, if specified
  30755. */
  30756. loop?: boolean;
  30757. /**
  30758. * Automatically updates internal texture from video at every frame in the render loop
  30759. */
  30760. autoUpdateTexture: boolean;
  30761. /**
  30762. * Image src displayed during the video loading or until the user interacts with the video.
  30763. */
  30764. poster?: string;
  30765. }
  30766. /**
  30767. * If you want to display a video in your scene, this is the special texture for that.
  30768. * This special texture works similar to other textures, with the exception of a few parameters.
  30769. * @see https://doc.babylonjs.com/how_to/video_texture
  30770. */
  30771. export class VideoTexture extends Texture {
  30772. /**
  30773. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30774. */
  30775. readonly autoUpdateTexture: boolean;
  30776. /**
  30777. * The video instance used by the texture internally
  30778. */
  30779. readonly video: HTMLVideoElement;
  30780. private _onUserActionRequestedObservable;
  30781. /**
  30782. * Event triggerd when a dom action is required by the user to play the video.
  30783. * This happens due to recent changes in browser policies preventing video to auto start.
  30784. */
  30785. get onUserActionRequestedObservable(): Observable<Texture>;
  30786. private _generateMipMaps;
  30787. private _engine;
  30788. private _stillImageCaptured;
  30789. private _displayingPosterTexture;
  30790. private _settings;
  30791. private _createInternalTextureOnEvent;
  30792. private _frameId;
  30793. private _currentSrc;
  30794. /**
  30795. * Creates a video texture.
  30796. * If you want to display a video in your scene, this is the special texture for that.
  30797. * This special texture works similar to other textures, with the exception of a few parameters.
  30798. * @see https://doc.babylonjs.com/how_to/video_texture
  30799. * @param name optional name, will detect from video source, if not defined
  30800. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30801. * @param scene is obviously the current scene.
  30802. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30803. * @param invertY is false by default but can be used to invert video on Y axis
  30804. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30805. * @param settings allows finer control over video usage
  30806. */
  30807. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30808. private _getName;
  30809. private _getVideo;
  30810. private _createInternalTexture;
  30811. private reset;
  30812. /**
  30813. * @hidden Internal method to initiate `update`.
  30814. */
  30815. _rebuild(): void;
  30816. /**
  30817. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30818. */
  30819. update(): void;
  30820. /**
  30821. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30822. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30823. */
  30824. updateTexture(isVisible: boolean): void;
  30825. protected _updateInternalTexture: () => void;
  30826. /**
  30827. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30828. * @param url New url.
  30829. */
  30830. updateURL(url: string): void;
  30831. /**
  30832. * Clones the texture.
  30833. * @returns the cloned texture
  30834. */
  30835. clone(): VideoTexture;
  30836. /**
  30837. * Dispose the texture and release its associated resources.
  30838. */
  30839. dispose(): void;
  30840. /**
  30841. * Creates a video texture straight from a stream.
  30842. * @param scene Define the scene the texture should be created in
  30843. * @param stream Define the stream the texture should be created from
  30844. * @returns The created video texture as a promise
  30845. */
  30846. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30847. /**
  30848. * Creates a video texture straight from your WebCam video feed.
  30849. * @param scene Define the scene the texture should be created in
  30850. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30851. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30852. * @returns The created video texture as a promise
  30853. */
  30854. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30855. minWidth: number;
  30856. maxWidth: number;
  30857. minHeight: number;
  30858. maxHeight: number;
  30859. deviceId: string;
  30860. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30861. /**
  30862. * Creates a video texture straight from your WebCam video feed.
  30863. * @param scene Define the scene the texture should be created in
  30864. * @param onReady Define a callback to triggered once the texture will be ready
  30865. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30866. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30867. */
  30868. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30869. minWidth: number;
  30870. maxWidth: number;
  30871. minHeight: number;
  30872. maxHeight: number;
  30873. deviceId: string;
  30874. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30875. }
  30876. }
  30877. declare module BABYLON {
  30878. /**
  30879. * Defines the interface used by objects working like Scene
  30880. * @hidden
  30881. */
  30882. export interface ISceneLike {
  30883. _addPendingData(data: any): void;
  30884. _removePendingData(data: any): void;
  30885. offlineProvider: IOfflineProvider;
  30886. }
  30887. /** Interface defining initialization parameters for Engine class */
  30888. export interface EngineOptions extends WebGLContextAttributes {
  30889. /**
  30890. * Defines if the engine should no exceed a specified device ratio
  30891. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30892. */
  30893. limitDeviceRatio?: number;
  30894. /**
  30895. * Defines if webvr should be enabled automatically
  30896. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30897. */
  30898. autoEnableWebVR?: boolean;
  30899. /**
  30900. * Defines if webgl2 should be turned off even if supported
  30901. * @see http://doc.babylonjs.com/features/webgl2
  30902. */
  30903. disableWebGL2Support?: boolean;
  30904. /**
  30905. * Defines if webaudio should be initialized as well
  30906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30907. */
  30908. audioEngine?: boolean;
  30909. /**
  30910. * Defines if animations should run using a deterministic lock step
  30911. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30912. */
  30913. deterministicLockstep?: boolean;
  30914. /** Defines the maximum steps to use with deterministic lock step mode */
  30915. lockstepMaxSteps?: number;
  30916. /** Defines the seconds between each deterministic lock step */
  30917. timeStep?: number;
  30918. /**
  30919. * Defines that engine should ignore context lost events
  30920. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30921. */
  30922. doNotHandleContextLost?: boolean;
  30923. /**
  30924. * Defines that engine should ignore modifying touch action attribute and style
  30925. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30926. */
  30927. doNotHandleTouchAction?: boolean;
  30928. /**
  30929. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30930. */
  30931. useHighPrecisionFloats?: boolean;
  30932. }
  30933. /**
  30934. * The base engine class (root of all engines)
  30935. */
  30936. export class ThinEngine {
  30937. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30938. static ExceptionList: ({
  30939. key: string;
  30940. capture: string;
  30941. captureConstraint: number;
  30942. targets: string[];
  30943. } | {
  30944. key: string;
  30945. capture: null;
  30946. captureConstraint: null;
  30947. targets: string[];
  30948. })[];
  30949. /** @hidden */
  30950. static _TextureLoaders: IInternalTextureLoader[];
  30951. /**
  30952. * Returns the current npm package of the sdk
  30953. */
  30954. static get NpmPackage(): string;
  30955. /**
  30956. * Returns the current version of the framework
  30957. */
  30958. static get Version(): string;
  30959. /**
  30960. * Returns a string describing the current engine
  30961. */
  30962. get description(): string;
  30963. /**
  30964. * Gets or sets the epsilon value used by collision engine
  30965. */
  30966. static CollisionsEpsilon: number;
  30967. /**
  30968. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30969. */
  30970. static get ShadersRepository(): string;
  30971. static set ShadersRepository(value: string);
  30972. /** @hidden */
  30973. _shaderProcessor: IShaderProcessor;
  30974. /**
  30975. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30976. */
  30977. forcePOTTextures: boolean;
  30978. /**
  30979. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30980. */
  30981. isFullscreen: boolean;
  30982. /**
  30983. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30984. */
  30985. cullBackFaces: boolean;
  30986. /**
  30987. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30988. */
  30989. renderEvenInBackground: boolean;
  30990. /**
  30991. * Gets or sets a boolean indicating that cache can be kept between frames
  30992. */
  30993. preventCacheWipeBetweenFrames: boolean;
  30994. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30995. validateShaderPrograms: boolean;
  30996. /**
  30997. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30998. * This can provide greater z depth for distant objects.
  30999. */
  31000. useReverseDepthBuffer: boolean;
  31001. /**
  31002. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31003. */
  31004. disableUniformBuffers: boolean;
  31005. /** @hidden */
  31006. _uniformBuffers: UniformBuffer[];
  31007. /**
  31008. * Gets a boolean indicating that the engine supports uniform buffers
  31009. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31010. */
  31011. get supportsUniformBuffers(): boolean;
  31012. /** @hidden */
  31013. _gl: WebGLRenderingContext;
  31014. /** @hidden */
  31015. _webGLVersion: number;
  31016. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31017. protected _windowIsBackground: boolean;
  31018. protected _creationOptions: EngineOptions;
  31019. protected _highPrecisionShadersAllowed: boolean;
  31020. /** @hidden */
  31021. get _shouldUseHighPrecisionShader(): boolean;
  31022. /**
  31023. * Gets a boolean indicating that only power of 2 textures are supported
  31024. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31025. */
  31026. get needPOTTextures(): boolean;
  31027. /** @hidden */
  31028. _badOS: boolean;
  31029. /** @hidden */
  31030. _badDesktopOS: boolean;
  31031. private _hardwareScalingLevel;
  31032. /** @hidden */
  31033. _caps: EngineCapabilities;
  31034. private _isStencilEnable;
  31035. private _glVersion;
  31036. private _glRenderer;
  31037. private _glVendor;
  31038. /** @hidden */
  31039. _videoTextureSupported: boolean;
  31040. protected _renderingQueueLaunched: boolean;
  31041. protected _activeRenderLoops: (() => void)[];
  31042. /**
  31043. * Observable signaled when a context lost event is raised
  31044. */
  31045. onContextLostObservable: Observable<ThinEngine>;
  31046. /**
  31047. * Observable signaled when a context restored event is raised
  31048. */
  31049. onContextRestoredObservable: Observable<ThinEngine>;
  31050. private _onContextLost;
  31051. private _onContextRestored;
  31052. protected _contextWasLost: boolean;
  31053. /** @hidden */
  31054. _doNotHandleContextLost: boolean;
  31055. /**
  31056. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31058. */
  31059. get doNotHandleContextLost(): boolean;
  31060. set doNotHandleContextLost(value: boolean);
  31061. /**
  31062. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31063. */
  31064. disableVertexArrayObjects: boolean;
  31065. /** @hidden */
  31066. protected _colorWrite: boolean;
  31067. /** @hidden */
  31068. protected _colorWriteChanged: boolean;
  31069. /** @hidden */
  31070. protected _depthCullingState: DepthCullingState;
  31071. /** @hidden */
  31072. protected _stencilState: StencilState;
  31073. /** @hidden */
  31074. _alphaState: AlphaState;
  31075. /** @hidden */
  31076. _alphaMode: number;
  31077. /** @hidden */
  31078. _alphaEquation: number;
  31079. /** @hidden */
  31080. _internalTexturesCache: InternalTexture[];
  31081. /** @hidden */
  31082. protected _activeChannel: number;
  31083. private _currentTextureChannel;
  31084. /** @hidden */
  31085. protected _boundTexturesCache: {
  31086. [key: string]: Nullable<InternalTexture>;
  31087. };
  31088. /** @hidden */
  31089. protected _currentEffect: Nullable<Effect>;
  31090. /** @hidden */
  31091. protected _currentProgram: Nullable<WebGLProgram>;
  31092. private _compiledEffects;
  31093. private _vertexAttribArraysEnabled;
  31094. /** @hidden */
  31095. protected _cachedViewport: Nullable<IViewportLike>;
  31096. private _cachedVertexArrayObject;
  31097. /** @hidden */
  31098. protected _cachedVertexBuffers: any;
  31099. /** @hidden */
  31100. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31101. /** @hidden */
  31102. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31103. /** @hidden */
  31104. _currentRenderTarget: Nullable<InternalTexture>;
  31105. private _uintIndicesCurrentlySet;
  31106. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31107. /** @hidden */
  31108. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31109. private _currentBufferPointers;
  31110. private _currentInstanceLocations;
  31111. private _currentInstanceBuffers;
  31112. private _textureUnits;
  31113. /** @hidden */
  31114. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31115. /** @hidden */
  31116. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31117. /** @hidden */
  31118. _boundRenderFunction: any;
  31119. private _vaoRecordInProgress;
  31120. private _mustWipeVertexAttributes;
  31121. private _emptyTexture;
  31122. private _emptyCubeTexture;
  31123. private _emptyTexture3D;
  31124. private _emptyTexture2DArray;
  31125. /** @hidden */
  31126. _frameHandler: number;
  31127. private _nextFreeTextureSlots;
  31128. private _maxSimultaneousTextures;
  31129. private _activeRequests;
  31130. protected _texturesSupported: string[];
  31131. /** @hidden */
  31132. _textureFormatInUse: Nullable<string>;
  31133. protected get _supportsHardwareTextureRescaling(): boolean;
  31134. private _framebufferDimensionsObject;
  31135. /**
  31136. * sets the object from which width and height will be taken from when getting render width and height
  31137. * Will fallback to the gl object
  31138. * @param dimensions the framebuffer width and height that will be used.
  31139. */
  31140. set framebufferDimensionsObject(dimensions: Nullable<{
  31141. framebufferWidth: number;
  31142. framebufferHeight: number;
  31143. }>);
  31144. /**
  31145. * Gets the list of texture formats supported
  31146. */
  31147. get texturesSupported(): Array<string>;
  31148. /**
  31149. * Gets the list of texture formats in use
  31150. */
  31151. get textureFormatInUse(): Nullable<string>;
  31152. /**
  31153. * Gets the current viewport
  31154. */
  31155. get currentViewport(): Nullable<IViewportLike>;
  31156. /**
  31157. * Gets the default empty texture
  31158. */
  31159. get emptyTexture(): InternalTexture;
  31160. /**
  31161. * Gets the default empty 3D texture
  31162. */
  31163. get emptyTexture3D(): InternalTexture;
  31164. /**
  31165. * Gets the default empty 2D array texture
  31166. */
  31167. get emptyTexture2DArray(): InternalTexture;
  31168. /**
  31169. * Gets the default empty cube texture
  31170. */
  31171. get emptyCubeTexture(): InternalTexture;
  31172. /**
  31173. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31174. */
  31175. readonly premultipliedAlpha: boolean;
  31176. /**
  31177. * Observable event triggered before each texture is initialized
  31178. */
  31179. onBeforeTextureInitObservable: Observable<Texture>;
  31180. /**
  31181. * Creates a new engine
  31182. * @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
  31183. * @param antialias defines enable antialiasing (default: false)
  31184. * @param options defines further options to be sent to the getContext() function
  31185. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31186. */
  31187. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31188. private _rebuildInternalTextures;
  31189. private _rebuildEffects;
  31190. /**
  31191. * Gets a boolean indicating if all created effects are ready
  31192. * @returns true if all effects are ready
  31193. */
  31194. areAllEffectsReady(): boolean;
  31195. protected _rebuildBuffers(): void;
  31196. private _initGLContext;
  31197. /**
  31198. * Gets version of the current webGL context
  31199. */
  31200. get webGLVersion(): number;
  31201. /**
  31202. * Gets a string idenfifying the name of the class
  31203. * @returns "Engine" string
  31204. */
  31205. getClassName(): string;
  31206. /**
  31207. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31208. */
  31209. get isStencilEnable(): boolean;
  31210. /** @hidden */
  31211. _prepareWorkingCanvas(): void;
  31212. /**
  31213. * Reset the texture cache to empty state
  31214. */
  31215. resetTextureCache(): void;
  31216. /**
  31217. * Gets an object containing information about the current webGL context
  31218. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31219. */
  31220. getGlInfo(): {
  31221. vendor: string;
  31222. renderer: string;
  31223. version: string;
  31224. };
  31225. /**
  31226. * Defines the hardware scaling level.
  31227. * By default the hardware scaling level is computed from the window device ratio.
  31228. * 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.
  31229. * @param level defines the level to use
  31230. */
  31231. setHardwareScalingLevel(level: number): void;
  31232. /**
  31233. * Gets the current hardware scaling level.
  31234. * By default the hardware scaling level is computed from the window device ratio.
  31235. * 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.
  31236. * @returns a number indicating the current hardware scaling level
  31237. */
  31238. getHardwareScalingLevel(): number;
  31239. /**
  31240. * Gets the list of loaded textures
  31241. * @returns an array containing all loaded textures
  31242. */
  31243. getLoadedTexturesCache(): InternalTexture[];
  31244. /**
  31245. * Gets the object containing all engine capabilities
  31246. * @returns the EngineCapabilities object
  31247. */
  31248. getCaps(): EngineCapabilities;
  31249. /**
  31250. * stop executing a render loop function and remove it from the execution array
  31251. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31252. */
  31253. stopRenderLoop(renderFunction?: () => void): void;
  31254. /** @hidden */
  31255. _renderLoop(): void;
  31256. /**
  31257. * Gets the HTML canvas attached with the current webGL context
  31258. * @returns a HTML canvas
  31259. */
  31260. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31261. /**
  31262. * Gets host window
  31263. * @returns the host window object
  31264. */
  31265. getHostWindow(): Nullable<Window>;
  31266. /**
  31267. * Gets the current render width
  31268. * @param useScreen defines if screen size must be used (or the current render target if any)
  31269. * @returns a number defining the current render width
  31270. */
  31271. getRenderWidth(useScreen?: boolean): number;
  31272. /**
  31273. * Gets the current render height
  31274. * @param useScreen defines if screen size must be used (or the current render target if any)
  31275. * @returns a number defining the current render height
  31276. */
  31277. getRenderHeight(useScreen?: boolean): number;
  31278. /**
  31279. * Can be used to override the current requestAnimationFrame requester.
  31280. * @hidden
  31281. */
  31282. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31283. /**
  31284. * Register and execute a render loop. The engine can have more than one render function
  31285. * @param renderFunction defines the function to continuously execute
  31286. */
  31287. runRenderLoop(renderFunction: () => void): void;
  31288. /**
  31289. * Clear the current render buffer or the current render target (if any is set up)
  31290. * @param color defines the color to use
  31291. * @param backBuffer defines if the back buffer must be cleared
  31292. * @param depth defines if the depth buffer must be cleared
  31293. * @param stencil defines if the stencil buffer must be cleared
  31294. */
  31295. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31296. private _viewportCached;
  31297. /** @hidden */
  31298. _viewport(x: number, y: number, width: number, height: number): void;
  31299. /**
  31300. * Set the WebGL's viewport
  31301. * @param viewport defines the viewport element to be used
  31302. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31303. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31304. */
  31305. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31306. /**
  31307. * Begin a new frame
  31308. */
  31309. beginFrame(): void;
  31310. /**
  31311. * Enf the current frame
  31312. */
  31313. endFrame(): void;
  31314. /**
  31315. * Resize the view according to the canvas' size
  31316. */
  31317. resize(): void;
  31318. /**
  31319. * Force a specific size of the canvas
  31320. * @param width defines the new canvas' width
  31321. * @param height defines the new canvas' height
  31322. */
  31323. setSize(width: number, height: number): void;
  31324. /**
  31325. * Binds the frame buffer to the specified texture.
  31326. * @param texture The texture to render to or null for the default canvas
  31327. * @param faceIndex The face of the texture to render to in case of cube texture
  31328. * @param requiredWidth The width of the target to render to
  31329. * @param requiredHeight The height of the target to render to
  31330. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31331. * @param lodLevel defines the lod level to bind to the frame buffer
  31332. * @param layer defines the 2d array index to bind to frame buffer to
  31333. */
  31334. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31335. /** @hidden */
  31336. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31337. /**
  31338. * Unbind the current render target texture from the webGL context
  31339. * @param texture defines the render target texture to unbind
  31340. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31341. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31342. */
  31343. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31344. /**
  31345. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31346. */
  31347. flushFramebuffer(): void;
  31348. /**
  31349. * Unbind the current render target and bind the default framebuffer
  31350. */
  31351. restoreDefaultFramebuffer(): void;
  31352. /** @hidden */
  31353. protected _resetVertexBufferBinding(): void;
  31354. /**
  31355. * Creates a vertex buffer
  31356. * @param data the data for the vertex buffer
  31357. * @returns the new WebGL static buffer
  31358. */
  31359. createVertexBuffer(data: DataArray): DataBuffer;
  31360. private _createVertexBuffer;
  31361. /**
  31362. * Creates a dynamic vertex buffer
  31363. * @param data the data for the dynamic vertex buffer
  31364. * @returns the new WebGL dynamic buffer
  31365. */
  31366. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31367. protected _resetIndexBufferBinding(): void;
  31368. /**
  31369. * Creates a new index buffer
  31370. * @param indices defines the content of the index buffer
  31371. * @param updatable defines if the index buffer must be updatable
  31372. * @returns a new webGL buffer
  31373. */
  31374. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31375. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31376. /**
  31377. * Bind a webGL buffer to the webGL context
  31378. * @param buffer defines the buffer to bind
  31379. */
  31380. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31381. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31382. private bindBuffer;
  31383. /**
  31384. * update the bound buffer with the given data
  31385. * @param data defines the data to update
  31386. */
  31387. updateArrayBuffer(data: Float32Array): void;
  31388. private _vertexAttribPointer;
  31389. /** @hidden */
  31390. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31391. private _bindVertexBuffersAttributes;
  31392. /**
  31393. * Records a vertex array object
  31394. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31395. * @param vertexBuffers defines the list of vertex buffers to store
  31396. * @param indexBuffer defines the index buffer to store
  31397. * @param effect defines the effect to store
  31398. * @returns the new vertex array object
  31399. */
  31400. recordVertexArrayObject(vertexBuffers: {
  31401. [key: string]: VertexBuffer;
  31402. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31403. /**
  31404. * Bind a specific vertex array object
  31405. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31406. * @param vertexArrayObject defines the vertex array object to bind
  31407. * @param indexBuffer defines the index buffer to bind
  31408. */
  31409. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31410. /**
  31411. * Bind webGl buffers directly to the webGL context
  31412. * @param vertexBuffer defines the vertex buffer to bind
  31413. * @param indexBuffer defines the index buffer to bind
  31414. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31415. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31416. * @param effect defines the effect associated with the vertex buffer
  31417. */
  31418. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31419. private _unbindVertexArrayObject;
  31420. /**
  31421. * Bind a list of vertex buffers to the webGL context
  31422. * @param vertexBuffers defines the list of vertex buffers to bind
  31423. * @param indexBuffer defines the index buffer to bind
  31424. * @param effect defines the effect associated with the vertex buffers
  31425. */
  31426. bindBuffers(vertexBuffers: {
  31427. [key: string]: Nullable<VertexBuffer>;
  31428. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31429. /**
  31430. * Unbind all instance attributes
  31431. */
  31432. unbindInstanceAttributes(): void;
  31433. /**
  31434. * Release and free the memory of a vertex array object
  31435. * @param vao defines the vertex array object to delete
  31436. */
  31437. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31438. /** @hidden */
  31439. _releaseBuffer(buffer: DataBuffer): boolean;
  31440. protected _deleteBuffer(buffer: DataBuffer): void;
  31441. /**
  31442. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31443. * @param instancesBuffer defines the webGL buffer to update and bind
  31444. * @param data defines the data to store in the buffer
  31445. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31446. */
  31447. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31448. /**
  31449. * Bind the content of a webGL buffer used with instantiation
  31450. * @param instancesBuffer defines the webGL buffer to bind
  31451. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31452. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31453. */
  31454. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31455. /**
  31456. * Disable the instance attribute corresponding to the name in parameter
  31457. * @param name defines the name of the attribute to disable
  31458. */
  31459. disableInstanceAttributeByName(name: string): void;
  31460. /**
  31461. * Disable the instance attribute corresponding to the location in parameter
  31462. * @param attributeLocation defines the attribute location of the attribute to disable
  31463. */
  31464. disableInstanceAttribute(attributeLocation: number): void;
  31465. /**
  31466. * Disable the attribute corresponding to the location in parameter
  31467. * @param attributeLocation defines the attribute location of the attribute to disable
  31468. */
  31469. disableAttributeByIndex(attributeLocation: number): void;
  31470. /**
  31471. * Send a draw order
  31472. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31473. * @param indexStart defines the starting index
  31474. * @param indexCount defines the number of index to draw
  31475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31476. */
  31477. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31478. /**
  31479. * Draw a list of points
  31480. * @param verticesStart defines the index of first vertex to draw
  31481. * @param verticesCount defines the count of vertices to draw
  31482. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31483. */
  31484. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31485. /**
  31486. * Draw a list of unindexed primitives
  31487. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31488. * @param verticesStart defines the index of first vertex to draw
  31489. * @param verticesCount defines the count of vertices to draw
  31490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31491. */
  31492. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31493. /**
  31494. * Draw a list of indexed primitives
  31495. * @param fillMode defines the primitive to use
  31496. * @param indexStart defines the starting index
  31497. * @param indexCount defines the number of index to draw
  31498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31499. */
  31500. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31501. /**
  31502. * Draw a list of unindexed primitives
  31503. * @param fillMode defines the primitive to use
  31504. * @param verticesStart defines the index of first vertex to draw
  31505. * @param verticesCount defines the count of vertices to draw
  31506. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31507. */
  31508. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31509. private _drawMode;
  31510. /** @hidden */
  31511. protected _reportDrawCall(): void;
  31512. /** @hidden */
  31513. _releaseEffect(effect: Effect): void;
  31514. /** @hidden */
  31515. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31516. /**
  31517. * Create a new effect (used to store vertex/fragment shaders)
  31518. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31519. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31520. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31521. * @param samplers defines an array of string used to represent textures
  31522. * @param defines defines the string containing the defines to use to compile the shaders
  31523. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31524. * @param onCompiled defines a function to call when the effect creation is successful
  31525. * @param onError defines a function to call when the effect creation has failed
  31526. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31527. * @returns the new Effect
  31528. */
  31529. 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;
  31530. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31531. private _compileShader;
  31532. private _compileRawShader;
  31533. /**
  31534. * Directly creates a webGL program
  31535. * @param pipelineContext defines the pipeline context to attach to
  31536. * @param vertexCode defines the vertex shader code to use
  31537. * @param fragmentCode defines the fragment shader code to use
  31538. * @param context defines the webGL context to use (if not set, the current one will be used)
  31539. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31540. * @returns the new webGL program
  31541. */
  31542. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31543. /**
  31544. * Creates a webGL program
  31545. * @param pipelineContext defines the pipeline context to attach to
  31546. * @param vertexCode defines the vertex shader code to use
  31547. * @param fragmentCode defines the fragment shader code to use
  31548. * @param defines defines the string containing the defines to use to compile the shaders
  31549. * @param context defines the webGL context to use (if not set, the current one will be used)
  31550. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31551. * @returns the new webGL program
  31552. */
  31553. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31554. /**
  31555. * Creates a new pipeline context
  31556. * @returns the new pipeline
  31557. */
  31558. createPipelineContext(): IPipelineContext;
  31559. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31560. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31561. /** @hidden */
  31562. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31563. /** @hidden */
  31564. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31565. /** @hidden */
  31566. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31567. /**
  31568. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31569. * @param pipelineContext defines the pipeline context to use
  31570. * @param uniformsNames defines the list of uniform names
  31571. * @returns an array of webGL uniform locations
  31572. */
  31573. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31574. /**
  31575. * Gets the lsit of active attributes for a given webGL program
  31576. * @param pipelineContext defines the pipeline context to use
  31577. * @param attributesNames defines the list of attribute names to get
  31578. * @returns an array of indices indicating the offset of each attribute
  31579. */
  31580. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31581. /**
  31582. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31583. * @param effect defines the effect to activate
  31584. */
  31585. enableEffect(effect: Nullable<Effect>): void;
  31586. /**
  31587. * Set the value of an uniform to a number (int)
  31588. * @param uniform defines the webGL uniform location where to store the value
  31589. * @param value defines the int number to store
  31590. */
  31591. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31592. /**
  31593. * Set the value of an uniform to an array of int32
  31594. * @param uniform defines the webGL uniform location where to store the value
  31595. * @param array defines the array of int32 to store
  31596. */
  31597. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31598. /**
  31599. * Set the value of an uniform to an array of int32 (stored as vec2)
  31600. * @param uniform defines the webGL uniform location where to store the value
  31601. * @param array defines the array of int32 to store
  31602. */
  31603. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31604. /**
  31605. * Set the value of an uniform to an array of int32 (stored as vec3)
  31606. * @param uniform defines the webGL uniform location where to store the value
  31607. * @param array defines the array of int32 to store
  31608. */
  31609. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31610. /**
  31611. * Set the value of an uniform to an array of int32 (stored as vec4)
  31612. * @param uniform defines the webGL uniform location where to store the value
  31613. * @param array defines the array of int32 to store
  31614. */
  31615. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31616. /**
  31617. * Set the value of an uniform to an array of number
  31618. * @param uniform defines the webGL uniform location where to store the value
  31619. * @param array defines the array of number to store
  31620. */
  31621. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31622. /**
  31623. * Set the value of an uniform to an array of number (stored as vec2)
  31624. * @param uniform defines the webGL uniform location where to store the value
  31625. * @param array defines the array of number to store
  31626. */
  31627. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31628. /**
  31629. * Set the value of an uniform to an array of number (stored as vec3)
  31630. * @param uniform defines the webGL uniform location where to store the value
  31631. * @param array defines the array of number to store
  31632. */
  31633. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31634. /**
  31635. * Set the value of an uniform to an array of number (stored as vec4)
  31636. * @param uniform defines the webGL uniform location where to store the value
  31637. * @param array defines the array of number to store
  31638. */
  31639. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31640. /**
  31641. * Set the value of an uniform to an array of float32 (stored as matrices)
  31642. * @param uniform defines the webGL uniform location where to store the value
  31643. * @param matrices defines the array of float32 to store
  31644. */
  31645. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31646. /**
  31647. * Set the value of an uniform to a matrix (3x3)
  31648. * @param uniform defines the webGL uniform location where to store the value
  31649. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31650. */
  31651. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31652. /**
  31653. * Set the value of an uniform to a matrix (2x2)
  31654. * @param uniform defines the webGL uniform location where to store the value
  31655. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31656. */
  31657. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31658. /**
  31659. * Set the value of an uniform to a number (float)
  31660. * @param uniform defines the webGL uniform location where to store the value
  31661. * @param value defines the float number to store
  31662. */
  31663. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31664. /**
  31665. * Set the value of an uniform to a vec2
  31666. * @param uniform defines the webGL uniform location where to store the value
  31667. * @param x defines the 1st component of the value
  31668. * @param y defines the 2nd component of the value
  31669. */
  31670. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31671. /**
  31672. * Set the value of an uniform to a vec3
  31673. * @param uniform defines the webGL uniform location where to store the value
  31674. * @param x defines the 1st component of the value
  31675. * @param y defines the 2nd component of the value
  31676. * @param z defines the 3rd component of the value
  31677. */
  31678. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31679. /**
  31680. * Set the value of an uniform to a vec4
  31681. * @param uniform defines the webGL uniform location where to store the value
  31682. * @param x defines the 1st component of the value
  31683. * @param y defines the 2nd component of the value
  31684. * @param z defines the 3rd component of the value
  31685. * @param w defines the 4th component of the value
  31686. */
  31687. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31688. /**
  31689. * Apply all cached states (depth, culling, stencil and alpha)
  31690. */
  31691. applyStates(): void;
  31692. /**
  31693. * Enable or disable color writing
  31694. * @param enable defines the state to set
  31695. */
  31696. setColorWrite(enable: boolean): void;
  31697. /**
  31698. * Gets a boolean indicating if color writing is enabled
  31699. * @returns the current color writing state
  31700. */
  31701. getColorWrite(): boolean;
  31702. /**
  31703. * Gets the depth culling state manager
  31704. */
  31705. get depthCullingState(): DepthCullingState;
  31706. /**
  31707. * Gets the alpha state manager
  31708. */
  31709. get alphaState(): AlphaState;
  31710. /**
  31711. * Gets the stencil state manager
  31712. */
  31713. get stencilState(): StencilState;
  31714. /**
  31715. * Clears the list of texture accessible through engine.
  31716. * This can help preventing texture load conflict due to name collision.
  31717. */
  31718. clearInternalTexturesCache(): void;
  31719. /**
  31720. * Force the entire cache to be cleared
  31721. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31722. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31723. */
  31724. wipeCaches(bruteForce?: boolean): void;
  31725. /** @hidden */
  31726. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31727. min: number;
  31728. mag: number;
  31729. };
  31730. /** @hidden */
  31731. _createTexture(): WebGLTexture;
  31732. /**
  31733. * Usually called from Texture.ts.
  31734. * Passed information to create a WebGLTexture
  31735. * @param urlArg defines a value which contains one of the following:
  31736. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31737. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31738. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31739. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31740. * @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)
  31741. * @param scene needed for loading to the correct scene
  31742. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31743. * @param onLoad optional callback to be called upon successful completion
  31744. * @param onError optional callback to be called upon failure
  31745. * @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
  31746. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31747. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31748. * @param forcedExtension defines the extension to use to pick the right loader
  31749. * @param mimeType defines an optional mime type
  31750. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31751. */
  31752. 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;
  31753. /**
  31754. * Loads an image as an HTMLImageElement.
  31755. * @param input url string, ArrayBuffer, or Blob to load
  31756. * @param onLoad callback called when the image successfully loads
  31757. * @param onError callback called when the image fails to load
  31758. * @param offlineProvider offline provider for caching
  31759. * @param mimeType optional mime type
  31760. * @returns the HTMLImageElement of the loaded image
  31761. * @hidden
  31762. */
  31763. 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>;
  31764. /**
  31765. * @hidden
  31766. */
  31767. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31768. /**
  31769. * Creates a raw texture
  31770. * @param data defines the data to store in the texture
  31771. * @param width defines the width of the texture
  31772. * @param height defines the height of the texture
  31773. * @param format defines the format of the data
  31774. * @param generateMipMaps defines if the engine should generate the mip levels
  31775. * @param invertY defines if data must be stored with Y axis inverted
  31776. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31777. * @param compression defines the compression used (null by default)
  31778. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31779. * @returns the raw texture inside an InternalTexture
  31780. */
  31781. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31782. /**
  31783. * Creates a new raw cube texture
  31784. * @param data defines the array of data to use to create each face
  31785. * @param size defines the size of the textures
  31786. * @param format defines the format of the data
  31787. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31788. * @param generateMipMaps defines if the engine should generate the mip levels
  31789. * @param invertY defines if data must be stored with Y axis inverted
  31790. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31791. * @param compression defines the compression used (null by default)
  31792. * @returns the cube texture as an InternalTexture
  31793. */
  31794. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31795. /**
  31796. * Creates a new raw 3D texture
  31797. * @param data defines the data used to create the texture
  31798. * @param width defines the width of the texture
  31799. * @param height defines the height of the texture
  31800. * @param depth defines the depth of the texture
  31801. * @param format defines the format of the texture
  31802. * @param generateMipMaps defines if the engine must generate mip levels
  31803. * @param invertY defines if data must be stored with Y axis inverted
  31804. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31805. * @param compression defines the compressed used (can be null)
  31806. * @param textureType defines the compressed used (can be null)
  31807. * @returns a new raw 3D texture (stored in an InternalTexture)
  31808. */
  31809. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31810. /**
  31811. * Creates a new raw 2D array texture
  31812. * @param data defines the data used to create the texture
  31813. * @param width defines the width of the texture
  31814. * @param height defines the height of the texture
  31815. * @param depth defines the number of layers of the texture
  31816. * @param format defines the format of the texture
  31817. * @param generateMipMaps defines if the engine must generate mip levels
  31818. * @param invertY defines if data must be stored with Y axis inverted
  31819. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31820. * @param compression defines the compressed used (can be null)
  31821. * @param textureType defines the compressed used (can be null)
  31822. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31823. */
  31824. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31825. private _unpackFlipYCached;
  31826. /**
  31827. * In case you are sharing the context with other applications, it might
  31828. * be interested to not cache the unpack flip y state to ensure a consistent
  31829. * value would be set.
  31830. */
  31831. enableUnpackFlipYCached: boolean;
  31832. /** @hidden */
  31833. _unpackFlipY(value: boolean): void;
  31834. /** @hidden */
  31835. _getUnpackAlignement(): number;
  31836. private _getTextureTarget;
  31837. /**
  31838. * Update the sampling mode of a given texture
  31839. * @param samplingMode defines the required sampling mode
  31840. * @param texture defines the texture to update
  31841. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31842. */
  31843. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31844. /**
  31845. * Update the sampling mode of a given texture
  31846. * @param texture defines the texture to update
  31847. * @param wrapU defines the texture wrap mode of the u coordinates
  31848. * @param wrapV defines the texture wrap mode of the v coordinates
  31849. * @param wrapR defines the texture wrap mode of the r coordinates
  31850. */
  31851. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31852. /** @hidden */
  31853. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31854. width: number;
  31855. height: number;
  31856. layers?: number;
  31857. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31858. /** @hidden */
  31859. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31860. /** @hidden */
  31861. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31862. /**
  31863. * Update a portion of an internal texture
  31864. * @param texture defines the texture to update
  31865. * @param imageData defines the data to store into the texture
  31866. * @param xOffset defines the x coordinates of the update rectangle
  31867. * @param yOffset defines the y coordinates of the update rectangle
  31868. * @param width defines the width of the update rectangle
  31869. * @param height defines the height of the update rectangle
  31870. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31871. * @param lod defines the lod level to update (0 by default)
  31872. */
  31873. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31874. /** @hidden */
  31875. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31876. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31877. private _prepareWebGLTexture;
  31878. /** @hidden */
  31879. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31880. private _getDepthStencilBuffer;
  31881. /** @hidden */
  31882. _releaseFramebufferObjects(texture: InternalTexture): void;
  31883. /** @hidden */
  31884. _releaseTexture(texture: InternalTexture): void;
  31885. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31886. protected _setProgram(program: WebGLProgram): void;
  31887. protected _boundUniforms: {
  31888. [key: number]: WebGLUniformLocation;
  31889. };
  31890. /**
  31891. * Binds an effect to the webGL context
  31892. * @param effect defines the effect to bind
  31893. */
  31894. bindSamplers(effect: Effect): void;
  31895. private _activateCurrentTexture;
  31896. /** @hidden */
  31897. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31898. /** @hidden */
  31899. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31900. /**
  31901. * Unbind all textures from the webGL context
  31902. */
  31903. unbindAllTextures(): void;
  31904. /**
  31905. * Sets a texture to the according uniform.
  31906. * @param channel The texture channel
  31907. * @param uniform The uniform to set
  31908. * @param texture The texture to apply
  31909. */
  31910. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31911. private _bindSamplerUniformToChannel;
  31912. private _getTextureWrapMode;
  31913. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31914. /**
  31915. * Sets an array of texture to the webGL context
  31916. * @param channel defines the channel where the texture array must be set
  31917. * @param uniform defines the associated uniform location
  31918. * @param textures defines the array of textures to bind
  31919. */
  31920. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31921. /** @hidden */
  31922. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31923. private _setTextureParameterFloat;
  31924. private _setTextureParameterInteger;
  31925. /**
  31926. * Unbind all vertex attributes from the webGL context
  31927. */
  31928. unbindAllAttributes(): void;
  31929. /**
  31930. * 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
  31931. */
  31932. releaseEffects(): void;
  31933. /**
  31934. * Dispose and release all associated resources
  31935. */
  31936. dispose(): void;
  31937. /**
  31938. * Attach a new callback raised when context lost event is fired
  31939. * @param callback defines the callback to call
  31940. */
  31941. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31942. /**
  31943. * Attach a new callback raised when context restored event is fired
  31944. * @param callback defines the callback to call
  31945. */
  31946. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31947. /**
  31948. * Get the current error code of the webGL context
  31949. * @returns the error code
  31950. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31951. */
  31952. getError(): number;
  31953. private _canRenderToFloatFramebuffer;
  31954. private _canRenderToHalfFloatFramebuffer;
  31955. private _canRenderToFramebuffer;
  31956. /** @hidden */
  31957. _getWebGLTextureType(type: number): number;
  31958. /** @hidden */
  31959. _getInternalFormat(format: number): number;
  31960. /** @hidden */
  31961. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31962. /** @hidden */
  31963. _getRGBAMultiSampleBufferFormat(type: number): number;
  31964. /** @hidden */
  31965. _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;
  31966. /**
  31967. * Loads a file from a url
  31968. * @param url url to load
  31969. * @param onSuccess callback called when the file successfully loads
  31970. * @param onProgress callback called while file is loading (if the server supports this mode)
  31971. * @param offlineProvider defines the offline provider for caching
  31972. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31973. * @param onError callback called when the file fails to load
  31974. * @returns a file request object
  31975. * @hidden
  31976. */
  31977. 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;
  31978. /**
  31979. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31980. * @param x defines the x coordinate of the rectangle where pixels must be read
  31981. * @param y defines the y coordinate of the rectangle where pixels must be read
  31982. * @param width defines the width of the rectangle where pixels must be read
  31983. * @param height defines the height of the rectangle where pixels must be read
  31984. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  31985. * @returns a Uint8Array containing RGBA colors
  31986. */
  31987. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31988. private static _isSupported;
  31989. /**
  31990. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31991. * @returns true if the engine can be created
  31992. * @ignorenaming
  31993. */
  31994. static isSupported(): boolean;
  31995. /**
  31996. * Find the next highest power of two.
  31997. * @param x Number to start search from.
  31998. * @return Next highest power of two.
  31999. */
  32000. static CeilingPOT(x: number): number;
  32001. /**
  32002. * Find the next lowest power of two.
  32003. * @param x Number to start search from.
  32004. * @return Next lowest power of two.
  32005. */
  32006. static FloorPOT(x: number): number;
  32007. /**
  32008. * Find the nearest power of two.
  32009. * @param x Number to start search from.
  32010. * @return Next nearest power of two.
  32011. */
  32012. static NearestPOT(x: number): number;
  32013. /**
  32014. * Get the closest exponent of two
  32015. * @param value defines the value to approximate
  32016. * @param max defines the maximum value to return
  32017. * @param mode defines how to define the closest value
  32018. * @returns closest exponent of two of the given value
  32019. */
  32020. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32021. /**
  32022. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32023. * @param func - the function to be called
  32024. * @param requester - the object that will request the next frame. Falls back to window.
  32025. * @returns frame number
  32026. */
  32027. static QueueNewFrame(func: () => void, requester?: any): number;
  32028. /**
  32029. * Gets host document
  32030. * @returns the host document object
  32031. */
  32032. getHostDocument(): Nullable<Document>;
  32033. }
  32034. }
  32035. declare module BABYLON {
  32036. /**
  32037. * Class representing spherical harmonics coefficients to the 3rd degree
  32038. */
  32039. export class SphericalHarmonics {
  32040. /**
  32041. * Defines whether or not the harmonics have been prescaled for rendering.
  32042. */
  32043. preScaled: boolean;
  32044. /**
  32045. * The l0,0 coefficients of the spherical harmonics
  32046. */
  32047. l00: Vector3;
  32048. /**
  32049. * The l1,-1 coefficients of the spherical harmonics
  32050. */
  32051. l1_1: Vector3;
  32052. /**
  32053. * The l1,0 coefficients of the spherical harmonics
  32054. */
  32055. l10: Vector3;
  32056. /**
  32057. * The l1,1 coefficients of the spherical harmonics
  32058. */
  32059. l11: Vector3;
  32060. /**
  32061. * The l2,-2 coefficients of the spherical harmonics
  32062. */
  32063. l2_2: Vector3;
  32064. /**
  32065. * The l2,-1 coefficients of the spherical harmonics
  32066. */
  32067. l2_1: Vector3;
  32068. /**
  32069. * The l2,0 coefficients of the spherical harmonics
  32070. */
  32071. l20: Vector3;
  32072. /**
  32073. * The l2,1 coefficients of the spherical harmonics
  32074. */
  32075. l21: Vector3;
  32076. /**
  32077. * The l2,2 coefficients of the spherical harmonics
  32078. */
  32079. l22: Vector3;
  32080. /**
  32081. * Adds a light to the spherical harmonics
  32082. * @param direction the direction of the light
  32083. * @param color the color of the light
  32084. * @param deltaSolidAngle the delta solid angle of the light
  32085. */
  32086. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32087. /**
  32088. * Scales the spherical harmonics by the given amount
  32089. * @param scale the amount to scale
  32090. */
  32091. scaleInPlace(scale: number): void;
  32092. /**
  32093. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32094. *
  32095. * ```
  32096. * E_lm = A_l * L_lm
  32097. * ```
  32098. *
  32099. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32100. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32101. * the scaling factors are given in equation 9.
  32102. */
  32103. convertIncidentRadianceToIrradiance(): void;
  32104. /**
  32105. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32106. *
  32107. * ```
  32108. * L = (1/pi) * E * rho
  32109. * ```
  32110. *
  32111. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32112. */
  32113. convertIrradianceToLambertianRadiance(): void;
  32114. /**
  32115. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32116. * required operations at run time.
  32117. *
  32118. * This is simply done by scaling back the SH with Ylm constants parameter.
  32119. * The trigonometric part being applied by the shader at run time.
  32120. */
  32121. preScaleForRendering(): void;
  32122. /**
  32123. * Constructs a spherical harmonics from an array.
  32124. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32125. * @returns the spherical harmonics
  32126. */
  32127. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32128. /**
  32129. * Gets the spherical harmonics from polynomial
  32130. * @param polynomial the spherical polynomial
  32131. * @returns the spherical harmonics
  32132. */
  32133. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32134. }
  32135. /**
  32136. * Class representing spherical polynomial coefficients to the 3rd degree
  32137. */
  32138. export class SphericalPolynomial {
  32139. private _harmonics;
  32140. /**
  32141. * The spherical harmonics used to create the polynomials.
  32142. */
  32143. get preScaledHarmonics(): SphericalHarmonics;
  32144. /**
  32145. * The x coefficients of the spherical polynomial
  32146. */
  32147. x: Vector3;
  32148. /**
  32149. * The y coefficients of the spherical polynomial
  32150. */
  32151. y: Vector3;
  32152. /**
  32153. * The z coefficients of the spherical polynomial
  32154. */
  32155. z: Vector3;
  32156. /**
  32157. * The xx coefficients of the spherical polynomial
  32158. */
  32159. xx: Vector3;
  32160. /**
  32161. * The yy coefficients of the spherical polynomial
  32162. */
  32163. yy: Vector3;
  32164. /**
  32165. * The zz coefficients of the spherical polynomial
  32166. */
  32167. zz: Vector3;
  32168. /**
  32169. * The xy coefficients of the spherical polynomial
  32170. */
  32171. xy: Vector3;
  32172. /**
  32173. * The yz coefficients of the spherical polynomial
  32174. */
  32175. yz: Vector3;
  32176. /**
  32177. * The zx coefficients of the spherical polynomial
  32178. */
  32179. zx: Vector3;
  32180. /**
  32181. * Adds an ambient color to the spherical polynomial
  32182. * @param color the color to add
  32183. */
  32184. addAmbient(color: Color3): void;
  32185. /**
  32186. * Scales the spherical polynomial by the given amount
  32187. * @param scale the amount to scale
  32188. */
  32189. scaleInPlace(scale: number): void;
  32190. /**
  32191. * Gets the spherical polynomial from harmonics
  32192. * @param harmonics the spherical harmonics
  32193. * @returns the spherical polynomial
  32194. */
  32195. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32196. /**
  32197. * Constructs a spherical polynomial from an array.
  32198. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32199. * @returns the spherical polynomial
  32200. */
  32201. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32202. }
  32203. }
  32204. declare module BABYLON {
  32205. /**
  32206. * Defines the source of the internal texture
  32207. */
  32208. export enum InternalTextureSource {
  32209. /**
  32210. * The source of the texture data is unknown
  32211. */
  32212. Unknown = 0,
  32213. /**
  32214. * Texture data comes from an URL
  32215. */
  32216. Url = 1,
  32217. /**
  32218. * Texture data is only used for temporary storage
  32219. */
  32220. Temp = 2,
  32221. /**
  32222. * Texture data comes from raw data (ArrayBuffer)
  32223. */
  32224. Raw = 3,
  32225. /**
  32226. * Texture content is dynamic (video or dynamic texture)
  32227. */
  32228. Dynamic = 4,
  32229. /**
  32230. * Texture content is generated by rendering to it
  32231. */
  32232. RenderTarget = 5,
  32233. /**
  32234. * Texture content is part of a multi render target process
  32235. */
  32236. MultiRenderTarget = 6,
  32237. /**
  32238. * Texture data comes from a cube data file
  32239. */
  32240. Cube = 7,
  32241. /**
  32242. * Texture data comes from a raw cube data
  32243. */
  32244. CubeRaw = 8,
  32245. /**
  32246. * Texture data come from a prefiltered cube data file
  32247. */
  32248. CubePrefiltered = 9,
  32249. /**
  32250. * Texture content is raw 3D data
  32251. */
  32252. Raw3D = 10,
  32253. /**
  32254. * Texture content is raw 2D array data
  32255. */
  32256. Raw2DArray = 11,
  32257. /**
  32258. * Texture content is a depth texture
  32259. */
  32260. Depth = 12,
  32261. /**
  32262. * Texture data comes from a raw cube data encoded with RGBD
  32263. */
  32264. CubeRawRGBD = 13
  32265. }
  32266. /**
  32267. * Class used to store data associated with WebGL texture data for the engine
  32268. * This class should not be used directly
  32269. */
  32270. export class InternalTexture {
  32271. /** @hidden */
  32272. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32273. /**
  32274. * Defines if the texture is ready
  32275. */
  32276. isReady: boolean;
  32277. /**
  32278. * Defines if the texture is a cube texture
  32279. */
  32280. isCube: boolean;
  32281. /**
  32282. * Defines if the texture contains 3D data
  32283. */
  32284. is3D: boolean;
  32285. /**
  32286. * Defines if the texture contains 2D array data
  32287. */
  32288. is2DArray: boolean;
  32289. /**
  32290. * Defines if the texture contains multiview data
  32291. */
  32292. isMultiview: boolean;
  32293. /**
  32294. * Gets the URL used to load this texture
  32295. */
  32296. url: string;
  32297. /**
  32298. * Gets the sampling mode of the texture
  32299. */
  32300. samplingMode: number;
  32301. /**
  32302. * Gets a boolean indicating if the texture needs mipmaps generation
  32303. */
  32304. generateMipMaps: boolean;
  32305. /**
  32306. * Gets the number of samples used by the texture (WebGL2+ only)
  32307. */
  32308. samples: number;
  32309. /**
  32310. * Gets the type of the texture (int, float...)
  32311. */
  32312. type: number;
  32313. /**
  32314. * Gets the format of the texture (RGB, RGBA...)
  32315. */
  32316. format: number;
  32317. /**
  32318. * Observable called when the texture is loaded
  32319. */
  32320. onLoadedObservable: Observable<InternalTexture>;
  32321. /**
  32322. * Gets the width of the texture
  32323. */
  32324. width: number;
  32325. /**
  32326. * Gets the height of the texture
  32327. */
  32328. height: number;
  32329. /**
  32330. * Gets the depth of the texture
  32331. */
  32332. depth: number;
  32333. /**
  32334. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32335. */
  32336. baseWidth: number;
  32337. /**
  32338. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32339. */
  32340. baseHeight: number;
  32341. /**
  32342. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32343. */
  32344. baseDepth: number;
  32345. /**
  32346. * Gets a boolean indicating if the texture is inverted on Y axis
  32347. */
  32348. invertY: boolean;
  32349. /** @hidden */
  32350. _invertVScale: boolean;
  32351. /** @hidden */
  32352. _associatedChannel: number;
  32353. /** @hidden */
  32354. _source: InternalTextureSource;
  32355. /** @hidden */
  32356. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32357. /** @hidden */
  32358. _bufferView: Nullable<ArrayBufferView>;
  32359. /** @hidden */
  32360. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32361. /** @hidden */
  32362. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32363. /** @hidden */
  32364. _size: number;
  32365. /** @hidden */
  32366. _extension: string;
  32367. /** @hidden */
  32368. _files: Nullable<string[]>;
  32369. /** @hidden */
  32370. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32371. /** @hidden */
  32372. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32373. /** @hidden */
  32374. _framebuffer: Nullable<WebGLFramebuffer>;
  32375. /** @hidden */
  32376. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32377. /** @hidden */
  32378. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32379. /** @hidden */
  32380. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32381. /** @hidden */
  32382. _attachments: Nullable<number[]>;
  32383. /** @hidden */
  32384. _cachedCoordinatesMode: Nullable<number>;
  32385. /** @hidden */
  32386. _cachedWrapU: Nullable<number>;
  32387. /** @hidden */
  32388. _cachedWrapV: Nullable<number>;
  32389. /** @hidden */
  32390. _cachedWrapR: Nullable<number>;
  32391. /** @hidden */
  32392. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32393. /** @hidden */
  32394. _isDisabled: boolean;
  32395. /** @hidden */
  32396. _compression: Nullable<string>;
  32397. /** @hidden */
  32398. _generateStencilBuffer: boolean;
  32399. /** @hidden */
  32400. _generateDepthBuffer: boolean;
  32401. /** @hidden */
  32402. _comparisonFunction: number;
  32403. /** @hidden */
  32404. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32405. /** @hidden */
  32406. _lodGenerationScale: number;
  32407. /** @hidden */
  32408. _lodGenerationOffset: number;
  32409. /** @hidden */
  32410. _depthStencilTexture: Nullable<InternalTexture>;
  32411. /** @hidden */
  32412. _colorTextureArray: Nullable<WebGLTexture>;
  32413. /** @hidden */
  32414. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32415. /** @hidden */
  32416. _lodTextureHigh: Nullable<BaseTexture>;
  32417. /** @hidden */
  32418. _lodTextureMid: Nullable<BaseTexture>;
  32419. /** @hidden */
  32420. _lodTextureLow: Nullable<BaseTexture>;
  32421. /** @hidden */
  32422. _isRGBD: boolean;
  32423. /** @hidden */
  32424. _linearSpecularLOD: boolean;
  32425. /** @hidden */
  32426. _irradianceTexture: Nullable<BaseTexture>;
  32427. /** @hidden */
  32428. _webGLTexture: Nullable<WebGLTexture>;
  32429. /** @hidden */
  32430. _references: number;
  32431. private _engine;
  32432. /**
  32433. * Gets the Engine the texture belongs to.
  32434. * @returns The babylon engine
  32435. */
  32436. getEngine(): ThinEngine;
  32437. /**
  32438. * Gets the data source type of the texture
  32439. */
  32440. get source(): InternalTextureSource;
  32441. /**
  32442. * Creates a new InternalTexture
  32443. * @param engine defines the engine to use
  32444. * @param source defines the type of data that will be used
  32445. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32446. */
  32447. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32448. /**
  32449. * Increments the number of references (ie. the number of Texture that point to it)
  32450. */
  32451. incrementReferences(): void;
  32452. /**
  32453. * Change the size of the texture (not the size of the content)
  32454. * @param width defines the new width
  32455. * @param height defines the new height
  32456. * @param depth defines the new depth (1 by default)
  32457. */
  32458. updateSize(width: int, height: int, depth?: int): void;
  32459. /** @hidden */
  32460. _rebuild(): void;
  32461. /** @hidden */
  32462. _swapAndDie(target: InternalTexture): void;
  32463. /**
  32464. * Dispose the current allocated resources
  32465. */
  32466. dispose(): void;
  32467. }
  32468. }
  32469. declare module BABYLON {
  32470. /**
  32471. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32473. */
  32474. export class Analyser {
  32475. /**
  32476. * Gets or sets the smoothing
  32477. * @ignorenaming
  32478. */
  32479. SMOOTHING: number;
  32480. /**
  32481. * Gets or sets the FFT table size
  32482. * @ignorenaming
  32483. */
  32484. FFT_SIZE: number;
  32485. /**
  32486. * Gets or sets the bar graph amplitude
  32487. * @ignorenaming
  32488. */
  32489. BARGRAPHAMPLITUDE: number;
  32490. /**
  32491. * Gets or sets the position of the debug canvas
  32492. * @ignorenaming
  32493. */
  32494. DEBUGCANVASPOS: {
  32495. x: number;
  32496. y: number;
  32497. };
  32498. /**
  32499. * Gets or sets the debug canvas size
  32500. * @ignorenaming
  32501. */
  32502. DEBUGCANVASSIZE: {
  32503. width: number;
  32504. height: number;
  32505. };
  32506. private _byteFreqs;
  32507. private _byteTime;
  32508. private _floatFreqs;
  32509. private _webAudioAnalyser;
  32510. private _debugCanvas;
  32511. private _debugCanvasContext;
  32512. private _scene;
  32513. private _registerFunc;
  32514. private _audioEngine;
  32515. /**
  32516. * Creates a new analyser
  32517. * @param scene defines hosting scene
  32518. */
  32519. constructor(scene: Scene);
  32520. /**
  32521. * Get the number of data values you will have to play with for the visualization
  32522. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32523. * @returns a number
  32524. */
  32525. getFrequencyBinCount(): number;
  32526. /**
  32527. * Gets the current frequency data as a byte array
  32528. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32529. * @returns a Uint8Array
  32530. */
  32531. getByteFrequencyData(): Uint8Array;
  32532. /**
  32533. * Gets the current waveform as a byte array
  32534. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32535. * @returns a Uint8Array
  32536. */
  32537. getByteTimeDomainData(): Uint8Array;
  32538. /**
  32539. * Gets the current frequency data as a float array
  32540. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32541. * @returns a Float32Array
  32542. */
  32543. getFloatFrequencyData(): Float32Array;
  32544. /**
  32545. * Renders the debug canvas
  32546. */
  32547. drawDebugCanvas(): void;
  32548. /**
  32549. * Stops rendering the debug canvas and removes it
  32550. */
  32551. stopDebugCanvas(): void;
  32552. /**
  32553. * Connects two audio nodes
  32554. * @param inputAudioNode defines first node to connect
  32555. * @param outputAudioNode defines second node to connect
  32556. */
  32557. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32558. /**
  32559. * Releases all associated resources
  32560. */
  32561. dispose(): void;
  32562. }
  32563. }
  32564. declare module BABYLON {
  32565. /**
  32566. * This represents an audio engine and it is responsible
  32567. * to play, synchronize and analyse sounds throughout the application.
  32568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32569. */
  32570. export interface IAudioEngine extends IDisposable {
  32571. /**
  32572. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32573. */
  32574. readonly canUseWebAudio: boolean;
  32575. /**
  32576. * Gets the current AudioContext if available.
  32577. */
  32578. readonly audioContext: Nullable<AudioContext>;
  32579. /**
  32580. * The master gain node defines the global audio volume of your audio engine.
  32581. */
  32582. readonly masterGain: GainNode;
  32583. /**
  32584. * Gets whether or not mp3 are supported by your browser.
  32585. */
  32586. readonly isMP3supported: boolean;
  32587. /**
  32588. * Gets whether or not ogg are supported by your browser.
  32589. */
  32590. readonly isOGGsupported: boolean;
  32591. /**
  32592. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32593. * @ignoreNaming
  32594. */
  32595. WarnedWebAudioUnsupported: boolean;
  32596. /**
  32597. * Defines if the audio engine relies on a custom unlocked button.
  32598. * In this case, the embedded button will not be displayed.
  32599. */
  32600. useCustomUnlockedButton: boolean;
  32601. /**
  32602. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32603. */
  32604. readonly unlocked: boolean;
  32605. /**
  32606. * Event raised when audio has been unlocked on the browser.
  32607. */
  32608. onAudioUnlockedObservable: Observable<AudioEngine>;
  32609. /**
  32610. * Event raised when audio has been locked on the browser.
  32611. */
  32612. onAudioLockedObservable: Observable<AudioEngine>;
  32613. /**
  32614. * Flags the audio engine in Locked state.
  32615. * This happens due to new browser policies preventing audio to autoplay.
  32616. */
  32617. lock(): void;
  32618. /**
  32619. * Unlocks the audio engine once a user action has been done on the dom.
  32620. * This is helpful to resume play once browser policies have been satisfied.
  32621. */
  32622. unlock(): void;
  32623. }
  32624. /**
  32625. * This represents the default audio engine used in babylon.
  32626. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32628. */
  32629. export class AudioEngine implements IAudioEngine {
  32630. private _audioContext;
  32631. private _audioContextInitialized;
  32632. private _muteButton;
  32633. private _hostElement;
  32634. /**
  32635. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32636. */
  32637. canUseWebAudio: boolean;
  32638. /**
  32639. * The master gain node defines the global audio volume of your audio engine.
  32640. */
  32641. masterGain: GainNode;
  32642. /**
  32643. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32644. * @ignoreNaming
  32645. */
  32646. WarnedWebAudioUnsupported: boolean;
  32647. /**
  32648. * Gets whether or not mp3 are supported by your browser.
  32649. */
  32650. isMP3supported: boolean;
  32651. /**
  32652. * Gets whether or not ogg are supported by your browser.
  32653. */
  32654. isOGGsupported: boolean;
  32655. /**
  32656. * Gets whether audio has been unlocked on the device.
  32657. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32658. * a user interaction has happened.
  32659. */
  32660. unlocked: boolean;
  32661. /**
  32662. * Defines if the audio engine relies on a custom unlocked button.
  32663. * In this case, the embedded button will not be displayed.
  32664. */
  32665. useCustomUnlockedButton: boolean;
  32666. /**
  32667. * Event raised when audio has been unlocked on the browser.
  32668. */
  32669. onAudioUnlockedObservable: Observable<AudioEngine>;
  32670. /**
  32671. * Event raised when audio has been locked on the browser.
  32672. */
  32673. onAudioLockedObservable: Observable<AudioEngine>;
  32674. /**
  32675. * Gets the current AudioContext if available.
  32676. */
  32677. get audioContext(): Nullable<AudioContext>;
  32678. private _connectedAnalyser;
  32679. /**
  32680. * Instantiates a new audio engine.
  32681. *
  32682. * There should be only one per page as some browsers restrict the number
  32683. * of audio contexts you can create.
  32684. * @param hostElement defines the host element where to display the mute icon if necessary
  32685. */
  32686. constructor(hostElement?: Nullable<HTMLElement>);
  32687. /**
  32688. * Flags the audio engine in Locked state.
  32689. * This happens due to new browser policies preventing audio to autoplay.
  32690. */
  32691. lock(): void;
  32692. /**
  32693. * Unlocks the audio engine once a user action has been done on the dom.
  32694. * This is helpful to resume play once browser policies have been satisfied.
  32695. */
  32696. unlock(): void;
  32697. private _resumeAudioContext;
  32698. private _initializeAudioContext;
  32699. private _tryToRun;
  32700. private _triggerRunningState;
  32701. private _triggerSuspendedState;
  32702. private _displayMuteButton;
  32703. private _moveButtonToTopLeft;
  32704. private _onResize;
  32705. private _hideMuteButton;
  32706. /**
  32707. * Destroy and release the resources associated with the audio ccontext.
  32708. */
  32709. dispose(): void;
  32710. /**
  32711. * Gets the global volume sets on the master gain.
  32712. * @returns the global volume if set or -1 otherwise
  32713. */
  32714. getGlobalVolume(): number;
  32715. /**
  32716. * Sets the global volume of your experience (sets on the master gain).
  32717. * @param newVolume Defines the new global volume of the application
  32718. */
  32719. setGlobalVolume(newVolume: number): void;
  32720. /**
  32721. * Connect the audio engine to an audio analyser allowing some amazing
  32722. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32724. * @param analyser The analyser to connect to the engine
  32725. */
  32726. connectToAnalyser(analyser: Analyser): void;
  32727. }
  32728. }
  32729. declare module BABYLON {
  32730. /**
  32731. * Interface used to present a loading screen while loading a scene
  32732. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32733. */
  32734. export interface ILoadingScreen {
  32735. /**
  32736. * Function called to display the loading screen
  32737. */
  32738. displayLoadingUI: () => void;
  32739. /**
  32740. * Function called to hide the loading screen
  32741. */
  32742. hideLoadingUI: () => void;
  32743. /**
  32744. * Gets or sets the color to use for the background
  32745. */
  32746. loadingUIBackgroundColor: string;
  32747. /**
  32748. * Gets or sets the text to display while loading
  32749. */
  32750. loadingUIText: string;
  32751. }
  32752. /**
  32753. * Class used for the default loading screen
  32754. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32755. */
  32756. export class DefaultLoadingScreen implements ILoadingScreen {
  32757. private _renderingCanvas;
  32758. private _loadingText;
  32759. private _loadingDivBackgroundColor;
  32760. private _loadingDiv;
  32761. private _loadingTextDiv;
  32762. /** Gets or sets the logo url to use for the default loading screen */
  32763. static DefaultLogoUrl: string;
  32764. /** Gets or sets the spinner url to use for the default loading screen */
  32765. static DefaultSpinnerUrl: string;
  32766. /**
  32767. * Creates a new default loading screen
  32768. * @param _renderingCanvas defines the canvas used to render the scene
  32769. * @param _loadingText defines the default text to display
  32770. * @param _loadingDivBackgroundColor defines the default background color
  32771. */
  32772. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32773. /**
  32774. * Function called to display the loading screen
  32775. */
  32776. displayLoadingUI(): void;
  32777. /**
  32778. * Function called to hide the loading screen
  32779. */
  32780. hideLoadingUI(): void;
  32781. /**
  32782. * Gets or sets the text to display while loading
  32783. */
  32784. set loadingUIText(text: string);
  32785. get loadingUIText(): string;
  32786. /**
  32787. * Gets or sets the color to use for the background
  32788. */
  32789. get loadingUIBackgroundColor(): string;
  32790. set loadingUIBackgroundColor(color: string);
  32791. private _resizeLoadingUI;
  32792. }
  32793. }
  32794. declare module BABYLON {
  32795. /**
  32796. * Interface for any object that can request an animation frame
  32797. */
  32798. export interface ICustomAnimationFrameRequester {
  32799. /**
  32800. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32801. */
  32802. renderFunction?: Function;
  32803. /**
  32804. * Called to request the next frame to render to
  32805. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32806. */
  32807. requestAnimationFrame: Function;
  32808. /**
  32809. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32810. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32811. */
  32812. requestID?: number;
  32813. }
  32814. }
  32815. declare module BABYLON {
  32816. /**
  32817. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32818. */
  32819. export class PerformanceMonitor {
  32820. private _enabled;
  32821. private _rollingFrameTime;
  32822. private _lastFrameTimeMs;
  32823. /**
  32824. * constructor
  32825. * @param frameSampleSize The number of samples required to saturate the sliding window
  32826. */
  32827. constructor(frameSampleSize?: number);
  32828. /**
  32829. * Samples current frame
  32830. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32831. */
  32832. sampleFrame(timeMs?: number): void;
  32833. /**
  32834. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32835. */
  32836. get averageFrameTime(): number;
  32837. /**
  32838. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32839. */
  32840. get averageFrameTimeVariance(): number;
  32841. /**
  32842. * Returns the frame time of the most recent frame
  32843. */
  32844. get instantaneousFrameTime(): number;
  32845. /**
  32846. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32847. */
  32848. get averageFPS(): number;
  32849. /**
  32850. * Returns the average framerate in frames per second using the most recent frame time
  32851. */
  32852. get instantaneousFPS(): number;
  32853. /**
  32854. * Returns true if enough samples have been taken to completely fill the sliding window
  32855. */
  32856. get isSaturated(): boolean;
  32857. /**
  32858. * Enables contributions to the sliding window sample set
  32859. */
  32860. enable(): void;
  32861. /**
  32862. * Disables contributions to the sliding window sample set
  32863. * Samples will not be interpolated over the disabled period
  32864. */
  32865. disable(): void;
  32866. /**
  32867. * Returns true if sampling is enabled
  32868. */
  32869. get isEnabled(): boolean;
  32870. /**
  32871. * Resets performance monitor
  32872. */
  32873. reset(): void;
  32874. }
  32875. /**
  32876. * RollingAverage
  32877. *
  32878. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32879. */
  32880. export class RollingAverage {
  32881. /**
  32882. * Current average
  32883. */
  32884. average: number;
  32885. /**
  32886. * Current variance
  32887. */
  32888. variance: number;
  32889. protected _samples: Array<number>;
  32890. protected _sampleCount: number;
  32891. protected _pos: number;
  32892. protected _m2: number;
  32893. /**
  32894. * constructor
  32895. * @param length The number of samples required to saturate the sliding window
  32896. */
  32897. constructor(length: number);
  32898. /**
  32899. * Adds a sample to the sample set
  32900. * @param v The sample value
  32901. */
  32902. add(v: number): void;
  32903. /**
  32904. * Returns previously added values or null if outside of history or outside the sliding window domain
  32905. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32906. * @return Value previously recorded with add() or null if outside of range
  32907. */
  32908. history(i: number): number;
  32909. /**
  32910. * Returns true if enough samples have been taken to completely fill the sliding window
  32911. * @return true if sample-set saturated
  32912. */
  32913. isSaturated(): boolean;
  32914. /**
  32915. * Resets the rolling average (equivalent to 0 samples taken so far)
  32916. */
  32917. reset(): void;
  32918. /**
  32919. * Wraps a value around the sample range boundaries
  32920. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32921. * @return Wrapped position in sample range
  32922. */
  32923. protected _wrapPosition(i: number): number;
  32924. }
  32925. }
  32926. declare module BABYLON {
  32927. /**
  32928. * This class is used to track a performance counter which is number based.
  32929. * The user has access to many properties which give statistics of different nature.
  32930. *
  32931. * The implementer can track two kinds of Performance Counter: time and count.
  32932. * 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.
  32933. * 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.
  32934. */
  32935. export class PerfCounter {
  32936. /**
  32937. * Gets or sets a global boolean to turn on and off all the counters
  32938. */
  32939. static Enabled: boolean;
  32940. /**
  32941. * Returns the smallest value ever
  32942. */
  32943. get min(): number;
  32944. /**
  32945. * Returns the biggest value ever
  32946. */
  32947. get max(): number;
  32948. /**
  32949. * Returns the average value since the performance counter is running
  32950. */
  32951. get average(): number;
  32952. /**
  32953. * Returns the average value of the last second the counter was monitored
  32954. */
  32955. get lastSecAverage(): number;
  32956. /**
  32957. * Returns the current value
  32958. */
  32959. get current(): number;
  32960. /**
  32961. * Gets the accumulated total
  32962. */
  32963. get total(): number;
  32964. /**
  32965. * Gets the total value count
  32966. */
  32967. get count(): number;
  32968. /**
  32969. * Creates a new counter
  32970. */
  32971. constructor();
  32972. /**
  32973. * Call this method to start monitoring a new frame.
  32974. * 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.
  32975. */
  32976. fetchNewFrame(): void;
  32977. /**
  32978. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32979. * @param newCount the count value to add to the monitored count
  32980. * @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.
  32981. */
  32982. addCount(newCount: number, fetchResult: boolean): void;
  32983. /**
  32984. * Start monitoring this performance counter
  32985. */
  32986. beginMonitoring(): void;
  32987. /**
  32988. * Compute the time lapsed since the previous beginMonitoring() call.
  32989. * @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
  32990. */
  32991. endMonitoring(newFrame?: boolean): void;
  32992. private _fetchResult;
  32993. private _startMonitoringTime;
  32994. private _min;
  32995. private _max;
  32996. private _average;
  32997. private _current;
  32998. private _totalValueCount;
  32999. private _totalAccumulated;
  33000. private _lastSecAverage;
  33001. private _lastSecAccumulated;
  33002. private _lastSecTime;
  33003. private _lastSecValueCount;
  33004. }
  33005. }
  33006. declare module BABYLON {
  33007. interface ThinEngine {
  33008. /**
  33009. * Sets alpha constants used by some alpha blending modes
  33010. * @param r defines the red component
  33011. * @param g defines the green component
  33012. * @param b defines the blue component
  33013. * @param a defines the alpha component
  33014. */
  33015. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33016. /**
  33017. * Sets the current alpha mode
  33018. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33019. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33020. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33021. */
  33022. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33023. /**
  33024. * Gets the current alpha mode
  33025. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33026. * @returns the current alpha mode
  33027. */
  33028. getAlphaMode(): number;
  33029. /**
  33030. * Sets the current alpha equation
  33031. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33032. */
  33033. setAlphaEquation(equation: number): void;
  33034. /**
  33035. * Gets the current alpha equation.
  33036. * @returns the current alpha equation
  33037. */
  33038. getAlphaEquation(): number;
  33039. }
  33040. }
  33041. declare module BABYLON {
  33042. /**
  33043. * Defines the interface used by display changed events
  33044. */
  33045. export interface IDisplayChangedEventArgs {
  33046. /** Gets the vrDisplay object (if any) */
  33047. vrDisplay: Nullable<any>;
  33048. /** Gets a boolean indicating if webVR is supported */
  33049. vrSupported: boolean;
  33050. }
  33051. /**
  33052. * Defines the interface used by objects containing a viewport (like a camera)
  33053. */
  33054. interface IViewportOwnerLike {
  33055. /**
  33056. * Gets or sets the viewport
  33057. */
  33058. viewport: IViewportLike;
  33059. }
  33060. /**
  33061. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33062. */
  33063. export class Engine extends ThinEngine {
  33064. /** Defines that alpha blending is disabled */
  33065. static readonly ALPHA_DISABLE: number;
  33066. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33067. static readonly ALPHA_ADD: number;
  33068. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33069. static readonly ALPHA_COMBINE: number;
  33070. /** Defines that alpha blending to DEST - SRC * DEST */
  33071. static readonly ALPHA_SUBTRACT: number;
  33072. /** Defines that alpha blending to SRC * DEST */
  33073. static readonly ALPHA_MULTIPLY: number;
  33074. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33075. static readonly ALPHA_MAXIMIZED: number;
  33076. /** Defines that alpha blending to SRC + DEST */
  33077. static readonly ALPHA_ONEONE: number;
  33078. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33079. static readonly ALPHA_PREMULTIPLIED: number;
  33080. /**
  33081. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33082. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33083. */
  33084. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33085. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33086. static readonly ALPHA_INTERPOLATE: number;
  33087. /**
  33088. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33089. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33090. */
  33091. static readonly ALPHA_SCREENMODE: number;
  33092. /** Defines that the ressource is not delayed*/
  33093. static readonly DELAYLOADSTATE_NONE: number;
  33094. /** Defines that the ressource was successfully delay loaded */
  33095. static readonly DELAYLOADSTATE_LOADED: number;
  33096. /** Defines that the ressource is currently delay loading */
  33097. static readonly DELAYLOADSTATE_LOADING: number;
  33098. /** Defines that the ressource is delayed and has not started loading */
  33099. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33100. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33101. static readonly NEVER: number;
  33102. /** 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 */
  33103. static readonly ALWAYS: number;
  33104. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33105. static readonly LESS: number;
  33106. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33107. static readonly EQUAL: number;
  33108. /** 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 */
  33109. static readonly LEQUAL: number;
  33110. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33111. static readonly GREATER: number;
  33112. /** 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 */
  33113. static readonly GEQUAL: number;
  33114. /** 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 */
  33115. static readonly NOTEQUAL: number;
  33116. /** Passed to stencilOperation to specify that stencil value must be kept */
  33117. static readonly KEEP: number;
  33118. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33119. static readonly REPLACE: number;
  33120. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33121. static readonly INCR: number;
  33122. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33123. static readonly DECR: number;
  33124. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33125. static readonly INVERT: number;
  33126. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33127. static readonly INCR_WRAP: number;
  33128. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33129. static readonly DECR_WRAP: number;
  33130. /** Texture is not repeating outside of 0..1 UVs */
  33131. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33132. /** Texture is repeating outside of 0..1 UVs */
  33133. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33134. /** Texture is repeating and mirrored */
  33135. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33136. /** ALPHA */
  33137. static readonly TEXTUREFORMAT_ALPHA: number;
  33138. /** LUMINANCE */
  33139. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33140. /** LUMINANCE_ALPHA */
  33141. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33142. /** RGB */
  33143. static readonly TEXTUREFORMAT_RGB: number;
  33144. /** RGBA */
  33145. static readonly TEXTUREFORMAT_RGBA: number;
  33146. /** RED */
  33147. static readonly TEXTUREFORMAT_RED: number;
  33148. /** RED (2nd reference) */
  33149. static readonly TEXTUREFORMAT_R: number;
  33150. /** RG */
  33151. static readonly TEXTUREFORMAT_RG: number;
  33152. /** RED_INTEGER */
  33153. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33154. /** RED_INTEGER (2nd reference) */
  33155. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33156. /** RG_INTEGER */
  33157. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33158. /** RGB_INTEGER */
  33159. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33160. /** RGBA_INTEGER */
  33161. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33162. /** UNSIGNED_BYTE */
  33163. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33164. /** UNSIGNED_BYTE (2nd reference) */
  33165. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33166. /** FLOAT */
  33167. static readonly TEXTURETYPE_FLOAT: number;
  33168. /** HALF_FLOAT */
  33169. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33170. /** BYTE */
  33171. static readonly TEXTURETYPE_BYTE: number;
  33172. /** SHORT */
  33173. static readonly TEXTURETYPE_SHORT: number;
  33174. /** UNSIGNED_SHORT */
  33175. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33176. /** INT */
  33177. static readonly TEXTURETYPE_INT: number;
  33178. /** UNSIGNED_INT */
  33179. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33180. /** UNSIGNED_SHORT_4_4_4_4 */
  33181. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33182. /** UNSIGNED_SHORT_5_5_5_1 */
  33183. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33184. /** UNSIGNED_SHORT_5_6_5 */
  33185. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33186. /** UNSIGNED_INT_2_10_10_10_REV */
  33187. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33188. /** UNSIGNED_INT_24_8 */
  33189. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33190. /** UNSIGNED_INT_10F_11F_11F_REV */
  33191. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33192. /** UNSIGNED_INT_5_9_9_9_REV */
  33193. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33194. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33195. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33196. /** nearest is mag = nearest and min = nearest and mip = linear */
  33197. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33198. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33199. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33200. /** Trilinear is mag = linear and min = linear and mip = linear */
  33201. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33202. /** nearest is mag = nearest and min = nearest and mip = linear */
  33203. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33204. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33205. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33206. /** Trilinear is mag = linear and min = linear and mip = linear */
  33207. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33208. /** mag = nearest and min = nearest and mip = nearest */
  33209. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33210. /** mag = nearest and min = linear and mip = nearest */
  33211. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33212. /** mag = nearest and min = linear and mip = linear */
  33213. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33214. /** mag = nearest and min = linear and mip = none */
  33215. static readonly TEXTURE_NEAREST_LINEAR: number;
  33216. /** mag = nearest and min = nearest and mip = none */
  33217. static readonly TEXTURE_NEAREST_NEAREST: number;
  33218. /** mag = linear and min = nearest and mip = nearest */
  33219. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33220. /** mag = linear and min = nearest and mip = linear */
  33221. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33222. /** mag = linear and min = linear and mip = none */
  33223. static readonly TEXTURE_LINEAR_LINEAR: number;
  33224. /** mag = linear and min = nearest and mip = none */
  33225. static readonly TEXTURE_LINEAR_NEAREST: number;
  33226. /** Explicit coordinates mode */
  33227. static readonly TEXTURE_EXPLICIT_MODE: number;
  33228. /** Spherical coordinates mode */
  33229. static readonly TEXTURE_SPHERICAL_MODE: number;
  33230. /** Planar coordinates mode */
  33231. static readonly TEXTURE_PLANAR_MODE: number;
  33232. /** Cubic coordinates mode */
  33233. static readonly TEXTURE_CUBIC_MODE: number;
  33234. /** Projection coordinates mode */
  33235. static readonly TEXTURE_PROJECTION_MODE: number;
  33236. /** Skybox coordinates mode */
  33237. static readonly TEXTURE_SKYBOX_MODE: number;
  33238. /** Inverse Cubic coordinates mode */
  33239. static readonly TEXTURE_INVCUBIC_MODE: number;
  33240. /** Equirectangular coordinates mode */
  33241. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33242. /** Equirectangular Fixed coordinates mode */
  33243. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33244. /** Equirectangular Fixed Mirrored coordinates mode */
  33245. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33246. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33247. static readonly SCALEMODE_FLOOR: number;
  33248. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33249. static readonly SCALEMODE_NEAREST: number;
  33250. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33251. static readonly SCALEMODE_CEILING: number;
  33252. /**
  33253. * Returns the current npm package of the sdk
  33254. */
  33255. static get NpmPackage(): string;
  33256. /**
  33257. * Returns the current version of the framework
  33258. */
  33259. static get Version(): string;
  33260. /** Gets the list of created engines */
  33261. static get Instances(): Engine[];
  33262. /**
  33263. * Gets the latest created engine
  33264. */
  33265. static get LastCreatedEngine(): Nullable<Engine>;
  33266. /**
  33267. * Gets the latest created scene
  33268. */
  33269. static get LastCreatedScene(): Nullable<Scene>;
  33270. /**
  33271. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33272. * @param flag defines which part of the materials must be marked as dirty
  33273. * @param predicate defines a predicate used to filter which materials should be affected
  33274. */
  33275. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33276. /**
  33277. * Method called to create the default loading screen.
  33278. * This can be overriden in your own app.
  33279. * @param canvas The rendering canvas element
  33280. * @returns The loading screen
  33281. */
  33282. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33283. /**
  33284. * Method called to create the default rescale post process on each engine.
  33285. */
  33286. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33287. /**
  33288. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33289. **/
  33290. enableOfflineSupport: boolean;
  33291. /**
  33292. * 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)
  33293. **/
  33294. disableManifestCheck: boolean;
  33295. /**
  33296. * Gets the list of created scenes
  33297. */
  33298. scenes: Scene[];
  33299. /**
  33300. * Event raised when a new scene is created
  33301. */
  33302. onNewSceneAddedObservable: Observable<Scene>;
  33303. /**
  33304. * Gets the list of created postprocesses
  33305. */
  33306. postProcesses: PostProcess[];
  33307. /**
  33308. * Gets a boolean indicating if the pointer is currently locked
  33309. */
  33310. isPointerLock: boolean;
  33311. /**
  33312. * Observable event triggered each time the rendering canvas is resized
  33313. */
  33314. onResizeObservable: Observable<Engine>;
  33315. /**
  33316. * Observable event triggered each time the canvas loses focus
  33317. */
  33318. onCanvasBlurObservable: Observable<Engine>;
  33319. /**
  33320. * Observable event triggered each time the canvas gains focus
  33321. */
  33322. onCanvasFocusObservable: Observable<Engine>;
  33323. /**
  33324. * Observable event triggered each time the canvas receives pointerout event
  33325. */
  33326. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33327. /**
  33328. * Observable raised when the engine begins a new frame
  33329. */
  33330. onBeginFrameObservable: Observable<Engine>;
  33331. /**
  33332. * If set, will be used to request the next animation frame for the render loop
  33333. */
  33334. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33335. /**
  33336. * Observable raised when the engine ends the current frame
  33337. */
  33338. onEndFrameObservable: Observable<Engine>;
  33339. /**
  33340. * Observable raised when the engine is about to compile a shader
  33341. */
  33342. onBeforeShaderCompilationObservable: Observable<Engine>;
  33343. /**
  33344. * Observable raised when the engine has jsut compiled a shader
  33345. */
  33346. onAfterShaderCompilationObservable: Observable<Engine>;
  33347. /**
  33348. * Gets the audio engine
  33349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33350. * @ignorenaming
  33351. */
  33352. static audioEngine: IAudioEngine;
  33353. /**
  33354. * Default AudioEngine factory responsible of creating the Audio Engine.
  33355. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33356. */
  33357. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33358. /**
  33359. * Default offline support factory responsible of creating a tool used to store data locally.
  33360. * By default, this will create a Database object if the workload has been embedded.
  33361. */
  33362. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33363. private _loadingScreen;
  33364. private _pointerLockRequested;
  33365. private _dummyFramebuffer;
  33366. private _rescalePostProcess;
  33367. private _deterministicLockstep;
  33368. private _lockstepMaxSteps;
  33369. private _timeStep;
  33370. protected get _supportsHardwareTextureRescaling(): boolean;
  33371. private _fps;
  33372. private _deltaTime;
  33373. /** @hidden */
  33374. _drawCalls: PerfCounter;
  33375. /** 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 */
  33376. canvasTabIndex: number;
  33377. /**
  33378. * Turn this value on if you want to pause FPS computation when in background
  33379. */
  33380. disablePerformanceMonitorInBackground: boolean;
  33381. private _performanceMonitor;
  33382. /**
  33383. * Gets the performance monitor attached to this engine
  33384. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33385. */
  33386. get performanceMonitor(): PerformanceMonitor;
  33387. private _onFocus;
  33388. private _onBlur;
  33389. private _onCanvasPointerOut;
  33390. private _onCanvasBlur;
  33391. private _onCanvasFocus;
  33392. private _onFullscreenChange;
  33393. private _onPointerLockChange;
  33394. /**
  33395. * Gets the HTML element used to attach event listeners
  33396. * @returns a HTML element
  33397. */
  33398. getInputElement(): Nullable<HTMLElement>;
  33399. /**
  33400. * Creates a new engine
  33401. * @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
  33402. * @param antialias defines enable antialiasing (default: false)
  33403. * @param options defines further options to be sent to the getContext() function
  33404. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33405. */
  33406. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33407. /**
  33408. * Gets current aspect ratio
  33409. * @param viewportOwner defines the camera to use to get the aspect ratio
  33410. * @param useScreen defines if screen size must be used (or the current render target if any)
  33411. * @returns a number defining the aspect ratio
  33412. */
  33413. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33414. /**
  33415. * Gets current screen aspect ratio
  33416. * @returns a number defining the aspect ratio
  33417. */
  33418. getScreenAspectRatio(): number;
  33419. /**
  33420. * Gets the client rect of the HTML canvas attached with the current webGL context
  33421. * @returns a client rectanglee
  33422. */
  33423. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33424. /**
  33425. * Gets the client rect of the HTML element used for events
  33426. * @returns a client rectanglee
  33427. */
  33428. getInputElementClientRect(): Nullable<ClientRect>;
  33429. /**
  33430. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33431. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33432. * @returns true if engine is in deterministic lock step mode
  33433. */
  33434. isDeterministicLockStep(): boolean;
  33435. /**
  33436. * Gets the max steps when engine is running in deterministic lock step
  33437. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33438. * @returns the max steps
  33439. */
  33440. getLockstepMaxSteps(): number;
  33441. /**
  33442. * Returns the time in ms between steps when using deterministic lock step.
  33443. * @returns time step in (ms)
  33444. */
  33445. getTimeStep(): number;
  33446. /**
  33447. * Force the mipmap generation for the given render target texture
  33448. * @param texture defines the render target texture to use
  33449. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33450. */
  33451. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33452. /** States */
  33453. /**
  33454. * Set various states to the webGL context
  33455. * @param culling defines backface culling state
  33456. * @param zOffset defines the value to apply to zOffset (0 by default)
  33457. * @param force defines if states must be applied even if cache is up to date
  33458. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33459. */
  33460. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33461. /**
  33462. * Set the z offset to apply to current rendering
  33463. * @param value defines the offset to apply
  33464. */
  33465. setZOffset(value: number): void;
  33466. /**
  33467. * Gets the current value of the zOffset
  33468. * @returns the current zOffset state
  33469. */
  33470. getZOffset(): number;
  33471. /**
  33472. * Enable or disable depth buffering
  33473. * @param enable defines the state to set
  33474. */
  33475. setDepthBuffer(enable: boolean): void;
  33476. /**
  33477. * Gets a boolean indicating if depth writing is enabled
  33478. * @returns the current depth writing state
  33479. */
  33480. getDepthWrite(): boolean;
  33481. /**
  33482. * Enable or disable depth writing
  33483. * @param enable defines the state to set
  33484. */
  33485. setDepthWrite(enable: boolean): void;
  33486. /**
  33487. * Gets a boolean indicating if stencil buffer is enabled
  33488. * @returns the current stencil buffer state
  33489. */
  33490. getStencilBuffer(): boolean;
  33491. /**
  33492. * Enable or disable the stencil buffer
  33493. * @param enable defines if the stencil buffer must be enabled or disabled
  33494. */
  33495. setStencilBuffer(enable: boolean): void;
  33496. /**
  33497. * Gets the current stencil mask
  33498. * @returns a number defining the new stencil mask to use
  33499. */
  33500. getStencilMask(): number;
  33501. /**
  33502. * Sets the current stencil mask
  33503. * @param mask defines the new stencil mask to use
  33504. */
  33505. setStencilMask(mask: number): void;
  33506. /**
  33507. * Gets the current stencil function
  33508. * @returns a number defining the stencil function to use
  33509. */
  33510. getStencilFunction(): number;
  33511. /**
  33512. * Gets the current stencil reference value
  33513. * @returns a number defining the stencil reference value to use
  33514. */
  33515. getStencilFunctionReference(): number;
  33516. /**
  33517. * Gets the current stencil mask
  33518. * @returns a number defining the stencil mask to use
  33519. */
  33520. getStencilFunctionMask(): number;
  33521. /**
  33522. * Sets the current stencil function
  33523. * @param stencilFunc defines the new stencil function to use
  33524. */
  33525. setStencilFunction(stencilFunc: number): void;
  33526. /**
  33527. * Sets the current stencil reference
  33528. * @param reference defines the new stencil reference to use
  33529. */
  33530. setStencilFunctionReference(reference: number): void;
  33531. /**
  33532. * Sets the current stencil mask
  33533. * @param mask defines the new stencil mask to use
  33534. */
  33535. setStencilFunctionMask(mask: number): void;
  33536. /**
  33537. * Gets the current stencil operation when stencil fails
  33538. * @returns a number defining stencil operation to use when stencil fails
  33539. */
  33540. getStencilOperationFail(): number;
  33541. /**
  33542. * Gets the current stencil operation when depth fails
  33543. * @returns a number defining stencil operation to use when depth fails
  33544. */
  33545. getStencilOperationDepthFail(): number;
  33546. /**
  33547. * Gets the current stencil operation when stencil passes
  33548. * @returns a number defining stencil operation to use when stencil passes
  33549. */
  33550. getStencilOperationPass(): number;
  33551. /**
  33552. * Sets the stencil operation to use when stencil fails
  33553. * @param operation defines the stencil operation to use when stencil fails
  33554. */
  33555. setStencilOperationFail(operation: number): void;
  33556. /**
  33557. * Sets the stencil operation to use when depth fails
  33558. * @param operation defines the stencil operation to use when depth fails
  33559. */
  33560. setStencilOperationDepthFail(operation: number): void;
  33561. /**
  33562. * Sets the stencil operation to use when stencil passes
  33563. * @param operation defines the stencil operation to use when stencil passes
  33564. */
  33565. setStencilOperationPass(operation: number): void;
  33566. /**
  33567. * Sets a boolean indicating if the dithering state is enabled or disabled
  33568. * @param value defines the dithering state
  33569. */
  33570. setDitheringState(value: boolean): void;
  33571. /**
  33572. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33573. * @param value defines the rasterizer state
  33574. */
  33575. setRasterizerState(value: boolean): void;
  33576. /**
  33577. * Gets the current depth function
  33578. * @returns a number defining the depth function
  33579. */
  33580. getDepthFunction(): Nullable<number>;
  33581. /**
  33582. * Sets the current depth function
  33583. * @param depthFunc defines the function to use
  33584. */
  33585. setDepthFunction(depthFunc: number): void;
  33586. /**
  33587. * Sets the current depth function to GREATER
  33588. */
  33589. setDepthFunctionToGreater(): void;
  33590. /**
  33591. * Sets the current depth function to GEQUAL
  33592. */
  33593. setDepthFunctionToGreaterOrEqual(): void;
  33594. /**
  33595. * Sets the current depth function to LESS
  33596. */
  33597. setDepthFunctionToLess(): void;
  33598. /**
  33599. * Sets the current depth function to LEQUAL
  33600. */
  33601. setDepthFunctionToLessOrEqual(): void;
  33602. private _cachedStencilBuffer;
  33603. private _cachedStencilFunction;
  33604. private _cachedStencilMask;
  33605. private _cachedStencilOperationPass;
  33606. private _cachedStencilOperationFail;
  33607. private _cachedStencilOperationDepthFail;
  33608. private _cachedStencilReference;
  33609. /**
  33610. * Caches the the state of the stencil buffer
  33611. */
  33612. cacheStencilState(): void;
  33613. /**
  33614. * Restores the state of the stencil buffer
  33615. */
  33616. restoreStencilState(): void;
  33617. /**
  33618. * Directly set the WebGL Viewport
  33619. * @param x defines the x coordinate of the viewport (in screen space)
  33620. * @param y defines the y coordinate of the viewport (in screen space)
  33621. * @param width defines the width of the viewport (in screen space)
  33622. * @param height defines the height of the viewport (in screen space)
  33623. * @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
  33624. */
  33625. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33626. /**
  33627. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33628. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33629. * @param y defines the y-coordinate of the corner of the clear rectangle
  33630. * @param width defines the width of the clear rectangle
  33631. * @param height defines the height of the clear rectangle
  33632. * @param clearColor defines the clear color
  33633. */
  33634. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33635. /**
  33636. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33637. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33638. * @param y defines the y-coordinate of the corner of the clear rectangle
  33639. * @param width defines the width of the clear rectangle
  33640. * @param height defines the height of the clear rectangle
  33641. */
  33642. enableScissor(x: number, y: number, width: number, height: number): void;
  33643. /**
  33644. * Disable previously set scissor test rectangle
  33645. */
  33646. disableScissor(): void;
  33647. protected _reportDrawCall(): void;
  33648. /**
  33649. * Initializes a webVR display and starts listening to display change events
  33650. * The onVRDisplayChangedObservable will be notified upon these changes
  33651. * @returns The onVRDisplayChangedObservable
  33652. */
  33653. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33654. /** @hidden */
  33655. _prepareVRComponent(): void;
  33656. /** @hidden */
  33657. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33658. /** @hidden */
  33659. _submitVRFrame(): void;
  33660. /**
  33661. * Call this function to leave webVR mode
  33662. * Will do nothing if webVR is not supported or if there is no webVR device
  33663. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33664. */
  33665. disableVR(): void;
  33666. /**
  33667. * Gets a boolean indicating that the system is in VR mode and is presenting
  33668. * @returns true if VR mode is engaged
  33669. */
  33670. isVRPresenting(): boolean;
  33671. /** @hidden */
  33672. _requestVRFrame(): void;
  33673. /** @hidden */
  33674. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33675. /**
  33676. * Gets the source code of the vertex shader associated with a specific webGL program
  33677. * @param program defines the program to use
  33678. * @returns a string containing the source code of the vertex shader associated with the program
  33679. */
  33680. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33681. /**
  33682. * Gets the source code of the fragment shader associated with a specific webGL program
  33683. * @param program defines the program to use
  33684. * @returns a string containing the source code of the fragment shader associated with the program
  33685. */
  33686. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33687. /**
  33688. * Sets a depth stencil texture from a render target to the according uniform.
  33689. * @param channel The texture channel
  33690. * @param uniform The uniform to set
  33691. * @param texture The render target texture containing the depth stencil texture to apply
  33692. */
  33693. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33694. /**
  33695. * Sets a texture to the webGL context from a postprocess
  33696. * @param channel defines the channel to use
  33697. * @param postProcess defines the source postprocess
  33698. */
  33699. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33700. /**
  33701. * Binds the output of the passed in post process to the texture channel specified
  33702. * @param channel The channel the texture should be bound to
  33703. * @param postProcess The post process which's output should be bound
  33704. */
  33705. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33706. /** @hidden */
  33707. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33708. protected _rebuildBuffers(): void;
  33709. /** @hidden */
  33710. _renderFrame(): void;
  33711. _renderLoop(): void;
  33712. /** @hidden */
  33713. _renderViews(): boolean;
  33714. /**
  33715. * Toggle full screen mode
  33716. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33717. */
  33718. switchFullscreen(requestPointerLock: boolean): void;
  33719. /**
  33720. * Enters full screen mode
  33721. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33722. */
  33723. enterFullscreen(requestPointerLock: boolean): void;
  33724. /**
  33725. * Exits full screen mode
  33726. */
  33727. exitFullscreen(): void;
  33728. /**
  33729. * Enters Pointerlock mode
  33730. */
  33731. enterPointerlock(): void;
  33732. /**
  33733. * Exits Pointerlock mode
  33734. */
  33735. exitPointerlock(): void;
  33736. /**
  33737. * Begin a new frame
  33738. */
  33739. beginFrame(): void;
  33740. /**
  33741. * Enf the current frame
  33742. */
  33743. endFrame(): void;
  33744. resize(): void;
  33745. /**
  33746. * Force a specific size of the canvas
  33747. * @param width defines the new canvas' width
  33748. * @param height defines the new canvas' height
  33749. */
  33750. setSize(width: number, height: number): void;
  33751. /**
  33752. * Updates a dynamic vertex buffer.
  33753. * @param vertexBuffer the vertex buffer to update
  33754. * @param data the data used to update the vertex buffer
  33755. * @param byteOffset the byte offset of the data
  33756. * @param byteLength the byte length of the data
  33757. */
  33758. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33759. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33760. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33761. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33762. _releaseTexture(texture: InternalTexture): void;
  33763. /**
  33764. * @hidden
  33765. * Rescales a texture
  33766. * @param source input texutre
  33767. * @param destination destination texture
  33768. * @param scene scene to use to render the resize
  33769. * @param internalFormat format to use when resizing
  33770. * @param onComplete callback to be called when resize has completed
  33771. */
  33772. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33773. /**
  33774. * Gets the current framerate
  33775. * @returns a number representing the framerate
  33776. */
  33777. getFps(): number;
  33778. /**
  33779. * Gets the time spent between current and previous frame
  33780. * @returns a number representing the delta time in ms
  33781. */
  33782. getDeltaTime(): number;
  33783. private _measureFps;
  33784. /** @hidden */
  33785. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33786. /**
  33787. * Update a dynamic index buffer
  33788. * @param indexBuffer defines the target index buffer
  33789. * @param indices defines the data to update
  33790. * @param offset defines the offset in the target index buffer where update should start
  33791. */
  33792. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33793. /**
  33794. * Updates the sample count of a render target texture
  33795. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33796. * @param texture defines the texture to update
  33797. * @param samples defines the sample count to set
  33798. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33799. */
  33800. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33801. /**
  33802. * Updates a depth texture Comparison Mode and Function.
  33803. * If the comparison Function is equal to 0, the mode will be set to none.
  33804. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33805. * @param texture The texture to set the comparison function for
  33806. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33807. */
  33808. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33809. /**
  33810. * Creates a webGL buffer to use with instanciation
  33811. * @param capacity defines the size of the buffer
  33812. * @returns the webGL buffer
  33813. */
  33814. createInstancesBuffer(capacity: number): DataBuffer;
  33815. /**
  33816. * Delete a webGL buffer used with instanciation
  33817. * @param buffer defines the webGL buffer to delete
  33818. */
  33819. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33820. private _clientWaitAsync;
  33821. /** @hidden */
  33822. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  33823. /** @hidden */
  33824. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33825. dispose(): void;
  33826. private _disableTouchAction;
  33827. /**
  33828. * Display the loading screen
  33829. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33830. */
  33831. displayLoadingUI(): void;
  33832. /**
  33833. * Hide the loading screen
  33834. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33835. */
  33836. hideLoadingUI(): void;
  33837. /**
  33838. * Gets the current loading screen object
  33839. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33840. */
  33841. get loadingScreen(): ILoadingScreen;
  33842. /**
  33843. * Sets the current loading screen object
  33844. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33845. */
  33846. set loadingScreen(loadingScreen: ILoadingScreen);
  33847. /**
  33848. * Sets the current loading screen text
  33849. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33850. */
  33851. set loadingUIText(text: string);
  33852. /**
  33853. * Sets the current loading screen background color
  33854. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33855. */
  33856. set loadingUIBackgroundColor(color: string);
  33857. /** Pointerlock and fullscreen */
  33858. /**
  33859. * Ask the browser to promote the current element to pointerlock mode
  33860. * @param element defines the DOM element to promote
  33861. */
  33862. static _RequestPointerlock(element: HTMLElement): void;
  33863. /**
  33864. * Asks the browser to exit pointerlock mode
  33865. */
  33866. static _ExitPointerlock(): void;
  33867. /**
  33868. * Ask the browser to promote the current element to fullscreen rendering mode
  33869. * @param element defines the DOM element to promote
  33870. */
  33871. static _RequestFullscreen(element: HTMLElement): void;
  33872. /**
  33873. * Asks the browser to exit fullscreen mode
  33874. */
  33875. static _ExitFullscreen(): void;
  33876. }
  33877. }
  33878. declare module BABYLON {
  33879. /**
  33880. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33881. * during the life time of the application.
  33882. */
  33883. export class EngineStore {
  33884. /** Gets the list of created engines */
  33885. static Instances: Engine[];
  33886. /** @hidden */
  33887. static _LastCreatedScene: Nullable<Scene>;
  33888. /**
  33889. * Gets the latest created engine
  33890. */
  33891. static get LastCreatedEngine(): Nullable<Engine>;
  33892. /**
  33893. * Gets the latest created scene
  33894. */
  33895. static get LastCreatedScene(): Nullable<Scene>;
  33896. /**
  33897. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33898. * @ignorenaming
  33899. */
  33900. static UseFallbackTexture: boolean;
  33901. /**
  33902. * Texture content used if a texture cannot loaded
  33903. * @ignorenaming
  33904. */
  33905. static FallbackTexture: string;
  33906. }
  33907. }
  33908. declare module BABYLON {
  33909. /**
  33910. * Helper class that provides a small promise polyfill
  33911. */
  33912. export class PromisePolyfill {
  33913. /**
  33914. * Static function used to check if the polyfill is required
  33915. * If this is the case then the function will inject the polyfill to window.Promise
  33916. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33917. */
  33918. static Apply(force?: boolean): void;
  33919. }
  33920. }
  33921. declare module BABYLON {
  33922. /**
  33923. * Interface for screenshot methods with describe argument called `size` as object with options
  33924. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33925. */
  33926. export interface IScreenshotSize {
  33927. /**
  33928. * number in pixels for canvas height
  33929. */
  33930. height?: number;
  33931. /**
  33932. * multiplier allowing render at a higher or lower resolution
  33933. * If value is defined then height and width will be ignored and taken from camera
  33934. */
  33935. precision?: number;
  33936. /**
  33937. * number in pixels for canvas width
  33938. */
  33939. width?: number;
  33940. }
  33941. }
  33942. declare module BABYLON {
  33943. interface IColor4Like {
  33944. r: float;
  33945. g: float;
  33946. b: float;
  33947. a: float;
  33948. }
  33949. /**
  33950. * Class containing a set of static utilities functions
  33951. */
  33952. export class Tools {
  33953. /**
  33954. * Gets or sets the base URL to use to load assets
  33955. */
  33956. static get BaseUrl(): string;
  33957. static set BaseUrl(value: string);
  33958. /**
  33959. * Enable/Disable Custom HTTP Request Headers globally.
  33960. * default = false
  33961. * @see CustomRequestHeaders
  33962. */
  33963. static UseCustomRequestHeaders: boolean;
  33964. /**
  33965. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33966. * i.e. when loading files, where the server/service expects an Authorization header
  33967. */
  33968. static CustomRequestHeaders: {
  33969. [key: string]: string;
  33970. };
  33971. /**
  33972. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33973. */
  33974. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33975. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33976. /**
  33977. * Default behaviour for cors in the application.
  33978. * It can be a string if the expected behavior is identical in the entire app.
  33979. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33980. */
  33981. static CorsBehavior: string | ((url: string | string[]) => string);
  33982. /**
  33983. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33984. * @ignorenaming
  33985. */
  33986. static get UseFallbackTexture(): boolean;
  33987. static set UseFallbackTexture(value: boolean);
  33988. /**
  33989. * Use this object to register external classes like custom textures or material
  33990. * to allow the laoders to instantiate them
  33991. */
  33992. static get RegisteredExternalClasses(): {
  33993. [key: string]: Object;
  33994. };
  33995. static set RegisteredExternalClasses(classes: {
  33996. [key: string]: Object;
  33997. });
  33998. /**
  33999. * Texture content used if a texture cannot loaded
  34000. * @ignorenaming
  34001. */
  34002. static get fallbackTexture(): string;
  34003. static set fallbackTexture(value: string);
  34004. /**
  34005. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34006. * @param u defines the coordinate on X axis
  34007. * @param v defines the coordinate on Y axis
  34008. * @param width defines the width of the source data
  34009. * @param height defines the height of the source data
  34010. * @param pixels defines the source byte array
  34011. * @param color defines the output color
  34012. */
  34013. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34014. /**
  34015. * Interpolates between a and b via alpha
  34016. * @param a The lower value (returned when alpha = 0)
  34017. * @param b The upper value (returned when alpha = 1)
  34018. * @param alpha The interpolation-factor
  34019. * @return The mixed value
  34020. */
  34021. static Mix(a: number, b: number, alpha: number): number;
  34022. /**
  34023. * Tries to instantiate a new object from a given class name
  34024. * @param className defines the class name to instantiate
  34025. * @returns the new object or null if the system was not able to do the instantiation
  34026. */
  34027. static Instantiate(className: string): any;
  34028. /**
  34029. * Provides a slice function that will work even on IE
  34030. * @param data defines the array to slice
  34031. * @param start defines the start of the data (optional)
  34032. * @param end defines the end of the data (optional)
  34033. * @returns the new sliced array
  34034. */
  34035. static Slice<T>(data: T, start?: number, end?: number): T;
  34036. /**
  34037. * Polyfill for setImmediate
  34038. * @param action defines the action to execute after the current execution block
  34039. */
  34040. static SetImmediate(action: () => void): void;
  34041. /**
  34042. * Function indicating if a number is an exponent of 2
  34043. * @param value defines the value to test
  34044. * @returns true if the value is an exponent of 2
  34045. */
  34046. static IsExponentOfTwo(value: number): boolean;
  34047. private static _tmpFloatArray;
  34048. /**
  34049. * Returns the nearest 32-bit single precision float representation of a Number
  34050. * @param value A Number. If the parameter is of a different type, it will get converted
  34051. * to a number or to NaN if it cannot be converted
  34052. * @returns number
  34053. */
  34054. static FloatRound(value: number): number;
  34055. /**
  34056. * Extracts the filename from a path
  34057. * @param path defines the path to use
  34058. * @returns the filename
  34059. */
  34060. static GetFilename(path: string): string;
  34061. /**
  34062. * Extracts the "folder" part of a path (everything before the filename).
  34063. * @param uri The URI to extract the info from
  34064. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34065. * @returns The "folder" part of the path
  34066. */
  34067. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34068. /**
  34069. * Extracts text content from a DOM element hierarchy
  34070. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34071. */
  34072. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34073. /**
  34074. * Convert an angle in radians to degrees
  34075. * @param angle defines the angle to convert
  34076. * @returns the angle in degrees
  34077. */
  34078. static ToDegrees(angle: number): number;
  34079. /**
  34080. * Convert an angle in degrees to radians
  34081. * @param angle defines the angle to convert
  34082. * @returns the angle in radians
  34083. */
  34084. static ToRadians(angle: number): number;
  34085. /**
  34086. * Returns an array if obj is not an array
  34087. * @param obj defines the object to evaluate as an array
  34088. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34089. * @returns either obj directly if obj is an array or a new array containing obj
  34090. */
  34091. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34092. /**
  34093. * Gets the pointer prefix to use
  34094. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34095. */
  34096. static GetPointerPrefix(): string;
  34097. /**
  34098. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34099. * @param url define the url we are trying
  34100. * @param element define the dom element where to configure the cors policy
  34101. */
  34102. static SetCorsBehavior(url: string | string[], element: {
  34103. crossOrigin: string | null;
  34104. }): void;
  34105. /**
  34106. * Removes unwanted characters from an url
  34107. * @param url defines the url to clean
  34108. * @returns the cleaned url
  34109. */
  34110. static CleanUrl(url: string): string;
  34111. /**
  34112. * Gets or sets a function used to pre-process url before using them to load assets
  34113. */
  34114. static get PreprocessUrl(): (url: string) => string;
  34115. static set PreprocessUrl(processor: (url: string) => string);
  34116. /**
  34117. * Loads an image as an HTMLImageElement.
  34118. * @param input url string, ArrayBuffer, or Blob to load
  34119. * @param onLoad callback called when the image successfully loads
  34120. * @param onError callback called when the image fails to load
  34121. * @param offlineProvider offline provider for caching
  34122. * @param mimeType optional mime type
  34123. * @returns the HTMLImageElement of the loaded image
  34124. */
  34125. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34126. /**
  34127. * Loads a file from a url
  34128. * @param url url string, ArrayBuffer, or Blob to load
  34129. * @param onSuccess callback called when the file successfully loads
  34130. * @param onProgress callback called while file is loading (if the server supports this mode)
  34131. * @param offlineProvider defines the offline provider for caching
  34132. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34133. * @param onError callback called when the file fails to load
  34134. * @returns a file request object
  34135. */
  34136. 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;
  34137. /**
  34138. * Loads a file from a url
  34139. * @param url the file url to load
  34140. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34141. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34142. */
  34143. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34144. /**
  34145. * Load a script (identified by an url). When the url returns, the
  34146. * content of this file is added into a new script element, attached to the DOM (body element)
  34147. * @param scriptUrl defines the url of the script to laod
  34148. * @param onSuccess defines the callback called when the script is loaded
  34149. * @param onError defines the callback to call if an error occurs
  34150. * @param scriptId defines the id of the script element
  34151. */
  34152. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34153. /**
  34154. * Load an asynchronous script (identified by an url). When the url returns, the
  34155. * content of this file is added into a new script element, attached to the DOM (body element)
  34156. * @param scriptUrl defines the url of the script to laod
  34157. * @param scriptId defines the id of the script element
  34158. * @returns a promise request object
  34159. */
  34160. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34161. /**
  34162. * Loads a file from a blob
  34163. * @param fileToLoad defines the blob to use
  34164. * @param callback defines the callback to call when data is loaded
  34165. * @param progressCallback defines the callback to call during loading process
  34166. * @returns a file request object
  34167. */
  34168. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34169. /**
  34170. * Reads a file from a File object
  34171. * @param file defines the file to load
  34172. * @param onSuccess defines the callback to call when data is loaded
  34173. * @param onProgress defines the callback to call during loading process
  34174. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34175. * @param onError defines the callback to call when an error occurs
  34176. * @returns a file request object
  34177. */
  34178. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34179. /**
  34180. * Creates a data url from a given string content
  34181. * @param content defines the content to convert
  34182. * @returns the new data url link
  34183. */
  34184. static FileAsURL(content: string): string;
  34185. /**
  34186. * Format the given number to a specific decimal format
  34187. * @param value defines the number to format
  34188. * @param decimals defines the number of decimals to use
  34189. * @returns the formatted string
  34190. */
  34191. static Format(value: number, decimals?: number): string;
  34192. /**
  34193. * Tries to copy an object by duplicating every property
  34194. * @param source defines the source object
  34195. * @param destination defines the target object
  34196. * @param doNotCopyList defines a list of properties to avoid
  34197. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34198. */
  34199. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34200. /**
  34201. * Gets a boolean indicating if the given object has no own property
  34202. * @param obj defines the object to test
  34203. * @returns true if object has no own property
  34204. */
  34205. static IsEmpty(obj: any): boolean;
  34206. /**
  34207. * Function used to register events at window level
  34208. * @param windowElement defines the Window object to use
  34209. * @param events defines the events to register
  34210. */
  34211. static RegisterTopRootEvents(windowElement: Window, events: {
  34212. name: string;
  34213. handler: Nullable<(e: FocusEvent) => any>;
  34214. }[]): void;
  34215. /**
  34216. * Function used to unregister events from window level
  34217. * @param windowElement defines the Window object to use
  34218. * @param events defines the events to unregister
  34219. */
  34220. static UnregisterTopRootEvents(windowElement: Window, events: {
  34221. name: string;
  34222. handler: Nullable<(e: FocusEvent) => any>;
  34223. }[]): void;
  34224. /**
  34225. * @ignore
  34226. */
  34227. static _ScreenshotCanvas: HTMLCanvasElement;
  34228. /**
  34229. * Dumps the current bound framebuffer
  34230. * @param width defines the rendering width
  34231. * @param height defines the rendering height
  34232. * @param engine defines the hosting engine
  34233. * @param successCallback defines the callback triggered once the data are available
  34234. * @param mimeType defines the mime type of the result
  34235. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34236. */
  34237. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34238. /**
  34239. * Converts the canvas data to blob.
  34240. * This acts as a polyfill for browsers not supporting the to blob function.
  34241. * @param canvas Defines the canvas to extract the data from
  34242. * @param successCallback Defines the callback triggered once the data are available
  34243. * @param mimeType Defines the mime type of the result
  34244. */
  34245. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34246. /**
  34247. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34248. * @param successCallback defines the callback triggered once the data are available
  34249. * @param mimeType defines the mime type of the result
  34250. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34251. */
  34252. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34253. /**
  34254. * Downloads a blob in the browser
  34255. * @param blob defines the blob to download
  34256. * @param fileName defines the name of the downloaded file
  34257. */
  34258. static Download(blob: Blob, fileName: string): void;
  34259. /**
  34260. * Captures a screenshot of the current rendering
  34261. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34262. * @param engine defines the rendering engine
  34263. * @param camera defines the source camera
  34264. * @param size This parameter can be set to a single number or to an object with the
  34265. * following (optional) properties: precision, width, height. If a single number is passed,
  34266. * it will be used for both width and height. If an object is passed, the screenshot size
  34267. * will be derived from the parameters. The precision property is a multiplier allowing
  34268. * rendering at a higher or lower resolution
  34269. * @param successCallback defines the callback receives a single parameter which contains the
  34270. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34271. * src parameter of an <img> to display it
  34272. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34273. * Check your browser for supported MIME types
  34274. */
  34275. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34276. /**
  34277. * Captures a screenshot of the current rendering
  34278. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34279. * @param engine defines the rendering engine
  34280. * @param camera defines the source camera
  34281. * @param size This parameter can be set to a single number or to an object with the
  34282. * following (optional) properties: precision, width, height. If a single number is passed,
  34283. * it will be used for both width and height. If an object is passed, the screenshot size
  34284. * will be derived from the parameters. The precision property is a multiplier allowing
  34285. * rendering at a higher or lower resolution
  34286. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34287. * Check your browser for supported MIME types
  34288. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34289. * to the src parameter of an <img> to display it
  34290. */
  34291. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34292. /**
  34293. * Generates an image screenshot from the specified camera.
  34294. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34295. * @param engine The engine to use for rendering
  34296. * @param camera The camera to use for rendering
  34297. * @param size This parameter can be set to a single number or to an object with the
  34298. * following (optional) properties: precision, width, height. If a single number is passed,
  34299. * it will be used for both width and height. If an object is passed, the screenshot size
  34300. * will be derived from the parameters. The precision property is a multiplier allowing
  34301. * rendering at a higher or lower resolution
  34302. * @param successCallback The callback receives a single parameter which contains the
  34303. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34304. * src parameter of an <img> to display it
  34305. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34306. * Check your browser for supported MIME types
  34307. * @param samples Texture samples (default: 1)
  34308. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34309. * @param fileName A name for for the downloaded file.
  34310. */
  34311. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34312. /**
  34313. * Generates an image screenshot from the specified camera.
  34314. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34315. * @param engine The engine to use for rendering
  34316. * @param camera The camera to use for rendering
  34317. * @param size This parameter can be set to a single number or to an object with the
  34318. * following (optional) properties: precision, width, height. If a single number is passed,
  34319. * it will be used for both width and height. If an object is passed, the screenshot size
  34320. * will be derived from the parameters. The precision property is a multiplier allowing
  34321. * rendering at a higher or lower resolution
  34322. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34323. * Check your browser for supported MIME types
  34324. * @param samples Texture samples (default: 1)
  34325. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34326. * @param fileName A name for for the downloaded file.
  34327. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34328. * to the src parameter of an <img> to display it
  34329. */
  34330. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34331. /**
  34332. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34333. * Be aware Math.random() could cause collisions, but:
  34334. * "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"
  34335. * @returns a pseudo random id
  34336. */
  34337. static RandomId(): string;
  34338. /**
  34339. * Test if the given uri is a base64 string
  34340. * @param uri The uri to test
  34341. * @return True if the uri is a base64 string or false otherwise
  34342. */
  34343. static IsBase64(uri: string): boolean;
  34344. /**
  34345. * Decode the given base64 uri.
  34346. * @param uri The uri to decode
  34347. * @return The decoded base64 data.
  34348. */
  34349. static DecodeBase64(uri: string): ArrayBuffer;
  34350. /**
  34351. * Gets the absolute url.
  34352. * @param url the input url
  34353. * @return the absolute url
  34354. */
  34355. static GetAbsoluteUrl(url: string): string;
  34356. /**
  34357. * No log
  34358. */
  34359. static readonly NoneLogLevel: number;
  34360. /**
  34361. * Only message logs
  34362. */
  34363. static readonly MessageLogLevel: number;
  34364. /**
  34365. * Only warning logs
  34366. */
  34367. static readonly WarningLogLevel: number;
  34368. /**
  34369. * Only error logs
  34370. */
  34371. static readonly ErrorLogLevel: number;
  34372. /**
  34373. * All logs
  34374. */
  34375. static readonly AllLogLevel: number;
  34376. /**
  34377. * Gets a value indicating the number of loading errors
  34378. * @ignorenaming
  34379. */
  34380. static get errorsCount(): number;
  34381. /**
  34382. * Callback called when a new log is added
  34383. */
  34384. static OnNewCacheEntry: (entry: string) => void;
  34385. /**
  34386. * Log a message to the console
  34387. * @param message defines the message to log
  34388. */
  34389. static Log(message: string): void;
  34390. /**
  34391. * Write a warning message to the console
  34392. * @param message defines the message to log
  34393. */
  34394. static Warn(message: string): void;
  34395. /**
  34396. * Write an error message to the console
  34397. * @param message defines the message to log
  34398. */
  34399. static Error(message: string): void;
  34400. /**
  34401. * Gets current log cache (list of logs)
  34402. */
  34403. static get LogCache(): string;
  34404. /**
  34405. * Clears the log cache
  34406. */
  34407. static ClearLogCache(): void;
  34408. /**
  34409. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34410. */
  34411. static set LogLevels(level: number);
  34412. /**
  34413. * Checks if the window object exists
  34414. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34415. */
  34416. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34417. /**
  34418. * No performance log
  34419. */
  34420. static readonly PerformanceNoneLogLevel: number;
  34421. /**
  34422. * Use user marks to log performance
  34423. */
  34424. static readonly PerformanceUserMarkLogLevel: number;
  34425. /**
  34426. * Log performance to the console
  34427. */
  34428. static readonly PerformanceConsoleLogLevel: number;
  34429. private static _performance;
  34430. /**
  34431. * Sets the current performance log level
  34432. */
  34433. static set PerformanceLogLevel(level: number);
  34434. private static _StartPerformanceCounterDisabled;
  34435. private static _EndPerformanceCounterDisabled;
  34436. private static _StartUserMark;
  34437. private static _EndUserMark;
  34438. private static _StartPerformanceConsole;
  34439. private static _EndPerformanceConsole;
  34440. /**
  34441. * Starts a performance counter
  34442. */
  34443. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34444. /**
  34445. * Ends a specific performance coutner
  34446. */
  34447. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34448. /**
  34449. * Gets either window.performance.now() if supported or Date.now() else
  34450. */
  34451. static get Now(): number;
  34452. /**
  34453. * This method will return the name of the class used to create the instance of the given object.
  34454. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34455. * @param object the object to get the class name from
  34456. * @param isType defines if the object is actually a type
  34457. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34458. */
  34459. static GetClassName(object: any, isType?: boolean): string;
  34460. /**
  34461. * Gets the first element of an array satisfying a given predicate
  34462. * @param array defines the array to browse
  34463. * @param predicate defines the predicate to use
  34464. * @returns null if not found or the element
  34465. */
  34466. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34467. /**
  34468. * This method will return the name of the full name of the class, including its owning module (if any).
  34469. * 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).
  34470. * @param object the object to get the class name from
  34471. * @param isType defines if the object is actually a type
  34472. * @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.
  34473. * @ignorenaming
  34474. */
  34475. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34476. /**
  34477. * Returns a promise that resolves after the given amount of time.
  34478. * @param delay Number of milliseconds to delay
  34479. * @returns Promise that resolves after the given amount of time
  34480. */
  34481. static DelayAsync(delay: number): Promise<void>;
  34482. /**
  34483. * Utility function to detect if the current user agent is Safari
  34484. * @returns whether or not the current user agent is safari
  34485. */
  34486. static IsSafari(): boolean;
  34487. }
  34488. /**
  34489. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34490. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34491. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34492. * @param name The name of the class, case should be preserved
  34493. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34494. */
  34495. export function className(name: string, module?: string): (target: Object) => void;
  34496. /**
  34497. * An implementation of a loop for asynchronous functions.
  34498. */
  34499. export class AsyncLoop {
  34500. /**
  34501. * Defines the number of iterations for the loop
  34502. */
  34503. iterations: number;
  34504. /**
  34505. * Defines the current index of the loop.
  34506. */
  34507. index: number;
  34508. private _done;
  34509. private _fn;
  34510. private _successCallback;
  34511. /**
  34512. * Constructor.
  34513. * @param iterations the number of iterations.
  34514. * @param func the function to run each iteration
  34515. * @param successCallback the callback that will be called upon succesful execution
  34516. * @param offset starting offset.
  34517. */
  34518. constructor(
  34519. /**
  34520. * Defines the number of iterations for the loop
  34521. */
  34522. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34523. /**
  34524. * Execute the next iteration. Must be called after the last iteration was finished.
  34525. */
  34526. executeNext(): void;
  34527. /**
  34528. * Break the loop and run the success callback.
  34529. */
  34530. breakLoop(): void;
  34531. /**
  34532. * Create and run an async loop.
  34533. * @param iterations the number of iterations.
  34534. * @param fn the function to run each iteration
  34535. * @param successCallback the callback that will be called upon succesful execution
  34536. * @param offset starting offset.
  34537. * @returns the created async loop object
  34538. */
  34539. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34540. /**
  34541. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34542. * @param iterations total number of iterations
  34543. * @param syncedIterations number of synchronous iterations in each async iteration.
  34544. * @param fn the function to call each iteration.
  34545. * @param callback a success call back that will be called when iterating stops.
  34546. * @param breakFunction a break condition (optional)
  34547. * @param timeout timeout settings for the setTimeout function. default - 0.
  34548. * @returns the created async loop object
  34549. */
  34550. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34551. }
  34552. }
  34553. declare module BABYLON {
  34554. /**
  34555. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34556. * The underlying implementation relies on an associative array to ensure the best performances.
  34557. * The value can be anything including 'null' but except 'undefined'
  34558. */
  34559. export class StringDictionary<T> {
  34560. /**
  34561. * This will clear this dictionary and copy the content from the 'source' one.
  34562. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34563. * @param source the dictionary to take the content from and copy to this dictionary
  34564. */
  34565. copyFrom(source: StringDictionary<T>): void;
  34566. /**
  34567. * Get a value based from its key
  34568. * @param key the given key to get the matching value from
  34569. * @return the value if found, otherwise undefined is returned
  34570. */
  34571. get(key: string): T | undefined;
  34572. /**
  34573. * Get a value from its key or add it if it doesn't exist.
  34574. * This method will ensure you that a given key/data will be present in the dictionary.
  34575. * @param key the given key to get the matching value from
  34576. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34577. * The factory will only be invoked if there's no data for the given key.
  34578. * @return the value corresponding to the key.
  34579. */
  34580. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34581. /**
  34582. * Get a value from its key if present in the dictionary otherwise add it
  34583. * @param key the key to get the value from
  34584. * @param val if there's no such key/value pair in the dictionary add it with this value
  34585. * @return the value corresponding to the key
  34586. */
  34587. getOrAdd(key: string, val: T): T;
  34588. /**
  34589. * Check if there's a given key in the dictionary
  34590. * @param key the key to check for
  34591. * @return true if the key is present, false otherwise
  34592. */
  34593. contains(key: string): boolean;
  34594. /**
  34595. * Add a new key and its corresponding value
  34596. * @param key the key to add
  34597. * @param value the value corresponding to the key
  34598. * @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
  34599. */
  34600. add(key: string, value: T): boolean;
  34601. /**
  34602. * Update a specific value associated to a key
  34603. * @param key defines the key to use
  34604. * @param value defines the value to store
  34605. * @returns true if the value was updated (or false if the key was not found)
  34606. */
  34607. set(key: string, value: T): boolean;
  34608. /**
  34609. * Get the element of the given key and remove it from the dictionary
  34610. * @param key defines the key to search
  34611. * @returns the value associated with the key or null if not found
  34612. */
  34613. getAndRemove(key: string): Nullable<T>;
  34614. /**
  34615. * Remove a key/value from the dictionary.
  34616. * @param key the key to remove
  34617. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34618. */
  34619. remove(key: string): boolean;
  34620. /**
  34621. * Clear the whole content of the dictionary
  34622. */
  34623. clear(): void;
  34624. /**
  34625. * Gets the current count
  34626. */
  34627. get count(): number;
  34628. /**
  34629. * Execute a callback on each key/val of the dictionary.
  34630. * Note that you can remove any element in this dictionary in the callback implementation
  34631. * @param callback the callback to execute on a given key/value pair
  34632. */
  34633. forEach(callback: (key: string, val: T) => void): void;
  34634. /**
  34635. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34636. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34637. * Note that you can remove any element in this dictionary in the callback implementation
  34638. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34639. * @returns the first item
  34640. */
  34641. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34642. private _count;
  34643. private _data;
  34644. }
  34645. }
  34646. declare module BABYLON {
  34647. /** @hidden */
  34648. export interface ICollisionCoordinator {
  34649. createCollider(): Collider;
  34650. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34651. init(scene: Scene): void;
  34652. }
  34653. /** @hidden */
  34654. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34655. private _scene;
  34656. private _scaledPosition;
  34657. private _scaledVelocity;
  34658. private _finalPosition;
  34659. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34660. createCollider(): Collider;
  34661. init(scene: Scene): void;
  34662. private _collideWithWorld;
  34663. }
  34664. }
  34665. declare module BABYLON {
  34666. /**
  34667. * Class used to manage all inputs for the scene.
  34668. */
  34669. export class InputManager {
  34670. /** The distance in pixel that you have to move to prevent some events */
  34671. static DragMovementThreshold: number;
  34672. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34673. static LongPressDelay: number;
  34674. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34675. static DoubleClickDelay: number;
  34676. /** If you need to check double click without raising a single click at first click, enable this flag */
  34677. static ExclusiveDoubleClickMode: boolean;
  34678. private _wheelEventName;
  34679. private _onPointerMove;
  34680. private _onPointerDown;
  34681. private _onPointerUp;
  34682. private _initClickEvent;
  34683. private _initActionManager;
  34684. private _delayedSimpleClick;
  34685. private _delayedSimpleClickTimeout;
  34686. private _previousDelayedSimpleClickTimeout;
  34687. private _meshPickProceed;
  34688. private _previousButtonPressed;
  34689. private _currentPickResult;
  34690. private _previousPickResult;
  34691. private _totalPointersPressed;
  34692. private _doubleClickOccured;
  34693. private _pointerOverMesh;
  34694. private _pickedDownMesh;
  34695. private _pickedUpMesh;
  34696. private _pointerX;
  34697. private _pointerY;
  34698. private _unTranslatedPointerX;
  34699. private _unTranslatedPointerY;
  34700. private _startingPointerPosition;
  34701. private _previousStartingPointerPosition;
  34702. private _startingPointerTime;
  34703. private _previousStartingPointerTime;
  34704. private _pointerCaptures;
  34705. private _onKeyDown;
  34706. private _onKeyUp;
  34707. private _onCanvasFocusObserver;
  34708. private _onCanvasBlurObserver;
  34709. private _scene;
  34710. /**
  34711. * Creates a new InputManager
  34712. * @param scene defines the hosting scene
  34713. */
  34714. constructor(scene: Scene);
  34715. /**
  34716. * Gets the mesh that is currently under the pointer
  34717. */
  34718. get meshUnderPointer(): Nullable<AbstractMesh>;
  34719. /**
  34720. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34721. */
  34722. get unTranslatedPointer(): Vector2;
  34723. /**
  34724. * Gets or sets the current on-screen X position of the pointer
  34725. */
  34726. get pointerX(): number;
  34727. set pointerX(value: number);
  34728. /**
  34729. * Gets or sets the current on-screen Y position of the pointer
  34730. */
  34731. get pointerY(): number;
  34732. set pointerY(value: number);
  34733. private _updatePointerPosition;
  34734. private _processPointerMove;
  34735. private _setRayOnPointerInfo;
  34736. private _checkPrePointerObservable;
  34737. /**
  34738. * Use this method to simulate a pointer move on a mesh
  34739. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34740. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34741. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34742. */
  34743. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34744. /**
  34745. * Use this method to simulate a pointer down on a mesh
  34746. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34747. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34748. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34749. */
  34750. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34751. private _processPointerDown;
  34752. /** @hidden */
  34753. _isPointerSwiping(): boolean;
  34754. /**
  34755. * Use this method to simulate a pointer up on a mesh
  34756. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34757. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34758. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34759. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34760. */
  34761. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34762. private _processPointerUp;
  34763. /**
  34764. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34765. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34766. * @returns true if the pointer was captured
  34767. */
  34768. isPointerCaptured(pointerId?: number): boolean;
  34769. /**
  34770. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34771. * @param attachUp defines if you want to attach events to pointerup
  34772. * @param attachDown defines if you want to attach events to pointerdown
  34773. * @param attachMove defines if you want to attach events to pointermove
  34774. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34775. */
  34776. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34777. /**
  34778. * Detaches all event handlers
  34779. */
  34780. detachControl(): void;
  34781. /**
  34782. * Force the value of meshUnderPointer
  34783. * @param mesh defines the mesh to use
  34784. */
  34785. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34786. /**
  34787. * Gets the mesh under the pointer
  34788. * @returns a Mesh or null if no mesh is under the pointer
  34789. */
  34790. getPointerOverMesh(): Nullable<AbstractMesh>;
  34791. }
  34792. }
  34793. declare module BABYLON {
  34794. /**
  34795. * Helper class used to generate session unique ID
  34796. */
  34797. export class UniqueIdGenerator {
  34798. private static _UniqueIdCounter;
  34799. /**
  34800. * Gets an unique (relatively to the current scene) Id
  34801. */
  34802. static get UniqueId(): number;
  34803. }
  34804. }
  34805. declare module BABYLON {
  34806. /**
  34807. * This class defines the direct association between an animation and a target
  34808. */
  34809. export class TargetedAnimation {
  34810. /**
  34811. * Animation to perform
  34812. */
  34813. animation: Animation;
  34814. /**
  34815. * Target to animate
  34816. */
  34817. target: any;
  34818. /**
  34819. * Serialize the object
  34820. * @returns the JSON object representing the current entity
  34821. */
  34822. serialize(): any;
  34823. }
  34824. /**
  34825. * Use this class to create coordinated animations on multiple targets
  34826. */
  34827. export class AnimationGroup implements IDisposable {
  34828. /** The name of the animation group */
  34829. name: string;
  34830. private _scene;
  34831. private _targetedAnimations;
  34832. private _animatables;
  34833. private _from;
  34834. private _to;
  34835. private _isStarted;
  34836. private _isPaused;
  34837. private _speedRatio;
  34838. private _loopAnimation;
  34839. /**
  34840. * Gets or sets the unique id of the node
  34841. */
  34842. uniqueId: number;
  34843. /**
  34844. * This observable will notify when one animation have ended
  34845. */
  34846. onAnimationEndObservable: Observable<TargetedAnimation>;
  34847. /**
  34848. * Observer raised when one animation loops
  34849. */
  34850. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34851. /**
  34852. * Observer raised when all animations have looped
  34853. */
  34854. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34855. /**
  34856. * This observable will notify when all animations have ended.
  34857. */
  34858. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34859. /**
  34860. * This observable will notify when all animations have paused.
  34861. */
  34862. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34863. /**
  34864. * This observable will notify when all animations are playing.
  34865. */
  34866. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34867. /**
  34868. * Gets the first frame
  34869. */
  34870. get from(): number;
  34871. /**
  34872. * Gets the last frame
  34873. */
  34874. get to(): number;
  34875. /**
  34876. * Define if the animations are started
  34877. */
  34878. get isStarted(): boolean;
  34879. /**
  34880. * Gets a value indicating that the current group is playing
  34881. */
  34882. get isPlaying(): boolean;
  34883. /**
  34884. * Gets or sets the speed ratio to use for all animations
  34885. */
  34886. get speedRatio(): number;
  34887. /**
  34888. * Gets or sets the speed ratio to use for all animations
  34889. */
  34890. set speedRatio(value: number);
  34891. /**
  34892. * Gets or sets if all animations should loop or not
  34893. */
  34894. get loopAnimation(): boolean;
  34895. set loopAnimation(value: boolean);
  34896. /**
  34897. * Gets the targeted animations for this animation group
  34898. */
  34899. get targetedAnimations(): Array<TargetedAnimation>;
  34900. /**
  34901. * returning the list of animatables controlled by this animation group.
  34902. */
  34903. get animatables(): Array<Animatable>;
  34904. /**
  34905. * Instantiates a new Animation Group.
  34906. * This helps managing several animations at once.
  34907. * @see http://doc.babylonjs.com/how_to/group
  34908. * @param name Defines the name of the group
  34909. * @param scene Defines the scene the group belongs to
  34910. */
  34911. constructor(
  34912. /** The name of the animation group */
  34913. name: string, scene?: Nullable<Scene>);
  34914. /**
  34915. * Add an animation (with its target) in the group
  34916. * @param animation defines the animation we want to add
  34917. * @param target defines the target of the animation
  34918. * @returns the TargetedAnimation object
  34919. */
  34920. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34921. /**
  34922. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34923. * It can add constant keys at begin or end
  34924. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34925. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34926. * @returns the animation group
  34927. */
  34928. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34929. private _animationLoopCount;
  34930. private _animationLoopFlags;
  34931. private _processLoop;
  34932. /**
  34933. * Start all animations on given targets
  34934. * @param loop defines if animations must loop
  34935. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34936. * @param from defines the from key (optional)
  34937. * @param to defines the to key (optional)
  34938. * @returns the current animation group
  34939. */
  34940. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34941. /**
  34942. * Pause all animations
  34943. * @returns the animation group
  34944. */
  34945. pause(): AnimationGroup;
  34946. /**
  34947. * Play all animations to initial state
  34948. * This function will start() the animations if they were not started or will restart() them if they were paused
  34949. * @param loop defines if animations must loop
  34950. * @returns the animation group
  34951. */
  34952. play(loop?: boolean): AnimationGroup;
  34953. /**
  34954. * Reset all animations to initial state
  34955. * @returns the animation group
  34956. */
  34957. reset(): AnimationGroup;
  34958. /**
  34959. * Restart animations from key 0
  34960. * @returns the animation group
  34961. */
  34962. restart(): AnimationGroup;
  34963. /**
  34964. * Stop all animations
  34965. * @returns the animation group
  34966. */
  34967. stop(): AnimationGroup;
  34968. /**
  34969. * Set animation weight for all animatables
  34970. * @param weight defines the weight to use
  34971. * @return the animationGroup
  34972. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34973. */
  34974. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34975. /**
  34976. * Synchronize and normalize all animatables with a source animatable
  34977. * @param root defines the root animatable to synchronize with
  34978. * @return the animationGroup
  34979. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34980. */
  34981. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34982. /**
  34983. * Goes to a specific frame in this animation group
  34984. * @param frame the frame number to go to
  34985. * @return the animationGroup
  34986. */
  34987. goToFrame(frame: number): AnimationGroup;
  34988. /**
  34989. * Dispose all associated resources
  34990. */
  34991. dispose(): void;
  34992. private _checkAnimationGroupEnded;
  34993. /**
  34994. * Clone the current animation group and returns a copy
  34995. * @param newName defines the name of the new group
  34996. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34997. * @returns the new aniamtion group
  34998. */
  34999. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35000. /**
  35001. * Serializes the animationGroup to an object
  35002. * @returns Serialized object
  35003. */
  35004. serialize(): any;
  35005. /**
  35006. * Returns a new AnimationGroup object parsed from the source provided.
  35007. * @param parsedAnimationGroup defines the source
  35008. * @param scene defines the scene that will receive the animationGroup
  35009. * @returns a new AnimationGroup
  35010. */
  35011. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35012. /**
  35013. * Returns the string "AnimationGroup"
  35014. * @returns "AnimationGroup"
  35015. */
  35016. getClassName(): string;
  35017. /**
  35018. * Creates a detailled string about the object
  35019. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35020. * @returns a string representing the object
  35021. */
  35022. toString(fullDetails?: boolean): string;
  35023. }
  35024. }
  35025. declare module BABYLON {
  35026. /**
  35027. * Define an interface for all classes that will hold resources
  35028. */
  35029. export interface IDisposable {
  35030. /**
  35031. * Releases all held resources
  35032. */
  35033. dispose(): void;
  35034. }
  35035. /** Interface defining initialization parameters for Scene class */
  35036. export interface SceneOptions {
  35037. /**
  35038. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35039. * It will improve performance when the number of geometries becomes important.
  35040. */
  35041. useGeometryUniqueIdsMap?: boolean;
  35042. /**
  35043. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35044. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35045. */
  35046. useMaterialMeshMap?: boolean;
  35047. /**
  35048. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35049. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35050. */
  35051. useClonedMeshMap?: boolean;
  35052. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35053. virtual?: boolean;
  35054. }
  35055. /**
  35056. * Represents a scene to be rendered by the engine.
  35057. * @see http://doc.babylonjs.com/features/scene
  35058. */
  35059. export class Scene extends AbstractScene implements IAnimatable {
  35060. /** The fog is deactivated */
  35061. static readonly FOGMODE_NONE: number;
  35062. /** The fog density is following an exponential function */
  35063. static readonly FOGMODE_EXP: number;
  35064. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35065. static readonly FOGMODE_EXP2: number;
  35066. /** The fog density is following a linear function. */
  35067. static readonly FOGMODE_LINEAR: number;
  35068. /**
  35069. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35070. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35071. */
  35072. static MinDeltaTime: number;
  35073. /**
  35074. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35075. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35076. */
  35077. static MaxDeltaTime: number;
  35078. /**
  35079. * Factory used to create the default material.
  35080. * @param name The name of the material to create
  35081. * @param scene The scene to create the material for
  35082. * @returns The default material
  35083. */
  35084. static DefaultMaterialFactory(scene: Scene): Material;
  35085. /**
  35086. * Factory used to create the a collision coordinator.
  35087. * @returns The collision coordinator
  35088. */
  35089. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35090. /** @hidden */
  35091. _inputManager: InputManager;
  35092. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35093. cameraToUseForPointers: Nullable<Camera>;
  35094. /** @hidden */
  35095. readonly _isScene: boolean;
  35096. /** @hidden */
  35097. _blockEntityCollection: boolean;
  35098. /**
  35099. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35100. */
  35101. autoClear: boolean;
  35102. /**
  35103. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35104. */
  35105. autoClearDepthAndStencil: boolean;
  35106. /**
  35107. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35108. */
  35109. clearColor: Color4;
  35110. /**
  35111. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35112. */
  35113. ambientColor: Color3;
  35114. /**
  35115. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35116. * It should only be one of the following (if not the default embedded one):
  35117. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35118. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35119. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35120. * The material properties need to be setup according to the type of texture in use.
  35121. */
  35122. environmentBRDFTexture: BaseTexture;
  35123. /** @hidden */
  35124. protected _environmentTexture: Nullable<BaseTexture>;
  35125. /**
  35126. * Texture used in all pbr material as the reflection texture.
  35127. * As in the majority of the scene they are the same (exception for multi room and so on),
  35128. * this is easier to reference from here than from all the materials.
  35129. */
  35130. get environmentTexture(): Nullable<BaseTexture>;
  35131. /**
  35132. * Texture used in all pbr material as the reflection texture.
  35133. * As in the majority of the scene they are the same (exception for multi room and so on),
  35134. * this is easier to set here than in all the materials.
  35135. */
  35136. set environmentTexture(value: Nullable<BaseTexture>);
  35137. /** @hidden */
  35138. protected _environmentIntensity: number;
  35139. /**
  35140. * Intensity of the environment in all pbr material.
  35141. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35142. * As in the majority of the scene they are the same (exception for multi room and so on),
  35143. * this is easier to reference from here than from all the materials.
  35144. */
  35145. get environmentIntensity(): number;
  35146. /**
  35147. * Intensity of the environment in all pbr material.
  35148. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35149. * As in the majority of the scene they are the same (exception for multi room and so on),
  35150. * this is easier to set here than in all the materials.
  35151. */
  35152. set environmentIntensity(value: number);
  35153. /** @hidden */
  35154. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35155. /**
  35156. * Default image processing configuration used either in the rendering
  35157. * Forward main pass or through the imageProcessingPostProcess if present.
  35158. * As in the majority of the scene they are the same (exception for multi camera),
  35159. * this is easier to reference from here than from all the materials and post process.
  35160. *
  35161. * No setter as we it is a shared configuration, you can set the values instead.
  35162. */
  35163. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35164. private _forceWireframe;
  35165. /**
  35166. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35167. */
  35168. set forceWireframe(value: boolean);
  35169. get forceWireframe(): boolean;
  35170. private _skipFrustumClipping;
  35171. /**
  35172. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35173. */
  35174. set skipFrustumClipping(value: boolean);
  35175. get skipFrustumClipping(): boolean;
  35176. private _forcePointsCloud;
  35177. /**
  35178. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35179. */
  35180. set forcePointsCloud(value: boolean);
  35181. get forcePointsCloud(): boolean;
  35182. /**
  35183. * Gets or sets the active clipplane 1
  35184. */
  35185. clipPlane: Nullable<Plane>;
  35186. /**
  35187. * Gets or sets the active clipplane 2
  35188. */
  35189. clipPlane2: Nullable<Plane>;
  35190. /**
  35191. * Gets or sets the active clipplane 3
  35192. */
  35193. clipPlane3: Nullable<Plane>;
  35194. /**
  35195. * Gets or sets the active clipplane 4
  35196. */
  35197. clipPlane4: Nullable<Plane>;
  35198. /**
  35199. * Gets or sets the active clipplane 5
  35200. */
  35201. clipPlane5: Nullable<Plane>;
  35202. /**
  35203. * Gets or sets the active clipplane 6
  35204. */
  35205. clipPlane6: Nullable<Plane>;
  35206. /**
  35207. * Gets or sets a boolean indicating if animations are enabled
  35208. */
  35209. animationsEnabled: boolean;
  35210. private _animationPropertiesOverride;
  35211. /**
  35212. * Gets or sets the animation properties override
  35213. */
  35214. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35215. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35216. /**
  35217. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35218. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35219. */
  35220. useConstantAnimationDeltaTime: boolean;
  35221. /**
  35222. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35223. * Please note that it requires to run a ray cast through the scene on every frame
  35224. */
  35225. constantlyUpdateMeshUnderPointer: boolean;
  35226. /**
  35227. * Defines the HTML cursor to use when hovering over interactive elements
  35228. */
  35229. hoverCursor: string;
  35230. /**
  35231. * Defines the HTML default cursor to use (empty by default)
  35232. */
  35233. defaultCursor: string;
  35234. /**
  35235. * Defines whether cursors are handled by the scene.
  35236. */
  35237. doNotHandleCursors: boolean;
  35238. /**
  35239. * This is used to call preventDefault() on pointer down
  35240. * in order to block unwanted artifacts like system double clicks
  35241. */
  35242. preventDefaultOnPointerDown: boolean;
  35243. /**
  35244. * This is used to call preventDefault() on pointer up
  35245. * in order to block unwanted artifacts like system double clicks
  35246. */
  35247. preventDefaultOnPointerUp: boolean;
  35248. /**
  35249. * Gets or sets user defined metadata
  35250. */
  35251. metadata: any;
  35252. /**
  35253. * For internal use only. Please do not use.
  35254. */
  35255. reservedDataStore: any;
  35256. /**
  35257. * Gets the name of the plugin used to load this scene (null by default)
  35258. */
  35259. loadingPluginName: string;
  35260. /**
  35261. * Use this array to add regular expressions used to disable offline support for specific urls
  35262. */
  35263. disableOfflineSupportExceptionRules: RegExp[];
  35264. /**
  35265. * An event triggered when the scene is disposed.
  35266. */
  35267. onDisposeObservable: Observable<Scene>;
  35268. private _onDisposeObserver;
  35269. /** Sets a function to be executed when this scene is disposed. */
  35270. set onDispose(callback: () => void);
  35271. /**
  35272. * An event triggered before rendering the scene (right after animations and physics)
  35273. */
  35274. onBeforeRenderObservable: Observable<Scene>;
  35275. private _onBeforeRenderObserver;
  35276. /** Sets a function to be executed before rendering this scene */
  35277. set beforeRender(callback: Nullable<() => void>);
  35278. /**
  35279. * An event triggered after rendering the scene
  35280. */
  35281. onAfterRenderObservable: Observable<Scene>;
  35282. /**
  35283. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35284. */
  35285. onAfterRenderCameraObservable: Observable<Camera>;
  35286. private _onAfterRenderObserver;
  35287. /** Sets a function to be executed after rendering this scene */
  35288. set afterRender(callback: Nullable<() => void>);
  35289. /**
  35290. * An event triggered before animating the scene
  35291. */
  35292. onBeforeAnimationsObservable: Observable<Scene>;
  35293. /**
  35294. * An event triggered after animations processing
  35295. */
  35296. onAfterAnimationsObservable: Observable<Scene>;
  35297. /**
  35298. * An event triggered before draw calls are ready to be sent
  35299. */
  35300. onBeforeDrawPhaseObservable: Observable<Scene>;
  35301. /**
  35302. * An event triggered after draw calls have been sent
  35303. */
  35304. onAfterDrawPhaseObservable: Observable<Scene>;
  35305. /**
  35306. * An event triggered when the scene is ready
  35307. */
  35308. onReadyObservable: Observable<Scene>;
  35309. /**
  35310. * An event triggered before rendering a camera
  35311. */
  35312. onBeforeCameraRenderObservable: Observable<Camera>;
  35313. private _onBeforeCameraRenderObserver;
  35314. /** Sets a function to be executed before rendering a camera*/
  35315. set beforeCameraRender(callback: () => void);
  35316. /**
  35317. * An event triggered after rendering a camera
  35318. */
  35319. onAfterCameraRenderObservable: Observable<Camera>;
  35320. private _onAfterCameraRenderObserver;
  35321. /** Sets a function to be executed after rendering a camera*/
  35322. set afterCameraRender(callback: () => void);
  35323. /**
  35324. * An event triggered when active meshes evaluation is about to start
  35325. */
  35326. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35327. /**
  35328. * An event triggered when active meshes evaluation is done
  35329. */
  35330. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35331. /**
  35332. * An event triggered when particles rendering is about to start
  35333. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35334. */
  35335. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35336. /**
  35337. * An event triggered when particles rendering is done
  35338. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35339. */
  35340. onAfterParticlesRenderingObservable: Observable<Scene>;
  35341. /**
  35342. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35343. */
  35344. onDataLoadedObservable: Observable<Scene>;
  35345. /**
  35346. * An event triggered when a camera is created
  35347. */
  35348. onNewCameraAddedObservable: Observable<Camera>;
  35349. /**
  35350. * An event triggered when a camera is removed
  35351. */
  35352. onCameraRemovedObservable: Observable<Camera>;
  35353. /**
  35354. * An event triggered when a light is created
  35355. */
  35356. onNewLightAddedObservable: Observable<Light>;
  35357. /**
  35358. * An event triggered when a light is removed
  35359. */
  35360. onLightRemovedObservable: Observable<Light>;
  35361. /**
  35362. * An event triggered when a geometry is created
  35363. */
  35364. onNewGeometryAddedObservable: Observable<Geometry>;
  35365. /**
  35366. * An event triggered when a geometry is removed
  35367. */
  35368. onGeometryRemovedObservable: Observable<Geometry>;
  35369. /**
  35370. * An event triggered when a transform node is created
  35371. */
  35372. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35373. /**
  35374. * An event triggered when a transform node is removed
  35375. */
  35376. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35377. /**
  35378. * An event triggered when a mesh is created
  35379. */
  35380. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35381. /**
  35382. * An event triggered when a mesh is removed
  35383. */
  35384. onMeshRemovedObservable: Observable<AbstractMesh>;
  35385. /**
  35386. * An event triggered when a skeleton is created
  35387. */
  35388. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35389. /**
  35390. * An event triggered when a skeleton is removed
  35391. */
  35392. onSkeletonRemovedObservable: Observable<Skeleton>;
  35393. /**
  35394. * An event triggered when a material is created
  35395. */
  35396. onNewMaterialAddedObservable: Observable<Material>;
  35397. /**
  35398. * An event triggered when a material is removed
  35399. */
  35400. onMaterialRemovedObservable: Observable<Material>;
  35401. /**
  35402. * An event triggered when a texture is created
  35403. */
  35404. onNewTextureAddedObservable: Observable<BaseTexture>;
  35405. /**
  35406. * An event triggered when a texture is removed
  35407. */
  35408. onTextureRemovedObservable: Observable<BaseTexture>;
  35409. /**
  35410. * An event triggered when render targets are about to be rendered
  35411. * Can happen multiple times per frame.
  35412. */
  35413. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35414. /**
  35415. * An event triggered when render targets were rendered.
  35416. * Can happen multiple times per frame.
  35417. */
  35418. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35419. /**
  35420. * An event triggered before calculating deterministic simulation step
  35421. */
  35422. onBeforeStepObservable: Observable<Scene>;
  35423. /**
  35424. * An event triggered after calculating deterministic simulation step
  35425. */
  35426. onAfterStepObservable: Observable<Scene>;
  35427. /**
  35428. * An event triggered when the activeCamera property is updated
  35429. */
  35430. onActiveCameraChanged: Observable<Scene>;
  35431. /**
  35432. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35433. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35434. * 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)
  35435. */
  35436. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35437. /**
  35438. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35439. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35440. * 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)
  35441. */
  35442. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35443. /**
  35444. * This Observable will when a mesh has been imported into the scene.
  35445. */
  35446. onMeshImportedObservable: Observable<AbstractMesh>;
  35447. /**
  35448. * This Observable will when an animation file has been imported into the scene.
  35449. */
  35450. onAnimationFileImportedObservable: Observable<Scene>;
  35451. /**
  35452. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35453. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35454. */
  35455. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35456. /** @hidden */
  35457. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35458. /**
  35459. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35460. */
  35461. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35462. /**
  35463. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35464. */
  35465. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35466. /**
  35467. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35468. */
  35469. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35470. /** Callback called when a pointer move is detected */
  35471. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35472. /** Callback called when a pointer down is detected */
  35473. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35474. /** Callback called when a pointer up is detected */
  35475. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35476. /** Callback called when a pointer pick is detected */
  35477. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35478. /**
  35479. * 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).
  35480. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35481. */
  35482. onPrePointerObservable: Observable<PointerInfoPre>;
  35483. /**
  35484. * Observable event triggered each time an input event is received from the rendering canvas
  35485. */
  35486. onPointerObservable: Observable<PointerInfo>;
  35487. /**
  35488. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35489. */
  35490. get unTranslatedPointer(): Vector2;
  35491. /**
  35492. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35493. */
  35494. static get DragMovementThreshold(): number;
  35495. static set DragMovementThreshold(value: number);
  35496. /**
  35497. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35498. */
  35499. static get LongPressDelay(): number;
  35500. static set LongPressDelay(value: number);
  35501. /**
  35502. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35503. */
  35504. static get DoubleClickDelay(): number;
  35505. static set DoubleClickDelay(value: number);
  35506. /** If you need to check double click without raising a single click at first click, enable this flag */
  35507. static get ExclusiveDoubleClickMode(): boolean;
  35508. static set ExclusiveDoubleClickMode(value: boolean);
  35509. /** @hidden */
  35510. _mirroredCameraPosition: Nullable<Vector3>;
  35511. /**
  35512. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35513. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35514. */
  35515. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35516. /**
  35517. * Observable event triggered each time an keyboard event is received from the hosting window
  35518. */
  35519. onKeyboardObservable: Observable<KeyboardInfo>;
  35520. private _useRightHandedSystem;
  35521. /**
  35522. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35523. */
  35524. set useRightHandedSystem(value: boolean);
  35525. get useRightHandedSystem(): boolean;
  35526. private _timeAccumulator;
  35527. private _currentStepId;
  35528. private _currentInternalStep;
  35529. /**
  35530. * Sets the step Id used by deterministic lock step
  35531. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35532. * @param newStepId defines the step Id
  35533. */
  35534. setStepId(newStepId: number): void;
  35535. /**
  35536. * Gets the step Id used by deterministic lock step
  35537. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35538. * @returns the step Id
  35539. */
  35540. getStepId(): number;
  35541. /**
  35542. * Gets the internal step used by deterministic lock step
  35543. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35544. * @returns the internal step
  35545. */
  35546. getInternalStep(): number;
  35547. private _fogEnabled;
  35548. /**
  35549. * Gets or sets a boolean indicating if fog is enabled on this scene
  35550. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35551. * (Default is true)
  35552. */
  35553. set fogEnabled(value: boolean);
  35554. get fogEnabled(): boolean;
  35555. private _fogMode;
  35556. /**
  35557. * Gets or sets the fog mode to use
  35558. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35559. * | mode | value |
  35560. * | --- | --- |
  35561. * | FOGMODE_NONE | 0 |
  35562. * | FOGMODE_EXP | 1 |
  35563. * | FOGMODE_EXP2 | 2 |
  35564. * | FOGMODE_LINEAR | 3 |
  35565. */
  35566. set fogMode(value: number);
  35567. get fogMode(): number;
  35568. /**
  35569. * Gets or sets the fog color to use
  35570. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35571. * (Default is Color3(0.2, 0.2, 0.3))
  35572. */
  35573. fogColor: Color3;
  35574. /**
  35575. * Gets or sets the fog density to use
  35576. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35577. * (Default is 0.1)
  35578. */
  35579. fogDensity: number;
  35580. /**
  35581. * Gets or sets the fog start distance to use
  35582. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35583. * (Default is 0)
  35584. */
  35585. fogStart: number;
  35586. /**
  35587. * Gets or sets the fog end distance to use
  35588. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35589. * (Default is 1000)
  35590. */
  35591. fogEnd: number;
  35592. private _shadowsEnabled;
  35593. /**
  35594. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35595. */
  35596. set shadowsEnabled(value: boolean);
  35597. get shadowsEnabled(): boolean;
  35598. private _lightsEnabled;
  35599. /**
  35600. * Gets or sets a boolean indicating if lights are enabled on this scene
  35601. */
  35602. set lightsEnabled(value: boolean);
  35603. get lightsEnabled(): boolean;
  35604. /** All of the active cameras added to this scene. */
  35605. activeCameras: Camera[];
  35606. /** @hidden */
  35607. _activeCamera: Nullable<Camera>;
  35608. /** Gets or sets the current active camera */
  35609. get activeCamera(): Nullable<Camera>;
  35610. set activeCamera(value: Nullable<Camera>);
  35611. private _defaultMaterial;
  35612. /** The default material used on meshes when no material is affected */
  35613. get defaultMaterial(): Material;
  35614. /** The default material used on meshes when no material is affected */
  35615. set defaultMaterial(value: Material);
  35616. private _texturesEnabled;
  35617. /**
  35618. * Gets or sets a boolean indicating if textures are enabled on this scene
  35619. */
  35620. set texturesEnabled(value: boolean);
  35621. get texturesEnabled(): boolean;
  35622. /**
  35623. * Gets or sets a boolean indicating if particles are enabled on this scene
  35624. */
  35625. particlesEnabled: boolean;
  35626. /**
  35627. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35628. */
  35629. spritesEnabled: boolean;
  35630. private _skeletonsEnabled;
  35631. /**
  35632. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35633. */
  35634. set skeletonsEnabled(value: boolean);
  35635. get skeletonsEnabled(): boolean;
  35636. /**
  35637. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35638. */
  35639. lensFlaresEnabled: boolean;
  35640. /**
  35641. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35642. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35643. */
  35644. collisionsEnabled: boolean;
  35645. private _collisionCoordinator;
  35646. /** @hidden */
  35647. get collisionCoordinator(): ICollisionCoordinator;
  35648. /**
  35649. * Defines the gravity applied to this scene (used only for collisions)
  35650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35651. */
  35652. gravity: Vector3;
  35653. /**
  35654. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35655. */
  35656. postProcessesEnabled: boolean;
  35657. /**
  35658. * The list of postprocesses added to the scene
  35659. */
  35660. postProcesses: PostProcess[];
  35661. /**
  35662. * Gets the current postprocess manager
  35663. */
  35664. postProcessManager: PostProcessManager;
  35665. /**
  35666. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35667. */
  35668. renderTargetsEnabled: boolean;
  35669. /**
  35670. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35671. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35672. */
  35673. dumpNextRenderTargets: boolean;
  35674. /**
  35675. * The list of user defined render targets added to the scene
  35676. */
  35677. customRenderTargets: RenderTargetTexture[];
  35678. /**
  35679. * Defines if texture loading must be delayed
  35680. * If true, textures will only be loaded when they need to be rendered
  35681. */
  35682. useDelayedTextureLoading: boolean;
  35683. /**
  35684. * Gets the list of meshes imported to the scene through SceneLoader
  35685. */
  35686. importedMeshesFiles: String[];
  35687. /**
  35688. * Gets or sets a boolean indicating if probes are enabled on this scene
  35689. */
  35690. probesEnabled: boolean;
  35691. /**
  35692. * Gets or sets the current offline provider to use to store scene data
  35693. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35694. */
  35695. offlineProvider: IOfflineProvider;
  35696. /**
  35697. * Gets or sets the action manager associated with the scene
  35698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35699. */
  35700. actionManager: AbstractActionManager;
  35701. private _meshesForIntersections;
  35702. /**
  35703. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35704. */
  35705. proceduralTexturesEnabled: boolean;
  35706. private _engine;
  35707. private _totalVertices;
  35708. /** @hidden */
  35709. _activeIndices: PerfCounter;
  35710. /** @hidden */
  35711. _activeParticles: PerfCounter;
  35712. /** @hidden */
  35713. _activeBones: PerfCounter;
  35714. private _animationRatio;
  35715. /** @hidden */
  35716. _animationTimeLast: number;
  35717. /** @hidden */
  35718. _animationTime: number;
  35719. /**
  35720. * Gets or sets a general scale for animation speed
  35721. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35722. */
  35723. animationTimeScale: number;
  35724. /** @hidden */
  35725. _cachedMaterial: Nullable<Material>;
  35726. /** @hidden */
  35727. _cachedEffect: Nullable<Effect>;
  35728. /** @hidden */
  35729. _cachedVisibility: Nullable<number>;
  35730. private _renderId;
  35731. private _frameId;
  35732. private _executeWhenReadyTimeoutId;
  35733. private _intermediateRendering;
  35734. private _viewUpdateFlag;
  35735. private _projectionUpdateFlag;
  35736. /** @hidden */
  35737. _toBeDisposed: Nullable<IDisposable>[];
  35738. private _activeRequests;
  35739. /** @hidden */
  35740. _pendingData: any[];
  35741. private _isDisposed;
  35742. /**
  35743. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35744. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35745. */
  35746. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35747. private _activeMeshes;
  35748. private _processedMaterials;
  35749. private _renderTargets;
  35750. /** @hidden */
  35751. _activeParticleSystems: SmartArray<IParticleSystem>;
  35752. private _activeSkeletons;
  35753. private _softwareSkinnedMeshes;
  35754. private _renderingManager;
  35755. /** @hidden */
  35756. _activeAnimatables: Animatable[];
  35757. private _transformMatrix;
  35758. private _sceneUbo;
  35759. /** @hidden */
  35760. _viewMatrix: Matrix;
  35761. private _projectionMatrix;
  35762. /** @hidden */
  35763. _forcedViewPosition: Nullable<Vector3>;
  35764. /** @hidden */
  35765. _frustumPlanes: Plane[];
  35766. /**
  35767. * Gets the list of frustum planes (built from the active camera)
  35768. */
  35769. get frustumPlanes(): Plane[];
  35770. /**
  35771. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35772. * This is useful if there are more lights that the maximum simulteanous authorized
  35773. */
  35774. requireLightSorting: boolean;
  35775. /** @hidden */
  35776. readonly useMaterialMeshMap: boolean;
  35777. /** @hidden */
  35778. readonly useClonedMeshMap: boolean;
  35779. private _externalData;
  35780. private _uid;
  35781. /**
  35782. * @hidden
  35783. * Backing store of defined scene components.
  35784. */
  35785. _components: ISceneComponent[];
  35786. /**
  35787. * @hidden
  35788. * Backing store of defined scene components.
  35789. */
  35790. _serializableComponents: ISceneSerializableComponent[];
  35791. /**
  35792. * List of components to register on the next registration step.
  35793. */
  35794. private _transientComponents;
  35795. /**
  35796. * Registers the transient components if needed.
  35797. */
  35798. private _registerTransientComponents;
  35799. /**
  35800. * @hidden
  35801. * Add a component to the scene.
  35802. * Note that the ccomponent could be registered on th next frame if this is called after
  35803. * the register component stage.
  35804. * @param component Defines the component to add to the scene
  35805. */
  35806. _addComponent(component: ISceneComponent): void;
  35807. /**
  35808. * @hidden
  35809. * Gets a component from the scene.
  35810. * @param name defines the name of the component to retrieve
  35811. * @returns the component or null if not present
  35812. */
  35813. _getComponent(name: string): Nullable<ISceneComponent>;
  35814. /**
  35815. * @hidden
  35816. * Defines the actions happening before camera updates.
  35817. */
  35818. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35819. /**
  35820. * @hidden
  35821. * Defines the actions happening before clear the canvas.
  35822. */
  35823. _beforeClearStage: Stage<SimpleStageAction>;
  35824. /**
  35825. * @hidden
  35826. * Defines the actions when collecting render targets for the frame.
  35827. */
  35828. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35829. /**
  35830. * @hidden
  35831. * Defines the actions happening for one camera in the frame.
  35832. */
  35833. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35834. /**
  35835. * @hidden
  35836. * Defines the actions happening during the per mesh ready checks.
  35837. */
  35838. _isReadyForMeshStage: Stage<MeshStageAction>;
  35839. /**
  35840. * @hidden
  35841. * Defines the actions happening before evaluate active mesh checks.
  35842. */
  35843. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35844. /**
  35845. * @hidden
  35846. * Defines the actions happening during the evaluate sub mesh checks.
  35847. */
  35848. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35849. /**
  35850. * @hidden
  35851. * Defines the actions happening during the active mesh stage.
  35852. */
  35853. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35854. /**
  35855. * @hidden
  35856. * Defines the actions happening during the per camera render target step.
  35857. */
  35858. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35859. /**
  35860. * @hidden
  35861. * Defines the actions happening just before the active camera is drawing.
  35862. */
  35863. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35864. /**
  35865. * @hidden
  35866. * Defines the actions happening just before a render target is drawing.
  35867. */
  35868. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35869. /**
  35870. * @hidden
  35871. * Defines the actions happening just before a rendering group is drawing.
  35872. */
  35873. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35874. /**
  35875. * @hidden
  35876. * Defines the actions happening just before a mesh is drawing.
  35877. */
  35878. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35879. /**
  35880. * @hidden
  35881. * Defines the actions happening just after a mesh has been drawn.
  35882. */
  35883. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35884. /**
  35885. * @hidden
  35886. * Defines the actions happening just after a rendering group has been drawn.
  35887. */
  35888. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35889. /**
  35890. * @hidden
  35891. * Defines the actions happening just after the active camera has been drawn.
  35892. */
  35893. _afterCameraDrawStage: Stage<CameraStageAction>;
  35894. /**
  35895. * @hidden
  35896. * Defines the actions happening just after a render target has been drawn.
  35897. */
  35898. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35899. /**
  35900. * @hidden
  35901. * Defines the actions happening just after rendering all cameras and computing intersections.
  35902. */
  35903. _afterRenderStage: Stage<SimpleStageAction>;
  35904. /**
  35905. * @hidden
  35906. * Defines the actions happening when a pointer move event happens.
  35907. */
  35908. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35909. /**
  35910. * @hidden
  35911. * Defines the actions happening when a pointer down event happens.
  35912. */
  35913. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35914. /**
  35915. * @hidden
  35916. * Defines the actions happening when a pointer up event happens.
  35917. */
  35918. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35919. /**
  35920. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35921. */
  35922. private geometriesByUniqueId;
  35923. /**
  35924. * Creates a new Scene
  35925. * @param engine defines the engine to use to render this scene
  35926. * @param options defines the scene options
  35927. */
  35928. constructor(engine: Engine, options?: SceneOptions);
  35929. /**
  35930. * Gets a string idenfifying the name of the class
  35931. * @returns "Scene" string
  35932. */
  35933. getClassName(): string;
  35934. private _defaultMeshCandidates;
  35935. /**
  35936. * @hidden
  35937. */
  35938. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35939. private _defaultSubMeshCandidates;
  35940. /**
  35941. * @hidden
  35942. */
  35943. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35944. /**
  35945. * Sets the default candidate providers for the scene.
  35946. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35947. * and getCollidingSubMeshCandidates to their default function
  35948. */
  35949. setDefaultCandidateProviders(): void;
  35950. /**
  35951. * Gets the mesh that is currently under the pointer
  35952. */
  35953. get meshUnderPointer(): Nullable<AbstractMesh>;
  35954. /**
  35955. * Gets or sets the current on-screen X position of the pointer
  35956. */
  35957. get pointerX(): number;
  35958. set pointerX(value: number);
  35959. /**
  35960. * Gets or sets the current on-screen Y position of the pointer
  35961. */
  35962. get pointerY(): number;
  35963. set pointerY(value: number);
  35964. /**
  35965. * Gets the cached material (ie. the latest rendered one)
  35966. * @returns the cached material
  35967. */
  35968. getCachedMaterial(): Nullable<Material>;
  35969. /**
  35970. * Gets the cached effect (ie. the latest rendered one)
  35971. * @returns the cached effect
  35972. */
  35973. getCachedEffect(): Nullable<Effect>;
  35974. /**
  35975. * Gets the cached visibility state (ie. the latest rendered one)
  35976. * @returns the cached visibility state
  35977. */
  35978. getCachedVisibility(): Nullable<number>;
  35979. /**
  35980. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35981. * @param material defines the current material
  35982. * @param effect defines the current effect
  35983. * @param visibility defines the current visibility state
  35984. * @returns true if one parameter is not cached
  35985. */
  35986. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35987. /**
  35988. * Gets the engine associated with the scene
  35989. * @returns an Engine
  35990. */
  35991. getEngine(): Engine;
  35992. /**
  35993. * Gets the total number of vertices rendered per frame
  35994. * @returns the total number of vertices rendered per frame
  35995. */
  35996. getTotalVertices(): number;
  35997. /**
  35998. * Gets the performance counter for total vertices
  35999. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36000. */
  36001. get totalVerticesPerfCounter(): PerfCounter;
  36002. /**
  36003. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36004. * @returns the total number of active indices rendered per frame
  36005. */
  36006. getActiveIndices(): number;
  36007. /**
  36008. * Gets the performance counter for active indices
  36009. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36010. */
  36011. get totalActiveIndicesPerfCounter(): PerfCounter;
  36012. /**
  36013. * Gets the total number of active particles rendered per frame
  36014. * @returns the total number of active particles rendered per frame
  36015. */
  36016. getActiveParticles(): number;
  36017. /**
  36018. * Gets the performance counter for active particles
  36019. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36020. */
  36021. get activeParticlesPerfCounter(): PerfCounter;
  36022. /**
  36023. * Gets the total number of active bones rendered per frame
  36024. * @returns the total number of active bones rendered per frame
  36025. */
  36026. getActiveBones(): number;
  36027. /**
  36028. * Gets the performance counter for active bones
  36029. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36030. */
  36031. get activeBonesPerfCounter(): PerfCounter;
  36032. /**
  36033. * Gets the array of active meshes
  36034. * @returns an array of AbstractMesh
  36035. */
  36036. getActiveMeshes(): SmartArray<AbstractMesh>;
  36037. /**
  36038. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36039. * @returns a number
  36040. */
  36041. getAnimationRatio(): number;
  36042. /**
  36043. * Gets an unique Id for the current render phase
  36044. * @returns a number
  36045. */
  36046. getRenderId(): number;
  36047. /**
  36048. * Gets an unique Id for the current frame
  36049. * @returns a number
  36050. */
  36051. getFrameId(): number;
  36052. /** Call this function if you want to manually increment the render Id*/
  36053. incrementRenderId(): void;
  36054. private _createUbo;
  36055. /**
  36056. * Use this method to simulate a pointer move on a mesh
  36057. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36058. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36059. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36060. * @returns the current scene
  36061. */
  36062. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36063. /**
  36064. * Use this method to simulate a pointer down on a mesh
  36065. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36066. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36067. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36068. * @returns the current scene
  36069. */
  36070. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36071. /**
  36072. * Use this method to simulate a pointer up on a mesh
  36073. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36074. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36075. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36076. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36077. * @returns the current scene
  36078. */
  36079. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36080. /**
  36081. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36082. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36083. * @returns true if the pointer was captured
  36084. */
  36085. isPointerCaptured(pointerId?: number): boolean;
  36086. /**
  36087. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36088. * @param attachUp defines if you want to attach events to pointerup
  36089. * @param attachDown defines if you want to attach events to pointerdown
  36090. * @param attachMove defines if you want to attach events to pointermove
  36091. */
  36092. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36093. /** Detaches all event handlers*/
  36094. detachControl(): void;
  36095. /**
  36096. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36097. * Delay loaded resources are not taking in account
  36098. * @return true if all required resources are ready
  36099. */
  36100. isReady(): boolean;
  36101. /** Resets all cached information relative to material (including effect and visibility) */
  36102. resetCachedMaterial(): void;
  36103. /**
  36104. * Registers a function to be called before every frame render
  36105. * @param func defines the function to register
  36106. */
  36107. registerBeforeRender(func: () => void): void;
  36108. /**
  36109. * Unregisters a function called before every frame render
  36110. * @param func defines the function to unregister
  36111. */
  36112. unregisterBeforeRender(func: () => void): void;
  36113. /**
  36114. * Registers a function to be called after every frame render
  36115. * @param func defines the function to register
  36116. */
  36117. registerAfterRender(func: () => void): void;
  36118. /**
  36119. * Unregisters a function called after every frame render
  36120. * @param func defines the function to unregister
  36121. */
  36122. unregisterAfterRender(func: () => void): void;
  36123. private _executeOnceBeforeRender;
  36124. /**
  36125. * The provided function will run before render once and will be disposed afterwards.
  36126. * A timeout delay can be provided so that the function will be executed in N ms.
  36127. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36128. * @param func The function to be executed.
  36129. * @param timeout optional delay in ms
  36130. */
  36131. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36132. /** @hidden */
  36133. _addPendingData(data: any): void;
  36134. /** @hidden */
  36135. _removePendingData(data: any): void;
  36136. /**
  36137. * Returns the number of items waiting to be loaded
  36138. * @returns the number of items waiting to be loaded
  36139. */
  36140. getWaitingItemsCount(): number;
  36141. /**
  36142. * Returns a boolean indicating if the scene is still loading data
  36143. */
  36144. get isLoading(): boolean;
  36145. /**
  36146. * Registers a function to be executed when the scene is ready
  36147. * @param {Function} func - the function to be executed
  36148. */
  36149. executeWhenReady(func: () => void): void;
  36150. /**
  36151. * Returns a promise that resolves when the scene is ready
  36152. * @returns A promise that resolves when the scene is ready
  36153. */
  36154. whenReadyAsync(): Promise<void>;
  36155. /** @hidden */
  36156. _checkIsReady(): void;
  36157. /**
  36158. * Gets all animatable attached to the scene
  36159. */
  36160. get animatables(): Animatable[];
  36161. /**
  36162. * Resets the last animation time frame.
  36163. * Useful to override when animations start running when loading a scene for the first time.
  36164. */
  36165. resetLastAnimationTimeFrame(): void;
  36166. /**
  36167. * Gets the current view matrix
  36168. * @returns a Matrix
  36169. */
  36170. getViewMatrix(): Matrix;
  36171. /**
  36172. * Gets the current projection matrix
  36173. * @returns a Matrix
  36174. */
  36175. getProjectionMatrix(): Matrix;
  36176. /**
  36177. * Gets the current transform matrix
  36178. * @returns a Matrix made of View * Projection
  36179. */
  36180. getTransformMatrix(): Matrix;
  36181. /**
  36182. * Sets the current transform matrix
  36183. * @param viewL defines the View matrix to use
  36184. * @param projectionL defines the Projection matrix to use
  36185. * @param viewR defines the right View matrix to use (if provided)
  36186. * @param projectionR defines the right Projection matrix to use (if provided)
  36187. */
  36188. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36189. /**
  36190. * Gets the uniform buffer used to store scene data
  36191. * @returns a UniformBuffer
  36192. */
  36193. getSceneUniformBuffer(): UniformBuffer;
  36194. /**
  36195. * Gets an unique (relatively to the current scene) Id
  36196. * @returns an unique number for the scene
  36197. */
  36198. getUniqueId(): number;
  36199. /**
  36200. * Add a mesh to the list of scene's meshes
  36201. * @param newMesh defines the mesh to add
  36202. * @param recursive if all child meshes should also be added to the scene
  36203. */
  36204. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36205. /**
  36206. * Remove a mesh for the list of scene's meshes
  36207. * @param toRemove defines the mesh to remove
  36208. * @param recursive if all child meshes should also be removed from the scene
  36209. * @returns the index where the mesh was in the mesh list
  36210. */
  36211. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36212. /**
  36213. * Add a transform node to the list of scene's transform nodes
  36214. * @param newTransformNode defines the transform node to add
  36215. */
  36216. addTransformNode(newTransformNode: TransformNode): void;
  36217. /**
  36218. * Remove a transform node for the list of scene's transform nodes
  36219. * @param toRemove defines the transform node to remove
  36220. * @returns the index where the transform node was in the transform node list
  36221. */
  36222. removeTransformNode(toRemove: TransformNode): number;
  36223. /**
  36224. * Remove a skeleton for the list of scene's skeletons
  36225. * @param toRemove defines the skeleton to remove
  36226. * @returns the index where the skeleton was in the skeleton list
  36227. */
  36228. removeSkeleton(toRemove: Skeleton): number;
  36229. /**
  36230. * Remove a morph target for the list of scene's morph targets
  36231. * @param toRemove defines the morph target to remove
  36232. * @returns the index where the morph target was in the morph target list
  36233. */
  36234. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36235. /**
  36236. * Remove a light for the list of scene's lights
  36237. * @param toRemove defines the light to remove
  36238. * @returns the index where the light was in the light list
  36239. */
  36240. removeLight(toRemove: Light): number;
  36241. /**
  36242. * Remove a camera for the list of scene's cameras
  36243. * @param toRemove defines the camera to remove
  36244. * @returns the index where the camera was in the camera list
  36245. */
  36246. removeCamera(toRemove: Camera): number;
  36247. /**
  36248. * Remove a particle system for the list of scene's particle systems
  36249. * @param toRemove defines the particle system to remove
  36250. * @returns the index where the particle system was in the particle system list
  36251. */
  36252. removeParticleSystem(toRemove: IParticleSystem): number;
  36253. /**
  36254. * Remove a animation for the list of scene's animations
  36255. * @param toRemove defines the animation to remove
  36256. * @returns the index where the animation was in the animation list
  36257. */
  36258. removeAnimation(toRemove: Animation): number;
  36259. /**
  36260. * Will stop the animation of the given target
  36261. * @param target - the target
  36262. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36263. * @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)
  36264. */
  36265. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36266. /**
  36267. * Removes the given animation group from this scene.
  36268. * @param toRemove The animation group to remove
  36269. * @returns The index of the removed animation group
  36270. */
  36271. removeAnimationGroup(toRemove: AnimationGroup): number;
  36272. /**
  36273. * Removes the given multi-material from this scene.
  36274. * @param toRemove The multi-material to remove
  36275. * @returns The index of the removed multi-material
  36276. */
  36277. removeMultiMaterial(toRemove: MultiMaterial): number;
  36278. /**
  36279. * Removes the given material from this scene.
  36280. * @param toRemove The material to remove
  36281. * @returns The index of the removed material
  36282. */
  36283. removeMaterial(toRemove: Material): number;
  36284. /**
  36285. * Removes the given action manager from this scene.
  36286. * @param toRemove The action manager to remove
  36287. * @returns The index of the removed action manager
  36288. */
  36289. removeActionManager(toRemove: AbstractActionManager): number;
  36290. /**
  36291. * Removes the given texture from this scene.
  36292. * @param toRemove The texture to remove
  36293. * @returns The index of the removed texture
  36294. */
  36295. removeTexture(toRemove: BaseTexture): number;
  36296. /**
  36297. * Adds the given light to this scene
  36298. * @param newLight The light to add
  36299. */
  36300. addLight(newLight: Light): void;
  36301. /**
  36302. * Sorts the list list based on light priorities
  36303. */
  36304. sortLightsByPriority(): void;
  36305. /**
  36306. * Adds the given camera to this scene
  36307. * @param newCamera The camera to add
  36308. */
  36309. addCamera(newCamera: Camera): void;
  36310. /**
  36311. * Adds the given skeleton to this scene
  36312. * @param newSkeleton The skeleton to add
  36313. */
  36314. addSkeleton(newSkeleton: Skeleton): void;
  36315. /**
  36316. * Adds the given particle system to this scene
  36317. * @param newParticleSystem The particle system to add
  36318. */
  36319. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36320. /**
  36321. * Adds the given animation to this scene
  36322. * @param newAnimation The animation to add
  36323. */
  36324. addAnimation(newAnimation: Animation): void;
  36325. /**
  36326. * Adds the given animation group to this scene.
  36327. * @param newAnimationGroup The animation group to add
  36328. */
  36329. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36330. /**
  36331. * Adds the given multi-material to this scene
  36332. * @param newMultiMaterial The multi-material to add
  36333. */
  36334. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36335. /**
  36336. * Adds the given material to this scene
  36337. * @param newMaterial The material to add
  36338. */
  36339. addMaterial(newMaterial: Material): void;
  36340. /**
  36341. * Adds the given morph target to this scene
  36342. * @param newMorphTargetManager The morph target to add
  36343. */
  36344. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36345. /**
  36346. * Adds the given geometry to this scene
  36347. * @param newGeometry The geometry to add
  36348. */
  36349. addGeometry(newGeometry: Geometry): void;
  36350. /**
  36351. * Adds the given action manager to this scene
  36352. * @param newActionManager The action manager to add
  36353. */
  36354. addActionManager(newActionManager: AbstractActionManager): void;
  36355. /**
  36356. * Adds the given texture to this scene.
  36357. * @param newTexture The texture to add
  36358. */
  36359. addTexture(newTexture: BaseTexture): void;
  36360. /**
  36361. * Switch active camera
  36362. * @param newCamera defines the new active camera
  36363. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36364. */
  36365. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36366. /**
  36367. * sets the active camera of the scene using its ID
  36368. * @param id defines the camera's ID
  36369. * @return the new active camera or null if none found.
  36370. */
  36371. setActiveCameraByID(id: string): Nullable<Camera>;
  36372. /**
  36373. * sets the active camera of the scene using its name
  36374. * @param name defines the camera's name
  36375. * @returns the new active camera or null if none found.
  36376. */
  36377. setActiveCameraByName(name: string): Nullable<Camera>;
  36378. /**
  36379. * get an animation group using its name
  36380. * @param name defines the material's name
  36381. * @return the animation group or null if none found.
  36382. */
  36383. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36384. /**
  36385. * Get a material using its unique id
  36386. * @param uniqueId defines the material's unique id
  36387. * @return the material or null if none found.
  36388. */
  36389. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36390. /**
  36391. * get a material using its id
  36392. * @param id defines the material's ID
  36393. * @return the material or null if none found.
  36394. */
  36395. getMaterialByID(id: string): Nullable<Material>;
  36396. /**
  36397. * Gets a the last added material using a given id
  36398. * @param id defines the material's ID
  36399. * @return the last material with the given id or null if none found.
  36400. */
  36401. getLastMaterialByID(id: string): Nullable<Material>;
  36402. /**
  36403. * Gets a material using its name
  36404. * @param name defines the material's name
  36405. * @return the material or null if none found.
  36406. */
  36407. getMaterialByName(name: string): Nullable<Material>;
  36408. /**
  36409. * Get a texture using its unique id
  36410. * @param uniqueId defines the texture's unique id
  36411. * @return the texture or null if none found.
  36412. */
  36413. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36414. /**
  36415. * Gets a camera using its id
  36416. * @param id defines the id to look for
  36417. * @returns the camera or null if not found
  36418. */
  36419. getCameraByID(id: string): Nullable<Camera>;
  36420. /**
  36421. * Gets a camera using its unique id
  36422. * @param uniqueId defines the unique id to look for
  36423. * @returns the camera or null if not found
  36424. */
  36425. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36426. /**
  36427. * Gets a camera using its name
  36428. * @param name defines the camera's name
  36429. * @return the camera or null if none found.
  36430. */
  36431. getCameraByName(name: string): Nullable<Camera>;
  36432. /**
  36433. * Gets a bone using its id
  36434. * @param id defines the bone's id
  36435. * @return the bone or null if not found
  36436. */
  36437. getBoneByID(id: string): Nullable<Bone>;
  36438. /**
  36439. * Gets a bone using its id
  36440. * @param name defines the bone's name
  36441. * @return the bone or null if not found
  36442. */
  36443. getBoneByName(name: string): Nullable<Bone>;
  36444. /**
  36445. * Gets a light node using its name
  36446. * @param name defines the the light's name
  36447. * @return the light or null if none found.
  36448. */
  36449. getLightByName(name: string): Nullable<Light>;
  36450. /**
  36451. * Gets a light node using its id
  36452. * @param id defines the light's id
  36453. * @return the light or null if none found.
  36454. */
  36455. getLightByID(id: string): Nullable<Light>;
  36456. /**
  36457. * Gets a light node using its scene-generated unique ID
  36458. * @param uniqueId defines the light's unique id
  36459. * @return the light or null if none found.
  36460. */
  36461. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36462. /**
  36463. * Gets a particle system by id
  36464. * @param id defines the particle system id
  36465. * @return the corresponding system or null if none found
  36466. */
  36467. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36468. /**
  36469. * Gets a geometry using its ID
  36470. * @param id defines the geometry's id
  36471. * @return the geometry or null if none found.
  36472. */
  36473. getGeometryByID(id: string): Nullable<Geometry>;
  36474. private _getGeometryByUniqueID;
  36475. /**
  36476. * Add a new geometry to this scene
  36477. * @param geometry defines the geometry to be added to the scene.
  36478. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36479. * @return a boolean defining if the geometry was added or not
  36480. */
  36481. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36482. /**
  36483. * Removes an existing geometry
  36484. * @param geometry defines the geometry to be removed from the scene
  36485. * @return a boolean defining if the geometry was removed or not
  36486. */
  36487. removeGeometry(geometry: Geometry): boolean;
  36488. /**
  36489. * Gets the list of geometries attached to the scene
  36490. * @returns an array of Geometry
  36491. */
  36492. getGeometries(): Geometry[];
  36493. /**
  36494. * Gets the first added mesh found of a given ID
  36495. * @param id defines the id to search for
  36496. * @return the mesh found or null if not found at all
  36497. */
  36498. getMeshByID(id: string): Nullable<AbstractMesh>;
  36499. /**
  36500. * Gets a list of meshes using their id
  36501. * @param id defines the id to search for
  36502. * @returns a list of meshes
  36503. */
  36504. getMeshesByID(id: string): Array<AbstractMesh>;
  36505. /**
  36506. * Gets the first added transform node found of a given ID
  36507. * @param id defines the id to search for
  36508. * @return the found transform node or null if not found at all.
  36509. */
  36510. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36511. /**
  36512. * Gets a transform node with its auto-generated unique id
  36513. * @param uniqueId efines the unique id to search for
  36514. * @return the found transform node or null if not found at all.
  36515. */
  36516. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36517. /**
  36518. * Gets a list of transform nodes using their id
  36519. * @param id defines the id to search for
  36520. * @returns a list of transform nodes
  36521. */
  36522. getTransformNodesByID(id: string): Array<TransformNode>;
  36523. /**
  36524. * Gets a mesh with its auto-generated unique id
  36525. * @param uniqueId defines the unique id to search for
  36526. * @return the found mesh or null if not found at all.
  36527. */
  36528. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36529. /**
  36530. * Gets a the last added mesh using a given id
  36531. * @param id defines the id to search for
  36532. * @return the found mesh or null if not found at all.
  36533. */
  36534. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36535. /**
  36536. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36537. * @param id defines the id to search for
  36538. * @return the found node or null if not found at all
  36539. */
  36540. getLastEntryByID(id: string): Nullable<Node>;
  36541. /**
  36542. * Gets a node (Mesh, Camera, Light) using a given id
  36543. * @param id defines the id to search for
  36544. * @return the found node or null if not found at all
  36545. */
  36546. getNodeByID(id: string): Nullable<Node>;
  36547. /**
  36548. * Gets a node (Mesh, Camera, Light) using a given name
  36549. * @param name defines the name to search for
  36550. * @return the found node or null if not found at all.
  36551. */
  36552. getNodeByName(name: string): Nullable<Node>;
  36553. /**
  36554. * Gets a mesh using a given name
  36555. * @param name defines the name to search for
  36556. * @return the found mesh or null if not found at all.
  36557. */
  36558. getMeshByName(name: string): Nullable<AbstractMesh>;
  36559. /**
  36560. * Gets a transform node using a given name
  36561. * @param name defines the name to search for
  36562. * @return the found transform node or null if not found at all.
  36563. */
  36564. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36565. /**
  36566. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36567. * @param id defines the id to search for
  36568. * @return the found skeleton or null if not found at all.
  36569. */
  36570. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36571. /**
  36572. * Gets a skeleton using a given auto generated unique id
  36573. * @param uniqueId defines the unique id to search for
  36574. * @return the found skeleton or null if not found at all.
  36575. */
  36576. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36577. /**
  36578. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36579. * @param id defines the id to search for
  36580. * @return the found skeleton or null if not found at all.
  36581. */
  36582. getSkeletonById(id: string): Nullable<Skeleton>;
  36583. /**
  36584. * Gets a skeleton using a given name
  36585. * @param name defines the name to search for
  36586. * @return the found skeleton or null if not found at all.
  36587. */
  36588. getSkeletonByName(name: string): Nullable<Skeleton>;
  36589. /**
  36590. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36591. * @param id defines the id to search for
  36592. * @return the found morph target manager or null if not found at all.
  36593. */
  36594. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36595. /**
  36596. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36597. * @param id defines the id to search for
  36598. * @return the found morph target or null if not found at all.
  36599. */
  36600. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36601. /**
  36602. * Gets a boolean indicating if the given mesh is active
  36603. * @param mesh defines the mesh to look for
  36604. * @returns true if the mesh is in the active list
  36605. */
  36606. isActiveMesh(mesh: AbstractMesh): boolean;
  36607. /**
  36608. * Return a unique id as a string which can serve as an identifier for the scene
  36609. */
  36610. get uid(): string;
  36611. /**
  36612. * Add an externaly attached data from its key.
  36613. * This method call will fail and return false, if such key already exists.
  36614. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36615. * @param key the unique key that identifies the data
  36616. * @param data the data object to associate to the key for this Engine instance
  36617. * @return true if no such key were already present and the data was added successfully, false otherwise
  36618. */
  36619. addExternalData<T>(key: string, data: T): boolean;
  36620. /**
  36621. * Get an externaly attached data from its key
  36622. * @param key the unique key that identifies the data
  36623. * @return the associated data, if present (can be null), or undefined if not present
  36624. */
  36625. getExternalData<T>(key: string): Nullable<T>;
  36626. /**
  36627. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36628. * @param key the unique key that identifies the data
  36629. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36630. * @return the associated data, can be null if the factory returned null.
  36631. */
  36632. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36633. /**
  36634. * Remove an externaly attached data from the Engine instance
  36635. * @param key the unique key that identifies the data
  36636. * @return true if the data was successfully removed, false if it doesn't exist
  36637. */
  36638. removeExternalData(key: string): boolean;
  36639. private _evaluateSubMesh;
  36640. /**
  36641. * Clear the processed materials smart array preventing retention point in material dispose.
  36642. */
  36643. freeProcessedMaterials(): void;
  36644. private _preventFreeActiveMeshesAndRenderingGroups;
  36645. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36646. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36647. * when disposing several meshes in a row or a hierarchy of meshes.
  36648. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36649. */
  36650. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36651. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36652. /**
  36653. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36654. */
  36655. freeActiveMeshes(): void;
  36656. /**
  36657. * Clear the info related to rendering groups preventing retention points during dispose.
  36658. */
  36659. freeRenderingGroups(): void;
  36660. /** @hidden */
  36661. _isInIntermediateRendering(): boolean;
  36662. /**
  36663. * Lambda returning the list of potentially active meshes.
  36664. */
  36665. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36666. /**
  36667. * Lambda returning the list of potentially active sub meshes.
  36668. */
  36669. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36670. /**
  36671. * Lambda returning the list of potentially intersecting sub meshes.
  36672. */
  36673. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36674. /**
  36675. * Lambda returning the list of potentially colliding sub meshes.
  36676. */
  36677. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36678. private _activeMeshesFrozen;
  36679. private _skipEvaluateActiveMeshesCompletely;
  36680. /**
  36681. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36682. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36683. * @returns the current scene
  36684. */
  36685. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36686. /**
  36687. * Use this function to restart evaluating active meshes on every frame
  36688. * @returns the current scene
  36689. */
  36690. unfreezeActiveMeshes(): Scene;
  36691. private _evaluateActiveMeshes;
  36692. private _activeMesh;
  36693. /**
  36694. * Update the transform matrix to update from the current active camera
  36695. * @param force defines a boolean used to force the update even if cache is up to date
  36696. */
  36697. updateTransformMatrix(force?: boolean): void;
  36698. private _bindFrameBuffer;
  36699. /** @hidden */
  36700. _allowPostProcessClearColor: boolean;
  36701. /** @hidden */
  36702. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36703. private _processSubCameras;
  36704. private _checkIntersections;
  36705. /** @hidden */
  36706. _advancePhysicsEngineStep(step: number): void;
  36707. /**
  36708. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36709. */
  36710. getDeterministicFrameTime: () => number;
  36711. /** @hidden */
  36712. _animate(): void;
  36713. /** Execute all animations (for a frame) */
  36714. animate(): void;
  36715. /**
  36716. * Render the scene
  36717. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36718. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36719. */
  36720. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36721. /**
  36722. * Freeze all materials
  36723. * A frozen material will not be updatable but should be faster to render
  36724. */
  36725. freezeMaterials(): void;
  36726. /**
  36727. * Unfreeze all materials
  36728. * A frozen material will not be updatable but should be faster to render
  36729. */
  36730. unfreezeMaterials(): void;
  36731. /**
  36732. * Releases all held ressources
  36733. */
  36734. dispose(): void;
  36735. /**
  36736. * Gets if the scene is already disposed
  36737. */
  36738. get isDisposed(): boolean;
  36739. /**
  36740. * Call this function to reduce memory footprint of the scene.
  36741. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36742. */
  36743. clearCachedVertexData(): void;
  36744. /**
  36745. * This function will remove the local cached buffer data from texture.
  36746. * It will save memory but will prevent the texture from being rebuilt
  36747. */
  36748. cleanCachedTextureBuffer(): void;
  36749. /**
  36750. * Get the world extend vectors with an optional filter
  36751. *
  36752. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36753. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36754. */
  36755. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36756. min: Vector3;
  36757. max: Vector3;
  36758. };
  36759. /**
  36760. * Creates a ray that can be used to pick in the scene
  36761. * @param x defines the x coordinate of the origin (on-screen)
  36762. * @param y defines the y coordinate of the origin (on-screen)
  36763. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36764. * @param camera defines the camera to use for the picking
  36765. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36766. * @returns a Ray
  36767. */
  36768. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36769. /**
  36770. * Creates a ray that can be used to pick in the scene
  36771. * @param x defines the x coordinate of the origin (on-screen)
  36772. * @param y defines the y coordinate of the origin (on-screen)
  36773. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36774. * @param result defines the ray where to store the picking ray
  36775. * @param camera defines the camera to use for the picking
  36776. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36777. * @returns the current scene
  36778. */
  36779. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36780. /**
  36781. * Creates a ray that can be used to pick in the scene
  36782. * @param x defines the x coordinate of the origin (on-screen)
  36783. * @param y defines the y coordinate of the origin (on-screen)
  36784. * @param camera defines the camera to use for the picking
  36785. * @returns a Ray
  36786. */
  36787. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36788. /**
  36789. * Creates a ray that can be used to pick in the scene
  36790. * @param x defines the x coordinate of the origin (on-screen)
  36791. * @param y defines the y coordinate of the origin (on-screen)
  36792. * @param result defines the ray where to store the picking ray
  36793. * @param camera defines the camera to use for the picking
  36794. * @returns the current scene
  36795. */
  36796. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36797. /** Launch a ray to try to pick a mesh in the scene
  36798. * @param x position on screen
  36799. * @param y position on screen
  36800. * @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
  36801. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36802. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36803. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36804. * @returns a PickingInfo
  36805. */
  36806. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36807. /** Use the given ray to pick a mesh in the scene
  36808. * @param ray The ray to use to pick meshes
  36809. * @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
  36810. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36811. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36812. * @returns a PickingInfo
  36813. */
  36814. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36815. /**
  36816. * Launch a ray to try to pick a mesh in the scene
  36817. * @param x X position on screen
  36818. * @param y Y position on screen
  36819. * @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
  36820. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36821. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36822. * @returns an array of PickingInfo
  36823. */
  36824. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36825. /**
  36826. * Launch a ray to try to pick a mesh in the scene
  36827. * @param ray Ray to use
  36828. * @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
  36829. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36830. * @returns an array of PickingInfo
  36831. */
  36832. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36833. /**
  36834. * Force the value of meshUnderPointer
  36835. * @param mesh defines the mesh to use
  36836. */
  36837. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36838. /**
  36839. * Gets the mesh under the pointer
  36840. * @returns a Mesh or null if no mesh is under the pointer
  36841. */
  36842. getPointerOverMesh(): Nullable<AbstractMesh>;
  36843. /** @hidden */
  36844. _rebuildGeometries(): void;
  36845. /** @hidden */
  36846. _rebuildTextures(): void;
  36847. private _getByTags;
  36848. /**
  36849. * Get a list of meshes by tags
  36850. * @param tagsQuery defines the tags query to use
  36851. * @param forEach defines a predicate used to filter results
  36852. * @returns an array of Mesh
  36853. */
  36854. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36855. /**
  36856. * Get a list of cameras by tags
  36857. * @param tagsQuery defines the tags query to use
  36858. * @param forEach defines a predicate used to filter results
  36859. * @returns an array of Camera
  36860. */
  36861. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36862. /**
  36863. * Get a list of lights by tags
  36864. * @param tagsQuery defines the tags query to use
  36865. * @param forEach defines a predicate used to filter results
  36866. * @returns an array of Light
  36867. */
  36868. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36869. /**
  36870. * Get a list of materials by tags
  36871. * @param tagsQuery defines the tags query to use
  36872. * @param forEach defines a predicate used to filter results
  36873. * @returns an array of Material
  36874. */
  36875. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36876. /**
  36877. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36878. * This allowed control for front to back rendering or reversly depending of the special needs.
  36879. *
  36880. * @param renderingGroupId The rendering group id corresponding to its index
  36881. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36882. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36883. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36884. */
  36885. 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;
  36886. /**
  36887. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36888. *
  36889. * @param renderingGroupId The rendering group id corresponding to its index
  36890. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36891. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36892. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36893. */
  36894. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36895. /**
  36896. * Gets the current auto clear configuration for one rendering group of the rendering
  36897. * manager.
  36898. * @param index the rendering group index to get the information for
  36899. * @returns The auto clear setup for the requested rendering group
  36900. */
  36901. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36902. private _blockMaterialDirtyMechanism;
  36903. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36904. get blockMaterialDirtyMechanism(): boolean;
  36905. set blockMaterialDirtyMechanism(value: boolean);
  36906. /**
  36907. * Will flag all materials as dirty to trigger new shader compilation
  36908. * @param flag defines the flag used to specify which material part must be marked as dirty
  36909. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36910. */
  36911. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36912. /** @hidden */
  36913. _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;
  36914. /** @hidden */
  36915. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36916. /** @hidden */
  36917. _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;
  36918. /** @hidden */
  36919. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36920. /** @hidden */
  36921. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36922. /** @hidden */
  36923. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36924. }
  36925. }
  36926. declare module BABYLON {
  36927. /**
  36928. * Set of assets to keep when moving a scene into an asset container.
  36929. */
  36930. export class KeepAssets extends AbstractScene {
  36931. }
  36932. /**
  36933. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36934. */
  36935. export class InstantiatedEntries {
  36936. /**
  36937. * List of new root nodes (eg. nodes with no parent)
  36938. */
  36939. rootNodes: TransformNode[];
  36940. /**
  36941. * List of new skeletons
  36942. */
  36943. skeletons: Skeleton[];
  36944. /**
  36945. * List of new animation groups
  36946. */
  36947. animationGroups: AnimationGroup[];
  36948. }
  36949. /**
  36950. * Container with a set of assets that can be added or removed from a scene.
  36951. */
  36952. export class AssetContainer extends AbstractScene {
  36953. private _wasAddedToScene;
  36954. /**
  36955. * The scene the AssetContainer belongs to.
  36956. */
  36957. scene: Scene;
  36958. /**
  36959. * Instantiates an AssetContainer.
  36960. * @param scene The scene the AssetContainer belongs to.
  36961. */
  36962. constructor(scene: Scene);
  36963. /**
  36964. * Instantiate or clone all meshes and add the new ones to the scene.
  36965. * Skeletons and animation groups will all be cloned
  36966. * @param nameFunction defines an optional function used to get new names for clones
  36967. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36968. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36969. */
  36970. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36971. /**
  36972. * Adds all the assets from the container to the scene.
  36973. */
  36974. addAllToScene(): void;
  36975. /**
  36976. * Removes all the assets in the container from the scene
  36977. */
  36978. removeAllFromScene(): void;
  36979. /**
  36980. * Disposes all the assets in the container
  36981. */
  36982. dispose(): void;
  36983. private _moveAssets;
  36984. /**
  36985. * Removes all the assets contained in the scene and adds them to the container.
  36986. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36987. */
  36988. moveAllFromScene(keepAssets?: KeepAssets): void;
  36989. /**
  36990. * 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.
  36991. * @returns the root mesh
  36992. */
  36993. createRootMesh(): Mesh;
  36994. /**
  36995. * Merge animations from this asset container into a scene
  36996. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36997. * @param animatables set of animatables to retarget to a node from the scene
  36998. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36999. */
  37000. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37001. }
  37002. }
  37003. declare module BABYLON {
  37004. /**
  37005. * Defines how the parser contract is defined.
  37006. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37007. */
  37008. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37009. /**
  37010. * Defines how the individual parser contract is defined.
  37011. * These parser can parse an individual asset
  37012. */
  37013. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37014. /**
  37015. * Base class of the scene acting as a container for the different elements composing a scene.
  37016. * This class is dynamically extended by the different components of the scene increasing
  37017. * flexibility and reducing coupling
  37018. */
  37019. export abstract class AbstractScene {
  37020. /**
  37021. * Stores the list of available parsers in the application.
  37022. */
  37023. private static _BabylonFileParsers;
  37024. /**
  37025. * Stores the list of available individual parsers in the application.
  37026. */
  37027. private static _IndividualBabylonFileParsers;
  37028. /**
  37029. * Adds a parser in the list of available ones
  37030. * @param name Defines the name of the parser
  37031. * @param parser Defines the parser to add
  37032. */
  37033. static AddParser(name: string, parser: BabylonFileParser): void;
  37034. /**
  37035. * Gets a general parser from the list of avaialble ones
  37036. * @param name Defines the name of the parser
  37037. * @returns the requested parser or null
  37038. */
  37039. static GetParser(name: string): Nullable<BabylonFileParser>;
  37040. /**
  37041. * Adds n individual parser in the list of available ones
  37042. * @param name Defines the name of the parser
  37043. * @param parser Defines the parser to add
  37044. */
  37045. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37046. /**
  37047. * Gets an individual parser from the list of avaialble ones
  37048. * @param name Defines the name of the parser
  37049. * @returns the requested parser or null
  37050. */
  37051. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37052. /**
  37053. * Parser json data and populate both a scene and its associated container object
  37054. * @param jsonData Defines the data to parse
  37055. * @param scene Defines the scene to parse the data for
  37056. * @param container Defines the container attached to the parsing sequence
  37057. * @param rootUrl Defines the root url of the data
  37058. */
  37059. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37060. /**
  37061. * Gets the list of root nodes (ie. nodes with no parent)
  37062. */
  37063. rootNodes: Node[];
  37064. /** All of the cameras added to this scene
  37065. * @see http://doc.babylonjs.com/babylon101/cameras
  37066. */
  37067. cameras: Camera[];
  37068. /**
  37069. * All of the lights added to this scene
  37070. * @see http://doc.babylonjs.com/babylon101/lights
  37071. */
  37072. lights: Light[];
  37073. /**
  37074. * All of the (abstract) meshes added to this scene
  37075. */
  37076. meshes: AbstractMesh[];
  37077. /**
  37078. * The list of skeletons added to the scene
  37079. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37080. */
  37081. skeletons: Skeleton[];
  37082. /**
  37083. * All of the particle systems added to this scene
  37084. * @see http://doc.babylonjs.com/babylon101/particles
  37085. */
  37086. particleSystems: IParticleSystem[];
  37087. /**
  37088. * Gets a list of Animations associated with the scene
  37089. */
  37090. animations: Animation[];
  37091. /**
  37092. * All of the animation groups added to this scene
  37093. * @see http://doc.babylonjs.com/how_to/group
  37094. */
  37095. animationGroups: AnimationGroup[];
  37096. /**
  37097. * All of the multi-materials added to this scene
  37098. * @see http://doc.babylonjs.com/how_to/multi_materials
  37099. */
  37100. multiMaterials: MultiMaterial[];
  37101. /**
  37102. * All of the materials added to this scene
  37103. * In the context of a Scene, it is not supposed to be modified manually.
  37104. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37105. * Note also that the order of the Material within the array is not significant and might change.
  37106. * @see http://doc.babylonjs.com/babylon101/materials
  37107. */
  37108. materials: Material[];
  37109. /**
  37110. * The list of morph target managers added to the scene
  37111. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37112. */
  37113. morphTargetManagers: MorphTargetManager[];
  37114. /**
  37115. * The list of geometries used in the scene.
  37116. */
  37117. geometries: Geometry[];
  37118. /**
  37119. * All of the tranform nodes added to this scene
  37120. * In the context of a Scene, it is not supposed to be modified manually.
  37121. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37122. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37123. * @see http://doc.babylonjs.com/how_to/transformnode
  37124. */
  37125. transformNodes: TransformNode[];
  37126. /**
  37127. * ActionManagers available on the scene.
  37128. */
  37129. actionManagers: AbstractActionManager[];
  37130. /**
  37131. * Textures to keep.
  37132. */
  37133. textures: BaseTexture[];
  37134. /**
  37135. * Environment texture for the scene
  37136. */
  37137. environmentTexture: Nullable<BaseTexture>;
  37138. /**
  37139. * @returns all meshes, lights, cameras, transformNodes and bones
  37140. */
  37141. getNodes(): Array<Node>;
  37142. }
  37143. }
  37144. declare module BABYLON {
  37145. /**
  37146. * Interface used to define options for Sound class
  37147. */
  37148. export interface ISoundOptions {
  37149. /**
  37150. * Does the sound autoplay once loaded.
  37151. */
  37152. autoplay?: boolean;
  37153. /**
  37154. * Does the sound loop after it finishes playing once.
  37155. */
  37156. loop?: boolean;
  37157. /**
  37158. * Sound's volume
  37159. */
  37160. volume?: number;
  37161. /**
  37162. * Is it a spatial sound?
  37163. */
  37164. spatialSound?: boolean;
  37165. /**
  37166. * Maximum distance to hear that sound
  37167. */
  37168. maxDistance?: number;
  37169. /**
  37170. * Uses user defined attenuation function
  37171. */
  37172. useCustomAttenuation?: boolean;
  37173. /**
  37174. * Define the roll off factor of spatial sounds.
  37175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37176. */
  37177. rolloffFactor?: number;
  37178. /**
  37179. * Define the reference distance the sound should be heard perfectly.
  37180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37181. */
  37182. refDistance?: number;
  37183. /**
  37184. * Define the distance attenuation model the sound will follow.
  37185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37186. */
  37187. distanceModel?: string;
  37188. /**
  37189. * Defines the playback speed (1 by default)
  37190. */
  37191. playbackRate?: number;
  37192. /**
  37193. * Defines if the sound is from a streaming source
  37194. */
  37195. streaming?: boolean;
  37196. /**
  37197. * Defines an optional length (in seconds) inside the sound file
  37198. */
  37199. length?: number;
  37200. /**
  37201. * Defines an optional offset (in seconds) inside the sound file
  37202. */
  37203. offset?: number;
  37204. /**
  37205. * If true, URLs will not be required to state the audio file codec to use.
  37206. */
  37207. skipCodecCheck?: boolean;
  37208. }
  37209. /**
  37210. * Defines a sound that can be played in the application.
  37211. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37213. */
  37214. export class Sound {
  37215. /**
  37216. * The name of the sound in the scene.
  37217. */
  37218. name: string;
  37219. /**
  37220. * Does the sound autoplay once loaded.
  37221. */
  37222. autoplay: boolean;
  37223. /**
  37224. * Does the sound loop after it finishes playing once.
  37225. */
  37226. loop: boolean;
  37227. /**
  37228. * Does the sound use a custom attenuation curve to simulate the falloff
  37229. * happening when the source gets further away from the camera.
  37230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37231. */
  37232. useCustomAttenuation: boolean;
  37233. /**
  37234. * The sound track id this sound belongs to.
  37235. */
  37236. soundTrackId: number;
  37237. /**
  37238. * Is this sound currently played.
  37239. */
  37240. isPlaying: boolean;
  37241. /**
  37242. * Is this sound currently paused.
  37243. */
  37244. isPaused: boolean;
  37245. /**
  37246. * Does this sound enables spatial sound.
  37247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37248. */
  37249. spatialSound: boolean;
  37250. /**
  37251. * Define the reference distance the sound should be heard perfectly.
  37252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37253. */
  37254. refDistance: number;
  37255. /**
  37256. * Define the roll off factor of spatial sounds.
  37257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37258. */
  37259. rolloffFactor: number;
  37260. /**
  37261. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37263. */
  37264. maxDistance: number;
  37265. /**
  37266. * Define the distance attenuation model the sound will follow.
  37267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37268. */
  37269. distanceModel: string;
  37270. /**
  37271. * @hidden
  37272. * Back Compat
  37273. **/
  37274. onended: () => any;
  37275. /**
  37276. * Observable event when the current playing sound finishes.
  37277. */
  37278. onEndedObservable: Observable<Sound>;
  37279. private _panningModel;
  37280. private _playbackRate;
  37281. private _streaming;
  37282. private _startTime;
  37283. private _startOffset;
  37284. private _position;
  37285. /** @hidden */
  37286. _positionInEmitterSpace: boolean;
  37287. private _localDirection;
  37288. private _volume;
  37289. private _isReadyToPlay;
  37290. private _isDirectional;
  37291. private _readyToPlayCallback;
  37292. private _audioBuffer;
  37293. private _soundSource;
  37294. private _streamingSource;
  37295. private _soundPanner;
  37296. private _soundGain;
  37297. private _inputAudioNode;
  37298. private _outputAudioNode;
  37299. private _coneInnerAngle;
  37300. private _coneOuterAngle;
  37301. private _coneOuterGain;
  37302. private _scene;
  37303. private _connectedTransformNode;
  37304. private _customAttenuationFunction;
  37305. private _registerFunc;
  37306. private _isOutputConnected;
  37307. private _htmlAudioElement;
  37308. private _urlType;
  37309. private _length?;
  37310. private _offset?;
  37311. /** @hidden */
  37312. static _SceneComponentInitialization: (scene: Scene) => void;
  37313. /**
  37314. * Create a sound and attach it to a scene
  37315. * @param name Name of your sound
  37316. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37317. * @param scene defines the scene the sound belongs to
  37318. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37319. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37320. */
  37321. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37322. /**
  37323. * Release the sound and its associated resources
  37324. */
  37325. dispose(): void;
  37326. /**
  37327. * Gets if the sounds is ready to be played or not.
  37328. * @returns true if ready, otherwise false
  37329. */
  37330. isReady(): boolean;
  37331. private _soundLoaded;
  37332. /**
  37333. * Sets the data of the sound from an audiobuffer
  37334. * @param audioBuffer The audioBuffer containing the data
  37335. */
  37336. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37337. /**
  37338. * Updates the current sounds options such as maxdistance, loop...
  37339. * @param options A JSON object containing values named as the object properties
  37340. */
  37341. updateOptions(options: ISoundOptions): void;
  37342. private _createSpatialParameters;
  37343. private _updateSpatialParameters;
  37344. /**
  37345. * Switch the panning model to HRTF:
  37346. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37348. */
  37349. switchPanningModelToHRTF(): void;
  37350. /**
  37351. * Switch the panning model to Equal Power:
  37352. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37354. */
  37355. switchPanningModelToEqualPower(): void;
  37356. private _switchPanningModel;
  37357. /**
  37358. * Connect this sound to a sound track audio node like gain...
  37359. * @param soundTrackAudioNode the sound track audio node to connect to
  37360. */
  37361. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37362. /**
  37363. * Transform this sound into a directional source
  37364. * @param coneInnerAngle Size of the inner cone in degree
  37365. * @param coneOuterAngle Size of the outer cone in degree
  37366. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37367. */
  37368. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37369. /**
  37370. * Gets or sets the inner angle for the directional cone.
  37371. */
  37372. get directionalConeInnerAngle(): number;
  37373. /**
  37374. * Gets or sets the inner angle for the directional cone.
  37375. */
  37376. set directionalConeInnerAngle(value: number);
  37377. /**
  37378. * Gets or sets the outer angle for the directional cone.
  37379. */
  37380. get directionalConeOuterAngle(): number;
  37381. /**
  37382. * Gets or sets the outer angle for the directional cone.
  37383. */
  37384. set directionalConeOuterAngle(value: number);
  37385. /**
  37386. * Sets the position of the emitter if spatial sound is enabled
  37387. * @param newPosition Defines the new posisiton
  37388. */
  37389. setPosition(newPosition: Vector3): void;
  37390. /**
  37391. * Sets the local direction of the emitter if spatial sound is enabled
  37392. * @param newLocalDirection Defines the new local direction
  37393. */
  37394. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37395. private _updateDirection;
  37396. /** @hidden */
  37397. updateDistanceFromListener(): void;
  37398. /**
  37399. * Sets a new custom attenuation function for the sound.
  37400. * @param callback Defines the function used for the attenuation
  37401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37402. */
  37403. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37404. /**
  37405. * Play the sound
  37406. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37407. * @param offset (optional) Start the sound at a specific time in seconds
  37408. * @param length (optional) Sound duration (in seconds)
  37409. */
  37410. play(time?: number, offset?: number, length?: number): void;
  37411. private _onended;
  37412. /**
  37413. * Stop the sound
  37414. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37415. */
  37416. stop(time?: number): void;
  37417. /**
  37418. * Put the sound in pause
  37419. */
  37420. pause(): void;
  37421. /**
  37422. * Sets a dedicated volume for this sounds
  37423. * @param newVolume Define the new volume of the sound
  37424. * @param time Define time for gradual change to new volume
  37425. */
  37426. setVolume(newVolume: number, time?: number): void;
  37427. /**
  37428. * Set the sound play back rate
  37429. * @param newPlaybackRate Define the playback rate the sound should be played at
  37430. */
  37431. setPlaybackRate(newPlaybackRate: number): void;
  37432. /**
  37433. * Gets the volume of the sound.
  37434. * @returns the volume of the sound
  37435. */
  37436. getVolume(): number;
  37437. /**
  37438. * Attach the sound to a dedicated mesh
  37439. * @param transformNode The transform node to connect the sound with
  37440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37441. */
  37442. attachToMesh(transformNode: TransformNode): void;
  37443. /**
  37444. * Detach the sound from the previously attached mesh
  37445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37446. */
  37447. detachFromMesh(): void;
  37448. private _onRegisterAfterWorldMatrixUpdate;
  37449. /**
  37450. * Clone the current sound in the scene.
  37451. * @returns the new sound clone
  37452. */
  37453. clone(): Nullable<Sound>;
  37454. /**
  37455. * Gets the current underlying audio buffer containing the data
  37456. * @returns the audio buffer
  37457. */
  37458. getAudioBuffer(): Nullable<AudioBuffer>;
  37459. /**
  37460. * Serializes the Sound in a JSON representation
  37461. * @returns the JSON representation of the sound
  37462. */
  37463. serialize(): any;
  37464. /**
  37465. * Parse a JSON representation of a sound to innstantiate in a given scene
  37466. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37467. * @param scene Define the scene the new parsed sound should be created in
  37468. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37469. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37470. * @returns the newly parsed sound
  37471. */
  37472. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37473. }
  37474. }
  37475. declare module BABYLON {
  37476. /**
  37477. * This defines an action helpful to play a defined sound on a triggered action.
  37478. */
  37479. export class PlaySoundAction extends Action {
  37480. private _sound;
  37481. /**
  37482. * Instantiate the action
  37483. * @param triggerOptions defines the trigger options
  37484. * @param sound defines the sound to play
  37485. * @param condition defines the trigger related conditions
  37486. */
  37487. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37488. /** @hidden */
  37489. _prepare(): void;
  37490. /**
  37491. * Execute the action and play the sound.
  37492. */
  37493. execute(): void;
  37494. /**
  37495. * Serializes the actions and its related information.
  37496. * @param parent defines the object to serialize in
  37497. * @returns the serialized object
  37498. */
  37499. serialize(parent: any): any;
  37500. }
  37501. /**
  37502. * This defines an action helpful to stop a defined sound on a triggered action.
  37503. */
  37504. export class StopSoundAction extends Action {
  37505. private _sound;
  37506. /**
  37507. * Instantiate the action
  37508. * @param triggerOptions defines the trigger options
  37509. * @param sound defines the sound to stop
  37510. * @param condition defines the trigger related conditions
  37511. */
  37512. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37513. /** @hidden */
  37514. _prepare(): void;
  37515. /**
  37516. * Execute the action and stop the sound.
  37517. */
  37518. execute(): void;
  37519. /**
  37520. * Serializes the actions and its related information.
  37521. * @param parent defines the object to serialize in
  37522. * @returns the serialized object
  37523. */
  37524. serialize(parent: any): any;
  37525. }
  37526. }
  37527. declare module BABYLON {
  37528. /**
  37529. * This defines an action responsible to change the value of a property
  37530. * by interpolating between its current value and the newly set one once triggered.
  37531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37532. */
  37533. export class InterpolateValueAction extends Action {
  37534. /**
  37535. * Defines the path of the property where the value should be interpolated
  37536. */
  37537. propertyPath: string;
  37538. /**
  37539. * Defines the target value at the end of the interpolation.
  37540. */
  37541. value: any;
  37542. /**
  37543. * Defines the time it will take for the property to interpolate to the value.
  37544. */
  37545. duration: number;
  37546. /**
  37547. * Defines if the other scene animations should be stopped when the action has been triggered
  37548. */
  37549. stopOtherAnimations?: boolean;
  37550. /**
  37551. * Defines a callback raised once the interpolation animation has been done.
  37552. */
  37553. onInterpolationDone?: () => void;
  37554. /**
  37555. * Observable triggered once the interpolation animation has been done.
  37556. */
  37557. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37558. private _target;
  37559. private _effectiveTarget;
  37560. private _property;
  37561. /**
  37562. * Instantiate the action
  37563. * @param triggerOptions defines the trigger options
  37564. * @param target defines the object containing the value to interpolate
  37565. * @param propertyPath defines the path to the property in the target object
  37566. * @param value defines the target value at the end of the interpolation
  37567. * @param duration deines the time it will take for the property to interpolate to the value.
  37568. * @param condition defines the trigger related conditions
  37569. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37570. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37571. */
  37572. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37573. /** @hidden */
  37574. _prepare(): void;
  37575. /**
  37576. * Execute the action starts the value interpolation.
  37577. */
  37578. execute(): void;
  37579. /**
  37580. * Serializes the actions and its related information.
  37581. * @param parent defines the object to serialize in
  37582. * @returns the serialized object
  37583. */
  37584. serialize(parent: any): any;
  37585. }
  37586. }
  37587. declare module BABYLON {
  37588. /**
  37589. * Options allowed during the creation of a sound track.
  37590. */
  37591. export interface ISoundTrackOptions {
  37592. /**
  37593. * The volume the sound track should take during creation
  37594. */
  37595. volume?: number;
  37596. /**
  37597. * Define if the sound track is the main sound track of the scene
  37598. */
  37599. mainTrack?: boolean;
  37600. }
  37601. /**
  37602. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37603. * It will be also used in a future release to apply effects on a specific track.
  37604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37605. */
  37606. export class SoundTrack {
  37607. /**
  37608. * The unique identifier of the sound track in the scene.
  37609. */
  37610. id: number;
  37611. /**
  37612. * The list of sounds included in the sound track.
  37613. */
  37614. soundCollection: Array<Sound>;
  37615. private _outputAudioNode;
  37616. private _scene;
  37617. private _connectedAnalyser;
  37618. private _options;
  37619. private _isInitialized;
  37620. /**
  37621. * Creates a new sound track.
  37622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37623. * @param scene Define the scene the sound track belongs to
  37624. * @param options
  37625. */
  37626. constructor(scene: Scene, options?: ISoundTrackOptions);
  37627. private _initializeSoundTrackAudioGraph;
  37628. /**
  37629. * Release the sound track and its associated resources
  37630. */
  37631. dispose(): void;
  37632. /**
  37633. * Adds a sound to this sound track
  37634. * @param sound define the cound to add
  37635. * @ignoreNaming
  37636. */
  37637. AddSound(sound: Sound): void;
  37638. /**
  37639. * Removes a sound to this sound track
  37640. * @param sound define the cound to remove
  37641. * @ignoreNaming
  37642. */
  37643. RemoveSound(sound: Sound): void;
  37644. /**
  37645. * Set a global volume for the full sound track.
  37646. * @param newVolume Define the new volume of the sound track
  37647. */
  37648. setVolume(newVolume: number): void;
  37649. /**
  37650. * Switch the panning model to HRTF:
  37651. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37653. */
  37654. switchPanningModelToHRTF(): void;
  37655. /**
  37656. * Switch the panning model to Equal Power:
  37657. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37659. */
  37660. switchPanningModelToEqualPower(): void;
  37661. /**
  37662. * Connect the sound track to an audio analyser allowing some amazing
  37663. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37665. * @param analyser The analyser to connect to the engine
  37666. */
  37667. connectToAnalyser(analyser: Analyser): void;
  37668. }
  37669. }
  37670. declare module BABYLON {
  37671. interface AbstractScene {
  37672. /**
  37673. * The list of sounds used in the scene.
  37674. */
  37675. sounds: Nullable<Array<Sound>>;
  37676. }
  37677. interface Scene {
  37678. /**
  37679. * @hidden
  37680. * Backing field
  37681. */
  37682. _mainSoundTrack: SoundTrack;
  37683. /**
  37684. * The main sound track played by the scene.
  37685. * It cotains your primary collection of sounds.
  37686. */
  37687. mainSoundTrack: SoundTrack;
  37688. /**
  37689. * The list of sound tracks added to the scene
  37690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37691. */
  37692. soundTracks: Nullable<Array<SoundTrack>>;
  37693. /**
  37694. * Gets a sound using a given name
  37695. * @param name defines the name to search for
  37696. * @return the found sound or null if not found at all.
  37697. */
  37698. getSoundByName(name: string): Nullable<Sound>;
  37699. /**
  37700. * Gets or sets if audio support is enabled
  37701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37702. */
  37703. audioEnabled: boolean;
  37704. /**
  37705. * Gets or sets if audio will be output to headphones
  37706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37707. */
  37708. headphone: boolean;
  37709. /**
  37710. * Gets or sets custom audio listener position provider
  37711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37712. */
  37713. audioListenerPositionProvider: Nullable<() => Vector3>;
  37714. /**
  37715. * Gets or sets a refresh rate when using 3D audio positioning
  37716. */
  37717. audioPositioningRefreshRate: number;
  37718. }
  37719. /**
  37720. * Defines the sound scene component responsible to manage any sounds
  37721. * in a given scene.
  37722. */
  37723. export class AudioSceneComponent implements ISceneSerializableComponent {
  37724. /**
  37725. * The component name helpfull to identify the component in the list of scene components.
  37726. */
  37727. readonly name: string;
  37728. /**
  37729. * The scene the component belongs to.
  37730. */
  37731. scene: Scene;
  37732. private _audioEnabled;
  37733. /**
  37734. * Gets whether audio is enabled or not.
  37735. * Please use related enable/disable method to switch state.
  37736. */
  37737. get audioEnabled(): boolean;
  37738. private _headphone;
  37739. /**
  37740. * Gets whether audio is outputing to headphone or not.
  37741. * Please use the according Switch methods to change output.
  37742. */
  37743. get headphone(): boolean;
  37744. /**
  37745. * Gets or sets a refresh rate when using 3D audio positioning
  37746. */
  37747. audioPositioningRefreshRate: number;
  37748. private _audioListenerPositionProvider;
  37749. /**
  37750. * Gets the current audio listener position provider
  37751. */
  37752. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37753. /**
  37754. * Sets a custom listener position for all sounds in the scene
  37755. * By default, this is the position of the first active camera
  37756. */
  37757. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37758. /**
  37759. * Creates a new instance of the component for the given scene
  37760. * @param scene Defines the scene to register the component in
  37761. */
  37762. constructor(scene: Scene);
  37763. /**
  37764. * Registers the component in a given scene
  37765. */
  37766. register(): void;
  37767. /**
  37768. * Rebuilds the elements related to this component in case of
  37769. * context lost for instance.
  37770. */
  37771. rebuild(): void;
  37772. /**
  37773. * Serializes the component data to the specified json object
  37774. * @param serializationObject The object to serialize to
  37775. */
  37776. serialize(serializationObject: any): void;
  37777. /**
  37778. * Adds all the elements from the container to the scene
  37779. * @param container the container holding the elements
  37780. */
  37781. addFromContainer(container: AbstractScene): void;
  37782. /**
  37783. * Removes all the elements in the container from the scene
  37784. * @param container contains the elements to remove
  37785. * @param dispose if the removed element should be disposed (default: false)
  37786. */
  37787. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37788. /**
  37789. * Disposes the component and the associated ressources.
  37790. */
  37791. dispose(): void;
  37792. /**
  37793. * Disables audio in the associated scene.
  37794. */
  37795. disableAudio(): void;
  37796. /**
  37797. * Enables audio in the associated scene.
  37798. */
  37799. enableAudio(): void;
  37800. /**
  37801. * Switch audio to headphone output.
  37802. */
  37803. switchAudioModeForHeadphones(): void;
  37804. /**
  37805. * Switch audio to normal speakers.
  37806. */
  37807. switchAudioModeForNormalSpeakers(): void;
  37808. private _cachedCameraDirection;
  37809. private _cachedCameraPosition;
  37810. private _lastCheck;
  37811. private _afterRender;
  37812. }
  37813. }
  37814. declare module BABYLON {
  37815. /**
  37816. * Wraps one or more Sound objects and selects one with random weight for playback.
  37817. */
  37818. export class WeightedSound {
  37819. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37820. loop: boolean;
  37821. private _coneInnerAngle;
  37822. private _coneOuterAngle;
  37823. private _volume;
  37824. /** A Sound is currently playing. */
  37825. isPlaying: boolean;
  37826. /** A Sound is currently paused. */
  37827. isPaused: boolean;
  37828. private _sounds;
  37829. private _weights;
  37830. private _currentIndex?;
  37831. /**
  37832. * Creates a new WeightedSound from the list of sounds given.
  37833. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37834. * @param sounds Array of Sounds that will be selected from.
  37835. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37836. */
  37837. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37838. /**
  37839. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37840. */
  37841. get directionalConeInnerAngle(): number;
  37842. /**
  37843. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37844. */
  37845. set directionalConeInnerAngle(value: number);
  37846. /**
  37847. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37848. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37849. */
  37850. get directionalConeOuterAngle(): number;
  37851. /**
  37852. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37853. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37854. */
  37855. set directionalConeOuterAngle(value: number);
  37856. /**
  37857. * Playback volume.
  37858. */
  37859. get volume(): number;
  37860. /**
  37861. * Playback volume.
  37862. */
  37863. set volume(value: number);
  37864. private _onended;
  37865. /**
  37866. * Suspend playback
  37867. */
  37868. pause(): void;
  37869. /**
  37870. * Stop playback
  37871. */
  37872. stop(): void;
  37873. /**
  37874. * Start playback.
  37875. * @param startOffset Position the clip head at a specific time in seconds.
  37876. */
  37877. play(startOffset?: number): void;
  37878. }
  37879. }
  37880. declare module BABYLON {
  37881. /**
  37882. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37883. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37884. */
  37885. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37886. /**
  37887. * Gets the name of the behavior.
  37888. */
  37889. get name(): string;
  37890. /**
  37891. * The easing function used by animations
  37892. */
  37893. static EasingFunction: BackEase;
  37894. /**
  37895. * The easing mode used by animations
  37896. */
  37897. static EasingMode: number;
  37898. /**
  37899. * The duration of the animation, in milliseconds
  37900. */
  37901. transitionDuration: number;
  37902. /**
  37903. * Length of the distance animated by the transition when lower radius is reached
  37904. */
  37905. lowerRadiusTransitionRange: number;
  37906. /**
  37907. * Length of the distance animated by the transition when upper radius is reached
  37908. */
  37909. upperRadiusTransitionRange: number;
  37910. private _autoTransitionRange;
  37911. /**
  37912. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37913. */
  37914. get autoTransitionRange(): boolean;
  37915. /**
  37916. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37917. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37918. */
  37919. set autoTransitionRange(value: boolean);
  37920. private _attachedCamera;
  37921. private _onAfterCheckInputsObserver;
  37922. private _onMeshTargetChangedObserver;
  37923. /**
  37924. * Initializes the behavior.
  37925. */
  37926. init(): void;
  37927. /**
  37928. * Attaches the behavior to its arc rotate camera.
  37929. * @param camera Defines the camera to attach the behavior to
  37930. */
  37931. attach(camera: ArcRotateCamera): void;
  37932. /**
  37933. * Detaches the behavior from its current arc rotate camera.
  37934. */
  37935. detach(): void;
  37936. private _radiusIsAnimating;
  37937. private _radiusBounceTransition;
  37938. private _animatables;
  37939. private _cachedWheelPrecision;
  37940. /**
  37941. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37942. * @param radiusLimit The limit to check against.
  37943. * @return Bool to indicate if at limit.
  37944. */
  37945. private _isRadiusAtLimit;
  37946. /**
  37947. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37948. * @param radiusDelta The delta by which to animate to. Can be negative.
  37949. */
  37950. private _applyBoundRadiusAnimation;
  37951. /**
  37952. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37953. */
  37954. protected _clearAnimationLocks(): void;
  37955. /**
  37956. * Stops and removes all animations that have been applied to the camera
  37957. */
  37958. stopAllAnimations(): void;
  37959. }
  37960. }
  37961. declare module BABYLON {
  37962. /**
  37963. * 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.
  37964. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37965. */
  37966. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37967. /**
  37968. * Gets the name of the behavior.
  37969. */
  37970. get name(): string;
  37971. private _mode;
  37972. private _radiusScale;
  37973. private _positionScale;
  37974. private _defaultElevation;
  37975. private _elevationReturnTime;
  37976. private _elevationReturnWaitTime;
  37977. private _zoomStopsAnimation;
  37978. private _framingTime;
  37979. /**
  37980. * The easing function used by animations
  37981. */
  37982. static EasingFunction: ExponentialEase;
  37983. /**
  37984. * The easing mode used by animations
  37985. */
  37986. static EasingMode: number;
  37987. /**
  37988. * Sets the current mode used by the behavior
  37989. */
  37990. set mode(mode: number);
  37991. /**
  37992. * Gets current mode used by the behavior.
  37993. */
  37994. get mode(): number;
  37995. /**
  37996. * Sets the scale applied to the radius (1 by default)
  37997. */
  37998. set radiusScale(radius: number);
  37999. /**
  38000. * Gets the scale applied to the radius
  38001. */
  38002. get radiusScale(): number;
  38003. /**
  38004. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38005. */
  38006. set positionScale(scale: number);
  38007. /**
  38008. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38009. */
  38010. get positionScale(): number;
  38011. /**
  38012. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38013. * behaviour is triggered, in radians.
  38014. */
  38015. set defaultElevation(elevation: number);
  38016. /**
  38017. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38018. * behaviour is triggered, in radians.
  38019. */
  38020. get defaultElevation(): number;
  38021. /**
  38022. * Sets the time (in milliseconds) taken to return to the default beta position.
  38023. * Negative value indicates camera should not return to default.
  38024. */
  38025. set elevationReturnTime(speed: number);
  38026. /**
  38027. * Gets the time (in milliseconds) taken to return to the default beta position.
  38028. * Negative value indicates camera should not return to default.
  38029. */
  38030. get elevationReturnTime(): number;
  38031. /**
  38032. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38033. */
  38034. set elevationReturnWaitTime(time: number);
  38035. /**
  38036. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38037. */
  38038. get elevationReturnWaitTime(): number;
  38039. /**
  38040. * Sets the flag that indicates if user zooming should stop animation.
  38041. */
  38042. set zoomStopsAnimation(flag: boolean);
  38043. /**
  38044. * Gets the flag that indicates if user zooming should stop animation.
  38045. */
  38046. get zoomStopsAnimation(): boolean;
  38047. /**
  38048. * Sets the transition time when framing the mesh, in milliseconds
  38049. */
  38050. set framingTime(time: number);
  38051. /**
  38052. * Gets the transition time when framing the mesh, in milliseconds
  38053. */
  38054. get framingTime(): number;
  38055. /**
  38056. * Define if the behavior should automatically change the configured
  38057. * camera limits and sensibilities.
  38058. */
  38059. autoCorrectCameraLimitsAndSensibility: boolean;
  38060. private _onPrePointerObservableObserver;
  38061. private _onAfterCheckInputsObserver;
  38062. private _onMeshTargetChangedObserver;
  38063. private _attachedCamera;
  38064. private _isPointerDown;
  38065. private _lastInteractionTime;
  38066. /**
  38067. * Initializes the behavior.
  38068. */
  38069. init(): void;
  38070. /**
  38071. * Attaches the behavior to its arc rotate camera.
  38072. * @param camera Defines the camera to attach the behavior to
  38073. */
  38074. attach(camera: ArcRotateCamera): void;
  38075. /**
  38076. * Detaches the behavior from its current arc rotate camera.
  38077. */
  38078. detach(): void;
  38079. private _animatables;
  38080. private _betaIsAnimating;
  38081. private _betaTransition;
  38082. private _radiusTransition;
  38083. private _vectorTransition;
  38084. /**
  38085. * Targets the given mesh and updates zoom level accordingly.
  38086. * @param mesh The mesh to target.
  38087. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38088. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38089. */
  38090. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38091. /**
  38092. * Targets the given mesh with its children and updates zoom level accordingly.
  38093. * @param mesh The mesh to target.
  38094. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38095. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38096. */
  38097. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38098. /**
  38099. * Targets the given meshes with their children and updates zoom level accordingly.
  38100. * @param meshes The mesh to target.
  38101. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38102. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38103. */
  38104. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38105. /**
  38106. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38107. * @param minimumWorld Determines the smaller position of the bounding box extend
  38108. * @param maximumWorld Determines the bigger position of the bounding box extend
  38109. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38110. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38111. */
  38112. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38113. /**
  38114. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38115. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38116. * frustum width.
  38117. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38118. * to fully enclose the mesh in the viewing frustum.
  38119. */
  38120. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38121. /**
  38122. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38123. * is automatically returned to its default position (expected to be above ground plane).
  38124. */
  38125. private _maintainCameraAboveGround;
  38126. /**
  38127. * Returns the frustum slope based on the canvas ratio and camera FOV
  38128. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38129. */
  38130. private _getFrustumSlope;
  38131. /**
  38132. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38133. */
  38134. private _clearAnimationLocks;
  38135. /**
  38136. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38137. */
  38138. private _applyUserInteraction;
  38139. /**
  38140. * Stops and removes all animations that have been applied to the camera
  38141. */
  38142. stopAllAnimations(): void;
  38143. /**
  38144. * Gets a value indicating if the user is moving the camera
  38145. */
  38146. get isUserIsMoving(): boolean;
  38147. /**
  38148. * The camera can move all the way towards the mesh.
  38149. */
  38150. static IgnoreBoundsSizeMode: number;
  38151. /**
  38152. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38153. */
  38154. static FitFrustumSidesMode: number;
  38155. }
  38156. }
  38157. declare module BABYLON {
  38158. /**
  38159. * Base class for Camera Pointer Inputs.
  38160. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38161. * for example usage.
  38162. */
  38163. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38164. /**
  38165. * Defines the camera the input is attached to.
  38166. */
  38167. abstract camera: Camera;
  38168. /**
  38169. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38170. */
  38171. protected _altKey: boolean;
  38172. protected _ctrlKey: boolean;
  38173. protected _metaKey: boolean;
  38174. protected _shiftKey: boolean;
  38175. /**
  38176. * Which mouse buttons were pressed at time of last mouse event.
  38177. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38178. */
  38179. protected _buttonsPressed: number;
  38180. /**
  38181. * Defines the buttons associated with the input to handle camera move.
  38182. */
  38183. buttons: number[];
  38184. /**
  38185. * Attach the input controls to a specific dom element to get the input from.
  38186. * @param element Defines the element the controls should be listened from
  38187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38188. */
  38189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38190. /**
  38191. * Detach the current controls from the specified dom element.
  38192. * @param element Defines the element to stop listening the inputs from
  38193. */
  38194. detachControl(element: Nullable<HTMLElement>): void;
  38195. /**
  38196. * Gets the class name of the current input.
  38197. * @returns the class name
  38198. */
  38199. getClassName(): string;
  38200. /**
  38201. * Get the friendly name associated with the input class.
  38202. * @returns the input friendly name
  38203. */
  38204. getSimpleName(): string;
  38205. /**
  38206. * Called on pointer POINTERDOUBLETAP event.
  38207. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38208. */
  38209. protected onDoubleTap(type: string): void;
  38210. /**
  38211. * Called on pointer POINTERMOVE event if only a single touch is active.
  38212. * Override this method to provide functionality.
  38213. */
  38214. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38215. /**
  38216. * Called on pointer POINTERMOVE event if multiple touches are active.
  38217. * Override this method to provide functionality.
  38218. */
  38219. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38220. /**
  38221. * Called on JS contextmenu event.
  38222. * Override this method to provide functionality.
  38223. */
  38224. protected onContextMenu(evt: PointerEvent): void;
  38225. /**
  38226. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38227. * press.
  38228. * Override this method to provide functionality.
  38229. */
  38230. protected onButtonDown(evt: PointerEvent): void;
  38231. /**
  38232. * Called each time a new POINTERUP event occurs. Ie, for each button
  38233. * release.
  38234. * Override this method to provide functionality.
  38235. */
  38236. protected onButtonUp(evt: PointerEvent): void;
  38237. /**
  38238. * Called when window becomes inactive.
  38239. * Override this method to provide functionality.
  38240. */
  38241. protected onLostFocus(): void;
  38242. private _pointerInput;
  38243. private _observer;
  38244. private _onLostFocus;
  38245. private pointA;
  38246. private pointB;
  38247. }
  38248. }
  38249. declare module BABYLON {
  38250. /**
  38251. * Manage the pointers inputs to control an arc rotate camera.
  38252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38253. */
  38254. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38255. /**
  38256. * Defines the camera the input is attached to.
  38257. */
  38258. camera: ArcRotateCamera;
  38259. /**
  38260. * Gets the class name of the current input.
  38261. * @returns the class name
  38262. */
  38263. getClassName(): string;
  38264. /**
  38265. * Defines the buttons associated with the input to handle camera move.
  38266. */
  38267. buttons: number[];
  38268. /**
  38269. * Defines the pointer angular sensibility along the X axis or how fast is
  38270. * the camera rotating.
  38271. */
  38272. angularSensibilityX: number;
  38273. /**
  38274. * Defines the pointer angular sensibility along the Y axis or how fast is
  38275. * the camera rotating.
  38276. */
  38277. angularSensibilityY: number;
  38278. /**
  38279. * Defines the pointer pinch precision or how fast is the camera zooming.
  38280. */
  38281. pinchPrecision: number;
  38282. /**
  38283. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38284. * from 0.
  38285. * It defines the percentage of current camera.radius to use as delta when
  38286. * pinch zoom is used.
  38287. */
  38288. pinchDeltaPercentage: number;
  38289. /**
  38290. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38291. * that any object in the plane at the camera's target point will scale
  38292. * perfectly with finger motion.
  38293. * Overrides pinchDeltaPercentage and pinchPrecision.
  38294. */
  38295. useNaturalPinchZoom: boolean;
  38296. /**
  38297. * Defines the pointer panning sensibility or how fast is the camera moving.
  38298. */
  38299. panningSensibility: number;
  38300. /**
  38301. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38302. */
  38303. multiTouchPanning: boolean;
  38304. /**
  38305. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38306. * zoom (pinch) through multitouch.
  38307. */
  38308. multiTouchPanAndZoom: boolean;
  38309. /**
  38310. * Revers pinch action direction.
  38311. */
  38312. pinchInwards: boolean;
  38313. private _isPanClick;
  38314. private _twoFingerActivityCount;
  38315. private _isPinching;
  38316. /**
  38317. * Called on pointer POINTERMOVE event if only a single touch is active.
  38318. */
  38319. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38320. /**
  38321. * Called on pointer POINTERDOUBLETAP event.
  38322. */
  38323. protected onDoubleTap(type: string): void;
  38324. /**
  38325. * Called on pointer POINTERMOVE event if multiple touches are active.
  38326. */
  38327. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38328. /**
  38329. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38330. * press.
  38331. */
  38332. protected onButtonDown(evt: PointerEvent): void;
  38333. /**
  38334. * Called each time a new POINTERUP event occurs. Ie, for each button
  38335. * release.
  38336. */
  38337. protected onButtonUp(evt: PointerEvent): void;
  38338. /**
  38339. * Called when window becomes inactive.
  38340. */
  38341. protected onLostFocus(): void;
  38342. }
  38343. }
  38344. declare module BABYLON {
  38345. /**
  38346. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38348. */
  38349. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38350. /**
  38351. * Defines the camera the input is attached to.
  38352. */
  38353. camera: ArcRotateCamera;
  38354. /**
  38355. * Defines the list of key codes associated with the up action (increase alpha)
  38356. */
  38357. keysUp: number[];
  38358. /**
  38359. * Defines the list of key codes associated with the down action (decrease alpha)
  38360. */
  38361. keysDown: number[];
  38362. /**
  38363. * Defines the list of key codes associated with the left action (increase beta)
  38364. */
  38365. keysLeft: number[];
  38366. /**
  38367. * Defines the list of key codes associated with the right action (decrease beta)
  38368. */
  38369. keysRight: number[];
  38370. /**
  38371. * Defines the list of key codes associated with the reset action.
  38372. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38373. */
  38374. keysReset: number[];
  38375. /**
  38376. * Defines the panning sensibility of the inputs.
  38377. * (How fast is the camera panning)
  38378. */
  38379. panningSensibility: number;
  38380. /**
  38381. * Defines the zooming sensibility of the inputs.
  38382. * (How fast is the camera zooming)
  38383. */
  38384. zoomingSensibility: number;
  38385. /**
  38386. * Defines whether maintaining the alt key down switch the movement mode from
  38387. * orientation to zoom.
  38388. */
  38389. useAltToZoom: boolean;
  38390. /**
  38391. * Rotation speed of the camera
  38392. */
  38393. angularSpeed: number;
  38394. private _keys;
  38395. private _ctrlPressed;
  38396. private _altPressed;
  38397. private _onCanvasBlurObserver;
  38398. private _onKeyboardObserver;
  38399. private _engine;
  38400. private _scene;
  38401. /**
  38402. * Attach the input controls to a specific dom element to get the input from.
  38403. * @param element Defines the element the controls should be listened from
  38404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38405. */
  38406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38407. /**
  38408. * Detach the current controls from the specified dom element.
  38409. * @param element Defines the element to stop listening the inputs from
  38410. */
  38411. detachControl(element: Nullable<HTMLElement>): void;
  38412. /**
  38413. * Update the current camera state depending on the inputs that have been used this frame.
  38414. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38415. */
  38416. checkInputs(): void;
  38417. /**
  38418. * Gets the class name of the current intput.
  38419. * @returns the class name
  38420. */
  38421. getClassName(): string;
  38422. /**
  38423. * Get the friendly name associated with the input class.
  38424. * @returns the input friendly name
  38425. */
  38426. getSimpleName(): string;
  38427. }
  38428. }
  38429. declare module BABYLON {
  38430. /**
  38431. * Manage the mouse wheel inputs to control an arc rotate camera.
  38432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38433. */
  38434. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38435. /**
  38436. * Defines the camera the input is attached to.
  38437. */
  38438. camera: ArcRotateCamera;
  38439. /**
  38440. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38441. */
  38442. wheelPrecision: number;
  38443. /**
  38444. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38445. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38446. */
  38447. wheelDeltaPercentage: number;
  38448. private _wheel;
  38449. private _observer;
  38450. private computeDeltaFromMouseWheelLegacyEvent;
  38451. /**
  38452. * Attach the input controls to a specific dom element to get the input from.
  38453. * @param element Defines the element the controls should be listened from
  38454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38455. */
  38456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38457. /**
  38458. * Detach the current controls from the specified dom element.
  38459. * @param element Defines the element to stop listening the inputs from
  38460. */
  38461. detachControl(element: Nullable<HTMLElement>): void;
  38462. /**
  38463. * Gets the class name of the current intput.
  38464. * @returns the class name
  38465. */
  38466. getClassName(): string;
  38467. /**
  38468. * Get the friendly name associated with the input class.
  38469. * @returns the input friendly name
  38470. */
  38471. getSimpleName(): string;
  38472. }
  38473. }
  38474. declare module BABYLON {
  38475. /**
  38476. * Default Inputs manager for the ArcRotateCamera.
  38477. * It groups all the default supported inputs for ease of use.
  38478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38479. */
  38480. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38481. /**
  38482. * Instantiates a new ArcRotateCameraInputsManager.
  38483. * @param camera Defines the camera the inputs belong to
  38484. */
  38485. constructor(camera: ArcRotateCamera);
  38486. /**
  38487. * Add mouse wheel input support to the input manager.
  38488. * @returns the current input manager
  38489. */
  38490. addMouseWheel(): ArcRotateCameraInputsManager;
  38491. /**
  38492. * Add pointers input support to the input manager.
  38493. * @returns the current input manager
  38494. */
  38495. addPointers(): ArcRotateCameraInputsManager;
  38496. /**
  38497. * Add keyboard input support to the input manager.
  38498. * @returns the current input manager
  38499. */
  38500. addKeyboard(): ArcRotateCameraInputsManager;
  38501. }
  38502. }
  38503. declare module BABYLON {
  38504. /**
  38505. * This represents an orbital type of camera.
  38506. *
  38507. * 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.
  38508. * 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.
  38509. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38510. */
  38511. export class ArcRotateCamera extends TargetCamera {
  38512. /**
  38513. * Defines the rotation angle of the camera along the longitudinal axis.
  38514. */
  38515. alpha: number;
  38516. /**
  38517. * Defines the rotation angle of the camera along the latitudinal axis.
  38518. */
  38519. beta: number;
  38520. /**
  38521. * Defines the radius of the camera from it s target point.
  38522. */
  38523. radius: number;
  38524. protected _target: Vector3;
  38525. protected _targetHost: Nullable<AbstractMesh>;
  38526. /**
  38527. * Defines the target point of the camera.
  38528. * The camera looks towards it form the radius distance.
  38529. */
  38530. get target(): Vector3;
  38531. set target(value: Vector3);
  38532. /**
  38533. * Define the current local position of the camera in the scene
  38534. */
  38535. get position(): Vector3;
  38536. set position(newPosition: Vector3);
  38537. protected _upVector: Vector3;
  38538. protected _upToYMatrix: Matrix;
  38539. protected _YToUpMatrix: Matrix;
  38540. /**
  38541. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38542. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38543. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38544. */
  38545. set upVector(vec: Vector3);
  38546. get upVector(): Vector3;
  38547. /**
  38548. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38549. */
  38550. setMatUp(): void;
  38551. /**
  38552. * Current inertia value on the longitudinal axis.
  38553. * The bigger this number the longer it will take for the camera to stop.
  38554. */
  38555. inertialAlphaOffset: number;
  38556. /**
  38557. * Current inertia value on the latitudinal axis.
  38558. * The bigger this number the longer it will take for the camera to stop.
  38559. */
  38560. inertialBetaOffset: number;
  38561. /**
  38562. * Current inertia value on the radius axis.
  38563. * The bigger this number the longer it will take for the camera to stop.
  38564. */
  38565. inertialRadiusOffset: number;
  38566. /**
  38567. * Minimum allowed angle on the longitudinal axis.
  38568. * This can help limiting how the Camera is able to move in the scene.
  38569. */
  38570. lowerAlphaLimit: Nullable<number>;
  38571. /**
  38572. * Maximum allowed angle on the longitudinal axis.
  38573. * This can help limiting how the Camera is able to move in the scene.
  38574. */
  38575. upperAlphaLimit: Nullable<number>;
  38576. /**
  38577. * Minimum allowed angle on the latitudinal axis.
  38578. * This can help limiting how the Camera is able to move in the scene.
  38579. */
  38580. lowerBetaLimit: number;
  38581. /**
  38582. * Maximum allowed angle on the latitudinal axis.
  38583. * This can help limiting how the Camera is able to move in the scene.
  38584. */
  38585. upperBetaLimit: number;
  38586. /**
  38587. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38588. * This can help limiting how the Camera is able to move in the scene.
  38589. */
  38590. lowerRadiusLimit: Nullable<number>;
  38591. /**
  38592. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38593. * This can help limiting how the Camera is able to move in the scene.
  38594. */
  38595. upperRadiusLimit: Nullable<number>;
  38596. /**
  38597. * Defines the current inertia value used during panning of the camera along the X axis.
  38598. */
  38599. inertialPanningX: number;
  38600. /**
  38601. * Defines the current inertia value used during panning of the camera along the Y axis.
  38602. */
  38603. inertialPanningY: number;
  38604. /**
  38605. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38606. * Basically if your fingers moves away from more than this distance you will be considered
  38607. * in pinch mode.
  38608. */
  38609. pinchToPanMaxDistance: number;
  38610. /**
  38611. * Defines the maximum distance the camera can pan.
  38612. * This could help keeping the cammera always in your scene.
  38613. */
  38614. panningDistanceLimit: Nullable<number>;
  38615. /**
  38616. * Defines the target of the camera before paning.
  38617. */
  38618. panningOriginTarget: Vector3;
  38619. /**
  38620. * Defines the value of the inertia used during panning.
  38621. * 0 would mean stop inertia and one would mean no decelleration at all.
  38622. */
  38623. panningInertia: number;
  38624. /**
  38625. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38626. */
  38627. get angularSensibilityX(): number;
  38628. set angularSensibilityX(value: number);
  38629. /**
  38630. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38631. */
  38632. get angularSensibilityY(): number;
  38633. set angularSensibilityY(value: number);
  38634. /**
  38635. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38636. */
  38637. get pinchPrecision(): number;
  38638. set pinchPrecision(value: number);
  38639. /**
  38640. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38641. * It will be used instead of pinchDeltaPrecision if different from 0.
  38642. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38643. */
  38644. get pinchDeltaPercentage(): number;
  38645. set pinchDeltaPercentage(value: number);
  38646. /**
  38647. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38648. * and pinch delta percentage.
  38649. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38650. * that any object in the plane at the camera's target point will scale
  38651. * perfectly with finger motion.
  38652. */
  38653. get useNaturalPinchZoom(): boolean;
  38654. set useNaturalPinchZoom(value: boolean);
  38655. /**
  38656. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38657. */
  38658. get panningSensibility(): number;
  38659. set panningSensibility(value: number);
  38660. /**
  38661. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38662. */
  38663. get keysUp(): number[];
  38664. set keysUp(value: number[]);
  38665. /**
  38666. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38667. */
  38668. get keysDown(): number[];
  38669. set keysDown(value: number[]);
  38670. /**
  38671. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38672. */
  38673. get keysLeft(): number[];
  38674. set keysLeft(value: number[]);
  38675. /**
  38676. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38677. */
  38678. get keysRight(): number[];
  38679. set keysRight(value: number[]);
  38680. /**
  38681. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38682. */
  38683. get wheelPrecision(): number;
  38684. set wheelPrecision(value: number);
  38685. /**
  38686. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38687. * It will be used instead of pinchDeltaPrecision if different from 0.
  38688. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38689. */
  38690. get wheelDeltaPercentage(): number;
  38691. set wheelDeltaPercentage(value: number);
  38692. /**
  38693. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38694. */
  38695. zoomOnFactor: number;
  38696. /**
  38697. * Defines a screen offset for the camera position.
  38698. */
  38699. targetScreenOffset: Vector2;
  38700. /**
  38701. * Allows the camera to be completely reversed.
  38702. * If false the camera can not arrive upside down.
  38703. */
  38704. allowUpsideDown: boolean;
  38705. /**
  38706. * Define if double tap/click is used to restore the previously saved state of the camera.
  38707. */
  38708. useInputToRestoreState: boolean;
  38709. /** @hidden */
  38710. _viewMatrix: Matrix;
  38711. /** @hidden */
  38712. _useCtrlForPanning: boolean;
  38713. /** @hidden */
  38714. _panningMouseButton: number;
  38715. /**
  38716. * Defines the input associated to the camera.
  38717. */
  38718. inputs: ArcRotateCameraInputsManager;
  38719. /** @hidden */
  38720. _reset: () => void;
  38721. /**
  38722. * Defines the allowed panning axis.
  38723. */
  38724. panningAxis: Vector3;
  38725. protected _localDirection: Vector3;
  38726. protected _transformedDirection: Vector3;
  38727. private _bouncingBehavior;
  38728. /**
  38729. * Gets the bouncing behavior of the camera if it has been enabled.
  38730. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38731. */
  38732. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38733. /**
  38734. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38735. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38736. */
  38737. get useBouncingBehavior(): boolean;
  38738. set useBouncingBehavior(value: boolean);
  38739. private _framingBehavior;
  38740. /**
  38741. * Gets the framing behavior of the camera if it has been enabled.
  38742. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38743. */
  38744. get framingBehavior(): Nullable<FramingBehavior>;
  38745. /**
  38746. * Defines if the framing behavior of the camera is enabled on the camera.
  38747. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38748. */
  38749. get useFramingBehavior(): boolean;
  38750. set useFramingBehavior(value: boolean);
  38751. private _autoRotationBehavior;
  38752. /**
  38753. * Gets the auto rotation behavior of the camera if it has been enabled.
  38754. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38755. */
  38756. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38757. /**
  38758. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38759. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38760. */
  38761. get useAutoRotationBehavior(): boolean;
  38762. set useAutoRotationBehavior(value: boolean);
  38763. /**
  38764. * Observable triggered when the mesh target has been changed on the camera.
  38765. */
  38766. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38767. /**
  38768. * Event raised when the camera is colliding with a mesh.
  38769. */
  38770. onCollide: (collidedMesh: AbstractMesh) => void;
  38771. /**
  38772. * Defines whether the camera should check collision with the objects oh the scene.
  38773. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38774. */
  38775. checkCollisions: boolean;
  38776. /**
  38777. * Defines the collision radius of the camera.
  38778. * This simulates a sphere around the camera.
  38779. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38780. */
  38781. collisionRadius: Vector3;
  38782. protected _collider: Collider;
  38783. protected _previousPosition: Vector3;
  38784. protected _collisionVelocity: Vector3;
  38785. protected _newPosition: Vector3;
  38786. protected _previousAlpha: number;
  38787. protected _previousBeta: number;
  38788. protected _previousRadius: number;
  38789. protected _collisionTriggered: boolean;
  38790. protected _targetBoundingCenter: Nullable<Vector3>;
  38791. private _computationVector;
  38792. /**
  38793. * Instantiates a new ArcRotateCamera in a given scene
  38794. * @param name Defines the name of the camera
  38795. * @param alpha Defines the camera rotation along the logitudinal axis
  38796. * @param beta Defines the camera rotation along the latitudinal axis
  38797. * @param radius Defines the camera distance from its target
  38798. * @param target Defines the camera target
  38799. * @param scene Defines the scene the camera belongs to
  38800. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38801. */
  38802. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38803. /** @hidden */
  38804. _initCache(): void;
  38805. /** @hidden */
  38806. _updateCache(ignoreParentClass?: boolean): void;
  38807. protected _getTargetPosition(): Vector3;
  38808. private _storedAlpha;
  38809. private _storedBeta;
  38810. private _storedRadius;
  38811. private _storedTarget;
  38812. private _storedTargetScreenOffset;
  38813. /**
  38814. * Stores the current state of the camera (alpha, beta, radius and target)
  38815. * @returns the camera itself
  38816. */
  38817. storeState(): Camera;
  38818. /**
  38819. * @hidden
  38820. * Restored camera state. You must call storeState() first
  38821. */
  38822. _restoreStateValues(): boolean;
  38823. /** @hidden */
  38824. _isSynchronizedViewMatrix(): boolean;
  38825. /**
  38826. * Attached controls to the current camera.
  38827. * @param element Defines the element the controls should be listened from
  38828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38829. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38830. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38831. */
  38832. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38833. /**
  38834. * Detach the current controls from the camera.
  38835. * The camera will stop reacting to inputs.
  38836. * @param element Defines the element to stop listening the inputs from
  38837. */
  38838. detachControl(element: HTMLElement): void;
  38839. /** @hidden */
  38840. _checkInputs(): void;
  38841. protected _checkLimits(): void;
  38842. /**
  38843. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38844. */
  38845. rebuildAnglesAndRadius(): void;
  38846. /**
  38847. * Use a position to define the current camera related information like alpha, beta and radius
  38848. * @param position Defines the position to set the camera at
  38849. */
  38850. setPosition(position: Vector3): void;
  38851. /**
  38852. * Defines the target the camera should look at.
  38853. * This will automatically adapt alpha beta and radius to fit within the new target.
  38854. * @param target Defines the new target as a Vector or a mesh
  38855. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38856. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38857. */
  38858. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38859. /** @hidden */
  38860. _getViewMatrix(): Matrix;
  38861. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38862. /**
  38863. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38864. * @param meshes Defines the mesh to zoom on
  38865. * @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)
  38866. */
  38867. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38868. /**
  38869. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38870. * The target will be changed but the radius
  38871. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38872. * @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)
  38873. */
  38874. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38875. min: Vector3;
  38876. max: Vector3;
  38877. distance: number;
  38878. }, doNotUpdateMaxZ?: boolean): void;
  38879. /**
  38880. * @override
  38881. * Override Camera.createRigCamera
  38882. */
  38883. createRigCamera(name: string, cameraIndex: number): Camera;
  38884. /**
  38885. * @hidden
  38886. * @override
  38887. * Override Camera._updateRigCameras
  38888. */
  38889. _updateRigCameras(): void;
  38890. /**
  38891. * Destroy the camera and release the current resources hold by it.
  38892. */
  38893. dispose(): void;
  38894. /**
  38895. * Gets the current object class name.
  38896. * @return the class name
  38897. */
  38898. getClassName(): string;
  38899. }
  38900. }
  38901. declare module BABYLON {
  38902. /**
  38903. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38904. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38905. */
  38906. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38907. /**
  38908. * Gets the name of the behavior.
  38909. */
  38910. get name(): string;
  38911. private _zoomStopsAnimation;
  38912. private _idleRotationSpeed;
  38913. private _idleRotationWaitTime;
  38914. private _idleRotationSpinupTime;
  38915. /**
  38916. * Sets the flag that indicates if user zooming should stop animation.
  38917. */
  38918. set zoomStopsAnimation(flag: boolean);
  38919. /**
  38920. * Gets the flag that indicates if user zooming should stop animation.
  38921. */
  38922. get zoomStopsAnimation(): boolean;
  38923. /**
  38924. * Sets the default speed at which the camera rotates around the model.
  38925. */
  38926. set idleRotationSpeed(speed: number);
  38927. /**
  38928. * Gets the default speed at which the camera rotates around the model.
  38929. */
  38930. get idleRotationSpeed(): number;
  38931. /**
  38932. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38933. */
  38934. set idleRotationWaitTime(time: number);
  38935. /**
  38936. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38937. */
  38938. get idleRotationWaitTime(): number;
  38939. /**
  38940. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38941. */
  38942. set idleRotationSpinupTime(time: number);
  38943. /**
  38944. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38945. */
  38946. get idleRotationSpinupTime(): number;
  38947. /**
  38948. * Gets a value indicating if the camera is currently rotating because of this behavior
  38949. */
  38950. get rotationInProgress(): boolean;
  38951. private _onPrePointerObservableObserver;
  38952. private _onAfterCheckInputsObserver;
  38953. private _attachedCamera;
  38954. private _isPointerDown;
  38955. private _lastFrameTime;
  38956. private _lastInteractionTime;
  38957. private _cameraRotationSpeed;
  38958. /**
  38959. * Initializes the behavior.
  38960. */
  38961. init(): void;
  38962. /**
  38963. * Attaches the behavior to its arc rotate camera.
  38964. * @param camera Defines the camera to attach the behavior to
  38965. */
  38966. attach(camera: ArcRotateCamera): void;
  38967. /**
  38968. * Detaches the behavior from its current arc rotate camera.
  38969. */
  38970. detach(): void;
  38971. /**
  38972. * Returns true if user is scrolling.
  38973. * @return true if user is scrolling.
  38974. */
  38975. private _userIsZooming;
  38976. private _lastFrameRadius;
  38977. private _shouldAnimationStopForInteraction;
  38978. /**
  38979. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38980. */
  38981. private _applyUserInteraction;
  38982. private _userIsMoving;
  38983. }
  38984. }
  38985. declare module BABYLON {
  38986. /**
  38987. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38988. */
  38989. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38990. private ui;
  38991. /**
  38992. * The name of the behavior
  38993. */
  38994. name: string;
  38995. /**
  38996. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38997. */
  38998. distanceAwayFromFace: number;
  38999. /**
  39000. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39001. */
  39002. distanceAwayFromBottomOfFace: number;
  39003. private _faceVectors;
  39004. private _target;
  39005. private _scene;
  39006. private _onRenderObserver;
  39007. private _tmpMatrix;
  39008. private _tmpVector;
  39009. /**
  39010. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39011. * @param ui The transform node that should be attched to the mesh
  39012. */
  39013. constructor(ui: TransformNode);
  39014. /**
  39015. * Initializes the behavior
  39016. */
  39017. init(): void;
  39018. private _closestFace;
  39019. private _zeroVector;
  39020. private _lookAtTmpMatrix;
  39021. private _lookAtToRef;
  39022. /**
  39023. * Attaches the AttachToBoxBehavior to the passed in mesh
  39024. * @param target The mesh that the specified node will be attached to
  39025. */
  39026. attach(target: Mesh): void;
  39027. /**
  39028. * Detaches the behavior from the mesh
  39029. */
  39030. detach(): void;
  39031. }
  39032. }
  39033. declare module BABYLON {
  39034. /**
  39035. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39036. */
  39037. export class FadeInOutBehavior implements Behavior<Mesh> {
  39038. /**
  39039. * Time in milliseconds to delay before fading in (Default: 0)
  39040. */
  39041. delay: number;
  39042. /**
  39043. * Time in milliseconds for the mesh to fade in (Default: 300)
  39044. */
  39045. fadeInTime: number;
  39046. private _millisecondsPerFrame;
  39047. private _hovered;
  39048. private _hoverValue;
  39049. private _ownerNode;
  39050. /**
  39051. * Instatiates the FadeInOutBehavior
  39052. */
  39053. constructor();
  39054. /**
  39055. * The name of the behavior
  39056. */
  39057. get name(): string;
  39058. /**
  39059. * Initializes the behavior
  39060. */
  39061. init(): void;
  39062. /**
  39063. * Attaches the fade behavior on the passed in mesh
  39064. * @param ownerNode The mesh that will be faded in/out once attached
  39065. */
  39066. attach(ownerNode: Mesh): void;
  39067. /**
  39068. * Detaches the behavior from the mesh
  39069. */
  39070. detach(): void;
  39071. /**
  39072. * Triggers the mesh to begin fading in or out
  39073. * @param value if the object should fade in or out (true to fade in)
  39074. */
  39075. fadeIn(value: boolean): void;
  39076. private _update;
  39077. private _setAllVisibility;
  39078. }
  39079. }
  39080. declare module BABYLON {
  39081. /**
  39082. * Class containing a set of static utilities functions for managing Pivots
  39083. * @hidden
  39084. */
  39085. export class PivotTools {
  39086. private static _PivotCached;
  39087. private static _OldPivotPoint;
  39088. private static _PivotTranslation;
  39089. private static _PivotTmpVector;
  39090. /** @hidden */
  39091. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39092. /** @hidden */
  39093. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39094. }
  39095. }
  39096. declare module BABYLON {
  39097. /**
  39098. * Class containing static functions to help procedurally build meshes
  39099. */
  39100. export class PlaneBuilder {
  39101. /**
  39102. * Creates a plane mesh
  39103. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39104. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39105. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39107. * * 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
  39108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39109. * @param name defines the name of the mesh
  39110. * @param options defines the options used to create the mesh
  39111. * @param scene defines the hosting scene
  39112. * @returns the plane mesh
  39113. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39114. */
  39115. static CreatePlane(name: string, options: {
  39116. size?: number;
  39117. width?: number;
  39118. height?: number;
  39119. sideOrientation?: number;
  39120. frontUVs?: Vector4;
  39121. backUVs?: Vector4;
  39122. updatable?: boolean;
  39123. sourcePlane?: Plane;
  39124. }, scene?: Nullable<Scene>): Mesh;
  39125. }
  39126. }
  39127. declare module BABYLON {
  39128. /**
  39129. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39130. */
  39131. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39132. private static _AnyMouseID;
  39133. /**
  39134. * Abstract mesh the behavior is set on
  39135. */
  39136. attachedNode: AbstractMesh;
  39137. private _dragPlane;
  39138. private _scene;
  39139. private _pointerObserver;
  39140. private _beforeRenderObserver;
  39141. private static _planeScene;
  39142. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39143. /**
  39144. * 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)
  39145. */
  39146. maxDragAngle: number;
  39147. /**
  39148. * @hidden
  39149. */
  39150. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39151. /**
  39152. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39153. */
  39154. currentDraggingPointerID: number;
  39155. /**
  39156. * The last position where the pointer hit the drag plane in world space
  39157. */
  39158. lastDragPosition: Vector3;
  39159. /**
  39160. * If the behavior is currently in a dragging state
  39161. */
  39162. dragging: boolean;
  39163. /**
  39164. * 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)
  39165. */
  39166. dragDeltaRatio: number;
  39167. /**
  39168. * If the drag plane orientation should be updated during the dragging (Default: true)
  39169. */
  39170. updateDragPlane: boolean;
  39171. private _debugMode;
  39172. private _moving;
  39173. /**
  39174. * Fires each time the attached mesh is dragged with the pointer
  39175. * * delta between last drag position and current drag position in world space
  39176. * * dragDistance along the drag axis
  39177. * * dragPlaneNormal normal of the current drag plane used during the drag
  39178. * * dragPlanePoint in world space where the drag intersects the drag plane
  39179. */
  39180. onDragObservable: Observable<{
  39181. delta: Vector3;
  39182. dragPlanePoint: Vector3;
  39183. dragPlaneNormal: Vector3;
  39184. dragDistance: number;
  39185. pointerId: number;
  39186. }>;
  39187. /**
  39188. * Fires each time a drag begins (eg. mouse down on mesh)
  39189. */
  39190. onDragStartObservable: Observable<{
  39191. dragPlanePoint: Vector3;
  39192. pointerId: number;
  39193. }>;
  39194. /**
  39195. * Fires each time a drag ends (eg. mouse release after drag)
  39196. */
  39197. onDragEndObservable: Observable<{
  39198. dragPlanePoint: Vector3;
  39199. pointerId: number;
  39200. }>;
  39201. /**
  39202. * If the attached mesh should be moved when dragged
  39203. */
  39204. moveAttached: boolean;
  39205. /**
  39206. * If the drag behavior will react to drag events (Default: true)
  39207. */
  39208. enabled: boolean;
  39209. /**
  39210. * If pointer events should start and release the drag (Default: true)
  39211. */
  39212. startAndReleaseDragOnPointerEvents: boolean;
  39213. /**
  39214. * If camera controls should be detached during the drag
  39215. */
  39216. detachCameraControls: boolean;
  39217. /**
  39218. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39219. */
  39220. useObjectOrientationForDragging: boolean;
  39221. private _options;
  39222. /**
  39223. * Gets the options used by the behavior
  39224. */
  39225. get options(): {
  39226. dragAxis?: Vector3;
  39227. dragPlaneNormal?: Vector3;
  39228. };
  39229. /**
  39230. * Sets the options used by the behavior
  39231. */
  39232. set options(options: {
  39233. dragAxis?: Vector3;
  39234. dragPlaneNormal?: Vector3;
  39235. });
  39236. /**
  39237. * Creates a pointer drag behavior that can be attached to a mesh
  39238. * @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)
  39239. */
  39240. constructor(options?: {
  39241. dragAxis?: Vector3;
  39242. dragPlaneNormal?: Vector3;
  39243. });
  39244. /**
  39245. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39246. */
  39247. validateDrag: (targetPosition: Vector3) => boolean;
  39248. /**
  39249. * The name of the behavior
  39250. */
  39251. get name(): string;
  39252. /**
  39253. * Initializes the behavior
  39254. */
  39255. init(): void;
  39256. private _tmpVector;
  39257. private _alternatePickedPoint;
  39258. private _worldDragAxis;
  39259. private _targetPosition;
  39260. private _attachedElement;
  39261. /**
  39262. * Attaches the drag behavior the passed in mesh
  39263. * @param ownerNode The mesh that will be dragged around once attached
  39264. * @param predicate Predicate to use for pick filtering
  39265. */
  39266. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39267. /**
  39268. * Force relase the drag action by code.
  39269. */
  39270. releaseDrag(): void;
  39271. private _startDragRay;
  39272. private _lastPointerRay;
  39273. /**
  39274. * Simulates the start of a pointer drag event on the behavior
  39275. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39276. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39277. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39278. */
  39279. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39280. private _startDrag;
  39281. private _dragDelta;
  39282. private _moveDrag;
  39283. private _pickWithRayOnDragPlane;
  39284. private _pointA;
  39285. private _pointB;
  39286. private _pointC;
  39287. private _lineA;
  39288. private _lineB;
  39289. private _localAxis;
  39290. private _lookAt;
  39291. private _updateDragPlanePosition;
  39292. /**
  39293. * Detaches the behavior from the mesh
  39294. */
  39295. detach(): void;
  39296. }
  39297. }
  39298. declare module BABYLON {
  39299. /**
  39300. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39301. */
  39302. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39303. private _dragBehaviorA;
  39304. private _dragBehaviorB;
  39305. private _startDistance;
  39306. private _initialScale;
  39307. private _targetScale;
  39308. private _ownerNode;
  39309. private _sceneRenderObserver;
  39310. /**
  39311. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39312. */
  39313. constructor();
  39314. /**
  39315. * The name of the behavior
  39316. */
  39317. get name(): string;
  39318. /**
  39319. * Initializes the behavior
  39320. */
  39321. init(): void;
  39322. private _getCurrentDistance;
  39323. /**
  39324. * Attaches the scale behavior the passed in mesh
  39325. * @param ownerNode The mesh that will be scaled around once attached
  39326. */
  39327. attach(ownerNode: Mesh): void;
  39328. /**
  39329. * Detaches the behavior from the mesh
  39330. */
  39331. detach(): void;
  39332. }
  39333. }
  39334. declare module BABYLON {
  39335. /**
  39336. * 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
  39337. */
  39338. export class SixDofDragBehavior implements Behavior<Mesh> {
  39339. private static _virtualScene;
  39340. private _ownerNode;
  39341. private _sceneRenderObserver;
  39342. private _scene;
  39343. private _targetPosition;
  39344. private _virtualOriginMesh;
  39345. private _virtualDragMesh;
  39346. private _pointerObserver;
  39347. private _moving;
  39348. private _startingOrientation;
  39349. /**
  39350. * 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)
  39351. */
  39352. private zDragFactor;
  39353. /**
  39354. * If the object should rotate to face the drag origin
  39355. */
  39356. rotateDraggedObject: boolean;
  39357. /**
  39358. * If the behavior is currently in a dragging state
  39359. */
  39360. dragging: boolean;
  39361. /**
  39362. * 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)
  39363. */
  39364. dragDeltaRatio: number;
  39365. /**
  39366. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39367. */
  39368. currentDraggingPointerID: number;
  39369. /**
  39370. * If camera controls should be detached during the drag
  39371. */
  39372. detachCameraControls: boolean;
  39373. /**
  39374. * Fires each time a drag starts
  39375. */
  39376. onDragStartObservable: Observable<{}>;
  39377. /**
  39378. * Fires each time a drag ends (eg. mouse release after drag)
  39379. */
  39380. onDragEndObservable: Observable<{}>;
  39381. /**
  39382. * 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
  39383. */
  39384. constructor();
  39385. /**
  39386. * The name of the behavior
  39387. */
  39388. get name(): string;
  39389. /**
  39390. * Initializes the behavior
  39391. */
  39392. init(): void;
  39393. /**
  39394. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39395. */
  39396. private get _pointerCamera();
  39397. /**
  39398. * Attaches the scale behavior the passed in mesh
  39399. * @param ownerNode The mesh that will be scaled around once attached
  39400. */
  39401. attach(ownerNode: Mesh): void;
  39402. /**
  39403. * Detaches the behavior from the mesh
  39404. */
  39405. detach(): void;
  39406. }
  39407. }
  39408. declare module BABYLON {
  39409. /**
  39410. * Class used to apply inverse kinematics to bones
  39411. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39412. */
  39413. export class BoneIKController {
  39414. private static _tmpVecs;
  39415. private static _tmpQuat;
  39416. private static _tmpMats;
  39417. /**
  39418. * Gets or sets the target mesh
  39419. */
  39420. targetMesh: AbstractMesh;
  39421. /** Gets or sets the mesh used as pole */
  39422. poleTargetMesh: AbstractMesh;
  39423. /**
  39424. * Gets or sets the bone used as pole
  39425. */
  39426. poleTargetBone: Nullable<Bone>;
  39427. /**
  39428. * Gets or sets the target position
  39429. */
  39430. targetPosition: Vector3;
  39431. /**
  39432. * Gets or sets the pole target position
  39433. */
  39434. poleTargetPosition: Vector3;
  39435. /**
  39436. * Gets or sets the pole target local offset
  39437. */
  39438. poleTargetLocalOffset: Vector3;
  39439. /**
  39440. * Gets or sets the pole angle
  39441. */
  39442. poleAngle: number;
  39443. /**
  39444. * Gets or sets the mesh associated with the controller
  39445. */
  39446. mesh: AbstractMesh;
  39447. /**
  39448. * 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)
  39449. */
  39450. slerpAmount: number;
  39451. private _bone1Quat;
  39452. private _bone1Mat;
  39453. private _bone2Ang;
  39454. private _bone1;
  39455. private _bone2;
  39456. private _bone1Length;
  39457. private _bone2Length;
  39458. private _maxAngle;
  39459. private _maxReach;
  39460. private _rightHandedSystem;
  39461. private _bendAxis;
  39462. private _slerping;
  39463. private _adjustRoll;
  39464. /**
  39465. * Gets or sets maximum allowed angle
  39466. */
  39467. get maxAngle(): number;
  39468. set maxAngle(value: number);
  39469. /**
  39470. * Creates a new BoneIKController
  39471. * @param mesh defines the mesh to control
  39472. * @param bone defines the bone to control
  39473. * @param options defines options to set up the controller
  39474. */
  39475. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39476. targetMesh?: AbstractMesh;
  39477. poleTargetMesh?: AbstractMesh;
  39478. poleTargetBone?: Bone;
  39479. poleTargetLocalOffset?: Vector3;
  39480. poleAngle?: number;
  39481. bendAxis?: Vector3;
  39482. maxAngle?: number;
  39483. slerpAmount?: number;
  39484. });
  39485. private _setMaxAngle;
  39486. /**
  39487. * Force the controller to update the bones
  39488. */
  39489. update(): void;
  39490. }
  39491. }
  39492. declare module BABYLON {
  39493. /**
  39494. * Class used to make a bone look toward a point in space
  39495. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39496. */
  39497. export class BoneLookController {
  39498. private static _tmpVecs;
  39499. private static _tmpQuat;
  39500. private static _tmpMats;
  39501. /**
  39502. * The target Vector3 that the bone will look at
  39503. */
  39504. target: Vector3;
  39505. /**
  39506. * The mesh that the bone is attached to
  39507. */
  39508. mesh: AbstractMesh;
  39509. /**
  39510. * The bone that will be looking to the target
  39511. */
  39512. bone: Bone;
  39513. /**
  39514. * The up axis of the coordinate system that is used when the bone is rotated
  39515. */
  39516. upAxis: Vector3;
  39517. /**
  39518. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39519. */
  39520. upAxisSpace: Space;
  39521. /**
  39522. * Used to make an adjustment to the yaw of the bone
  39523. */
  39524. adjustYaw: number;
  39525. /**
  39526. * Used to make an adjustment to the pitch of the bone
  39527. */
  39528. adjustPitch: number;
  39529. /**
  39530. * Used to make an adjustment to the roll of the bone
  39531. */
  39532. adjustRoll: number;
  39533. /**
  39534. * 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)
  39535. */
  39536. slerpAmount: number;
  39537. private _minYaw;
  39538. private _maxYaw;
  39539. private _minPitch;
  39540. private _maxPitch;
  39541. private _minYawSin;
  39542. private _minYawCos;
  39543. private _maxYawSin;
  39544. private _maxYawCos;
  39545. private _midYawConstraint;
  39546. private _minPitchTan;
  39547. private _maxPitchTan;
  39548. private _boneQuat;
  39549. private _slerping;
  39550. private _transformYawPitch;
  39551. private _transformYawPitchInv;
  39552. private _firstFrameSkipped;
  39553. private _yawRange;
  39554. private _fowardAxis;
  39555. /**
  39556. * Gets or sets the minimum yaw angle that the bone can look to
  39557. */
  39558. get minYaw(): number;
  39559. set minYaw(value: number);
  39560. /**
  39561. * Gets or sets the maximum yaw angle that the bone can look to
  39562. */
  39563. get maxYaw(): number;
  39564. set maxYaw(value: number);
  39565. /**
  39566. * Gets or sets the minimum pitch angle that the bone can look to
  39567. */
  39568. get minPitch(): number;
  39569. set minPitch(value: number);
  39570. /**
  39571. * Gets or sets the maximum pitch angle that the bone can look to
  39572. */
  39573. get maxPitch(): number;
  39574. set maxPitch(value: number);
  39575. /**
  39576. * Create a BoneLookController
  39577. * @param mesh the mesh that the bone belongs to
  39578. * @param bone the bone that will be looking to the target
  39579. * @param target the target Vector3 to look at
  39580. * @param options optional settings:
  39581. * * maxYaw: the maximum angle the bone will yaw to
  39582. * * minYaw: the minimum angle the bone will yaw to
  39583. * * maxPitch: the maximum angle the bone will pitch to
  39584. * * minPitch: the minimum angle the bone will yaw to
  39585. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39586. * * upAxis: the up axis of the coordinate system
  39587. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39588. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39589. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39590. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39591. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39592. * * adjustRoll: used to make an adjustment to the roll of the bone
  39593. **/
  39594. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39595. maxYaw?: number;
  39596. minYaw?: number;
  39597. maxPitch?: number;
  39598. minPitch?: number;
  39599. slerpAmount?: number;
  39600. upAxis?: Vector3;
  39601. upAxisSpace?: Space;
  39602. yawAxis?: Vector3;
  39603. pitchAxis?: Vector3;
  39604. adjustYaw?: number;
  39605. adjustPitch?: number;
  39606. adjustRoll?: number;
  39607. });
  39608. /**
  39609. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39610. */
  39611. update(): void;
  39612. private _getAngleDiff;
  39613. private _getAngleBetween;
  39614. private _isAngleBetween;
  39615. }
  39616. }
  39617. declare module BABYLON {
  39618. /**
  39619. * Manage the gamepad inputs to control an arc rotate camera.
  39620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39621. */
  39622. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39623. /**
  39624. * Defines the camera the input is attached to.
  39625. */
  39626. camera: ArcRotateCamera;
  39627. /**
  39628. * Defines the gamepad the input is gathering event from.
  39629. */
  39630. gamepad: Nullable<Gamepad>;
  39631. /**
  39632. * Defines the gamepad rotation sensiblity.
  39633. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39634. */
  39635. gamepadRotationSensibility: number;
  39636. /**
  39637. * Defines the gamepad move sensiblity.
  39638. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39639. */
  39640. gamepadMoveSensibility: number;
  39641. private _yAxisScale;
  39642. /**
  39643. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39644. */
  39645. get invertYAxis(): boolean;
  39646. set invertYAxis(value: boolean);
  39647. private _onGamepadConnectedObserver;
  39648. private _onGamepadDisconnectedObserver;
  39649. /**
  39650. * Attach the input controls to a specific dom element to get the input from.
  39651. * @param element Defines the element the controls should be listened from
  39652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39653. */
  39654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39655. /**
  39656. * Detach the current controls from the specified dom element.
  39657. * @param element Defines the element to stop listening the inputs from
  39658. */
  39659. detachControl(element: Nullable<HTMLElement>): void;
  39660. /**
  39661. * Update the current camera state depending on the inputs that have been used this frame.
  39662. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39663. */
  39664. checkInputs(): void;
  39665. /**
  39666. * Gets the class name of the current intput.
  39667. * @returns the class name
  39668. */
  39669. getClassName(): string;
  39670. /**
  39671. * Get the friendly name associated with the input class.
  39672. * @returns the input friendly name
  39673. */
  39674. getSimpleName(): string;
  39675. }
  39676. }
  39677. declare module BABYLON {
  39678. interface ArcRotateCameraInputsManager {
  39679. /**
  39680. * Add orientation input support to the input manager.
  39681. * @returns the current input manager
  39682. */
  39683. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39684. }
  39685. /**
  39686. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39688. */
  39689. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39690. /**
  39691. * Defines the camera the input is attached to.
  39692. */
  39693. camera: ArcRotateCamera;
  39694. /**
  39695. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39696. */
  39697. alphaCorrection: number;
  39698. /**
  39699. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39700. */
  39701. gammaCorrection: number;
  39702. private _alpha;
  39703. private _gamma;
  39704. private _dirty;
  39705. private _deviceOrientationHandler;
  39706. /**
  39707. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39708. */
  39709. constructor();
  39710. /**
  39711. * Attach the input controls to a specific dom element to get the input from.
  39712. * @param element Defines the element the controls should be listened from
  39713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39714. */
  39715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39716. /** @hidden */
  39717. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39718. /**
  39719. * Update the current camera state depending on the inputs that have been used this frame.
  39720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39721. */
  39722. checkInputs(): void;
  39723. /**
  39724. * Detach the current controls from the specified dom element.
  39725. * @param element Defines the element to stop listening the inputs from
  39726. */
  39727. detachControl(element: Nullable<HTMLElement>): void;
  39728. /**
  39729. * Gets the class name of the current intput.
  39730. * @returns the class name
  39731. */
  39732. getClassName(): string;
  39733. /**
  39734. * Get the friendly name associated with the input class.
  39735. * @returns the input friendly name
  39736. */
  39737. getSimpleName(): string;
  39738. }
  39739. }
  39740. declare module BABYLON {
  39741. /**
  39742. * Listen to mouse events to control the camera.
  39743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39744. */
  39745. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39746. /**
  39747. * Defines the camera the input is attached to.
  39748. */
  39749. camera: FlyCamera;
  39750. /**
  39751. * Defines if touch is enabled. (Default is true.)
  39752. */
  39753. touchEnabled: boolean;
  39754. /**
  39755. * Defines the buttons associated with the input to handle camera rotation.
  39756. */
  39757. buttons: number[];
  39758. /**
  39759. * Assign buttons for Yaw control.
  39760. */
  39761. buttonsYaw: number[];
  39762. /**
  39763. * Assign buttons for Pitch control.
  39764. */
  39765. buttonsPitch: number[];
  39766. /**
  39767. * Assign buttons for Roll control.
  39768. */
  39769. buttonsRoll: number[];
  39770. /**
  39771. * Detect if any button is being pressed while mouse is moved.
  39772. * -1 = Mouse locked.
  39773. * 0 = Left button.
  39774. * 1 = Middle Button.
  39775. * 2 = Right Button.
  39776. */
  39777. activeButton: number;
  39778. /**
  39779. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39780. * Higher values reduce its sensitivity.
  39781. */
  39782. angularSensibility: number;
  39783. private _mousemoveCallback;
  39784. private _observer;
  39785. private _rollObserver;
  39786. private previousPosition;
  39787. private noPreventDefault;
  39788. private element;
  39789. /**
  39790. * Listen to mouse events to control the camera.
  39791. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39793. */
  39794. constructor(touchEnabled?: boolean);
  39795. /**
  39796. * Attach the mouse control to the HTML DOM element.
  39797. * @param element Defines the element that listens to the input events.
  39798. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39799. */
  39800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39801. /**
  39802. * Detach the current controls from the specified dom element.
  39803. * @param element Defines the element to stop listening the inputs from
  39804. */
  39805. detachControl(element: Nullable<HTMLElement>): void;
  39806. /**
  39807. * Gets the class name of the current input.
  39808. * @returns the class name.
  39809. */
  39810. getClassName(): string;
  39811. /**
  39812. * Get the friendly name associated with the input class.
  39813. * @returns the input's friendly name.
  39814. */
  39815. getSimpleName(): string;
  39816. private _pointerInput;
  39817. private _onMouseMove;
  39818. /**
  39819. * Rotate camera by mouse offset.
  39820. */
  39821. private rotateCamera;
  39822. }
  39823. }
  39824. declare module BABYLON {
  39825. /**
  39826. * Default Inputs manager for the FlyCamera.
  39827. * It groups all the default supported inputs for ease of use.
  39828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39829. */
  39830. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39831. /**
  39832. * Instantiates a new FlyCameraInputsManager.
  39833. * @param camera Defines the camera the inputs belong to.
  39834. */
  39835. constructor(camera: FlyCamera);
  39836. /**
  39837. * Add keyboard input support to the input manager.
  39838. * @returns the new FlyCameraKeyboardMoveInput().
  39839. */
  39840. addKeyboard(): FlyCameraInputsManager;
  39841. /**
  39842. * Add mouse input support to the input manager.
  39843. * @param touchEnabled Enable touch screen support.
  39844. * @returns the new FlyCameraMouseInput().
  39845. */
  39846. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39847. }
  39848. }
  39849. declare module BABYLON {
  39850. /**
  39851. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39852. * such as in a 3D Space Shooter or a Flight Simulator.
  39853. */
  39854. export class FlyCamera extends TargetCamera {
  39855. /**
  39856. * Define the collision ellipsoid of the camera.
  39857. * This is helpful for simulating a camera body, like a player's body.
  39858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39859. */
  39860. ellipsoid: Vector3;
  39861. /**
  39862. * Define an offset for the position of the ellipsoid around the camera.
  39863. * This can be helpful if the camera is attached away from the player's body center,
  39864. * such as at its head.
  39865. */
  39866. ellipsoidOffset: Vector3;
  39867. /**
  39868. * Enable or disable collisions of the camera with the rest of the scene objects.
  39869. */
  39870. checkCollisions: boolean;
  39871. /**
  39872. * Enable or disable gravity on the camera.
  39873. */
  39874. applyGravity: boolean;
  39875. /**
  39876. * Define the current direction the camera is moving to.
  39877. */
  39878. cameraDirection: Vector3;
  39879. /**
  39880. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39881. * This overrides and empties cameraRotation.
  39882. */
  39883. rotationQuaternion: Quaternion;
  39884. /**
  39885. * Track Roll to maintain the wanted Rolling when looking around.
  39886. */
  39887. _trackRoll: number;
  39888. /**
  39889. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39890. */
  39891. rollCorrect: number;
  39892. /**
  39893. * Mimic a banked turn, Rolling the camera when Yawing.
  39894. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39895. */
  39896. bankedTurn: boolean;
  39897. /**
  39898. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39899. */
  39900. bankedTurnLimit: number;
  39901. /**
  39902. * Value of 0 disables the banked Roll.
  39903. * Value of 1 is equal to the Yaw angle in radians.
  39904. */
  39905. bankedTurnMultiplier: number;
  39906. /**
  39907. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39908. */
  39909. inputs: FlyCameraInputsManager;
  39910. /**
  39911. * Gets the input sensibility for mouse input.
  39912. * Higher values reduce sensitivity.
  39913. */
  39914. get angularSensibility(): number;
  39915. /**
  39916. * Sets the input sensibility for a mouse input.
  39917. * Higher values reduce sensitivity.
  39918. */
  39919. set angularSensibility(value: number);
  39920. /**
  39921. * Get the keys for camera movement forward.
  39922. */
  39923. get keysForward(): number[];
  39924. /**
  39925. * Set the keys for camera movement forward.
  39926. */
  39927. set keysForward(value: number[]);
  39928. /**
  39929. * Get the keys for camera movement backward.
  39930. */
  39931. get keysBackward(): number[];
  39932. set keysBackward(value: number[]);
  39933. /**
  39934. * Get the keys for camera movement up.
  39935. */
  39936. get keysUp(): number[];
  39937. /**
  39938. * Set the keys for camera movement up.
  39939. */
  39940. set keysUp(value: number[]);
  39941. /**
  39942. * Get the keys for camera movement down.
  39943. */
  39944. get keysDown(): number[];
  39945. /**
  39946. * Set the keys for camera movement down.
  39947. */
  39948. set keysDown(value: number[]);
  39949. /**
  39950. * Get the keys for camera movement left.
  39951. */
  39952. get keysLeft(): number[];
  39953. /**
  39954. * Set the keys for camera movement left.
  39955. */
  39956. set keysLeft(value: number[]);
  39957. /**
  39958. * Set the keys for camera movement right.
  39959. */
  39960. get keysRight(): number[];
  39961. /**
  39962. * Set the keys for camera movement right.
  39963. */
  39964. set keysRight(value: number[]);
  39965. /**
  39966. * Event raised when the camera collides with a mesh in the scene.
  39967. */
  39968. onCollide: (collidedMesh: AbstractMesh) => void;
  39969. private _collider;
  39970. private _needMoveForGravity;
  39971. private _oldPosition;
  39972. private _diffPosition;
  39973. private _newPosition;
  39974. /** @hidden */
  39975. _localDirection: Vector3;
  39976. /** @hidden */
  39977. _transformedDirection: Vector3;
  39978. /**
  39979. * Instantiates a FlyCamera.
  39980. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39981. * such as in a 3D Space Shooter or a Flight Simulator.
  39982. * @param name Define the name of the camera in the scene.
  39983. * @param position Define the starting position of the camera in the scene.
  39984. * @param scene Define the scene the camera belongs to.
  39985. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39986. */
  39987. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39988. /**
  39989. * Attach a control to the HTML DOM element.
  39990. * @param element Defines the element that listens to the input events.
  39991. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39992. */
  39993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39994. /**
  39995. * Detach a control from the HTML DOM element.
  39996. * The camera will stop reacting to that input.
  39997. * @param element Defines the element that listens to the input events.
  39998. */
  39999. detachControl(element: HTMLElement): void;
  40000. private _collisionMask;
  40001. /**
  40002. * Get the mask that the camera ignores in collision events.
  40003. */
  40004. get collisionMask(): number;
  40005. /**
  40006. * Set the mask that the camera ignores in collision events.
  40007. */
  40008. set collisionMask(mask: number);
  40009. /** @hidden */
  40010. _collideWithWorld(displacement: Vector3): void;
  40011. /** @hidden */
  40012. private _onCollisionPositionChange;
  40013. /** @hidden */
  40014. _checkInputs(): void;
  40015. /** @hidden */
  40016. _decideIfNeedsToMove(): boolean;
  40017. /** @hidden */
  40018. _updatePosition(): void;
  40019. /**
  40020. * Restore the Roll to its target value at the rate specified.
  40021. * @param rate - Higher means slower restoring.
  40022. * @hidden
  40023. */
  40024. restoreRoll(rate: number): void;
  40025. /**
  40026. * Destroy the camera and release the current resources held by it.
  40027. */
  40028. dispose(): void;
  40029. /**
  40030. * Get the current object class name.
  40031. * @returns the class name.
  40032. */
  40033. getClassName(): string;
  40034. }
  40035. }
  40036. declare module BABYLON {
  40037. /**
  40038. * Listen to keyboard events to control the camera.
  40039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40040. */
  40041. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40042. /**
  40043. * Defines the camera the input is attached to.
  40044. */
  40045. camera: FlyCamera;
  40046. /**
  40047. * The list of keyboard keys used to control the forward move of the camera.
  40048. */
  40049. keysForward: number[];
  40050. /**
  40051. * The list of keyboard keys used to control the backward move of the camera.
  40052. */
  40053. keysBackward: number[];
  40054. /**
  40055. * The list of keyboard keys used to control the forward move of the camera.
  40056. */
  40057. keysUp: number[];
  40058. /**
  40059. * The list of keyboard keys used to control the backward move of the camera.
  40060. */
  40061. keysDown: number[];
  40062. /**
  40063. * The list of keyboard keys used to control the right strafe move of the camera.
  40064. */
  40065. keysRight: number[];
  40066. /**
  40067. * The list of keyboard keys used to control the left strafe move of the camera.
  40068. */
  40069. keysLeft: number[];
  40070. private _keys;
  40071. private _onCanvasBlurObserver;
  40072. private _onKeyboardObserver;
  40073. private _engine;
  40074. private _scene;
  40075. /**
  40076. * Attach the input controls to a specific dom element to get the input from.
  40077. * @param element Defines the element the controls should be listened from
  40078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40079. */
  40080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40081. /**
  40082. * Detach the current controls from the specified dom element.
  40083. * @param element Defines the element to stop listening the inputs from
  40084. */
  40085. detachControl(element: Nullable<HTMLElement>): void;
  40086. /**
  40087. * Gets the class name of the current intput.
  40088. * @returns the class name
  40089. */
  40090. getClassName(): string;
  40091. /** @hidden */
  40092. _onLostFocus(e: FocusEvent): void;
  40093. /**
  40094. * Get the friendly name associated with the input class.
  40095. * @returns the input friendly name
  40096. */
  40097. getSimpleName(): string;
  40098. /**
  40099. * Update the current camera state depending on the inputs that have been used this frame.
  40100. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40101. */
  40102. checkInputs(): void;
  40103. }
  40104. }
  40105. declare module BABYLON {
  40106. /**
  40107. * Manage the mouse wheel inputs to control a follow camera.
  40108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40109. */
  40110. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40111. /**
  40112. * Defines the camera the input is attached to.
  40113. */
  40114. camera: FollowCamera;
  40115. /**
  40116. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40117. */
  40118. axisControlRadius: boolean;
  40119. /**
  40120. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40121. */
  40122. axisControlHeight: boolean;
  40123. /**
  40124. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40125. */
  40126. axisControlRotation: boolean;
  40127. /**
  40128. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40129. * relation to mouseWheel events.
  40130. */
  40131. wheelPrecision: number;
  40132. /**
  40133. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40134. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40135. */
  40136. wheelDeltaPercentage: number;
  40137. private _wheel;
  40138. private _observer;
  40139. /**
  40140. * Attach the input controls to a specific dom element to get the input from.
  40141. * @param element Defines the element the controls should be listened from
  40142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40143. */
  40144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40145. /**
  40146. * Detach the current controls from the specified dom element.
  40147. * @param element Defines the element to stop listening the inputs from
  40148. */
  40149. detachControl(element: Nullable<HTMLElement>): void;
  40150. /**
  40151. * Gets the class name of the current intput.
  40152. * @returns the class name
  40153. */
  40154. getClassName(): string;
  40155. /**
  40156. * Get the friendly name associated with the input class.
  40157. * @returns the input friendly name
  40158. */
  40159. getSimpleName(): string;
  40160. }
  40161. }
  40162. declare module BABYLON {
  40163. /**
  40164. * Manage the pointers inputs to control an follow camera.
  40165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40166. */
  40167. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40168. /**
  40169. * Defines the camera the input is attached to.
  40170. */
  40171. camera: FollowCamera;
  40172. /**
  40173. * Gets the class name of the current input.
  40174. * @returns the class name
  40175. */
  40176. getClassName(): string;
  40177. /**
  40178. * Defines the pointer angular sensibility along the X axis or how fast is
  40179. * the camera rotating.
  40180. * A negative number will reverse the axis direction.
  40181. */
  40182. angularSensibilityX: number;
  40183. /**
  40184. * Defines the pointer angular sensibility along the Y axis or how fast is
  40185. * the camera rotating.
  40186. * A negative number will reverse the axis direction.
  40187. */
  40188. angularSensibilityY: number;
  40189. /**
  40190. * Defines the pointer pinch precision or how fast is the camera zooming.
  40191. * A negative number will reverse the axis direction.
  40192. */
  40193. pinchPrecision: number;
  40194. /**
  40195. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40196. * from 0.
  40197. * It defines the percentage of current camera.radius to use as delta when
  40198. * pinch zoom is used.
  40199. */
  40200. pinchDeltaPercentage: number;
  40201. /**
  40202. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40203. */
  40204. axisXControlRadius: boolean;
  40205. /**
  40206. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40207. */
  40208. axisXControlHeight: boolean;
  40209. /**
  40210. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40211. */
  40212. axisXControlRotation: boolean;
  40213. /**
  40214. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40215. */
  40216. axisYControlRadius: boolean;
  40217. /**
  40218. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40219. */
  40220. axisYControlHeight: boolean;
  40221. /**
  40222. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40223. */
  40224. axisYControlRotation: boolean;
  40225. /**
  40226. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40227. */
  40228. axisPinchControlRadius: boolean;
  40229. /**
  40230. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40231. */
  40232. axisPinchControlHeight: boolean;
  40233. /**
  40234. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40235. */
  40236. axisPinchControlRotation: boolean;
  40237. /**
  40238. * Log error messages if basic misconfiguration has occurred.
  40239. */
  40240. warningEnable: boolean;
  40241. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40242. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40243. private _warningCounter;
  40244. private _warning;
  40245. }
  40246. }
  40247. declare module BABYLON {
  40248. /**
  40249. * Default Inputs manager for the FollowCamera.
  40250. * It groups all the default supported inputs for ease of use.
  40251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40252. */
  40253. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40254. /**
  40255. * Instantiates a new FollowCameraInputsManager.
  40256. * @param camera Defines the camera the inputs belong to
  40257. */
  40258. constructor(camera: FollowCamera);
  40259. /**
  40260. * Add keyboard input support to the input manager.
  40261. * @returns the current input manager
  40262. */
  40263. addKeyboard(): FollowCameraInputsManager;
  40264. /**
  40265. * Add mouse wheel input support to the input manager.
  40266. * @returns the current input manager
  40267. */
  40268. addMouseWheel(): FollowCameraInputsManager;
  40269. /**
  40270. * Add pointers input support to the input manager.
  40271. * @returns the current input manager
  40272. */
  40273. addPointers(): FollowCameraInputsManager;
  40274. /**
  40275. * Add orientation input support to the input manager.
  40276. * @returns the current input manager
  40277. */
  40278. addVRDeviceOrientation(): FollowCameraInputsManager;
  40279. }
  40280. }
  40281. declare module BABYLON {
  40282. /**
  40283. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40284. * an arc rotate version arcFollowCamera are available.
  40285. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40286. */
  40287. export class FollowCamera extends TargetCamera {
  40288. /**
  40289. * Distance the follow camera should follow an object at
  40290. */
  40291. radius: number;
  40292. /**
  40293. * Minimum allowed distance of the camera to the axis of rotation
  40294. * (The camera can not get closer).
  40295. * This can help limiting how the Camera is able to move in the scene.
  40296. */
  40297. lowerRadiusLimit: Nullable<number>;
  40298. /**
  40299. * Maximum allowed distance of the camera to the axis of rotation
  40300. * (The camera can not get further).
  40301. * This can help limiting how the Camera is able to move in the scene.
  40302. */
  40303. upperRadiusLimit: Nullable<number>;
  40304. /**
  40305. * Define a rotation offset between the camera and the object it follows
  40306. */
  40307. rotationOffset: number;
  40308. /**
  40309. * Minimum allowed angle to camera position relative to target object.
  40310. * This can help limiting how the Camera is able to move in the scene.
  40311. */
  40312. lowerRotationOffsetLimit: Nullable<number>;
  40313. /**
  40314. * Maximum allowed angle to camera position relative to target object.
  40315. * This can help limiting how the Camera is able to move in the scene.
  40316. */
  40317. upperRotationOffsetLimit: Nullable<number>;
  40318. /**
  40319. * Define a height offset between the camera and the object it follows.
  40320. * It can help following an object from the top (like a car chaing a plane)
  40321. */
  40322. heightOffset: number;
  40323. /**
  40324. * Minimum allowed height of camera position relative to target object.
  40325. * This can help limiting how the Camera is able to move in the scene.
  40326. */
  40327. lowerHeightOffsetLimit: Nullable<number>;
  40328. /**
  40329. * Maximum allowed height of camera position relative to target object.
  40330. * This can help limiting how the Camera is able to move in the scene.
  40331. */
  40332. upperHeightOffsetLimit: Nullable<number>;
  40333. /**
  40334. * Define how fast the camera can accelerate to follow it s target.
  40335. */
  40336. cameraAcceleration: number;
  40337. /**
  40338. * Define the speed limit of the camera following an object.
  40339. */
  40340. maxCameraSpeed: number;
  40341. /**
  40342. * Define the target of the camera.
  40343. */
  40344. lockedTarget: Nullable<AbstractMesh>;
  40345. /**
  40346. * Defines the input associated with the camera.
  40347. */
  40348. inputs: FollowCameraInputsManager;
  40349. /**
  40350. * Instantiates the follow camera.
  40351. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40352. * @param name Define the name of the camera in the scene
  40353. * @param position Define the position of the camera
  40354. * @param scene Define the scene the camera belong to
  40355. * @param lockedTarget Define the target of the camera
  40356. */
  40357. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40358. private _follow;
  40359. /**
  40360. * Attached controls to the current camera.
  40361. * @param element Defines the element the controls should be listened from
  40362. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40363. */
  40364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40365. /**
  40366. * Detach the current controls from the camera.
  40367. * The camera will stop reacting to inputs.
  40368. * @param element Defines the element to stop listening the inputs from
  40369. */
  40370. detachControl(element: HTMLElement): void;
  40371. /** @hidden */
  40372. _checkInputs(): void;
  40373. private _checkLimits;
  40374. /**
  40375. * Gets the camera class name.
  40376. * @returns the class name
  40377. */
  40378. getClassName(): string;
  40379. }
  40380. /**
  40381. * Arc Rotate version of the follow camera.
  40382. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40383. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40384. */
  40385. export class ArcFollowCamera extends TargetCamera {
  40386. /** The longitudinal angle of the camera */
  40387. alpha: number;
  40388. /** The latitudinal angle of the camera */
  40389. beta: number;
  40390. /** The radius of the camera from its target */
  40391. radius: number;
  40392. /** Define the camera target (the messh it should follow) */
  40393. target: Nullable<AbstractMesh>;
  40394. private _cartesianCoordinates;
  40395. /**
  40396. * Instantiates a new ArcFollowCamera
  40397. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40398. * @param name Define the name of the camera
  40399. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40400. * @param beta Define the rotation angle of the camera around the elevation axis
  40401. * @param radius Define the radius of the camera from its target point
  40402. * @param target Define the target of the camera
  40403. * @param scene Define the scene the camera belongs to
  40404. */
  40405. constructor(name: string,
  40406. /** The longitudinal angle of the camera */
  40407. alpha: number,
  40408. /** The latitudinal angle of the camera */
  40409. beta: number,
  40410. /** The radius of the camera from its target */
  40411. radius: number,
  40412. /** Define the camera target (the messh it should follow) */
  40413. target: Nullable<AbstractMesh>, scene: Scene);
  40414. private _follow;
  40415. /** @hidden */
  40416. _checkInputs(): void;
  40417. /**
  40418. * Returns the class name of the object.
  40419. * It is mostly used internally for serialization purposes.
  40420. */
  40421. getClassName(): string;
  40422. }
  40423. }
  40424. declare module BABYLON {
  40425. /**
  40426. * Manage the keyboard inputs to control the movement of a follow camera.
  40427. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40428. */
  40429. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40430. /**
  40431. * Defines the camera the input is attached to.
  40432. */
  40433. camera: FollowCamera;
  40434. /**
  40435. * Defines the list of key codes associated with the up action (increase heightOffset)
  40436. */
  40437. keysHeightOffsetIncr: number[];
  40438. /**
  40439. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40440. */
  40441. keysHeightOffsetDecr: number[];
  40442. /**
  40443. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40444. */
  40445. keysHeightOffsetModifierAlt: boolean;
  40446. /**
  40447. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40448. */
  40449. keysHeightOffsetModifierCtrl: boolean;
  40450. /**
  40451. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40452. */
  40453. keysHeightOffsetModifierShift: boolean;
  40454. /**
  40455. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40456. */
  40457. keysRotationOffsetIncr: number[];
  40458. /**
  40459. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40460. */
  40461. keysRotationOffsetDecr: number[];
  40462. /**
  40463. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40464. */
  40465. keysRotationOffsetModifierAlt: boolean;
  40466. /**
  40467. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40468. */
  40469. keysRotationOffsetModifierCtrl: boolean;
  40470. /**
  40471. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40472. */
  40473. keysRotationOffsetModifierShift: boolean;
  40474. /**
  40475. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40476. */
  40477. keysRadiusIncr: number[];
  40478. /**
  40479. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40480. */
  40481. keysRadiusDecr: number[];
  40482. /**
  40483. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40484. */
  40485. keysRadiusModifierAlt: boolean;
  40486. /**
  40487. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40488. */
  40489. keysRadiusModifierCtrl: boolean;
  40490. /**
  40491. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40492. */
  40493. keysRadiusModifierShift: boolean;
  40494. /**
  40495. * Defines the rate of change of heightOffset.
  40496. */
  40497. heightSensibility: number;
  40498. /**
  40499. * Defines the rate of change of rotationOffset.
  40500. */
  40501. rotationSensibility: number;
  40502. /**
  40503. * Defines the rate of change of radius.
  40504. */
  40505. radiusSensibility: number;
  40506. private _keys;
  40507. private _ctrlPressed;
  40508. private _altPressed;
  40509. private _shiftPressed;
  40510. private _onCanvasBlurObserver;
  40511. private _onKeyboardObserver;
  40512. private _engine;
  40513. private _scene;
  40514. /**
  40515. * Attach the input controls to a specific dom element to get the input from.
  40516. * @param element Defines the element the controls should be listened from
  40517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40518. */
  40519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40520. /**
  40521. * Detach the current controls from the specified dom element.
  40522. * @param element Defines the element to stop listening the inputs from
  40523. */
  40524. detachControl(element: Nullable<HTMLElement>): void;
  40525. /**
  40526. * Update the current camera state depending on the inputs that have been used this frame.
  40527. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40528. */
  40529. checkInputs(): void;
  40530. /**
  40531. * Gets the class name of the current input.
  40532. * @returns the class name
  40533. */
  40534. getClassName(): string;
  40535. /**
  40536. * Get the friendly name associated with the input class.
  40537. * @returns the input friendly name
  40538. */
  40539. getSimpleName(): string;
  40540. /**
  40541. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40542. * allow modification of the heightOffset value.
  40543. */
  40544. private _modifierHeightOffset;
  40545. /**
  40546. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40547. * allow modification of the rotationOffset value.
  40548. */
  40549. private _modifierRotationOffset;
  40550. /**
  40551. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40552. * allow modification of the radius value.
  40553. */
  40554. private _modifierRadius;
  40555. }
  40556. }
  40557. declare module BABYLON {
  40558. interface FreeCameraInputsManager {
  40559. /**
  40560. * @hidden
  40561. */
  40562. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40563. /**
  40564. * Add orientation input support to the input manager.
  40565. * @returns the current input manager
  40566. */
  40567. addDeviceOrientation(): FreeCameraInputsManager;
  40568. }
  40569. /**
  40570. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40571. * Screen rotation is taken into account.
  40572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40573. */
  40574. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40575. private _camera;
  40576. private _screenOrientationAngle;
  40577. private _constantTranform;
  40578. private _screenQuaternion;
  40579. private _alpha;
  40580. private _beta;
  40581. private _gamma;
  40582. /**
  40583. * Can be used to detect if a device orientation sensor is available on a device
  40584. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40585. * @returns a promise that will resolve on orientation change
  40586. */
  40587. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40588. /**
  40589. * @hidden
  40590. */
  40591. _onDeviceOrientationChangedObservable: Observable<void>;
  40592. /**
  40593. * Instantiates a new input
  40594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40595. */
  40596. constructor();
  40597. /**
  40598. * Define the camera controlled by the input.
  40599. */
  40600. get camera(): FreeCamera;
  40601. set camera(camera: FreeCamera);
  40602. /**
  40603. * Attach the input controls to a specific dom element to get the input from.
  40604. * @param element Defines the element the controls should be listened from
  40605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40606. */
  40607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40608. private _orientationChanged;
  40609. private _deviceOrientation;
  40610. /**
  40611. * Detach the current controls from the specified dom element.
  40612. * @param element Defines the element to stop listening the inputs from
  40613. */
  40614. detachControl(element: Nullable<HTMLElement>): void;
  40615. /**
  40616. * Update the current camera state depending on the inputs that have been used this frame.
  40617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40618. */
  40619. checkInputs(): void;
  40620. /**
  40621. * Gets the class name of the current intput.
  40622. * @returns the class name
  40623. */
  40624. getClassName(): string;
  40625. /**
  40626. * Get the friendly name associated with the input class.
  40627. * @returns the input friendly name
  40628. */
  40629. getSimpleName(): string;
  40630. }
  40631. }
  40632. declare module BABYLON {
  40633. /**
  40634. * Manage the gamepad inputs to control a free camera.
  40635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40636. */
  40637. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40638. /**
  40639. * Define the camera the input is attached to.
  40640. */
  40641. camera: FreeCamera;
  40642. /**
  40643. * Define the Gamepad controlling the input
  40644. */
  40645. gamepad: Nullable<Gamepad>;
  40646. /**
  40647. * Defines the gamepad rotation sensiblity.
  40648. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40649. */
  40650. gamepadAngularSensibility: number;
  40651. /**
  40652. * Defines the gamepad move sensiblity.
  40653. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40654. */
  40655. gamepadMoveSensibility: number;
  40656. private _yAxisScale;
  40657. /**
  40658. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40659. */
  40660. get invertYAxis(): boolean;
  40661. set invertYAxis(value: boolean);
  40662. private _onGamepadConnectedObserver;
  40663. private _onGamepadDisconnectedObserver;
  40664. private _cameraTransform;
  40665. private _deltaTransform;
  40666. private _vector3;
  40667. private _vector2;
  40668. /**
  40669. * Attach the input controls to a specific dom element to get the input from.
  40670. * @param element Defines the element the controls should be listened from
  40671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40672. */
  40673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40674. /**
  40675. * Detach the current controls from the specified dom element.
  40676. * @param element Defines the element to stop listening the inputs from
  40677. */
  40678. detachControl(element: Nullable<HTMLElement>): void;
  40679. /**
  40680. * Update the current camera state depending on the inputs that have been used this frame.
  40681. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40682. */
  40683. checkInputs(): void;
  40684. /**
  40685. * Gets the class name of the current intput.
  40686. * @returns the class name
  40687. */
  40688. getClassName(): string;
  40689. /**
  40690. * Get the friendly name associated with the input class.
  40691. * @returns the input friendly name
  40692. */
  40693. getSimpleName(): string;
  40694. }
  40695. }
  40696. declare module BABYLON {
  40697. /**
  40698. * Defines the potential axis of a Joystick
  40699. */
  40700. export enum JoystickAxis {
  40701. /** X axis */
  40702. X = 0,
  40703. /** Y axis */
  40704. Y = 1,
  40705. /** Z axis */
  40706. Z = 2
  40707. }
  40708. /**
  40709. * Class used to define virtual joystick (used in touch mode)
  40710. */
  40711. export class VirtualJoystick {
  40712. /**
  40713. * Gets or sets a boolean indicating that left and right values must be inverted
  40714. */
  40715. reverseLeftRight: boolean;
  40716. /**
  40717. * Gets or sets a boolean indicating that up and down values must be inverted
  40718. */
  40719. reverseUpDown: boolean;
  40720. /**
  40721. * Gets the offset value for the position (ie. the change of the position value)
  40722. */
  40723. deltaPosition: Vector3;
  40724. /**
  40725. * Gets a boolean indicating if the virtual joystick was pressed
  40726. */
  40727. pressed: boolean;
  40728. /**
  40729. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40730. */
  40731. static Canvas: Nullable<HTMLCanvasElement>;
  40732. private static _globalJoystickIndex;
  40733. private static vjCanvasContext;
  40734. private static vjCanvasWidth;
  40735. private static vjCanvasHeight;
  40736. private static halfWidth;
  40737. private _action;
  40738. private _axisTargetedByLeftAndRight;
  40739. private _axisTargetedByUpAndDown;
  40740. private _joystickSensibility;
  40741. private _inversedSensibility;
  40742. private _joystickPointerID;
  40743. private _joystickColor;
  40744. private _joystickPointerPos;
  40745. private _joystickPreviousPointerPos;
  40746. private _joystickPointerStartPos;
  40747. private _deltaJoystickVector;
  40748. private _leftJoystick;
  40749. private _touches;
  40750. private _onPointerDownHandlerRef;
  40751. private _onPointerMoveHandlerRef;
  40752. private _onPointerUpHandlerRef;
  40753. private _onResize;
  40754. /**
  40755. * Creates a new virtual joystick
  40756. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40757. */
  40758. constructor(leftJoystick?: boolean);
  40759. /**
  40760. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40761. * @param newJoystickSensibility defines the new sensibility
  40762. */
  40763. setJoystickSensibility(newJoystickSensibility: number): void;
  40764. private _onPointerDown;
  40765. private _onPointerMove;
  40766. private _onPointerUp;
  40767. /**
  40768. * Change the color of the virtual joystick
  40769. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40770. */
  40771. setJoystickColor(newColor: string): void;
  40772. /**
  40773. * Defines a callback to call when the joystick is touched
  40774. * @param action defines the callback
  40775. */
  40776. setActionOnTouch(action: () => any): void;
  40777. /**
  40778. * Defines which axis you'd like to control for left & right
  40779. * @param axis defines the axis to use
  40780. */
  40781. setAxisForLeftRight(axis: JoystickAxis): void;
  40782. /**
  40783. * Defines which axis you'd like to control for up & down
  40784. * @param axis defines the axis to use
  40785. */
  40786. setAxisForUpDown(axis: JoystickAxis): void;
  40787. private _drawVirtualJoystick;
  40788. /**
  40789. * Release internal HTML canvas
  40790. */
  40791. releaseCanvas(): void;
  40792. }
  40793. }
  40794. declare module BABYLON {
  40795. interface FreeCameraInputsManager {
  40796. /**
  40797. * Add virtual joystick input support to the input manager.
  40798. * @returns the current input manager
  40799. */
  40800. addVirtualJoystick(): FreeCameraInputsManager;
  40801. }
  40802. /**
  40803. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40805. */
  40806. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40807. /**
  40808. * Defines the camera the input is attached to.
  40809. */
  40810. camera: FreeCamera;
  40811. private _leftjoystick;
  40812. private _rightjoystick;
  40813. /**
  40814. * Gets the left stick of the virtual joystick.
  40815. * @returns The virtual Joystick
  40816. */
  40817. getLeftJoystick(): VirtualJoystick;
  40818. /**
  40819. * Gets the right stick of the virtual joystick.
  40820. * @returns The virtual Joystick
  40821. */
  40822. getRightJoystick(): VirtualJoystick;
  40823. /**
  40824. * Update the current camera state depending on the inputs that have been used this frame.
  40825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40826. */
  40827. checkInputs(): void;
  40828. /**
  40829. * Attach the input controls to a specific dom element to get the input from.
  40830. * @param element Defines the element the controls should be listened from
  40831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40832. */
  40833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40834. /**
  40835. * Detach the current controls from the specified dom element.
  40836. * @param element Defines the element to stop listening the inputs from
  40837. */
  40838. detachControl(element: Nullable<HTMLElement>): void;
  40839. /**
  40840. * Gets the class name of the current intput.
  40841. * @returns the class name
  40842. */
  40843. getClassName(): string;
  40844. /**
  40845. * Get the friendly name associated with the input class.
  40846. * @returns the input friendly name
  40847. */
  40848. getSimpleName(): string;
  40849. }
  40850. }
  40851. declare module BABYLON {
  40852. /**
  40853. * This represents a FPS type of camera controlled by touch.
  40854. * This is like a universal camera minus the Gamepad controls.
  40855. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40856. */
  40857. export class TouchCamera extends FreeCamera {
  40858. /**
  40859. * Defines the touch sensibility for rotation.
  40860. * The higher the faster.
  40861. */
  40862. get touchAngularSensibility(): number;
  40863. set touchAngularSensibility(value: number);
  40864. /**
  40865. * Defines the touch sensibility for move.
  40866. * The higher the faster.
  40867. */
  40868. get touchMoveSensibility(): number;
  40869. set touchMoveSensibility(value: number);
  40870. /**
  40871. * Instantiates a new touch camera.
  40872. * This represents a FPS type of camera controlled by touch.
  40873. * This is like a universal camera minus the Gamepad controls.
  40874. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40875. * @param name Define the name of the camera in the scene
  40876. * @param position Define the start position of the camera in the scene
  40877. * @param scene Define the scene the camera belongs to
  40878. */
  40879. constructor(name: string, position: Vector3, scene: Scene);
  40880. /**
  40881. * Gets the current object class name.
  40882. * @return the class name
  40883. */
  40884. getClassName(): string;
  40885. /** @hidden */
  40886. _setupInputs(): void;
  40887. }
  40888. }
  40889. declare module BABYLON {
  40890. /**
  40891. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40892. * being tilted forward or back and left or right.
  40893. */
  40894. export class DeviceOrientationCamera extends FreeCamera {
  40895. private _initialQuaternion;
  40896. private _quaternionCache;
  40897. private _tmpDragQuaternion;
  40898. private _disablePointerInputWhenUsingDeviceOrientation;
  40899. /**
  40900. * Creates a new device orientation camera
  40901. * @param name The name of the camera
  40902. * @param position The start position camera
  40903. * @param scene The scene the camera belongs to
  40904. */
  40905. constructor(name: string, position: Vector3, scene: Scene);
  40906. /**
  40907. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40908. */
  40909. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40910. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40911. private _dragFactor;
  40912. /**
  40913. * Enabled turning on the y axis when the orientation sensor is active
  40914. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40915. */
  40916. enableHorizontalDragging(dragFactor?: number): void;
  40917. /**
  40918. * Gets the current instance class name ("DeviceOrientationCamera").
  40919. * This helps avoiding instanceof at run time.
  40920. * @returns the class name
  40921. */
  40922. getClassName(): string;
  40923. /**
  40924. * @hidden
  40925. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40926. */
  40927. _checkInputs(): void;
  40928. /**
  40929. * Reset the camera to its default orientation on the specified axis only.
  40930. * @param axis The axis to reset
  40931. */
  40932. resetToCurrentRotation(axis?: Axis): void;
  40933. }
  40934. }
  40935. declare module BABYLON {
  40936. /**
  40937. * Defines supported buttons for XBox360 compatible gamepads
  40938. */
  40939. export enum Xbox360Button {
  40940. /** A */
  40941. A = 0,
  40942. /** B */
  40943. B = 1,
  40944. /** X */
  40945. X = 2,
  40946. /** Y */
  40947. Y = 3,
  40948. /** Left button */
  40949. LB = 4,
  40950. /** Right button */
  40951. RB = 5,
  40952. /** Back */
  40953. Back = 8,
  40954. /** Start */
  40955. Start = 9,
  40956. /** Left stick */
  40957. LeftStick = 10,
  40958. /** Right stick */
  40959. RightStick = 11
  40960. }
  40961. /** Defines values for XBox360 DPad */
  40962. export enum Xbox360Dpad {
  40963. /** Up */
  40964. Up = 12,
  40965. /** Down */
  40966. Down = 13,
  40967. /** Left */
  40968. Left = 14,
  40969. /** Right */
  40970. Right = 15
  40971. }
  40972. /**
  40973. * Defines a XBox360 gamepad
  40974. */
  40975. export class Xbox360Pad extends Gamepad {
  40976. private _leftTrigger;
  40977. private _rightTrigger;
  40978. private _onlefttriggerchanged;
  40979. private _onrighttriggerchanged;
  40980. private _onbuttondown;
  40981. private _onbuttonup;
  40982. private _ondpaddown;
  40983. private _ondpadup;
  40984. /** Observable raised when a button is pressed */
  40985. onButtonDownObservable: Observable<Xbox360Button>;
  40986. /** Observable raised when a button is released */
  40987. onButtonUpObservable: Observable<Xbox360Button>;
  40988. /** Observable raised when a pad is pressed */
  40989. onPadDownObservable: Observable<Xbox360Dpad>;
  40990. /** Observable raised when a pad is released */
  40991. onPadUpObservable: Observable<Xbox360Dpad>;
  40992. private _buttonA;
  40993. private _buttonB;
  40994. private _buttonX;
  40995. private _buttonY;
  40996. private _buttonBack;
  40997. private _buttonStart;
  40998. private _buttonLB;
  40999. private _buttonRB;
  41000. private _buttonLeftStick;
  41001. private _buttonRightStick;
  41002. private _dPadUp;
  41003. private _dPadDown;
  41004. private _dPadLeft;
  41005. private _dPadRight;
  41006. private _isXboxOnePad;
  41007. /**
  41008. * Creates a new XBox360 gamepad object
  41009. * @param id defines the id of this gamepad
  41010. * @param index defines its index
  41011. * @param gamepad defines the internal HTML gamepad object
  41012. * @param xboxOne defines if it is a XBox One gamepad
  41013. */
  41014. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41015. /**
  41016. * Defines the callback to call when left trigger is pressed
  41017. * @param callback defines the callback to use
  41018. */
  41019. onlefttriggerchanged(callback: (value: number) => void): void;
  41020. /**
  41021. * Defines the callback to call when right trigger is pressed
  41022. * @param callback defines the callback to use
  41023. */
  41024. onrighttriggerchanged(callback: (value: number) => void): void;
  41025. /**
  41026. * Gets the left trigger value
  41027. */
  41028. get leftTrigger(): number;
  41029. /**
  41030. * Sets the left trigger value
  41031. */
  41032. set leftTrigger(newValue: number);
  41033. /**
  41034. * Gets the right trigger value
  41035. */
  41036. get rightTrigger(): number;
  41037. /**
  41038. * Sets the right trigger value
  41039. */
  41040. set rightTrigger(newValue: number);
  41041. /**
  41042. * Defines the callback to call when a button is pressed
  41043. * @param callback defines the callback to use
  41044. */
  41045. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41046. /**
  41047. * Defines the callback to call when a button is released
  41048. * @param callback defines the callback to use
  41049. */
  41050. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41051. /**
  41052. * Defines the callback to call when a pad is pressed
  41053. * @param callback defines the callback to use
  41054. */
  41055. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41056. /**
  41057. * Defines the callback to call when a pad is released
  41058. * @param callback defines the callback to use
  41059. */
  41060. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41061. private _setButtonValue;
  41062. private _setDPadValue;
  41063. /**
  41064. * Gets the value of the `A` button
  41065. */
  41066. get buttonA(): number;
  41067. /**
  41068. * Sets the value of the `A` button
  41069. */
  41070. set buttonA(value: number);
  41071. /**
  41072. * Gets the value of the `B` button
  41073. */
  41074. get buttonB(): number;
  41075. /**
  41076. * Sets the value of the `B` button
  41077. */
  41078. set buttonB(value: number);
  41079. /**
  41080. * Gets the value of the `X` button
  41081. */
  41082. get buttonX(): number;
  41083. /**
  41084. * Sets the value of the `X` button
  41085. */
  41086. set buttonX(value: number);
  41087. /**
  41088. * Gets the value of the `Y` button
  41089. */
  41090. get buttonY(): number;
  41091. /**
  41092. * Sets the value of the `Y` button
  41093. */
  41094. set buttonY(value: number);
  41095. /**
  41096. * Gets the value of the `Start` button
  41097. */
  41098. get buttonStart(): number;
  41099. /**
  41100. * Sets the value of the `Start` button
  41101. */
  41102. set buttonStart(value: number);
  41103. /**
  41104. * Gets the value of the `Back` button
  41105. */
  41106. get buttonBack(): number;
  41107. /**
  41108. * Sets the value of the `Back` button
  41109. */
  41110. set buttonBack(value: number);
  41111. /**
  41112. * Gets the value of the `Left` button
  41113. */
  41114. get buttonLB(): number;
  41115. /**
  41116. * Sets the value of the `Left` button
  41117. */
  41118. set buttonLB(value: number);
  41119. /**
  41120. * Gets the value of the `Right` button
  41121. */
  41122. get buttonRB(): number;
  41123. /**
  41124. * Sets the value of the `Right` button
  41125. */
  41126. set buttonRB(value: number);
  41127. /**
  41128. * Gets the value of the Left joystick
  41129. */
  41130. get buttonLeftStick(): number;
  41131. /**
  41132. * Sets the value of the Left joystick
  41133. */
  41134. set buttonLeftStick(value: number);
  41135. /**
  41136. * Gets the value of the Right joystick
  41137. */
  41138. get buttonRightStick(): number;
  41139. /**
  41140. * Sets the value of the Right joystick
  41141. */
  41142. set buttonRightStick(value: number);
  41143. /**
  41144. * Gets the value of D-pad up
  41145. */
  41146. get dPadUp(): number;
  41147. /**
  41148. * Sets the value of D-pad up
  41149. */
  41150. set dPadUp(value: number);
  41151. /**
  41152. * Gets the value of D-pad down
  41153. */
  41154. get dPadDown(): number;
  41155. /**
  41156. * Sets the value of D-pad down
  41157. */
  41158. set dPadDown(value: number);
  41159. /**
  41160. * Gets the value of D-pad left
  41161. */
  41162. get dPadLeft(): number;
  41163. /**
  41164. * Sets the value of D-pad left
  41165. */
  41166. set dPadLeft(value: number);
  41167. /**
  41168. * Gets the value of D-pad right
  41169. */
  41170. get dPadRight(): number;
  41171. /**
  41172. * Sets the value of D-pad right
  41173. */
  41174. set dPadRight(value: number);
  41175. /**
  41176. * Force the gamepad to synchronize with device values
  41177. */
  41178. update(): void;
  41179. /**
  41180. * Disposes the gamepad
  41181. */
  41182. dispose(): void;
  41183. }
  41184. }
  41185. declare module BABYLON {
  41186. /**
  41187. * Defines supported buttons for DualShock compatible gamepads
  41188. */
  41189. export enum DualShockButton {
  41190. /** Cross */
  41191. Cross = 0,
  41192. /** Circle */
  41193. Circle = 1,
  41194. /** Square */
  41195. Square = 2,
  41196. /** Triangle */
  41197. Triangle = 3,
  41198. /** L1 */
  41199. L1 = 4,
  41200. /** R1 */
  41201. R1 = 5,
  41202. /** Share */
  41203. Share = 8,
  41204. /** Options */
  41205. Options = 9,
  41206. /** Left stick */
  41207. LeftStick = 10,
  41208. /** Right stick */
  41209. RightStick = 11
  41210. }
  41211. /** Defines values for DualShock DPad */
  41212. export enum DualShockDpad {
  41213. /** Up */
  41214. Up = 12,
  41215. /** Down */
  41216. Down = 13,
  41217. /** Left */
  41218. Left = 14,
  41219. /** Right */
  41220. Right = 15
  41221. }
  41222. /**
  41223. * Defines a DualShock gamepad
  41224. */
  41225. export class DualShockPad extends Gamepad {
  41226. private _leftTrigger;
  41227. private _rightTrigger;
  41228. private _onlefttriggerchanged;
  41229. private _onrighttriggerchanged;
  41230. private _onbuttondown;
  41231. private _onbuttonup;
  41232. private _ondpaddown;
  41233. private _ondpadup;
  41234. /** Observable raised when a button is pressed */
  41235. onButtonDownObservable: Observable<DualShockButton>;
  41236. /** Observable raised when a button is released */
  41237. onButtonUpObservable: Observable<DualShockButton>;
  41238. /** Observable raised when a pad is pressed */
  41239. onPadDownObservable: Observable<DualShockDpad>;
  41240. /** Observable raised when a pad is released */
  41241. onPadUpObservable: Observable<DualShockDpad>;
  41242. private _buttonCross;
  41243. private _buttonCircle;
  41244. private _buttonSquare;
  41245. private _buttonTriangle;
  41246. private _buttonShare;
  41247. private _buttonOptions;
  41248. private _buttonL1;
  41249. private _buttonR1;
  41250. private _buttonLeftStick;
  41251. private _buttonRightStick;
  41252. private _dPadUp;
  41253. private _dPadDown;
  41254. private _dPadLeft;
  41255. private _dPadRight;
  41256. /**
  41257. * Creates a new DualShock gamepad object
  41258. * @param id defines the id of this gamepad
  41259. * @param index defines its index
  41260. * @param gamepad defines the internal HTML gamepad object
  41261. */
  41262. constructor(id: string, index: number, gamepad: any);
  41263. /**
  41264. * Defines the callback to call when left trigger is pressed
  41265. * @param callback defines the callback to use
  41266. */
  41267. onlefttriggerchanged(callback: (value: number) => void): void;
  41268. /**
  41269. * Defines the callback to call when right trigger is pressed
  41270. * @param callback defines the callback to use
  41271. */
  41272. onrighttriggerchanged(callback: (value: number) => void): void;
  41273. /**
  41274. * Gets the left trigger value
  41275. */
  41276. get leftTrigger(): number;
  41277. /**
  41278. * Sets the left trigger value
  41279. */
  41280. set leftTrigger(newValue: number);
  41281. /**
  41282. * Gets the right trigger value
  41283. */
  41284. get rightTrigger(): number;
  41285. /**
  41286. * Sets the right trigger value
  41287. */
  41288. set rightTrigger(newValue: number);
  41289. /**
  41290. * Defines the callback to call when a button is pressed
  41291. * @param callback defines the callback to use
  41292. */
  41293. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41294. /**
  41295. * Defines the callback to call when a button is released
  41296. * @param callback defines the callback to use
  41297. */
  41298. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41299. /**
  41300. * Defines the callback to call when a pad is pressed
  41301. * @param callback defines the callback to use
  41302. */
  41303. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41304. /**
  41305. * Defines the callback to call when a pad is released
  41306. * @param callback defines the callback to use
  41307. */
  41308. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41309. private _setButtonValue;
  41310. private _setDPadValue;
  41311. /**
  41312. * Gets the value of the `Cross` button
  41313. */
  41314. get buttonCross(): number;
  41315. /**
  41316. * Sets the value of the `Cross` button
  41317. */
  41318. set buttonCross(value: number);
  41319. /**
  41320. * Gets the value of the `Circle` button
  41321. */
  41322. get buttonCircle(): number;
  41323. /**
  41324. * Sets the value of the `Circle` button
  41325. */
  41326. set buttonCircle(value: number);
  41327. /**
  41328. * Gets the value of the `Square` button
  41329. */
  41330. get buttonSquare(): number;
  41331. /**
  41332. * Sets the value of the `Square` button
  41333. */
  41334. set buttonSquare(value: number);
  41335. /**
  41336. * Gets the value of the `Triangle` button
  41337. */
  41338. get buttonTriangle(): number;
  41339. /**
  41340. * Sets the value of the `Triangle` button
  41341. */
  41342. set buttonTriangle(value: number);
  41343. /**
  41344. * Gets the value of the `Options` button
  41345. */
  41346. get buttonOptions(): number;
  41347. /**
  41348. * Sets the value of the `Options` button
  41349. */
  41350. set buttonOptions(value: number);
  41351. /**
  41352. * Gets the value of the `Share` button
  41353. */
  41354. get buttonShare(): number;
  41355. /**
  41356. * Sets the value of the `Share` button
  41357. */
  41358. set buttonShare(value: number);
  41359. /**
  41360. * Gets the value of the `L1` button
  41361. */
  41362. get buttonL1(): number;
  41363. /**
  41364. * Sets the value of the `L1` button
  41365. */
  41366. set buttonL1(value: number);
  41367. /**
  41368. * Gets the value of the `R1` button
  41369. */
  41370. get buttonR1(): number;
  41371. /**
  41372. * Sets the value of the `R1` button
  41373. */
  41374. set buttonR1(value: number);
  41375. /**
  41376. * Gets the value of the Left joystick
  41377. */
  41378. get buttonLeftStick(): number;
  41379. /**
  41380. * Sets the value of the Left joystick
  41381. */
  41382. set buttonLeftStick(value: number);
  41383. /**
  41384. * Gets the value of the Right joystick
  41385. */
  41386. get buttonRightStick(): number;
  41387. /**
  41388. * Sets the value of the Right joystick
  41389. */
  41390. set buttonRightStick(value: number);
  41391. /**
  41392. * Gets the value of D-pad up
  41393. */
  41394. get dPadUp(): number;
  41395. /**
  41396. * Sets the value of D-pad up
  41397. */
  41398. set dPadUp(value: number);
  41399. /**
  41400. * Gets the value of D-pad down
  41401. */
  41402. get dPadDown(): number;
  41403. /**
  41404. * Sets the value of D-pad down
  41405. */
  41406. set dPadDown(value: number);
  41407. /**
  41408. * Gets the value of D-pad left
  41409. */
  41410. get dPadLeft(): number;
  41411. /**
  41412. * Sets the value of D-pad left
  41413. */
  41414. set dPadLeft(value: number);
  41415. /**
  41416. * Gets the value of D-pad right
  41417. */
  41418. get dPadRight(): number;
  41419. /**
  41420. * Sets the value of D-pad right
  41421. */
  41422. set dPadRight(value: number);
  41423. /**
  41424. * Force the gamepad to synchronize with device values
  41425. */
  41426. update(): void;
  41427. /**
  41428. * Disposes the gamepad
  41429. */
  41430. dispose(): void;
  41431. }
  41432. }
  41433. declare module BABYLON {
  41434. /**
  41435. * Manager for handling gamepads
  41436. */
  41437. export class GamepadManager {
  41438. private _scene?;
  41439. private _babylonGamepads;
  41440. private _oneGamepadConnected;
  41441. /** @hidden */
  41442. _isMonitoring: boolean;
  41443. private _gamepadEventSupported;
  41444. private _gamepadSupport?;
  41445. /**
  41446. * observable to be triggered when the gamepad controller has been connected
  41447. */
  41448. onGamepadConnectedObservable: Observable<Gamepad>;
  41449. /**
  41450. * observable to be triggered when the gamepad controller has been disconnected
  41451. */
  41452. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41453. private _onGamepadConnectedEvent;
  41454. private _onGamepadDisconnectedEvent;
  41455. /**
  41456. * Initializes the gamepad manager
  41457. * @param _scene BabylonJS scene
  41458. */
  41459. constructor(_scene?: Scene | undefined);
  41460. /**
  41461. * The gamepads in the game pad manager
  41462. */
  41463. get gamepads(): Gamepad[];
  41464. /**
  41465. * Get the gamepad controllers based on type
  41466. * @param type The type of gamepad controller
  41467. * @returns Nullable gamepad
  41468. */
  41469. getGamepadByType(type?: number): Nullable<Gamepad>;
  41470. /**
  41471. * Disposes the gamepad manager
  41472. */
  41473. dispose(): void;
  41474. private _addNewGamepad;
  41475. private _startMonitoringGamepads;
  41476. private _stopMonitoringGamepads;
  41477. /** @hidden */
  41478. _checkGamepadsStatus(): void;
  41479. private _updateGamepadObjects;
  41480. }
  41481. }
  41482. declare module BABYLON {
  41483. interface Scene {
  41484. /** @hidden */
  41485. _gamepadManager: Nullable<GamepadManager>;
  41486. /**
  41487. * Gets the gamepad manager associated with the scene
  41488. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41489. */
  41490. gamepadManager: GamepadManager;
  41491. }
  41492. /**
  41493. * Interface representing a free camera inputs manager
  41494. */
  41495. interface FreeCameraInputsManager {
  41496. /**
  41497. * Adds gamepad input support to the FreeCameraInputsManager.
  41498. * @returns the FreeCameraInputsManager
  41499. */
  41500. addGamepad(): FreeCameraInputsManager;
  41501. }
  41502. /**
  41503. * Interface representing an arc rotate camera inputs manager
  41504. */
  41505. interface ArcRotateCameraInputsManager {
  41506. /**
  41507. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41508. * @returns the camera inputs manager
  41509. */
  41510. addGamepad(): ArcRotateCameraInputsManager;
  41511. }
  41512. /**
  41513. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41514. */
  41515. export class GamepadSystemSceneComponent implements ISceneComponent {
  41516. /**
  41517. * The component name helpfull to identify the component in the list of scene components.
  41518. */
  41519. readonly name: string;
  41520. /**
  41521. * The scene the component belongs to.
  41522. */
  41523. scene: Scene;
  41524. /**
  41525. * Creates a new instance of the component for the given scene
  41526. * @param scene Defines the scene to register the component in
  41527. */
  41528. constructor(scene: Scene);
  41529. /**
  41530. * Registers the component in a given scene
  41531. */
  41532. register(): void;
  41533. /**
  41534. * Rebuilds the elements related to this component in case of
  41535. * context lost for instance.
  41536. */
  41537. rebuild(): void;
  41538. /**
  41539. * Disposes the component and the associated ressources
  41540. */
  41541. dispose(): void;
  41542. private _beforeCameraUpdate;
  41543. }
  41544. }
  41545. declare module BABYLON {
  41546. /**
  41547. * 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,
  41548. * which still works and will still be found in many Playgrounds.
  41549. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41550. */
  41551. export class UniversalCamera extends TouchCamera {
  41552. /**
  41553. * Defines the gamepad rotation sensiblity.
  41554. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41555. */
  41556. get gamepadAngularSensibility(): number;
  41557. set gamepadAngularSensibility(value: number);
  41558. /**
  41559. * Defines the gamepad move sensiblity.
  41560. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41561. */
  41562. get gamepadMoveSensibility(): number;
  41563. set gamepadMoveSensibility(value: number);
  41564. /**
  41565. * 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,
  41566. * which still works and will still be found in many Playgrounds.
  41567. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41568. * @param name Define the name of the camera in the scene
  41569. * @param position Define the start position of the camera in the scene
  41570. * @param scene Define the scene the camera belongs to
  41571. */
  41572. constructor(name: string, position: Vector3, scene: Scene);
  41573. /**
  41574. * Gets the current object class name.
  41575. * @return the class name
  41576. */
  41577. getClassName(): string;
  41578. }
  41579. }
  41580. declare module BABYLON {
  41581. /**
  41582. * This represents a FPS type of camera. This is only here for back compat purpose.
  41583. * Please use the UniversalCamera instead as both are identical.
  41584. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41585. */
  41586. export class GamepadCamera extends UniversalCamera {
  41587. /**
  41588. * Instantiates a new Gamepad Camera
  41589. * This represents a FPS type of camera. This is only here for back compat purpose.
  41590. * Please use the UniversalCamera instead as both are identical.
  41591. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41592. * @param name Define the name of the camera in the scene
  41593. * @param position Define the start position of the camera in the scene
  41594. * @param scene Define the scene the camera belongs to
  41595. */
  41596. constructor(name: string, position: Vector3, scene: Scene);
  41597. /**
  41598. * Gets the current object class name.
  41599. * @return the class name
  41600. */
  41601. getClassName(): string;
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /** @hidden */
  41606. export var passPixelShader: {
  41607. name: string;
  41608. shader: string;
  41609. };
  41610. }
  41611. declare module BABYLON {
  41612. /** @hidden */
  41613. export var passCubePixelShader: {
  41614. name: string;
  41615. shader: string;
  41616. };
  41617. }
  41618. declare module BABYLON {
  41619. /**
  41620. * PassPostProcess which produces an output the same as it's input
  41621. */
  41622. export class PassPostProcess extends PostProcess {
  41623. /**
  41624. * Creates the PassPostProcess
  41625. * @param name The name of the effect.
  41626. * @param options The required width/height ratio to downsize to before computing the render pass.
  41627. * @param camera The camera to apply the render pass to.
  41628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41629. * @param engine The engine which the post process will be applied. (default: current engine)
  41630. * @param reusable If the post process can be reused on the same frame. (default: false)
  41631. * @param textureType The type of texture to be used when performing the post processing.
  41632. * @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)
  41633. */
  41634. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41635. }
  41636. /**
  41637. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41638. */
  41639. export class PassCubePostProcess extends PostProcess {
  41640. private _face;
  41641. /**
  41642. * Gets or sets the cube face to display.
  41643. * * 0 is +X
  41644. * * 1 is -X
  41645. * * 2 is +Y
  41646. * * 3 is -Y
  41647. * * 4 is +Z
  41648. * * 5 is -Z
  41649. */
  41650. get face(): number;
  41651. set face(value: number);
  41652. /**
  41653. * Creates the PassCubePostProcess
  41654. * @param name The name of the effect.
  41655. * @param options The required width/height ratio to downsize to before computing the render pass.
  41656. * @param camera The camera to apply the render pass to.
  41657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41658. * @param engine The engine which the post process will be applied. (default: current engine)
  41659. * @param reusable If the post process can be reused on the same frame. (default: false)
  41660. * @param textureType The type of texture to be used when performing the post processing.
  41661. * @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)
  41662. */
  41663. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41664. }
  41665. }
  41666. declare module BABYLON {
  41667. /** @hidden */
  41668. export var anaglyphPixelShader: {
  41669. name: string;
  41670. shader: string;
  41671. };
  41672. }
  41673. declare module BABYLON {
  41674. /**
  41675. * Postprocess used to generate anaglyphic rendering
  41676. */
  41677. export class AnaglyphPostProcess extends PostProcess {
  41678. private _passedProcess;
  41679. /**
  41680. * Creates a new AnaglyphPostProcess
  41681. * @param name defines postprocess name
  41682. * @param options defines creation options or target ratio scale
  41683. * @param rigCameras defines cameras using this postprocess
  41684. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41685. * @param engine defines hosting engine
  41686. * @param reusable defines if the postprocess will be reused multiple times per frame
  41687. */
  41688. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41689. }
  41690. }
  41691. declare module BABYLON {
  41692. /**
  41693. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41694. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41695. */
  41696. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41697. /**
  41698. * Creates a new AnaglyphArcRotateCamera
  41699. * @param name defines camera name
  41700. * @param alpha defines alpha angle (in radians)
  41701. * @param beta defines beta angle (in radians)
  41702. * @param radius defines radius
  41703. * @param target defines camera target
  41704. * @param interaxialDistance defines distance between each color axis
  41705. * @param scene defines the hosting scene
  41706. */
  41707. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41708. /**
  41709. * Gets camera class name
  41710. * @returns AnaglyphArcRotateCamera
  41711. */
  41712. getClassName(): string;
  41713. }
  41714. }
  41715. declare module BABYLON {
  41716. /**
  41717. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41718. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41719. */
  41720. export class AnaglyphFreeCamera extends FreeCamera {
  41721. /**
  41722. * Creates a new AnaglyphFreeCamera
  41723. * @param name defines camera name
  41724. * @param position defines initial position
  41725. * @param interaxialDistance defines distance between each color axis
  41726. * @param scene defines the hosting scene
  41727. */
  41728. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41729. /**
  41730. * Gets camera class name
  41731. * @returns AnaglyphFreeCamera
  41732. */
  41733. getClassName(): string;
  41734. }
  41735. }
  41736. declare module BABYLON {
  41737. /**
  41738. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41739. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41740. */
  41741. export class AnaglyphGamepadCamera extends GamepadCamera {
  41742. /**
  41743. * Creates a new AnaglyphGamepadCamera
  41744. * @param name defines camera name
  41745. * @param position defines initial position
  41746. * @param interaxialDistance defines distance between each color axis
  41747. * @param scene defines the hosting scene
  41748. */
  41749. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41750. /**
  41751. * Gets camera class name
  41752. * @returns AnaglyphGamepadCamera
  41753. */
  41754. getClassName(): string;
  41755. }
  41756. }
  41757. declare module BABYLON {
  41758. /**
  41759. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41760. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41761. */
  41762. export class AnaglyphUniversalCamera extends UniversalCamera {
  41763. /**
  41764. * Creates a new AnaglyphUniversalCamera
  41765. * @param name defines camera name
  41766. * @param position defines initial position
  41767. * @param interaxialDistance defines distance between each color axis
  41768. * @param scene defines the hosting scene
  41769. */
  41770. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41771. /**
  41772. * Gets camera class name
  41773. * @returns AnaglyphUniversalCamera
  41774. */
  41775. getClassName(): string;
  41776. }
  41777. }
  41778. declare module BABYLON {
  41779. /** @hidden */
  41780. export var stereoscopicInterlacePixelShader: {
  41781. name: string;
  41782. shader: string;
  41783. };
  41784. }
  41785. declare module BABYLON {
  41786. /**
  41787. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41788. */
  41789. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41790. private _stepSize;
  41791. private _passedProcess;
  41792. /**
  41793. * Initializes a StereoscopicInterlacePostProcessI
  41794. * @param name The name of the effect.
  41795. * @param rigCameras The rig cameras to be appled to the post process
  41796. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41797. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41799. * @param engine The engine which the post process will be applied. (default: current engine)
  41800. * @param reusable If the post process can be reused on the same frame. (default: false)
  41801. */
  41802. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41803. }
  41804. /**
  41805. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41806. */
  41807. export class StereoscopicInterlacePostProcess extends PostProcess {
  41808. private _stepSize;
  41809. private _passedProcess;
  41810. /**
  41811. * Initializes a StereoscopicInterlacePostProcess
  41812. * @param name The name of the effect.
  41813. * @param rigCameras The rig cameras to be appled to the post process
  41814. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41816. * @param engine The engine which the post process will be applied. (default: current engine)
  41817. * @param reusable If the post process can be reused on the same frame. (default: false)
  41818. */
  41819. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41820. }
  41821. }
  41822. declare module BABYLON {
  41823. /**
  41824. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41825. * @see http://doc.babylonjs.com/features/cameras
  41826. */
  41827. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41828. /**
  41829. * Creates a new StereoscopicArcRotateCamera
  41830. * @param name defines camera name
  41831. * @param alpha defines alpha angle (in radians)
  41832. * @param beta defines beta angle (in radians)
  41833. * @param radius defines radius
  41834. * @param target defines camera target
  41835. * @param interaxialDistance defines distance between each color axis
  41836. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41837. * @param scene defines the hosting scene
  41838. */
  41839. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41840. /**
  41841. * Gets camera class name
  41842. * @returns StereoscopicArcRotateCamera
  41843. */
  41844. getClassName(): string;
  41845. }
  41846. }
  41847. declare module BABYLON {
  41848. /**
  41849. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41850. * @see http://doc.babylonjs.com/features/cameras
  41851. */
  41852. export class StereoscopicFreeCamera extends FreeCamera {
  41853. /**
  41854. * Creates a new StereoscopicFreeCamera
  41855. * @param name defines camera name
  41856. * @param position defines initial position
  41857. * @param interaxialDistance defines distance between each color axis
  41858. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41859. * @param scene defines the hosting scene
  41860. */
  41861. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41862. /**
  41863. * Gets camera class name
  41864. * @returns StereoscopicFreeCamera
  41865. */
  41866. getClassName(): string;
  41867. }
  41868. }
  41869. declare module BABYLON {
  41870. /**
  41871. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41872. * @see http://doc.babylonjs.com/features/cameras
  41873. */
  41874. export class StereoscopicGamepadCamera extends GamepadCamera {
  41875. /**
  41876. * Creates a new StereoscopicGamepadCamera
  41877. * @param name defines camera name
  41878. * @param position defines initial position
  41879. * @param interaxialDistance defines distance between each color axis
  41880. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41881. * @param scene defines the hosting scene
  41882. */
  41883. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41884. /**
  41885. * Gets camera class name
  41886. * @returns StereoscopicGamepadCamera
  41887. */
  41888. getClassName(): string;
  41889. }
  41890. }
  41891. declare module BABYLON {
  41892. /**
  41893. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41894. * @see http://doc.babylonjs.com/features/cameras
  41895. */
  41896. export class StereoscopicUniversalCamera extends UniversalCamera {
  41897. /**
  41898. * Creates a new StereoscopicUniversalCamera
  41899. * @param name defines camera name
  41900. * @param position defines initial position
  41901. * @param interaxialDistance defines distance between each color axis
  41902. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41903. * @param scene defines the hosting scene
  41904. */
  41905. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41906. /**
  41907. * Gets camera class name
  41908. * @returns StereoscopicUniversalCamera
  41909. */
  41910. getClassName(): string;
  41911. }
  41912. }
  41913. declare module BABYLON {
  41914. /**
  41915. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41916. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41917. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41918. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41919. */
  41920. export class VirtualJoysticksCamera extends FreeCamera {
  41921. /**
  41922. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41923. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41924. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41925. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41926. * @param name Define the name of the camera in the scene
  41927. * @param position Define the start position of the camera in the scene
  41928. * @param scene Define the scene the camera belongs to
  41929. */
  41930. constructor(name: string, position: Vector3, scene: Scene);
  41931. /**
  41932. * Gets the current object class name.
  41933. * @return the class name
  41934. */
  41935. getClassName(): string;
  41936. }
  41937. }
  41938. declare module BABYLON {
  41939. /**
  41940. * This represents all the required metrics to create a VR camera.
  41941. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41942. */
  41943. export class VRCameraMetrics {
  41944. /**
  41945. * Define the horizontal resolution off the screen.
  41946. */
  41947. hResolution: number;
  41948. /**
  41949. * Define the vertical resolution off the screen.
  41950. */
  41951. vResolution: number;
  41952. /**
  41953. * Define the horizontal screen size.
  41954. */
  41955. hScreenSize: number;
  41956. /**
  41957. * Define the vertical screen size.
  41958. */
  41959. vScreenSize: number;
  41960. /**
  41961. * Define the vertical screen center position.
  41962. */
  41963. vScreenCenter: number;
  41964. /**
  41965. * Define the distance of the eyes to the screen.
  41966. */
  41967. eyeToScreenDistance: number;
  41968. /**
  41969. * Define the distance between both lenses
  41970. */
  41971. lensSeparationDistance: number;
  41972. /**
  41973. * Define the distance between both viewer's eyes.
  41974. */
  41975. interpupillaryDistance: number;
  41976. /**
  41977. * Define the distortion factor of the VR postprocess.
  41978. * Please, touch with care.
  41979. */
  41980. distortionK: number[];
  41981. /**
  41982. * Define the chromatic aberration correction factors for the VR post process.
  41983. */
  41984. chromaAbCorrection: number[];
  41985. /**
  41986. * Define the scale factor of the post process.
  41987. * The smaller the better but the slower.
  41988. */
  41989. postProcessScaleFactor: number;
  41990. /**
  41991. * Define an offset for the lens center.
  41992. */
  41993. lensCenterOffset: number;
  41994. /**
  41995. * Define if the current vr camera should compensate the distortion of the lense or not.
  41996. */
  41997. compensateDistortion: boolean;
  41998. /**
  41999. * Defines if multiview should be enabled when rendering (Default: false)
  42000. */
  42001. multiviewEnabled: boolean;
  42002. /**
  42003. * Gets the rendering aspect ratio based on the provided resolutions.
  42004. */
  42005. get aspectRatio(): number;
  42006. /**
  42007. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42008. */
  42009. get aspectRatioFov(): number;
  42010. /**
  42011. * @hidden
  42012. */
  42013. get leftHMatrix(): Matrix;
  42014. /**
  42015. * @hidden
  42016. */
  42017. get rightHMatrix(): Matrix;
  42018. /**
  42019. * @hidden
  42020. */
  42021. get leftPreViewMatrix(): Matrix;
  42022. /**
  42023. * @hidden
  42024. */
  42025. get rightPreViewMatrix(): Matrix;
  42026. /**
  42027. * Get the default VRMetrics based on the most generic setup.
  42028. * @returns the default vr metrics
  42029. */
  42030. static GetDefault(): VRCameraMetrics;
  42031. }
  42032. }
  42033. declare module BABYLON {
  42034. /** @hidden */
  42035. export var vrDistortionCorrectionPixelShader: {
  42036. name: string;
  42037. shader: string;
  42038. };
  42039. }
  42040. declare module BABYLON {
  42041. /**
  42042. * VRDistortionCorrectionPostProcess used for mobile VR
  42043. */
  42044. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42045. private _isRightEye;
  42046. private _distortionFactors;
  42047. private _postProcessScaleFactor;
  42048. private _lensCenterOffset;
  42049. private _scaleIn;
  42050. private _scaleFactor;
  42051. private _lensCenter;
  42052. /**
  42053. * Initializes the VRDistortionCorrectionPostProcess
  42054. * @param name The name of the effect.
  42055. * @param camera The camera to apply the render pass to.
  42056. * @param isRightEye If this is for the right eye distortion
  42057. * @param vrMetrics All the required metrics for the VR camera
  42058. */
  42059. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42060. }
  42061. }
  42062. declare module BABYLON {
  42063. /**
  42064. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42065. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42066. */
  42067. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42068. /**
  42069. * Creates a new VRDeviceOrientationArcRotateCamera
  42070. * @param name defines camera name
  42071. * @param alpha defines the camera rotation along the logitudinal axis
  42072. * @param beta defines the camera rotation along the latitudinal axis
  42073. * @param radius defines the camera distance from its target
  42074. * @param target defines the camera target
  42075. * @param scene defines the scene the camera belongs to
  42076. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42077. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42078. */
  42079. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42080. /**
  42081. * Gets camera class name
  42082. * @returns VRDeviceOrientationArcRotateCamera
  42083. */
  42084. getClassName(): string;
  42085. }
  42086. }
  42087. declare module BABYLON {
  42088. /**
  42089. * Camera used to simulate VR rendering (based on FreeCamera)
  42090. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42091. */
  42092. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42093. /**
  42094. * Creates a new VRDeviceOrientationFreeCamera
  42095. * @param name defines camera name
  42096. * @param position defines the start position of the camera
  42097. * @param scene defines the scene the camera belongs to
  42098. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42099. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42100. */
  42101. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42102. /**
  42103. * Gets camera class name
  42104. * @returns VRDeviceOrientationFreeCamera
  42105. */
  42106. getClassName(): string;
  42107. }
  42108. }
  42109. declare module BABYLON {
  42110. /**
  42111. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42112. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42113. */
  42114. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42115. /**
  42116. * Creates a new VRDeviceOrientationGamepadCamera
  42117. * @param name defines camera name
  42118. * @param position defines the start position of the camera
  42119. * @param scene defines the scene the camera belongs to
  42120. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42121. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42122. */
  42123. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42124. /**
  42125. * Gets camera class name
  42126. * @returns VRDeviceOrientationGamepadCamera
  42127. */
  42128. getClassName(): string;
  42129. }
  42130. }
  42131. declare module BABYLON {
  42132. /** @hidden */
  42133. export var imageProcessingPixelShader: {
  42134. name: string;
  42135. shader: string;
  42136. };
  42137. }
  42138. declare module BABYLON {
  42139. /**
  42140. * ImageProcessingPostProcess
  42141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42142. */
  42143. export class ImageProcessingPostProcess extends PostProcess {
  42144. /**
  42145. * Default configuration related to image processing available in the PBR Material.
  42146. */
  42147. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42148. /**
  42149. * Gets the image processing configuration used either in this material.
  42150. */
  42151. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42152. /**
  42153. * Sets the Default image processing configuration used either in the this material.
  42154. *
  42155. * If sets to null, the scene one is in use.
  42156. */
  42157. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42158. /**
  42159. * Keep track of the image processing observer to allow dispose and replace.
  42160. */
  42161. private _imageProcessingObserver;
  42162. /**
  42163. * Attaches a new image processing configuration to the PBR Material.
  42164. * @param configuration
  42165. */
  42166. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42167. /**
  42168. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42169. */
  42170. get colorCurves(): Nullable<ColorCurves>;
  42171. /**
  42172. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42173. */
  42174. set colorCurves(value: Nullable<ColorCurves>);
  42175. /**
  42176. * Gets wether the color curves effect is enabled.
  42177. */
  42178. get colorCurvesEnabled(): boolean;
  42179. /**
  42180. * Sets wether the color curves effect is enabled.
  42181. */
  42182. set colorCurvesEnabled(value: boolean);
  42183. /**
  42184. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42185. */
  42186. get colorGradingTexture(): Nullable<BaseTexture>;
  42187. /**
  42188. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42189. */
  42190. set colorGradingTexture(value: Nullable<BaseTexture>);
  42191. /**
  42192. * Gets wether the color grading effect is enabled.
  42193. */
  42194. get colorGradingEnabled(): boolean;
  42195. /**
  42196. * Gets wether the color grading effect is enabled.
  42197. */
  42198. set colorGradingEnabled(value: boolean);
  42199. /**
  42200. * Gets exposure used in the effect.
  42201. */
  42202. get exposure(): number;
  42203. /**
  42204. * Sets exposure used in the effect.
  42205. */
  42206. set exposure(value: number);
  42207. /**
  42208. * Gets wether tonemapping is enabled or not.
  42209. */
  42210. get toneMappingEnabled(): boolean;
  42211. /**
  42212. * Sets wether tonemapping is enabled or not
  42213. */
  42214. set toneMappingEnabled(value: boolean);
  42215. /**
  42216. * Gets the type of tone mapping effect.
  42217. */
  42218. get toneMappingType(): number;
  42219. /**
  42220. * Sets the type of tone mapping effect.
  42221. */
  42222. set toneMappingType(value: number);
  42223. /**
  42224. * Gets contrast used in the effect.
  42225. */
  42226. get contrast(): number;
  42227. /**
  42228. * Sets contrast used in the effect.
  42229. */
  42230. set contrast(value: number);
  42231. /**
  42232. * Gets Vignette stretch size.
  42233. */
  42234. get vignetteStretch(): number;
  42235. /**
  42236. * Sets Vignette stretch size.
  42237. */
  42238. set vignetteStretch(value: number);
  42239. /**
  42240. * Gets Vignette centre X Offset.
  42241. */
  42242. get vignetteCentreX(): number;
  42243. /**
  42244. * Sets Vignette centre X Offset.
  42245. */
  42246. set vignetteCentreX(value: number);
  42247. /**
  42248. * Gets Vignette centre Y Offset.
  42249. */
  42250. get vignetteCentreY(): number;
  42251. /**
  42252. * Sets Vignette centre Y Offset.
  42253. */
  42254. set vignetteCentreY(value: number);
  42255. /**
  42256. * Gets Vignette weight or intensity of the vignette effect.
  42257. */
  42258. get vignetteWeight(): number;
  42259. /**
  42260. * Sets Vignette weight or intensity of the vignette effect.
  42261. */
  42262. set vignetteWeight(value: number);
  42263. /**
  42264. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42265. * if vignetteEnabled is set to true.
  42266. */
  42267. get vignetteColor(): Color4;
  42268. /**
  42269. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42270. * if vignetteEnabled is set to true.
  42271. */
  42272. set vignetteColor(value: Color4);
  42273. /**
  42274. * Gets Camera field of view used by the Vignette effect.
  42275. */
  42276. get vignetteCameraFov(): number;
  42277. /**
  42278. * Sets Camera field of view used by the Vignette effect.
  42279. */
  42280. set vignetteCameraFov(value: number);
  42281. /**
  42282. * Gets the vignette blend mode allowing different kind of effect.
  42283. */
  42284. get vignetteBlendMode(): number;
  42285. /**
  42286. * Sets the vignette blend mode allowing different kind of effect.
  42287. */
  42288. set vignetteBlendMode(value: number);
  42289. /**
  42290. * Gets wether the vignette effect is enabled.
  42291. */
  42292. get vignetteEnabled(): boolean;
  42293. /**
  42294. * Sets wether the vignette effect is enabled.
  42295. */
  42296. set vignetteEnabled(value: boolean);
  42297. private _fromLinearSpace;
  42298. /**
  42299. * Gets wether the input of the processing is in Gamma or Linear Space.
  42300. */
  42301. get fromLinearSpace(): boolean;
  42302. /**
  42303. * Sets wether the input of the processing is in Gamma or Linear Space.
  42304. */
  42305. set fromLinearSpace(value: boolean);
  42306. /**
  42307. * Defines cache preventing GC.
  42308. */
  42309. private _defines;
  42310. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42311. /**
  42312. * "ImageProcessingPostProcess"
  42313. * @returns "ImageProcessingPostProcess"
  42314. */
  42315. getClassName(): string;
  42316. protected _updateParameters(): void;
  42317. dispose(camera?: Camera): void;
  42318. }
  42319. }
  42320. declare module BABYLON {
  42321. /**
  42322. * Class containing static functions to help procedurally build meshes
  42323. */
  42324. export class GroundBuilder {
  42325. /**
  42326. * Creates a ground mesh
  42327. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42328. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42330. * @param name defines the name of the mesh
  42331. * @param options defines the options used to create the mesh
  42332. * @param scene defines the hosting scene
  42333. * @returns the ground mesh
  42334. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42335. */
  42336. static CreateGround(name: string, options: {
  42337. width?: number;
  42338. height?: number;
  42339. subdivisions?: number;
  42340. subdivisionsX?: number;
  42341. subdivisionsY?: number;
  42342. updatable?: boolean;
  42343. }, scene: any): Mesh;
  42344. /**
  42345. * Creates a tiled ground mesh
  42346. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42347. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42348. * * 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
  42349. * * 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
  42350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42351. * @param name defines the name of the mesh
  42352. * @param options defines the options used to create the mesh
  42353. * @param scene defines the hosting scene
  42354. * @returns the tiled ground mesh
  42355. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42356. */
  42357. static CreateTiledGround(name: string, options: {
  42358. xmin: number;
  42359. zmin: number;
  42360. xmax: number;
  42361. zmax: number;
  42362. subdivisions?: {
  42363. w: number;
  42364. h: number;
  42365. };
  42366. precision?: {
  42367. w: number;
  42368. h: number;
  42369. };
  42370. updatable?: boolean;
  42371. }, scene?: Nullable<Scene>): Mesh;
  42372. /**
  42373. * Creates a ground mesh from a height map
  42374. * * The parameter `url` sets the URL of the height map image resource.
  42375. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42376. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42377. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42378. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42379. * * 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.
  42380. * * 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).
  42381. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42383. * @param name defines the name of the mesh
  42384. * @param url defines the url to the height map
  42385. * @param options defines the options used to create the mesh
  42386. * @param scene defines the hosting scene
  42387. * @returns the ground mesh
  42388. * @see https://doc.babylonjs.com/babylon101/height_map
  42389. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42390. */
  42391. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42392. width?: number;
  42393. height?: number;
  42394. subdivisions?: number;
  42395. minHeight?: number;
  42396. maxHeight?: number;
  42397. colorFilter?: Color3;
  42398. alphaFilter?: number;
  42399. updatable?: boolean;
  42400. onReady?: (mesh: GroundMesh) => void;
  42401. }, scene?: Nullable<Scene>): GroundMesh;
  42402. }
  42403. }
  42404. declare module BABYLON {
  42405. /**
  42406. * Class containing static functions to help procedurally build meshes
  42407. */
  42408. export class TorusBuilder {
  42409. /**
  42410. * Creates a torus mesh
  42411. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42412. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42413. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42415. * * 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
  42416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42417. * @param name defines the name of the mesh
  42418. * @param options defines the options used to create the mesh
  42419. * @param scene defines the hosting scene
  42420. * @returns the torus mesh
  42421. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42422. */
  42423. static CreateTorus(name: string, options: {
  42424. diameter?: number;
  42425. thickness?: number;
  42426. tessellation?: number;
  42427. updatable?: boolean;
  42428. sideOrientation?: number;
  42429. frontUVs?: Vector4;
  42430. backUVs?: Vector4;
  42431. }, scene: any): Mesh;
  42432. }
  42433. }
  42434. declare module BABYLON {
  42435. /**
  42436. * Class containing static functions to help procedurally build meshes
  42437. */
  42438. export class CylinderBuilder {
  42439. /**
  42440. * Creates a cylinder or a cone mesh
  42441. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42442. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42443. * * 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.
  42444. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42445. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42446. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42447. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42448. * * 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).
  42449. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42450. * * 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).
  42451. * * 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
  42452. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42453. * * 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
  42454. * * 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.
  42455. * * If `enclose` is false, a ring surface is one element.
  42456. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42457. * * 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
  42458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42459. * * 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
  42460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42461. * @param name defines the name of the mesh
  42462. * @param options defines the options used to create the mesh
  42463. * @param scene defines the hosting scene
  42464. * @returns the cylinder mesh
  42465. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42466. */
  42467. static CreateCylinder(name: string, options: {
  42468. height?: number;
  42469. diameterTop?: number;
  42470. diameterBottom?: number;
  42471. diameter?: number;
  42472. tessellation?: number;
  42473. subdivisions?: number;
  42474. arc?: number;
  42475. faceColors?: Color4[];
  42476. faceUV?: Vector4[];
  42477. updatable?: boolean;
  42478. hasRings?: boolean;
  42479. enclose?: boolean;
  42480. cap?: number;
  42481. sideOrientation?: number;
  42482. frontUVs?: Vector4;
  42483. backUVs?: Vector4;
  42484. }, scene: any): Mesh;
  42485. }
  42486. }
  42487. declare module BABYLON {
  42488. /**
  42489. * States of the webXR experience
  42490. */
  42491. export enum WebXRState {
  42492. /**
  42493. * Transitioning to being in XR mode
  42494. */
  42495. ENTERING_XR = 0,
  42496. /**
  42497. * Transitioning to non XR mode
  42498. */
  42499. EXITING_XR = 1,
  42500. /**
  42501. * In XR mode and presenting
  42502. */
  42503. IN_XR = 2,
  42504. /**
  42505. * Not entered XR mode
  42506. */
  42507. NOT_IN_XR = 3
  42508. }
  42509. /**
  42510. * Abstraction of the XR render target
  42511. */
  42512. export interface WebXRRenderTarget extends IDisposable {
  42513. /**
  42514. * xrpresent context of the canvas which can be used to display/mirror xr content
  42515. */
  42516. canvasContext: WebGLRenderingContext;
  42517. /**
  42518. * xr layer for the canvas
  42519. */
  42520. xrLayer: Nullable<XRWebGLLayer>;
  42521. /**
  42522. * Initializes the xr layer for the session
  42523. * @param xrSession xr session
  42524. * @returns a promise that will resolve once the XR Layer has been created
  42525. */
  42526. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42527. }
  42528. }
  42529. declare module BABYLON {
  42530. /**
  42531. * COnfiguration object for WebXR output canvas
  42532. */
  42533. export class WebXRManagedOutputCanvasOptions {
  42534. /**
  42535. * An optional canvas in case you wish to create it yourself and provide it here.
  42536. * If not provided, a new canvas will be created
  42537. */
  42538. canvasElement?: HTMLCanvasElement;
  42539. /**
  42540. * Options for this XR Layer output
  42541. */
  42542. canvasOptions?: XRWebGLLayerOptions;
  42543. /**
  42544. * CSS styling for a newly created canvas (if not provided)
  42545. */
  42546. newCanvasCssStyle?: string;
  42547. /**
  42548. * Get the default values of the configuration object
  42549. * @returns default values of this configuration object
  42550. */
  42551. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42552. }
  42553. /**
  42554. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42555. */
  42556. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42557. private _options;
  42558. private _canvas;
  42559. private _engine;
  42560. /**
  42561. * Rendering context of the canvas which can be used to display/mirror xr content
  42562. */
  42563. canvasContext: WebGLRenderingContext;
  42564. /**
  42565. * xr layer for the canvas
  42566. */
  42567. xrLayer: Nullable<XRWebGLLayer>;
  42568. /**
  42569. * Initializes the canvas to be added/removed upon entering/exiting xr
  42570. * @param _xrSessionManager The XR Session manager
  42571. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42572. */
  42573. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42574. /**
  42575. * Disposes of the object
  42576. */
  42577. dispose(): void;
  42578. /**
  42579. * Initializes the xr layer for the session
  42580. * @param xrSession xr session
  42581. * @returns a promise that will resolve once the XR Layer has been created
  42582. */
  42583. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42584. private _addCanvas;
  42585. private _removeCanvas;
  42586. private _setManagedOutputCanvas;
  42587. }
  42588. }
  42589. declare module BABYLON {
  42590. /**
  42591. * Manages an XRSession to work with Babylon's engine
  42592. * @see https://doc.babylonjs.com/how_to/webxr
  42593. */
  42594. export class WebXRSessionManager implements IDisposable {
  42595. /** The scene which the session should be created for */
  42596. scene: Scene;
  42597. private _referenceSpace;
  42598. private _rttProvider;
  42599. private _sessionEnded;
  42600. private _xrNavigator;
  42601. private baseLayer;
  42602. /**
  42603. * The base reference space from which the session started. good if you want to reset your
  42604. * reference space
  42605. */
  42606. baseReferenceSpace: XRReferenceSpace;
  42607. /**
  42608. * Current XR frame
  42609. */
  42610. currentFrame: Nullable<XRFrame>;
  42611. /** WebXR timestamp updated every frame */
  42612. currentTimestamp: number;
  42613. /**
  42614. * Used just in case of a failure to initialize an immersive session.
  42615. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42616. */
  42617. defaultHeightCompensation: number;
  42618. /**
  42619. * Fires every time a new xrFrame arrives which can be used to update the camera
  42620. */
  42621. onXRFrameObservable: Observable<XRFrame>;
  42622. /**
  42623. * Fires when the reference space changed
  42624. */
  42625. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42626. /**
  42627. * Fires when the xr session is ended either by the device or manually done
  42628. */
  42629. onXRSessionEnded: Observable<any>;
  42630. /**
  42631. * Fires when the xr session is ended either by the device or manually done
  42632. */
  42633. onXRSessionInit: Observable<XRSession>;
  42634. /**
  42635. * Underlying xr session
  42636. */
  42637. session: XRSession;
  42638. /**
  42639. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42640. * or get the offset the player is currently at.
  42641. */
  42642. viewerReferenceSpace: XRReferenceSpace;
  42643. /**
  42644. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42645. * @param scene The scene which the session should be created for
  42646. */
  42647. constructor(
  42648. /** The scene which the session should be created for */
  42649. scene: Scene);
  42650. /**
  42651. * The current reference space used in this session. This reference space can constantly change!
  42652. * It is mainly used to offset the camera's position.
  42653. */
  42654. get referenceSpace(): XRReferenceSpace;
  42655. /**
  42656. * Set a new reference space and triggers the observable
  42657. */
  42658. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42659. /**
  42660. * Disposes of the session manager
  42661. */
  42662. dispose(): void;
  42663. /**
  42664. * Stops the xrSession and restores the render loop
  42665. * @returns Promise which resolves after it exits XR
  42666. */
  42667. exitXRAsync(): Promise<void>;
  42668. /**
  42669. * Gets the correct render target texture to be rendered this frame for this eye
  42670. * @param eye the eye for which to get the render target
  42671. * @returns the render target for the specified eye
  42672. */
  42673. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42674. /**
  42675. * Creates a WebXRRenderTarget object for the XR session
  42676. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42677. * @param options optional options to provide when creating a new render target
  42678. * @returns a WebXR render target to which the session can render
  42679. */
  42680. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42681. /**
  42682. * Initializes the manager
  42683. * After initialization enterXR can be called to start an XR session
  42684. * @returns Promise which resolves after it is initialized
  42685. */
  42686. initializeAsync(): Promise<void>;
  42687. /**
  42688. * Initializes an xr session
  42689. * @param xrSessionMode mode to initialize
  42690. * @param xrSessionInit defines optional and required values to pass to the session builder
  42691. * @returns a promise which will resolve once the session has been initialized
  42692. */
  42693. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42694. /**
  42695. * Checks if a session would be supported for the creation options specified
  42696. * @param sessionMode session mode to check if supported eg. immersive-vr
  42697. * @returns A Promise that resolves to true if supported and false if not
  42698. */
  42699. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42700. /**
  42701. * Resets the reference space to the one started the session
  42702. */
  42703. resetReferenceSpace(): void;
  42704. /**
  42705. * Starts rendering to the xr layer
  42706. */
  42707. runXRRenderLoop(): void;
  42708. /**
  42709. * Sets the reference space on the xr session
  42710. * @param referenceSpaceType space to set
  42711. * @returns a promise that will resolve once the reference space has been set
  42712. */
  42713. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42714. /**
  42715. * Updates the render state of the session
  42716. * @param state state to set
  42717. * @returns a promise that resolves once the render state has been updated
  42718. */
  42719. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42720. /**
  42721. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42722. * @param sessionMode defines the session to test
  42723. * @returns a promise with boolean as final value
  42724. */
  42725. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42726. private _createRenderTargetTexture;
  42727. }
  42728. }
  42729. declare module BABYLON {
  42730. /**
  42731. * WebXR Camera which holds the views for the xrSession
  42732. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42733. */
  42734. export class WebXRCamera extends FreeCamera {
  42735. private _xrSessionManager;
  42736. private _firstFrame;
  42737. private _referenceQuaternion;
  42738. private _referencedPosition;
  42739. private _xrInvPositionCache;
  42740. private _xrInvQuaternionCache;
  42741. /**
  42742. * Should position compensation execute on first frame.
  42743. * This is used when copying the position from a native (non XR) camera
  42744. */
  42745. compensateOnFirstFrame: boolean;
  42746. /**
  42747. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42748. * @param name the name of the camera
  42749. * @param scene the scene to add the camera to
  42750. * @param _xrSessionManager a constructed xr session manager
  42751. */
  42752. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42753. /**
  42754. * Return the user's height, unrelated to the current ground.
  42755. * This will be the y position of this camera, when ground level is 0.
  42756. */
  42757. get realWorldHeight(): number;
  42758. /** @hidden */
  42759. _updateForDualEyeDebugging(): void;
  42760. /**
  42761. * Sets this camera's transformation based on a non-vr camera
  42762. * @param otherCamera the non-vr camera to copy the transformation from
  42763. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42764. */
  42765. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42766. /**
  42767. * Gets the current instance class name ("WebXRCamera").
  42768. * @returns the class name
  42769. */
  42770. getClassName(): string;
  42771. private _updateFromXRSession;
  42772. private _updateNumberOfRigCameras;
  42773. private _updateReferenceSpace;
  42774. private _updateReferenceSpaceOffset;
  42775. }
  42776. }
  42777. declare module BABYLON {
  42778. /**
  42779. * Defining the interface required for a (webxr) feature
  42780. */
  42781. export interface IWebXRFeature extends IDisposable {
  42782. /**
  42783. * Is this feature attached
  42784. */
  42785. attached: boolean;
  42786. /**
  42787. * Should auto-attach be disabled?
  42788. */
  42789. disableAutoAttach: boolean;
  42790. /**
  42791. * Attach the feature to the session
  42792. * Will usually be called by the features manager
  42793. *
  42794. * @param force should attachment be forced (even when already attached)
  42795. * @returns true if successful.
  42796. */
  42797. attach(force?: boolean): boolean;
  42798. /**
  42799. * Detach the feature from the session
  42800. * Will usually be called by the features manager
  42801. *
  42802. * @returns true if successful.
  42803. */
  42804. detach(): boolean;
  42805. }
  42806. /**
  42807. * A list of the currently available features without referencing them
  42808. */
  42809. export class WebXRFeatureName {
  42810. /**
  42811. * The name of the anchor system feature
  42812. */
  42813. static ANCHOR_SYSTEM: string;
  42814. /**
  42815. * The name of the background remover feature
  42816. */
  42817. static BACKGROUND_REMOVER: string;
  42818. /**
  42819. * The name of the hit test feature
  42820. */
  42821. static HIT_TEST: string;
  42822. /**
  42823. * physics impostors for xr controllers feature
  42824. */
  42825. static PHYSICS_CONTROLLERS: string;
  42826. /**
  42827. * The name of the plane detection feature
  42828. */
  42829. static PLANE_DETECTION: string;
  42830. /**
  42831. * The name of the pointer selection feature
  42832. */
  42833. static POINTER_SELECTION: string;
  42834. /**
  42835. * The name of the teleportation feature
  42836. */
  42837. static TELEPORTATION: string;
  42838. }
  42839. /**
  42840. * Defining the constructor of a feature. Used to register the modules.
  42841. */
  42842. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42843. /**
  42844. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42845. * It is mainly used in AR sessions.
  42846. *
  42847. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42848. */
  42849. export class WebXRFeaturesManager implements IDisposable {
  42850. private _xrSessionManager;
  42851. private static readonly _AvailableFeatures;
  42852. private _features;
  42853. /**
  42854. * constructs a new features manages.
  42855. *
  42856. * @param _xrSessionManager an instance of WebXRSessionManager
  42857. */
  42858. constructor(_xrSessionManager: WebXRSessionManager);
  42859. /**
  42860. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42861. * Mainly used internally.
  42862. *
  42863. * @param featureName the name of the feature to register
  42864. * @param constructorFunction the function used to construct the module
  42865. * @param version the (babylon) version of the module
  42866. * @param stable is that a stable version of this module
  42867. */
  42868. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42869. /**
  42870. * Returns a constructor of a specific feature.
  42871. *
  42872. * @param featureName the name of the feature to construct
  42873. * @param version the version of the feature to load
  42874. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42875. * @param options optional options provided to the module.
  42876. * @returns a function that, when called, will return a new instance of this feature
  42877. */
  42878. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42879. /**
  42880. * Can be used to return the list of features currently registered
  42881. *
  42882. * @returns an Array of available features
  42883. */
  42884. static GetAvailableFeatures(): string[];
  42885. /**
  42886. * Gets the versions available for a specific feature
  42887. * @param featureName the name of the feature
  42888. * @returns an array with the available versions
  42889. */
  42890. static GetAvailableVersions(featureName: string): string[];
  42891. /**
  42892. * Return the latest unstable version of this feature
  42893. * @param featureName the name of the feature to search
  42894. * @returns the version number. if not found will return -1
  42895. */
  42896. static GetLatestVersionOfFeature(featureName: string): number;
  42897. /**
  42898. * Return the latest stable version of this feature
  42899. * @param featureName the name of the feature to search
  42900. * @returns the version number. if not found will return -1
  42901. */
  42902. static GetStableVersionOfFeature(featureName: string): number;
  42903. /**
  42904. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42905. * Can be used during a session to start a feature
  42906. * @param featureName the name of feature to attach
  42907. */
  42908. attachFeature(featureName: string): void;
  42909. /**
  42910. * Can be used inside a session or when the session ends to detach a specific feature
  42911. * @param featureName the name of the feature to detach
  42912. */
  42913. detachFeature(featureName: string): void;
  42914. /**
  42915. * Used to disable an already-enabled feature
  42916. * The feature will be disposed and will be recreated once enabled.
  42917. * @param featureName the feature to disable
  42918. * @returns true if disable was successful
  42919. */
  42920. disableFeature(featureName: string | {
  42921. Name: string;
  42922. }): boolean;
  42923. /**
  42924. * dispose this features manager
  42925. */
  42926. dispose(): void;
  42927. /**
  42928. * 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.
  42929. * 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.
  42930. *
  42931. * @param featureName the name of the feature to load or the class of the feature
  42932. * @param version optional version to load. if not provided the latest version will be enabled
  42933. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42934. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42935. * @returns a new constructed feature or throws an error if feature not found.
  42936. */
  42937. enableFeature(featureName: string | {
  42938. Name: string;
  42939. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42940. /**
  42941. * get the implementation of an enabled feature.
  42942. * @param featureName the name of the feature to load
  42943. * @returns the feature class, if found
  42944. */
  42945. getEnabledFeature(featureName: string): IWebXRFeature;
  42946. /**
  42947. * Get the list of enabled features
  42948. * @returns an array of enabled features
  42949. */
  42950. getEnabledFeatures(): string[];
  42951. }
  42952. }
  42953. declare module BABYLON {
  42954. /**
  42955. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  42956. * @see https://doc.babylonjs.com/how_to/webxr
  42957. */
  42958. export class WebXRExperienceHelper implements IDisposable {
  42959. private scene;
  42960. private _nonVRCamera;
  42961. private _originalSceneAutoClear;
  42962. private _supported;
  42963. /**
  42964. * Camera used to render xr content
  42965. */
  42966. camera: WebXRCamera;
  42967. /** A features manager for this xr session */
  42968. featuresManager: WebXRFeaturesManager;
  42969. /**
  42970. * Observers registered here will be triggered after the camera's initial transformation is set
  42971. * This can be used to set a different ground level or an extra rotation.
  42972. *
  42973. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42974. * to the position set after this observable is done executing.
  42975. */
  42976. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42977. /**
  42978. * Fires when the state of the experience helper has changed
  42979. */
  42980. onStateChangedObservable: Observable<WebXRState>;
  42981. /** Session manager used to keep track of xr session */
  42982. sessionManager: WebXRSessionManager;
  42983. /**
  42984. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42985. */
  42986. state: WebXRState;
  42987. /**
  42988. * Creates a WebXRExperienceHelper
  42989. * @param scene The scene the helper should be created in
  42990. */
  42991. private constructor();
  42992. /**
  42993. * Creates the experience helper
  42994. * @param scene the scene to attach the experience helper to
  42995. * @returns a promise for the experience helper
  42996. */
  42997. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42998. /**
  42999. * Disposes of the experience helper
  43000. */
  43001. dispose(): void;
  43002. /**
  43003. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43004. * @param sessionMode options for the XR session
  43005. * @param referenceSpaceType frame of reference of the XR session
  43006. * @param renderTarget the output canvas that will be used to enter XR mode
  43007. * @returns promise that resolves after xr mode has entered
  43008. */
  43009. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43010. /**
  43011. * Exits XR mode and returns the scene to its original state
  43012. * @returns promise that resolves after xr mode has exited
  43013. */
  43014. exitXRAsync(): Promise<void>;
  43015. private _nonXRToXRCamera;
  43016. private _setState;
  43017. }
  43018. }
  43019. declare module BABYLON {
  43020. /**
  43021. * X-Y values for axes in WebXR
  43022. */
  43023. export interface IWebXRMotionControllerAxesValue {
  43024. /**
  43025. * The value of the x axis
  43026. */
  43027. x: number;
  43028. /**
  43029. * The value of the y-axis
  43030. */
  43031. y: number;
  43032. }
  43033. /**
  43034. * changed / previous values for the values of this component
  43035. */
  43036. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43037. /**
  43038. * current (this frame) value
  43039. */
  43040. current: T;
  43041. /**
  43042. * previous (last change) value
  43043. */
  43044. previous: T;
  43045. }
  43046. /**
  43047. * Represents changes in the component between current frame and last values recorded
  43048. */
  43049. export interface IWebXRMotionControllerComponentChanges {
  43050. /**
  43051. * will be populated with previous and current values if axes changed
  43052. */
  43053. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43054. /**
  43055. * will be populated with previous and current values if pressed changed
  43056. */
  43057. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43058. /**
  43059. * will be populated with previous and current values if touched changed
  43060. */
  43061. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43062. /**
  43063. * will be populated with previous and current values if value changed
  43064. */
  43065. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43066. }
  43067. /**
  43068. * This class represents a single component (for example button or thumbstick) of a motion controller
  43069. */
  43070. export class WebXRControllerComponent implements IDisposable {
  43071. /**
  43072. * the id of this component
  43073. */
  43074. id: string;
  43075. /**
  43076. * the type of the component
  43077. */
  43078. type: MotionControllerComponentType;
  43079. private _buttonIndex;
  43080. private _axesIndices;
  43081. private _axes;
  43082. private _changes;
  43083. private _currentValue;
  43084. private _hasChanges;
  43085. private _pressed;
  43086. private _touched;
  43087. /**
  43088. * button component type
  43089. */
  43090. static BUTTON_TYPE: MotionControllerComponentType;
  43091. /**
  43092. * squeeze component type
  43093. */
  43094. static SQUEEZE_TYPE: MotionControllerComponentType;
  43095. /**
  43096. * Thumbstick component type
  43097. */
  43098. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43099. /**
  43100. * Touchpad component type
  43101. */
  43102. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43103. /**
  43104. * trigger component type
  43105. */
  43106. static TRIGGER_TYPE: MotionControllerComponentType;
  43107. /**
  43108. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43109. * the axes data changes
  43110. */
  43111. onAxisValueChangedObservable: Observable<{
  43112. x: number;
  43113. y: number;
  43114. }>;
  43115. /**
  43116. * Observers registered here will be triggered when the state of a button changes
  43117. * State change is either pressed / touched / value
  43118. */
  43119. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43120. /**
  43121. * Creates a new component for a motion controller.
  43122. * It is created by the motion controller itself
  43123. *
  43124. * @param id the id of this component
  43125. * @param type the type of the component
  43126. * @param _buttonIndex index in the buttons array of the gamepad
  43127. * @param _axesIndices indices of the values in the axes array of the gamepad
  43128. */
  43129. constructor(
  43130. /**
  43131. * the id of this component
  43132. */
  43133. id: string,
  43134. /**
  43135. * the type of the component
  43136. */
  43137. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43138. /**
  43139. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43140. */
  43141. get axes(): IWebXRMotionControllerAxesValue;
  43142. /**
  43143. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43144. */
  43145. get changes(): IWebXRMotionControllerComponentChanges;
  43146. /**
  43147. * Return whether or not the component changed the last frame
  43148. */
  43149. get hasChanges(): boolean;
  43150. /**
  43151. * is the button currently pressed
  43152. */
  43153. get pressed(): boolean;
  43154. /**
  43155. * is the button currently touched
  43156. */
  43157. get touched(): boolean;
  43158. /**
  43159. * Get the current value of this component
  43160. */
  43161. get value(): number;
  43162. /**
  43163. * Dispose this component
  43164. */
  43165. dispose(): void;
  43166. /**
  43167. * Are there axes correlating to this component
  43168. * @return true is axes data is available
  43169. */
  43170. isAxes(): boolean;
  43171. /**
  43172. * Is this component a button (hence - pressable)
  43173. * @returns true if can be pressed
  43174. */
  43175. isButton(): boolean;
  43176. /**
  43177. * update this component using the gamepad object it is in. Called on every frame
  43178. * @param nativeController the native gamepad controller object
  43179. */
  43180. update(nativeController: IMinimalMotionControllerObject): void;
  43181. }
  43182. }
  43183. declare module BABYLON {
  43184. /**
  43185. * Class used to represent data loading progression
  43186. */
  43187. export class SceneLoaderProgressEvent {
  43188. /** defines if data length to load can be evaluated */
  43189. readonly lengthComputable: boolean;
  43190. /** defines the loaded data length */
  43191. readonly loaded: number;
  43192. /** defines the data length to load */
  43193. readonly total: number;
  43194. /**
  43195. * Create a new progress event
  43196. * @param lengthComputable defines if data length to load can be evaluated
  43197. * @param loaded defines the loaded data length
  43198. * @param total defines the data length to load
  43199. */
  43200. constructor(
  43201. /** defines if data length to load can be evaluated */
  43202. lengthComputable: boolean,
  43203. /** defines the loaded data length */
  43204. loaded: number,
  43205. /** defines the data length to load */
  43206. total: number);
  43207. /**
  43208. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43209. * @param event defines the source event
  43210. * @returns a new SceneLoaderProgressEvent
  43211. */
  43212. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43213. }
  43214. /**
  43215. * Interface used by SceneLoader plugins to define supported file extensions
  43216. */
  43217. export interface ISceneLoaderPluginExtensions {
  43218. /**
  43219. * Defines the list of supported extensions
  43220. */
  43221. [extension: string]: {
  43222. isBinary: boolean;
  43223. };
  43224. }
  43225. /**
  43226. * Interface used by SceneLoader plugin factory
  43227. */
  43228. export interface ISceneLoaderPluginFactory {
  43229. /**
  43230. * Defines the name of the factory
  43231. */
  43232. name: string;
  43233. /**
  43234. * Function called to create a new plugin
  43235. * @return the new plugin
  43236. */
  43237. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43238. /**
  43239. * The callback that returns true if the data can be directly loaded.
  43240. * @param data string containing the file data
  43241. * @returns if the data can be loaded directly
  43242. */
  43243. canDirectLoad?(data: string): boolean;
  43244. }
  43245. /**
  43246. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43247. */
  43248. export interface ISceneLoaderPluginBase {
  43249. /**
  43250. * The friendly name of this plugin.
  43251. */
  43252. name: string;
  43253. /**
  43254. * The file extensions supported by this plugin.
  43255. */
  43256. extensions: string | ISceneLoaderPluginExtensions;
  43257. /**
  43258. * The callback called when loading from a url.
  43259. * @param scene scene loading this url
  43260. * @param url url to load
  43261. * @param onSuccess callback called when the file successfully loads
  43262. * @param onProgress callback called while file is loading (if the server supports this mode)
  43263. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43264. * @param onError callback called when the file fails to load
  43265. * @returns a file request object
  43266. */
  43267. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43268. /**
  43269. * The callback called when loading from a file object.
  43270. * @param scene scene loading this file
  43271. * @param file defines the file to load
  43272. * @param onSuccess defines the callback to call when data is loaded
  43273. * @param onProgress defines the callback to call during loading process
  43274. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43275. * @param onError defines the callback to call when an error occurs
  43276. * @returns a file request object
  43277. */
  43278. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43279. /**
  43280. * The callback that returns true if the data can be directly loaded.
  43281. * @param data string containing the file data
  43282. * @returns if the data can be loaded directly
  43283. */
  43284. canDirectLoad?(data: string): boolean;
  43285. /**
  43286. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43287. * @param scene scene loading this data
  43288. * @param data string containing the data
  43289. * @returns data to pass to the plugin
  43290. */
  43291. directLoad?(scene: Scene, data: string): any;
  43292. /**
  43293. * The callback that allows custom handling of the root url based on the response url.
  43294. * @param rootUrl the original root url
  43295. * @param responseURL the response url if available
  43296. * @returns the new root url
  43297. */
  43298. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43299. }
  43300. /**
  43301. * Interface used to define a SceneLoader plugin
  43302. */
  43303. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43304. /**
  43305. * Import meshes into a scene.
  43306. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43307. * @param scene The scene to import into
  43308. * @param data The data to import
  43309. * @param rootUrl The root url for scene and resources
  43310. * @param meshes The meshes array to import into
  43311. * @param particleSystems The particle systems array to import into
  43312. * @param skeletons The skeletons array to import into
  43313. * @param onError The callback when import fails
  43314. * @returns True if successful or false otherwise
  43315. */
  43316. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43317. /**
  43318. * Load into a scene.
  43319. * @param scene The scene to load into
  43320. * @param data The data to import
  43321. * @param rootUrl The root url for scene and resources
  43322. * @param onError The callback when import fails
  43323. * @returns True if successful or false otherwise
  43324. */
  43325. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43326. /**
  43327. * Load into an asset container.
  43328. * @param scene The scene to load into
  43329. * @param data The data to import
  43330. * @param rootUrl The root url for scene and resources
  43331. * @param onError The callback when import fails
  43332. * @returns The loaded asset container
  43333. */
  43334. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43335. }
  43336. /**
  43337. * Interface used to define an async SceneLoader plugin
  43338. */
  43339. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43340. /**
  43341. * Import meshes into a scene.
  43342. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43343. * @param scene The scene to import into
  43344. * @param data The data to import
  43345. * @param rootUrl The root url for scene and resources
  43346. * @param onProgress The callback when the load progresses
  43347. * @param fileName Defines the name of the file to load
  43348. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43349. */
  43350. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43351. meshes: AbstractMesh[];
  43352. particleSystems: IParticleSystem[];
  43353. skeletons: Skeleton[];
  43354. animationGroups: AnimationGroup[];
  43355. }>;
  43356. /**
  43357. * Load into a scene.
  43358. * @param scene The scene to load into
  43359. * @param data The data to import
  43360. * @param rootUrl The root url for scene and resources
  43361. * @param onProgress The callback when the load progresses
  43362. * @param fileName Defines the name of the file to load
  43363. * @returns Nothing
  43364. */
  43365. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43366. /**
  43367. * Load into an asset container.
  43368. * @param scene The scene to load into
  43369. * @param data The data to import
  43370. * @param rootUrl The root url for scene and resources
  43371. * @param onProgress The callback when the load progresses
  43372. * @param fileName Defines the name of the file to load
  43373. * @returns The loaded asset container
  43374. */
  43375. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43376. }
  43377. /**
  43378. * Mode that determines how to handle old animation groups before loading new ones.
  43379. */
  43380. export enum SceneLoaderAnimationGroupLoadingMode {
  43381. /**
  43382. * Reset all old animations to initial state then dispose them.
  43383. */
  43384. Clean = 0,
  43385. /**
  43386. * Stop all old animations.
  43387. */
  43388. Stop = 1,
  43389. /**
  43390. * Restart old animations from first frame.
  43391. */
  43392. Sync = 2,
  43393. /**
  43394. * Old animations remains untouched.
  43395. */
  43396. NoSync = 3
  43397. }
  43398. /**
  43399. * Class used to load scene from various file formats using registered plugins
  43400. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43401. */
  43402. export class SceneLoader {
  43403. /**
  43404. * No logging while loading
  43405. */
  43406. static readonly NO_LOGGING: number;
  43407. /**
  43408. * Minimal logging while loading
  43409. */
  43410. static readonly MINIMAL_LOGGING: number;
  43411. /**
  43412. * Summary logging while loading
  43413. */
  43414. static readonly SUMMARY_LOGGING: number;
  43415. /**
  43416. * Detailled logging while loading
  43417. */
  43418. static readonly DETAILED_LOGGING: number;
  43419. /**
  43420. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43421. */
  43422. static get ForceFullSceneLoadingForIncremental(): boolean;
  43423. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43424. /**
  43425. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43426. */
  43427. static get ShowLoadingScreen(): boolean;
  43428. static set ShowLoadingScreen(value: boolean);
  43429. /**
  43430. * Defines the current logging level (while loading the scene)
  43431. * @ignorenaming
  43432. */
  43433. static get loggingLevel(): number;
  43434. static set loggingLevel(value: number);
  43435. /**
  43436. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43437. */
  43438. static get CleanBoneMatrixWeights(): boolean;
  43439. static set CleanBoneMatrixWeights(value: boolean);
  43440. /**
  43441. * Event raised when a plugin is used to load a scene
  43442. */
  43443. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43444. private static _registeredPlugins;
  43445. private static _getDefaultPlugin;
  43446. private static _getPluginForExtension;
  43447. private static _getPluginForDirectLoad;
  43448. private static _getPluginForFilename;
  43449. private static _getDirectLoad;
  43450. private static _loadData;
  43451. private static _getFileInfo;
  43452. /**
  43453. * Gets a plugin that can load the given extension
  43454. * @param extension defines the extension to load
  43455. * @returns a plugin or null if none works
  43456. */
  43457. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43458. /**
  43459. * Gets a boolean indicating that the given extension can be loaded
  43460. * @param extension defines the extension to load
  43461. * @returns true if the extension is supported
  43462. */
  43463. static IsPluginForExtensionAvailable(extension: string): boolean;
  43464. /**
  43465. * Adds a new plugin to the list of registered plugins
  43466. * @param plugin defines the plugin to add
  43467. */
  43468. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43469. /**
  43470. * Import meshes into a scene
  43471. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43472. * @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)
  43473. * @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)
  43474. * @param scene the instance of BABYLON.Scene to append to
  43475. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43476. * @param onProgress a callback with a progress event for each file being loaded
  43477. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43478. * @param pluginExtension the extension used to determine the plugin
  43479. * @returns The loaded plugin
  43480. */
  43481. 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>;
  43482. /**
  43483. * Import meshes into a scene
  43484. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43485. * @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)
  43486. * @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)
  43487. * @param scene the instance of BABYLON.Scene to append to
  43488. * @param onProgress a callback with a progress event for each file being loaded
  43489. * @param pluginExtension the extension used to determine the plugin
  43490. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43491. */
  43492. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43493. meshes: AbstractMesh[];
  43494. particleSystems: IParticleSystem[];
  43495. skeletons: Skeleton[];
  43496. animationGroups: AnimationGroup[];
  43497. }>;
  43498. /**
  43499. * Load a scene
  43500. * @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)
  43501. * @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)
  43502. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43503. * @param onSuccess a callback with the scene when import succeeds
  43504. * @param onProgress a callback with a progress event for each file being loaded
  43505. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43506. * @param pluginExtension the extension used to determine the plugin
  43507. * @returns The loaded plugin
  43508. */
  43509. 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>;
  43510. /**
  43511. * Load a scene
  43512. * @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)
  43513. * @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)
  43514. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43515. * @param onProgress a callback with a progress event for each file being loaded
  43516. * @param pluginExtension the extension used to determine the plugin
  43517. * @returns The loaded scene
  43518. */
  43519. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43520. /**
  43521. * Append a scene
  43522. * @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)
  43523. * @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)
  43524. * @param scene is the instance of BABYLON.Scene to append to
  43525. * @param onSuccess a callback with the scene when import succeeds
  43526. * @param onProgress a callback with a progress event for each file being loaded
  43527. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43528. * @param pluginExtension the extension used to determine the plugin
  43529. * @returns The loaded plugin
  43530. */
  43531. 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>;
  43532. /**
  43533. * Append a scene
  43534. * @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)
  43535. * @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)
  43536. * @param scene is the instance of BABYLON.Scene to append to
  43537. * @param onProgress a callback with a progress event for each file being loaded
  43538. * @param pluginExtension the extension used to determine the plugin
  43539. * @returns The given scene
  43540. */
  43541. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43542. /**
  43543. * Load a scene into an asset container
  43544. * @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)
  43545. * @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)
  43546. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43547. * @param onSuccess a callback with the scene when import succeeds
  43548. * @param onProgress a callback with a progress event for each file being loaded
  43549. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43550. * @param pluginExtension the extension used to determine the plugin
  43551. * @returns The loaded plugin
  43552. */
  43553. 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>;
  43554. /**
  43555. * Load a scene into an asset container
  43556. * @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)
  43557. * @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)
  43558. * @param scene is the instance of Scene to append to
  43559. * @param onProgress a callback with a progress event for each file being loaded
  43560. * @param pluginExtension the extension used to determine the plugin
  43561. * @returns The loaded asset container
  43562. */
  43563. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43564. /**
  43565. * Import animations from a file into a scene
  43566. * @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)
  43567. * @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)
  43568. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43569. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43570. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43571. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43572. * @param onSuccess a callback with the scene when import succeeds
  43573. * @param onProgress a callback with a progress event for each file being loaded
  43574. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43575. */
  43576. 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;
  43577. /**
  43578. * Import animations from a file into a scene
  43579. * @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)
  43580. * @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)
  43581. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43582. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43583. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43584. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43585. * @param onSuccess a callback with the scene when import succeeds
  43586. * @param onProgress a callback with a progress event for each file being loaded
  43587. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43588. * @returns the updated scene with imported animations
  43589. */
  43590. 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>;
  43591. }
  43592. }
  43593. declare module BABYLON {
  43594. /**
  43595. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43596. */
  43597. export type MotionControllerHandness = "none" | "left" | "right";
  43598. /**
  43599. * The type of components available in motion controllers.
  43600. * This is not the name of the component.
  43601. */
  43602. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43603. /**
  43604. * The state of a controller component
  43605. */
  43606. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43607. /**
  43608. * The schema of motion controller layout.
  43609. * No object will be initialized using this interface
  43610. * This is used just to define the profile.
  43611. */
  43612. export interface IMotionControllerLayout {
  43613. /**
  43614. * Path to load the assets. Usually relative to the base path
  43615. */
  43616. assetPath: string;
  43617. /**
  43618. * Available components (unsorted)
  43619. */
  43620. components: {
  43621. /**
  43622. * A map of component Ids
  43623. */
  43624. [componentId: string]: {
  43625. /**
  43626. * The type of input the component outputs
  43627. */
  43628. type: MotionControllerComponentType;
  43629. /**
  43630. * The indices of this component in the gamepad object
  43631. */
  43632. gamepadIndices: {
  43633. /**
  43634. * Index of button
  43635. */
  43636. button?: number;
  43637. /**
  43638. * If available, index of x-axis
  43639. */
  43640. xAxis?: number;
  43641. /**
  43642. * If available, index of y-axis
  43643. */
  43644. yAxis?: number;
  43645. };
  43646. /**
  43647. * The mesh's root node name
  43648. */
  43649. rootNodeName: string;
  43650. /**
  43651. * Animation definitions for this model
  43652. */
  43653. visualResponses: {
  43654. [stateKey: string]: {
  43655. /**
  43656. * What property will be animated
  43657. */
  43658. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43659. /**
  43660. * What states influence this visual response
  43661. */
  43662. states: MotionControllerComponentStateType[];
  43663. /**
  43664. * Type of animation - movement or visibility
  43665. */
  43666. valueNodeProperty: "transform" | "visibility";
  43667. /**
  43668. * Base node name to move. Its position will be calculated according to the min and max nodes
  43669. */
  43670. valueNodeName?: string;
  43671. /**
  43672. * Minimum movement node
  43673. */
  43674. minNodeName?: string;
  43675. /**
  43676. * Max movement node
  43677. */
  43678. maxNodeName?: string;
  43679. };
  43680. };
  43681. /**
  43682. * If touch enabled, what is the name of node to display user feedback
  43683. */
  43684. touchPointNodeName?: string;
  43685. };
  43686. };
  43687. /**
  43688. * Is it xr standard mapping or not
  43689. */
  43690. gamepadMapping: "" | "xr-standard";
  43691. /**
  43692. * Base root node of this entire model
  43693. */
  43694. rootNodeName: string;
  43695. /**
  43696. * Defines the main button component id
  43697. */
  43698. selectComponentId: string;
  43699. }
  43700. /**
  43701. * A definition for the layout map in the input profile
  43702. */
  43703. export interface IMotionControllerLayoutMap {
  43704. /**
  43705. * Layouts with handness type as a key
  43706. */
  43707. [handness: string]: IMotionControllerLayout;
  43708. }
  43709. /**
  43710. * The XR Input profile schema
  43711. * Profiles can be found here:
  43712. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43713. */
  43714. export interface IMotionControllerProfile {
  43715. /**
  43716. * fallback profiles for this profileId
  43717. */
  43718. fallbackProfileIds: string[];
  43719. /**
  43720. * The layout map, with handness as key
  43721. */
  43722. layouts: IMotionControllerLayoutMap;
  43723. /**
  43724. * The id of this profile
  43725. * correlates to the profile(s) in the xrInput.profiles array
  43726. */
  43727. profileId: string;
  43728. }
  43729. /**
  43730. * A helper-interface for the 3 meshes needed for controller button animation
  43731. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43732. */
  43733. export interface IMotionControllerButtonMeshMap {
  43734. /**
  43735. * the mesh that defines the pressed value mesh position.
  43736. * This is used to find the max-position of this button
  43737. */
  43738. pressedMesh: AbstractMesh;
  43739. /**
  43740. * the mesh that defines the unpressed value mesh position.
  43741. * This is used to find the min (or initial) position of this button
  43742. */
  43743. unpressedMesh: AbstractMesh;
  43744. /**
  43745. * The mesh that will be changed when value changes
  43746. */
  43747. valueMesh: AbstractMesh;
  43748. }
  43749. /**
  43750. * A helper-interface for the 3 meshes needed for controller axis animation.
  43751. * This will be expanded when touchpad animations are fully supported
  43752. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43753. */
  43754. export interface IMotionControllerMeshMap {
  43755. /**
  43756. * the mesh that defines the maximum value mesh position.
  43757. */
  43758. maxMesh?: AbstractMesh;
  43759. /**
  43760. * the mesh that defines the minimum value mesh position.
  43761. */
  43762. minMesh?: AbstractMesh;
  43763. /**
  43764. * The mesh that will be changed when axis value changes
  43765. */
  43766. valueMesh: AbstractMesh;
  43767. }
  43768. /**
  43769. * The elements needed for change-detection of the gamepad objects in motion controllers
  43770. */
  43771. export interface IMinimalMotionControllerObject {
  43772. /**
  43773. * Available axes of this controller
  43774. */
  43775. axes: number[];
  43776. /**
  43777. * An array of available buttons
  43778. */
  43779. buttons: Array<{
  43780. /**
  43781. * Value of the button/trigger
  43782. */
  43783. value: number;
  43784. /**
  43785. * If the button/trigger is currently touched
  43786. */
  43787. touched: boolean;
  43788. /**
  43789. * If the button/trigger is currently pressed
  43790. */
  43791. pressed: boolean;
  43792. }>;
  43793. }
  43794. /**
  43795. * An Abstract Motion controller
  43796. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43797. * Each component has an observable to check for changes in value and state
  43798. */
  43799. export abstract class WebXRAbstractMotionController implements IDisposable {
  43800. protected scene: Scene;
  43801. protected layout: IMotionControllerLayout;
  43802. /**
  43803. * The gamepad object correlating to this controller
  43804. */
  43805. gamepadObject: IMinimalMotionControllerObject;
  43806. /**
  43807. * handness (left/right/none) of this controller
  43808. */
  43809. handness: MotionControllerHandness;
  43810. private _initComponent;
  43811. private _modelReady;
  43812. /**
  43813. * A map of components (WebXRControllerComponent) in this motion controller
  43814. * Components have a ComponentType and can also have both button and axis definitions
  43815. */
  43816. readonly components: {
  43817. [id: string]: WebXRControllerComponent;
  43818. };
  43819. /**
  43820. * Disable the model's animation. Can be set at any time.
  43821. */
  43822. disableAnimation: boolean;
  43823. /**
  43824. * Observers registered here will be triggered when the model of this controller is done loading
  43825. */
  43826. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43827. /**
  43828. * The profile id of this motion controller
  43829. */
  43830. abstract profileId: string;
  43831. /**
  43832. * The root mesh of the model. It is null if the model was not yet initialized
  43833. */
  43834. rootMesh: Nullable<AbstractMesh>;
  43835. /**
  43836. * constructs a new abstract motion controller
  43837. * @param scene the scene to which the model of the controller will be added
  43838. * @param layout The profile layout to load
  43839. * @param gamepadObject The gamepad object correlating to this controller
  43840. * @param handness handness (left/right/none) of this controller
  43841. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43842. */
  43843. constructor(scene: Scene, layout: IMotionControllerLayout,
  43844. /**
  43845. * The gamepad object correlating to this controller
  43846. */
  43847. gamepadObject: IMinimalMotionControllerObject,
  43848. /**
  43849. * handness (left/right/none) of this controller
  43850. */
  43851. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43852. /**
  43853. * Dispose this controller, the model mesh and all its components
  43854. */
  43855. dispose(): void;
  43856. /**
  43857. * Returns all components of specific type
  43858. * @param type the type to search for
  43859. * @return an array of components with this type
  43860. */
  43861. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43862. /**
  43863. * get a component based an its component id as defined in layout.components
  43864. * @param id the id of the component
  43865. * @returns the component correlates to the id or undefined if not found
  43866. */
  43867. getComponent(id: string): WebXRControllerComponent;
  43868. /**
  43869. * Get the list of components available in this motion controller
  43870. * @returns an array of strings correlating to available components
  43871. */
  43872. getComponentIds(): string[];
  43873. /**
  43874. * Get the first component of specific type
  43875. * @param type type of component to find
  43876. * @return a controller component or null if not found
  43877. */
  43878. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43879. /**
  43880. * Get the main (Select) component of this controller as defined in the layout
  43881. * @returns the main component of this controller
  43882. */
  43883. getMainComponent(): WebXRControllerComponent;
  43884. /**
  43885. * Loads the model correlating to this controller
  43886. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43887. * @returns A promise fulfilled with the result of the model loading
  43888. */
  43889. loadModel(): Promise<boolean>;
  43890. /**
  43891. * Update this model using the current XRFrame
  43892. * @param xrFrame the current xr frame to use and update the model
  43893. */
  43894. updateFromXRFrame(xrFrame: XRFrame): void;
  43895. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43896. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43897. /**
  43898. * Moves the axis on the controller mesh based on its current state
  43899. * @param axis the index of the axis
  43900. * @param axisValue the value of the axis which determines the meshes new position
  43901. * @hidden
  43902. */
  43903. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43904. /**
  43905. * Update the model itself with the current frame data
  43906. * @param xrFrame the frame to use for updating the model mesh
  43907. */
  43908. protected updateModel(xrFrame: XRFrame): void;
  43909. /**
  43910. * Get the filename and path for this controller's model
  43911. * @returns a map of filename and path
  43912. */
  43913. protected abstract _getFilenameAndPath(): {
  43914. filename: string;
  43915. path: string;
  43916. };
  43917. /**
  43918. * This function is called before the mesh is loaded. It checks for loading constraints.
  43919. * For example, this function can check if the GLB loader is available
  43920. * If this function returns false, the generic controller will be loaded instead
  43921. * @returns Is the client ready to load the mesh
  43922. */
  43923. protected abstract _getModelLoadingConstraints(): boolean;
  43924. /**
  43925. * This function will be called after the model was successfully loaded and can be used
  43926. * for mesh transformations before it is available for the user
  43927. * @param meshes the loaded meshes
  43928. */
  43929. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43930. /**
  43931. * Set the root mesh for this controller. Important for the WebXR controller class
  43932. * @param meshes the loaded meshes
  43933. */
  43934. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43935. /**
  43936. * A function executed each frame that updates the mesh (if needed)
  43937. * @param xrFrame the current xrFrame
  43938. */
  43939. protected abstract _updateModel(xrFrame: XRFrame): void;
  43940. private _getGenericFilenameAndPath;
  43941. private _getGenericParentMesh;
  43942. }
  43943. }
  43944. declare module BABYLON {
  43945. /**
  43946. * A generic trigger-only motion controller for WebXR
  43947. */
  43948. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43949. /**
  43950. * Static version of the profile id of this controller
  43951. */
  43952. static ProfileId: string;
  43953. profileId: string;
  43954. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43955. protected _getFilenameAndPath(): {
  43956. filename: string;
  43957. path: string;
  43958. };
  43959. protected _getModelLoadingConstraints(): boolean;
  43960. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43961. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43962. protected _updateModel(): void;
  43963. }
  43964. }
  43965. declare module BABYLON {
  43966. /**
  43967. * Class containing static functions to help procedurally build meshes
  43968. */
  43969. export class SphereBuilder {
  43970. /**
  43971. * Creates a sphere mesh
  43972. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43973. * * 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`)
  43974. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43975. * * 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
  43976. * * 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)
  43977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43978. * * 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
  43979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43980. * @param name defines the name of the mesh
  43981. * @param options defines the options used to create the mesh
  43982. * @param scene defines the hosting scene
  43983. * @returns the sphere mesh
  43984. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43985. */
  43986. static CreateSphere(name: string, options: {
  43987. segments?: number;
  43988. diameter?: number;
  43989. diameterX?: number;
  43990. diameterY?: number;
  43991. diameterZ?: number;
  43992. arc?: number;
  43993. slice?: number;
  43994. sideOrientation?: number;
  43995. frontUVs?: Vector4;
  43996. backUVs?: Vector4;
  43997. updatable?: boolean;
  43998. }, scene?: Nullable<Scene>): Mesh;
  43999. }
  44000. }
  44001. declare module BABYLON {
  44002. /**
  44003. * A profiled motion controller has its profile loaded from an online repository.
  44004. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44005. */
  44006. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44007. private _repositoryUrl;
  44008. private _buttonMeshMapping;
  44009. private _touchDots;
  44010. /**
  44011. * The profile ID of this controller. Will be populated when the controller initializes.
  44012. */
  44013. profileId: string;
  44014. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44015. dispose(): void;
  44016. protected _getFilenameAndPath(): {
  44017. filename: string;
  44018. path: string;
  44019. };
  44020. protected _getModelLoadingConstraints(): boolean;
  44021. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44022. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44023. protected _updateModel(_xrFrame: XRFrame): void;
  44024. }
  44025. }
  44026. declare module BABYLON {
  44027. /**
  44028. * A construction function type to create a new controller based on an xrInput object
  44029. */
  44030. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44031. /**
  44032. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44033. *
  44034. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44035. * it should be replaced with auto-loaded controllers.
  44036. *
  44037. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44038. */
  44039. export class WebXRMotionControllerManager {
  44040. private static _AvailableControllers;
  44041. private static _Fallbacks;
  44042. private static _ProfileLoadingPromises;
  44043. private static _ProfilesList;
  44044. /**
  44045. * The base URL of the online controller repository. Can be changed at any time.
  44046. */
  44047. static BaseRepositoryUrl: string;
  44048. /**
  44049. * Which repository gets priority - local or online
  44050. */
  44051. static PrioritizeOnlineRepository: boolean;
  44052. /**
  44053. * Use the online repository, or use only locally-defined controllers
  44054. */
  44055. static UseOnlineRepository: boolean;
  44056. /**
  44057. * Clear the cache used for profile loading and reload when requested again
  44058. */
  44059. static ClearProfilesCache(): void;
  44060. /**
  44061. * Register the default fallbacks.
  44062. * This function is called automatically when this file is imported.
  44063. */
  44064. static DefaultFallbacks(): void;
  44065. /**
  44066. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44067. * @param profileId the profile to which a fallback needs to be found
  44068. * @return an array with corresponding fallback profiles
  44069. */
  44070. static FindFallbackWithProfileId(profileId: string): string[];
  44071. /**
  44072. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44073. * The order of search:
  44074. *
  44075. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44076. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44077. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44078. * 4) return the generic trigger controller if none were found
  44079. *
  44080. * @param xrInput the xrInput to which a new controller is initialized
  44081. * @param scene the scene to which the model will be added
  44082. * @param forceProfile force a certain profile for this controller
  44083. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44084. */
  44085. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44086. /**
  44087. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44088. *
  44089. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44090. *
  44091. * @param type the profile type to register
  44092. * @param constructFunction the function to be called when loading this profile
  44093. */
  44094. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44095. /**
  44096. * Register a fallback to a specific profile.
  44097. * @param profileId the profileId that will receive the fallbacks
  44098. * @param fallbacks A list of fallback profiles
  44099. */
  44100. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44101. /**
  44102. * Will update the list of profiles available in the repository
  44103. * @return a promise that resolves to a map of profiles available online
  44104. */
  44105. static UpdateProfilesList(): Promise<{
  44106. [profile: string]: string;
  44107. }>;
  44108. private static _LoadProfileFromRepository;
  44109. private static _LoadProfilesFromAvailableControllers;
  44110. }
  44111. }
  44112. declare module BABYLON {
  44113. /**
  44114. * Configuration options for the WebXR controller creation
  44115. */
  44116. export interface IWebXRControllerOptions {
  44117. /**
  44118. * Should the controller mesh be animated when a user interacts with it
  44119. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44120. */
  44121. disableMotionControllerAnimation?: boolean;
  44122. /**
  44123. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44124. */
  44125. doNotLoadControllerMesh?: boolean;
  44126. /**
  44127. * Force a specific controller type for this controller.
  44128. * This can be used when creating your own profile or when testing different controllers
  44129. */
  44130. forceControllerProfile?: string;
  44131. }
  44132. /**
  44133. * Represents an XR controller
  44134. */
  44135. export class WebXRInputSource {
  44136. private _scene;
  44137. /** The underlying input source for the controller */
  44138. inputSource: XRInputSource;
  44139. private _options;
  44140. private _tmpQuaternion;
  44141. private _tmpVector;
  44142. private _uniqueId;
  44143. /**
  44144. * 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
  44145. */
  44146. grip?: AbstractMesh;
  44147. /**
  44148. * If available, this is the gamepad object related to this controller.
  44149. * Using this object it is possible to get click events and trackpad changes of the
  44150. * webxr controller that is currently being used.
  44151. */
  44152. motionController?: WebXRAbstractMotionController;
  44153. /**
  44154. * Event that fires when the controller is removed/disposed.
  44155. * The object provided as event data is this controller, after associated assets were disposed.
  44156. * uniqueId is still available.
  44157. */
  44158. onDisposeObservable: Observable<WebXRInputSource>;
  44159. /**
  44160. * Will be triggered when the mesh associated with the motion controller is done loading.
  44161. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44162. * A shortened version of controller -> motion controller -> on mesh loaded.
  44163. */
  44164. onMeshLoadedObservable: Observable<AbstractMesh>;
  44165. /**
  44166. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44167. */
  44168. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44169. /**
  44170. * Pointer which can be used to select objects or attach a visible laser to
  44171. */
  44172. pointer: AbstractMesh;
  44173. /**
  44174. * Creates the controller
  44175. * @see https://doc.babylonjs.com/how_to/webxr
  44176. * @param _scene the scene which the controller should be associated to
  44177. * @param inputSource the underlying input source for the controller
  44178. * @param _options options for this controller creation
  44179. */
  44180. constructor(_scene: Scene,
  44181. /** The underlying input source for the controller */
  44182. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44183. /**
  44184. * Get this controllers unique id
  44185. */
  44186. get uniqueId(): string;
  44187. /**
  44188. * Disposes of the object
  44189. */
  44190. dispose(): void;
  44191. /**
  44192. * Gets a world space ray coming from the pointer or grip
  44193. * @param result the resulting ray
  44194. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44195. */
  44196. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44197. /**
  44198. * Updates the controller pose based on the given XRFrame
  44199. * @param xrFrame xr frame to update the pose with
  44200. * @param referenceSpace reference space to use
  44201. */
  44202. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44203. }
  44204. }
  44205. declare module BABYLON {
  44206. /**
  44207. * The schema for initialization options of the XR Input class
  44208. */
  44209. export interface IWebXRInputOptions {
  44210. /**
  44211. * If set to true no model will be automatically loaded
  44212. */
  44213. doNotLoadControllerMeshes?: boolean;
  44214. /**
  44215. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44216. * If not found, the xr input profile data will be used.
  44217. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44218. */
  44219. forceInputProfile?: string;
  44220. /**
  44221. * Do not send a request to the controller repository to load the profile.
  44222. *
  44223. * Instead, use the controllers available in babylon itself.
  44224. */
  44225. disableOnlineControllerRepository?: boolean;
  44226. /**
  44227. * A custom URL for the controllers repository
  44228. */
  44229. customControllersRepositoryURL?: string;
  44230. /**
  44231. * Should the controller model's components not move according to the user input
  44232. */
  44233. disableControllerAnimation?: boolean;
  44234. }
  44235. /**
  44236. * XR input used to track XR inputs such as controllers/rays
  44237. */
  44238. export class WebXRInput implements IDisposable {
  44239. /**
  44240. * the xr session manager for this session
  44241. */
  44242. xrSessionManager: WebXRSessionManager;
  44243. /**
  44244. * the WebXR camera for this session. Mainly used for teleportation
  44245. */
  44246. xrCamera: WebXRCamera;
  44247. private readonly options;
  44248. /**
  44249. * XR controllers being tracked
  44250. */
  44251. controllers: Array<WebXRInputSource>;
  44252. private _frameObserver;
  44253. private _sessionEndedObserver;
  44254. private _sessionInitObserver;
  44255. /**
  44256. * Event when a controller has been connected/added
  44257. */
  44258. onControllerAddedObservable: Observable<WebXRInputSource>;
  44259. /**
  44260. * Event when a controller has been removed/disconnected
  44261. */
  44262. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44263. /**
  44264. * Initializes the WebXRInput
  44265. * @param xrSessionManager the xr session manager for this session
  44266. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44267. * @param options = initialization options for this xr input
  44268. */
  44269. constructor(
  44270. /**
  44271. * the xr session manager for this session
  44272. */
  44273. xrSessionManager: WebXRSessionManager,
  44274. /**
  44275. * the WebXR camera for this session. Mainly used for teleportation
  44276. */
  44277. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44278. private _onInputSourcesChange;
  44279. private _addAndRemoveControllers;
  44280. /**
  44281. * Disposes of the object
  44282. */
  44283. dispose(): void;
  44284. }
  44285. }
  44286. declare module BABYLON {
  44287. /**
  44288. * This is the base class for all WebXR features.
  44289. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44290. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44291. */
  44292. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44293. protected _xrSessionManager: WebXRSessionManager;
  44294. private _attached;
  44295. private _removeOnDetach;
  44296. /**
  44297. * Should auto-attach be disabled?
  44298. */
  44299. disableAutoAttach: boolean;
  44300. /**
  44301. * Construct a new (abstract) WebXR feature
  44302. * @param _xrSessionManager the xr session manager for this feature
  44303. */
  44304. constructor(_xrSessionManager: WebXRSessionManager);
  44305. /**
  44306. * Is this feature attached
  44307. */
  44308. get attached(): boolean;
  44309. /**
  44310. * attach this feature
  44311. *
  44312. * @param force should attachment be forced (even when already attached)
  44313. * @returns true if successful, false is failed or already attached
  44314. */
  44315. attach(force?: boolean): boolean;
  44316. /**
  44317. * detach this feature.
  44318. *
  44319. * @returns true if successful, false if failed or already detached
  44320. */
  44321. detach(): boolean;
  44322. /**
  44323. * Dispose this feature and all of the resources attached
  44324. */
  44325. dispose(): void;
  44326. /**
  44327. * This is used to register callbacks that will automatically be removed when detach is called.
  44328. * @param observable the observable to which the observer will be attached
  44329. * @param callback the callback to register
  44330. */
  44331. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44332. /**
  44333. * Code in this function will be executed on each xrFrame received from the browser.
  44334. * This function will not execute after the feature is detached.
  44335. * @param _xrFrame the current frame
  44336. */
  44337. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44338. }
  44339. }
  44340. declare module BABYLON {
  44341. /**
  44342. * Renders a layer on top of an existing scene
  44343. */
  44344. export class UtilityLayerRenderer implements IDisposable {
  44345. /** the original scene that will be rendered on top of */
  44346. originalScene: Scene;
  44347. private _pointerCaptures;
  44348. private _lastPointerEvents;
  44349. private static _DefaultUtilityLayer;
  44350. private static _DefaultKeepDepthUtilityLayer;
  44351. private _sharedGizmoLight;
  44352. private _renderCamera;
  44353. /**
  44354. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44355. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44356. * @returns the camera that is used when rendering the utility layer
  44357. */
  44358. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44359. /**
  44360. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44361. * @param cam the camera that should be used when rendering the utility layer
  44362. */
  44363. setRenderCamera(cam: Nullable<Camera>): void;
  44364. /**
  44365. * @hidden
  44366. * Light which used by gizmos to get light shading
  44367. */
  44368. _getSharedGizmoLight(): HemisphericLight;
  44369. /**
  44370. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44371. */
  44372. pickUtilitySceneFirst: boolean;
  44373. /**
  44374. * 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)
  44375. */
  44376. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44377. /**
  44378. * 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)
  44379. */
  44380. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44381. /**
  44382. * The scene that is rendered on top of the original scene
  44383. */
  44384. utilityLayerScene: Scene;
  44385. /**
  44386. * If the utility layer should automatically be rendered on top of existing scene
  44387. */
  44388. shouldRender: boolean;
  44389. /**
  44390. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44391. */
  44392. onlyCheckPointerDownEvents: boolean;
  44393. /**
  44394. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44395. */
  44396. processAllEvents: boolean;
  44397. /**
  44398. * Observable raised when the pointer move from the utility layer scene to the main scene
  44399. */
  44400. onPointerOutObservable: Observable<number>;
  44401. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44402. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44403. private _afterRenderObserver;
  44404. private _sceneDisposeObserver;
  44405. private _originalPointerObserver;
  44406. /**
  44407. * Instantiates a UtilityLayerRenderer
  44408. * @param originalScene the original scene that will be rendered on top of
  44409. * @param handleEvents boolean indicating if the utility layer should handle events
  44410. */
  44411. constructor(
  44412. /** the original scene that will be rendered on top of */
  44413. originalScene: Scene, handleEvents?: boolean);
  44414. private _notifyObservers;
  44415. /**
  44416. * Renders the utility layers scene on top of the original scene
  44417. */
  44418. render(): void;
  44419. /**
  44420. * Disposes of the renderer
  44421. */
  44422. dispose(): void;
  44423. private _updateCamera;
  44424. }
  44425. }
  44426. declare module BABYLON {
  44427. /**
  44428. * Options interface for the pointer selection module
  44429. */
  44430. export interface IWebXRControllerPointerSelectionOptions {
  44431. /**
  44432. * if provided, this scene will be used to render meshes.
  44433. */
  44434. customUtilityLayerScene?: Scene;
  44435. /**
  44436. * 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)
  44437. * If not disabled, the last picked point will be used to execute a pointer up event
  44438. * If disabled, pointer up event will be triggered right after the pointer down event.
  44439. * Used in screen and gaze target ray mode only
  44440. */
  44441. disablePointerUpOnTouchOut: boolean;
  44442. /**
  44443. * For gaze mode (time to select instead of press)
  44444. */
  44445. forceGazeMode: boolean;
  44446. /**
  44447. * 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
  44448. * to start a new countdown to the pointer down event.
  44449. * Defaults to 1.
  44450. */
  44451. gazeModePointerMovedFactor?: number;
  44452. /**
  44453. * Different button type to use instead of the main component
  44454. */
  44455. overrideButtonId?: string;
  44456. /**
  44457. * use this rendering group id for the meshes (optional)
  44458. */
  44459. renderingGroupId?: number;
  44460. /**
  44461. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44462. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44463. * 3000 means 3 seconds between pointing at something and selecting it
  44464. */
  44465. timeToSelect?: number;
  44466. /**
  44467. * Should meshes created here be added to a utility layer or the main scene
  44468. */
  44469. useUtilityLayer?: boolean;
  44470. /**
  44471. * the xr input to use with this pointer selection
  44472. */
  44473. xrInput: WebXRInput;
  44474. }
  44475. /**
  44476. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44477. */
  44478. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44479. private readonly _options;
  44480. private static _idCounter;
  44481. private _attachController;
  44482. private _controllers;
  44483. private _scene;
  44484. private _tmpVectorForPickCompare;
  44485. /**
  44486. * The module's name
  44487. */
  44488. static readonly Name: string;
  44489. /**
  44490. * The (Babylon) version of this module.
  44491. * This is an integer representing the implementation version.
  44492. * This number does not correspond to the WebXR specs version
  44493. */
  44494. static readonly Version: number;
  44495. /**
  44496. * Disable lighting on the laser pointer (so it will always be visible)
  44497. */
  44498. disablePointerLighting: boolean;
  44499. /**
  44500. * Disable lighting on the selection mesh (so it will always be visible)
  44501. */
  44502. disableSelectionMeshLighting: boolean;
  44503. /**
  44504. * Should the laser pointer be displayed
  44505. */
  44506. displayLaserPointer: boolean;
  44507. /**
  44508. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44509. */
  44510. displaySelectionMesh: boolean;
  44511. /**
  44512. * This color will be set to the laser pointer when selection is triggered
  44513. */
  44514. laserPointerPickedColor: Color3;
  44515. /**
  44516. * Default color of the laser pointer
  44517. */
  44518. lasterPointerDefaultColor: Color3;
  44519. /**
  44520. * default color of the selection ring
  44521. */
  44522. selectionMeshDefaultColor: Color3;
  44523. /**
  44524. * This color will be applied to the selection ring when selection is triggered
  44525. */
  44526. selectionMeshPickedColor: Color3;
  44527. /**
  44528. * constructs a new background remover module
  44529. * @param _xrSessionManager the session manager for this module
  44530. * @param _options read-only options to be used in this module
  44531. */
  44532. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44533. /**
  44534. * attach this feature
  44535. * Will usually be called by the features manager
  44536. *
  44537. * @returns true if successful.
  44538. */
  44539. attach(): boolean;
  44540. /**
  44541. * detach this feature.
  44542. * Will usually be called by the features manager
  44543. *
  44544. * @returns true if successful.
  44545. */
  44546. detach(): boolean;
  44547. /**
  44548. * Will get the mesh under a specific pointer.
  44549. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44550. * @param controllerId the controllerId to check
  44551. * @returns The mesh under pointer or null if no mesh is under the pointer
  44552. */
  44553. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44554. /**
  44555. * Get the xr controller that correlates to the pointer id in the pointer event
  44556. *
  44557. * @param id the pointer id to search for
  44558. * @returns the controller that correlates to this id or null if not found
  44559. */
  44560. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44561. protected _onXRFrame(_xrFrame: XRFrame): void;
  44562. private _attachGazeMode;
  44563. private _attachScreenRayMode;
  44564. private _attachTrackedPointerRayMode;
  44565. private _convertNormalToDirectionOfRay;
  44566. private _detachController;
  44567. private _generateNewMeshPair;
  44568. private _pickingMoved;
  44569. private _updatePointerDistance;
  44570. }
  44571. }
  44572. declare module BABYLON {
  44573. /**
  44574. * Button which can be used to enter a different mode of XR
  44575. */
  44576. export class WebXREnterExitUIButton {
  44577. /** button element */
  44578. element: HTMLElement;
  44579. /** XR initialization options for the button */
  44580. sessionMode: XRSessionMode;
  44581. /** Reference space type */
  44582. referenceSpaceType: XRReferenceSpaceType;
  44583. /**
  44584. * Creates a WebXREnterExitUIButton
  44585. * @param element button element
  44586. * @param sessionMode XR initialization session mode
  44587. * @param referenceSpaceType the type of reference space to be used
  44588. */
  44589. constructor(
  44590. /** button element */
  44591. element: HTMLElement,
  44592. /** XR initialization options for the button */
  44593. sessionMode: XRSessionMode,
  44594. /** Reference space type */
  44595. referenceSpaceType: XRReferenceSpaceType);
  44596. /**
  44597. * Extendable function which can be used to update the button's visuals when the state changes
  44598. * @param activeButton the current active button in the UI
  44599. */
  44600. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44601. }
  44602. /**
  44603. * Options to create the webXR UI
  44604. */
  44605. export class WebXREnterExitUIOptions {
  44606. /**
  44607. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44608. */
  44609. customButtons?: Array<WebXREnterExitUIButton>;
  44610. /**
  44611. * A reference space type to use when creating the default button.
  44612. * Default is local-floor
  44613. */
  44614. referenceSpaceType?: XRReferenceSpaceType;
  44615. /**
  44616. * Context to enter xr with
  44617. */
  44618. renderTarget?: Nullable<WebXRRenderTarget>;
  44619. /**
  44620. * A session mode to use when creating the default button.
  44621. * Default is immersive-vr
  44622. */
  44623. sessionMode?: XRSessionMode;
  44624. }
  44625. /**
  44626. * UI to allow the user to enter/exit XR mode
  44627. */
  44628. export class WebXREnterExitUI implements IDisposable {
  44629. private scene;
  44630. /** version of the options passed to this UI */
  44631. options: WebXREnterExitUIOptions;
  44632. private _activeButton;
  44633. private _buttons;
  44634. private _overlay;
  44635. /**
  44636. * Fired every time the active button is changed.
  44637. *
  44638. * When xr is entered via a button that launches xr that button will be the callback parameter
  44639. *
  44640. * When exiting xr the callback parameter will be null)
  44641. */
  44642. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44643. /**
  44644. *
  44645. * @param scene babylon scene object to use
  44646. * @param options (read-only) version of the options passed to this UI
  44647. */
  44648. private constructor();
  44649. /**
  44650. * Creates UI to allow the user to enter/exit XR mode
  44651. * @param scene the scene to add the ui to
  44652. * @param helper the xr experience helper to enter/exit xr with
  44653. * @param options options to configure the UI
  44654. * @returns the created ui
  44655. */
  44656. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44657. /**
  44658. * Disposes of the XR UI component
  44659. */
  44660. dispose(): void;
  44661. private _updateButtons;
  44662. }
  44663. }
  44664. declare module BABYLON {
  44665. /**
  44666. * Class containing static functions to help procedurally build meshes
  44667. */
  44668. export class LinesBuilder {
  44669. /**
  44670. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44671. * * 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
  44672. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44673. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44674. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44675. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44676. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44677. * * 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
  44678. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44681. * @param name defines the name of the new line system
  44682. * @param options defines the options used to create the line system
  44683. * @param scene defines the hosting scene
  44684. * @returns a new line system mesh
  44685. */
  44686. static CreateLineSystem(name: string, options: {
  44687. lines: Vector3[][];
  44688. updatable?: boolean;
  44689. instance?: Nullable<LinesMesh>;
  44690. colors?: Nullable<Color4[][]>;
  44691. useVertexAlpha?: boolean;
  44692. }, scene: Nullable<Scene>): LinesMesh;
  44693. /**
  44694. * Creates a line mesh
  44695. * 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
  44696. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44697. * * The parameter `points` is an array successive Vector3
  44698. * * 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
  44699. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44700. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44701. * * When updating an instance, remember that only point positions can change, not the number of points
  44702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44704. * @param name defines the name of the new line system
  44705. * @param options defines the options used to create the line system
  44706. * @param scene defines the hosting scene
  44707. * @returns a new line mesh
  44708. */
  44709. static CreateLines(name: string, options: {
  44710. points: Vector3[];
  44711. updatable?: boolean;
  44712. instance?: Nullable<LinesMesh>;
  44713. colors?: Color4[];
  44714. useVertexAlpha?: boolean;
  44715. }, scene?: Nullable<Scene>): LinesMesh;
  44716. /**
  44717. * Creates a dashed line mesh
  44718. * * 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
  44719. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44720. * * The parameter `points` is an array successive Vector3
  44721. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44722. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44723. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44724. * * 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
  44725. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44726. * * When updating an instance, remember that only point positions can change, not the number of points
  44727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44728. * @param name defines the name of the mesh
  44729. * @param options defines the options used to create the mesh
  44730. * @param scene defines the hosting scene
  44731. * @returns the dashed line mesh
  44732. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44733. */
  44734. static CreateDashedLines(name: string, options: {
  44735. points: Vector3[];
  44736. dashSize?: number;
  44737. gapSize?: number;
  44738. dashNb?: number;
  44739. updatable?: boolean;
  44740. instance?: LinesMesh;
  44741. useVertexAlpha?: boolean;
  44742. }, scene?: Nullable<Scene>): LinesMesh;
  44743. }
  44744. }
  44745. declare module BABYLON {
  44746. /**
  44747. * The options container for the teleportation module
  44748. */
  44749. export interface IWebXRTeleportationOptions {
  44750. /**
  44751. * if provided, this scene will be used to render meshes.
  44752. */
  44753. customUtilityLayerScene?: Scene;
  44754. /**
  44755. * Values to configure the default target mesh
  44756. */
  44757. defaultTargetMeshOptions?: {
  44758. /**
  44759. * Fill color of the teleportation area
  44760. */
  44761. teleportationFillColor?: string;
  44762. /**
  44763. * Border color for the teleportation area
  44764. */
  44765. teleportationBorderColor?: string;
  44766. /**
  44767. * Disable the mesh's animation sequence
  44768. */
  44769. disableAnimation?: boolean;
  44770. /**
  44771. * Disable lighting on the material or the ring and arrow
  44772. */
  44773. disableLighting?: boolean;
  44774. /**
  44775. * Override the default material of the torus and arrow
  44776. */
  44777. torusArrowMaterial?: Material;
  44778. };
  44779. /**
  44780. * A list of meshes to use as floor meshes.
  44781. * Meshes can be added and removed after initializing the feature using the
  44782. * addFloorMesh and removeFloorMesh functions
  44783. * If empty, rotation will still work
  44784. */
  44785. floorMeshes?: AbstractMesh[];
  44786. /**
  44787. * use this rendering group id for the meshes (optional)
  44788. */
  44789. renderingGroupId?: number;
  44790. /**
  44791. * Should teleportation move only to snap points
  44792. */
  44793. snapPointsOnly?: boolean;
  44794. /**
  44795. * An array of points to which the teleportation will snap to.
  44796. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  44797. */
  44798. snapPositions?: Vector3[];
  44799. /**
  44800. * How close should the teleportation ray be in order to snap to position.
  44801. * Default to 0.8 units (meters)
  44802. */
  44803. snapToPositionRadius?: number;
  44804. /**
  44805. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44806. * If you want to support rotation, make sure your mesh has a direction indicator.
  44807. *
  44808. * When left untouched, the default mesh will be initialized.
  44809. */
  44810. teleportationTargetMesh?: AbstractMesh;
  44811. /**
  44812. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  44813. */
  44814. timeToTeleport?: number;
  44815. /**
  44816. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  44817. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  44818. */
  44819. useMainComponentOnly?: boolean;
  44820. /**
  44821. * Should meshes created here be added to a utility layer or the main scene
  44822. */
  44823. useUtilityLayer?: boolean;
  44824. /**
  44825. * Babylon XR Input class for controller
  44826. */
  44827. xrInput: WebXRInput;
  44828. }
  44829. /**
  44830. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  44831. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  44832. * the input of the attached controllers.
  44833. */
  44834. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44835. private _options;
  44836. private _controllers;
  44837. private _currentTeleportationControllerId;
  44838. private _floorMeshes;
  44839. private _quadraticBezierCurve;
  44840. private _selectionFeature;
  44841. private _snapToPositions;
  44842. private _snappedToPoint;
  44843. private _teleportationRingMaterial?;
  44844. private _tmpRay;
  44845. private _tmpVector;
  44846. /**
  44847. * The module's name
  44848. */
  44849. static readonly Name: string;
  44850. /**
  44851. * The (Babylon) version of this module.
  44852. * This is an integer representing the implementation version.
  44853. * This number does not correspond to the webxr specs version
  44854. */
  44855. static readonly Version: number;
  44856. /**
  44857. * Is movement backwards enabled
  44858. */
  44859. backwardsMovementEnabled: boolean;
  44860. /**
  44861. * Distance to travel when moving backwards
  44862. */
  44863. backwardsTeleportationDistance: number;
  44864. /**
  44865. * The distance from the user to the inspection point in the direction of the controller
  44866. * A higher number will allow the user to move further
  44867. * defaults to 5 (meters, in xr units)
  44868. */
  44869. parabolicCheckRadius: number;
  44870. /**
  44871. * Should the module support parabolic ray on top of direct ray
  44872. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44873. * Very helpful when moving between floors / different heights
  44874. */
  44875. parabolicRayEnabled: boolean;
  44876. /**
  44877. * How much rotation should be applied when rotating right and left
  44878. */
  44879. rotationAngle: number;
  44880. /**
  44881. * Is rotation enabled when moving forward?
  44882. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44883. */
  44884. rotationEnabled: boolean;
  44885. /**
  44886. * constructs a new anchor system
  44887. * @param _xrSessionManager an instance of WebXRSessionManager
  44888. * @param _options configuration object for this feature
  44889. */
  44890. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44891. /**
  44892. * Get the snapPointsOnly flag
  44893. */
  44894. get snapPointsOnly(): boolean;
  44895. /**
  44896. * Sets the snapPointsOnly flag
  44897. * @param snapToPoints should teleportation be exclusively to snap points
  44898. */
  44899. set snapPointsOnly(snapToPoints: boolean);
  44900. /**
  44901. * Add a new mesh to the floor meshes array
  44902. * @param mesh the mesh to use as floor mesh
  44903. */
  44904. addFloorMesh(mesh: AbstractMesh): void;
  44905. /**
  44906. * Add a new snap-to point to fix teleportation to this position
  44907. * @param newSnapPoint The new Snap-To point
  44908. */
  44909. addSnapPoint(newSnapPoint: Vector3): void;
  44910. attach(): boolean;
  44911. detach(): boolean;
  44912. dispose(): void;
  44913. /**
  44914. * Remove a mesh from the floor meshes array
  44915. * @param mesh the mesh to remove
  44916. */
  44917. removeFloorMesh(mesh: AbstractMesh): void;
  44918. /**
  44919. * Remove a mesh from the floor meshes array using its name
  44920. * @param name the mesh name to remove
  44921. */
  44922. removeFloorMeshByName(name: string): void;
  44923. /**
  44924. * 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
  44925. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  44926. * @returns was the point found and removed or not
  44927. */
  44928. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  44929. /**
  44930. * This function sets a selection feature that will be disabled when
  44931. * the forward ray is shown and will be reattached when hidden.
  44932. * This is used to remove the selection rays when moving.
  44933. * @param selectionFeature the feature to disable when forward movement is enabled
  44934. */
  44935. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44936. protected _onXRFrame(_xrFrame: XRFrame): void;
  44937. private _attachController;
  44938. private _createDefaultTargetMesh;
  44939. private _detachController;
  44940. private _findClosestSnapPointWithRadius;
  44941. private _setTargetMeshPosition;
  44942. private _setTargetMeshVisibility;
  44943. private _showParabolicPath;
  44944. private _teleportForward;
  44945. }
  44946. }
  44947. declare module BABYLON {
  44948. /**
  44949. * Options for the default xr helper
  44950. */
  44951. export class WebXRDefaultExperienceOptions {
  44952. /**
  44953. * Enable or disable default UI to enter XR
  44954. */
  44955. disableDefaultUI?: boolean;
  44956. /**
  44957. * Should teleportation not initialize. defaults to false.
  44958. */
  44959. disableTeleportation?: boolean;
  44960. /**
  44961. * Floor meshes that will be used for teleport
  44962. */
  44963. floorMeshes?: Array<AbstractMesh>;
  44964. /**
  44965. * If set to true, the first frame will not be used to reset position
  44966. * The first frame is mainly used when copying transformation from the old camera
  44967. * Mainly used in AR
  44968. */
  44969. ignoreNativeCameraTransformation?: boolean;
  44970. /**
  44971. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44972. */
  44973. inputOptions?: IWebXRInputOptions;
  44974. /**
  44975. * optional configuration for the output canvas
  44976. */
  44977. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44978. /**
  44979. * optional UI options. This can be used among other to change session mode and reference space type
  44980. */
  44981. uiOptions?: WebXREnterExitUIOptions;
  44982. /**
  44983. * When loading teleportation and pointer select, use stable versions instead of latest.
  44984. */
  44985. useStablePlugins?: boolean;
  44986. }
  44987. /**
  44988. * Default experience which provides a similar setup to the previous webVRExperience
  44989. */
  44990. export class WebXRDefaultExperience {
  44991. /**
  44992. * Base experience
  44993. */
  44994. baseExperience: WebXRExperienceHelper;
  44995. /**
  44996. * Enables ui for entering/exiting xr
  44997. */
  44998. enterExitUI: WebXREnterExitUI;
  44999. /**
  45000. * Input experience extension
  45001. */
  45002. input: WebXRInput;
  45003. /**
  45004. * Enables laser pointer and selection
  45005. */
  45006. pointerSelection: WebXRControllerPointerSelection;
  45007. /**
  45008. * Default target xr should render to
  45009. */
  45010. renderTarget: WebXRRenderTarget;
  45011. /**
  45012. * Enables teleportation
  45013. */
  45014. teleportation: WebXRMotionControllerTeleportation;
  45015. private constructor();
  45016. /**
  45017. * Creates the default xr experience
  45018. * @param scene scene
  45019. * @param options options for basic configuration
  45020. * @returns resulting WebXRDefaultExperience
  45021. */
  45022. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45023. /**
  45024. * DIsposes of the experience helper
  45025. */
  45026. dispose(): void;
  45027. }
  45028. }
  45029. declare module BABYLON {
  45030. /**
  45031. * Options to modify the vr teleportation behavior.
  45032. */
  45033. export interface VRTeleportationOptions {
  45034. /**
  45035. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45036. */
  45037. floorMeshName?: string;
  45038. /**
  45039. * A list of meshes to be used as the teleportation floor. (default: empty)
  45040. */
  45041. floorMeshes?: Mesh[];
  45042. /**
  45043. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45044. */
  45045. teleportationMode?: number;
  45046. /**
  45047. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45048. */
  45049. teleportationTime?: number;
  45050. /**
  45051. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45052. */
  45053. teleportationSpeed?: number;
  45054. /**
  45055. * The easing function used in the animation or null for Linear. (default CircleEase)
  45056. */
  45057. easingFunction?: EasingFunction;
  45058. }
  45059. /**
  45060. * Options to modify the vr experience helper's behavior.
  45061. */
  45062. export interface VRExperienceHelperOptions extends WebVROptions {
  45063. /**
  45064. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45065. */
  45066. createDeviceOrientationCamera?: boolean;
  45067. /**
  45068. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45069. */
  45070. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45071. /**
  45072. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45073. */
  45074. laserToggle?: boolean;
  45075. /**
  45076. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45077. */
  45078. floorMeshes?: Mesh[];
  45079. /**
  45080. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45081. */
  45082. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45083. /**
  45084. * Defines if WebXR should be used instead of WebVR (if available)
  45085. */
  45086. useXR?: boolean;
  45087. }
  45088. /**
  45089. * Event containing information after VR has been entered
  45090. */
  45091. export class OnAfterEnteringVRObservableEvent {
  45092. /**
  45093. * If entering vr was successful
  45094. */
  45095. success: boolean;
  45096. }
  45097. /**
  45098. * Helps to quickly add VR support to an existing scene.
  45099. * See http://doc.babylonjs.com/how_to/webvr_helper
  45100. */
  45101. export class VRExperienceHelper {
  45102. /** Options to modify the vr experience helper's behavior. */
  45103. webVROptions: VRExperienceHelperOptions;
  45104. private _scene;
  45105. private _position;
  45106. private _btnVR;
  45107. private _btnVRDisplayed;
  45108. private _webVRsupported;
  45109. private _webVRready;
  45110. private _webVRrequesting;
  45111. private _webVRpresenting;
  45112. private _hasEnteredVR;
  45113. private _fullscreenVRpresenting;
  45114. private _inputElement;
  45115. private _webVRCamera;
  45116. private _vrDeviceOrientationCamera;
  45117. private _deviceOrientationCamera;
  45118. private _existingCamera;
  45119. private _onKeyDown;
  45120. private _onVrDisplayPresentChange;
  45121. private _onVRDisplayChanged;
  45122. private _onVRRequestPresentStart;
  45123. private _onVRRequestPresentComplete;
  45124. /**
  45125. * 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)
  45126. */
  45127. enableGazeEvenWhenNoPointerLock: boolean;
  45128. /**
  45129. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45130. */
  45131. exitVROnDoubleTap: boolean;
  45132. /**
  45133. * Observable raised right before entering VR.
  45134. */
  45135. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45136. /**
  45137. * Observable raised when entering VR has completed.
  45138. */
  45139. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45140. /**
  45141. * Observable raised when exiting VR.
  45142. */
  45143. onExitingVRObservable: Observable<VRExperienceHelper>;
  45144. /**
  45145. * Observable raised when controller mesh is loaded.
  45146. */
  45147. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45148. /** Return this.onEnteringVRObservable
  45149. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45150. */
  45151. get onEnteringVR(): Observable<VRExperienceHelper>;
  45152. /** Return this.onExitingVRObservable
  45153. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45154. */
  45155. get onExitingVR(): Observable<VRExperienceHelper>;
  45156. /** Return this.onControllerMeshLoadedObservable
  45157. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45158. */
  45159. get onControllerMeshLoaded(): Observable<WebVRController>;
  45160. private _rayLength;
  45161. private _useCustomVRButton;
  45162. private _teleportationRequested;
  45163. private _teleportActive;
  45164. private _floorMeshName;
  45165. private _floorMeshesCollection;
  45166. private _teleportationMode;
  45167. private _teleportationTime;
  45168. private _teleportationSpeed;
  45169. private _teleportationEasing;
  45170. private _rotationAllowed;
  45171. private _teleportBackwardsVector;
  45172. private _teleportationTarget;
  45173. private _isDefaultTeleportationTarget;
  45174. private _postProcessMove;
  45175. private _teleportationFillColor;
  45176. private _teleportationBorderColor;
  45177. private _rotationAngle;
  45178. private _haloCenter;
  45179. private _cameraGazer;
  45180. private _padSensibilityUp;
  45181. private _padSensibilityDown;
  45182. private _leftController;
  45183. private _rightController;
  45184. private _gazeColor;
  45185. private _laserColor;
  45186. private _pickedLaserColor;
  45187. private _pickedGazeColor;
  45188. /**
  45189. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45190. */
  45191. onNewMeshSelected: Observable<AbstractMesh>;
  45192. /**
  45193. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45194. * This observable will provide the mesh and the controller used to select the mesh
  45195. */
  45196. onMeshSelectedWithController: Observable<{
  45197. mesh: AbstractMesh;
  45198. controller: WebVRController;
  45199. }>;
  45200. /**
  45201. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45202. */
  45203. onNewMeshPicked: Observable<PickingInfo>;
  45204. private _circleEase;
  45205. /**
  45206. * Observable raised before camera teleportation
  45207. */
  45208. onBeforeCameraTeleport: Observable<Vector3>;
  45209. /**
  45210. * Observable raised after camera teleportation
  45211. */
  45212. onAfterCameraTeleport: Observable<Vector3>;
  45213. /**
  45214. * Observable raised when current selected mesh gets unselected
  45215. */
  45216. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45217. private _raySelectionPredicate;
  45218. /**
  45219. * To be optionaly changed by user to define custom ray selection
  45220. */
  45221. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45222. /**
  45223. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45224. */
  45225. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45226. /**
  45227. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45228. */
  45229. teleportationEnabled: boolean;
  45230. private _defaultHeight;
  45231. private _teleportationInitialized;
  45232. private _interactionsEnabled;
  45233. private _interactionsRequested;
  45234. private _displayGaze;
  45235. private _displayLaserPointer;
  45236. /**
  45237. * The mesh used to display where the user is going to teleport.
  45238. */
  45239. get teleportationTarget(): Mesh;
  45240. /**
  45241. * Sets the mesh to be used to display where the user is going to teleport.
  45242. */
  45243. set teleportationTarget(value: Mesh);
  45244. /**
  45245. * 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
  45246. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45247. * See http://doc.babylonjs.com/resources/baking_transformations
  45248. */
  45249. get gazeTrackerMesh(): Mesh;
  45250. set gazeTrackerMesh(value: Mesh);
  45251. /**
  45252. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45253. */
  45254. updateGazeTrackerScale: boolean;
  45255. /**
  45256. * If the gaze trackers color should be updated when selecting meshes
  45257. */
  45258. updateGazeTrackerColor: boolean;
  45259. /**
  45260. * If the controller laser color should be updated when selecting meshes
  45261. */
  45262. updateControllerLaserColor: boolean;
  45263. /**
  45264. * The gaze tracking mesh corresponding to the left controller
  45265. */
  45266. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45267. /**
  45268. * The gaze tracking mesh corresponding to the right controller
  45269. */
  45270. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45271. /**
  45272. * If the ray of the gaze should be displayed.
  45273. */
  45274. get displayGaze(): boolean;
  45275. /**
  45276. * Sets if the ray of the gaze should be displayed.
  45277. */
  45278. set displayGaze(value: boolean);
  45279. /**
  45280. * If the ray of the LaserPointer should be displayed.
  45281. */
  45282. get displayLaserPointer(): boolean;
  45283. /**
  45284. * Sets if the ray of the LaserPointer should be displayed.
  45285. */
  45286. set displayLaserPointer(value: boolean);
  45287. /**
  45288. * The deviceOrientationCamera used as the camera when not in VR.
  45289. */
  45290. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45291. /**
  45292. * Based on the current WebVR support, returns the current VR camera used.
  45293. */
  45294. get currentVRCamera(): Nullable<Camera>;
  45295. /**
  45296. * The webVRCamera which is used when in VR.
  45297. */
  45298. get webVRCamera(): WebVRFreeCamera;
  45299. /**
  45300. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45301. */
  45302. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45303. /**
  45304. * The html button that is used to trigger entering into VR.
  45305. */
  45306. get vrButton(): Nullable<HTMLButtonElement>;
  45307. private get _teleportationRequestInitiated();
  45308. /**
  45309. * Defines whether or not Pointer lock should be requested when switching to
  45310. * full screen.
  45311. */
  45312. requestPointerLockOnFullScreen: boolean;
  45313. /**
  45314. * If asking to force XR, this will be populated with the default xr experience
  45315. */
  45316. xr: WebXRDefaultExperience;
  45317. /**
  45318. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45319. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45320. */
  45321. xrTestDone: boolean;
  45322. /**
  45323. * Instantiates a VRExperienceHelper.
  45324. * Helps to quickly add VR support to an existing scene.
  45325. * @param scene The scene the VRExperienceHelper belongs to.
  45326. * @param webVROptions Options to modify the vr experience helper's behavior.
  45327. */
  45328. constructor(scene: Scene,
  45329. /** Options to modify the vr experience helper's behavior. */
  45330. webVROptions?: VRExperienceHelperOptions);
  45331. private completeVRInit;
  45332. private _onDefaultMeshLoaded;
  45333. private _onResize;
  45334. private _onFullscreenChange;
  45335. /**
  45336. * Gets a value indicating if we are currently in VR mode.
  45337. */
  45338. get isInVRMode(): boolean;
  45339. private onVrDisplayPresentChange;
  45340. private onVRDisplayChanged;
  45341. private moveButtonToBottomRight;
  45342. private displayVRButton;
  45343. private updateButtonVisibility;
  45344. private _cachedAngularSensibility;
  45345. /**
  45346. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45347. * Otherwise, will use the fullscreen API.
  45348. */
  45349. enterVR(): void;
  45350. /**
  45351. * Attempt to exit VR, or fullscreen.
  45352. */
  45353. exitVR(): void;
  45354. /**
  45355. * The position of the vr experience helper.
  45356. */
  45357. get position(): Vector3;
  45358. /**
  45359. * Sets the position of the vr experience helper.
  45360. */
  45361. set position(value: Vector3);
  45362. /**
  45363. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45364. */
  45365. enableInteractions(): void;
  45366. private get _noControllerIsActive();
  45367. private beforeRender;
  45368. private _isTeleportationFloor;
  45369. /**
  45370. * Adds a floor mesh to be used for teleportation.
  45371. * @param floorMesh the mesh to be used for teleportation.
  45372. */
  45373. addFloorMesh(floorMesh: Mesh): void;
  45374. /**
  45375. * Removes a floor mesh from being used for teleportation.
  45376. * @param floorMesh the mesh to be removed.
  45377. */
  45378. removeFloorMesh(floorMesh: Mesh): void;
  45379. /**
  45380. * Enables interactions and teleportation using the VR controllers and gaze.
  45381. * @param vrTeleportationOptions options to modify teleportation behavior.
  45382. */
  45383. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45384. private _onNewGamepadConnected;
  45385. private _tryEnableInteractionOnController;
  45386. private _onNewGamepadDisconnected;
  45387. private _enableInteractionOnController;
  45388. private _checkTeleportWithRay;
  45389. private _checkRotate;
  45390. private _checkTeleportBackwards;
  45391. private _enableTeleportationOnController;
  45392. private _createTeleportationCircles;
  45393. private _displayTeleportationTarget;
  45394. private _hideTeleportationTarget;
  45395. private _rotateCamera;
  45396. private _moveTeleportationSelectorTo;
  45397. private _workingVector;
  45398. private _workingQuaternion;
  45399. private _workingMatrix;
  45400. /**
  45401. * Time Constant Teleportation Mode
  45402. */
  45403. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45404. /**
  45405. * Speed Constant Teleportation Mode
  45406. */
  45407. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45408. /**
  45409. * Teleports the users feet to the desired location
  45410. * @param location The location where the user's feet should be placed
  45411. */
  45412. teleportCamera(location: Vector3): void;
  45413. private _convertNormalToDirectionOfRay;
  45414. private _castRayAndSelectObject;
  45415. private _notifySelectedMeshUnselected;
  45416. /**
  45417. * Permanently set new colors for the laser pointer
  45418. * @param color the new laser color
  45419. * @param pickedColor the new laser color when picked mesh detected
  45420. */
  45421. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45422. /**
  45423. * Set lighting enabled / disabled on the laser pointer of both controllers
  45424. * @param enabled should the lighting be enabled on the laser pointer
  45425. */
  45426. setLaserLightingState(enabled?: boolean): void;
  45427. /**
  45428. * Permanently set new colors for the gaze pointer
  45429. * @param color the new gaze color
  45430. * @param pickedColor the new gaze color when picked mesh detected
  45431. */
  45432. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45433. /**
  45434. * Sets the color of the laser ray from the vr controllers.
  45435. * @param color new color for the ray.
  45436. */
  45437. changeLaserColor(color: Color3): void;
  45438. /**
  45439. * Sets the color of the ray from the vr headsets gaze.
  45440. * @param color new color for the ray.
  45441. */
  45442. changeGazeColor(color: Color3): void;
  45443. /**
  45444. * Exits VR and disposes of the vr experience helper
  45445. */
  45446. dispose(): void;
  45447. /**
  45448. * Gets the name of the VRExperienceHelper class
  45449. * @returns "VRExperienceHelper"
  45450. */
  45451. getClassName(): string;
  45452. }
  45453. }
  45454. declare module BABYLON {
  45455. /**
  45456. * Contains an array of blocks representing the octree
  45457. */
  45458. export interface IOctreeContainer<T> {
  45459. /**
  45460. * Blocks within the octree
  45461. */
  45462. blocks: Array<OctreeBlock<T>>;
  45463. }
  45464. /**
  45465. * Class used to store a cell in an octree
  45466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45467. */
  45468. export class OctreeBlock<T> {
  45469. /**
  45470. * Gets the content of the current block
  45471. */
  45472. entries: T[];
  45473. /**
  45474. * Gets the list of block children
  45475. */
  45476. blocks: Array<OctreeBlock<T>>;
  45477. private _depth;
  45478. private _maxDepth;
  45479. private _capacity;
  45480. private _minPoint;
  45481. private _maxPoint;
  45482. private _boundingVectors;
  45483. private _creationFunc;
  45484. /**
  45485. * Creates a new block
  45486. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45487. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45488. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45489. * @param depth defines the current depth of this block in the octree
  45490. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45491. * @param creationFunc defines a callback to call when an element is added to the block
  45492. */
  45493. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45494. /**
  45495. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45496. */
  45497. get capacity(): number;
  45498. /**
  45499. * Gets the minimum vector (in world space) of the block's bounding box
  45500. */
  45501. get minPoint(): Vector3;
  45502. /**
  45503. * Gets the maximum vector (in world space) of the block's bounding box
  45504. */
  45505. get maxPoint(): Vector3;
  45506. /**
  45507. * Add a new element to this block
  45508. * @param entry defines the element to add
  45509. */
  45510. addEntry(entry: T): void;
  45511. /**
  45512. * Remove an element from this block
  45513. * @param entry defines the element to remove
  45514. */
  45515. removeEntry(entry: T): void;
  45516. /**
  45517. * Add an array of elements to this block
  45518. * @param entries defines the array of elements to add
  45519. */
  45520. addEntries(entries: T[]): void;
  45521. /**
  45522. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45523. * @param frustumPlanes defines the frustum planes to test
  45524. * @param selection defines the array to store current content if selection is positive
  45525. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45526. */
  45527. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45528. /**
  45529. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45530. * @param sphereCenter defines the bounding sphere center
  45531. * @param sphereRadius defines the bounding sphere radius
  45532. * @param selection defines the array to store current content if selection is positive
  45533. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45534. */
  45535. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45536. /**
  45537. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45538. * @param ray defines the ray to test with
  45539. * @param selection defines the array to store current content if selection is positive
  45540. */
  45541. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45542. /**
  45543. * Subdivide the content into child blocks (this block will then be empty)
  45544. */
  45545. createInnerBlocks(): void;
  45546. /**
  45547. * @hidden
  45548. */
  45549. 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;
  45550. }
  45551. }
  45552. declare module BABYLON {
  45553. /**
  45554. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45555. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45556. */
  45557. export class Octree<T> {
  45558. /** 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.) */
  45559. maxDepth: number;
  45560. /**
  45561. * Blocks within the octree containing objects
  45562. */
  45563. blocks: Array<OctreeBlock<T>>;
  45564. /**
  45565. * Content stored in the octree
  45566. */
  45567. dynamicContent: T[];
  45568. private _maxBlockCapacity;
  45569. private _selectionContent;
  45570. private _creationFunc;
  45571. /**
  45572. * Creates a octree
  45573. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45574. * @param creationFunc function to be used to instatiate the octree
  45575. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45576. * @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.)
  45577. */
  45578. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45579. /** 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.) */
  45580. maxDepth?: number);
  45581. /**
  45582. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45583. * @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);
  45584. * @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);
  45585. * @param entries meshes to be added to the octree blocks
  45586. */
  45587. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45588. /**
  45589. * Adds a mesh to the octree
  45590. * @param entry Mesh to add to the octree
  45591. */
  45592. addMesh(entry: T): void;
  45593. /**
  45594. * Remove an element from the octree
  45595. * @param entry defines the element to remove
  45596. */
  45597. removeMesh(entry: T): void;
  45598. /**
  45599. * Selects an array of meshes within the frustum
  45600. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45601. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45602. * @returns array of meshes within the frustum
  45603. */
  45604. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45605. /**
  45606. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45607. * @param sphereCenter defines the bounding sphere center
  45608. * @param sphereRadius defines the bounding sphere radius
  45609. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45610. * @returns an array of objects that intersect the sphere
  45611. */
  45612. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45613. /**
  45614. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45615. * @param ray defines the ray to test with
  45616. * @returns array of intersected objects
  45617. */
  45618. intersectsRay(ray: Ray): SmartArray<T>;
  45619. /**
  45620. * Adds a mesh into the octree block if it intersects the block
  45621. */
  45622. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45623. /**
  45624. * Adds a submesh into the octree block if it intersects the block
  45625. */
  45626. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45627. }
  45628. }
  45629. declare module BABYLON {
  45630. interface Scene {
  45631. /**
  45632. * @hidden
  45633. * Backing Filed
  45634. */
  45635. _selectionOctree: Octree<AbstractMesh>;
  45636. /**
  45637. * Gets the octree used to boost mesh selection (picking)
  45638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45639. */
  45640. selectionOctree: Octree<AbstractMesh>;
  45641. /**
  45642. * Creates or updates the octree used to boost selection (picking)
  45643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45644. * @param maxCapacity defines the maximum capacity per leaf
  45645. * @param maxDepth defines the maximum depth of the octree
  45646. * @returns an octree of AbstractMesh
  45647. */
  45648. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45649. }
  45650. interface AbstractMesh {
  45651. /**
  45652. * @hidden
  45653. * Backing Field
  45654. */
  45655. _submeshesOctree: Octree<SubMesh>;
  45656. /**
  45657. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45658. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45659. * @param maxCapacity defines the maximum size of each block (64 by default)
  45660. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45661. * @returns the new octree
  45662. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45663. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45664. */
  45665. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45666. }
  45667. /**
  45668. * Defines the octree scene component responsible to manage any octrees
  45669. * in a given scene.
  45670. */
  45671. export class OctreeSceneComponent {
  45672. /**
  45673. * The component name help to identify the component in the list of scene components.
  45674. */
  45675. readonly name: string;
  45676. /**
  45677. * The scene the component belongs to.
  45678. */
  45679. scene: Scene;
  45680. /**
  45681. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45682. */
  45683. readonly checksIsEnabled: boolean;
  45684. /**
  45685. * Creates a new instance of the component for the given scene
  45686. * @param scene Defines the scene to register the component in
  45687. */
  45688. constructor(scene: Scene);
  45689. /**
  45690. * Registers the component in a given scene
  45691. */
  45692. register(): void;
  45693. /**
  45694. * Return the list of active meshes
  45695. * @returns the list of active meshes
  45696. */
  45697. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45698. /**
  45699. * Return the list of active sub meshes
  45700. * @param mesh The mesh to get the candidates sub meshes from
  45701. * @returns the list of active sub meshes
  45702. */
  45703. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45704. private _tempRay;
  45705. /**
  45706. * Return the list of sub meshes intersecting with a given local ray
  45707. * @param mesh defines the mesh to find the submesh for
  45708. * @param localRay defines the ray in local space
  45709. * @returns the list of intersecting sub meshes
  45710. */
  45711. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45712. /**
  45713. * Return the list of sub meshes colliding with a collider
  45714. * @param mesh defines the mesh to find the submesh for
  45715. * @param collider defines the collider to evaluate the collision against
  45716. * @returns the list of colliding sub meshes
  45717. */
  45718. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45719. /**
  45720. * Rebuilds the elements related to this component in case of
  45721. * context lost for instance.
  45722. */
  45723. rebuild(): void;
  45724. /**
  45725. * Disposes the component and the associated ressources.
  45726. */
  45727. dispose(): void;
  45728. }
  45729. }
  45730. declare module BABYLON {
  45731. /**
  45732. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45733. */
  45734. export class Gizmo implements IDisposable {
  45735. /** The utility layer the gizmo will be added to */
  45736. gizmoLayer: UtilityLayerRenderer;
  45737. /**
  45738. * The root mesh of the gizmo
  45739. */
  45740. _rootMesh: Mesh;
  45741. private _attachedMesh;
  45742. /**
  45743. * Ratio for the scale of the gizmo (Default: 1)
  45744. */
  45745. scaleRatio: number;
  45746. /**
  45747. * If a custom mesh has been set (Default: false)
  45748. */
  45749. protected _customMeshSet: boolean;
  45750. /**
  45751. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45752. * * When set, interactions will be enabled
  45753. */
  45754. get attachedMesh(): Nullable<AbstractMesh>;
  45755. set attachedMesh(value: Nullable<AbstractMesh>);
  45756. /**
  45757. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45758. * @param mesh The mesh to replace the default mesh of the gizmo
  45759. */
  45760. setCustomMesh(mesh: Mesh): void;
  45761. /**
  45762. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45763. */
  45764. updateGizmoRotationToMatchAttachedMesh: boolean;
  45765. /**
  45766. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45767. */
  45768. updateGizmoPositionToMatchAttachedMesh: boolean;
  45769. /**
  45770. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45771. */
  45772. updateScale: boolean;
  45773. protected _interactionsEnabled: boolean;
  45774. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45775. private _beforeRenderObserver;
  45776. private _tempVector;
  45777. /**
  45778. * Creates a gizmo
  45779. * @param gizmoLayer The utility layer the gizmo will be added to
  45780. */
  45781. constructor(
  45782. /** The utility layer the gizmo will be added to */
  45783. gizmoLayer?: UtilityLayerRenderer);
  45784. /**
  45785. * Updates the gizmo to match the attached mesh's position/rotation
  45786. */
  45787. protected _update(): void;
  45788. /**
  45789. * Disposes of the gizmo
  45790. */
  45791. dispose(): void;
  45792. }
  45793. }
  45794. declare module BABYLON {
  45795. /**
  45796. * Single plane drag gizmo
  45797. */
  45798. export class PlaneDragGizmo extends Gizmo {
  45799. /**
  45800. * Drag behavior responsible for the gizmos dragging interactions
  45801. */
  45802. dragBehavior: PointerDragBehavior;
  45803. private _pointerObserver;
  45804. /**
  45805. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45806. */
  45807. snapDistance: number;
  45808. /**
  45809. * Event that fires each time the gizmo snaps to a new location.
  45810. * * snapDistance is the the change in distance
  45811. */
  45812. onSnapObservable: Observable<{
  45813. snapDistance: number;
  45814. }>;
  45815. private _plane;
  45816. private _coloredMaterial;
  45817. private _hoverMaterial;
  45818. private _isEnabled;
  45819. private _parent;
  45820. /** @hidden */
  45821. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45822. /** @hidden */
  45823. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45824. /**
  45825. * Creates a PlaneDragGizmo
  45826. * @param gizmoLayer The utility layer the gizmo will be added to
  45827. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45828. * @param color The color of the gizmo
  45829. */
  45830. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45831. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45832. /**
  45833. * If the gizmo is enabled
  45834. */
  45835. set isEnabled(value: boolean);
  45836. get isEnabled(): boolean;
  45837. /**
  45838. * Disposes of the gizmo
  45839. */
  45840. dispose(): void;
  45841. }
  45842. }
  45843. declare module BABYLON {
  45844. /**
  45845. * Gizmo that enables dragging a mesh along 3 axis
  45846. */
  45847. export class PositionGizmo extends Gizmo {
  45848. /**
  45849. * Internal gizmo used for interactions on the x axis
  45850. */
  45851. xGizmo: AxisDragGizmo;
  45852. /**
  45853. * Internal gizmo used for interactions on the y axis
  45854. */
  45855. yGizmo: AxisDragGizmo;
  45856. /**
  45857. * Internal gizmo used for interactions on the z axis
  45858. */
  45859. zGizmo: AxisDragGizmo;
  45860. /**
  45861. * Internal gizmo used for interactions on the yz plane
  45862. */
  45863. xPlaneGizmo: PlaneDragGizmo;
  45864. /**
  45865. * Internal gizmo used for interactions on the xz plane
  45866. */
  45867. yPlaneGizmo: PlaneDragGizmo;
  45868. /**
  45869. * Internal gizmo used for interactions on the xy plane
  45870. */
  45871. zPlaneGizmo: PlaneDragGizmo;
  45872. /**
  45873. * private variables
  45874. */
  45875. private _meshAttached;
  45876. private _updateGizmoRotationToMatchAttachedMesh;
  45877. private _snapDistance;
  45878. private _scaleRatio;
  45879. /** Fires an event when any of it's sub gizmos are dragged */
  45880. onDragStartObservable: Observable<unknown>;
  45881. /** Fires an event when any of it's sub gizmos are released from dragging */
  45882. onDragEndObservable: Observable<unknown>;
  45883. /**
  45884. * If set to true, planar drag is enabled
  45885. */
  45886. private _planarGizmoEnabled;
  45887. get attachedMesh(): Nullable<AbstractMesh>;
  45888. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45889. /**
  45890. * Creates a PositionGizmo
  45891. * @param gizmoLayer The utility layer the gizmo will be added to
  45892. */
  45893. constructor(gizmoLayer?: UtilityLayerRenderer);
  45894. /**
  45895. * If the planar drag gizmo is enabled
  45896. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45897. */
  45898. set planarGizmoEnabled(value: boolean);
  45899. get planarGizmoEnabled(): boolean;
  45900. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45901. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45902. /**
  45903. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45904. */
  45905. set snapDistance(value: number);
  45906. get snapDistance(): number;
  45907. /**
  45908. * Ratio for the scale of the gizmo (Default: 1)
  45909. */
  45910. set scaleRatio(value: number);
  45911. get scaleRatio(): number;
  45912. /**
  45913. * Disposes of the gizmo
  45914. */
  45915. dispose(): void;
  45916. /**
  45917. * CustomMeshes are not supported by this gizmo
  45918. * @param mesh The mesh to replace the default mesh of the gizmo
  45919. */
  45920. setCustomMesh(mesh: Mesh): void;
  45921. }
  45922. }
  45923. declare module BABYLON {
  45924. /**
  45925. * Single axis drag gizmo
  45926. */
  45927. export class AxisDragGizmo extends Gizmo {
  45928. /**
  45929. * Drag behavior responsible for the gizmos dragging interactions
  45930. */
  45931. dragBehavior: PointerDragBehavior;
  45932. private _pointerObserver;
  45933. /**
  45934. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45935. */
  45936. snapDistance: number;
  45937. /**
  45938. * Event that fires each time the gizmo snaps to a new location.
  45939. * * snapDistance is the the change in distance
  45940. */
  45941. onSnapObservable: Observable<{
  45942. snapDistance: number;
  45943. }>;
  45944. private _isEnabled;
  45945. private _parent;
  45946. private _arrow;
  45947. private _coloredMaterial;
  45948. private _hoverMaterial;
  45949. /** @hidden */
  45950. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45951. /** @hidden */
  45952. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45953. /**
  45954. * Creates an AxisDragGizmo
  45955. * @param gizmoLayer The utility layer the gizmo will be added to
  45956. * @param dragAxis The axis which the gizmo will be able to drag on
  45957. * @param color The color of the gizmo
  45958. */
  45959. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45960. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45961. /**
  45962. * If the gizmo is enabled
  45963. */
  45964. set isEnabled(value: boolean);
  45965. get isEnabled(): boolean;
  45966. /**
  45967. * Disposes of the gizmo
  45968. */
  45969. dispose(): void;
  45970. }
  45971. }
  45972. declare module BABYLON.Debug {
  45973. /**
  45974. * The Axes viewer will show 3 axes in a specific point in space
  45975. */
  45976. export class AxesViewer {
  45977. private _xAxis;
  45978. private _yAxis;
  45979. private _zAxis;
  45980. private _scaleLinesFactor;
  45981. private _instanced;
  45982. /**
  45983. * Gets the hosting scene
  45984. */
  45985. scene: Scene;
  45986. /**
  45987. * Gets or sets a number used to scale line length
  45988. */
  45989. scaleLines: number;
  45990. /** Gets the node hierarchy used to render x-axis */
  45991. get xAxis(): TransformNode;
  45992. /** Gets the node hierarchy used to render y-axis */
  45993. get yAxis(): TransformNode;
  45994. /** Gets the node hierarchy used to render z-axis */
  45995. get zAxis(): TransformNode;
  45996. /**
  45997. * Creates a new AxesViewer
  45998. * @param scene defines the hosting scene
  45999. * @param scaleLines defines a number used to scale line length (1 by default)
  46000. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46001. * @param xAxis defines the node hierarchy used to render the x-axis
  46002. * @param yAxis defines the node hierarchy used to render the y-axis
  46003. * @param zAxis defines the node hierarchy used to render the z-axis
  46004. */
  46005. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46006. /**
  46007. * Force the viewer to update
  46008. * @param position defines the position of the viewer
  46009. * @param xaxis defines the x axis of the viewer
  46010. * @param yaxis defines the y axis of the viewer
  46011. * @param zaxis defines the z axis of the viewer
  46012. */
  46013. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46014. /**
  46015. * Creates an instance of this axes viewer.
  46016. * @returns a new axes viewer with instanced meshes
  46017. */
  46018. createInstance(): AxesViewer;
  46019. /** Releases resources */
  46020. dispose(): void;
  46021. private static _SetRenderingGroupId;
  46022. }
  46023. }
  46024. declare module BABYLON.Debug {
  46025. /**
  46026. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46027. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46028. */
  46029. export class BoneAxesViewer extends AxesViewer {
  46030. /**
  46031. * Gets or sets the target mesh where to display the axes viewer
  46032. */
  46033. mesh: Nullable<Mesh>;
  46034. /**
  46035. * Gets or sets the target bone where to display the axes viewer
  46036. */
  46037. bone: Nullable<Bone>;
  46038. /** Gets current position */
  46039. pos: Vector3;
  46040. /** Gets direction of X axis */
  46041. xaxis: Vector3;
  46042. /** Gets direction of Y axis */
  46043. yaxis: Vector3;
  46044. /** Gets direction of Z axis */
  46045. zaxis: Vector3;
  46046. /**
  46047. * Creates a new BoneAxesViewer
  46048. * @param scene defines the hosting scene
  46049. * @param bone defines the target bone
  46050. * @param mesh defines the target mesh
  46051. * @param scaleLines defines a scaling factor for line length (1 by default)
  46052. */
  46053. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46054. /**
  46055. * Force the viewer to update
  46056. */
  46057. update(): void;
  46058. /** Releases resources */
  46059. dispose(): void;
  46060. }
  46061. }
  46062. declare module BABYLON {
  46063. /**
  46064. * Interface used to define scene explorer extensibility option
  46065. */
  46066. export interface IExplorerExtensibilityOption {
  46067. /**
  46068. * Define the option label
  46069. */
  46070. label: string;
  46071. /**
  46072. * Defines the action to execute on click
  46073. */
  46074. action: (entity: any) => void;
  46075. }
  46076. /**
  46077. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46078. */
  46079. export interface IExplorerExtensibilityGroup {
  46080. /**
  46081. * Defines a predicate to test if a given type mut be extended
  46082. */
  46083. predicate: (entity: any) => boolean;
  46084. /**
  46085. * Gets the list of options added to a type
  46086. */
  46087. entries: IExplorerExtensibilityOption[];
  46088. }
  46089. /**
  46090. * Interface used to define the options to use to create the Inspector
  46091. */
  46092. export interface IInspectorOptions {
  46093. /**
  46094. * Display in overlay mode (default: false)
  46095. */
  46096. overlay?: boolean;
  46097. /**
  46098. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46099. */
  46100. globalRoot?: HTMLElement;
  46101. /**
  46102. * Display the Scene explorer
  46103. */
  46104. showExplorer?: boolean;
  46105. /**
  46106. * Display the property inspector
  46107. */
  46108. showInspector?: boolean;
  46109. /**
  46110. * Display in embed mode (both panes on the right)
  46111. */
  46112. embedMode?: boolean;
  46113. /**
  46114. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46115. */
  46116. handleResize?: boolean;
  46117. /**
  46118. * Allow the panes to popup (default: true)
  46119. */
  46120. enablePopup?: boolean;
  46121. /**
  46122. * Allow the panes to be closed by users (default: true)
  46123. */
  46124. enableClose?: boolean;
  46125. /**
  46126. * Optional list of extensibility entries
  46127. */
  46128. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46129. /**
  46130. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46131. */
  46132. inspectorURL?: string;
  46133. /**
  46134. * Optional initial tab (default to DebugLayerTab.Properties)
  46135. */
  46136. initialTab?: DebugLayerTab;
  46137. }
  46138. interface Scene {
  46139. /**
  46140. * @hidden
  46141. * Backing field
  46142. */
  46143. _debugLayer: DebugLayer;
  46144. /**
  46145. * Gets the debug layer (aka Inspector) associated with the scene
  46146. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46147. */
  46148. debugLayer: DebugLayer;
  46149. }
  46150. /**
  46151. * Enum of inspector action tab
  46152. */
  46153. export enum DebugLayerTab {
  46154. /**
  46155. * Properties tag (default)
  46156. */
  46157. Properties = 0,
  46158. /**
  46159. * Debug tab
  46160. */
  46161. Debug = 1,
  46162. /**
  46163. * Statistics tab
  46164. */
  46165. Statistics = 2,
  46166. /**
  46167. * Tools tab
  46168. */
  46169. Tools = 3,
  46170. /**
  46171. * Settings tab
  46172. */
  46173. Settings = 4
  46174. }
  46175. /**
  46176. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46177. * what is happening in your scene
  46178. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46179. */
  46180. export class DebugLayer {
  46181. /**
  46182. * Define the url to get the inspector script from.
  46183. * By default it uses the babylonjs CDN.
  46184. * @ignoreNaming
  46185. */
  46186. static InspectorURL: string;
  46187. private _scene;
  46188. private BJSINSPECTOR;
  46189. private _onPropertyChangedObservable?;
  46190. /**
  46191. * Observable triggered when a property is changed through the inspector.
  46192. */
  46193. get onPropertyChangedObservable(): any;
  46194. /**
  46195. * Instantiates a new debug layer.
  46196. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46197. * what is happening in your scene
  46198. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46199. * @param scene Defines the scene to inspect
  46200. */
  46201. constructor(scene: Scene);
  46202. /** Creates the inspector window. */
  46203. private _createInspector;
  46204. /**
  46205. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46206. * @param entity defines the entity to select
  46207. * @param lineContainerTitle defines the specific block to highlight
  46208. */
  46209. select(entity: any, lineContainerTitle?: string): void;
  46210. /** Get the inspector from bundle or global */
  46211. private _getGlobalInspector;
  46212. /**
  46213. * Get if the inspector is visible or not.
  46214. * @returns true if visible otherwise, false
  46215. */
  46216. isVisible(): boolean;
  46217. /**
  46218. * Hide the inspector and close its window.
  46219. */
  46220. hide(): void;
  46221. /**
  46222. * Launch the debugLayer.
  46223. * @param config Define the configuration of the inspector
  46224. * @return a promise fulfilled when the debug layer is visible
  46225. */
  46226. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46227. }
  46228. }
  46229. declare module BABYLON {
  46230. /**
  46231. * Class containing static functions to help procedurally build meshes
  46232. */
  46233. export class BoxBuilder {
  46234. /**
  46235. * Creates a box mesh
  46236. * * The parameter `size` sets the size (float) of each box side (default 1)
  46237. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46238. * * 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)
  46239. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46241. * * 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
  46242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46243. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46244. * @param name defines the name of the mesh
  46245. * @param options defines the options used to create the mesh
  46246. * @param scene defines the hosting scene
  46247. * @returns the box mesh
  46248. */
  46249. static CreateBox(name: string, options: {
  46250. size?: number;
  46251. width?: number;
  46252. height?: number;
  46253. depth?: number;
  46254. faceUV?: Vector4[];
  46255. faceColors?: Color4[];
  46256. sideOrientation?: number;
  46257. frontUVs?: Vector4;
  46258. backUVs?: Vector4;
  46259. wrap?: boolean;
  46260. topBaseAt?: number;
  46261. bottomBaseAt?: number;
  46262. updatable?: boolean;
  46263. }, scene?: Nullable<Scene>): Mesh;
  46264. }
  46265. }
  46266. declare module BABYLON.Debug {
  46267. /**
  46268. * Used to show the physics impostor around the specific mesh
  46269. */
  46270. export class PhysicsViewer {
  46271. /** @hidden */
  46272. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46273. /** @hidden */
  46274. protected _meshes: Array<Nullable<AbstractMesh>>;
  46275. /** @hidden */
  46276. protected _scene: Nullable<Scene>;
  46277. /** @hidden */
  46278. protected _numMeshes: number;
  46279. /** @hidden */
  46280. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46281. private _renderFunction;
  46282. private _utilityLayer;
  46283. private _debugBoxMesh;
  46284. private _debugSphereMesh;
  46285. private _debugCylinderMesh;
  46286. private _debugMaterial;
  46287. private _debugMeshMeshes;
  46288. /**
  46289. * Creates a new PhysicsViewer
  46290. * @param scene defines the hosting scene
  46291. */
  46292. constructor(scene: Scene);
  46293. /** @hidden */
  46294. protected _updateDebugMeshes(): void;
  46295. /**
  46296. * Renders a specified physic impostor
  46297. * @param impostor defines the impostor to render
  46298. * @param targetMesh defines the mesh represented by the impostor
  46299. * @returns the new debug mesh used to render the impostor
  46300. */
  46301. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46302. /**
  46303. * Hides a specified physic impostor
  46304. * @param impostor defines the impostor to hide
  46305. */
  46306. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46307. private _getDebugMaterial;
  46308. private _getDebugBoxMesh;
  46309. private _getDebugSphereMesh;
  46310. private _getDebugCylinderMesh;
  46311. private _getDebugMeshMesh;
  46312. private _getDebugMesh;
  46313. /** Releases all resources */
  46314. dispose(): void;
  46315. }
  46316. }
  46317. declare module BABYLON {
  46318. /**
  46319. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46320. * in order to better appreciate the issue one might have.
  46321. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46322. */
  46323. export class RayHelper {
  46324. /**
  46325. * Defines the ray we are currently tryin to visualize.
  46326. */
  46327. ray: Nullable<Ray>;
  46328. private _renderPoints;
  46329. private _renderLine;
  46330. private _renderFunction;
  46331. private _scene;
  46332. private _updateToMeshFunction;
  46333. private _attachedToMesh;
  46334. private _meshSpaceDirection;
  46335. private _meshSpaceOrigin;
  46336. /**
  46337. * Helper function to create a colored helper in a scene in one line.
  46338. * @param ray Defines the ray we are currently tryin to visualize
  46339. * @param scene Defines the scene the ray is used in
  46340. * @param color Defines the color we want to see the ray in
  46341. * @returns The newly created ray helper.
  46342. */
  46343. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46344. /**
  46345. * Instantiate a new ray helper.
  46346. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46347. * in order to better appreciate the issue one might have.
  46348. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46349. * @param ray Defines the ray we are currently tryin to visualize
  46350. */
  46351. constructor(ray: Ray);
  46352. /**
  46353. * Shows the ray we are willing to debug.
  46354. * @param scene Defines the scene the ray needs to be rendered in
  46355. * @param color Defines the color the ray needs to be rendered in
  46356. */
  46357. show(scene: Scene, color?: Color3): void;
  46358. /**
  46359. * Hides the ray we are debugging.
  46360. */
  46361. hide(): void;
  46362. private _render;
  46363. /**
  46364. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46365. * @param mesh Defines the mesh we want the helper attached to
  46366. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46367. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46368. * @param length Defines the length of the ray
  46369. */
  46370. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46371. /**
  46372. * Detach the ray helper from the mesh it has previously been attached to.
  46373. */
  46374. detachFromMesh(): void;
  46375. private _updateToMesh;
  46376. /**
  46377. * Dispose the helper and release its associated resources.
  46378. */
  46379. dispose(): void;
  46380. }
  46381. }
  46382. declare module BABYLON.Debug {
  46383. /**
  46384. * Class used to render a debug view of a given skeleton
  46385. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46386. */
  46387. export class SkeletonViewer {
  46388. /** defines the skeleton to render */
  46389. skeleton: Skeleton;
  46390. /** defines the mesh attached to the skeleton */
  46391. mesh: AbstractMesh;
  46392. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46393. autoUpdateBonesMatrices: boolean;
  46394. /** defines the rendering group id to use with the viewer */
  46395. renderingGroupId: number;
  46396. /** Gets or sets the color used to render the skeleton */
  46397. color: Color3;
  46398. private _scene;
  46399. private _debugLines;
  46400. private _debugMesh;
  46401. private _isEnabled;
  46402. private _renderFunction;
  46403. private _utilityLayer;
  46404. /**
  46405. * Returns the mesh used to render the bones
  46406. */
  46407. get debugMesh(): Nullable<LinesMesh>;
  46408. /**
  46409. * Creates a new SkeletonViewer
  46410. * @param skeleton defines the skeleton to render
  46411. * @param mesh defines the mesh attached to the skeleton
  46412. * @param scene defines the hosting scene
  46413. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46414. * @param renderingGroupId defines the rendering group id to use with the viewer
  46415. */
  46416. constructor(
  46417. /** defines the skeleton to render */
  46418. skeleton: Skeleton,
  46419. /** defines the mesh attached to the skeleton */
  46420. mesh: AbstractMesh, scene: Scene,
  46421. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46422. autoUpdateBonesMatrices?: boolean,
  46423. /** defines the rendering group id to use with the viewer */
  46424. renderingGroupId?: number);
  46425. /** Gets or sets a boolean indicating if the viewer is enabled */
  46426. set isEnabled(value: boolean);
  46427. get isEnabled(): boolean;
  46428. private _getBonePosition;
  46429. private _getLinesForBonesWithLength;
  46430. private _getLinesForBonesNoLength;
  46431. /** Update the viewer to sync with current skeleton state */
  46432. update(): void;
  46433. /** Release associated resources */
  46434. dispose(): void;
  46435. }
  46436. }
  46437. declare module BABYLON {
  46438. /**
  46439. * Options to create the null engine
  46440. */
  46441. export class NullEngineOptions {
  46442. /**
  46443. * Render width (Default: 512)
  46444. */
  46445. renderWidth: number;
  46446. /**
  46447. * Render height (Default: 256)
  46448. */
  46449. renderHeight: number;
  46450. /**
  46451. * Texture size (Default: 512)
  46452. */
  46453. textureSize: number;
  46454. /**
  46455. * If delta time between frames should be constant
  46456. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46457. */
  46458. deterministicLockstep: boolean;
  46459. /**
  46460. * Maximum about of steps between frames (Default: 4)
  46461. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46462. */
  46463. lockstepMaxSteps: number;
  46464. }
  46465. /**
  46466. * The null engine class provides support for headless version of babylon.js.
  46467. * This can be used in server side scenario or for testing purposes
  46468. */
  46469. export class NullEngine extends Engine {
  46470. private _options;
  46471. /**
  46472. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46473. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46474. * @returns true if engine is in deterministic lock step mode
  46475. */
  46476. isDeterministicLockStep(): boolean;
  46477. /**
  46478. * Gets the max steps when engine is running in deterministic lock step
  46479. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46480. * @returns the max steps
  46481. */
  46482. getLockstepMaxSteps(): number;
  46483. /**
  46484. * Gets the current hardware scaling level.
  46485. * By default the hardware scaling level is computed from the window device ratio.
  46486. * 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.
  46487. * @returns a number indicating the current hardware scaling level
  46488. */
  46489. getHardwareScalingLevel(): number;
  46490. constructor(options?: NullEngineOptions);
  46491. /**
  46492. * Creates a vertex buffer
  46493. * @param vertices the data for the vertex buffer
  46494. * @returns the new WebGL static buffer
  46495. */
  46496. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46497. /**
  46498. * Creates a new index buffer
  46499. * @param indices defines the content of the index buffer
  46500. * @param updatable defines if the index buffer must be updatable
  46501. * @returns a new webGL buffer
  46502. */
  46503. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46504. /**
  46505. * Clear the current render buffer or the current render target (if any is set up)
  46506. * @param color defines the color to use
  46507. * @param backBuffer defines if the back buffer must be cleared
  46508. * @param depth defines if the depth buffer must be cleared
  46509. * @param stencil defines if the stencil buffer must be cleared
  46510. */
  46511. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46512. /**
  46513. * Gets the current render width
  46514. * @param useScreen defines if screen size must be used (or the current render target if any)
  46515. * @returns a number defining the current render width
  46516. */
  46517. getRenderWidth(useScreen?: boolean): number;
  46518. /**
  46519. * Gets the current render height
  46520. * @param useScreen defines if screen size must be used (or the current render target if any)
  46521. * @returns a number defining the current render height
  46522. */
  46523. getRenderHeight(useScreen?: boolean): number;
  46524. /**
  46525. * Set the WebGL's viewport
  46526. * @param viewport defines the viewport element to be used
  46527. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46528. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46529. */
  46530. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46531. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46532. /**
  46533. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46534. * @param pipelineContext defines the pipeline context to use
  46535. * @param uniformsNames defines the list of uniform names
  46536. * @returns an array of webGL uniform locations
  46537. */
  46538. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46539. /**
  46540. * Gets the lsit of active attributes for a given webGL program
  46541. * @param pipelineContext defines the pipeline context to use
  46542. * @param attributesNames defines the list of attribute names to get
  46543. * @returns an array of indices indicating the offset of each attribute
  46544. */
  46545. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46546. /**
  46547. * Binds an effect to the webGL context
  46548. * @param effect defines the effect to bind
  46549. */
  46550. bindSamplers(effect: Effect): void;
  46551. /**
  46552. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46553. * @param effect defines the effect to activate
  46554. */
  46555. enableEffect(effect: Effect): void;
  46556. /**
  46557. * Set various states to the webGL context
  46558. * @param culling defines backface culling state
  46559. * @param zOffset defines the value to apply to zOffset (0 by default)
  46560. * @param force defines if states must be applied even if cache is up to date
  46561. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46562. */
  46563. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46564. /**
  46565. * Set the value of an uniform to an array of int32
  46566. * @param uniform defines the webGL uniform location where to store the value
  46567. * @param array defines the array of int32 to store
  46568. */
  46569. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46570. /**
  46571. * Set the value of an uniform to an array of int32 (stored as vec2)
  46572. * @param uniform defines the webGL uniform location where to store the value
  46573. * @param array defines the array of int32 to store
  46574. */
  46575. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46576. /**
  46577. * Set the value of an uniform to an array of int32 (stored as vec3)
  46578. * @param uniform defines the webGL uniform location where to store the value
  46579. * @param array defines the array of int32 to store
  46580. */
  46581. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46582. /**
  46583. * Set the value of an uniform to an array of int32 (stored as vec4)
  46584. * @param uniform defines the webGL uniform location where to store the value
  46585. * @param array defines the array of int32 to store
  46586. */
  46587. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46588. /**
  46589. * Set the value of an uniform to an array of float32
  46590. * @param uniform defines the webGL uniform location where to store the value
  46591. * @param array defines the array of float32 to store
  46592. */
  46593. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46594. /**
  46595. * Set the value of an uniform to an array of float32 (stored as vec2)
  46596. * @param uniform defines the webGL uniform location where to store the value
  46597. * @param array defines the array of float32 to store
  46598. */
  46599. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46600. /**
  46601. * Set the value of an uniform to an array of float32 (stored as vec3)
  46602. * @param uniform defines the webGL uniform location where to store the value
  46603. * @param array defines the array of float32 to store
  46604. */
  46605. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46606. /**
  46607. * Set the value of an uniform to an array of float32 (stored as vec4)
  46608. * @param uniform defines the webGL uniform location where to store the value
  46609. * @param array defines the array of float32 to store
  46610. */
  46611. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46612. /**
  46613. * Set the value of an uniform to an array of number
  46614. * @param uniform defines the webGL uniform location where to store the value
  46615. * @param array defines the array of number to store
  46616. */
  46617. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46618. /**
  46619. * Set the value of an uniform to an array of number (stored as vec2)
  46620. * @param uniform defines the webGL uniform location where to store the value
  46621. * @param array defines the array of number to store
  46622. */
  46623. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46624. /**
  46625. * Set the value of an uniform to an array of number (stored as vec3)
  46626. * @param uniform defines the webGL uniform location where to store the value
  46627. * @param array defines the array of number to store
  46628. */
  46629. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46630. /**
  46631. * Set the value of an uniform to an array of number (stored as vec4)
  46632. * @param uniform defines the webGL uniform location where to store the value
  46633. * @param array defines the array of number to store
  46634. */
  46635. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46636. /**
  46637. * Set the value of an uniform to an array of float32 (stored as matrices)
  46638. * @param uniform defines the webGL uniform location where to store the value
  46639. * @param matrices defines the array of float32 to store
  46640. */
  46641. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46642. /**
  46643. * Set the value of an uniform to a matrix (3x3)
  46644. * @param uniform defines the webGL uniform location where to store the value
  46645. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46646. */
  46647. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46648. /**
  46649. * Set the value of an uniform to a matrix (2x2)
  46650. * @param uniform defines the webGL uniform location where to store the value
  46651. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46652. */
  46653. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46654. /**
  46655. * Set the value of an uniform to a number (float)
  46656. * @param uniform defines the webGL uniform location where to store the value
  46657. * @param value defines the float number to store
  46658. */
  46659. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46660. /**
  46661. * Set the value of an uniform to a vec2
  46662. * @param uniform defines the webGL uniform location where to store the value
  46663. * @param x defines the 1st component of the value
  46664. * @param y defines the 2nd component of the value
  46665. */
  46666. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46667. /**
  46668. * Set the value of an uniform to a vec3
  46669. * @param uniform defines the webGL uniform location where to store the value
  46670. * @param x defines the 1st component of the value
  46671. * @param y defines the 2nd component of the value
  46672. * @param z defines the 3rd component of the value
  46673. */
  46674. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46675. /**
  46676. * Set the value of an uniform to a boolean
  46677. * @param uniform defines the webGL uniform location where to store the value
  46678. * @param bool defines the boolean to store
  46679. */
  46680. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46681. /**
  46682. * Set the value of an uniform to a vec4
  46683. * @param uniform defines the webGL uniform location where to store the value
  46684. * @param x defines the 1st component of the value
  46685. * @param y defines the 2nd component of the value
  46686. * @param z defines the 3rd component of the value
  46687. * @param w defines the 4th component of the value
  46688. */
  46689. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46690. /**
  46691. * Sets the current alpha mode
  46692. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46693. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46694. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46695. */
  46696. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46697. /**
  46698. * Bind webGl buffers directly to the webGL context
  46699. * @param vertexBuffers defines the vertex buffer to bind
  46700. * @param indexBuffer defines the index buffer to bind
  46701. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46702. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46703. * @param effect defines the effect associated with the vertex buffer
  46704. */
  46705. bindBuffers(vertexBuffers: {
  46706. [key: string]: VertexBuffer;
  46707. }, indexBuffer: DataBuffer, effect: Effect): void;
  46708. /**
  46709. * Force the entire cache to be cleared
  46710. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46711. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46712. */
  46713. wipeCaches(bruteForce?: boolean): void;
  46714. /**
  46715. * Send a draw order
  46716. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46717. * @param indexStart defines the starting index
  46718. * @param indexCount defines the number of index to draw
  46719. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46720. */
  46721. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46722. /**
  46723. * Draw a list of indexed primitives
  46724. * @param fillMode defines the primitive to use
  46725. * @param indexStart defines the starting index
  46726. * @param indexCount defines the number of index to draw
  46727. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46728. */
  46729. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46730. /**
  46731. * Draw a list of unindexed primitives
  46732. * @param fillMode defines the primitive to use
  46733. * @param verticesStart defines the index of first vertex to draw
  46734. * @param verticesCount defines the count of vertices to draw
  46735. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46736. */
  46737. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46738. /** @hidden */
  46739. _createTexture(): WebGLTexture;
  46740. /** @hidden */
  46741. _releaseTexture(texture: InternalTexture): void;
  46742. /**
  46743. * Usually called from Texture.ts.
  46744. * Passed information to create a WebGLTexture
  46745. * @param urlArg defines a value which contains one of the following:
  46746. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46747. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46748. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46750. * @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)
  46751. * @param scene needed for loading to the correct scene
  46752. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46753. * @param onLoad optional callback to be called upon successful completion
  46754. * @param onError optional callback to be called upon failure
  46755. * @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
  46756. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46757. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46758. * @param forcedExtension defines the extension to use to pick the right loader
  46759. * @param mimeType defines an optional mime type
  46760. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46761. */
  46762. 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;
  46763. /**
  46764. * Creates a new render target texture
  46765. * @param size defines the size of the texture
  46766. * @param options defines the options used to create the texture
  46767. * @returns a new render target texture stored in an InternalTexture
  46768. */
  46769. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46770. /**
  46771. * Update the sampling mode of a given texture
  46772. * @param samplingMode defines the required sampling mode
  46773. * @param texture defines the texture to update
  46774. */
  46775. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46776. /**
  46777. * Binds the frame buffer to the specified texture.
  46778. * @param texture The texture to render to or null for the default canvas
  46779. * @param faceIndex The face of the texture to render to in case of cube texture
  46780. * @param requiredWidth The width of the target to render to
  46781. * @param requiredHeight The height of the target to render to
  46782. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46783. * @param lodLevel defines le lod level to bind to the frame buffer
  46784. */
  46785. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46786. /**
  46787. * Unbind the current render target texture from the webGL context
  46788. * @param texture defines the render target texture to unbind
  46789. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46790. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46791. */
  46792. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46793. /**
  46794. * Creates a dynamic vertex buffer
  46795. * @param vertices the data for the dynamic vertex buffer
  46796. * @returns the new WebGL dynamic buffer
  46797. */
  46798. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46799. /**
  46800. * Update the content of a dynamic texture
  46801. * @param texture defines the texture to update
  46802. * @param canvas defines the canvas containing the source
  46803. * @param invertY defines if data must be stored with Y axis inverted
  46804. * @param premulAlpha defines if alpha is stored as premultiplied
  46805. * @param format defines the format of the data
  46806. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46807. */
  46808. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46809. /**
  46810. * Gets a boolean indicating if all created effects are ready
  46811. * @returns true if all effects are ready
  46812. */
  46813. areAllEffectsReady(): boolean;
  46814. /**
  46815. * @hidden
  46816. * Get the current error code of the webGL context
  46817. * @returns the error code
  46818. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46819. */
  46820. getError(): number;
  46821. /** @hidden */
  46822. _getUnpackAlignement(): number;
  46823. /** @hidden */
  46824. _unpackFlipY(value: boolean): void;
  46825. /**
  46826. * Update a dynamic index buffer
  46827. * @param indexBuffer defines the target index buffer
  46828. * @param indices defines the data to update
  46829. * @param offset defines the offset in the target index buffer where update should start
  46830. */
  46831. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46832. /**
  46833. * Updates a dynamic vertex buffer.
  46834. * @param vertexBuffer the vertex buffer to update
  46835. * @param vertices the data used to update the vertex buffer
  46836. * @param byteOffset the byte offset of the data (optional)
  46837. * @param byteLength the byte length of the data (optional)
  46838. */
  46839. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46840. /** @hidden */
  46841. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46842. /** @hidden */
  46843. _bindTexture(channel: number, texture: InternalTexture): void;
  46844. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46845. /**
  46846. * 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
  46847. */
  46848. releaseEffects(): void;
  46849. displayLoadingUI(): void;
  46850. hideLoadingUI(): void;
  46851. /** @hidden */
  46852. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46853. /** @hidden */
  46854. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46855. /** @hidden */
  46856. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46857. /** @hidden */
  46858. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46859. }
  46860. }
  46861. declare module BABYLON {
  46862. /**
  46863. * @hidden
  46864. **/
  46865. export class _TimeToken {
  46866. _startTimeQuery: Nullable<WebGLQuery>;
  46867. _endTimeQuery: Nullable<WebGLQuery>;
  46868. _timeElapsedQuery: Nullable<WebGLQuery>;
  46869. _timeElapsedQueryEnded: boolean;
  46870. }
  46871. }
  46872. declare module BABYLON {
  46873. /** @hidden */
  46874. export class _OcclusionDataStorage {
  46875. /** @hidden */
  46876. occlusionInternalRetryCounter: number;
  46877. /** @hidden */
  46878. isOcclusionQueryInProgress: boolean;
  46879. /** @hidden */
  46880. isOccluded: boolean;
  46881. /** @hidden */
  46882. occlusionRetryCount: number;
  46883. /** @hidden */
  46884. occlusionType: number;
  46885. /** @hidden */
  46886. occlusionQueryAlgorithmType: number;
  46887. }
  46888. interface Engine {
  46889. /**
  46890. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46891. * @return the new query
  46892. */
  46893. createQuery(): WebGLQuery;
  46894. /**
  46895. * Delete and release a webGL query
  46896. * @param query defines the query to delete
  46897. * @return the current engine
  46898. */
  46899. deleteQuery(query: WebGLQuery): Engine;
  46900. /**
  46901. * Check if a given query has resolved and got its value
  46902. * @param query defines the query to check
  46903. * @returns true if the query got its value
  46904. */
  46905. isQueryResultAvailable(query: WebGLQuery): boolean;
  46906. /**
  46907. * Gets the value of a given query
  46908. * @param query defines the query to check
  46909. * @returns the value of the query
  46910. */
  46911. getQueryResult(query: WebGLQuery): number;
  46912. /**
  46913. * Initiates an occlusion query
  46914. * @param algorithmType defines the algorithm to use
  46915. * @param query defines the query to use
  46916. * @returns the current engine
  46917. * @see http://doc.babylonjs.com/features/occlusionquery
  46918. */
  46919. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46920. /**
  46921. * Ends an occlusion query
  46922. * @see http://doc.babylonjs.com/features/occlusionquery
  46923. * @param algorithmType defines the algorithm to use
  46924. * @returns the current engine
  46925. */
  46926. endOcclusionQuery(algorithmType: number): Engine;
  46927. /**
  46928. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46929. * Please note that only one query can be issued at a time
  46930. * @returns a time token used to track the time span
  46931. */
  46932. startTimeQuery(): Nullable<_TimeToken>;
  46933. /**
  46934. * Ends a time query
  46935. * @param token defines the token used to measure the time span
  46936. * @returns the time spent (in ns)
  46937. */
  46938. endTimeQuery(token: _TimeToken): int;
  46939. /** @hidden */
  46940. _currentNonTimestampToken: Nullable<_TimeToken>;
  46941. /** @hidden */
  46942. _createTimeQuery(): WebGLQuery;
  46943. /** @hidden */
  46944. _deleteTimeQuery(query: WebGLQuery): void;
  46945. /** @hidden */
  46946. _getGlAlgorithmType(algorithmType: number): number;
  46947. /** @hidden */
  46948. _getTimeQueryResult(query: WebGLQuery): any;
  46949. /** @hidden */
  46950. _getTimeQueryAvailability(query: WebGLQuery): any;
  46951. }
  46952. interface AbstractMesh {
  46953. /**
  46954. * Backing filed
  46955. * @hidden
  46956. */
  46957. __occlusionDataStorage: _OcclusionDataStorage;
  46958. /**
  46959. * Access property
  46960. * @hidden
  46961. */
  46962. _occlusionDataStorage: _OcclusionDataStorage;
  46963. /**
  46964. * 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.
  46965. * The default value is -1 which means don't break the query and wait till the result
  46966. * @see http://doc.babylonjs.com/features/occlusionquery
  46967. */
  46968. occlusionRetryCount: number;
  46969. /**
  46970. * 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:
  46971. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46972. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46973. * * 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.
  46974. * @see http://doc.babylonjs.com/features/occlusionquery
  46975. */
  46976. occlusionType: number;
  46977. /**
  46978. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46979. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46980. * * 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.
  46981. * @see http://doc.babylonjs.com/features/occlusionquery
  46982. */
  46983. occlusionQueryAlgorithmType: number;
  46984. /**
  46985. * 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
  46986. * @see http://doc.babylonjs.com/features/occlusionquery
  46987. */
  46988. isOccluded: boolean;
  46989. /**
  46990. * Flag to check the progress status of the query
  46991. * @see http://doc.babylonjs.com/features/occlusionquery
  46992. */
  46993. isOcclusionQueryInProgress: boolean;
  46994. }
  46995. }
  46996. declare module BABYLON {
  46997. /** @hidden */
  46998. export var _forceTransformFeedbackToBundle: boolean;
  46999. interface Engine {
  47000. /**
  47001. * Creates a webGL transform feedback object
  47002. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47003. * @returns the webGL transform feedback object
  47004. */
  47005. createTransformFeedback(): WebGLTransformFeedback;
  47006. /**
  47007. * Delete a webGL transform feedback object
  47008. * @param value defines the webGL transform feedback object to delete
  47009. */
  47010. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47011. /**
  47012. * Bind a webGL transform feedback object to the webgl context
  47013. * @param value defines the webGL transform feedback object to bind
  47014. */
  47015. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47016. /**
  47017. * Begins a transform feedback operation
  47018. * @param usePoints defines if points or triangles must be used
  47019. */
  47020. beginTransformFeedback(usePoints: boolean): void;
  47021. /**
  47022. * Ends a transform feedback operation
  47023. */
  47024. endTransformFeedback(): void;
  47025. /**
  47026. * Specify the varyings to use with transform feedback
  47027. * @param program defines the associated webGL program
  47028. * @param value defines the list of strings representing the varying names
  47029. */
  47030. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47031. /**
  47032. * Bind a webGL buffer for a transform feedback operation
  47033. * @param value defines the webGL buffer to bind
  47034. */
  47035. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47036. }
  47037. }
  47038. declare module BABYLON {
  47039. /**
  47040. * Creation options of the multi render target texture.
  47041. */
  47042. export interface IMultiRenderTargetOptions {
  47043. /**
  47044. * Define if the texture needs to create mip maps after render.
  47045. */
  47046. generateMipMaps?: boolean;
  47047. /**
  47048. * Define the types of all the draw buffers we want to create
  47049. */
  47050. types?: number[];
  47051. /**
  47052. * Define the sampling modes of all the draw buffers we want to create
  47053. */
  47054. samplingModes?: number[];
  47055. /**
  47056. * Define if a depth buffer is required
  47057. */
  47058. generateDepthBuffer?: boolean;
  47059. /**
  47060. * Define if a stencil buffer is required
  47061. */
  47062. generateStencilBuffer?: boolean;
  47063. /**
  47064. * Define if a depth texture is required instead of a depth buffer
  47065. */
  47066. generateDepthTexture?: boolean;
  47067. /**
  47068. * Define the number of desired draw buffers
  47069. */
  47070. textureCount?: number;
  47071. /**
  47072. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47073. */
  47074. doNotChangeAspectRatio?: boolean;
  47075. /**
  47076. * Define the default type of the buffers we are creating
  47077. */
  47078. defaultType?: number;
  47079. }
  47080. /**
  47081. * A multi render target, like a render target provides the ability to render to a texture.
  47082. * Unlike the render target, it can render to several draw buffers in one draw.
  47083. * This is specially interesting in deferred rendering or for any effects requiring more than
  47084. * just one color from a single pass.
  47085. */
  47086. export class MultiRenderTarget extends RenderTargetTexture {
  47087. private _internalTextures;
  47088. private _textures;
  47089. private _multiRenderTargetOptions;
  47090. /**
  47091. * Get if draw buffers are currently supported by the used hardware and browser.
  47092. */
  47093. get isSupported(): boolean;
  47094. /**
  47095. * Get the list of textures generated by the multi render target.
  47096. */
  47097. get textures(): Texture[];
  47098. /**
  47099. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47100. */
  47101. get depthTexture(): Texture;
  47102. /**
  47103. * Set the wrapping mode on U of all the textures we are rendering to.
  47104. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47105. */
  47106. set wrapU(wrap: number);
  47107. /**
  47108. * Set the wrapping mode on V of all the textures we are rendering to.
  47109. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47110. */
  47111. set wrapV(wrap: number);
  47112. /**
  47113. * Instantiate a new multi render target texture.
  47114. * A multi render target, like a render target provides the ability to render to a texture.
  47115. * Unlike the render target, it can render to several draw buffers in one draw.
  47116. * This is specially interesting in deferred rendering or for any effects requiring more than
  47117. * just one color from a single pass.
  47118. * @param name Define the name of the texture
  47119. * @param size Define the size of the buffers to render to
  47120. * @param count Define the number of target we are rendering into
  47121. * @param scene Define the scene the texture belongs to
  47122. * @param options Define the options used to create the multi render target
  47123. */
  47124. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47125. /** @hidden */
  47126. _rebuild(): void;
  47127. private _createInternalTextures;
  47128. private _createTextures;
  47129. /**
  47130. * Define the number of samples used if MSAA is enabled.
  47131. */
  47132. get samples(): number;
  47133. set samples(value: number);
  47134. /**
  47135. * Resize all the textures in the multi render target.
  47136. * Be carrefull as it will recreate all the data in the new texture.
  47137. * @param size Define the new size
  47138. */
  47139. resize(size: any): void;
  47140. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47141. /**
  47142. * Dispose the render targets and their associated resources
  47143. */
  47144. dispose(): void;
  47145. /**
  47146. * Release all the underlying texture used as draw buffers.
  47147. */
  47148. releaseInternalTextures(): void;
  47149. }
  47150. }
  47151. declare module BABYLON {
  47152. interface ThinEngine {
  47153. /**
  47154. * Unbind a list of render target textures from the webGL context
  47155. * This is used only when drawBuffer extension or webGL2 are active
  47156. * @param textures defines the render target textures to unbind
  47157. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47158. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47159. */
  47160. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47161. /**
  47162. * Create a multi render target texture
  47163. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47164. * @param size defines the size of the texture
  47165. * @param options defines the creation options
  47166. * @returns the cube texture as an InternalTexture
  47167. */
  47168. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47169. /**
  47170. * Update the sample count for a given multiple render target texture
  47171. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47172. * @param textures defines the textures to update
  47173. * @param samples defines the sample count to set
  47174. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47175. */
  47176. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47177. }
  47178. }
  47179. declare module BABYLON {
  47180. /**
  47181. * Class used to define an additional view for the engine
  47182. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47183. */
  47184. export class EngineView {
  47185. /** Defines the canvas where to render the view */
  47186. target: HTMLCanvasElement;
  47187. /** Defines an optional camera used to render the view (will use active camera else) */
  47188. camera?: Camera;
  47189. }
  47190. interface Engine {
  47191. /**
  47192. * Gets or sets the HTML element to use for attaching events
  47193. */
  47194. inputElement: Nullable<HTMLElement>;
  47195. /**
  47196. * Gets the current engine view
  47197. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47198. */
  47199. activeView: Nullable<EngineView>;
  47200. /** Gets or sets the list of views */
  47201. views: EngineView[];
  47202. /**
  47203. * Register a new child canvas
  47204. * @param canvas defines the canvas to register
  47205. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47206. * @returns the associated view
  47207. */
  47208. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47209. /**
  47210. * Remove a registered child canvas
  47211. * @param canvas defines the canvas to remove
  47212. * @returns the current engine
  47213. */
  47214. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47215. }
  47216. }
  47217. declare module BABYLON {
  47218. /**
  47219. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47220. */
  47221. export interface CubeMapInfo {
  47222. /**
  47223. * The pixel array for the front face.
  47224. * This is stored in format, left to right, up to down format.
  47225. */
  47226. front: Nullable<ArrayBufferView>;
  47227. /**
  47228. * The pixel array for the back face.
  47229. * This is stored in format, left to right, up to down format.
  47230. */
  47231. back: Nullable<ArrayBufferView>;
  47232. /**
  47233. * The pixel array for the left face.
  47234. * This is stored in format, left to right, up to down format.
  47235. */
  47236. left: Nullable<ArrayBufferView>;
  47237. /**
  47238. * The pixel array for the right face.
  47239. * This is stored in format, left to right, up to down format.
  47240. */
  47241. right: Nullable<ArrayBufferView>;
  47242. /**
  47243. * The pixel array for the up face.
  47244. * This is stored in format, left to right, up to down format.
  47245. */
  47246. up: Nullable<ArrayBufferView>;
  47247. /**
  47248. * The pixel array for the down face.
  47249. * This is stored in format, left to right, up to down format.
  47250. */
  47251. down: Nullable<ArrayBufferView>;
  47252. /**
  47253. * The size of the cubemap stored.
  47254. *
  47255. * Each faces will be size * size pixels.
  47256. */
  47257. size: number;
  47258. /**
  47259. * The format of the texture.
  47260. *
  47261. * RGBA, RGB.
  47262. */
  47263. format: number;
  47264. /**
  47265. * The type of the texture data.
  47266. *
  47267. * UNSIGNED_INT, FLOAT.
  47268. */
  47269. type: number;
  47270. /**
  47271. * Specifies whether the texture is in gamma space.
  47272. */
  47273. gammaSpace: boolean;
  47274. }
  47275. /**
  47276. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47277. */
  47278. export class PanoramaToCubeMapTools {
  47279. private static FACE_FRONT;
  47280. private static FACE_BACK;
  47281. private static FACE_RIGHT;
  47282. private static FACE_LEFT;
  47283. private static FACE_DOWN;
  47284. private static FACE_UP;
  47285. /**
  47286. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47287. *
  47288. * @param float32Array The source data.
  47289. * @param inputWidth The width of the input panorama.
  47290. * @param inputHeight The height of the input panorama.
  47291. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47292. * @return The cubemap data
  47293. */
  47294. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47295. private static CreateCubemapTexture;
  47296. private static CalcProjectionSpherical;
  47297. }
  47298. }
  47299. declare module BABYLON {
  47300. /**
  47301. * Helper class dealing with the extraction of spherical polynomial dataArray
  47302. * from a cube map.
  47303. */
  47304. export class CubeMapToSphericalPolynomialTools {
  47305. private static FileFaces;
  47306. /**
  47307. * Converts a texture to the according Spherical Polynomial data.
  47308. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47309. *
  47310. * @param texture The texture to extract the information from.
  47311. * @return The Spherical Polynomial data.
  47312. */
  47313. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47314. /**
  47315. * Converts a cubemap to the according Spherical Polynomial data.
  47316. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47317. *
  47318. * @param cubeInfo The Cube map to extract the information from.
  47319. * @return The Spherical Polynomial data.
  47320. */
  47321. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47322. }
  47323. }
  47324. declare module BABYLON {
  47325. interface BaseTexture {
  47326. /**
  47327. * Get the polynomial representation of the texture data.
  47328. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47329. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47330. */
  47331. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47332. }
  47333. }
  47334. declare module BABYLON {
  47335. /** @hidden */
  47336. export var rgbdEncodePixelShader: {
  47337. name: string;
  47338. shader: string;
  47339. };
  47340. }
  47341. declare module BABYLON {
  47342. /** @hidden */
  47343. export var rgbdDecodePixelShader: {
  47344. name: string;
  47345. shader: string;
  47346. };
  47347. }
  47348. declare module BABYLON {
  47349. /**
  47350. * Raw texture data and descriptor sufficient for WebGL texture upload
  47351. */
  47352. export interface EnvironmentTextureInfo {
  47353. /**
  47354. * Version of the environment map
  47355. */
  47356. version: number;
  47357. /**
  47358. * Width of image
  47359. */
  47360. width: number;
  47361. /**
  47362. * Irradiance information stored in the file.
  47363. */
  47364. irradiance: any;
  47365. /**
  47366. * Specular information stored in the file.
  47367. */
  47368. specular: any;
  47369. }
  47370. /**
  47371. * Defines One Image in the file. It requires only the position in the file
  47372. * as well as the length.
  47373. */
  47374. interface BufferImageData {
  47375. /**
  47376. * Length of the image data.
  47377. */
  47378. length: number;
  47379. /**
  47380. * Position of the data from the null terminator delimiting the end of the JSON.
  47381. */
  47382. position: number;
  47383. }
  47384. /**
  47385. * Defines the specular data enclosed in the file.
  47386. * This corresponds to the version 1 of the data.
  47387. */
  47388. export interface EnvironmentTextureSpecularInfoV1 {
  47389. /**
  47390. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47391. */
  47392. specularDataPosition?: number;
  47393. /**
  47394. * This contains all the images data needed to reconstruct the cubemap.
  47395. */
  47396. mipmaps: Array<BufferImageData>;
  47397. /**
  47398. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47399. */
  47400. lodGenerationScale: number;
  47401. }
  47402. /**
  47403. * Sets of helpers addressing the serialization and deserialization of environment texture
  47404. * stored in a BabylonJS env file.
  47405. * Those files are usually stored as .env files.
  47406. */
  47407. export class EnvironmentTextureTools {
  47408. /**
  47409. * Magic number identifying the env file.
  47410. */
  47411. private static _MagicBytes;
  47412. /**
  47413. * Gets the environment info from an env file.
  47414. * @param data The array buffer containing the .env bytes.
  47415. * @returns the environment file info (the json header) if successfully parsed.
  47416. */
  47417. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47418. /**
  47419. * Creates an environment texture from a loaded cube texture.
  47420. * @param texture defines the cube texture to convert in env file
  47421. * @return a promise containing the environment data if succesfull.
  47422. */
  47423. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47424. /**
  47425. * Creates a JSON representation of the spherical data.
  47426. * @param texture defines the texture containing the polynomials
  47427. * @return the JSON representation of the spherical info
  47428. */
  47429. private static _CreateEnvTextureIrradiance;
  47430. /**
  47431. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47432. * @param data the image data
  47433. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47434. * @return the views described by info providing access to the underlying buffer
  47435. */
  47436. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47437. /**
  47438. * Uploads the texture info contained in the env file to the GPU.
  47439. * @param texture defines the internal texture to upload to
  47440. * @param data defines the data to load
  47441. * @param info defines the texture info retrieved through the GetEnvInfo method
  47442. * @returns a promise
  47443. */
  47444. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47445. private static _OnImageReadyAsync;
  47446. /**
  47447. * Uploads the levels of image data to the GPU.
  47448. * @param texture defines the internal texture to upload to
  47449. * @param imageData defines the array buffer views of image data [mipmap][face]
  47450. * @returns a promise
  47451. */
  47452. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47453. /**
  47454. * Uploads spherical polynomials information to the texture.
  47455. * @param texture defines the texture we are trying to upload the information to
  47456. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47457. */
  47458. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47459. /** @hidden */
  47460. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47461. }
  47462. }
  47463. declare module BABYLON {
  47464. /**
  47465. * Contains position and normal vectors for a vertex
  47466. */
  47467. export class PositionNormalVertex {
  47468. /** the position of the vertex (defaut: 0,0,0) */
  47469. position: Vector3;
  47470. /** the normal of the vertex (defaut: 0,1,0) */
  47471. normal: Vector3;
  47472. /**
  47473. * Creates a PositionNormalVertex
  47474. * @param position the position of the vertex (defaut: 0,0,0)
  47475. * @param normal the normal of the vertex (defaut: 0,1,0)
  47476. */
  47477. constructor(
  47478. /** the position of the vertex (defaut: 0,0,0) */
  47479. position?: Vector3,
  47480. /** the normal of the vertex (defaut: 0,1,0) */
  47481. normal?: Vector3);
  47482. /**
  47483. * Clones the PositionNormalVertex
  47484. * @returns the cloned PositionNormalVertex
  47485. */
  47486. clone(): PositionNormalVertex;
  47487. }
  47488. /**
  47489. * Contains position, normal and uv vectors for a vertex
  47490. */
  47491. export class PositionNormalTextureVertex {
  47492. /** the position of the vertex (defaut: 0,0,0) */
  47493. position: Vector3;
  47494. /** the normal of the vertex (defaut: 0,1,0) */
  47495. normal: Vector3;
  47496. /** the uv of the vertex (default: 0,0) */
  47497. uv: Vector2;
  47498. /**
  47499. * Creates a PositionNormalTextureVertex
  47500. * @param position the position of the vertex (defaut: 0,0,0)
  47501. * @param normal the normal of the vertex (defaut: 0,1,0)
  47502. * @param uv the uv of the vertex (default: 0,0)
  47503. */
  47504. constructor(
  47505. /** the position of the vertex (defaut: 0,0,0) */
  47506. position?: Vector3,
  47507. /** the normal of the vertex (defaut: 0,1,0) */
  47508. normal?: Vector3,
  47509. /** the uv of the vertex (default: 0,0) */
  47510. uv?: Vector2);
  47511. /**
  47512. * Clones the PositionNormalTextureVertex
  47513. * @returns the cloned PositionNormalTextureVertex
  47514. */
  47515. clone(): PositionNormalTextureVertex;
  47516. }
  47517. }
  47518. declare module BABYLON {
  47519. /** @hidden */
  47520. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47521. private _genericAttributeLocation;
  47522. private _varyingLocationCount;
  47523. private _varyingLocationMap;
  47524. private _replacements;
  47525. private _textureCount;
  47526. private _uniforms;
  47527. lineProcessor(line: string): string;
  47528. attributeProcessor(attribute: string): string;
  47529. varyingProcessor(varying: string, isFragment: boolean): string;
  47530. uniformProcessor(uniform: string): string;
  47531. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47532. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47533. }
  47534. }
  47535. declare module BABYLON {
  47536. /**
  47537. * Container for accessors for natively-stored mesh data buffers.
  47538. */
  47539. class NativeDataBuffer extends DataBuffer {
  47540. /**
  47541. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47542. */
  47543. nativeIndexBuffer?: any;
  47544. /**
  47545. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47546. */
  47547. nativeVertexBuffer?: any;
  47548. }
  47549. /** @hidden */
  47550. class NativeTexture extends InternalTexture {
  47551. getInternalTexture(): InternalTexture;
  47552. getViewCount(): number;
  47553. }
  47554. /** @hidden */
  47555. export class NativeEngine extends Engine {
  47556. private readonly _native;
  47557. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47558. private readonly INVALID_HANDLE;
  47559. getHardwareScalingLevel(): number;
  47560. constructor();
  47561. /**
  47562. * Can be used to override the current requestAnimationFrame requester.
  47563. * @hidden
  47564. */
  47565. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47566. /**
  47567. * Override default engine behavior.
  47568. * @param color
  47569. * @param backBuffer
  47570. * @param depth
  47571. * @param stencil
  47572. */
  47573. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47574. /**
  47575. * Gets host document
  47576. * @returns the host document object
  47577. */
  47578. getHostDocument(): Nullable<Document>;
  47579. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47580. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47581. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47582. recordVertexArrayObject(vertexBuffers: {
  47583. [key: string]: VertexBuffer;
  47584. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47585. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47586. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47587. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47588. /**
  47589. * Draw a list of indexed primitives
  47590. * @param fillMode defines the primitive to use
  47591. * @param indexStart defines the starting index
  47592. * @param indexCount defines the number of index to draw
  47593. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47594. */
  47595. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47596. /**
  47597. * Draw a list of unindexed primitives
  47598. * @param fillMode defines the primitive to use
  47599. * @param verticesStart defines the index of first vertex to draw
  47600. * @param verticesCount defines the count of vertices to draw
  47601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47602. */
  47603. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47604. createPipelineContext(): IPipelineContext;
  47605. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47606. /** @hidden */
  47607. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47608. /** @hidden */
  47609. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47610. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47611. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47612. protected _setProgram(program: WebGLProgram): void;
  47613. _releaseEffect(effect: Effect): void;
  47614. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47615. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47616. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47617. bindSamplers(effect: Effect): void;
  47618. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47619. getRenderWidth(useScreen?: boolean): number;
  47620. getRenderHeight(useScreen?: boolean): number;
  47621. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47622. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47623. /**
  47624. * Set the z offset to apply to current rendering
  47625. * @param value defines the offset to apply
  47626. */
  47627. setZOffset(value: number): void;
  47628. /**
  47629. * Gets the current value of the zOffset
  47630. * @returns the current zOffset state
  47631. */
  47632. getZOffset(): number;
  47633. /**
  47634. * Enable or disable depth buffering
  47635. * @param enable defines the state to set
  47636. */
  47637. setDepthBuffer(enable: boolean): void;
  47638. /**
  47639. * Gets a boolean indicating if depth writing is enabled
  47640. * @returns the current depth writing state
  47641. */
  47642. getDepthWrite(): boolean;
  47643. /**
  47644. * Enable or disable depth writing
  47645. * @param enable defines the state to set
  47646. */
  47647. setDepthWrite(enable: boolean): void;
  47648. /**
  47649. * Enable or disable color writing
  47650. * @param enable defines the state to set
  47651. */
  47652. setColorWrite(enable: boolean): void;
  47653. /**
  47654. * Gets a boolean indicating if color writing is enabled
  47655. * @returns the current color writing state
  47656. */
  47657. getColorWrite(): boolean;
  47658. /**
  47659. * Sets alpha constants used by some alpha blending modes
  47660. * @param r defines the red component
  47661. * @param g defines the green component
  47662. * @param b defines the blue component
  47663. * @param a defines the alpha component
  47664. */
  47665. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47666. /**
  47667. * Sets the current alpha mode
  47668. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47669. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47670. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47671. */
  47672. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47673. /**
  47674. * Gets the current alpha mode
  47675. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47676. * @returns the current alpha mode
  47677. */
  47678. getAlphaMode(): number;
  47679. setInt(uniform: WebGLUniformLocation, int: number): void;
  47680. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47681. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47682. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47683. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47684. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47685. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47686. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47687. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47688. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47689. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47690. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47691. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47692. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47693. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47694. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47695. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47696. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47697. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47698. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47699. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47700. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47701. wipeCaches(bruteForce?: boolean): void;
  47702. _createTexture(): WebGLTexture;
  47703. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47704. /**
  47705. * Usually called from Texture.ts.
  47706. * Passed information to create a WebGLTexture
  47707. * @param urlArg defines a value which contains one of the following:
  47708. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47709. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47710. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47711. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47712. * @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)
  47713. * @param scene needed for loading to the correct scene
  47714. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47715. * @param onLoad optional callback to be called upon successful completion
  47716. * @param onError optional callback to be called upon failure
  47717. * @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
  47718. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47719. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47720. * @param forcedExtension defines the extension to use to pick the right loader
  47721. * @param mimeType defines an optional mime type
  47722. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47723. */
  47724. 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;
  47725. /**
  47726. * Creates a cube texture
  47727. * @param rootUrl defines the url where the files to load is located
  47728. * @param scene defines the current scene
  47729. * @param files defines the list of files to load (1 per face)
  47730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47731. * @param onLoad defines an optional callback raised when the texture is loaded
  47732. * @param onError defines an optional callback raised if there is an issue to load the texture
  47733. * @param format defines the format of the data
  47734. * @param forcedExtension defines the extension to use to pick the right loader
  47735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47738. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47739. * @returns the cube texture as an InternalTexture
  47740. */
  47741. 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;
  47742. private _getSamplingFilter;
  47743. private static _GetNativeTextureFormat;
  47744. createRenderTargetTexture(size: number | {
  47745. width: number;
  47746. height: number;
  47747. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47748. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47749. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47750. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47751. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47752. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47753. /**
  47754. * Updates a dynamic vertex buffer.
  47755. * @param vertexBuffer the vertex buffer to update
  47756. * @param data the data used to update the vertex buffer
  47757. * @param byteOffset the byte offset of the data (optional)
  47758. * @param byteLength the byte length of the data (optional)
  47759. */
  47760. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47761. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47762. private _updateAnisotropicLevel;
  47763. private _getAddressMode;
  47764. /** @hidden */
  47765. _bindTexture(channel: number, texture: InternalTexture): void;
  47766. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47767. releaseEffects(): void;
  47768. /** @hidden */
  47769. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47770. /** @hidden */
  47771. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47772. /** @hidden */
  47773. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47774. /** @hidden */
  47775. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47776. }
  47777. }
  47778. declare module BABYLON {
  47779. /**
  47780. * Gather the list of clipboard event types as constants.
  47781. */
  47782. export class ClipboardEventTypes {
  47783. /**
  47784. * The clipboard event is fired when a copy command is active (pressed).
  47785. */
  47786. static readonly COPY: number;
  47787. /**
  47788. * The clipboard event is fired when a cut command is active (pressed).
  47789. */
  47790. static readonly CUT: number;
  47791. /**
  47792. * The clipboard event is fired when a paste command is active (pressed).
  47793. */
  47794. static readonly PASTE: number;
  47795. }
  47796. /**
  47797. * This class is used to store clipboard related info for the onClipboardObservable event.
  47798. */
  47799. export class ClipboardInfo {
  47800. /**
  47801. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47802. */
  47803. type: number;
  47804. /**
  47805. * Defines the related dom event
  47806. */
  47807. event: ClipboardEvent;
  47808. /**
  47809. *Creates an instance of ClipboardInfo.
  47810. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47811. * @param event Defines the related dom event
  47812. */
  47813. constructor(
  47814. /**
  47815. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47816. */
  47817. type: number,
  47818. /**
  47819. * Defines the related dom event
  47820. */
  47821. event: ClipboardEvent);
  47822. /**
  47823. * Get the clipboard event's type from the keycode.
  47824. * @param keyCode Defines the keyCode for the current keyboard event.
  47825. * @return {number}
  47826. */
  47827. static GetTypeFromCharacter(keyCode: number): number;
  47828. }
  47829. }
  47830. declare module BABYLON {
  47831. /**
  47832. * Google Daydream controller
  47833. */
  47834. export class DaydreamController extends WebVRController {
  47835. /**
  47836. * Base Url for the controller model.
  47837. */
  47838. static MODEL_BASE_URL: string;
  47839. /**
  47840. * File name for the controller model.
  47841. */
  47842. static MODEL_FILENAME: string;
  47843. /**
  47844. * Gamepad Id prefix used to identify Daydream Controller.
  47845. */
  47846. static readonly GAMEPAD_ID_PREFIX: string;
  47847. /**
  47848. * Creates a new DaydreamController from a gamepad
  47849. * @param vrGamepad the gamepad that the controller should be created from
  47850. */
  47851. constructor(vrGamepad: any);
  47852. /**
  47853. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47854. * @param scene scene in which to add meshes
  47855. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47856. */
  47857. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47858. /**
  47859. * Called once for each button that changed state since the last frame
  47860. * @param buttonIdx Which button index changed
  47861. * @param state New state of the button
  47862. * @param changes Which properties on the state changed since last frame
  47863. */
  47864. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47865. }
  47866. }
  47867. declare module BABYLON {
  47868. /**
  47869. * Gear VR Controller
  47870. */
  47871. export class GearVRController extends WebVRController {
  47872. /**
  47873. * Base Url for the controller model.
  47874. */
  47875. static MODEL_BASE_URL: string;
  47876. /**
  47877. * File name for the controller model.
  47878. */
  47879. static MODEL_FILENAME: string;
  47880. /**
  47881. * Gamepad Id prefix used to identify this controller.
  47882. */
  47883. static readonly GAMEPAD_ID_PREFIX: string;
  47884. private readonly _buttonIndexToObservableNameMap;
  47885. /**
  47886. * Creates a new GearVRController from a gamepad
  47887. * @param vrGamepad the gamepad that the controller should be created from
  47888. */
  47889. constructor(vrGamepad: any);
  47890. /**
  47891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47892. * @param scene scene in which to add meshes
  47893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47894. */
  47895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47896. /**
  47897. * Called once for each button that changed state since the last frame
  47898. * @param buttonIdx Which button index changed
  47899. * @param state New state of the button
  47900. * @param changes Which properties on the state changed since last frame
  47901. */
  47902. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47903. }
  47904. }
  47905. declare module BABYLON {
  47906. /**
  47907. * Generic Controller
  47908. */
  47909. export class GenericController extends WebVRController {
  47910. /**
  47911. * Base Url for the controller model.
  47912. */
  47913. static readonly MODEL_BASE_URL: string;
  47914. /**
  47915. * File name for the controller model.
  47916. */
  47917. static readonly MODEL_FILENAME: string;
  47918. /**
  47919. * Creates a new GenericController from a gamepad
  47920. * @param vrGamepad the gamepad that the controller should be created from
  47921. */
  47922. constructor(vrGamepad: any);
  47923. /**
  47924. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47925. * @param scene scene in which to add meshes
  47926. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47927. */
  47928. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47929. /**
  47930. * Called once for each button that changed state since the last frame
  47931. * @param buttonIdx Which button index changed
  47932. * @param state New state of the button
  47933. * @param changes Which properties on the state changed since last frame
  47934. */
  47935. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47936. }
  47937. }
  47938. declare module BABYLON {
  47939. /**
  47940. * Oculus Touch Controller
  47941. */
  47942. export class OculusTouchController extends WebVRController {
  47943. /**
  47944. * Base Url for the controller model.
  47945. */
  47946. static MODEL_BASE_URL: string;
  47947. /**
  47948. * File name for the left controller model.
  47949. */
  47950. static MODEL_LEFT_FILENAME: string;
  47951. /**
  47952. * File name for the right controller model.
  47953. */
  47954. static MODEL_RIGHT_FILENAME: string;
  47955. /**
  47956. * Base Url for the Quest controller model.
  47957. */
  47958. static QUEST_MODEL_BASE_URL: string;
  47959. /**
  47960. * @hidden
  47961. * If the controllers are running on a device that needs the updated Quest controller models
  47962. */
  47963. static _IsQuest: boolean;
  47964. /**
  47965. * Fired when the secondary trigger on this controller is modified
  47966. */
  47967. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47968. /**
  47969. * Fired when the thumb rest on this controller is modified
  47970. */
  47971. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  47972. /**
  47973. * Creates a new OculusTouchController from a gamepad
  47974. * @param vrGamepad the gamepad that the controller should be created from
  47975. */
  47976. constructor(vrGamepad: any);
  47977. /**
  47978. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47979. * @param scene scene in which to add meshes
  47980. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47981. */
  47982. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47983. /**
  47984. * Fired when the A button on this controller is modified
  47985. */
  47986. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47987. /**
  47988. * Fired when the B button on this controller is modified
  47989. */
  47990. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47991. /**
  47992. * Fired when the X button on this controller is modified
  47993. */
  47994. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47995. /**
  47996. * Fired when the Y button on this controller is modified
  47997. */
  47998. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47999. /**
  48000. * Called once for each button that changed state since the last frame
  48001. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48002. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48003. * 2) secondary trigger (same)
  48004. * 3) A (right) X (left), touch, pressed = value
  48005. * 4) B / Y
  48006. * 5) thumb rest
  48007. * @param buttonIdx Which button index changed
  48008. * @param state New state of the button
  48009. * @param changes Which properties on the state changed since last frame
  48010. */
  48011. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48012. }
  48013. }
  48014. declare module BABYLON {
  48015. /**
  48016. * Vive Controller
  48017. */
  48018. export class ViveController extends WebVRController {
  48019. /**
  48020. * Base Url for the controller model.
  48021. */
  48022. static MODEL_BASE_URL: string;
  48023. /**
  48024. * File name for the controller model.
  48025. */
  48026. static MODEL_FILENAME: string;
  48027. /**
  48028. * Creates a new ViveController from a gamepad
  48029. * @param vrGamepad the gamepad that the controller should be created from
  48030. */
  48031. constructor(vrGamepad: any);
  48032. /**
  48033. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48034. * @param scene scene in which to add meshes
  48035. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48036. */
  48037. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48038. /**
  48039. * Fired when the left button on this controller is modified
  48040. */
  48041. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48042. /**
  48043. * Fired when the right button on this controller is modified
  48044. */
  48045. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48046. /**
  48047. * Fired when the menu button on this controller is modified
  48048. */
  48049. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48050. /**
  48051. * Called once for each button that changed state since the last frame
  48052. * Vive mapping:
  48053. * 0: touchpad
  48054. * 1: trigger
  48055. * 2: left AND right buttons
  48056. * 3: menu button
  48057. * @param buttonIdx Which button index changed
  48058. * @param state New state of the button
  48059. * @param changes Which properties on the state changed since last frame
  48060. */
  48061. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48062. }
  48063. }
  48064. declare module BABYLON {
  48065. /**
  48066. * Defines the WindowsMotionController object that the state of the windows motion controller
  48067. */
  48068. export class WindowsMotionController extends WebVRController {
  48069. /**
  48070. * The base url used to load the left and right controller models
  48071. */
  48072. static MODEL_BASE_URL: string;
  48073. /**
  48074. * The name of the left controller model file
  48075. */
  48076. static MODEL_LEFT_FILENAME: string;
  48077. /**
  48078. * The name of the right controller model file
  48079. */
  48080. static MODEL_RIGHT_FILENAME: string;
  48081. /**
  48082. * The controller name prefix for this controller type
  48083. */
  48084. static readonly GAMEPAD_ID_PREFIX: string;
  48085. /**
  48086. * The controller id pattern for this controller type
  48087. */
  48088. private static readonly GAMEPAD_ID_PATTERN;
  48089. private _loadedMeshInfo;
  48090. protected readonly _mapping: {
  48091. buttons: string[];
  48092. buttonMeshNames: {
  48093. 'trigger': string;
  48094. 'menu': string;
  48095. 'grip': string;
  48096. 'thumbstick': string;
  48097. 'trackpad': string;
  48098. };
  48099. buttonObservableNames: {
  48100. 'trigger': string;
  48101. 'menu': string;
  48102. 'grip': string;
  48103. 'thumbstick': string;
  48104. 'trackpad': string;
  48105. };
  48106. axisMeshNames: string[];
  48107. pointingPoseMeshName: string;
  48108. };
  48109. /**
  48110. * Fired when the trackpad on this controller is clicked
  48111. */
  48112. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48113. /**
  48114. * Fired when the trackpad on this controller is modified
  48115. */
  48116. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48117. /**
  48118. * The current x and y values of this controller's trackpad
  48119. */
  48120. trackpad: StickValues;
  48121. /**
  48122. * Creates a new WindowsMotionController from a gamepad
  48123. * @param vrGamepad the gamepad that the controller should be created from
  48124. */
  48125. constructor(vrGamepad: any);
  48126. /**
  48127. * Fired when the trigger on this controller is modified
  48128. */
  48129. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48130. /**
  48131. * Fired when the menu button on this controller is modified
  48132. */
  48133. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48134. /**
  48135. * Fired when the grip button on this controller is modified
  48136. */
  48137. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48138. /**
  48139. * Fired when the thumbstick button on this controller is modified
  48140. */
  48141. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48142. /**
  48143. * Fired when the touchpad button on this controller is modified
  48144. */
  48145. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48146. /**
  48147. * Fired when the touchpad values on this controller are modified
  48148. */
  48149. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48150. protected _updateTrackpad(): void;
  48151. /**
  48152. * Called once per frame by the engine.
  48153. */
  48154. update(): void;
  48155. /**
  48156. * Called once for each button that changed state since the last frame
  48157. * @param buttonIdx Which button index changed
  48158. * @param state New state of the button
  48159. * @param changes Which properties on the state changed since last frame
  48160. */
  48161. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48162. /**
  48163. * Moves the buttons on the controller mesh based on their current state
  48164. * @param buttonName the name of the button to move
  48165. * @param buttonValue the value of the button which determines the buttons new position
  48166. */
  48167. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48168. /**
  48169. * Moves the axis on the controller mesh based on its current state
  48170. * @param axis the index of the axis
  48171. * @param axisValue the value of the axis which determines the meshes new position
  48172. * @hidden
  48173. */
  48174. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48175. /**
  48176. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48177. * @param scene scene in which to add meshes
  48178. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48179. */
  48180. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48181. /**
  48182. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48183. * can be transformed by button presses and axes values, based on this._mapping.
  48184. *
  48185. * @param scene scene in which the meshes exist
  48186. * @param meshes list of meshes that make up the controller model to process
  48187. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48188. */
  48189. private processModel;
  48190. private createMeshInfo;
  48191. /**
  48192. * Gets the ray of the controller in the direction the controller is pointing
  48193. * @param length the length the resulting ray should be
  48194. * @returns a ray in the direction the controller is pointing
  48195. */
  48196. getForwardRay(length?: number): Ray;
  48197. /**
  48198. * Disposes of the controller
  48199. */
  48200. dispose(): void;
  48201. }
  48202. /**
  48203. * This class represents a new windows motion controller in XR.
  48204. */
  48205. export class XRWindowsMotionController extends WindowsMotionController {
  48206. /**
  48207. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48208. */
  48209. protected readonly _mapping: {
  48210. buttons: string[];
  48211. buttonMeshNames: {
  48212. 'trigger': string;
  48213. 'menu': string;
  48214. 'grip': string;
  48215. 'thumbstick': string;
  48216. 'trackpad': string;
  48217. };
  48218. buttonObservableNames: {
  48219. 'trigger': string;
  48220. 'menu': string;
  48221. 'grip': string;
  48222. 'thumbstick': string;
  48223. 'trackpad': string;
  48224. };
  48225. axisMeshNames: string[];
  48226. pointingPoseMeshName: string;
  48227. };
  48228. /**
  48229. * Construct a new XR-Based windows motion controller
  48230. *
  48231. * @param gamepadInfo the gamepad object from the browser
  48232. */
  48233. constructor(gamepadInfo: any);
  48234. /**
  48235. * holds the thumbstick values (X,Y)
  48236. */
  48237. thumbstickValues: StickValues;
  48238. /**
  48239. * Fired when the thumbstick on this controller is clicked
  48240. */
  48241. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48242. /**
  48243. * Fired when the thumbstick on this controller is modified
  48244. */
  48245. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48246. /**
  48247. * Fired when the touchpad button on this controller is modified
  48248. */
  48249. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48250. /**
  48251. * Fired when the touchpad values on this controller are modified
  48252. */
  48253. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48254. /**
  48255. * Fired when the thumbstick button on this controller is modified
  48256. * here to prevent breaking changes
  48257. */
  48258. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48259. /**
  48260. * updating the thumbstick(!) and not the trackpad.
  48261. * This is named this way due to the difference between WebVR and XR and to avoid
  48262. * changing the parent class.
  48263. */
  48264. protected _updateTrackpad(): void;
  48265. /**
  48266. * Disposes the class with joy
  48267. */
  48268. dispose(): void;
  48269. }
  48270. }
  48271. declare module BABYLON {
  48272. /**
  48273. * Class containing static functions to help procedurally build meshes
  48274. */
  48275. export class PolyhedronBuilder {
  48276. /**
  48277. * Creates a polyhedron mesh
  48278. * * 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
  48279. * * The parameter `size` (positive float, default 1) sets the polygon size
  48280. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48281. * * 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`
  48282. * * 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
  48283. * * 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)`)
  48284. * * 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
  48285. * * 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
  48286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48287. * * 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
  48288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48289. * @param name defines the name of the mesh
  48290. * @param options defines the options used to create the mesh
  48291. * @param scene defines the hosting scene
  48292. * @returns the polyhedron mesh
  48293. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48294. */
  48295. static CreatePolyhedron(name: string, options: {
  48296. type?: number;
  48297. size?: number;
  48298. sizeX?: number;
  48299. sizeY?: number;
  48300. sizeZ?: number;
  48301. custom?: any;
  48302. faceUV?: Vector4[];
  48303. faceColors?: Color4[];
  48304. flat?: boolean;
  48305. updatable?: boolean;
  48306. sideOrientation?: number;
  48307. frontUVs?: Vector4;
  48308. backUVs?: Vector4;
  48309. }, scene?: Nullable<Scene>): Mesh;
  48310. }
  48311. }
  48312. declare module BABYLON {
  48313. /**
  48314. * Gizmo that enables scaling a mesh along 3 axis
  48315. */
  48316. export class ScaleGizmo extends Gizmo {
  48317. /**
  48318. * Internal gizmo used for interactions on the x axis
  48319. */
  48320. xGizmo: AxisScaleGizmo;
  48321. /**
  48322. * Internal gizmo used for interactions on the y axis
  48323. */
  48324. yGizmo: AxisScaleGizmo;
  48325. /**
  48326. * Internal gizmo used for interactions on the z axis
  48327. */
  48328. zGizmo: AxisScaleGizmo;
  48329. /**
  48330. * Internal gizmo used to scale all axis equally
  48331. */
  48332. uniformScaleGizmo: AxisScaleGizmo;
  48333. private _meshAttached;
  48334. private _updateGizmoRotationToMatchAttachedMesh;
  48335. private _snapDistance;
  48336. private _scaleRatio;
  48337. private _uniformScalingMesh;
  48338. private _octahedron;
  48339. private _sensitivity;
  48340. /** Fires an event when any of it's sub gizmos are dragged */
  48341. onDragStartObservable: Observable<unknown>;
  48342. /** Fires an event when any of it's sub gizmos are released from dragging */
  48343. onDragEndObservable: Observable<unknown>;
  48344. get attachedMesh(): Nullable<AbstractMesh>;
  48345. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48346. /**
  48347. * Creates a ScaleGizmo
  48348. * @param gizmoLayer The utility layer the gizmo will be added to
  48349. */
  48350. constructor(gizmoLayer?: UtilityLayerRenderer);
  48351. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48352. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48353. /**
  48354. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48355. */
  48356. set snapDistance(value: number);
  48357. get snapDistance(): number;
  48358. /**
  48359. * Ratio for the scale of the gizmo (Default: 1)
  48360. */
  48361. set scaleRatio(value: number);
  48362. get scaleRatio(): number;
  48363. /**
  48364. * Sensitivity factor for dragging (Default: 1)
  48365. */
  48366. set sensitivity(value: number);
  48367. get sensitivity(): number;
  48368. /**
  48369. * Disposes of the gizmo
  48370. */
  48371. dispose(): void;
  48372. }
  48373. }
  48374. declare module BABYLON {
  48375. /**
  48376. * Single axis scale gizmo
  48377. */
  48378. export class AxisScaleGizmo extends Gizmo {
  48379. /**
  48380. * Drag behavior responsible for the gizmos dragging interactions
  48381. */
  48382. dragBehavior: PointerDragBehavior;
  48383. private _pointerObserver;
  48384. /**
  48385. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48386. */
  48387. snapDistance: number;
  48388. /**
  48389. * Event that fires each time the gizmo snaps to a new location.
  48390. * * snapDistance is the the change in distance
  48391. */
  48392. onSnapObservable: Observable<{
  48393. snapDistance: number;
  48394. }>;
  48395. /**
  48396. * If the scaling operation should be done on all axis (default: false)
  48397. */
  48398. uniformScaling: boolean;
  48399. /**
  48400. * Custom sensitivity value for the drag strength
  48401. */
  48402. sensitivity: number;
  48403. private _isEnabled;
  48404. private _parent;
  48405. private _arrow;
  48406. private _coloredMaterial;
  48407. private _hoverMaterial;
  48408. /**
  48409. * Creates an AxisScaleGizmo
  48410. * @param gizmoLayer The utility layer the gizmo will be added to
  48411. * @param dragAxis The axis which the gizmo will be able to scale on
  48412. * @param color The color of the gizmo
  48413. */
  48414. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48415. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48416. /**
  48417. * If the gizmo is enabled
  48418. */
  48419. set isEnabled(value: boolean);
  48420. get isEnabled(): boolean;
  48421. /**
  48422. * Disposes of the gizmo
  48423. */
  48424. dispose(): void;
  48425. /**
  48426. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48427. * @param mesh The mesh to replace the default mesh of the gizmo
  48428. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48429. */
  48430. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48431. }
  48432. }
  48433. declare module BABYLON {
  48434. /**
  48435. * Bounding box gizmo
  48436. */
  48437. export class BoundingBoxGizmo extends Gizmo {
  48438. private _lineBoundingBox;
  48439. private _rotateSpheresParent;
  48440. private _scaleBoxesParent;
  48441. private _boundingDimensions;
  48442. private _renderObserver;
  48443. private _pointerObserver;
  48444. private _scaleDragSpeed;
  48445. private _tmpQuaternion;
  48446. private _tmpVector;
  48447. private _tmpRotationMatrix;
  48448. /**
  48449. * 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)
  48450. */
  48451. ignoreChildren: boolean;
  48452. /**
  48453. * 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)
  48454. */
  48455. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48456. /**
  48457. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48458. */
  48459. rotationSphereSize: number;
  48460. /**
  48461. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48462. */
  48463. scaleBoxSize: number;
  48464. /**
  48465. * 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)
  48466. */
  48467. fixedDragMeshScreenSize: boolean;
  48468. /**
  48469. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48470. */
  48471. fixedDragMeshScreenSizeDistanceFactor: number;
  48472. /**
  48473. * Fired when a rotation sphere or scale box is dragged
  48474. */
  48475. onDragStartObservable: Observable<{}>;
  48476. /**
  48477. * Fired when a scale box is dragged
  48478. */
  48479. onScaleBoxDragObservable: Observable<{}>;
  48480. /**
  48481. * Fired when a scale box drag is ended
  48482. */
  48483. onScaleBoxDragEndObservable: Observable<{}>;
  48484. /**
  48485. * Fired when a rotation sphere is dragged
  48486. */
  48487. onRotationSphereDragObservable: Observable<{}>;
  48488. /**
  48489. * Fired when a rotation sphere drag is ended
  48490. */
  48491. onRotationSphereDragEndObservable: Observable<{}>;
  48492. /**
  48493. * 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)
  48494. */
  48495. scalePivot: Nullable<Vector3>;
  48496. /**
  48497. * Mesh used as a pivot to rotate the attached mesh
  48498. */
  48499. private _anchorMesh;
  48500. private _existingMeshScale;
  48501. private _dragMesh;
  48502. private pointerDragBehavior;
  48503. private coloredMaterial;
  48504. private hoverColoredMaterial;
  48505. /**
  48506. * Sets the color of the bounding box gizmo
  48507. * @param color the color to set
  48508. */
  48509. setColor(color: Color3): void;
  48510. /**
  48511. * Creates an BoundingBoxGizmo
  48512. * @param gizmoLayer The utility layer the gizmo will be added to
  48513. * @param color The color of the gizmo
  48514. */
  48515. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48516. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48517. private _selectNode;
  48518. /**
  48519. * Updates the bounding box information for the Gizmo
  48520. */
  48521. updateBoundingBox(): void;
  48522. private _updateRotationSpheres;
  48523. private _updateScaleBoxes;
  48524. /**
  48525. * Enables rotation on the specified axis and disables rotation on the others
  48526. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48527. */
  48528. setEnabledRotationAxis(axis: string): void;
  48529. /**
  48530. * Enables/disables scaling
  48531. * @param enable if scaling should be enabled
  48532. */
  48533. setEnabledScaling(enable: boolean): void;
  48534. private _updateDummy;
  48535. /**
  48536. * Enables a pointer drag behavior on the bounding box of the gizmo
  48537. */
  48538. enableDragBehavior(): void;
  48539. /**
  48540. * Disposes of the gizmo
  48541. */
  48542. dispose(): void;
  48543. /**
  48544. * 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)
  48545. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48546. * @returns the bounding box mesh with the passed in mesh as a child
  48547. */
  48548. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48549. /**
  48550. * CustomMeshes are not supported by this gizmo
  48551. * @param mesh The mesh to replace the default mesh of the gizmo
  48552. */
  48553. setCustomMesh(mesh: Mesh): void;
  48554. }
  48555. }
  48556. declare module BABYLON {
  48557. /**
  48558. * Single plane rotation gizmo
  48559. */
  48560. export class PlaneRotationGizmo extends Gizmo {
  48561. /**
  48562. * Drag behavior responsible for the gizmos dragging interactions
  48563. */
  48564. dragBehavior: PointerDragBehavior;
  48565. private _pointerObserver;
  48566. /**
  48567. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48568. */
  48569. snapDistance: number;
  48570. /**
  48571. * Event that fires each time the gizmo snaps to a new location.
  48572. * * snapDistance is the the change in distance
  48573. */
  48574. onSnapObservable: Observable<{
  48575. snapDistance: number;
  48576. }>;
  48577. private _isEnabled;
  48578. private _parent;
  48579. /**
  48580. * Creates a PlaneRotationGizmo
  48581. * @param gizmoLayer The utility layer the gizmo will be added to
  48582. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48583. * @param color The color of the gizmo
  48584. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48585. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48586. */
  48587. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48588. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48589. /**
  48590. * If the gizmo is enabled
  48591. */
  48592. set isEnabled(value: boolean);
  48593. get isEnabled(): boolean;
  48594. /**
  48595. * Disposes of the gizmo
  48596. */
  48597. dispose(): void;
  48598. }
  48599. }
  48600. declare module BABYLON {
  48601. /**
  48602. * Gizmo that enables rotating a mesh along 3 axis
  48603. */
  48604. export class RotationGizmo extends Gizmo {
  48605. /**
  48606. * Internal gizmo used for interactions on the x axis
  48607. */
  48608. xGizmo: PlaneRotationGizmo;
  48609. /**
  48610. * Internal gizmo used for interactions on the y axis
  48611. */
  48612. yGizmo: PlaneRotationGizmo;
  48613. /**
  48614. * Internal gizmo used for interactions on the z axis
  48615. */
  48616. zGizmo: PlaneRotationGizmo;
  48617. /** Fires an event when any of it's sub gizmos are dragged */
  48618. onDragStartObservable: Observable<unknown>;
  48619. /** Fires an event when any of it's sub gizmos are released from dragging */
  48620. onDragEndObservable: Observable<unknown>;
  48621. private _meshAttached;
  48622. get attachedMesh(): Nullable<AbstractMesh>;
  48623. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48624. /**
  48625. * Creates a RotationGizmo
  48626. * @param gizmoLayer The utility layer the gizmo will be added to
  48627. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48628. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48629. */
  48630. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48631. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48632. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48633. /**
  48634. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48635. */
  48636. set snapDistance(value: number);
  48637. get snapDistance(): number;
  48638. /**
  48639. * Ratio for the scale of the gizmo (Default: 1)
  48640. */
  48641. set scaleRatio(value: number);
  48642. get scaleRatio(): number;
  48643. /**
  48644. * Disposes of the gizmo
  48645. */
  48646. dispose(): void;
  48647. /**
  48648. * CustomMeshes are not supported by this gizmo
  48649. * @param mesh The mesh to replace the default mesh of the gizmo
  48650. */
  48651. setCustomMesh(mesh: Mesh): void;
  48652. }
  48653. }
  48654. declare module BABYLON {
  48655. /**
  48656. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48657. */
  48658. export class GizmoManager implements IDisposable {
  48659. private scene;
  48660. /**
  48661. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48662. */
  48663. gizmos: {
  48664. positionGizmo: Nullable<PositionGizmo>;
  48665. rotationGizmo: Nullable<RotationGizmo>;
  48666. scaleGizmo: Nullable<ScaleGizmo>;
  48667. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48668. };
  48669. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48670. clearGizmoOnEmptyPointerEvent: boolean;
  48671. /** Fires an event when the manager is attached to a mesh */
  48672. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48673. private _gizmosEnabled;
  48674. private _pointerObserver;
  48675. private _attachedMesh;
  48676. private _boundingBoxColor;
  48677. private _defaultUtilityLayer;
  48678. private _defaultKeepDepthUtilityLayer;
  48679. /**
  48680. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48681. */
  48682. boundingBoxDragBehavior: SixDofDragBehavior;
  48683. /**
  48684. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48685. */
  48686. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48687. /**
  48688. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48689. */
  48690. usePointerToAttachGizmos: boolean;
  48691. /**
  48692. * Utility layer that the bounding box gizmo belongs to
  48693. */
  48694. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48695. /**
  48696. * Utility layer that all gizmos besides bounding box belong to
  48697. */
  48698. get utilityLayer(): UtilityLayerRenderer;
  48699. /**
  48700. * Instatiates a gizmo manager
  48701. * @param scene the scene to overlay the gizmos on top of
  48702. */
  48703. constructor(scene: Scene);
  48704. /**
  48705. * Attaches a set of gizmos to the specified mesh
  48706. * @param mesh The mesh the gizmo's should be attached to
  48707. */
  48708. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48709. /**
  48710. * If the position gizmo is enabled
  48711. */
  48712. set positionGizmoEnabled(value: boolean);
  48713. get positionGizmoEnabled(): boolean;
  48714. /**
  48715. * If the rotation gizmo is enabled
  48716. */
  48717. set rotationGizmoEnabled(value: boolean);
  48718. get rotationGizmoEnabled(): boolean;
  48719. /**
  48720. * If the scale gizmo is enabled
  48721. */
  48722. set scaleGizmoEnabled(value: boolean);
  48723. get scaleGizmoEnabled(): boolean;
  48724. /**
  48725. * If the boundingBox gizmo is enabled
  48726. */
  48727. set boundingBoxGizmoEnabled(value: boolean);
  48728. get boundingBoxGizmoEnabled(): boolean;
  48729. /**
  48730. * Disposes of the gizmo manager
  48731. */
  48732. dispose(): void;
  48733. }
  48734. }
  48735. declare module BABYLON {
  48736. /**
  48737. * A directional light is defined by a direction (what a surprise!).
  48738. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48739. * 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.
  48740. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48741. */
  48742. export class DirectionalLight extends ShadowLight {
  48743. private _shadowFrustumSize;
  48744. /**
  48745. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48746. */
  48747. get shadowFrustumSize(): number;
  48748. /**
  48749. * Specifies a fix frustum size for the shadow generation.
  48750. */
  48751. set shadowFrustumSize(value: number);
  48752. private _shadowOrthoScale;
  48753. /**
  48754. * Gets the shadow projection scale against the optimal computed one.
  48755. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48756. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48757. */
  48758. get shadowOrthoScale(): number;
  48759. /**
  48760. * Sets the shadow projection scale against the optimal computed one.
  48761. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48762. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48763. */
  48764. set shadowOrthoScale(value: number);
  48765. /**
  48766. * Automatically compute the projection matrix to best fit (including all the casters)
  48767. * on each frame.
  48768. */
  48769. autoUpdateExtends: boolean;
  48770. /**
  48771. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48772. * on each frame. autoUpdateExtends must be set to true for this to work
  48773. */
  48774. autoCalcShadowZBounds: boolean;
  48775. private _orthoLeft;
  48776. private _orthoRight;
  48777. private _orthoTop;
  48778. private _orthoBottom;
  48779. /**
  48780. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48781. * The directional light is emitted from everywhere in the given direction.
  48782. * It can cast shadows.
  48783. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48784. * @param name The friendly name of the light
  48785. * @param direction The direction of the light
  48786. * @param scene The scene the light belongs to
  48787. */
  48788. constructor(name: string, direction: Vector3, scene: Scene);
  48789. /**
  48790. * Returns the string "DirectionalLight".
  48791. * @return The class name
  48792. */
  48793. getClassName(): string;
  48794. /**
  48795. * Returns the integer 1.
  48796. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48797. */
  48798. getTypeID(): number;
  48799. /**
  48800. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48801. * Returns the DirectionalLight Shadow projection matrix.
  48802. */
  48803. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48804. /**
  48805. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48806. * Returns the DirectionalLight Shadow projection matrix.
  48807. */
  48808. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48809. /**
  48810. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48811. * Returns the DirectionalLight Shadow projection matrix.
  48812. */
  48813. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48814. protected _buildUniformLayout(): void;
  48815. /**
  48816. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48817. * @param effect The effect to update
  48818. * @param lightIndex The index of the light in the effect to update
  48819. * @returns The directional light
  48820. */
  48821. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48822. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48823. /**
  48824. * Gets the minZ used for shadow according to both the scene and the light.
  48825. *
  48826. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48827. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48828. * @param activeCamera The camera we are returning the min for
  48829. * @returns the depth min z
  48830. */
  48831. getDepthMinZ(activeCamera: Camera): number;
  48832. /**
  48833. * Gets the maxZ used for shadow according to both the scene and the light.
  48834. *
  48835. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48836. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48837. * @param activeCamera The camera we are returning the max for
  48838. * @returns the depth max z
  48839. */
  48840. getDepthMaxZ(activeCamera: Camera): number;
  48841. /**
  48842. * Prepares the list of defines specific to the light type.
  48843. * @param defines the list of defines
  48844. * @param lightIndex defines the index of the light for the effect
  48845. */
  48846. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48847. }
  48848. }
  48849. declare module BABYLON {
  48850. /**
  48851. * Class containing static functions to help procedurally build meshes
  48852. */
  48853. export class HemisphereBuilder {
  48854. /**
  48855. * Creates a hemisphere mesh
  48856. * @param name defines the name of the mesh
  48857. * @param options defines the options used to create the mesh
  48858. * @param scene defines the hosting scene
  48859. * @returns the hemisphere mesh
  48860. */
  48861. static CreateHemisphere(name: string, options: {
  48862. segments?: number;
  48863. diameter?: number;
  48864. sideOrientation?: number;
  48865. }, scene: any): Mesh;
  48866. }
  48867. }
  48868. declare module BABYLON {
  48869. /**
  48870. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48871. * These values define a cone of light starting from the position, emitting toward the direction.
  48872. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48873. * and the exponent defines the speed of the decay of the light with distance (reach).
  48874. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48875. */
  48876. export class SpotLight extends ShadowLight {
  48877. private _angle;
  48878. private _innerAngle;
  48879. private _cosHalfAngle;
  48880. private _lightAngleScale;
  48881. private _lightAngleOffset;
  48882. /**
  48883. * Gets the cone angle of the spot light in Radians.
  48884. */
  48885. get angle(): number;
  48886. /**
  48887. * Sets the cone angle of the spot light in Radians.
  48888. */
  48889. set angle(value: number);
  48890. /**
  48891. * Only used in gltf falloff mode, this defines the angle where
  48892. * the directional falloff will start before cutting at angle which could be seen
  48893. * as outer angle.
  48894. */
  48895. get innerAngle(): number;
  48896. /**
  48897. * Only used in gltf falloff mode, this defines the angle where
  48898. * the directional falloff will start before cutting at angle which could be seen
  48899. * as outer angle.
  48900. */
  48901. set innerAngle(value: number);
  48902. private _shadowAngleScale;
  48903. /**
  48904. * Allows scaling the angle of the light for shadow generation only.
  48905. */
  48906. get shadowAngleScale(): number;
  48907. /**
  48908. * Allows scaling the angle of the light for shadow generation only.
  48909. */
  48910. set shadowAngleScale(value: number);
  48911. /**
  48912. * The light decay speed with the distance from the emission spot.
  48913. */
  48914. exponent: number;
  48915. private _projectionTextureMatrix;
  48916. /**
  48917. * Allows reading the projecton texture
  48918. */
  48919. get projectionTextureMatrix(): Matrix;
  48920. protected _projectionTextureLightNear: number;
  48921. /**
  48922. * Gets the near clip of the Spotlight for texture projection.
  48923. */
  48924. get projectionTextureLightNear(): number;
  48925. /**
  48926. * Sets the near clip of the Spotlight for texture projection.
  48927. */
  48928. set projectionTextureLightNear(value: number);
  48929. protected _projectionTextureLightFar: number;
  48930. /**
  48931. * Gets the far clip of the Spotlight for texture projection.
  48932. */
  48933. get projectionTextureLightFar(): number;
  48934. /**
  48935. * Sets the far clip of the Spotlight for texture projection.
  48936. */
  48937. set projectionTextureLightFar(value: number);
  48938. protected _projectionTextureUpDirection: Vector3;
  48939. /**
  48940. * Gets the Up vector of the Spotlight for texture projection.
  48941. */
  48942. get projectionTextureUpDirection(): Vector3;
  48943. /**
  48944. * Sets the Up vector of the Spotlight for texture projection.
  48945. */
  48946. set projectionTextureUpDirection(value: Vector3);
  48947. private _projectionTexture;
  48948. /**
  48949. * Gets the projection texture of the light.
  48950. */
  48951. get projectionTexture(): Nullable<BaseTexture>;
  48952. /**
  48953. * Sets the projection texture of the light.
  48954. */
  48955. set projectionTexture(value: Nullable<BaseTexture>);
  48956. private _projectionTextureViewLightDirty;
  48957. private _projectionTextureProjectionLightDirty;
  48958. private _projectionTextureDirty;
  48959. private _projectionTextureViewTargetVector;
  48960. private _projectionTextureViewLightMatrix;
  48961. private _projectionTextureProjectionLightMatrix;
  48962. private _projectionTextureScalingMatrix;
  48963. /**
  48964. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48965. * It can cast shadows.
  48966. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48967. * @param name The light friendly name
  48968. * @param position The position of the spot light in the scene
  48969. * @param direction The direction of the light in the scene
  48970. * @param angle The cone angle of the light in Radians
  48971. * @param exponent The light decay speed with the distance from the emission spot
  48972. * @param scene The scene the lights belongs to
  48973. */
  48974. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48975. /**
  48976. * Returns the string "SpotLight".
  48977. * @returns the class name
  48978. */
  48979. getClassName(): string;
  48980. /**
  48981. * Returns the integer 2.
  48982. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48983. */
  48984. getTypeID(): number;
  48985. /**
  48986. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48987. */
  48988. protected _setDirection(value: Vector3): void;
  48989. /**
  48990. * Overrides the position setter to recompute the projection texture view light Matrix.
  48991. */
  48992. protected _setPosition(value: Vector3): void;
  48993. /**
  48994. * 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.
  48995. * Returns the SpotLight.
  48996. */
  48997. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48998. protected _computeProjectionTextureViewLightMatrix(): void;
  48999. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49000. /**
  49001. * Main function for light texture projection matrix computing.
  49002. */
  49003. protected _computeProjectionTextureMatrix(): void;
  49004. protected _buildUniformLayout(): void;
  49005. private _computeAngleValues;
  49006. /**
  49007. * Sets the passed Effect "effect" with the Light textures.
  49008. * @param effect The effect to update
  49009. * @param lightIndex The index of the light in the effect to update
  49010. * @returns The light
  49011. */
  49012. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49013. /**
  49014. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49015. * @param effect The effect to update
  49016. * @param lightIndex The index of the light in the effect to update
  49017. * @returns The spot light
  49018. */
  49019. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49020. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49021. /**
  49022. * Disposes the light and the associated resources.
  49023. */
  49024. dispose(): void;
  49025. /**
  49026. * Prepares the list of defines specific to the light type.
  49027. * @param defines the list of defines
  49028. * @param lightIndex defines the index of the light for the effect
  49029. */
  49030. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49031. }
  49032. }
  49033. declare module BABYLON {
  49034. /**
  49035. * Gizmo that enables viewing a light
  49036. */
  49037. export class LightGizmo extends Gizmo {
  49038. private _lightMesh;
  49039. private _material;
  49040. private _cachedPosition;
  49041. private _cachedForward;
  49042. private _attachedMeshParent;
  49043. /**
  49044. * Creates a LightGizmo
  49045. * @param gizmoLayer The utility layer the gizmo will be added to
  49046. */
  49047. constructor(gizmoLayer?: UtilityLayerRenderer);
  49048. private _light;
  49049. /**
  49050. * The light that the gizmo is attached to
  49051. */
  49052. set light(light: Nullable<Light>);
  49053. get light(): Nullable<Light>;
  49054. /**
  49055. * Gets the material used to render the light gizmo
  49056. */
  49057. get material(): StandardMaterial;
  49058. /**
  49059. * @hidden
  49060. * Updates the gizmo to match the attached mesh's position/rotation
  49061. */
  49062. protected _update(): void;
  49063. private static _Scale;
  49064. /**
  49065. * Creates the lines for a light mesh
  49066. */
  49067. private static _CreateLightLines;
  49068. /**
  49069. * Disposes of the light gizmo
  49070. */
  49071. dispose(): void;
  49072. private static _CreateHemisphericLightMesh;
  49073. private static _CreatePointLightMesh;
  49074. private static _CreateSpotLightMesh;
  49075. private static _CreateDirectionalLightMesh;
  49076. }
  49077. }
  49078. declare module BABYLON {
  49079. /** @hidden */
  49080. export var backgroundFragmentDeclaration: {
  49081. name: string;
  49082. shader: string;
  49083. };
  49084. }
  49085. declare module BABYLON {
  49086. /** @hidden */
  49087. export var backgroundUboDeclaration: {
  49088. name: string;
  49089. shader: string;
  49090. };
  49091. }
  49092. declare module BABYLON {
  49093. /** @hidden */
  49094. export var backgroundPixelShader: {
  49095. name: string;
  49096. shader: string;
  49097. };
  49098. }
  49099. declare module BABYLON {
  49100. /** @hidden */
  49101. export var backgroundVertexDeclaration: {
  49102. name: string;
  49103. shader: string;
  49104. };
  49105. }
  49106. declare module BABYLON {
  49107. /** @hidden */
  49108. export var backgroundVertexShader: {
  49109. name: string;
  49110. shader: string;
  49111. };
  49112. }
  49113. declare module BABYLON {
  49114. /**
  49115. * Background material used to create an efficient environement around your scene.
  49116. */
  49117. export class BackgroundMaterial extends PushMaterial {
  49118. /**
  49119. * Standard reflectance value at parallel view angle.
  49120. */
  49121. static StandardReflectance0: number;
  49122. /**
  49123. * Standard reflectance value at grazing angle.
  49124. */
  49125. static StandardReflectance90: number;
  49126. protected _primaryColor: Color3;
  49127. /**
  49128. * Key light Color (multiply against the environement texture)
  49129. */
  49130. primaryColor: Color3;
  49131. protected __perceptualColor: Nullable<Color3>;
  49132. /**
  49133. * Experimental Internal Use Only.
  49134. *
  49135. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49136. * This acts as a helper to set the primary color to a more "human friendly" value.
  49137. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49138. * output color as close as possible from the chosen value.
  49139. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49140. * part of lighting setup.)
  49141. */
  49142. get _perceptualColor(): Nullable<Color3>;
  49143. set _perceptualColor(value: Nullable<Color3>);
  49144. protected _primaryColorShadowLevel: float;
  49145. /**
  49146. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49147. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49148. */
  49149. get primaryColorShadowLevel(): float;
  49150. set primaryColorShadowLevel(value: float);
  49151. protected _primaryColorHighlightLevel: float;
  49152. /**
  49153. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49154. * The primary color is used at the level chosen to define what the white area would look.
  49155. */
  49156. get primaryColorHighlightLevel(): float;
  49157. set primaryColorHighlightLevel(value: float);
  49158. protected _reflectionTexture: Nullable<BaseTexture>;
  49159. /**
  49160. * Reflection Texture used in the material.
  49161. * Should be author in a specific way for the best result (refer to the documentation).
  49162. */
  49163. reflectionTexture: Nullable<BaseTexture>;
  49164. protected _reflectionBlur: float;
  49165. /**
  49166. * Reflection Texture level of blur.
  49167. *
  49168. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49169. * texture twice.
  49170. */
  49171. reflectionBlur: float;
  49172. protected _diffuseTexture: Nullable<BaseTexture>;
  49173. /**
  49174. * Diffuse Texture used in the material.
  49175. * Should be author in a specific way for the best result (refer to the documentation).
  49176. */
  49177. diffuseTexture: Nullable<BaseTexture>;
  49178. protected _shadowLights: Nullable<IShadowLight[]>;
  49179. /**
  49180. * Specify the list of lights casting shadow on the material.
  49181. * All scene shadow lights will be included if null.
  49182. */
  49183. shadowLights: Nullable<IShadowLight[]>;
  49184. protected _shadowLevel: float;
  49185. /**
  49186. * Helps adjusting the shadow to a softer level if required.
  49187. * 0 means black shadows and 1 means no shadows.
  49188. */
  49189. shadowLevel: float;
  49190. protected _sceneCenter: Vector3;
  49191. /**
  49192. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49193. * It is usually zero but might be interesting to modify according to your setup.
  49194. */
  49195. sceneCenter: Vector3;
  49196. protected _opacityFresnel: boolean;
  49197. /**
  49198. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49199. * This helps ensuring a nice transition when the camera goes under the ground.
  49200. */
  49201. opacityFresnel: boolean;
  49202. protected _reflectionFresnel: boolean;
  49203. /**
  49204. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49205. * This helps adding a mirror texture on the ground.
  49206. */
  49207. reflectionFresnel: boolean;
  49208. protected _reflectionFalloffDistance: number;
  49209. /**
  49210. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49211. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49212. */
  49213. reflectionFalloffDistance: number;
  49214. protected _reflectionAmount: number;
  49215. /**
  49216. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49217. */
  49218. reflectionAmount: number;
  49219. protected _reflectionReflectance0: number;
  49220. /**
  49221. * This specifies the weight of the reflection at grazing angle.
  49222. */
  49223. reflectionReflectance0: number;
  49224. protected _reflectionReflectance90: number;
  49225. /**
  49226. * This specifies the weight of the reflection at a perpendicular point of view.
  49227. */
  49228. reflectionReflectance90: number;
  49229. /**
  49230. * Sets the reflection reflectance fresnel values according to the default standard
  49231. * empirically know to work well :-)
  49232. */
  49233. set reflectionStandardFresnelWeight(value: number);
  49234. protected _useRGBColor: boolean;
  49235. /**
  49236. * Helps to directly use the maps channels instead of their level.
  49237. */
  49238. useRGBColor: boolean;
  49239. protected _enableNoise: boolean;
  49240. /**
  49241. * This helps reducing the banding effect that could occur on the background.
  49242. */
  49243. enableNoise: boolean;
  49244. /**
  49245. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49246. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49247. * Recommended to be keep at 1.0 except for special cases.
  49248. */
  49249. get fovMultiplier(): number;
  49250. set fovMultiplier(value: number);
  49251. private _fovMultiplier;
  49252. /**
  49253. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49254. */
  49255. useEquirectangularFOV: boolean;
  49256. private _maxSimultaneousLights;
  49257. /**
  49258. * Number of Simultaneous lights allowed on the material.
  49259. */
  49260. maxSimultaneousLights: int;
  49261. /**
  49262. * Default configuration related to image processing available in the Background Material.
  49263. */
  49264. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49265. /**
  49266. * Keep track of the image processing observer to allow dispose and replace.
  49267. */
  49268. private _imageProcessingObserver;
  49269. /**
  49270. * Attaches a new image processing configuration to the PBR Material.
  49271. * @param configuration (if null the scene configuration will be use)
  49272. */
  49273. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49274. /**
  49275. * Gets the image processing configuration used either in this material.
  49276. */
  49277. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49278. /**
  49279. * Sets the Default image processing configuration used either in the this material.
  49280. *
  49281. * If sets to null, the scene one is in use.
  49282. */
  49283. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49284. /**
  49285. * Gets wether the color curves effect is enabled.
  49286. */
  49287. get cameraColorCurvesEnabled(): boolean;
  49288. /**
  49289. * Sets wether the color curves effect is enabled.
  49290. */
  49291. set cameraColorCurvesEnabled(value: boolean);
  49292. /**
  49293. * Gets wether the color grading effect is enabled.
  49294. */
  49295. get cameraColorGradingEnabled(): boolean;
  49296. /**
  49297. * Gets wether the color grading effect is enabled.
  49298. */
  49299. set cameraColorGradingEnabled(value: boolean);
  49300. /**
  49301. * Gets wether tonemapping is enabled or not.
  49302. */
  49303. get cameraToneMappingEnabled(): boolean;
  49304. /**
  49305. * Sets wether tonemapping is enabled or not
  49306. */
  49307. set cameraToneMappingEnabled(value: boolean);
  49308. /**
  49309. * The camera exposure used on this material.
  49310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49311. * This corresponds to a photographic exposure.
  49312. */
  49313. get cameraExposure(): float;
  49314. /**
  49315. * The camera exposure used on this material.
  49316. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49317. * This corresponds to a photographic exposure.
  49318. */
  49319. set cameraExposure(value: float);
  49320. /**
  49321. * Gets The camera contrast used on this material.
  49322. */
  49323. get cameraContrast(): float;
  49324. /**
  49325. * Sets The camera contrast used on this material.
  49326. */
  49327. set cameraContrast(value: float);
  49328. /**
  49329. * Gets the Color Grading 2D Lookup Texture.
  49330. */
  49331. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49332. /**
  49333. * Sets the Color Grading 2D Lookup Texture.
  49334. */
  49335. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49336. /**
  49337. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49338. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49339. * 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;
  49340. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49341. */
  49342. get cameraColorCurves(): Nullable<ColorCurves>;
  49343. /**
  49344. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49345. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49346. * 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;
  49347. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49348. */
  49349. set cameraColorCurves(value: Nullable<ColorCurves>);
  49350. /**
  49351. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49352. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49353. */
  49354. switchToBGR: boolean;
  49355. private _renderTargets;
  49356. private _reflectionControls;
  49357. private _white;
  49358. private _primaryShadowColor;
  49359. private _primaryHighlightColor;
  49360. /**
  49361. * Instantiates a Background Material in the given scene
  49362. * @param name The friendly name of the material
  49363. * @param scene The scene to add the material to
  49364. */
  49365. constructor(name: string, scene: Scene);
  49366. /**
  49367. * Gets a boolean indicating that current material needs to register RTT
  49368. */
  49369. get hasRenderTargetTextures(): boolean;
  49370. /**
  49371. * The entire material has been created in order to prevent overdraw.
  49372. * @returns false
  49373. */
  49374. needAlphaTesting(): boolean;
  49375. /**
  49376. * The entire material has been created in order to prevent overdraw.
  49377. * @returns true if blending is enable
  49378. */
  49379. needAlphaBlending(): boolean;
  49380. /**
  49381. * Checks wether the material is ready to be rendered for a given mesh.
  49382. * @param mesh The mesh to render
  49383. * @param subMesh The submesh to check against
  49384. * @param useInstances Specify wether or not the material is used with instances
  49385. * @returns true if all the dependencies are ready (Textures, Effects...)
  49386. */
  49387. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49388. /**
  49389. * Compute the primary color according to the chosen perceptual color.
  49390. */
  49391. private _computePrimaryColorFromPerceptualColor;
  49392. /**
  49393. * Compute the highlights and shadow colors according to their chosen levels.
  49394. */
  49395. private _computePrimaryColors;
  49396. /**
  49397. * Build the uniform buffer used in the material.
  49398. */
  49399. buildUniformLayout(): void;
  49400. /**
  49401. * Unbind the material.
  49402. */
  49403. unbind(): void;
  49404. /**
  49405. * Bind only the world matrix to the material.
  49406. * @param world The world matrix to bind.
  49407. */
  49408. bindOnlyWorldMatrix(world: Matrix): void;
  49409. /**
  49410. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49411. * @param world The world matrix to bind.
  49412. * @param subMesh The submesh to bind for.
  49413. */
  49414. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49415. /**
  49416. * Checks to see if a texture is used in the material.
  49417. * @param texture - Base texture to use.
  49418. * @returns - Boolean specifying if a texture is used in the material.
  49419. */
  49420. hasTexture(texture: BaseTexture): boolean;
  49421. /**
  49422. * Dispose the material.
  49423. * @param forceDisposeEffect Force disposal of the associated effect.
  49424. * @param forceDisposeTextures Force disposal of the associated textures.
  49425. */
  49426. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49427. /**
  49428. * Clones the material.
  49429. * @param name The cloned name.
  49430. * @returns The cloned material.
  49431. */
  49432. clone(name: string): BackgroundMaterial;
  49433. /**
  49434. * Serializes the current material to its JSON representation.
  49435. * @returns The JSON representation.
  49436. */
  49437. serialize(): any;
  49438. /**
  49439. * Gets the class name of the material
  49440. * @returns "BackgroundMaterial"
  49441. */
  49442. getClassName(): string;
  49443. /**
  49444. * Parse a JSON input to create back a background material.
  49445. * @param source The JSON data to parse
  49446. * @param scene The scene to create the parsed material in
  49447. * @param rootUrl The root url of the assets the material depends upon
  49448. * @returns the instantiated BackgroundMaterial.
  49449. */
  49450. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49451. }
  49452. }
  49453. declare module BABYLON {
  49454. /**
  49455. * Represents the different options available during the creation of
  49456. * a Environment helper.
  49457. *
  49458. * This can control the default ground, skybox and image processing setup of your scene.
  49459. */
  49460. export interface IEnvironmentHelperOptions {
  49461. /**
  49462. * Specifies whether or not to create a ground.
  49463. * True by default.
  49464. */
  49465. createGround: boolean;
  49466. /**
  49467. * Specifies the ground size.
  49468. * 15 by default.
  49469. */
  49470. groundSize: number;
  49471. /**
  49472. * The texture used on the ground for the main color.
  49473. * Comes from the BabylonJS CDN by default.
  49474. *
  49475. * Remarks: Can be either a texture or a url.
  49476. */
  49477. groundTexture: string | BaseTexture;
  49478. /**
  49479. * The color mixed in the ground texture by default.
  49480. * BabylonJS clearColor by default.
  49481. */
  49482. groundColor: Color3;
  49483. /**
  49484. * Specifies the ground opacity.
  49485. * 1 by default.
  49486. */
  49487. groundOpacity: number;
  49488. /**
  49489. * Enables the ground to receive shadows.
  49490. * True by default.
  49491. */
  49492. enableGroundShadow: boolean;
  49493. /**
  49494. * Helps preventing the shadow to be fully black on the ground.
  49495. * 0.5 by default.
  49496. */
  49497. groundShadowLevel: number;
  49498. /**
  49499. * Creates a mirror texture attach to the ground.
  49500. * false by default.
  49501. */
  49502. enableGroundMirror: boolean;
  49503. /**
  49504. * Specifies the ground mirror size ratio.
  49505. * 0.3 by default as the default kernel is 64.
  49506. */
  49507. groundMirrorSizeRatio: number;
  49508. /**
  49509. * Specifies the ground mirror blur kernel size.
  49510. * 64 by default.
  49511. */
  49512. groundMirrorBlurKernel: number;
  49513. /**
  49514. * Specifies the ground mirror visibility amount.
  49515. * 1 by default
  49516. */
  49517. groundMirrorAmount: number;
  49518. /**
  49519. * Specifies the ground mirror reflectance weight.
  49520. * This uses the standard weight of the background material to setup the fresnel effect
  49521. * of the mirror.
  49522. * 1 by default.
  49523. */
  49524. groundMirrorFresnelWeight: number;
  49525. /**
  49526. * Specifies the ground mirror Falloff distance.
  49527. * This can helps reducing the size of the reflection.
  49528. * 0 by Default.
  49529. */
  49530. groundMirrorFallOffDistance: number;
  49531. /**
  49532. * Specifies the ground mirror texture type.
  49533. * Unsigned Int by Default.
  49534. */
  49535. groundMirrorTextureType: number;
  49536. /**
  49537. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49538. * the shown objects.
  49539. */
  49540. groundYBias: number;
  49541. /**
  49542. * Specifies whether or not to create a skybox.
  49543. * True by default.
  49544. */
  49545. createSkybox: boolean;
  49546. /**
  49547. * Specifies the skybox size.
  49548. * 20 by default.
  49549. */
  49550. skyboxSize: number;
  49551. /**
  49552. * The texture used on the skybox for the main color.
  49553. * Comes from the BabylonJS CDN by default.
  49554. *
  49555. * Remarks: Can be either a texture or a url.
  49556. */
  49557. skyboxTexture: string | BaseTexture;
  49558. /**
  49559. * The color mixed in the skybox texture by default.
  49560. * BabylonJS clearColor by default.
  49561. */
  49562. skyboxColor: Color3;
  49563. /**
  49564. * The background rotation around the Y axis of the scene.
  49565. * This helps aligning the key lights of your scene with the background.
  49566. * 0 by default.
  49567. */
  49568. backgroundYRotation: number;
  49569. /**
  49570. * Compute automatically the size of the elements to best fit with the scene.
  49571. */
  49572. sizeAuto: boolean;
  49573. /**
  49574. * Default position of the rootMesh if autoSize is not true.
  49575. */
  49576. rootPosition: Vector3;
  49577. /**
  49578. * Sets up the image processing in the scene.
  49579. * true by default.
  49580. */
  49581. setupImageProcessing: boolean;
  49582. /**
  49583. * The texture used as your environment texture in the scene.
  49584. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49585. *
  49586. * Remarks: Can be either a texture or a url.
  49587. */
  49588. environmentTexture: string | BaseTexture;
  49589. /**
  49590. * The value of the exposure to apply to the scene.
  49591. * 0.6 by default if setupImageProcessing is true.
  49592. */
  49593. cameraExposure: number;
  49594. /**
  49595. * The value of the contrast to apply to the scene.
  49596. * 1.6 by default if setupImageProcessing is true.
  49597. */
  49598. cameraContrast: number;
  49599. /**
  49600. * Specifies whether or not tonemapping should be enabled in the scene.
  49601. * true by default if setupImageProcessing is true.
  49602. */
  49603. toneMappingEnabled: boolean;
  49604. }
  49605. /**
  49606. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49607. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49608. * It also helps with the default setup of your imageProcessing configuration.
  49609. */
  49610. export class EnvironmentHelper {
  49611. /**
  49612. * Default ground texture URL.
  49613. */
  49614. private static _groundTextureCDNUrl;
  49615. /**
  49616. * Default skybox texture URL.
  49617. */
  49618. private static _skyboxTextureCDNUrl;
  49619. /**
  49620. * Default environment texture URL.
  49621. */
  49622. private static _environmentTextureCDNUrl;
  49623. /**
  49624. * Creates the default options for the helper.
  49625. */
  49626. private static _getDefaultOptions;
  49627. private _rootMesh;
  49628. /**
  49629. * Gets the root mesh created by the helper.
  49630. */
  49631. get rootMesh(): Mesh;
  49632. private _skybox;
  49633. /**
  49634. * Gets the skybox created by the helper.
  49635. */
  49636. get skybox(): Nullable<Mesh>;
  49637. private _skyboxTexture;
  49638. /**
  49639. * Gets the skybox texture created by the helper.
  49640. */
  49641. get skyboxTexture(): Nullable<BaseTexture>;
  49642. private _skyboxMaterial;
  49643. /**
  49644. * Gets the skybox material created by the helper.
  49645. */
  49646. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49647. private _ground;
  49648. /**
  49649. * Gets the ground mesh created by the helper.
  49650. */
  49651. get ground(): Nullable<Mesh>;
  49652. private _groundTexture;
  49653. /**
  49654. * Gets the ground texture created by the helper.
  49655. */
  49656. get groundTexture(): Nullable<BaseTexture>;
  49657. private _groundMirror;
  49658. /**
  49659. * Gets the ground mirror created by the helper.
  49660. */
  49661. get groundMirror(): Nullable<MirrorTexture>;
  49662. /**
  49663. * Gets the ground mirror render list to helps pushing the meshes
  49664. * you wish in the ground reflection.
  49665. */
  49666. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49667. private _groundMaterial;
  49668. /**
  49669. * Gets the ground material created by the helper.
  49670. */
  49671. get groundMaterial(): Nullable<BackgroundMaterial>;
  49672. /**
  49673. * Stores the creation options.
  49674. */
  49675. private readonly _scene;
  49676. private _options;
  49677. /**
  49678. * This observable will be notified with any error during the creation of the environment,
  49679. * mainly texture creation errors.
  49680. */
  49681. onErrorObservable: Observable<{
  49682. message?: string;
  49683. exception?: any;
  49684. }>;
  49685. /**
  49686. * constructor
  49687. * @param options Defines the options we want to customize the helper
  49688. * @param scene The scene to add the material to
  49689. */
  49690. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49691. /**
  49692. * Updates the background according to the new options
  49693. * @param options
  49694. */
  49695. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49696. /**
  49697. * Sets the primary color of all the available elements.
  49698. * @param color the main color to affect to the ground and the background
  49699. */
  49700. setMainColor(color: Color3): void;
  49701. /**
  49702. * Setup the image processing according to the specified options.
  49703. */
  49704. private _setupImageProcessing;
  49705. /**
  49706. * Setup the environment texture according to the specified options.
  49707. */
  49708. private _setupEnvironmentTexture;
  49709. /**
  49710. * Setup the background according to the specified options.
  49711. */
  49712. private _setupBackground;
  49713. /**
  49714. * Get the scene sizes according to the setup.
  49715. */
  49716. private _getSceneSize;
  49717. /**
  49718. * Setup the ground according to the specified options.
  49719. */
  49720. private _setupGround;
  49721. /**
  49722. * Setup the ground material according to the specified options.
  49723. */
  49724. private _setupGroundMaterial;
  49725. /**
  49726. * Setup the ground diffuse texture according to the specified options.
  49727. */
  49728. private _setupGroundDiffuseTexture;
  49729. /**
  49730. * Setup the ground mirror texture according to the specified options.
  49731. */
  49732. private _setupGroundMirrorTexture;
  49733. /**
  49734. * Setup the ground to receive the mirror texture.
  49735. */
  49736. private _setupMirrorInGroundMaterial;
  49737. /**
  49738. * Setup the skybox according to the specified options.
  49739. */
  49740. private _setupSkybox;
  49741. /**
  49742. * Setup the skybox material according to the specified options.
  49743. */
  49744. private _setupSkyboxMaterial;
  49745. /**
  49746. * Setup the skybox reflection texture according to the specified options.
  49747. */
  49748. private _setupSkyboxReflectionTexture;
  49749. private _errorHandler;
  49750. /**
  49751. * Dispose all the elements created by the Helper.
  49752. */
  49753. dispose(): void;
  49754. }
  49755. }
  49756. declare module BABYLON {
  49757. /**
  49758. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49759. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49760. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49761. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49762. */
  49763. export class PhotoDome extends TransformNode {
  49764. /**
  49765. * Define the image as a Monoscopic panoramic 360 image.
  49766. */
  49767. static readonly MODE_MONOSCOPIC: number;
  49768. /**
  49769. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49770. */
  49771. static readonly MODE_TOPBOTTOM: number;
  49772. /**
  49773. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49774. */
  49775. static readonly MODE_SIDEBYSIDE: number;
  49776. private _useDirectMapping;
  49777. /**
  49778. * The texture being displayed on the sphere
  49779. */
  49780. protected _photoTexture: Texture;
  49781. /**
  49782. * Gets or sets the texture being displayed on the sphere
  49783. */
  49784. get photoTexture(): Texture;
  49785. set photoTexture(value: Texture);
  49786. /**
  49787. * Observable raised when an error occured while loading the 360 image
  49788. */
  49789. onLoadErrorObservable: Observable<string>;
  49790. /**
  49791. * The skybox material
  49792. */
  49793. protected _material: BackgroundMaterial;
  49794. /**
  49795. * The surface used for the skybox
  49796. */
  49797. protected _mesh: Mesh;
  49798. /**
  49799. * Gets the mesh used for the skybox.
  49800. */
  49801. get mesh(): Mesh;
  49802. /**
  49803. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49804. * Also see the options.resolution property.
  49805. */
  49806. get fovMultiplier(): number;
  49807. set fovMultiplier(value: number);
  49808. private _imageMode;
  49809. /**
  49810. * Gets or set the current video mode for the video. It can be:
  49811. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49812. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49813. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49814. */
  49815. get imageMode(): number;
  49816. set imageMode(value: number);
  49817. /**
  49818. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49819. * @param name Element's name, child elements will append suffixes for their own names.
  49820. * @param urlsOfPhoto defines the url of the photo to display
  49821. * @param options defines an object containing optional or exposed sub element properties
  49822. * @param onError defines a callback called when an error occured while loading the texture
  49823. */
  49824. constructor(name: string, urlOfPhoto: string, options: {
  49825. resolution?: number;
  49826. size?: number;
  49827. useDirectMapping?: boolean;
  49828. faceForward?: boolean;
  49829. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49830. private _onBeforeCameraRenderObserver;
  49831. private _changeImageMode;
  49832. /**
  49833. * Releases resources associated with this node.
  49834. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49835. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49836. */
  49837. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49838. }
  49839. }
  49840. declare module BABYLON {
  49841. /**
  49842. * Class used to host RGBD texture specific utilities
  49843. */
  49844. export class RGBDTextureTools {
  49845. /**
  49846. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49847. * @param texture the texture to expand.
  49848. */
  49849. static ExpandRGBDTexture(texture: Texture): void;
  49850. }
  49851. }
  49852. declare module BABYLON {
  49853. /**
  49854. * Class used to host texture specific utilities
  49855. */
  49856. export class BRDFTextureTools {
  49857. /**
  49858. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49859. * @param scene defines the hosting scene
  49860. * @returns the environment BRDF texture
  49861. */
  49862. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49863. private static _environmentBRDFBase64Texture;
  49864. }
  49865. }
  49866. declare module BABYLON {
  49867. /**
  49868. * @hidden
  49869. */
  49870. export interface IMaterialClearCoatDefines {
  49871. CLEARCOAT: boolean;
  49872. CLEARCOAT_DEFAULTIOR: boolean;
  49873. CLEARCOAT_TEXTURE: boolean;
  49874. CLEARCOAT_TEXTUREDIRECTUV: number;
  49875. CLEARCOAT_BUMP: boolean;
  49876. CLEARCOAT_BUMPDIRECTUV: number;
  49877. CLEARCOAT_TINT: boolean;
  49878. CLEARCOAT_TINT_TEXTURE: boolean;
  49879. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49880. /** @hidden */
  49881. _areTexturesDirty: boolean;
  49882. }
  49883. /**
  49884. * Define the code related to the clear coat parameters of the pbr material.
  49885. */
  49886. export class PBRClearCoatConfiguration {
  49887. /**
  49888. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49889. * The default fits with a polyurethane material.
  49890. */
  49891. private static readonly _DefaultIndexOfRefraction;
  49892. private _isEnabled;
  49893. /**
  49894. * Defines if the clear coat is enabled in the material.
  49895. */
  49896. isEnabled: boolean;
  49897. /**
  49898. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49899. */
  49900. intensity: number;
  49901. /**
  49902. * Defines the clear coat layer roughness.
  49903. */
  49904. roughness: number;
  49905. private _indexOfRefraction;
  49906. /**
  49907. * Defines the index of refraction of the clear coat.
  49908. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49909. * The default fits with a polyurethane material.
  49910. * Changing the default value is more performance intensive.
  49911. */
  49912. indexOfRefraction: number;
  49913. private _texture;
  49914. /**
  49915. * Stores the clear coat values in a texture.
  49916. */
  49917. texture: Nullable<BaseTexture>;
  49918. private _bumpTexture;
  49919. /**
  49920. * Define the clear coat specific bump texture.
  49921. */
  49922. bumpTexture: Nullable<BaseTexture>;
  49923. private _isTintEnabled;
  49924. /**
  49925. * Defines if the clear coat tint is enabled in the material.
  49926. */
  49927. isTintEnabled: boolean;
  49928. /**
  49929. * Defines the clear coat tint of the material.
  49930. * This is only use if tint is enabled
  49931. */
  49932. tintColor: Color3;
  49933. /**
  49934. * Defines the distance at which the tint color should be found in the
  49935. * clear coat media.
  49936. * This is only use if tint is enabled
  49937. */
  49938. tintColorAtDistance: number;
  49939. /**
  49940. * Defines the clear coat layer thickness.
  49941. * This is only use if tint is enabled
  49942. */
  49943. tintThickness: number;
  49944. private _tintTexture;
  49945. /**
  49946. * Stores the clear tint values in a texture.
  49947. * rgb is tint
  49948. * a is a thickness factor
  49949. */
  49950. tintTexture: Nullable<BaseTexture>;
  49951. /** @hidden */
  49952. private _internalMarkAllSubMeshesAsTexturesDirty;
  49953. /** @hidden */
  49954. _markAllSubMeshesAsTexturesDirty(): void;
  49955. /**
  49956. * Instantiate a new istance of clear coat configuration.
  49957. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49958. */
  49959. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49960. /**
  49961. * Gets wehter the submesh is ready to be used or not.
  49962. * @param defines the list of "defines" to update.
  49963. * @param scene defines the scene the material belongs to.
  49964. * @param engine defines the engine the material belongs to.
  49965. * @param disableBumpMap defines wether the material disables bump or not.
  49966. * @returns - boolean indicating that the submesh is ready or not.
  49967. */
  49968. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49969. /**
  49970. * Checks to see if a texture is used in the material.
  49971. * @param defines the list of "defines" to update.
  49972. * @param scene defines the scene to the material belongs to.
  49973. */
  49974. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49975. /**
  49976. * Binds the material data.
  49977. * @param uniformBuffer defines the Uniform buffer to fill in.
  49978. * @param scene defines the scene the material belongs to.
  49979. * @param engine defines the engine the material belongs to.
  49980. * @param disableBumpMap defines wether the material disables bump or not.
  49981. * @param isFrozen defines wether the material is frozen or not.
  49982. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49983. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49984. */
  49985. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49986. /**
  49987. * Checks to see if a texture is used in the material.
  49988. * @param texture - Base texture to use.
  49989. * @returns - Boolean specifying if a texture is used in the material.
  49990. */
  49991. hasTexture(texture: BaseTexture): boolean;
  49992. /**
  49993. * Returns an array of the actively used textures.
  49994. * @param activeTextures Array of BaseTextures
  49995. */
  49996. getActiveTextures(activeTextures: BaseTexture[]): void;
  49997. /**
  49998. * Returns the animatable textures.
  49999. * @param animatables Array of animatable textures.
  50000. */
  50001. getAnimatables(animatables: IAnimatable[]): void;
  50002. /**
  50003. * Disposes the resources of the material.
  50004. * @param forceDisposeTextures - Forces the disposal of all textures.
  50005. */
  50006. dispose(forceDisposeTextures?: boolean): void;
  50007. /**
  50008. * Get the current class name of the texture useful for serialization or dynamic coding.
  50009. * @returns "PBRClearCoatConfiguration"
  50010. */
  50011. getClassName(): string;
  50012. /**
  50013. * Add fallbacks to the effect fallbacks list.
  50014. * @param defines defines the Base texture to use.
  50015. * @param fallbacks defines the current fallback list.
  50016. * @param currentRank defines the current fallback rank.
  50017. * @returns the new fallback rank.
  50018. */
  50019. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50020. /**
  50021. * Add the required uniforms to the current list.
  50022. * @param uniforms defines the current uniform list.
  50023. */
  50024. static AddUniforms(uniforms: string[]): void;
  50025. /**
  50026. * Add the required samplers to the current list.
  50027. * @param samplers defines the current sampler list.
  50028. */
  50029. static AddSamplers(samplers: string[]): void;
  50030. /**
  50031. * Add the required uniforms to the current buffer.
  50032. * @param uniformBuffer defines the current uniform buffer.
  50033. */
  50034. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50035. /**
  50036. * Makes a duplicate of the current configuration into another one.
  50037. * @param clearCoatConfiguration define the config where to copy the info
  50038. */
  50039. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50040. /**
  50041. * Serializes this clear coat configuration.
  50042. * @returns - An object with the serialized config.
  50043. */
  50044. serialize(): any;
  50045. /**
  50046. * Parses a anisotropy Configuration from a serialized object.
  50047. * @param source - Serialized object.
  50048. * @param scene Defines the scene we are parsing for
  50049. * @param rootUrl Defines the rootUrl to load from
  50050. */
  50051. parse(source: any, scene: Scene, rootUrl: string): void;
  50052. }
  50053. }
  50054. declare module BABYLON {
  50055. /**
  50056. * @hidden
  50057. */
  50058. export interface IMaterialAnisotropicDefines {
  50059. ANISOTROPIC: boolean;
  50060. ANISOTROPIC_TEXTURE: boolean;
  50061. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50062. MAINUV1: boolean;
  50063. _areTexturesDirty: boolean;
  50064. _needUVs: boolean;
  50065. }
  50066. /**
  50067. * Define the code related to the anisotropic parameters of the pbr material.
  50068. */
  50069. export class PBRAnisotropicConfiguration {
  50070. private _isEnabled;
  50071. /**
  50072. * Defines if the anisotropy is enabled in the material.
  50073. */
  50074. isEnabled: boolean;
  50075. /**
  50076. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50077. */
  50078. intensity: number;
  50079. /**
  50080. * Defines if the effect is along the tangents, bitangents or in between.
  50081. * By default, the effect is "strectching" the highlights along the tangents.
  50082. */
  50083. direction: Vector2;
  50084. private _texture;
  50085. /**
  50086. * Stores the anisotropy values in a texture.
  50087. * rg is direction (like normal from -1 to 1)
  50088. * b is a intensity
  50089. */
  50090. texture: Nullable<BaseTexture>;
  50091. /** @hidden */
  50092. private _internalMarkAllSubMeshesAsTexturesDirty;
  50093. /** @hidden */
  50094. _markAllSubMeshesAsTexturesDirty(): void;
  50095. /**
  50096. * Instantiate a new istance of anisotropy configuration.
  50097. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50098. */
  50099. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50100. /**
  50101. * Specifies that the submesh is ready to be used.
  50102. * @param defines the list of "defines" to update.
  50103. * @param scene defines the scene the material belongs to.
  50104. * @returns - boolean indicating that the submesh is ready or not.
  50105. */
  50106. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50107. /**
  50108. * Checks to see if a texture is used in the material.
  50109. * @param defines the list of "defines" to update.
  50110. * @param mesh the mesh we are preparing the defines for.
  50111. * @param scene defines the scene the material belongs to.
  50112. */
  50113. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50114. /**
  50115. * Binds the material data.
  50116. * @param uniformBuffer defines the Uniform buffer to fill in.
  50117. * @param scene defines the scene the material belongs to.
  50118. * @param isFrozen defines wether the material is frozen or not.
  50119. */
  50120. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50121. /**
  50122. * Checks to see if a texture is used in the material.
  50123. * @param texture - Base texture to use.
  50124. * @returns - Boolean specifying if a texture is used in the material.
  50125. */
  50126. hasTexture(texture: BaseTexture): boolean;
  50127. /**
  50128. * Returns an array of the actively used textures.
  50129. * @param activeTextures Array of BaseTextures
  50130. */
  50131. getActiveTextures(activeTextures: BaseTexture[]): void;
  50132. /**
  50133. * Returns the animatable textures.
  50134. * @param animatables Array of animatable textures.
  50135. */
  50136. getAnimatables(animatables: IAnimatable[]): void;
  50137. /**
  50138. * Disposes the resources of the material.
  50139. * @param forceDisposeTextures - Forces the disposal of all textures.
  50140. */
  50141. dispose(forceDisposeTextures?: boolean): void;
  50142. /**
  50143. * Get the current class name of the texture useful for serialization or dynamic coding.
  50144. * @returns "PBRAnisotropicConfiguration"
  50145. */
  50146. getClassName(): string;
  50147. /**
  50148. * Add fallbacks to the effect fallbacks list.
  50149. * @param defines defines the Base texture to use.
  50150. * @param fallbacks defines the current fallback list.
  50151. * @param currentRank defines the current fallback rank.
  50152. * @returns the new fallback rank.
  50153. */
  50154. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50155. /**
  50156. * Add the required uniforms to the current list.
  50157. * @param uniforms defines the current uniform list.
  50158. */
  50159. static AddUniforms(uniforms: string[]): void;
  50160. /**
  50161. * Add the required uniforms to the current buffer.
  50162. * @param uniformBuffer defines the current uniform buffer.
  50163. */
  50164. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50165. /**
  50166. * Add the required samplers to the current list.
  50167. * @param samplers defines the current sampler list.
  50168. */
  50169. static AddSamplers(samplers: string[]): void;
  50170. /**
  50171. * Makes a duplicate of the current configuration into another one.
  50172. * @param anisotropicConfiguration define the config where to copy the info
  50173. */
  50174. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50175. /**
  50176. * Serializes this anisotropy configuration.
  50177. * @returns - An object with the serialized config.
  50178. */
  50179. serialize(): any;
  50180. /**
  50181. * Parses a anisotropy Configuration from a serialized object.
  50182. * @param source - Serialized object.
  50183. * @param scene Defines the scene we are parsing for
  50184. * @param rootUrl Defines the rootUrl to load from
  50185. */
  50186. parse(source: any, scene: Scene, rootUrl: string): void;
  50187. }
  50188. }
  50189. declare module BABYLON {
  50190. /**
  50191. * @hidden
  50192. */
  50193. export interface IMaterialBRDFDefines {
  50194. BRDF_V_HEIGHT_CORRELATED: boolean;
  50195. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50196. SPHERICAL_HARMONICS: boolean;
  50197. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50198. /** @hidden */
  50199. _areMiscDirty: boolean;
  50200. }
  50201. /**
  50202. * Define the code related to the BRDF parameters of the pbr material.
  50203. */
  50204. export class PBRBRDFConfiguration {
  50205. /**
  50206. * Default value used for the energy conservation.
  50207. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50208. */
  50209. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50210. /**
  50211. * Default value used for the Smith Visibility Height Correlated mode.
  50212. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50213. */
  50214. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50215. /**
  50216. * Default value used for the IBL diffuse part.
  50217. * This can help switching back to the polynomials mode globally which is a tiny bit
  50218. * less GPU intensive at the drawback of a lower quality.
  50219. */
  50220. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50221. /**
  50222. * Default value used for activating energy conservation for the specular workflow.
  50223. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50224. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50225. */
  50226. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50227. private _useEnergyConservation;
  50228. /**
  50229. * Defines if the material uses energy conservation.
  50230. */
  50231. useEnergyConservation: boolean;
  50232. private _useSmithVisibilityHeightCorrelated;
  50233. /**
  50234. * LEGACY Mode set to false
  50235. * Defines if the material uses height smith correlated visibility term.
  50236. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50237. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50238. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50239. * Not relying on height correlated will also disable energy conservation.
  50240. */
  50241. useSmithVisibilityHeightCorrelated: boolean;
  50242. private _useSphericalHarmonics;
  50243. /**
  50244. * LEGACY Mode set to false
  50245. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50246. * diffuse part of the IBL.
  50247. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50248. * to the ground truth.
  50249. */
  50250. useSphericalHarmonics: boolean;
  50251. private _useSpecularGlossinessInputEnergyConservation;
  50252. /**
  50253. * Defines if the material uses energy conservation, when the specular workflow is active.
  50254. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50255. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50256. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50257. */
  50258. useSpecularGlossinessInputEnergyConservation: boolean;
  50259. /** @hidden */
  50260. private _internalMarkAllSubMeshesAsMiscDirty;
  50261. /** @hidden */
  50262. _markAllSubMeshesAsMiscDirty(): void;
  50263. /**
  50264. * Instantiate a new istance of clear coat configuration.
  50265. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50266. */
  50267. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50268. /**
  50269. * Checks to see if a texture is used in the material.
  50270. * @param defines the list of "defines" to update.
  50271. */
  50272. prepareDefines(defines: IMaterialBRDFDefines): void;
  50273. /**
  50274. * Get the current class name of the texture useful for serialization or dynamic coding.
  50275. * @returns "PBRClearCoatConfiguration"
  50276. */
  50277. getClassName(): string;
  50278. /**
  50279. * Makes a duplicate of the current configuration into another one.
  50280. * @param brdfConfiguration define the config where to copy the info
  50281. */
  50282. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50283. /**
  50284. * Serializes this BRDF configuration.
  50285. * @returns - An object with the serialized config.
  50286. */
  50287. serialize(): any;
  50288. /**
  50289. * Parses a anisotropy Configuration from a serialized object.
  50290. * @param source - Serialized object.
  50291. * @param scene Defines the scene we are parsing for
  50292. * @param rootUrl Defines the rootUrl to load from
  50293. */
  50294. parse(source: any, scene: Scene, rootUrl: string): void;
  50295. }
  50296. }
  50297. declare module BABYLON {
  50298. /**
  50299. * @hidden
  50300. */
  50301. export interface IMaterialSheenDefines {
  50302. SHEEN: boolean;
  50303. SHEEN_TEXTURE: boolean;
  50304. SHEEN_TEXTUREDIRECTUV: number;
  50305. SHEEN_LINKWITHALBEDO: boolean;
  50306. /** @hidden */
  50307. _areTexturesDirty: boolean;
  50308. }
  50309. /**
  50310. * Define the code related to the Sheen parameters of the pbr material.
  50311. */
  50312. export class PBRSheenConfiguration {
  50313. private _isEnabled;
  50314. /**
  50315. * Defines if the material uses sheen.
  50316. */
  50317. isEnabled: boolean;
  50318. private _linkSheenWithAlbedo;
  50319. /**
  50320. * Defines if the sheen is linked to the sheen color.
  50321. */
  50322. linkSheenWithAlbedo: boolean;
  50323. /**
  50324. * Defines the sheen intensity.
  50325. */
  50326. intensity: number;
  50327. /**
  50328. * Defines the sheen color.
  50329. */
  50330. color: Color3;
  50331. private _texture;
  50332. /**
  50333. * Stores the sheen tint values in a texture.
  50334. * rgb is tint
  50335. * a is a intensity
  50336. */
  50337. texture: Nullable<BaseTexture>;
  50338. /** @hidden */
  50339. private _internalMarkAllSubMeshesAsTexturesDirty;
  50340. /** @hidden */
  50341. _markAllSubMeshesAsTexturesDirty(): void;
  50342. /**
  50343. * Instantiate a new istance of clear coat configuration.
  50344. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50345. */
  50346. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50347. /**
  50348. * Specifies that the submesh is ready to be used.
  50349. * @param defines the list of "defines" to update.
  50350. * @param scene defines the scene the material belongs to.
  50351. * @returns - boolean indicating that the submesh is ready or not.
  50352. */
  50353. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50354. /**
  50355. * Checks to see if a texture is used in the material.
  50356. * @param defines the list of "defines" to update.
  50357. * @param scene defines the scene the material belongs to.
  50358. */
  50359. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50360. /**
  50361. * Binds the material data.
  50362. * @param uniformBuffer defines the Uniform buffer to fill in.
  50363. * @param scene defines the scene the material belongs to.
  50364. * @param isFrozen defines wether the material is frozen or not.
  50365. */
  50366. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50367. /**
  50368. * Checks to see if a texture is used in the material.
  50369. * @param texture - Base texture to use.
  50370. * @returns - Boolean specifying if a texture is used in the material.
  50371. */
  50372. hasTexture(texture: BaseTexture): boolean;
  50373. /**
  50374. * Returns an array of the actively used textures.
  50375. * @param activeTextures Array of BaseTextures
  50376. */
  50377. getActiveTextures(activeTextures: BaseTexture[]): void;
  50378. /**
  50379. * Returns the animatable textures.
  50380. * @param animatables Array of animatable textures.
  50381. */
  50382. getAnimatables(animatables: IAnimatable[]): void;
  50383. /**
  50384. * Disposes the resources of the material.
  50385. * @param forceDisposeTextures - Forces the disposal of all textures.
  50386. */
  50387. dispose(forceDisposeTextures?: boolean): void;
  50388. /**
  50389. * Get the current class name of the texture useful for serialization or dynamic coding.
  50390. * @returns "PBRSheenConfiguration"
  50391. */
  50392. getClassName(): string;
  50393. /**
  50394. * Add fallbacks to the effect fallbacks list.
  50395. * @param defines defines the Base texture to use.
  50396. * @param fallbacks defines the current fallback list.
  50397. * @param currentRank defines the current fallback rank.
  50398. * @returns the new fallback rank.
  50399. */
  50400. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50401. /**
  50402. * Add the required uniforms to the current list.
  50403. * @param uniforms defines the current uniform list.
  50404. */
  50405. static AddUniforms(uniforms: string[]): void;
  50406. /**
  50407. * Add the required uniforms to the current buffer.
  50408. * @param uniformBuffer defines the current uniform buffer.
  50409. */
  50410. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50411. /**
  50412. * Add the required samplers to the current list.
  50413. * @param samplers defines the current sampler list.
  50414. */
  50415. static AddSamplers(samplers: string[]): void;
  50416. /**
  50417. * Makes a duplicate of the current configuration into another one.
  50418. * @param sheenConfiguration define the config where to copy the info
  50419. */
  50420. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50421. /**
  50422. * Serializes this BRDF configuration.
  50423. * @returns - An object with the serialized config.
  50424. */
  50425. serialize(): any;
  50426. /**
  50427. * Parses a anisotropy Configuration from a serialized object.
  50428. * @param source - Serialized object.
  50429. * @param scene Defines the scene we are parsing for
  50430. * @param rootUrl Defines the rootUrl to load from
  50431. */
  50432. parse(source: any, scene: Scene, rootUrl: string): void;
  50433. }
  50434. }
  50435. declare module BABYLON {
  50436. /**
  50437. * @hidden
  50438. */
  50439. export interface IMaterialSubSurfaceDefines {
  50440. SUBSURFACE: boolean;
  50441. SS_REFRACTION: boolean;
  50442. SS_TRANSLUCENCY: boolean;
  50443. SS_SCATERRING: boolean;
  50444. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50445. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50446. SS_REFRACTIONMAP_3D: boolean;
  50447. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50448. SS_LODINREFRACTIONALPHA: boolean;
  50449. SS_GAMMAREFRACTION: boolean;
  50450. SS_RGBDREFRACTION: boolean;
  50451. SS_LINEARSPECULARREFRACTION: boolean;
  50452. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50453. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50454. /** @hidden */
  50455. _areTexturesDirty: boolean;
  50456. }
  50457. /**
  50458. * Define the code related to the sub surface parameters of the pbr material.
  50459. */
  50460. export class PBRSubSurfaceConfiguration {
  50461. private _isRefractionEnabled;
  50462. /**
  50463. * Defines if the refraction is enabled in the material.
  50464. */
  50465. isRefractionEnabled: boolean;
  50466. private _isTranslucencyEnabled;
  50467. /**
  50468. * Defines if the translucency is enabled in the material.
  50469. */
  50470. isTranslucencyEnabled: boolean;
  50471. private _isScatteringEnabled;
  50472. /**
  50473. * Defines the refraction intensity of the material.
  50474. * The refraction when enabled replaces the Diffuse part of the material.
  50475. * The intensity helps transitionning between diffuse and refraction.
  50476. */
  50477. refractionIntensity: number;
  50478. /**
  50479. * Defines the translucency intensity of the material.
  50480. * When translucency has been enabled, this defines how much of the "translucency"
  50481. * is addded to the diffuse part of the material.
  50482. */
  50483. translucencyIntensity: number;
  50484. /**
  50485. * Defines the scattering intensity of the material.
  50486. * When scattering has been enabled, this defines how much of the "scattered light"
  50487. * is addded to the diffuse part of the material.
  50488. */
  50489. scatteringIntensity: number;
  50490. private _thicknessTexture;
  50491. /**
  50492. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50493. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50494. * 0 would mean minimumThickness
  50495. * 1 would mean maximumThickness
  50496. * The other channels might be use as a mask to vary the different effects intensity.
  50497. */
  50498. thicknessTexture: Nullable<BaseTexture>;
  50499. private _refractionTexture;
  50500. /**
  50501. * Defines the texture to use for refraction.
  50502. */
  50503. refractionTexture: Nullable<BaseTexture>;
  50504. private _indexOfRefraction;
  50505. /**
  50506. * Defines the index of refraction used in the material.
  50507. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50508. */
  50509. indexOfRefraction: number;
  50510. private _invertRefractionY;
  50511. /**
  50512. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50513. */
  50514. invertRefractionY: boolean;
  50515. private _linkRefractionWithTransparency;
  50516. /**
  50517. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50518. * Materials half opaque for instance using refraction could benefit from this control.
  50519. */
  50520. linkRefractionWithTransparency: boolean;
  50521. /**
  50522. * Defines the minimum thickness stored in the thickness map.
  50523. * If no thickness map is defined, this value will be used to simulate thickness.
  50524. */
  50525. minimumThickness: number;
  50526. /**
  50527. * Defines the maximum thickness stored in the thickness map.
  50528. */
  50529. maximumThickness: number;
  50530. /**
  50531. * Defines the volume tint of the material.
  50532. * This is used for both translucency and scattering.
  50533. */
  50534. tintColor: Color3;
  50535. /**
  50536. * Defines the distance at which the tint color should be found in the media.
  50537. * This is used for refraction only.
  50538. */
  50539. tintColorAtDistance: number;
  50540. /**
  50541. * Defines how far each channel transmit through the media.
  50542. * It is defined as a color to simplify it selection.
  50543. */
  50544. diffusionDistance: Color3;
  50545. private _useMaskFromThicknessTexture;
  50546. /**
  50547. * Stores the intensity of the different subsurface effects in the thickness texture.
  50548. * * the green channel is the translucency intensity.
  50549. * * the blue channel is the scattering intensity.
  50550. * * the alpha channel is the refraction intensity.
  50551. */
  50552. useMaskFromThicknessTexture: boolean;
  50553. /** @hidden */
  50554. private _internalMarkAllSubMeshesAsTexturesDirty;
  50555. /** @hidden */
  50556. _markAllSubMeshesAsTexturesDirty(): void;
  50557. /**
  50558. * Instantiate a new istance of sub surface configuration.
  50559. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50560. */
  50561. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50562. /**
  50563. * Gets wehter the submesh is ready to be used or not.
  50564. * @param defines the list of "defines" to update.
  50565. * @param scene defines the scene the material belongs to.
  50566. * @returns - boolean indicating that the submesh is ready or not.
  50567. */
  50568. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50569. /**
  50570. * Checks to see if a texture is used in the material.
  50571. * @param defines the list of "defines" to update.
  50572. * @param scene defines the scene to the material belongs to.
  50573. */
  50574. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50575. /**
  50576. * Binds the material data.
  50577. * @param uniformBuffer defines the Uniform buffer to fill in.
  50578. * @param scene defines the scene the material belongs to.
  50579. * @param engine defines the engine the material belongs to.
  50580. * @param isFrozen defines wether the material is frozen or not.
  50581. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50582. */
  50583. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50584. /**
  50585. * Unbinds the material from the mesh.
  50586. * @param activeEffect defines the effect that should be unbound from.
  50587. * @returns true if unbound, otherwise false
  50588. */
  50589. unbind(activeEffect: Effect): boolean;
  50590. /**
  50591. * Returns the texture used for refraction or null if none is used.
  50592. * @param scene defines the scene the material belongs to.
  50593. * @returns - Refraction texture if present. If no refraction texture and refraction
  50594. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50595. */
  50596. private _getRefractionTexture;
  50597. /**
  50598. * Returns true if alpha blending should be disabled.
  50599. */
  50600. get disableAlphaBlending(): boolean;
  50601. /**
  50602. * Fills the list of render target textures.
  50603. * @param renderTargets the list of render targets to update
  50604. */
  50605. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50606. /**
  50607. * Checks to see if a texture is used in the material.
  50608. * @param texture - Base texture to use.
  50609. * @returns - Boolean specifying if a texture is used in the material.
  50610. */
  50611. hasTexture(texture: BaseTexture): boolean;
  50612. /**
  50613. * Gets a boolean indicating that current material needs to register RTT
  50614. * @returns true if this uses a render target otherwise false.
  50615. */
  50616. hasRenderTargetTextures(): boolean;
  50617. /**
  50618. * Returns an array of the actively used textures.
  50619. * @param activeTextures Array of BaseTextures
  50620. */
  50621. getActiveTextures(activeTextures: BaseTexture[]): void;
  50622. /**
  50623. * Returns the animatable textures.
  50624. * @param animatables Array of animatable textures.
  50625. */
  50626. getAnimatables(animatables: IAnimatable[]): void;
  50627. /**
  50628. * Disposes the resources of the material.
  50629. * @param forceDisposeTextures - Forces the disposal of all textures.
  50630. */
  50631. dispose(forceDisposeTextures?: boolean): void;
  50632. /**
  50633. * Get the current class name of the texture useful for serialization or dynamic coding.
  50634. * @returns "PBRSubSurfaceConfiguration"
  50635. */
  50636. getClassName(): string;
  50637. /**
  50638. * Add fallbacks to the effect fallbacks list.
  50639. * @param defines defines the Base texture to use.
  50640. * @param fallbacks defines the current fallback list.
  50641. * @param currentRank defines the current fallback rank.
  50642. * @returns the new fallback rank.
  50643. */
  50644. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50645. /**
  50646. * Add the required uniforms to the current list.
  50647. * @param uniforms defines the current uniform list.
  50648. */
  50649. static AddUniforms(uniforms: string[]): void;
  50650. /**
  50651. * Add the required samplers to the current list.
  50652. * @param samplers defines the current sampler list.
  50653. */
  50654. static AddSamplers(samplers: string[]): void;
  50655. /**
  50656. * Add the required uniforms to the current buffer.
  50657. * @param uniformBuffer defines the current uniform buffer.
  50658. */
  50659. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50660. /**
  50661. * Makes a duplicate of the current configuration into another one.
  50662. * @param configuration define the config where to copy the info
  50663. */
  50664. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50665. /**
  50666. * Serializes this Sub Surface configuration.
  50667. * @returns - An object with the serialized config.
  50668. */
  50669. serialize(): any;
  50670. /**
  50671. * Parses a anisotropy Configuration from a serialized object.
  50672. * @param source - Serialized object.
  50673. * @param scene Defines the scene we are parsing for
  50674. * @param rootUrl Defines the rootUrl to load from
  50675. */
  50676. parse(source: any, scene: Scene, rootUrl: string): void;
  50677. }
  50678. }
  50679. declare module BABYLON {
  50680. /** @hidden */
  50681. export var pbrFragmentDeclaration: {
  50682. name: string;
  50683. shader: string;
  50684. };
  50685. }
  50686. declare module BABYLON {
  50687. /** @hidden */
  50688. export var pbrUboDeclaration: {
  50689. name: string;
  50690. shader: string;
  50691. };
  50692. }
  50693. declare module BABYLON {
  50694. /** @hidden */
  50695. export var pbrFragmentExtraDeclaration: {
  50696. name: string;
  50697. shader: string;
  50698. };
  50699. }
  50700. declare module BABYLON {
  50701. /** @hidden */
  50702. export var pbrFragmentSamplersDeclaration: {
  50703. name: string;
  50704. shader: string;
  50705. };
  50706. }
  50707. declare module BABYLON {
  50708. /** @hidden */
  50709. export var pbrHelperFunctions: {
  50710. name: string;
  50711. shader: string;
  50712. };
  50713. }
  50714. declare module BABYLON {
  50715. /** @hidden */
  50716. export var harmonicsFunctions: {
  50717. name: string;
  50718. shader: string;
  50719. };
  50720. }
  50721. declare module BABYLON {
  50722. /** @hidden */
  50723. export var pbrDirectLightingSetupFunctions: {
  50724. name: string;
  50725. shader: string;
  50726. };
  50727. }
  50728. declare module BABYLON {
  50729. /** @hidden */
  50730. export var pbrDirectLightingFalloffFunctions: {
  50731. name: string;
  50732. shader: string;
  50733. };
  50734. }
  50735. declare module BABYLON {
  50736. /** @hidden */
  50737. export var pbrBRDFFunctions: {
  50738. name: string;
  50739. shader: string;
  50740. };
  50741. }
  50742. declare module BABYLON {
  50743. /** @hidden */
  50744. export var pbrDirectLightingFunctions: {
  50745. name: string;
  50746. shader: string;
  50747. };
  50748. }
  50749. declare module BABYLON {
  50750. /** @hidden */
  50751. export var pbrIBLFunctions: {
  50752. name: string;
  50753. shader: string;
  50754. };
  50755. }
  50756. declare module BABYLON {
  50757. /** @hidden */
  50758. export var pbrDebug: {
  50759. name: string;
  50760. shader: string;
  50761. };
  50762. }
  50763. declare module BABYLON {
  50764. /** @hidden */
  50765. export var pbrPixelShader: {
  50766. name: string;
  50767. shader: string;
  50768. };
  50769. }
  50770. declare module BABYLON {
  50771. /** @hidden */
  50772. export var pbrVertexDeclaration: {
  50773. name: string;
  50774. shader: string;
  50775. };
  50776. }
  50777. declare module BABYLON {
  50778. /** @hidden */
  50779. export var pbrVertexShader: {
  50780. name: string;
  50781. shader: string;
  50782. };
  50783. }
  50784. declare module BABYLON {
  50785. /**
  50786. * Manages the defines for the PBR Material.
  50787. * @hidden
  50788. */
  50789. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50790. PBR: boolean;
  50791. MAINUV1: boolean;
  50792. MAINUV2: boolean;
  50793. UV1: boolean;
  50794. UV2: boolean;
  50795. ALBEDO: boolean;
  50796. GAMMAALBEDO: boolean;
  50797. ALBEDODIRECTUV: number;
  50798. VERTEXCOLOR: boolean;
  50799. AMBIENT: boolean;
  50800. AMBIENTDIRECTUV: number;
  50801. AMBIENTINGRAYSCALE: boolean;
  50802. OPACITY: boolean;
  50803. VERTEXALPHA: boolean;
  50804. OPACITYDIRECTUV: number;
  50805. OPACITYRGB: boolean;
  50806. ALPHATEST: boolean;
  50807. DEPTHPREPASS: boolean;
  50808. ALPHABLEND: boolean;
  50809. ALPHAFROMALBEDO: boolean;
  50810. ALPHATESTVALUE: string;
  50811. SPECULAROVERALPHA: boolean;
  50812. RADIANCEOVERALPHA: boolean;
  50813. ALPHAFRESNEL: boolean;
  50814. LINEARALPHAFRESNEL: boolean;
  50815. PREMULTIPLYALPHA: boolean;
  50816. EMISSIVE: boolean;
  50817. EMISSIVEDIRECTUV: number;
  50818. REFLECTIVITY: boolean;
  50819. REFLECTIVITYDIRECTUV: number;
  50820. SPECULARTERM: boolean;
  50821. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50822. MICROSURFACEAUTOMATIC: boolean;
  50823. LODBASEDMICROSFURACE: boolean;
  50824. MICROSURFACEMAP: boolean;
  50825. MICROSURFACEMAPDIRECTUV: number;
  50826. METALLICWORKFLOW: boolean;
  50827. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50828. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50829. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50830. AOSTOREINMETALMAPRED: boolean;
  50831. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50832. ENVIRONMENTBRDF: boolean;
  50833. ENVIRONMENTBRDF_RGBD: boolean;
  50834. NORMAL: boolean;
  50835. TANGENT: boolean;
  50836. BUMP: boolean;
  50837. BUMPDIRECTUV: number;
  50838. OBJECTSPACE_NORMALMAP: boolean;
  50839. PARALLAX: boolean;
  50840. PARALLAXOCCLUSION: boolean;
  50841. NORMALXYSCALE: boolean;
  50842. LIGHTMAP: boolean;
  50843. LIGHTMAPDIRECTUV: number;
  50844. USELIGHTMAPASSHADOWMAP: boolean;
  50845. GAMMALIGHTMAP: boolean;
  50846. RGBDLIGHTMAP: boolean;
  50847. REFLECTION: boolean;
  50848. REFLECTIONMAP_3D: boolean;
  50849. REFLECTIONMAP_SPHERICAL: boolean;
  50850. REFLECTIONMAP_PLANAR: boolean;
  50851. REFLECTIONMAP_CUBIC: boolean;
  50852. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50853. REFLECTIONMAP_PROJECTION: boolean;
  50854. REFLECTIONMAP_SKYBOX: boolean;
  50855. REFLECTIONMAP_EXPLICIT: boolean;
  50856. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50857. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50858. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50859. INVERTCUBICMAP: boolean;
  50860. USESPHERICALFROMREFLECTIONMAP: boolean;
  50861. USEIRRADIANCEMAP: boolean;
  50862. SPHERICAL_HARMONICS: boolean;
  50863. USESPHERICALINVERTEX: boolean;
  50864. REFLECTIONMAP_OPPOSITEZ: boolean;
  50865. LODINREFLECTIONALPHA: boolean;
  50866. GAMMAREFLECTION: boolean;
  50867. RGBDREFLECTION: boolean;
  50868. LINEARSPECULARREFLECTION: boolean;
  50869. RADIANCEOCCLUSION: boolean;
  50870. HORIZONOCCLUSION: boolean;
  50871. INSTANCES: boolean;
  50872. NUM_BONE_INFLUENCERS: number;
  50873. BonesPerMesh: number;
  50874. BONETEXTURE: boolean;
  50875. NONUNIFORMSCALING: boolean;
  50876. MORPHTARGETS: boolean;
  50877. MORPHTARGETS_NORMAL: boolean;
  50878. MORPHTARGETS_TANGENT: boolean;
  50879. MORPHTARGETS_UV: boolean;
  50880. NUM_MORPH_INFLUENCERS: number;
  50881. IMAGEPROCESSING: boolean;
  50882. VIGNETTE: boolean;
  50883. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50884. VIGNETTEBLENDMODEOPAQUE: boolean;
  50885. TONEMAPPING: boolean;
  50886. TONEMAPPING_ACES: boolean;
  50887. CONTRAST: boolean;
  50888. COLORCURVES: boolean;
  50889. COLORGRADING: boolean;
  50890. COLORGRADING3D: boolean;
  50891. SAMPLER3DGREENDEPTH: boolean;
  50892. SAMPLER3DBGRMAP: boolean;
  50893. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50894. EXPOSURE: boolean;
  50895. MULTIVIEW: boolean;
  50896. USEPHYSICALLIGHTFALLOFF: boolean;
  50897. USEGLTFLIGHTFALLOFF: boolean;
  50898. TWOSIDEDLIGHTING: boolean;
  50899. SHADOWFLOAT: boolean;
  50900. CLIPPLANE: boolean;
  50901. CLIPPLANE2: boolean;
  50902. CLIPPLANE3: boolean;
  50903. CLIPPLANE4: boolean;
  50904. CLIPPLANE5: boolean;
  50905. CLIPPLANE6: boolean;
  50906. POINTSIZE: boolean;
  50907. FOG: boolean;
  50908. LOGARITHMICDEPTH: boolean;
  50909. FORCENORMALFORWARD: boolean;
  50910. SPECULARAA: boolean;
  50911. CLEARCOAT: boolean;
  50912. CLEARCOAT_DEFAULTIOR: boolean;
  50913. CLEARCOAT_TEXTURE: boolean;
  50914. CLEARCOAT_TEXTUREDIRECTUV: number;
  50915. CLEARCOAT_BUMP: boolean;
  50916. CLEARCOAT_BUMPDIRECTUV: number;
  50917. CLEARCOAT_TINT: boolean;
  50918. CLEARCOAT_TINT_TEXTURE: boolean;
  50919. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50920. ANISOTROPIC: boolean;
  50921. ANISOTROPIC_TEXTURE: boolean;
  50922. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50923. BRDF_V_HEIGHT_CORRELATED: boolean;
  50924. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50925. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50926. SHEEN: boolean;
  50927. SHEEN_TEXTURE: boolean;
  50928. SHEEN_TEXTUREDIRECTUV: number;
  50929. SHEEN_LINKWITHALBEDO: boolean;
  50930. SUBSURFACE: boolean;
  50931. SS_REFRACTION: boolean;
  50932. SS_TRANSLUCENCY: boolean;
  50933. SS_SCATERRING: boolean;
  50934. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50935. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50936. SS_REFRACTIONMAP_3D: boolean;
  50937. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50938. SS_LODINREFRACTIONALPHA: boolean;
  50939. SS_GAMMAREFRACTION: boolean;
  50940. SS_RGBDREFRACTION: boolean;
  50941. SS_LINEARSPECULARREFRACTION: boolean;
  50942. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50943. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50944. UNLIT: boolean;
  50945. DEBUGMODE: number;
  50946. /**
  50947. * Initializes the PBR Material defines.
  50948. */
  50949. constructor();
  50950. /**
  50951. * Resets the PBR Material defines.
  50952. */
  50953. reset(): void;
  50954. }
  50955. /**
  50956. * The Physically based material base class of BJS.
  50957. *
  50958. * This offers the main features of a standard PBR material.
  50959. * For more information, please refer to the documentation :
  50960. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50961. */
  50962. export abstract class PBRBaseMaterial extends PushMaterial {
  50963. /**
  50964. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50965. */
  50966. static readonly PBRMATERIAL_OPAQUE: number;
  50967. /**
  50968. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50969. */
  50970. static readonly PBRMATERIAL_ALPHATEST: number;
  50971. /**
  50972. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50973. */
  50974. static readonly PBRMATERIAL_ALPHABLEND: number;
  50975. /**
  50976. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50977. * They are also discarded below the alpha cutoff threshold to improve performances.
  50978. */
  50979. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50980. /**
  50981. * Defines the default value of how much AO map is occluding the analytical lights
  50982. * (point spot...).
  50983. */
  50984. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50985. /**
  50986. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50987. */
  50988. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50989. /**
  50990. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50991. * to enhance interoperability with other engines.
  50992. */
  50993. static readonly LIGHTFALLOFF_GLTF: number;
  50994. /**
  50995. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50996. * to enhance interoperability with other materials.
  50997. */
  50998. static readonly LIGHTFALLOFF_STANDARD: number;
  50999. /**
  51000. * Intensity of the direct lights e.g. the four lights available in your scene.
  51001. * This impacts both the direct diffuse and specular highlights.
  51002. */
  51003. protected _directIntensity: number;
  51004. /**
  51005. * Intensity of the emissive part of the material.
  51006. * This helps controlling the emissive effect without modifying the emissive color.
  51007. */
  51008. protected _emissiveIntensity: number;
  51009. /**
  51010. * Intensity of the environment e.g. how much the environment will light the object
  51011. * either through harmonics for rough material or through the refelction for shiny ones.
  51012. */
  51013. protected _environmentIntensity: number;
  51014. /**
  51015. * This is a special control allowing the reduction of the specular highlights coming from the
  51016. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51017. */
  51018. protected _specularIntensity: number;
  51019. /**
  51020. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51021. */
  51022. private _lightingInfos;
  51023. /**
  51024. * Debug Control allowing disabling the bump map on this material.
  51025. */
  51026. protected _disableBumpMap: boolean;
  51027. /**
  51028. * AKA Diffuse Texture in standard nomenclature.
  51029. */
  51030. protected _albedoTexture: Nullable<BaseTexture>;
  51031. /**
  51032. * AKA Occlusion Texture in other nomenclature.
  51033. */
  51034. protected _ambientTexture: Nullable<BaseTexture>;
  51035. /**
  51036. * AKA Occlusion Texture Intensity in other nomenclature.
  51037. */
  51038. protected _ambientTextureStrength: number;
  51039. /**
  51040. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51041. * 1 means it completely occludes it
  51042. * 0 mean it has no impact
  51043. */
  51044. protected _ambientTextureImpactOnAnalyticalLights: number;
  51045. /**
  51046. * Stores the alpha values in a texture.
  51047. */
  51048. protected _opacityTexture: Nullable<BaseTexture>;
  51049. /**
  51050. * Stores the reflection values in a texture.
  51051. */
  51052. protected _reflectionTexture: Nullable<BaseTexture>;
  51053. /**
  51054. * Stores the emissive values in a texture.
  51055. */
  51056. protected _emissiveTexture: Nullable<BaseTexture>;
  51057. /**
  51058. * AKA Specular texture in other nomenclature.
  51059. */
  51060. protected _reflectivityTexture: Nullable<BaseTexture>;
  51061. /**
  51062. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51063. */
  51064. protected _metallicTexture: Nullable<BaseTexture>;
  51065. /**
  51066. * Specifies the metallic scalar of the metallic/roughness workflow.
  51067. * Can also be used to scale the metalness values of the metallic texture.
  51068. */
  51069. protected _metallic: Nullable<number>;
  51070. /**
  51071. * Specifies the roughness scalar of the metallic/roughness workflow.
  51072. * Can also be used to scale the roughness values of the metallic texture.
  51073. */
  51074. protected _roughness: Nullable<number>;
  51075. /**
  51076. * Specifies the an F0 factor to help configuring the material F0.
  51077. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51078. * to 0.5 the previously hard coded value stays the same.
  51079. * Can also be used to scale the F0 values of the metallic texture.
  51080. */
  51081. protected _metallicF0Factor: number;
  51082. /**
  51083. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51084. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51085. * your expectation as it multiplies with the texture data.
  51086. */
  51087. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51088. /**
  51089. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51090. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51091. */
  51092. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51093. /**
  51094. * Stores surface normal data used to displace a mesh in a texture.
  51095. */
  51096. protected _bumpTexture: Nullable<BaseTexture>;
  51097. /**
  51098. * Stores the pre-calculated light information of a mesh in a texture.
  51099. */
  51100. protected _lightmapTexture: Nullable<BaseTexture>;
  51101. /**
  51102. * The color of a material in ambient lighting.
  51103. */
  51104. protected _ambientColor: Color3;
  51105. /**
  51106. * AKA Diffuse Color in other nomenclature.
  51107. */
  51108. protected _albedoColor: Color3;
  51109. /**
  51110. * AKA Specular Color in other nomenclature.
  51111. */
  51112. protected _reflectivityColor: Color3;
  51113. /**
  51114. * The color applied when light is reflected from a material.
  51115. */
  51116. protected _reflectionColor: Color3;
  51117. /**
  51118. * The color applied when light is emitted from a material.
  51119. */
  51120. protected _emissiveColor: Color3;
  51121. /**
  51122. * AKA Glossiness in other nomenclature.
  51123. */
  51124. protected _microSurface: number;
  51125. /**
  51126. * Specifies that the material will use the light map as a show map.
  51127. */
  51128. protected _useLightmapAsShadowmap: boolean;
  51129. /**
  51130. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51131. * makes the reflect vector face the model (under horizon).
  51132. */
  51133. protected _useHorizonOcclusion: boolean;
  51134. /**
  51135. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51136. * too much the area relying on ambient texture to define their ambient occlusion.
  51137. */
  51138. protected _useRadianceOcclusion: boolean;
  51139. /**
  51140. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51141. */
  51142. protected _useAlphaFromAlbedoTexture: boolean;
  51143. /**
  51144. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51145. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51146. */
  51147. protected _useSpecularOverAlpha: boolean;
  51148. /**
  51149. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51150. */
  51151. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51152. /**
  51153. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51154. */
  51155. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51156. /**
  51157. * Specifies if the metallic texture contains the roughness information in its green channel.
  51158. */
  51159. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51160. /**
  51161. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51162. */
  51163. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51164. /**
  51165. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51166. */
  51167. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51168. /**
  51169. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51170. */
  51171. protected _useAmbientInGrayScale: boolean;
  51172. /**
  51173. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51174. * The material will try to infer what glossiness each pixel should be.
  51175. */
  51176. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51177. /**
  51178. * Defines the falloff type used in this material.
  51179. * It by default is Physical.
  51180. */
  51181. protected _lightFalloff: number;
  51182. /**
  51183. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51184. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51185. */
  51186. protected _useRadianceOverAlpha: boolean;
  51187. /**
  51188. * Allows using an object space normal map (instead of tangent space).
  51189. */
  51190. protected _useObjectSpaceNormalMap: boolean;
  51191. /**
  51192. * Allows using the bump map in parallax mode.
  51193. */
  51194. protected _useParallax: boolean;
  51195. /**
  51196. * Allows using the bump map in parallax occlusion mode.
  51197. */
  51198. protected _useParallaxOcclusion: boolean;
  51199. /**
  51200. * Controls the scale bias of the parallax mode.
  51201. */
  51202. protected _parallaxScaleBias: number;
  51203. /**
  51204. * If sets to true, disables all the lights affecting the material.
  51205. */
  51206. protected _disableLighting: boolean;
  51207. /**
  51208. * Number of Simultaneous lights allowed on the material.
  51209. */
  51210. protected _maxSimultaneousLights: number;
  51211. /**
  51212. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51213. */
  51214. protected _invertNormalMapX: boolean;
  51215. /**
  51216. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51217. */
  51218. protected _invertNormalMapY: boolean;
  51219. /**
  51220. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51221. */
  51222. protected _twoSidedLighting: boolean;
  51223. /**
  51224. * Defines the alpha limits in alpha test mode.
  51225. */
  51226. protected _alphaCutOff: number;
  51227. /**
  51228. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51229. */
  51230. protected _forceAlphaTest: boolean;
  51231. /**
  51232. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51233. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51234. */
  51235. protected _useAlphaFresnel: boolean;
  51236. /**
  51237. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51238. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51239. */
  51240. protected _useLinearAlphaFresnel: boolean;
  51241. /**
  51242. * The transparency mode of the material.
  51243. */
  51244. protected _transparencyMode: Nullable<number>;
  51245. /**
  51246. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51247. * from cos thetav and roughness:
  51248. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51249. */
  51250. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51251. /**
  51252. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51253. */
  51254. protected _forceIrradianceInFragment: boolean;
  51255. /**
  51256. * Force normal to face away from face.
  51257. */
  51258. protected _forceNormalForward: boolean;
  51259. /**
  51260. * Enables specular anti aliasing in the PBR shader.
  51261. * It will both interacts on the Geometry for analytical and IBL lighting.
  51262. * It also prefilter the roughness map based on the bump values.
  51263. */
  51264. protected _enableSpecularAntiAliasing: boolean;
  51265. /**
  51266. * Default configuration related to image processing available in the PBR Material.
  51267. */
  51268. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51269. /**
  51270. * Keep track of the image processing observer to allow dispose and replace.
  51271. */
  51272. private _imageProcessingObserver;
  51273. /**
  51274. * Attaches a new image processing configuration to the PBR Material.
  51275. * @param configuration
  51276. */
  51277. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51278. /**
  51279. * Stores the available render targets.
  51280. */
  51281. private _renderTargets;
  51282. /**
  51283. * Sets the global ambient color for the material used in lighting calculations.
  51284. */
  51285. private _globalAmbientColor;
  51286. /**
  51287. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51288. */
  51289. private _useLogarithmicDepth;
  51290. /**
  51291. * If set to true, no lighting calculations will be applied.
  51292. */
  51293. private _unlit;
  51294. private _debugMode;
  51295. /**
  51296. * @hidden
  51297. * This is reserved for the inspector.
  51298. * Defines the material debug mode.
  51299. * It helps seeing only some components of the material while troubleshooting.
  51300. */
  51301. debugMode: number;
  51302. /**
  51303. * @hidden
  51304. * This is reserved for the inspector.
  51305. * Specify from where on screen the debug mode should start.
  51306. * The value goes from -1 (full screen) to 1 (not visible)
  51307. * It helps with side by side comparison against the final render
  51308. * This defaults to -1
  51309. */
  51310. private debugLimit;
  51311. /**
  51312. * @hidden
  51313. * This is reserved for the inspector.
  51314. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51315. * You can use the factor to better multiply the final value.
  51316. */
  51317. private debugFactor;
  51318. /**
  51319. * Defines the clear coat layer parameters for the material.
  51320. */
  51321. readonly clearCoat: PBRClearCoatConfiguration;
  51322. /**
  51323. * Defines the anisotropic parameters for the material.
  51324. */
  51325. readonly anisotropy: PBRAnisotropicConfiguration;
  51326. /**
  51327. * Defines the BRDF parameters for the material.
  51328. */
  51329. readonly brdf: PBRBRDFConfiguration;
  51330. /**
  51331. * Defines the Sheen parameters for the material.
  51332. */
  51333. readonly sheen: PBRSheenConfiguration;
  51334. /**
  51335. * Defines the SubSurface parameters for the material.
  51336. */
  51337. readonly subSurface: PBRSubSurfaceConfiguration;
  51338. /**
  51339. * Custom callback helping to override the default shader used in the material.
  51340. */
  51341. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51342. protected _rebuildInParallel: boolean;
  51343. /**
  51344. * Instantiates a new PBRMaterial instance.
  51345. *
  51346. * @param name The material name
  51347. * @param scene The scene the material will be use in.
  51348. */
  51349. constructor(name: string, scene: Scene);
  51350. /**
  51351. * Gets a boolean indicating that current material needs to register RTT
  51352. */
  51353. get hasRenderTargetTextures(): boolean;
  51354. /**
  51355. * Gets the name of the material class.
  51356. */
  51357. getClassName(): string;
  51358. /**
  51359. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51360. */
  51361. get useLogarithmicDepth(): boolean;
  51362. /**
  51363. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51364. */
  51365. set useLogarithmicDepth(value: boolean);
  51366. /**
  51367. * Gets the current transparency mode.
  51368. */
  51369. get transparencyMode(): Nullable<number>;
  51370. /**
  51371. * Sets the transparency mode of the material.
  51372. *
  51373. * | Value | Type | Description |
  51374. * | ----- | ----------------------------------- | ----------- |
  51375. * | 0 | OPAQUE | |
  51376. * | 1 | ALPHATEST | |
  51377. * | 2 | ALPHABLEND | |
  51378. * | 3 | ALPHATESTANDBLEND | |
  51379. *
  51380. */
  51381. set transparencyMode(value: Nullable<number>);
  51382. /**
  51383. * Returns true if alpha blending should be disabled.
  51384. */
  51385. private get _disableAlphaBlending();
  51386. /**
  51387. * Specifies whether or not this material should be rendered in alpha blend mode.
  51388. */
  51389. needAlphaBlending(): boolean;
  51390. /**
  51391. * Specifies if the mesh will require alpha blending.
  51392. * @param mesh - BJS mesh.
  51393. */
  51394. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51395. /**
  51396. * Specifies whether or not this material should be rendered in alpha test mode.
  51397. */
  51398. needAlphaTesting(): boolean;
  51399. /**
  51400. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51401. */
  51402. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51403. /**
  51404. * Gets the texture used for the alpha test.
  51405. */
  51406. getAlphaTestTexture(): Nullable<BaseTexture>;
  51407. /**
  51408. * Specifies that the submesh is ready to be used.
  51409. * @param mesh - BJS mesh.
  51410. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51411. * @param useInstances - Specifies that instances should be used.
  51412. * @returns - boolean indicating that the submesh is ready or not.
  51413. */
  51414. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51415. /**
  51416. * Specifies if the material uses metallic roughness workflow.
  51417. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51418. */
  51419. isMetallicWorkflow(): boolean;
  51420. private _prepareEffect;
  51421. private _prepareDefines;
  51422. /**
  51423. * Force shader compilation
  51424. */
  51425. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51426. /**
  51427. * Initializes the uniform buffer layout for the shader.
  51428. */
  51429. buildUniformLayout(): void;
  51430. /**
  51431. * Unbinds the material from the mesh
  51432. */
  51433. unbind(): void;
  51434. /**
  51435. * Binds the submesh data.
  51436. * @param world - The world matrix.
  51437. * @param mesh - The BJS mesh.
  51438. * @param subMesh - A submesh of the BJS mesh.
  51439. */
  51440. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51441. /**
  51442. * Returns the animatable textures.
  51443. * @returns - Array of animatable textures.
  51444. */
  51445. getAnimatables(): IAnimatable[];
  51446. /**
  51447. * Returns the texture used for reflections.
  51448. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51449. */
  51450. private _getReflectionTexture;
  51451. /**
  51452. * Returns an array of the actively used textures.
  51453. * @returns - Array of BaseTextures
  51454. */
  51455. getActiveTextures(): BaseTexture[];
  51456. /**
  51457. * Checks to see if a texture is used in the material.
  51458. * @param texture - Base texture to use.
  51459. * @returns - Boolean specifying if a texture is used in the material.
  51460. */
  51461. hasTexture(texture: BaseTexture): boolean;
  51462. /**
  51463. * Disposes the resources of the material.
  51464. * @param forceDisposeEffect - Forces the disposal of effects.
  51465. * @param forceDisposeTextures - Forces the disposal of all textures.
  51466. */
  51467. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51468. }
  51469. }
  51470. declare module BABYLON {
  51471. /**
  51472. * The Physically based material of BJS.
  51473. *
  51474. * This offers the main features of a standard PBR material.
  51475. * For more information, please refer to the documentation :
  51476. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51477. */
  51478. export class PBRMaterial extends PBRBaseMaterial {
  51479. /**
  51480. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51481. */
  51482. static readonly PBRMATERIAL_OPAQUE: number;
  51483. /**
  51484. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51485. */
  51486. static readonly PBRMATERIAL_ALPHATEST: number;
  51487. /**
  51488. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51489. */
  51490. static readonly PBRMATERIAL_ALPHABLEND: number;
  51491. /**
  51492. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51493. * They are also discarded below the alpha cutoff threshold to improve performances.
  51494. */
  51495. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51496. /**
  51497. * Defines the default value of how much AO map is occluding the analytical lights
  51498. * (point spot...).
  51499. */
  51500. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51501. /**
  51502. * Intensity of the direct lights e.g. the four lights available in your scene.
  51503. * This impacts both the direct diffuse and specular highlights.
  51504. */
  51505. directIntensity: number;
  51506. /**
  51507. * Intensity of the emissive part of the material.
  51508. * This helps controlling the emissive effect without modifying the emissive color.
  51509. */
  51510. emissiveIntensity: number;
  51511. /**
  51512. * Intensity of the environment e.g. how much the environment will light the object
  51513. * either through harmonics for rough material or through the refelction for shiny ones.
  51514. */
  51515. environmentIntensity: number;
  51516. /**
  51517. * This is a special control allowing the reduction of the specular highlights coming from the
  51518. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51519. */
  51520. specularIntensity: number;
  51521. /**
  51522. * Debug Control allowing disabling the bump map on this material.
  51523. */
  51524. disableBumpMap: boolean;
  51525. /**
  51526. * AKA Diffuse Texture in standard nomenclature.
  51527. */
  51528. albedoTexture: BaseTexture;
  51529. /**
  51530. * AKA Occlusion Texture in other nomenclature.
  51531. */
  51532. ambientTexture: BaseTexture;
  51533. /**
  51534. * AKA Occlusion Texture Intensity in other nomenclature.
  51535. */
  51536. ambientTextureStrength: number;
  51537. /**
  51538. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51539. * 1 means it completely occludes it
  51540. * 0 mean it has no impact
  51541. */
  51542. ambientTextureImpactOnAnalyticalLights: number;
  51543. /**
  51544. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51545. */
  51546. opacityTexture: BaseTexture;
  51547. /**
  51548. * Stores the reflection values in a texture.
  51549. */
  51550. reflectionTexture: Nullable<BaseTexture>;
  51551. /**
  51552. * Stores the emissive values in a texture.
  51553. */
  51554. emissiveTexture: BaseTexture;
  51555. /**
  51556. * AKA Specular texture in other nomenclature.
  51557. */
  51558. reflectivityTexture: BaseTexture;
  51559. /**
  51560. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51561. */
  51562. metallicTexture: BaseTexture;
  51563. /**
  51564. * Specifies the metallic scalar of the metallic/roughness workflow.
  51565. * Can also be used to scale the metalness values of the metallic texture.
  51566. */
  51567. metallic: Nullable<number>;
  51568. /**
  51569. * Specifies the roughness scalar of the metallic/roughness workflow.
  51570. * Can also be used to scale the roughness values of the metallic texture.
  51571. */
  51572. roughness: Nullable<number>;
  51573. /**
  51574. * Specifies the an F0 factor to help configuring the material F0.
  51575. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51576. * to 0.5 the previously hard coded value stays the same.
  51577. * Can also be used to scale the F0 values of the metallic texture.
  51578. */
  51579. metallicF0Factor: number;
  51580. /**
  51581. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51582. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51583. * your expectation as it multiplies with the texture data.
  51584. */
  51585. useMetallicF0FactorFromMetallicTexture: boolean;
  51586. /**
  51587. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51588. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51589. */
  51590. microSurfaceTexture: BaseTexture;
  51591. /**
  51592. * Stores surface normal data used to displace a mesh in a texture.
  51593. */
  51594. bumpTexture: BaseTexture;
  51595. /**
  51596. * Stores the pre-calculated light information of a mesh in a texture.
  51597. */
  51598. lightmapTexture: BaseTexture;
  51599. /**
  51600. * Stores the refracted light information in a texture.
  51601. */
  51602. get refractionTexture(): Nullable<BaseTexture>;
  51603. set refractionTexture(value: Nullable<BaseTexture>);
  51604. /**
  51605. * The color of a material in ambient lighting.
  51606. */
  51607. ambientColor: Color3;
  51608. /**
  51609. * AKA Diffuse Color in other nomenclature.
  51610. */
  51611. albedoColor: Color3;
  51612. /**
  51613. * AKA Specular Color in other nomenclature.
  51614. */
  51615. reflectivityColor: Color3;
  51616. /**
  51617. * The color reflected from the material.
  51618. */
  51619. reflectionColor: Color3;
  51620. /**
  51621. * The color emitted from the material.
  51622. */
  51623. emissiveColor: Color3;
  51624. /**
  51625. * AKA Glossiness in other nomenclature.
  51626. */
  51627. microSurface: number;
  51628. /**
  51629. * source material index of refraction (IOR)' / 'destination material IOR.
  51630. */
  51631. get indexOfRefraction(): number;
  51632. set indexOfRefraction(value: number);
  51633. /**
  51634. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51635. */
  51636. get invertRefractionY(): boolean;
  51637. set invertRefractionY(value: boolean);
  51638. /**
  51639. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51640. * Materials half opaque for instance using refraction could benefit from this control.
  51641. */
  51642. get linkRefractionWithTransparency(): boolean;
  51643. set linkRefractionWithTransparency(value: boolean);
  51644. /**
  51645. * If true, the light map contains occlusion information instead of lighting info.
  51646. */
  51647. useLightmapAsShadowmap: boolean;
  51648. /**
  51649. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51650. */
  51651. useAlphaFromAlbedoTexture: boolean;
  51652. /**
  51653. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51654. */
  51655. forceAlphaTest: boolean;
  51656. /**
  51657. * Defines the alpha limits in alpha test mode.
  51658. */
  51659. alphaCutOff: number;
  51660. /**
  51661. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51662. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51663. */
  51664. useSpecularOverAlpha: boolean;
  51665. /**
  51666. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51667. */
  51668. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51669. /**
  51670. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51671. */
  51672. useRoughnessFromMetallicTextureAlpha: boolean;
  51673. /**
  51674. * Specifies if the metallic texture contains the roughness information in its green channel.
  51675. */
  51676. useRoughnessFromMetallicTextureGreen: boolean;
  51677. /**
  51678. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51679. */
  51680. useMetallnessFromMetallicTextureBlue: boolean;
  51681. /**
  51682. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51683. */
  51684. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51685. /**
  51686. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51687. */
  51688. useAmbientInGrayScale: boolean;
  51689. /**
  51690. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51691. * The material will try to infer what glossiness each pixel should be.
  51692. */
  51693. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51694. /**
  51695. * BJS is using an harcoded light falloff based on a manually sets up range.
  51696. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51697. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51698. */
  51699. get usePhysicalLightFalloff(): boolean;
  51700. /**
  51701. * BJS is using an harcoded light falloff based on a manually sets up range.
  51702. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51703. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51704. */
  51705. set usePhysicalLightFalloff(value: boolean);
  51706. /**
  51707. * In order to support the falloff compatibility with gltf, a special mode has been added
  51708. * to reproduce the gltf light falloff.
  51709. */
  51710. get useGLTFLightFalloff(): boolean;
  51711. /**
  51712. * In order to support the falloff compatibility with gltf, a special mode has been added
  51713. * to reproduce the gltf light falloff.
  51714. */
  51715. set useGLTFLightFalloff(value: boolean);
  51716. /**
  51717. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51718. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51719. */
  51720. useRadianceOverAlpha: boolean;
  51721. /**
  51722. * Allows using an object space normal map (instead of tangent space).
  51723. */
  51724. useObjectSpaceNormalMap: boolean;
  51725. /**
  51726. * Allows using the bump map in parallax mode.
  51727. */
  51728. useParallax: boolean;
  51729. /**
  51730. * Allows using the bump map in parallax occlusion mode.
  51731. */
  51732. useParallaxOcclusion: boolean;
  51733. /**
  51734. * Controls the scale bias of the parallax mode.
  51735. */
  51736. parallaxScaleBias: number;
  51737. /**
  51738. * If sets to true, disables all the lights affecting the material.
  51739. */
  51740. disableLighting: boolean;
  51741. /**
  51742. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51743. */
  51744. forceIrradianceInFragment: boolean;
  51745. /**
  51746. * Number of Simultaneous lights allowed on the material.
  51747. */
  51748. maxSimultaneousLights: number;
  51749. /**
  51750. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51751. */
  51752. invertNormalMapX: boolean;
  51753. /**
  51754. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51755. */
  51756. invertNormalMapY: boolean;
  51757. /**
  51758. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51759. */
  51760. twoSidedLighting: boolean;
  51761. /**
  51762. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51763. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51764. */
  51765. useAlphaFresnel: boolean;
  51766. /**
  51767. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51768. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51769. */
  51770. useLinearAlphaFresnel: boolean;
  51771. /**
  51772. * Let user defines the brdf lookup texture used for IBL.
  51773. * A default 8bit version is embedded but you could point at :
  51774. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51775. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51776. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51777. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51778. */
  51779. environmentBRDFTexture: Nullable<BaseTexture>;
  51780. /**
  51781. * Force normal to face away from face.
  51782. */
  51783. forceNormalForward: boolean;
  51784. /**
  51785. * Enables specular anti aliasing in the PBR shader.
  51786. * It will both interacts on the Geometry for analytical and IBL lighting.
  51787. * It also prefilter the roughness map based on the bump values.
  51788. */
  51789. enableSpecularAntiAliasing: boolean;
  51790. /**
  51791. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51792. * makes the reflect vector face the model (under horizon).
  51793. */
  51794. useHorizonOcclusion: boolean;
  51795. /**
  51796. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51797. * too much the area relying on ambient texture to define their ambient occlusion.
  51798. */
  51799. useRadianceOcclusion: boolean;
  51800. /**
  51801. * If set to true, no lighting calculations will be applied.
  51802. */
  51803. unlit: boolean;
  51804. /**
  51805. * Gets the image processing configuration used either in this material.
  51806. */
  51807. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51808. /**
  51809. * Sets the Default image processing configuration used either in the this material.
  51810. *
  51811. * If sets to null, the scene one is in use.
  51812. */
  51813. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51814. /**
  51815. * Gets wether the color curves effect is enabled.
  51816. */
  51817. get cameraColorCurvesEnabled(): boolean;
  51818. /**
  51819. * Sets wether the color curves effect is enabled.
  51820. */
  51821. set cameraColorCurvesEnabled(value: boolean);
  51822. /**
  51823. * Gets wether the color grading effect is enabled.
  51824. */
  51825. get cameraColorGradingEnabled(): boolean;
  51826. /**
  51827. * Gets wether the color grading effect is enabled.
  51828. */
  51829. set cameraColorGradingEnabled(value: boolean);
  51830. /**
  51831. * Gets wether tonemapping is enabled or not.
  51832. */
  51833. get cameraToneMappingEnabled(): boolean;
  51834. /**
  51835. * Sets wether tonemapping is enabled or not
  51836. */
  51837. set cameraToneMappingEnabled(value: boolean);
  51838. /**
  51839. * The camera exposure used on this material.
  51840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51841. * This corresponds to a photographic exposure.
  51842. */
  51843. get cameraExposure(): number;
  51844. /**
  51845. * The camera exposure used on this material.
  51846. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51847. * This corresponds to a photographic exposure.
  51848. */
  51849. set cameraExposure(value: number);
  51850. /**
  51851. * Gets The camera contrast used on this material.
  51852. */
  51853. get cameraContrast(): number;
  51854. /**
  51855. * Sets The camera contrast used on this material.
  51856. */
  51857. set cameraContrast(value: number);
  51858. /**
  51859. * Gets the Color Grading 2D Lookup Texture.
  51860. */
  51861. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51862. /**
  51863. * Sets the Color Grading 2D Lookup Texture.
  51864. */
  51865. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51866. /**
  51867. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51868. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51869. * 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;
  51870. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51871. */
  51872. get cameraColorCurves(): Nullable<ColorCurves>;
  51873. /**
  51874. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51875. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51876. * 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;
  51877. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51878. */
  51879. set cameraColorCurves(value: Nullable<ColorCurves>);
  51880. /**
  51881. * Instantiates a new PBRMaterial instance.
  51882. *
  51883. * @param name The material name
  51884. * @param scene The scene the material will be use in.
  51885. */
  51886. constructor(name: string, scene: Scene);
  51887. /**
  51888. * Returns the name of this material class.
  51889. */
  51890. getClassName(): string;
  51891. /**
  51892. * Makes a duplicate of the current material.
  51893. * @param name - name to use for the new material.
  51894. */
  51895. clone(name: string): PBRMaterial;
  51896. /**
  51897. * Serializes this PBR Material.
  51898. * @returns - An object with the serialized material.
  51899. */
  51900. serialize(): any;
  51901. /**
  51902. * Parses a PBR Material from a serialized object.
  51903. * @param source - Serialized object.
  51904. * @param scene - BJS scene instance.
  51905. * @param rootUrl - url for the scene object
  51906. * @returns - PBRMaterial
  51907. */
  51908. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51909. }
  51910. }
  51911. declare module BABYLON {
  51912. /**
  51913. * Direct draw surface info
  51914. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51915. */
  51916. export interface DDSInfo {
  51917. /**
  51918. * Width of the texture
  51919. */
  51920. width: number;
  51921. /**
  51922. * Width of the texture
  51923. */
  51924. height: number;
  51925. /**
  51926. * Number of Mipmaps for the texture
  51927. * @see https://en.wikipedia.org/wiki/Mipmap
  51928. */
  51929. mipmapCount: number;
  51930. /**
  51931. * If the textures format is a known fourCC format
  51932. * @see https://www.fourcc.org/
  51933. */
  51934. isFourCC: boolean;
  51935. /**
  51936. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51937. */
  51938. isRGB: boolean;
  51939. /**
  51940. * If the texture is a lumincance format
  51941. */
  51942. isLuminance: boolean;
  51943. /**
  51944. * If this is a cube texture
  51945. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51946. */
  51947. isCube: boolean;
  51948. /**
  51949. * If the texture is a compressed format eg. FOURCC_DXT1
  51950. */
  51951. isCompressed: boolean;
  51952. /**
  51953. * The dxgiFormat of the texture
  51954. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51955. */
  51956. dxgiFormat: number;
  51957. /**
  51958. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51959. */
  51960. textureType: number;
  51961. /**
  51962. * Sphericle polynomial created for the dds texture
  51963. */
  51964. sphericalPolynomial?: SphericalPolynomial;
  51965. }
  51966. /**
  51967. * Class used to provide DDS decompression tools
  51968. */
  51969. export class DDSTools {
  51970. /**
  51971. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51972. */
  51973. static StoreLODInAlphaChannel: boolean;
  51974. /**
  51975. * Gets DDS information from an array buffer
  51976. * @param data defines the array buffer view to read data from
  51977. * @returns the DDS information
  51978. */
  51979. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  51980. private static _FloatView;
  51981. private static _Int32View;
  51982. private static _ToHalfFloat;
  51983. private static _FromHalfFloat;
  51984. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51985. private static _GetHalfFloatRGBAArrayBuffer;
  51986. private static _GetFloatRGBAArrayBuffer;
  51987. private static _GetFloatAsUIntRGBAArrayBuffer;
  51988. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51989. private static _GetRGBAArrayBuffer;
  51990. private static _ExtractLongWordOrder;
  51991. private static _GetRGBArrayBuffer;
  51992. private static _GetLuminanceArrayBuffer;
  51993. /**
  51994. * Uploads DDS Levels to a Babylon Texture
  51995. * @hidden
  51996. */
  51997. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51998. }
  51999. interface ThinEngine {
  52000. /**
  52001. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52002. * @param rootUrl defines the url where the file to load is located
  52003. * @param scene defines the current scene
  52004. * @param lodScale defines scale to apply to the mip map selection
  52005. * @param lodOffset defines offset to apply to the mip map selection
  52006. * @param onLoad defines an optional callback raised when the texture is loaded
  52007. * @param onError defines an optional callback raised if there is an issue to load the texture
  52008. * @param format defines the format of the data
  52009. * @param forcedExtension defines the extension to use to pick the right loader
  52010. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52011. * @returns the cube texture as an InternalTexture
  52012. */
  52013. 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;
  52014. }
  52015. }
  52016. declare module BABYLON {
  52017. /**
  52018. * Implementation of the DDS Texture Loader.
  52019. * @hidden
  52020. */
  52021. export class _DDSTextureLoader implements IInternalTextureLoader {
  52022. /**
  52023. * Defines wether the loader supports cascade loading the different faces.
  52024. */
  52025. readonly supportCascades: boolean;
  52026. /**
  52027. * This returns if the loader support the current file information.
  52028. * @param extension defines the file extension of the file being loaded
  52029. * @returns true if the loader can load the specified file
  52030. */
  52031. canLoad(extension: string): boolean;
  52032. /**
  52033. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52034. * @param data contains the texture data
  52035. * @param texture defines the BabylonJS internal texture
  52036. * @param createPolynomials will be true if polynomials have been requested
  52037. * @param onLoad defines the callback to trigger once the texture is ready
  52038. * @param onError defines the callback to trigger in case of error
  52039. */
  52040. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52041. /**
  52042. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52043. * @param data contains the texture data
  52044. * @param texture defines the BabylonJS internal texture
  52045. * @param callback defines the method to call once ready to upload
  52046. */
  52047. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52048. }
  52049. }
  52050. declare module BABYLON {
  52051. /**
  52052. * Implementation of the ENV Texture Loader.
  52053. * @hidden
  52054. */
  52055. export class _ENVTextureLoader implements IInternalTextureLoader {
  52056. /**
  52057. * Defines wether the loader supports cascade loading the different faces.
  52058. */
  52059. readonly supportCascades: boolean;
  52060. /**
  52061. * This returns if the loader support the current file information.
  52062. * @param extension defines the file extension of the file being loaded
  52063. * @returns true if the loader can load the specified file
  52064. */
  52065. canLoad(extension: string): boolean;
  52066. /**
  52067. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52068. * @param data contains the texture data
  52069. * @param texture defines the BabylonJS internal texture
  52070. * @param createPolynomials will be true if polynomials have been requested
  52071. * @param onLoad defines the callback to trigger once the texture is ready
  52072. * @param onError defines the callback to trigger in case of error
  52073. */
  52074. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52075. /**
  52076. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52077. * @param data contains the texture data
  52078. * @param texture defines the BabylonJS internal texture
  52079. * @param callback defines the method to call once ready to upload
  52080. */
  52081. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52082. }
  52083. }
  52084. declare module BABYLON {
  52085. /**
  52086. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52087. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52088. */
  52089. export class KhronosTextureContainer {
  52090. /** contents of the KTX container file */
  52091. data: ArrayBufferView;
  52092. private static HEADER_LEN;
  52093. private static COMPRESSED_2D;
  52094. private static COMPRESSED_3D;
  52095. private static TEX_2D;
  52096. private static TEX_3D;
  52097. /**
  52098. * Gets the openGL type
  52099. */
  52100. glType: number;
  52101. /**
  52102. * Gets the openGL type size
  52103. */
  52104. glTypeSize: number;
  52105. /**
  52106. * Gets the openGL format
  52107. */
  52108. glFormat: number;
  52109. /**
  52110. * Gets the openGL internal format
  52111. */
  52112. glInternalFormat: number;
  52113. /**
  52114. * Gets the base internal format
  52115. */
  52116. glBaseInternalFormat: number;
  52117. /**
  52118. * Gets image width in pixel
  52119. */
  52120. pixelWidth: number;
  52121. /**
  52122. * Gets image height in pixel
  52123. */
  52124. pixelHeight: number;
  52125. /**
  52126. * Gets image depth in pixels
  52127. */
  52128. pixelDepth: number;
  52129. /**
  52130. * Gets the number of array elements
  52131. */
  52132. numberOfArrayElements: number;
  52133. /**
  52134. * Gets the number of faces
  52135. */
  52136. numberOfFaces: number;
  52137. /**
  52138. * Gets the number of mipmap levels
  52139. */
  52140. numberOfMipmapLevels: number;
  52141. /**
  52142. * Gets the bytes of key value data
  52143. */
  52144. bytesOfKeyValueData: number;
  52145. /**
  52146. * Gets the load type
  52147. */
  52148. loadType: number;
  52149. /**
  52150. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52151. */
  52152. isInvalid: boolean;
  52153. /**
  52154. * Creates a new KhronosTextureContainer
  52155. * @param data contents of the KTX container file
  52156. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52157. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52158. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52159. */
  52160. constructor(
  52161. /** contents of the KTX container file */
  52162. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52163. /**
  52164. * Uploads KTX content to a Babylon Texture.
  52165. * It is assumed that the texture has already been created & is currently bound
  52166. * @hidden
  52167. */
  52168. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52169. private _upload2DCompressedLevels;
  52170. /**
  52171. * Checks if the given data starts with a KTX file identifier.
  52172. * @param data the data to check
  52173. * @returns true if the data is a KTX file or false otherwise
  52174. */
  52175. static IsValid(data: ArrayBufferView): boolean;
  52176. }
  52177. }
  52178. declare module BABYLON {
  52179. /**
  52180. * Class for loading KTX2 files
  52181. * !!! Experimental Extension Subject to Changes !!!
  52182. * @hidden
  52183. */
  52184. export class KhronosTextureContainer2 {
  52185. private static _ModulePromise;
  52186. private static _TranscodeFormat;
  52187. constructor(engine: ThinEngine);
  52188. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52189. private _determineTranscodeFormat;
  52190. /**
  52191. * Checks if the given data starts with a KTX2 file identifier.
  52192. * @param data the data to check
  52193. * @returns true if the data is a KTX2 file or false otherwise
  52194. */
  52195. static IsValid(data: ArrayBufferView): boolean;
  52196. }
  52197. }
  52198. declare module BABYLON {
  52199. /**
  52200. * Implementation of the KTX Texture Loader.
  52201. * @hidden
  52202. */
  52203. export class _KTXTextureLoader implements IInternalTextureLoader {
  52204. /**
  52205. * Defines wether the loader supports cascade loading the different faces.
  52206. */
  52207. readonly supportCascades: boolean;
  52208. /**
  52209. * This returns if the loader support the current file information.
  52210. * @param extension defines the file extension of the file being loaded
  52211. * @returns true if the loader can load the specified file
  52212. */
  52213. canLoad(extension: string): boolean;
  52214. /**
  52215. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52216. * @param data contains the texture data
  52217. * @param texture defines the BabylonJS internal texture
  52218. * @param createPolynomials will be true if polynomials have been requested
  52219. * @param onLoad defines the callback to trigger once the texture is ready
  52220. * @param onError defines the callback to trigger in case of error
  52221. */
  52222. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52223. /**
  52224. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52225. * @param data contains the texture data
  52226. * @param texture defines the BabylonJS internal texture
  52227. * @param callback defines the method to call once ready to upload
  52228. */
  52229. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52230. }
  52231. }
  52232. declare module BABYLON {
  52233. /** @hidden */
  52234. export var _forceSceneHelpersToBundle: boolean;
  52235. interface Scene {
  52236. /**
  52237. * Creates a default light for the scene.
  52238. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52239. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52240. */
  52241. createDefaultLight(replace?: boolean): void;
  52242. /**
  52243. * Creates a default camera for the scene.
  52244. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52245. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52246. * @param replace has default false, when true replaces the active camera in the scene
  52247. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52248. */
  52249. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52250. /**
  52251. * Creates a default camera and a default light.
  52252. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52253. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52254. * @param replace has the default false, when true replaces the active camera/light in the scene
  52255. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52256. */
  52257. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52258. /**
  52259. * Creates a new sky box
  52260. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52261. * @param environmentTexture defines the texture to use as environment texture
  52262. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52263. * @param scale defines the overall scale of the skybox
  52264. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52265. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52266. * @returns a new mesh holding the sky box
  52267. */
  52268. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52269. /**
  52270. * Creates a new environment
  52271. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52272. * @param options defines the options you can use to configure the environment
  52273. * @returns the new EnvironmentHelper
  52274. */
  52275. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52276. /**
  52277. * Creates a new VREXperienceHelper
  52278. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52279. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52280. * @returns a new VREXperienceHelper
  52281. */
  52282. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52283. /**
  52284. * Creates a new WebXRDefaultExperience
  52285. * @see http://doc.babylonjs.com/how_to/webxr
  52286. * @param options experience options
  52287. * @returns a promise for a new WebXRDefaultExperience
  52288. */
  52289. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52290. }
  52291. }
  52292. declare module BABYLON {
  52293. /**
  52294. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52295. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52296. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52297. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52298. */
  52299. export class VideoDome extends TransformNode {
  52300. /**
  52301. * Define the video source as a Monoscopic panoramic 360 video.
  52302. */
  52303. static readonly MODE_MONOSCOPIC: number;
  52304. /**
  52305. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52306. */
  52307. static readonly MODE_TOPBOTTOM: number;
  52308. /**
  52309. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52310. */
  52311. static readonly MODE_SIDEBYSIDE: number;
  52312. private _halfDome;
  52313. private _useDirectMapping;
  52314. /**
  52315. * The video texture being displayed on the sphere
  52316. */
  52317. protected _videoTexture: VideoTexture;
  52318. /**
  52319. * Gets the video texture being displayed on the sphere
  52320. */
  52321. get videoTexture(): VideoTexture;
  52322. /**
  52323. * The skybox material
  52324. */
  52325. protected _material: BackgroundMaterial;
  52326. /**
  52327. * The surface used for the skybox
  52328. */
  52329. protected _mesh: Mesh;
  52330. /**
  52331. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52332. */
  52333. private _halfDomeMask;
  52334. /**
  52335. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52336. * Also see the options.resolution property.
  52337. */
  52338. get fovMultiplier(): number;
  52339. set fovMultiplier(value: number);
  52340. private _videoMode;
  52341. /**
  52342. * Gets or set the current video mode for the video. It can be:
  52343. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52344. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52345. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52346. */
  52347. get videoMode(): number;
  52348. set videoMode(value: number);
  52349. /**
  52350. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52351. *
  52352. */
  52353. get halfDome(): boolean;
  52354. /**
  52355. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52356. */
  52357. set halfDome(enabled: boolean);
  52358. /**
  52359. * Oberserver used in Stereoscopic VR Mode.
  52360. */
  52361. private _onBeforeCameraRenderObserver;
  52362. /**
  52363. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52364. * @param name Element's name, child elements will append suffixes for their own names.
  52365. * @param urlsOrVideo defines the url(s) or the video element to use
  52366. * @param options An object containing optional or exposed sub element properties
  52367. */
  52368. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52369. resolution?: number;
  52370. clickToPlay?: boolean;
  52371. autoPlay?: boolean;
  52372. loop?: boolean;
  52373. size?: number;
  52374. poster?: string;
  52375. faceForward?: boolean;
  52376. useDirectMapping?: boolean;
  52377. halfDomeMode?: boolean;
  52378. }, scene: Scene);
  52379. private _changeVideoMode;
  52380. /**
  52381. * Releases resources associated with this node.
  52382. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52383. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52384. */
  52385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52386. }
  52387. }
  52388. declare module BABYLON {
  52389. /**
  52390. * This class can be used to get instrumentation data from a Babylon engine
  52391. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52392. */
  52393. export class EngineInstrumentation implements IDisposable {
  52394. /**
  52395. * Define the instrumented engine.
  52396. */
  52397. engine: Engine;
  52398. private _captureGPUFrameTime;
  52399. private _gpuFrameTimeToken;
  52400. private _gpuFrameTime;
  52401. private _captureShaderCompilationTime;
  52402. private _shaderCompilationTime;
  52403. private _onBeginFrameObserver;
  52404. private _onEndFrameObserver;
  52405. private _onBeforeShaderCompilationObserver;
  52406. private _onAfterShaderCompilationObserver;
  52407. /**
  52408. * Gets the perf counter used for GPU frame time
  52409. */
  52410. get gpuFrameTimeCounter(): PerfCounter;
  52411. /**
  52412. * Gets the GPU frame time capture status
  52413. */
  52414. get captureGPUFrameTime(): boolean;
  52415. /**
  52416. * Enable or disable the GPU frame time capture
  52417. */
  52418. set captureGPUFrameTime(value: boolean);
  52419. /**
  52420. * Gets the perf counter used for shader compilation time
  52421. */
  52422. get shaderCompilationTimeCounter(): PerfCounter;
  52423. /**
  52424. * Gets the shader compilation time capture status
  52425. */
  52426. get captureShaderCompilationTime(): boolean;
  52427. /**
  52428. * Enable or disable the shader compilation time capture
  52429. */
  52430. set captureShaderCompilationTime(value: boolean);
  52431. /**
  52432. * Instantiates a new engine instrumentation.
  52433. * This class can be used to get instrumentation data from a Babylon engine
  52434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52435. * @param engine Defines the engine to instrument
  52436. */
  52437. constructor(
  52438. /**
  52439. * Define the instrumented engine.
  52440. */
  52441. engine: Engine);
  52442. /**
  52443. * Dispose and release associated resources.
  52444. */
  52445. dispose(): void;
  52446. }
  52447. }
  52448. declare module BABYLON {
  52449. /**
  52450. * This class can be used to get instrumentation data from a Babylon engine
  52451. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52452. */
  52453. export class SceneInstrumentation implements IDisposable {
  52454. /**
  52455. * Defines the scene to instrument
  52456. */
  52457. scene: Scene;
  52458. private _captureActiveMeshesEvaluationTime;
  52459. private _activeMeshesEvaluationTime;
  52460. private _captureRenderTargetsRenderTime;
  52461. private _renderTargetsRenderTime;
  52462. private _captureFrameTime;
  52463. private _frameTime;
  52464. private _captureRenderTime;
  52465. private _renderTime;
  52466. private _captureInterFrameTime;
  52467. private _interFrameTime;
  52468. private _captureParticlesRenderTime;
  52469. private _particlesRenderTime;
  52470. private _captureSpritesRenderTime;
  52471. private _spritesRenderTime;
  52472. private _capturePhysicsTime;
  52473. private _physicsTime;
  52474. private _captureAnimationsTime;
  52475. private _animationsTime;
  52476. private _captureCameraRenderTime;
  52477. private _cameraRenderTime;
  52478. private _onBeforeActiveMeshesEvaluationObserver;
  52479. private _onAfterActiveMeshesEvaluationObserver;
  52480. private _onBeforeRenderTargetsRenderObserver;
  52481. private _onAfterRenderTargetsRenderObserver;
  52482. private _onAfterRenderObserver;
  52483. private _onBeforeDrawPhaseObserver;
  52484. private _onAfterDrawPhaseObserver;
  52485. private _onBeforeAnimationsObserver;
  52486. private _onBeforeParticlesRenderingObserver;
  52487. private _onAfterParticlesRenderingObserver;
  52488. private _onBeforeSpritesRenderingObserver;
  52489. private _onAfterSpritesRenderingObserver;
  52490. private _onBeforePhysicsObserver;
  52491. private _onAfterPhysicsObserver;
  52492. private _onAfterAnimationsObserver;
  52493. private _onBeforeCameraRenderObserver;
  52494. private _onAfterCameraRenderObserver;
  52495. /**
  52496. * Gets the perf counter used for active meshes evaluation time
  52497. */
  52498. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52499. /**
  52500. * Gets the active meshes evaluation time capture status
  52501. */
  52502. get captureActiveMeshesEvaluationTime(): boolean;
  52503. /**
  52504. * Enable or disable the active meshes evaluation time capture
  52505. */
  52506. set captureActiveMeshesEvaluationTime(value: boolean);
  52507. /**
  52508. * Gets the perf counter used for render targets render time
  52509. */
  52510. get renderTargetsRenderTimeCounter(): PerfCounter;
  52511. /**
  52512. * Gets the render targets render time capture status
  52513. */
  52514. get captureRenderTargetsRenderTime(): boolean;
  52515. /**
  52516. * Enable or disable the render targets render time capture
  52517. */
  52518. set captureRenderTargetsRenderTime(value: boolean);
  52519. /**
  52520. * Gets the perf counter used for particles render time
  52521. */
  52522. get particlesRenderTimeCounter(): PerfCounter;
  52523. /**
  52524. * Gets the particles render time capture status
  52525. */
  52526. get captureParticlesRenderTime(): boolean;
  52527. /**
  52528. * Enable or disable the particles render time capture
  52529. */
  52530. set captureParticlesRenderTime(value: boolean);
  52531. /**
  52532. * Gets the perf counter used for sprites render time
  52533. */
  52534. get spritesRenderTimeCounter(): PerfCounter;
  52535. /**
  52536. * Gets the sprites render time capture status
  52537. */
  52538. get captureSpritesRenderTime(): boolean;
  52539. /**
  52540. * Enable or disable the sprites render time capture
  52541. */
  52542. set captureSpritesRenderTime(value: boolean);
  52543. /**
  52544. * Gets the perf counter used for physics time
  52545. */
  52546. get physicsTimeCounter(): PerfCounter;
  52547. /**
  52548. * Gets the physics time capture status
  52549. */
  52550. get capturePhysicsTime(): boolean;
  52551. /**
  52552. * Enable or disable the physics time capture
  52553. */
  52554. set capturePhysicsTime(value: boolean);
  52555. /**
  52556. * Gets the perf counter used for animations time
  52557. */
  52558. get animationsTimeCounter(): PerfCounter;
  52559. /**
  52560. * Gets the animations time capture status
  52561. */
  52562. get captureAnimationsTime(): boolean;
  52563. /**
  52564. * Enable or disable the animations time capture
  52565. */
  52566. set captureAnimationsTime(value: boolean);
  52567. /**
  52568. * Gets the perf counter used for frame time capture
  52569. */
  52570. get frameTimeCounter(): PerfCounter;
  52571. /**
  52572. * Gets the frame time capture status
  52573. */
  52574. get captureFrameTime(): boolean;
  52575. /**
  52576. * Enable or disable the frame time capture
  52577. */
  52578. set captureFrameTime(value: boolean);
  52579. /**
  52580. * Gets the perf counter used for inter-frames time capture
  52581. */
  52582. get interFrameTimeCounter(): PerfCounter;
  52583. /**
  52584. * Gets the inter-frames time capture status
  52585. */
  52586. get captureInterFrameTime(): boolean;
  52587. /**
  52588. * Enable or disable the inter-frames time capture
  52589. */
  52590. set captureInterFrameTime(value: boolean);
  52591. /**
  52592. * Gets the perf counter used for render time capture
  52593. */
  52594. get renderTimeCounter(): PerfCounter;
  52595. /**
  52596. * Gets the render time capture status
  52597. */
  52598. get captureRenderTime(): boolean;
  52599. /**
  52600. * Enable or disable the render time capture
  52601. */
  52602. set captureRenderTime(value: boolean);
  52603. /**
  52604. * Gets the perf counter used for camera render time capture
  52605. */
  52606. get cameraRenderTimeCounter(): PerfCounter;
  52607. /**
  52608. * Gets the camera render time capture status
  52609. */
  52610. get captureCameraRenderTime(): boolean;
  52611. /**
  52612. * Enable or disable the camera render time capture
  52613. */
  52614. set captureCameraRenderTime(value: boolean);
  52615. /**
  52616. * Gets the perf counter used for draw calls
  52617. */
  52618. get drawCallsCounter(): PerfCounter;
  52619. /**
  52620. * Instantiates a new scene instrumentation.
  52621. * This class can be used to get instrumentation data from a Babylon engine
  52622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52623. * @param scene Defines the scene to instrument
  52624. */
  52625. constructor(
  52626. /**
  52627. * Defines the scene to instrument
  52628. */
  52629. scene: Scene);
  52630. /**
  52631. * Dispose and release associated resources.
  52632. */
  52633. dispose(): void;
  52634. }
  52635. }
  52636. declare module BABYLON {
  52637. /** @hidden */
  52638. export var glowMapGenerationPixelShader: {
  52639. name: string;
  52640. shader: string;
  52641. };
  52642. }
  52643. declare module BABYLON {
  52644. /** @hidden */
  52645. export var glowMapGenerationVertexShader: {
  52646. name: string;
  52647. shader: string;
  52648. };
  52649. }
  52650. declare module BABYLON {
  52651. /**
  52652. * Effect layer options. This helps customizing the behaviour
  52653. * of the effect layer.
  52654. */
  52655. export interface IEffectLayerOptions {
  52656. /**
  52657. * Multiplication factor apply to the canvas size to compute the render target size
  52658. * used to generated the objects (the smaller the faster).
  52659. */
  52660. mainTextureRatio: number;
  52661. /**
  52662. * Enforces a fixed size texture to ensure effect stability across devices.
  52663. */
  52664. mainTextureFixedSize?: number;
  52665. /**
  52666. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52667. */
  52668. alphaBlendingMode: number;
  52669. /**
  52670. * The camera attached to the layer.
  52671. */
  52672. camera: Nullable<Camera>;
  52673. /**
  52674. * The rendering group to draw the layer in.
  52675. */
  52676. renderingGroupId: number;
  52677. }
  52678. /**
  52679. * The effect layer Helps adding post process effect blended with the main pass.
  52680. *
  52681. * This can be for instance use to generate glow or higlight effects on the scene.
  52682. *
  52683. * The effect layer class can not be used directly and is intented to inherited from to be
  52684. * customized per effects.
  52685. */
  52686. export abstract class EffectLayer {
  52687. private _vertexBuffers;
  52688. private _indexBuffer;
  52689. private _cachedDefines;
  52690. private _effectLayerMapGenerationEffect;
  52691. private _effectLayerOptions;
  52692. private _mergeEffect;
  52693. protected _scene: Scene;
  52694. protected _engine: Engine;
  52695. protected _maxSize: number;
  52696. protected _mainTextureDesiredSize: ISize;
  52697. protected _mainTexture: RenderTargetTexture;
  52698. protected _shouldRender: boolean;
  52699. protected _postProcesses: PostProcess[];
  52700. protected _textures: BaseTexture[];
  52701. protected _emissiveTextureAndColor: {
  52702. texture: Nullable<BaseTexture>;
  52703. color: Color4;
  52704. };
  52705. /**
  52706. * The name of the layer
  52707. */
  52708. name: string;
  52709. /**
  52710. * The clear color of the texture used to generate the glow map.
  52711. */
  52712. neutralColor: Color4;
  52713. /**
  52714. * Specifies whether the highlight layer is enabled or not.
  52715. */
  52716. isEnabled: boolean;
  52717. /**
  52718. * Gets the camera attached to the layer.
  52719. */
  52720. get camera(): Nullable<Camera>;
  52721. /**
  52722. * Gets the rendering group id the layer should render in.
  52723. */
  52724. get renderingGroupId(): number;
  52725. set renderingGroupId(renderingGroupId: number);
  52726. /**
  52727. * An event triggered when the effect layer has been disposed.
  52728. */
  52729. onDisposeObservable: Observable<EffectLayer>;
  52730. /**
  52731. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52732. */
  52733. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52734. /**
  52735. * An event triggered when the generated texture is being merged in the scene.
  52736. */
  52737. onBeforeComposeObservable: Observable<EffectLayer>;
  52738. /**
  52739. * An event triggered when the mesh is rendered into the effect render target.
  52740. */
  52741. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52742. /**
  52743. * An event triggered after the mesh has been rendered into the effect render target.
  52744. */
  52745. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52746. /**
  52747. * An event triggered when the generated texture has been merged in the scene.
  52748. */
  52749. onAfterComposeObservable: Observable<EffectLayer>;
  52750. /**
  52751. * An event triggered when the efffect layer changes its size.
  52752. */
  52753. onSizeChangedObservable: Observable<EffectLayer>;
  52754. /** @hidden */
  52755. static _SceneComponentInitialization: (scene: Scene) => void;
  52756. /**
  52757. * Instantiates a new effect Layer and references it in the scene.
  52758. * @param name The name of the layer
  52759. * @param scene The scene to use the layer in
  52760. */
  52761. constructor(
  52762. /** The Friendly of the effect in the scene */
  52763. name: string, scene: Scene);
  52764. /**
  52765. * Get the effect name of the layer.
  52766. * @return The effect name
  52767. */
  52768. abstract getEffectName(): string;
  52769. /**
  52770. * Checks for the readiness of the element composing the layer.
  52771. * @param subMesh the mesh to check for
  52772. * @param useInstances specify whether or not to use instances to render the mesh
  52773. * @return true if ready otherwise, false
  52774. */
  52775. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52776. /**
  52777. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52778. * @returns true if the effect requires stencil during the main canvas render pass.
  52779. */
  52780. abstract needStencil(): boolean;
  52781. /**
  52782. * Create the merge effect. This is the shader use to blit the information back
  52783. * to the main canvas at the end of the scene rendering.
  52784. * @returns The effect containing the shader used to merge the effect on the main canvas
  52785. */
  52786. protected abstract _createMergeEffect(): Effect;
  52787. /**
  52788. * Creates the render target textures and post processes used in the effect layer.
  52789. */
  52790. protected abstract _createTextureAndPostProcesses(): void;
  52791. /**
  52792. * Implementation specific of rendering the generating effect on the main canvas.
  52793. * @param effect The effect used to render through
  52794. */
  52795. protected abstract _internalRender(effect: Effect): void;
  52796. /**
  52797. * Sets the required values for both the emissive texture and and the main color.
  52798. */
  52799. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52800. /**
  52801. * Free any resources and references associated to a mesh.
  52802. * Internal use
  52803. * @param mesh The mesh to free.
  52804. */
  52805. abstract _disposeMesh(mesh: Mesh): void;
  52806. /**
  52807. * Serializes this layer (Glow or Highlight for example)
  52808. * @returns a serialized layer object
  52809. */
  52810. abstract serialize?(): any;
  52811. /**
  52812. * Initializes the effect layer with the required options.
  52813. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52814. */
  52815. protected _init(options: Partial<IEffectLayerOptions>): void;
  52816. /**
  52817. * Generates the index buffer of the full screen quad blending to the main canvas.
  52818. */
  52819. private _generateIndexBuffer;
  52820. /**
  52821. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52822. */
  52823. private _generateVertexBuffer;
  52824. /**
  52825. * Sets the main texture desired size which is the closest power of two
  52826. * of the engine canvas size.
  52827. */
  52828. private _setMainTextureSize;
  52829. /**
  52830. * Creates the main texture for the effect layer.
  52831. */
  52832. protected _createMainTexture(): void;
  52833. /**
  52834. * Adds specific effects defines.
  52835. * @param defines The defines to add specifics to.
  52836. */
  52837. protected _addCustomEffectDefines(defines: string[]): void;
  52838. /**
  52839. * Checks for the readiness of the element composing the layer.
  52840. * @param subMesh the mesh to check for
  52841. * @param useInstances specify whether or not to use instances to render the mesh
  52842. * @param emissiveTexture the associated emissive texture used to generate the glow
  52843. * @return true if ready otherwise, false
  52844. */
  52845. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52846. /**
  52847. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52848. */
  52849. render(): void;
  52850. /**
  52851. * Determine if a given mesh will be used in the current effect.
  52852. * @param mesh mesh to test
  52853. * @returns true if the mesh will be used
  52854. */
  52855. hasMesh(mesh: AbstractMesh): boolean;
  52856. /**
  52857. * Returns true if the layer contains information to display, otherwise false.
  52858. * @returns true if the glow layer should be rendered
  52859. */
  52860. shouldRender(): boolean;
  52861. /**
  52862. * Returns true if the mesh should render, otherwise false.
  52863. * @param mesh The mesh to render
  52864. * @returns true if it should render otherwise false
  52865. */
  52866. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52867. /**
  52868. * Returns true if the mesh can be rendered, otherwise false.
  52869. * @param mesh The mesh to render
  52870. * @param material The material used on the mesh
  52871. * @returns true if it can be rendered otherwise false
  52872. */
  52873. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52874. /**
  52875. * Returns true if the mesh should render, otherwise false.
  52876. * @param mesh The mesh to render
  52877. * @returns true if it should render otherwise false
  52878. */
  52879. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52880. /**
  52881. * Renders the submesh passed in parameter to the generation map.
  52882. */
  52883. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52884. /**
  52885. * Defines whether the current material of the mesh should be use to render the effect.
  52886. * @param mesh defines the current mesh to render
  52887. */
  52888. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52889. /**
  52890. * Rebuild the required buffers.
  52891. * @hidden Internal use only.
  52892. */
  52893. _rebuild(): void;
  52894. /**
  52895. * Dispose only the render target textures and post process.
  52896. */
  52897. private _disposeTextureAndPostProcesses;
  52898. /**
  52899. * Dispose the highlight layer and free resources.
  52900. */
  52901. dispose(): void;
  52902. /**
  52903. * Gets the class name of the effect layer
  52904. * @returns the string with the class name of the effect layer
  52905. */
  52906. getClassName(): string;
  52907. /**
  52908. * Creates an effect layer from parsed effect layer data
  52909. * @param parsedEffectLayer defines effect layer data
  52910. * @param scene defines the current scene
  52911. * @param rootUrl defines the root URL containing the effect layer information
  52912. * @returns a parsed effect Layer
  52913. */
  52914. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52915. }
  52916. }
  52917. declare module BABYLON {
  52918. interface AbstractScene {
  52919. /**
  52920. * The list of effect layers (highlights/glow) added to the scene
  52921. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52922. * @see http://doc.babylonjs.com/how_to/glow_layer
  52923. */
  52924. effectLayers: Array<EffectLayer>;
  52925. /**
  52926. * Removes the given effect layer from this scene.
  52927. * @param toRemove defines the effect layer to remove
  52928. * @returns the index of the removed effect layer
  52929. */
  52930. removeEffectLayer(toRemove: EffectLayer): number;
  52931. /**
  52932. * Adds the given effect layer to this scene
  52933. * @param newEffectLayer defines the effect layer to add
  52934. */
  52935. addEffectLayer(newEffectLayer: EffectLayer): void;
  52936. }
  52937. /**
  52938. * Defines the layer scene component responsible to manage any effect layers
  52939. * in a given scene.
  52940. */
  52941. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52942. /**
  52943. * The component name helpfull to identify the component in the list of scene components.
  52944. */
  52945. readonly name: string;
  52946. /**
  52947. * The scene the component belongs to.
  52948. */
  52949. scene: Scene;
  52950. private _engine;
  52951. private _renderEffects;
  52952. private _needStencil;
  52953. private _previousStencilState;
  52954. /**
  52955. * Creates a new instance of the component for the given scene
  52956. * @param scene Defines the scene to register the component in
  52957. */
  52958. constructor(scene: Scene);
  52959. /**
  52960. * Registers the component in a given scene
  52961. */
  52962. register(): void;
  52963. /**
  52964. * Rebuilds the elements related to this component in case of
  52965. * context lost for instance.
  52966. */
  52967. rebuild(): void;
  52968. /**
  52969. * Serializes the component data to the specified json object
  52970. * @param serializationObject The object to serialize to
  52971. */
  52972. serialize(serializationObject: any): void;
  52973. /**
  52974. * Adds all the elements from the container to the scene
  52975. * @param container the container holding the elements
  52976. */
  52977. addFromContainer(container: AbstractScene): void;
  52978. /**
  52979. * Removes all the elements in the container from the scene
  52980. * @param container contains the elements to remove
  52981. * @param dispose if the removed element should be disposed (default: false)
  52982. */
  52983. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52984. /**
  52985. * Disposes the component and the associated ressources.
  52986. */
  52987. dispose(): void;
  52988. private _isReadyForMesh;
  52989. private _renderMainTexture;
  52990. private _setStencil;
  52991. private _setStencilBack;
  52992. private _draw;
  52993. private _drawCamera;
  52994. private _drawRenderingGroup;
  52995. }
  52996. }
  52997. declare module BABYLON {
  52998. /** @hidden */
  52999. export var glowMapMergePixelShader: {
  53000. name: string;
  53001. shader: string;
  53002. };
  53003. }
  53004. declare module BABYLON {
  53005. /** @hidden */
  53006. export var glowMapMergeVertexShader: {
  53007. name: string;
  53008. shader: string;
  53009. };
  53010. }
  53011. declare module BABYLON {
  53012. interface AbstractScene {
  53013. /**
  53014. * Return a the first highlight layer of the scene with a given name.
  53015. * @param name The name of the highlight layer to look for.
  53016. * @return The highlight layer if found otherwise null.
  53017. */
  53018. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53019. }
  53020. /**
  53021. * Glow layer options. This helps customizing the behaviour
  53022. * of the glow layer.
  53023. */
  53024. export interface IGlowLayerOptions {
  53025. /**
  53026. * Multiplication factor apply to the canvas size to compute the render target size
  53027. * used to generated the glowing objects (the smaller the faster).
  53028. */
  53029. mainTextureRatio: number;
  53030. /**
  53031. * Enforces a fixed size texture to ensure resize independant blur.
  53032. */
  53033. mainTextureFixedSize?: number;
  53034. /**
  53035. * How big is the kernel of the blur texture.
  53036. */
  53037. blurKernelSize: number;
  53038. /**
  53039. * The camera attached to the layer.
  53040. */
  53041. camera: Nullable<Camera>;
  53042. /**
  53043. * Enable MSAA by chosing the number of samples.
  53044. */
  53045. mainTextureSamples?: number;
  53046. /**
  53047. * The rendering group to draw the layer in.
  53048. */
  53049. renderingGroupId: number;
  53050. }
  53051. /**
  53052. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53053. *
  53054. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53055. *
  53056. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53057. */
  53058. export class GlowLayer extends EffectLayer {
  53059. /**
  53060. * Effect Name of the layer.
  53061. */
  53062. static readonly EffectName: string;
  53063. /**
  53064. * The default blur kernel size used for the glow.
  53065. */
  53066. static DefaultBlurKernelSize: number;
  53067. /**
  53068. * The default texture size ratio used for the glow.
  53069. */
  53070. static DefaultTextureRatio: number;
  53071. /**
  53072. * Sets the kernel size of the blur.
  53073. */
  53074. set blurKernelSize(value: number);
  53075. /**
  53076. * Gets the kernel size of the blur.
  53077. */
  53078. get blurKernelSize(): number;
  53079. /**
  53080. * Sets the glow intensity.
  53081. */
  53082. set intensity(value: number);
  53083. /**
  53084. * Gets the glow intensity.
  53085. */
  53086. get intensity(): number;
  53087. private _options;
  53088. private _intensity;
  53089. private _horizontalBlurPostprocess1;
  53090. private _verticalBlurPostprocess1;
  53091. private _horizontalBlurPostprocess2;
  53092. private _verticalBlurPostprocess2;
  53093. private _blurTexture1;
  53094. private _blurTexture2;
  53095. private _postProcesses1;
  53096. private _postProcesses2;
  53097. private _includedOnlyMeshes;
  53098. private _excludedMeshes;
  53099. private _meshesUsingTheirOwnMaterials;
  53100. /**
  53101. * Callback used to let the user override the color selection on a per mesh basis
  53102. */
  53103. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53104. /**
  53105. * Callback used to let the user override the texture selection on a per mesh basis
  53106. */
  53107. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53108. /**
  53109. * Instantiates a new glow Layer and references it to the scene.
  53110. * @param name The name of the layer
  53111. * @param scene The scene to use the layer in
  53112. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53113. */
  53114. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53115. /**
  53116. * Get the effect name of the layer.
  53117. * @return The effect name
  53118. */
  53119. getEffectName(): string;
  53120. /**
  53121. * Create the merge effect. This is the shader use to blit the information back
  53122. * to the main canvas at the end of the scene rendering.
  53123. */
  53124. protected _createMergeEffect(): Effect;
  53125. /**
  53126. * Creates the render target textures and post processes used in the glow layer.
  53127. */
  53128. protected _createTextureAndPostProcesses(): void;
  53129. /**
  53130. * Checks for the readiness of the element composing the layer.
  53131. * @param subMesh the mesh to check for
  53132. * @param useInstances specify wether or not to use instances to render the mesh
  53133. * @param emissiveTexture the associated emissive texture used to generate the glow
  53134. * @return true if ready otherwise, false
  53135. */
  53136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53137. /**
  53138. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53139. */
  53140. needStencil(): boolean;
  53141. /**
  53142. * Returns true if the mesh can be rendered, otherwise false.
  53143. * @param mesh The mesh to render
  53144. * @param material The material used on the mesh
  53145. * @returns true if it can be rendered otherwise false
  53146. */
  53147. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53148. /**
  53149. * Implementation specific of rendering the generating effect on the main canvas.
  53150. * @param effect The effect used to render through
  53151. */
  53152. protected _internalRender(effect: Effect): void;
  53153. /**
  53154. * Sets the required values for both the emissive texture and and the main color.
  53155. */
  53156. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53157. /**
  53158. * Returns true if the mesh should render, otherwise false.
  53159. * @param mesh The mesh to render
  53160. * @returns true if it should render otherwise false
  53161. */
  53162. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53163. /**
  53164. * Adds specific effects defines.
  53165. * @param defines The defines to add specifics to.
  53166. */
  53167. protected _addCustomEffectDefines(defines: string[]): void;
  53168. /**
  53169. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53170. * @param mesh The mesh to exclude from the glow layer
  53171. */
  53172. addExcludedMesh(mesh: Mesh): void;
  53173. /**
  53174. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53175. * @param mesh The mesh to remove
  53176. */
  53177. removeExcludedMesh(mesh: Mesh): void;
  53178. /**
  53179. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53180. * @param mesh The mesh to include in the glow layer
  53181. */
  53182. addIncludedOnlyMesh(mesh: Mesh): void;
  53183. /**
  53184. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53185. * @param mesh The mesh to remove
  53186. */
  53187. removeIncludedOnlyMesh(mesh: Mesh): void;
  53188. /**
  53189. * Determine if a given mesh will be used in the glow layer
  53190. * @param mesh The mesh to test
  53191. * @returns true if the mesh will be highlighted by the current glow layer
  53192. */
  53193. hasMesh(mesh: AbstractMesh): boolean;
  53194. /**
  53195. * Defines whether the current material of the mesh should be use to render the effect.
  53196. * @param mesh defines the current mesh to render
  53197. */
  53198. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53199. /**
  53200. * Add a mesh to be rendered through its own material and not with emissive only.
  53201. * @param mesh The mesh for which we need to use its material
  53202. */
  53203. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53204. /**
  53205. * Remove a mesh from being rendered through its own material and not with emissive only.
  53206. * @param mesh The mesh for which we need to not use its material
  53207. */
  53208. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53209. /**
  53210. * Free any resources and references associated to a mesh.
  53211. * Internal use
  53212. * @param mesh The mesh to free.
  53213. * @hidden
  53214. */
  53215. _disposeMesh(mesh: Mesh): void;
  53216. /**
  53217. * Gets the class name of the effect layer
  53218. * @returns the string with the class name of the effect layer
  53219. */
  53220. getClassName(): string;
  53221. /**
  53222. * Serializes this glow layer
  53223. * @returns a serialized glow layer object
  53224. */
  53225. serialize(): any;
  53226. /**
  53227. * Creates a Glow Layer from parsed glow layer data
  53228. * @param parsedGlowLayer defines glow layer data
  53229. * @param scene defines the current scene
  53230. * @param rootUrl defines the root URL containing the glow layer information
  53231. * @returns a parsed Glow Layer
  53232. */
  53233. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53234. }
  53235. }
  53236. declare module BABYLON {
  53237. /** @hidden */
  53238. export var glowBlurPostProcessPixelShader: {
  53239. name: string;
  53240. shader: string;
  53241. };
  53242. }
  53243. declare module BABYLON {
  53244. interface AbstractScene {
  53245. /**
  53246. * Return a the first highlight layer of the scene with a given name.
  53247. * @param name The name of the highlight layer to look for.
  53248. * @return The highlight layer if found otherwise null.
  53249. */
  53250. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53251. }
  53252. /**
  53253. * Highlight layer options. This helps customizing the behaviour
  53254. * of the highlight layer.
  53255. */
  53256. export interface IHighlightLayerOptions {
  53257. /**
  53258. * Multiplication factor apply to the canvas size to compute the render target size
  53259. * used to generated the glowing objects (the smaller the faster).
  53260. */
  53261. mainTextureRatio: number;
  53262. /**
  53263. * Enforces a fixed size texture to ensure resize independant blur.
  53264. */
  53265. mainTextureFixedSize?: number;
  53266. /**
  53267. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53268. * of the picture to blur (the smaller the faster).
  53269. */
  53270. blurTextureSizeRatio: number;
  53271. /**
  53272. * How big in texel of the blur texture is the vertical blur.
  53273. */
  53274. blurVerticalSize: number;
  53275. /**
  53276. * How big in texel of the blur texture is the horizontal blur.
  53277. */
  53278. blurHorizontalSize: number;
  53279. /**
  53280. * Alpha blending mode used to apply the blur. Default is combine.
  53281. */
  53282. alphaBlendingMode: number;
  53283. /**
  53284. * The camera attached to the layer.
  53285. */
  53286. camera: Nullable<Camera>;
  53287. /**
  53288. * Should we display highlight as a solid stroke?
  53289. */
  53290. isStroke?: boolean;
  53291. /**
  53292. * The rendering group to draw the layer in.
  53293. */
  53294. renderingGroupId: number;
  53295. }
  53296. /**
  53297. * The highlight layer Helps adding a glow effect around a mesh.
  53298. *
  53299. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53300. * glowy meshes to your scene.
  53301. *
  53302. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53303. */
  53304. export class HighlightLayer extends EffectLayer {
  53305. name: string;
  53306. /**
  53307. * Effect Name of the highlight layer.
  53308. */
  53309. static readonly EffectName: string;
  53310. /**
  53311. * The neutral color used during the preparation of the glow effect.
  53312. * This is black by default as the blend operation is a blend operation.
  53313. */
  53314. static NeutralColor: Color4;
  53315. /**
  53316. * Stencil value used for glowing meshes.
  53317. */
  53318. static GlowingMeshStencilReference: number;
  53319. /**
  53320. * Stencil value used for the other meshes in the scene.
  53321. */
  53322. static NormalMeshStencilReference: number;
  53323. /**
  53324. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53325. */
  53326. innerGlow: boolean;
  53327. /**
  53328. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53329. */
  53330. outerGlow: boolean;
  53331. /**
  53332. * Specifies the horizontal size of the blur.
  53333. */
  53334. set blurHorizontalSize(value: number);
  53335. /**
  53336. * Specifies the vertical size of the blur.
  53337. */
  53338. set blurVerticalSize(value: number);
  53339. /**
  53340. * Gets the horizontal size of the blur.
  53341. */
  53342. get blurHorizontalSize(): number;
  53343. /**
  53344. * Gets the vertical size of the blur.
  53345. */
  53346. get blurVerticalSize(): number;
  53347. /**
  53348. * An event triggered when the highlight layer is being blurred.
  53349. */
  53350. onBeforeBlurObservable: Observable<HighlightLayer>;
  53351. /**
  53352. * An event triggered when the highlight layer has been blurred.
  53353. */
  53354. onAfterBlurObservable: Observable<HighlightLayer>;
  53355. private _instanceGlowingMeshStencilReference;
  53356. private _options;
  53357. private _downSamplePostprocess;
  53358. private _horizontalBlurPostprocess;
  53359. private _verticalBlurPostprocess;
  53360. private _blurTexture;
  53361. private _meshes;
  53362. private _excludedMeshes;
  53363. /**
  53364. * Instantiates a new highlight Layer and references it to the scene..
  53365. * @param name The name of the layer
  53366. * @param scene The scene to use the layer in
  53367. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53368. */
  53369. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53370. /**
  53371. * Get the effect name of the layer.
  53372. * @return The effect name
  53373. */
  53374. getEffectName(): string;
  53375. /**
  53376. * Create the merge effect. This is the shader use to blit the information back
  53377. * to the main canvas at the end of the scene rendering.
  53378. */
  53379. protected _createMergeEffect(): Effect;
  53380. /**
  53381. * Creates the render target textures and post processes used in the highlight layer.
  53382. */
  53383. protected _createTextureAndPostProcesses(): void;
  53384. /**
  53385. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53386. */
  53387. needStencil(): boolean;
  53388. /**
  53389. * Checks for the readiness of the element composing the layer.
  53390. * @param subMesh the mesh to check for
  53391. * @param useInstances specify wether or not to use instances to render the mesh
  53392. * @param emissiveTexture the associated emissive texture used to generate the glow
  53393. * @return true if ready otherwise, false
  53394. */
  53395. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53396. /**
  53397. * Implementation specific of rendering the generating effect on the main canvas.
  53398. * @param effect The effect used to render through
  53399. */
  53400. protected _internalRender(effect: Effect): void;
  53401. /**
  53402. * Returns true if the layer contains information to display, otherwise false.
  53403. */
  53404. shouldRender(): boolean;
  53405. /**
  53406. * Returns true if the mesh should render, otherwise false.
  53407. * @param mesh The mesh to render
  53408. * @returns true if it should render otherwise false
  53409. */
  53410. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53411. /**
  53412. * Sets the required values for both the emissive texture and and the main color.
  53413. */
  53414. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53415. /**
  53416. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53417. * @param mesh The mesh to exclude from the highlight layer
  53418. */
  53419. addExcludedMesh(mesh: Mesh): void;
  53420. /**
  53421. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53422. * @param mesh The mesh to highlight
  53423. */
  53424. removeExcludedMesh(mesh: Mesh): void;
  53425. /**
  53426. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53427. * @param mesh mesh to test
  53428. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53429. */
  53430. hasMesh(mesh: AbstractMesh): boolean;
  53431. /**
  53432. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53433. * @param mesh The mesh to highlight
  53434. * @param color The color of the highlight
  53435. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53436. */
  53437. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53438. /**
  53439. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53440. * @param mesh The mesh to highlight
  53441. */
  53442. removeMesh(mesh: Mesh): void;
  53443. /**
  53444. * Remove all the meshes currently referenced in the highlight layer
  53445. */
  53446. removeAllMeshes(): void;
  53447. /**
  53448. * Force the stencil to the normal expected value for none glowing parts
  53449. */
  53450. private _defaultStencilReference;
  53451. /**
  53452. * Free any resources and references associated to a mesh.
  53453. * Internal use
  53454. * @param mesh The mesh to free.
  53455. * @hidden
  53456. */
  53457. _disposeMesh(mesh: Mesh): void;
  53458. /**
  53459. * Dispose the highlight layer and free resources.
  53460. */
  53461. dispose(): void;
  53462. /**
  53463. * Gets the class name of the effect layer
  53464. * @returns the string with the class name of the effect layer
  53465. */
  53466. getClassName(): string;
  53467. /**
  53468. * Serializes this Highlight layer
  53469. * @returns a serialized Highlight layer object
  53470. */
  53471. serialize(): any;
  53472. /**
  53473. * Creates a Highlight layer from parsed Highlight layer data
  53474. * @param parsedHightlightLayer defines the Highlight layer data
  53475. * @param scene defines the current scene
  53476. * @param rootUrl defines the root URL containing the Highlight layer information
  53477. * @returns a parsed Highlight layer
  53478. */
  53479. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53480. }
  53481. }
  53482. declare module BABYLON {
  53483. interface AbstractScene {
  53484. /**
  53485. * The list of layers (background and foreground) of the scene
  53486. */
  53487. layers: Array<Layer>;
  53488. }
  53489. /**
  53490. * Defines the layer scene component responsible to manage any layers
  53491. * in a given scene.
  53492. */
  53493. export class LayerSceneComponent implements ISceneComponent {
  53494. /**
  53495. * The component name helpfull to identify the component in the list of scene components.
  53496. */
  53497. readonly name: string;
  53498. /**
  53499. * The scene the component belongs to.
  53500. */
  53501. scene: Scene;
  53502. private _engine;
  53503. /**
  53504. * Creates a new instance of the component for the given scene
  53505. * @param scene Defines the scene to register the component in
  53506. */
  53507. constructor(scene: Scene);
  53508. /**
  53509. * Registers the component in a given scene
  53510. */
  53511. register(): void;
  53512. /**
  53513. * Rebuilds the elements related to this component in case of
  53514. * context lost for instance.
  53515. */
  53516. rebuild(): void;
  53517. /**
  53518. * Disposes the component and the associated ressources.
  53519. */
  53520. dispose(): void;
  53521. private _draw;
  53522. private _drawCameraPredicate;
  53523. private _drawCameraBackground;
  53524. private _drawCameraForeground;
  53525. private _drawRenderTargetPredicate;
  53526. private _drawRenderTargetBackground;
  53527. private _drawRenderTargetForeground;
  53528. /**
  53529. * Adds all the elements from the container to the scene
  53530. * @param container the container holding the elements
  53531. */
  53532. addFromContainer(container: AbstractScene): void;
  53533. /**
  53534. * Removes all the elements in the container from the scene
  53535. * @param container contains the elements to remove
  53536. * @param dispose if the removed element should be disposed (default: false)
  53537. */
  53538. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53539. }
  53540. }
  53541. declare module BABYLON {
  53542. /** @hidden */
  53543. export var layerPixelShader: {
  53544. name: string;
  53545. shader: string;
  53546. };
  53547. }
  53548. declare module BABYLON {
  53549. /** @hidden */
  53550. export var layerVertexShader: {
  53551. name: string;
  53552. shader: string;
  53553. };
  53554. }
  53555. declare module BABYLON {
  53556. /**
  53557. * This represents a full screen 2d layer.
  53558. * This can be useful to display a picture in the background of your scene for instance.
  53559. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53560. */
  53561. export class Layer {
  53562. /**
  53563. * Define the name of the layer.
  53564. */
  53565. name: string;
  53566. /**
  53567. * Define the texture the layer should display.
  53568. */
  53569. texture: Nullable<Texture>;
  53570. /**
  53571. * Is the layer in background or foreground.
  53572. */
  53573. isBackground: boolean;
  53574. /**
  53575. * Define the color of the layer (instead of texture).
  53576. */
  53577. color: Color4;
  53578. /**
  53579. * Define the scale of the layer in order to zoom in out of the texture.
  53580. */
  53581. scale: Vector2;
  53582. /**
  53583. * Define an offset for the layer in order to shift the texture.
  53584. */
  53585. offset: Vector2;
  53586. /**
  53587. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53588. */
  53589. alphaBlendingMode: number;
  53590. /**
  53591. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53592. * Alpha test will not mix with the background color in case of transparency.
  53593. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53594. */
  53595. alphaTest: boolean;
  53596. /**
  53597. * Define a mask to restrict the layer to only some of the scene cameras.
  53598. */
  53599. layerMask: number;
  53600. /**
  53601. * Define the list of render target the layer is visible into.
  53602. */
  53603. renderTargetTextures: RenderTargetTexture[];
  53604. /**
  53605. * Define if the layer is only used in renderTarget or if it also
  53606. * renders in the main frame buffer of the canvas.
  53607. */
  53608. renderOnlyInRenderTargetTextures: boolean;
  53609. private _scene;
  53610. private _vertexBuffers;
  53611. private _indexBuffer;
  53612. private _effect;
  53613. private _previousDefines;
  53614. /**
  53615. * An event triggered when the layer is disposed.
  53616. */
  53617. onDisposeObservable: Observable<Layer>;
  53618. private _onDisposeObserver;
  53619. /**
  53620. * Back compatibility with callback before the onDisposeObservable existed.
  53621. * The set callback will be triggered when the layer has been disposed.
  53622. */
  53623. set onDispose(callback: () => void);
  53624. /**
  53625. * An event triggered before rendering the scene
  53626. */
  53627. onBeforeRenderObservable: Observable<Layer>;
  53628. private _onBeforeRenderObserver;
  53629. /**
  53630. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53631. * The set callback will be triggered just before rendering the layer.
  53632. */
  53633. set onBeforeRender(callback: () => void);
  53634. /**
  53635. * An event triggered after rendering the scene
  53636. */
  53637. onAfterRenderObservable: Observable<Layer>;
  53638. private _onAfterRenderObserver;
  53639. /**
  53640. * Back compatibility with callback before the onAfterRenderObservable existed.
  53641. * The set callback will be triggered just after rendering the layer.
  53642. */
  53643. set onAfterRender(callback: () => void);
  53644. /**
  53645. * Instantiates a new layer.
  53646. * This represents a full screen 2d layer.
  53647. * This can be useful to display a picture in the background of your scene for instance.
  53648. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53649. * @param name Define the name of the layer in the scene
  53650. * @param imgUrl Define the url of the texture to display in the layer
  53651. * @param scene Define the scene the layer belongs to
  53652. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53653. * @param color Defines a color for the layer
  53654. */
  53655. constructor(
  53656. /**
  53657. * Define the name of the layer.
  53658. */
  53659. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53660. private _createIndexBuffer;
  53661. /** @hidden */
  53662. _rebuild(): void;
  53663. /**
  53664. * Renders the layer in the scene.
  53665. */
  53666. render(): void;
  53667. /**
  53668. * Disposes and releases the associated ressources.
  53669. */
  53670. dispose(): void;
  53671. }
  53672. }
  53673. declare module BABYLON {
  53674. /** @hidden */
  53675. export var lensFlarePixelShader: {
  53676. name: string;
  53677. shader: string;
  53678. };
  53679. }
  53680. declare module BABYLON {
  53681. /** @hidden */
  53682. export var lensFlareVertexShader: {
  53683. name: string;
  53684. shader: string;
  53685. };
  53686. }
  53687. declare module BABYLON {
  53688. /**
  53689. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53690. * It is usually composed of several `lensFlare`.
  53691. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53692. */
  53693. export class LensFlareSystem {
  53694. /**
  53695. * Define the name of the lens flare system
  53696. */
  53697. name: string;
  53698. /**
  53699. * List of lens flares used in this system.
  53700. */
  53701. lensFlares: LensFlare[];
  53702. /**
  53703. * Define a limit from the border the lens flare can be visible.
  53704. */
  53705. borderLimit: number;
  53706. /**
  53707. * Define a viewport border we do not want to see the lens flare in.
  53708. */
  53709. viewportBorder: number;
  53710. /**
  53711. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53712. */
  53713. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53714. /**
  53715. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53716. */
  53717. layerMask: number;
  53718. /**
  53719. * Define the id of the lens flare system in the scene.
  53720. * (equal to name by default)
  53721. */
  53722. id: string;
  53723. private _scene;
  53724. private _emitter;
  53725. private _vertexBuffers;
  53726. private _indexBuffer;
  53727. private _effect;
  53728. private _positionX;
  53729. private _positionY;
  53730. private _isEnabled;
  53731. /** @hidden */
  53732. static _SceneComponentInitialization: (scene: Scene) => void;
  53733. /**
  53734. * Instantiates a lens flare system.
  53735. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53736. * It is usually composed of several `lensFlare`.
  53737. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53738. * @param name Define the name of the lens flare system in the scene
  53739. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53740. * @param scene Define the scene the lens flare system belongs to
  53741. */
  53742. constructor(
  53743. /**
  53744. * Define the name of the lens flare system
  53745. */
  53746. name: string, emitter: any, scene: Scene);
  53747. /**
  53748. * Define if the lens flare system is enabled.
  53749. */
  53750. get isEnabled(): boolean;
  53751. set isEnabled(value: boolean);
  53752. /**
  53753. * Get the scene the effects belongs to.
  53754. * @returns the scene holding the lens flare system
  53755. */
  53756. getScene(): Scene;
  53757. /**
  53758. * Get the emitter of the lens flare system.
  53759. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53760. * @returns the emitter of the lens flare system
  53761. */
  53762. getEmitter(): any;
  53763. /**
  53764. * Set the emitter of the lens flare system.
  53765. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53766. * @param newEmitter Define the new emitter of the system
  53767. */
  53768. setEmitter(newEmitter: any): void;
  53769. /**
  53770. * Get the lens flare system emitter position.
  53771. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53772. * @returns the position
  53773. */
  53774. getEmitterPosition(): Vector3;
  53775. /**
  53776. * @hidden
  53777. */
  53778. computeEffectivePosition(globalViewport: Viewport): boolean;
  53779. /** @hidden */
  53780. _isVisible(): boolean;
  53781. /**
  53782. * @hidden
  53783. */
  53784. render(): boolean;
  53785. /**
  53786. * Dispose and release the lens flare with its associated resources.
  53787. */
  53788. dispose(): void;
  53789. /**
  53790. * Parse a lens flare system from a JSON repressentation
  53791. * @param parsedLensFlareSystem Define the JSON to parse
  53792. * @param scene Define the scene the parsed system should be instantiated in
  53793. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53794. * @returns the parsed system
  53795. */
  53796. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53797. /**
  53798. * Serialize the current Lens Flare System into a JSON representation.
  53799. * @returns the serialized JSON
  53800. */
  53801. serialize(): any;
  53802. }
  53803. }
  53804. declare module BABYLON {
  53805. /**
  53806. * This represents one of the lens effect in a `lensFlareSystem`.
  53807. * It controls one of the indiviual texture used in the effect.
  53808. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53809. */
  53810. export class LensFlare {
  53811. /**
  53812. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53813. */
  53814. size: number;
  53815. /**
  53816. * 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.
  53817. */
  53818. position: number;
  53819. /**
  53820. * Define the lens color.
  53821. */
  53822. color: Color3;
  53823. /**
  53824. * Define the lens texture.
  53825. */
  53826. texture: Nullable<Texture>;
  53827. /**
  53828. * Define the alpha mode to render this particular lens.
  53829. */
  53830. alphaMode: number;
  53831. private _system;
  53832. /**
  53833. * Creates a new Lens Flare.
  53834. * This represents one of the lens effect in a `lensFlareSystem`.
  53835. * It controls one of the indiviual texture used in the effect.
  53836. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53837. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53838. * @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.
  53839. * @param color Define the lens color
  53840. * @param imgUrl Define the lens texture url
  53841. * @param system Define the `lensFlareSystem` this flare is part of
  53842. * @returns The newly created Lens Flare
  53843. */
  53844. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53845. /**
  53846. * Instantiates a new Lens Flare.
  53847. * This represents one of the lens effect in a `lensFlareSystem`.
  53848. * It controls one of the indiviual texture used in the effect.
  53849. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53850. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53851. * @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.
  53852. * @param color Define the lens color
  53853. * @param imgUrl Define the lens texture url
  53854. * @param system Define the `lensFlareSystem` this flare is part of
  53855. */
  53856. constructor(
  53857. /**
  53858. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53859. */
  53860. size: number,
  53861. /**
  53862. * 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.
  53863. */
  53864. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53865. /**
  53866. * Dispose and release the lens flare with its associated resources.
  53867. */
  53868. dispose(): void;
  53869. }
  53870. }
  53871. declare module BABYLON {
  53872. interface AbstractScene {
  53873. /**
  53874. * The list of lens flare system added to the scene
  53875. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53876. */
  53877. lensFlareSystems: Array<LensFlareSystem>;
  53878. /**
  53879. * Removes the given lens flare system from this scene.
  53880. * @param toRemove The lens flare system to remove
  53881. * @returns The index of the removed lens flare system
  53882. */
  53883. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53884. /**
  53885. * Adds the given lens flare system to this scene
  53886. * @param newLensFlareSystem The lens flare system to add
  53887. */
  53888. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53889. /**
  53890. * Gets a lens flare system using its name
  53891. * @param name defines the name to look for
  53892. * @returns the lens flare system or null if not found
  53893. */
  53894. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53895. /**
  53896. * Gets a lens flare system using its id
  53897. * @param id defines the id to look for
  53898. * @returns the lens flare system or null if not found
  53899. */
  53900. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53901. }
  53902. /**
  53903. * Defines the lens flare scene component responsible to manage any lens flares
  53904. * in a given scene.
  53905. */
  53906. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53907. /**
  53908. * The component name helpfull to identify the component in the list of scene components.
  53909. */
  53910. readonly name: string;
  53911. /**
  53912. * The scene the component belongs to.
  53913. */
  53914. scene: Scene;
  53915. /**
  53916. * Creates a new instance of the component for the given scene
  53917. * @param scene Defines the scene to register the component in
  53918. */
  53919. constructor(scene: Scene);
  53920. /**
  53921. * Registers the component in a given scene
  53922. */
  53923. register(): void;
  53924. /**
  53925. * Rebuilds the elements related to this component in case of
  53926. * context lost for instance.
  53927. */
  53928. rebuild(): void;
  53929. /**
  53930. * Adds all the elements from the container to the scene
  53931. * @param container the container holding the elements
  53932. */
  53933. addFromContainer(container: AbstractScene): void;
  53934. /**
  53935. * Removes all the elements in the container from the scene
  53936. * @param container contains the elements to remove
  53937. * @param dispose if the removed element should be disposed (default: false)
  53938. */
  53939. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53940. /**
  53941. * Serializes the component data to the specified json object
  53942. * @param serializationObject The object to serialize to
  53943. */
  53944. serialize(serializationObject: any): void;
  53945. /**
  53946. * Disposes the component and the associated ressources.
  53947. */
  53948. dispose(): void;
  53949. private _draw;
  53950. }
  53951. }
  53952. declare module BABYLON {
  53953. /** @hidden */
  53954. export var depthPixelShader: {
  53955. name: string;
  53956. shader: string;
  53957. };
  53958. }
  53959. declare module BABYLON {
  53960. /** @hidden */
  53961. export var depthVertexShader: {
  53962. name: string;
  53963. shader: string;
  53964. };
  53965. }
  53966. declare module BABYLON {
  53967. /**
  53968. * This represents a depth renderer in Babylon.
  53969. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53970. */
  53971. export class DepthRenderer {
  53972. private _scene;
  53973. private _depthMap;
  53974. private _effect;
  53975. private readonly _storeNonLinearDepth;
  53976. private readonly _clearColor;
  53977. /** Get if the depth renderer is using packed depth or not */
  53978. readonly isPacked: boolean;
  53979. private _cachedDefines;
  53980. private _camera;
  53981. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  53982. enabled: boolean;
  53983. /**
  53984. * Specifiess that the depth renderer will only be used within
  53985. * the camera it is created for.
  53986. * This can help forcing its rendering during the camera processing.
  53987. */
  53988. useOnlyInActiveCamera: boolean;
  53989. /** @hidden */
  53990. static _SceneComponentInitialization: (scene: Scene) => void;
  53991. /**
  53992. * Instantiates a depth renderer
  53993. * @param scene The scene the renderer belongs to
  53994. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53995. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53996. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  53997. */
  53998. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  53999. /**
  54000. * Creates the depth rendering effect and checks if the effect is ready.
  54001. * @param subMesh The submesh to be used to render the depth map of
  54002. * @param useInstances If multiple world instances should be used
  54003. * @returns if the depth renderer is ready to render the depth map
  54004. */
  54005. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54006. /**
  54007. * Gets the texture which the depth map will be written to.
  54008. * @returns The depth map texture
  54009. */
  54010. getDepthMap(): RenderTargetTexture;
  54011. /**
  54012. * Disposes of the depth renderer.
  54013. */
  54014. dispose(): void;
  54015. }
  54016. }
  54017. declare module BABYLON {
  54018. /** @hidden */
  54019. export var minmaxReduxPixelShader: {
  54020. name: string;
  54021. shader: string;
  54022. };
  54023. }
  54024. declare module BABYLON {
  54025. /**
  54026. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54027. * and maximum values from all values of the texture.
  54028. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54029. * The source values are read from the red channel of the texture.
  54030. */
  54031. export class MinMaxReducer {
  54032. /**
  54033. * Observable triggered when the computation has been performed
  54034. */
  54035. onAfterReductionPerformed: Observable<{
  54036. min: number;
  54037. max: number;
  54038. }>;
  54039. protected _camera: Camera;
  54040. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54041. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54042. protected _postProcessManager: PostProcessManager;
  54043. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54044. protected _forceFullscreenViewport: boolean;
  54045. /**
  54046. * Creates a min/max reducer
  54047. * @param camera The camera to use for the post processes
  54048. */
  54049. constructor(camera: Camera);
  54050. /**
  54051. * Gets the texture used to read the values from.
  54052. */
  54053. get sourceTexture(): Nullable<RenderTargetTexture>;
  54054. /**
  54055. * Sets the source texture to read the values from.
  54056. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54057. * because in such textures '1' value must not be taken into account to compute the maximum
  54058. * as this value is used to clear the texture.
  54059. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54060. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54061. * @param depthRedux Indicates if the texture is a depth texture or not
  54062. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54063. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54064. */
  54065. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54066. /**
  54067. * Defines the refresh rate of the computation.
  54068. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54069. */
  54070. get refreshRate(): number;
  54071. set refreshRate(value: number);
  54072. protected _activated: boolean;
  54073. /**
  54074. * Gets the activation status of the reducer
  54075. */
  54076. get activated(): boolean;
  54077. /**
  54078. * Activates the reduction computation.
  54079. * When activated, the observers registered in onAfterReductionPerformed are
  54080. * called after the compuation is performed
  54081. */
  54082. activate(): void;
  54083. /**
  54084. * Deactivates the reduction computation.
  54085. */
  54086. deactivate(): void;
  54087. /**
  54088. * Disposes the min/max reducer
  54089. * @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.
  54090. */
  54091. dispose(disposeAll?: boolean): void;
  54092. }
  54093. }
  54094. declare module BABYLON {
  54095. /**
  54096. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54097. */
  54098. export class DepthReducer extends MinMaxReducer {
  54099. private _depthRenderer;
  54100. private _depthRendererId;
  54101. /**
  54102. * Gets the depth renderer used for the computation.
  54103. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54104. */
  54105. get depthRenderer(): Nullable<DepthRenderer>;
  54106. /**
  54107. * Creates a depth reducer
  54108. * @param camera The camera used to render the depth texture
  54109. */
  54110. constructor(camera: Camera);
  54111. /**
  54112. * Sets the depth renderer to use to generate the depth map
  54113. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54114. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54115. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54116. */
  54117. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54118. /** @hidden */
  54119. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54120. /**
  54121. * Activates the reduction computation.
  54122. * When activated, the observers registered in onAfterReductionPerformed are
  54123. * called after the compuation is performed
  54124. */
  54125. activate(): void;
  54126. /**
  54127. * Deactivates the reduction computation.
  54128. */
  54129. deactivate(): void;
  54130. /**
  54131. * Disposes the depth reducer
  54132. * @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.
  54133. */
  54134. dispose(disposeAll?: boolean): void;
  54135. }
  54136. }
  54137. declare module BABYLON {
  54138. /**
  54139. * A CSM implementation allowing casting shadows on large scenes.
  54140. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54141. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54142. */
  54143. export class CascadedShadowGenerator extends ShadowGenerator {
  54144. private static readonly frustumCornersNDCSpace;
  54145. /**
  54146. * Name of the CSM class
  54147. */
  54148. static CLASSNAME: string;
  54149. /**
  54150. * Defines the default number of cascades used by the CSM.
  54151. */
  54152. static readonly DEFAULT_CASCADES_COUNT: number;
  54153. /**
  54154. * Defines the minimum number of cascades used by the CSM.
  54155. */
  54156. static readonly MIN_CASCADES_COUNT: number;
  54157. /**
  54158. * Defines the maximum number of cascades used by the CSM.
  54159. */
  54160. static readonly MAX_CASCADES_COUNT: number;
  54161. protected _validateFilter(filter: number): number;
  54162. /**
  54163. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54164. */
  54165. penumbraDarkness: number;
  54166. private _numCascades;
  54167. /**
  54168. * Gets or set the number of cascades used by the CSM.
  54169. */
  54170. get numCascades(): number;
  54171. set numCascades(value: number);
  54172. /**
  54173. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54174. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54175. */
  54176. stabilizeCascades: boolean;
  54177. private _freezeShadowCastersBoundingInfo;
  54178. private _freezeShadowCastersBoundingInfoObservable;
  54179. /**
  54180. * Enables or disables the shadow casters bounding info computation.
  54181. * If your shadow casters don't move, you can disable this feature.
  54182. * If it is enabled, the bounding box computation is done every frame.
  54183. */
  54184. get freezeShadowCastersBoundingInfo(): boolean;
  54185. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54186. private _scbiMin;
  54187. private _scbiMax;
  54188. protected _computeShadowCastersBoundingInfo(): void;
  54189. protected _shadowCastersBoundingInfo: BoundingInfo;
  54190. /**
  54191. * Gets or sets the shadow casters bounding info.
  54192. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54193. * so that the system won't overwrite the bounds you provide
  54194. */
  54195. get shadowCastersBoundingInfo(): BoundingInfo;
  54196. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54197. protected _breaksAreDirty: boolean;
  54198. protected _minDistance: number;
  54199. protected _maxDistance: number;
  54200. /**
  54201. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54202. *
  54203. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54204. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54205. * @param min minimal distance for the breaks (default to 0.)
  54206. * @param max maximal distance for the breaks (default to 1.)
  54207. */
  54208. setMinMaxDistance(min: number, max: number): void;
  54209. /** Gets the minimal distance used in the cascade break computation */
  54210. get minDistance(): number;
  54211. /** Gets the maximal distance used in the cascade break computation */
  54212. get maxDistance(): number;
  54213. /**
  54214. * Gets the class name of that object
  54215. * @returns "CascadedShadowGenerator"
  54216. */
  54217. getClassName(): string;
  54218. private _cascadeMinExtents;
  54219. private _cascadeMaxExtents;
  54220. /**
  54221. * Gets a cascade minimum extents
  54222. * @param cascadeIndex index of the cascade
  54223. * @returns the minimum cascade extents
  54224. */
  54225. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54226. /**
  54227. * Gets a cascade maximum extents
  54228. * @param cascadeIndex index of the cascade
  54229. * @returns the maximum cascade extents
  54230. */
  54231. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54232. private _cascades;
  54233. private _currentLayer;
  54234. private _viewSpaceFrustumsZ;
  54235. private _viewMatrices;
  54236. private _projectionMatrices;
  54237. private _transformMatrices;
  54238. private _transformMatricesAsArray;
  54239. private _frustumLengths;
  54240. private _lightSizeUVCorrection;
  54241. private _depthCorrection;
  54242. private _frustumCornersWorldSpace;
  54243. private _frustumCenter;
  54244. private _shadowCameraPos;
  54245. private _shadowMaxZ;
  54246. /**
  54247. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54248. * It defaults to camera.maxZ
  54249. */
  54250. get shadowMaxZ(): number;
  54251. /**
  54252. * Sets the shadow max z distance.
  54253. */
  54254. set shadowMaxZ(value: number);
  54255. protected _debug: boolean;
  54256. /**
  54257. * Gets or sets the debug flag.
  54258. * When enabled, the cascades are materialized by different colors on the screen.
  54259. */
  54260. get debug(): boolean;
  54261. set debug(dbg: boolean);
  54262. private _depthClamp;
  54263. /**
  54264. * Gets or sets the depth clamping value.
  54265. *
  54266. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54267. * to account for the shadow casters far away.
  54268. *
  54269. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54270. */
  54271. get depthClamp(): boolean;
  54272. set depthClamp(value: boolean);
  54273. private _cascadeBlendPercentage;
  54274. /**
  54275. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54276. * It defaults to 0.1 (10% blending).
  54277. */
  54278. get cascadeBlendPercentage(): number;
  54279. set cascadeBlendPercentage(value: number);
  54280. private _lambda;
  54281. /**
  54282. * Gets or set the lambda parameter.
  54283. * This parameter is used to split the camera frustum and create the cascades.
  54284. * 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.
  54285. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54286. */
  54287. get lambda(): number;
  54288. set lambda(value: number);
  54289. /**
  54290. * Gets the view matrix corresponding to a given cascade
  54291. * @param cascadeNum cascade to retrieve the view matrix from
  54292. * @returns the cascade view matrix
  54293. */
  54294. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54295. /**
  54296. * Gets the projection matrix corresponding to a given cascade
  54297. * @param cascadeNum cascade to retrieve the projection matrix from
  54298. * @returns the cascade projection matrix
  54299. */
  54300. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54301. /**
  54302. * Gets the transformation matrix corresponding to a given cascade
  54303. * @param cascadeNum cascade to retrieve the transformation matrix from
  54304. * @returns the cascade transformation matrix
  54305. */
  54306. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54307. private _depthRenderer;
  54308. /**
  54309. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54310. *
  54311. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54312. *
  54313. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54314. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54315. * @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
  54316. */
  54317. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54318. private _depthReducer;
  54319. private _autoCalcDepthBounds;
  54320. /**
  54321. * Gets or sets the autoCalcDepthBounds property.
  54322. *
  54323. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54324. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54325. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54326. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54327. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54328. */
  54329. get autoCalcDepthBounds(): boolean;
  54330. set autoCalcDepthBounds(value: boolean);
  54331. /**
  54332. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54333. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54334. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54335. * for setting the refresh rate on the renderer yourself!
  54336. */
  54337. get autoCalcDepthBoundsRefreshRate(): number;
  54338. set autoCalcDepthBoundsRefreshRate(value: number);
  54339. /**
  54340. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54341. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54342. * you change the camera near/far planes!
  54343. */
  54344. splitFrustum(): void;
  54345. private _splitFrustum;
  54346. private _computeMatrices;
  54347. private _computeFrustumInWorldSpace;
  54348. private _computeCascadeFrustum;
  54349. /** @hidden */
  54350. static _SceneComponentInitialization: (scene: Scene) => void;
  54351. /**
  54352. * Creates a Cascaded Shadow Generator object.
  54353. * A ShadowGenerator is the required tool to use the shadows.
  54354. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54355. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54356. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54357. * @param light The directional light object generating the shadows.
  54358. * @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.
  54359. */
  54360. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54361. protected _initializeGenerator(): void;
  54362. protected _createTargetRenderTexture(): void;
  54363. protected _initializeShadowMap(): void;
  54364. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54365. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54366. /**
  54367. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54368. * @param defines Defines of the material we want to update
  54369. * @param lightIndex Index of the light in the enabled light list of the material
  54370. */
  54371. prepareDefines(defines: any, lightIndex: number): void;
  54372. /**
  54373. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54374. * defined in the generator but impacting the effect).
  54375. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54376. * @param effect The effect we are binfing the information for
  54377. */
  54378. bindShadowLight(lightIndex: string, effect: Effect): void;
  54379. /**
  54380. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54381. * (eq to view projection * shadow projection matrices)
  54382. * @returns The transform matrix used to create the shadow map
  54383. */
  54384. getTransformMatrix(): Matrix;
  54385. /**
  54386. * Disposes the ShadowGenerator.
  54387. * Returns nothing.
  54388. */
  54389. dispose(): void;
  54390. /**
  54391. * Serializes the shadow generator setup to a json object.
  54392. * @returns The serialized JSON object
  54393. */
  54394. serialize(): any;
  54395. /**
  54396. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54397. * @param parsedShadowGenerator The JSON object to parse
  54398. * @param scene The scene to create the shadow map for
  54399. * @returns The parsed shadow generator
  54400. */
  54401. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54402. }
  54403. }
  54404. declare module BABYLON {
  54405. /**
  54406. * Defines the shadow generator component responsible to manage any shadow generators
  54407. * in a given scene.
  54408. */
  54409. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54410. /**
  54411. * The component name helpfull to identify the component in the list of scene components.
  54412. */
  54413. readonly name: string;
  54414. /**
  54415. * The scene the component belongs to.
  54416. */
  54417. scene: Scene;
  54418. /**
  54419. * Creates a new instance of the component for the given scene
  54420. * @param scene Defines the scene to register the component in
  54421. */
  54422. constructor(scene: Scene);
  54423. /**
  54424. * Registers the component in a given scene
  54425. */
  54426. register(): void;
  54427. /**
  54428. * Rebuilds the elements related to this component in case of
  54429. * context lost for instance.
  54430. */
  54431. rebuild(): void;
  54432. /**
  54433. * Serializes the component data to the specified json object
  54434. * @param serializationObject The object to serialize to
  54435. */
  54436. serialize(serializationObject: any): void;
  54437. /**
  54438. * Adds all the elements from the container to the scene
  54439. * @param container the container holding the elements
  54440. */
  54441. addFromContainer(container: AbstractScene): void;
  54442. /**
  54443. * Removes all the elements in the container from the scene
  54444. * @param container contains the elements to remove
  54445. * @param dispose if the removed element should be disposed (default: false)
  54446. */
  54447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54448. /**
  54449. * Rebuilds the elements related to this component in case of
  54450. * context lost for instance.
  54451. */
  54452. dispose(): void;
  54453. private _gatherRenderTargets;
  54454. }
  54455. }
  54456. declare module BABYLON {
  54457. /**
  54458. * A point light is a light defined by an unique point in world space.
  54459. * The light is emitted in every direction from this point.
  54460. * A good example of a point light is a standard light bulb.
  54461. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54462. */
  54463. export class PointLight extends ShadowLight {
  54464. private _shadowAngle;
  54465. /**
  54466. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54467. * This specifies what angle the shadow will use to be created.
  54468. *
  54469. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54470. */
  54471. get shadowAngle(): number;
  54472. /**
  54473. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54474. * This specifies what angle the shadow will use to be created.
  54475. *
  54476. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54477. */
  54478. set shadowAngle(value: number);
  54479. /**
  54480. * Gets the direction if it has been set.
  54481. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54482. */
  54483. get direction(): Vector3;
  54484. /**
  54485. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54486. */
  54487. set direction(value: Vector3);
  54488. /**
  54489. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54490. * A PointLight emits the light in every direction.
  54491. * It can cast shadows.
  54492. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54493. * ```javascript
  54494. * var pointLight = new PointLight("pl", camera.position, scene);
  54495. * ```
  54496. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54497. * @param name The light friendly name
  54498. * @param position The position of the point light in the scene
  54499. * @param scene The scene the lights belongs to
  54500. */
  54501. constructor(name: string, position: Vector3, scene: Scene);
  54502. /**
  54503. * Returns the string "PointLight"
  54504. * @returns the class name
  54505. */
  54506. getClassName(): string;
  54507. /**
  54508. * Returns the integer 0.
  54509. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54510. */
  54511. getTypeID(): number;
  54512. /**
  54513. * Specifies wether or not the shadowmap should be a cube texture.
  54514. * @returns true if the shadowmap needs to be a cube texture.
  54515. */
  54516. needCube(): boolean;
  54517. /**
  54518. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54519. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54520. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54521. */
  54522. getShadowDirection(faceIndex?: number): Vector3;
  54523. /**
  54524. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54525. * - fov = PI / 2
  54526. * - aspect ratio : 1.0
  54527. * - z-near and far equal to the active camera minZ and maxZ.
  54528. * Returns the PointLight.
  54529. */
  54530. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54531. protected _buildUniformLayout(): void;
  54532. /**
  54533. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54534. * @param effect The effect to update
  54535. * @param lightIndex The index of the light in the effect to update
  54536. * @returns The point light
  54537. */
  54538. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54539. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54540. /**
  54541. * Prepares the list of defines specific to the light type.
  54542. * @param defines the list of defines
  54543. * @param lightIndex defines the index of the light for the effect
  54544. */
  54545. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54546. }
  54547. }
  54548. declare module BABYLON {
  54549. /**
  54550. * Header information of HDR texture files.
  54551. */
  54552. export interface HDRInfo {
  54553. /**
  54554. * The height of the texture in pixels.
  54555. */
  54556. height: number;
  54557. /**
  54558. * The width of the texture in pixels.
  54559. */
  54560. width: number;
  54561. /**
  54562. * The index of the beginning of the data in the binary file.
  54563. */
  54564. dataPosition: number;
  54565. }
  54566. /**
  54567. * This groups tools to convert HDR texture to native colors array.
  54568. */
  54569. export class HDRTools {
  54570. private static Ldexp;
  54571. private static Rgbe2float;
  54572. private static readStringLine;
  54573. /**
  54574. * Reads header information from an RGBE texture stored in a native array.
  54575. * More information on this format are available here:
  54576. * https://en.wikipedia.org/wiki/RGBE_image_format
  54577. *
  54578. * @param uint8array The binary file stored in native array.
  54579. * @return The header information.
  54580. */
  54581. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54582. /**
  54583. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54584. * This RGBE texture needs to store the information as a panorama.
  54585. *
  54586. * More information on this format are available here:
  54587. * https://en.wikipedia.org/wiki/RGBE_image_format
  54588. *
  54589. * @param buffer The binary file stored in an array buffer.
  54590. * @param size The expected size of the extracted cubemap.
  54591. * @return The Cube Map information.
  54592. */
  54593. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54594. /**
  54595. * Returns the pixels data extracted from an RGBE texture.
  54596. * This pixels will be stored left to right up to down in the R G B order in one array.
  54597. *
  54598. * More information on this format are available here:
  54599. * https://en.wikipedia.org/wiki/RGBE_image_format
  54600. *
  54601. * @param uint8array The binary file stored in an array buffer.
  54602. * @param hdrInfo The header information of the file.
  54603. * @return The pixels data in RGB right to left up to down order.
  54604. */
  54605. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54606. private static RGBE_ReadPixels_RLE;
  54607. }
  54608. }
  54609. declare module BABYLON {
  54610. /**
  54611. * This represents a texture coming from an HDR input.
  54612. *
  54613. * The only supported format is currently panorama picture stored in RGBE format.
  54614. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54615. */
  54616. export class HDRCubeTexture extends BaseTexture {
  54617. private static _facesMapping;
  54618. private _generateHarmonics;
  54619. private _noMipmap;
  54620. private _textureMatrix;
  54621. private _size;
  54622. private _onLoad;
  54623. private _onError;
  54624. /**
  54625. * The texture URL.
  54626. */
  54627. url: string;
  54628. /**
  54629. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54630. */
  54631. coordinatesMode: number;
  54632. protected _isBlocking: boolean;
  54633. /**
  54634. * Sets wether or not the texture is blocking during loading.
  54635. */
  54636. set isBlocking(value: boolean);
  54637. /**
  54638. * Gets wether or not the texture is blocking during loading.
  54639. */
  54640. get isBlocking(): boolean;
  54641. protected _rotationY: number;
  54642. /**
  54643. * Sets texture matrix rotation angle around Y axis in radians.
  54644. */
  54645. set rotationY(value: number);
  54646. /**
  54647. * Gets texture matrix rotation angle around Y axis radians.
  54648. */
  54649. get rotationY(): number;
  54650. /**
  54651. * Gets or sets the center of the bounding box associated with the cube texture
  54652. * It must define where the camera used to render the texture was set
  54653. */
  54654. boundingBoxPosition: Vector3;
  54655. private _boundingBoxSize;
  54656. /**
  54657. * Gets or sets the size of the bounding box associated with the cube texture
  54658. * When defined, the cubemap will switch to local mode
  54659. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54660. * @example https://www.babylonjs-playground.com/#RNASML
  54661. */
  54662. set boundingBoxSize(value: Vector3);
  54663. get boundingBoxSize(): Vector3;
  54664. /**
  54665. * Instantiates an HDRTexture from the following parameters.
  54666. *
  54667. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54668. * @param scene The scene the texture will be used in
  54669. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54670. * @param noMipmap Forces to not generate the mipmap if true
  54671. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54672. * @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)
  54673. * @param reserved Reserved flag for internal use.
  54674. */
  54675. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54676. /**
  54677. * Get the current class name of the texture useful for serialization or dynamic coding.
  54678. * @returns "HDRCubeTexture"
  54679. */
  54680. getClassName(): string;
  54681. /**
  54682. * Occurs when the file is raw .hdr file.
  54683. */
  54684. private loadTexture;
  54685. clone(): HDRCubeTexture;
  54686. delayLoad(): void;
  54687. /**
  54688. * Get the texture reflection matrix used to rotate/transform the reflection.
  54689. * @returns the reflection matrix
  54690. */
  54691. getReflectionTextureMatrix(): Matrix;
  54692. /**
  54693. * Set the texture reflection matrix used to rotate/transform the reflection.
  54694. * @param value Define the reflection matrix to set
  54695. */
  54696. setReflectionTextureMatrix(value: Matrix): void;
  54697. /**
  54698. * Parses a JSON representation of an HDR Texture in order to create the texture
  54699. * @param parsedTexture Define the JSON representation
  54700. * @param scene Define the scene the texture should be created in
  54701. * @param rootUrl Define the root url in case we need to load relative dependencies
  54702. * @returns the newly created texture after parsing
  54703. */
  54704. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54705. serialize(): any;
  54706. }
  54707. }
  54708. declare module BABYLON {
  54709. /**
  54710. * Class used to control physics engine
  54711. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54712. */
  54713. export class PhysicsEngine implements IPhysicsEngine {
  54714. private _physicsPlugin;
  54715. /**
  54716. * Global value used to control the smallest number supported by the simulation
  54717. */
  54718. static Epsilon: number;
  54719. private _impostors;
  54720. private _joints;
  54721. private _subTimeStep;
  54722. /**
  54723. * Gets the gravity vector used by the simulation
  54724. */
  54725. gravity: Vector3;
  54726. /**
  54727. * Factory used to create the default physics plugin.
  54728. * @returns The default physics plugin
  54729. */
  54730. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54731. /**
  54732. * Creates a new Physics Engine
  54733. * @param gravity defines the gravity vector used by the simulation
  54734. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54735. */
  54736. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54737. /**
  54738. * Sets the gravity vector used by the simulation
  54739. * @param gravity defines the gravity vector to use
  54740. */
  54741. setGravity(gravity: Vector3): void;
  54742. /**
  54743. * Set the time step of the physics engine.
  54744. * Default is 1/60.
  54745. * To slow it down, enter 1/600 for example.
  54746. * To speed it up, 1/30
  54747. * @param newTimeStep defines the new timestep to apply to this world.
  54748. */
  54749. setTimeStep(newTimeStep?: number): void;
  54750. /**
  54751. * Get the time step of the physics engine.
  54752. * @returns the current time step
  54753. */
  54754. getTimeStep(): number;
  54755. /**
  54756. * Set the sub time step of the physics engine.
  54757. * Default is 0 meaning there is no sub steps
  54758. * To increase physics resolution precision, set a small value (like 1 ms)
  54759. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54760. */
  54761. setSubTimeStep(subTimeStep?: number): void;
  54762. /**
  54763. * Get the sub time step of the physics engine.
  54764. * @returns the current sub time step
  54765. */
  54766. getSubTimeStep(): number;
  54767. /**
  54768. * Release all resources
  54769. */
  54770. dispose(): void;
  54771. /**
  54772. * Gets the name of the current physics plugin
  54773. * @returns the name of the plugin
  54774. */
  54775. getPhysicsPluginName(): string;
  54776. /**
  54777. * Adding a new impostor for the impostor tracking.
  54778. * This will be done by the impostor itself.
  54779. * @param impostor the impostor to add
  54780. */
  54781. addImpostor(impostor: PhysicsImpostor): void;
  54782. /**
  54783. * Remove an impostor from the engine.
  54784. * This impostor and its mesh will not longer be updated by the physics engine.
  54785. * @param impostor the impostor to remove
  54786. */
  54787. removeImpostor(impostor: PhysicsImpostor): void;
  54788. /**
  54789. * Add a joint to the physics engine
  54790. * @param mainImpostor defines the main impostor to which the joint is added.
  54791. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54792. * @param joint defines the joint that will connect both impostors.
  54793. */
  54794. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54795. /**
  54796. * Removes a joint from the simulation
  54797. * @param mainImpostor defines the impostor used with the joint
  54798. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54799. * @param joint defines the joint to remove
  54800. */
  54801. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54802. /**
  54803. * Called by the scene. No need to call it.
  54804. * @param delta defines the timespam between frames
  54805. */
  54806. _step(delta: number): void;
  54807. /**
  54808. * Gets the current plugin used to run the simulation
  54809. * @returns current plugin
  54810. */
  54811. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54812. /**
  54813. * Gets the list of physic impostors
  54814. * @returns an array of PhysicsImpostor
  54815. */
  54816. getImpostors(): Array<PhysicsImpostor>;
  54817. /**
  54818. * Gets the impostor for a physics enabled object
  54819. * @param object defines the object impersonated by the impostor
  54820. * @returns the PhysicsImpostor or null if not found
  54821. */
  54822. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54823. /**
  54824. * Gets the impostor for a physics body object
  54825. * @param body defines physics body used by the impostor
  54826. * @returns the PhysicsImpostor or null if not found
  54827. */
  54828. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54829. /**
  54830. * Does a raycast in the physics world
  54831. * @param from when should the ray start?
  54832. * @param to when should the ray end?
  54833. * @returns PhysicsRaycastResult
  54834. */
  54835. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54836. }
  54837. }
  54838. declare module BABYLON {
  54839. /** @hidden */
  54840. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54841. private _useDeltaForWorldStep;
  54842. world: any;
  54843. name: string;
  54844. private _physicsMaterials;
  54845. private _fixedTimeStep;
  54846. private _cannonRaycastResult;
  54847. private _raycastResult;
  54848. private _physicsBodysToRemoveAfterStep;
  54849. BJSCANNON: any;
  54850. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54851. setGravity(gravity: Vector3): void;
  54852. setTimeStep(timeStep: number): void;
  54853. getTimeStep(): number;
  54854. executeStep(delta: number): void;
  54855. private _removeMarkedPhysicsBodiesFromWorld;
  54856. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54857. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54858. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54859. private _processChildMeshes;
  54860. removePhysicsBody(impostor: PhysicsImpostor): void;
  54861. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54862. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54863. private _addMaterial;
  54864. private _checkWithEpsilon;
  54865. private _createShape;
  54866. private _createHeightmap;
  54867. private _minus90X;
  54868. private _plus90X;
  54869. private _tmpPosition;
  54870. private _tmpDeltaPosition;
  54871. private _tmpUnityRotation;
  54872. private _updatePhysicsBodyTransformation;
  54873. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54874. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54875. isSupported(): boolean;
  54876. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54877. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54878. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54879. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54880. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54881. getBodyMass(impostor: PhysicsImpostor): number;
  54882. getBodyFriction(impostor: PhysicsImpostor): number;
  54883. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54884. getBodyRestitution(impostor: PhysicsImpostor): number;
  54885. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54886. sleepBody(impostor: PhysicsImpostor): void;
  54887. wakeUpBody(impostor: PhysicsImpostor): void;
  54888. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54889. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54890. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54891. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54892. getRadius(impostor: PhysicsImpostor): number;
  54893. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54894. dispose(): void;
  54895. private _extendNamespace;
  54896. /**
  54897. * Does a raycast in the physics world
  54898. * @param from when should the ray start?
  54899. * @param to when should the ray end?
  54900. * @returns PhysicsRaycastResult
  54901. */
  54902. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54903. }
  54904. }
  54905. declare module BABYLON {
  54906. /** @hidden */
  54907. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54908. world: any;
  54909. name: string;
  54910. BJSOIMO: any;
  54911. private _raycastResult;
  54912. constructor(iterations?: number, oimoInjection?: any);
  54913. setGravity(gravity: Vector3): void;
  54914. setTimeStep(timeStep: number): void;
  54915. getTimeStep(): number;
  54916. private _tmpImpostorsArray;
  54917. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54918. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54919. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54920. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54921. private _tmpPositionVector;
  54922. removePhysicsBody(impostor: PhysicsImpostor): void;
  54923. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54924. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54925. isSupported(): boolean;
  54926. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54927. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54928. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54929. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54930. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54931. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54932. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54933. getBodyMass(impostor: PhysicsImpostor): number;
  54934. getBodyFriction(impostor: PhysicsImpostor): number;
  54935. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54936. getBodyRestitution(impostor: PhysicsImpostor): number;
  54937. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54938. sleepBody(impostor: PhysicsImpostor): void;
  54939. wakeUpBody(impostor: PhysicsImpostor): void;
  54940. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54941. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54942. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54943. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54944. getRadius(impostor: PhysicsImpostor): number;
  54945. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54946. dispose(): void;
  54947. /**
  54948. * Does a raycast in the physics world
  54949. * @param from when should the ray start?
  54950. * @param to when should the ray end?
  54951. * @returns PhysicsRaycastResult
  54952. */
  54953. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54954. }
  54955. }
  54956. declare module BABYLON {
  54957. /**
  54958. * Class containing static functions to help procedurally build meshes
  54959. */
  54960. export class RibbonBuilder {
  54961. /**
  54962. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54963. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54964. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54965. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54966. * * 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
  54967. * * 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
  54968. * * 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
  54969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54970. * * 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
  54971. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54972. * * 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
  54973. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54974. * * 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
  54975. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54977. * @param name defines the name of the mesh
  54978. * @param options defines the options used to create the mesh
  54979. * @param scene defines the hosting scene
  54980. * @returns the ribbon mesh
  54981. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54982. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54983. */
  54984. static CreateRibbon(name: string, options: {
  54985. pathArray: Vector3[][];
  54986. closeArray?: boolean;
  54987. closePath?: boolean;
  54988. offset?: number;
  54989. updatable?: boolean;
  54990. sideOrientation?: number;
  54991. frontUVs?: Vector4;
  54992. backUVs?: Vector4;
  54993. instance?: Mesh;
  54994. invertUV?: boolean;
  54995. uvs?: Vector2[];
  54996. colors?: Color4[];
  54997. }, scene?: Nullable<Scene>): Mesh;
  54998. }
  54999. }
  55000. declare module BABYLON {
  55001. /**
  55002. * Class containing static functions to help procedurally build meshes
  55003. */
  55004. export class ShapeBuilder {
  55005. /**
  55006. * 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.
  55007. * * 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.
  55008. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55009. * * 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.
  55010. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55011. * * 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
  55012. * * 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
  55013. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55015. * * 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
  55016. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55018. * @param name defines the name of the mesh
  55019. * @param options defines the options used to create the mesh
  55020. * @param scene defines the hosting scene
  55021. * @returns the extruded shape mesh
  55022. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55024. */
  55025. static ExtrudeShape(name: string, options: {
  55026. shape: Vector3[];
  55027. path: Vector3[];
  55028. scale?: number;
  55029. rotation?: number;
  55030. cap?: number;
  55031. updatable?: boolean;
  55032. sideOrientation?: number;
  55033. frontUVs?: Vector4;
  55034. backUVs?: Vector4;
  55035. instance?: Mesh;
  55036. invertUV?: boolean;
  55037. }, scene?: Nullable<Scene>): Mesh;
  55038. /**
  55039. * Creates an custom extruded shape mesh.
  55040. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55041. * * 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.
  55042. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55043. * * 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
  55044. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55045. * * 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
  55046. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55047. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55048. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55049. * * 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
  55050. * * 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
  55051. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55053. * * 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
  55054. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55056. * @param name defines the name of the mesh
  55057. * @param options defines the options used to create the mesh
  55058. * @param scene defines the hosting scene
  55059. * @returns the custom extruded shape mesh
  55060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55061. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55063. */
  55064. static ExtrudeShapeCustom(name: string, options: {
  55065. shape: Vector3[];
  55066. path: Vector3[];
  55067. scaleFunction?: any;
  55068. rotationFunction?: any;
  55069. ribbonCloseArray?: boolean;
  55070. ribbonClosePath?: boolean;
  55071. cap?: number;
  55072. updatable?: boolean;
  55073. sideOrientation?: number;
  55074. frontUVs?: Vector4;
  55075. backUVs?: Vector4;
  55076. instance?: Mesh;
  55077. invertUV?: boolean;
  55078. }, scene?: Nullable<Scene>): Mesh;
  55079. private static _ExtrudeShapeGeneric;
  55080. }
  55081. }
  55082. declare module BABYLON {
  55083. /**
  55084. * AmmoJS Physics plugin
  55085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55086. * @see https://github.com/kripken/ammo.js/
  55087. */
  55088. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55089. private _useDeltaForWorldStep;
  55090. /**
  55091. * Reference to the Ammo library
  55092. */
  55093. bjsAMMO: any;
  55094. /**
  55095. * Created ammoJS world which physics bodies are added to
  55096. */
  55097. world: any;
  55098. /**
  55099. * Name of the plugin
  55100. */
  55101. name: string;
  55102. private _timeStep;
  55103. private _fixedTimeStep;
  55104. private _maxSteps;
  55105. private _tmpQuaternion;
  55106. private _tmpAmmoTransform;
  55107. private _tmpAmmoQuaternion;
  55108. private _tmpAmmoConcreteContactResultCallback;
  55109. private _collisionConfiguration;
  55110. private _dispatcher;
  55111. private _overlappingPairCache;
  55112. private _solver;
  55113. private _softBodySolver;
  55114. private _tmpAmmoVectorA;
  55115. private _tmpAmmoVectorB;
  55116. private _tmpAmmoVectorC;
  55117. private _tmpAmmoVectorD;
  55118. private _tmpContactCallbackResult;
  55119. private _tmpAmmoVectorRCA;
  55120. private _tmpAmmoVectorRCB;
  55121. private _raycastResult;
  55122. private static readonly DISABLE_COLLISION_FLAG;
  55123. private static readonly KINEMATIC_FLAG;
  55124. private static readonly DISABLE_DEACTIVATION_FLAG;
  55125. /**
  55126. * Initializes the ammoJS plugin
  55127. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55128. * @param ammoInjection can be used to inject your own ammo reference
  55129. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55130. */
  55131. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55132. /**
  55133. * Sets the gravity of the physics world (m/(s^2))
  55134. * @param gravity Gravity to set
  55135. */
  55136. setGravity(gravity: Vector3): void;
  55137. /**
  55138. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55139. * @param timeStep timestep to use in seconds
  55140. */
  55141. setTimeStep(timeStep: number): void;
  55142. /**
  55143. * 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)
  55144. * @param fixedTimeStep fixedTimeStep to use in seconds
  55145. */
  55146. setFixedTimeStep(fixedTimeStep: number): void;
  55147. /**
  55148. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55149. * @param maxSteps the maximum number of steps by the physics engine per frame
  55150. */
  55151. setMaxSteps(maxSteps: number): void;
  55152. /**
  55153. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55154. * @returns the current timestep in seconds
  55155. */
  55156. getTimeStep(): number;
  55157. /**
  55158. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55159. */
  55160. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55161. private _isImpostorInContact;
  55162. private _isImpostorPairInContact;
  55163. private _stepSimulation;
  55164. /**
  55165. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55166. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55167. * After the step the babylon meshes are set to the position of the physics imposters
  55168. * @param delta amount of time to step forward
  55169. * @param impostors array of imposters to update before/after the step
  55170. */
  55171. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55172. /**
  55173. * Update babylon mesh to match physics world object
  55174. * @param impostor imposter to match
  55175. */
  55176. private _afterSoftStep;
  55177. /**
  55178. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55179. * @param impostor imposter to match
  55180. */
  55181. private _ropeStep;
  55182. /**
  55183. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55184. * @param impostor imposter to match
  55185. */
  55186. private _softbodyOrClothStep;
  55187. private _tmpVector;
  55188. private _tmpMatrix;
  55189. /**
  55190. * Applies an impulse on the imposter
  55191. * @param impostor imposter to apply impulse to
  55192. * @param force amount of force to be applied to the imposter
  55193. * @param contactPoint the location to apply the impulse on the imposter
  55194. */
  55195. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55196. /**
  55197. * Applies a force on the imposter
  55198. * @param impostor imposter to apply force
  55199. * @param force amount of force to be applied to the imposter
  55200. * @param contactPoint the location to apply the force on the imposter
  55201. */
  55202. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55203. /**
  55204. * Creates a physics body using the plugin
  55205. * @param impostor the imposter to create the physics body on
  55206. */
  55207. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55208. /**
  55209. * Removes the physics body from the imposter and disposes of the body's memory
  55210. * @param impostor imposter to remove the physics body from
  55211. */
  55212. removePhysicsBody(impostor: PhysicsImpostor): void;
  55213. /**
  55214. * Generates a joint
  55215. * @param impostorJoint the imposter joint to create the joint with
  55216. */
  55217. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55218. /**
  55219. * Removes a joint
  55220. * @param impostorJoint the imposter joint to remove the joint from
  55221. */
  55222. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55223. private _addMeshVerts;
  55224. /**
  55225. * Initialise the soft body vertices to match its object's (mesh) vertices
  55226. * Softbody vertices (nodes) are in world space and to match this
  55227. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55228. * @param impostor to create the softbody for
  55229. */
  55230. private _softVertexData;
  55231. /**
  55232. * Create an impostor's soft body
  55233. * @param impostor to create the softbody for
  55234. */
  55235. private _createSoftbody;
  55236. /**
  55237. * Create cloth for an impostor
  55238. * @param impostor to create the softbody for
  55239. */
  55240. private _createCloth;
  55241. /**
  55242. * Create rope for an impostor
  55243. * @param impostor to create the softbody for
  55244. */
  55245. private _createRope;
  55246. /**
  55247. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55248. * @param impostor to create the custom physics shape for
  55249. */
  55250. private _createCustom;
  55251. private _addHullVerts;
  55252. private _createShape;
  55253. /**
  55254. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55255. * @param impostor imposter containing the physics body and babylon object
  55256. */
  55257. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55258. /**
  55259. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55260. * @param impostor imposter containing the physics body and babylon object
  55261. * @param newPosition new position
  55262. * @param newRotation new rotation
  55263. */
  55264. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55265. /**
  55266. * If this plugin is supported
  55267. * @returns true if its supported
  55268. */
  55269. isSupported(): boolean;
  55270. /**
  55271. * Sets the linear velocity of the physics body
  55272. * @param impostor imposter to set the velocity on
  55273. * @param velocity velocity to set
  55274. */
  55275. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55276. /**
  55277. * Sets the angular velocity of the physics body
  55278. * @param impostor imposter to set the velocity on
  55279. * @param velocity velocity to set
  55280. */
  55281. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55282. /**
  55283. * gets the linear velocity
  55284. * @param impostor imposter to get linear velocity from
  55285. * @returns linear velocity
  55286. */
  55287. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55288. /**
  55289. * gets the angular velocity
  55290. * @param impostor imposter to get angular velocity from
  55291. * @returns angular velocity
  55292. */
  55293. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55294. /**
  55295. * Sets the mass of physics body
  55296. * @param impostor imposter to set the mass on
  55297. * @param mass mass to set
  55298. */
  55299. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55300. /**
  55301. * Gets the mass of the physics body
  55302. * @param impostor imposter to get the mass from
  55303. * @returns mass
  55304. */
  55305. getBodyMass(impostor: PhysicsImpostor): number;
  55306. /**
  55307. * Gets friction of the impostor
  55308. * @param impostor impostor to get friction from
  55309. * @returns friction value
  55310. */
  55311. getBodyFriction(impostor: PhysicsImpostor): number;
  55312. /**
  55313. * Sets friction of the impostor
  55314. * @param impostor impostor to set friction on
  55315. * @param friction friction value
  55316. */
  55317. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55318. /**
  55319. * Gets restitution of the impostor
  55320. * @param impostor impostor to get restitution from
  55321. * @returns restitution value
  55322. */
  55323. getBodyRestitution(impostor: PhysicsImpostor): number;
  55324. /**
  55325. * Sets resitution of the impostor
  55326. * @param impostor impostor to set resitution on
  55327. * @param restitution resitution value
  55328. */
  55329. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55330. /**
  55331. * Gets pressure inside the impostor
  55332. * @param impostor impostor to get pressure from
  55333. * @returns pressure value
  55334. */
  55335. getBodyPressure(impostor: PhysicsImpostor): number;
  55336. /**
  55337. * Sets pressure inside a soft body impostor
  55338. * Cloth and rope must remain 0 pressure
  55339. * @param impostor impostor to set pressure on
  55340. * @param pressure pressure value
  55341. */
  55342. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55343. /**
  55344. * Gets stiffness of the impostor
  55345. * @param impostor impostor to get stiffness from
  55346. * @returns pressure value
  55347. */
  55348. getBodyStiffness(impostor: PhysicsImpostor): number;
  55349. /**
  55350. * Sets stiffness of the impostor
  55351. * @param impostor impostor to set stiffness on
  55352. * @param stiffness stiffness value from 0 to 1
  55353. */
  55354. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55355. /**
  55356. * Gets velocityIterations of the impostor
  55357. * @param impostor impostor to get velocity iterations from
  55358. * @returns velocityIterations value
  55359. */
  55360. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55361. /**
  55362. * Sets velocityIterations of the impostor
  55363. * @param impostor impostor to set velocity iterations on
  55364. * @param velocityIterations velocityIterations value
  55365. */
  55366. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55367. /**
  55368. * Gets positionIterations of the impostor
  55369. * @param impostor impostor to get position iterations from
  55370. * @returns positionIterations value
  55371. */
  55372. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55373. /**
  55374. * Sets positionIterations of the impostor
  55375. * @param impostor impostor to set position on
  55376. * @param positionIterations positionIterations value
  55377. */
  55378. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55379. /**
  55380. * Append an anchor to a cloth object
  55381. * @param impostor is the cloth impostor to add anchor to
  55382. * @param otherImpostor is the rigid impostor to anchor to
  55383. * @param width ratio across width from 0 to 1
  55384. * @param height ratio up height from 0 to 1
  55385. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55386. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55387. */
  55388. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55389. /**
  55390. * Append an hook to a rope object
  55391. * @param impostor is the rope impostor to add hook to
  55392. * @param otherImpostor is the rigid impostor to hook to
  55393. * @param length ratio along the rope from 0 to 1
  55394. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55395. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55396. */
  55397. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55398. /**
  55399. * Sleeps the physics body and stops it from being active
  55400. * @param impostor impostor to sleep
  55401. */
  55402. sleepBody(impostor: PhysicsImpostor): void;
  55403. /**
  55404. * Activates the physics body
  55405. * @param impostor impostor to activate
  55406. */
  55407. wakeUpBody(impostor: PhysicsImpostor): void;
  55408. /**
  55409. * Updates the distance parameters of the joint
  55410. * @param joint joint to update
  55411. * @param maxDistance maximum distance of the joint
  55412. * @param minDistance minimum distance of the joint
  55413. */
  55414. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55415. /**
  55416. * Sets a motor on the joint
  55417. * @param joint joint to set motor on
  55418. * @param speed speed of the motor
  55419. * @param maxForce maximum force of the motor
  55420. * @param motorIndex index of the motor
  55421. */
  55422. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55423. /**
  55424. * Sets the motors limit
  55425. * @param joint joint to set limit on
  55426. * @param upperLimit upper limit
  55427. * @param lowerLimit lower limit
  55428. */
  55429. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55430. /**
  55431. * Syncs the position and rotation of a mesh with the impostor
  55432. * @param mesh mesh to sync
  55433. * @param impostor impostor to update the mesh with
  55434. */
  55435. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55436. /**
  55437. * Gets the radius of the impostor
  55438. * @param impostor impostor to get radius from
  55439. * @returns the radius
  55440. */
  55441. getRadius(impostor: PhysicsImpostor): number;
  55442. /**
  55443. * Gets the box size of the impostor
  55444. * @param impostor impostor to get box size from
  55445. * @param result the resulting box size
  55446. */
  55447. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55448. /**
  55449. * Disposes of the impostor
  55450. */
  55451. dispose(): void;
  55452. /**
  55453. * Does a raycast in the physics world
  55454. * @param from when should the ray start?
  55455. * @param to when should the ray end?
  55456. * @returns PhysicsRaycastResult
  55457. */
  55458. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55459. }
  55460. }
  55461. declare module BABYLON {
  55462. interface AbstractScene {
  55463. /**
  55464. * The list of reflection probes added to the scene
  55465. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55466. */
  55467. reflectionProbes: Array<ReflectionProbe>;
  55468. /**
  55469. * Removes the given reflection probe from this scene.
  55470. * @param toRemove The reflection probe to remove
  55471. * @returns The index of the removed reflection probe
  55472. */
  55473. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55474. /**
  55475. * Adds the given reflection probe to this scene.
  55476. * @param newReflectionProbe The reflection probe to add
  55477. */
  55478. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55479. }
  55480. /**
  55481. * Class used to generate realtime reflection / refraction cube textures
  55482. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55483. */
  55484. export class ReflectionProbe {
  55485. /** defines the name of the probe */
  55486. name: string;
  55487. private _scene;
  55488. private _renderTargetTexture;
  55489. private _projectionMatrix;
  55490. private _viewMatrix;
  55491. private _target;
  55492. private _add;
  55493. private _attachedMesh;
  55494. private _invertYAxis;
  55495. /** Gets or sets probe position (center of the cube map) */
  55496. position: Vector3;
  55497. /**
  55498. * Creates a new reflection probe
  55499. * @param name defines the name of the probe
  55500. * @param size defines the texture resolution (for each face)
  55501. * @param scene defines the hosting scene
  55502. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55503. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55504. */
  55505. constructor(
  55506. /** defines the name of the probe */
  55507. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55508. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55509. get samples(): number;
  55510. set samples(value: number);
  55511. /** Gets or sets the refresh rate to use (on every frame by default) */
  55512. get refreshRate(): number;
  55513. set refreshRate(value: number);
  55514. /**
  55515. * Gets the hosting scene
  55516. * @returns a Scene
  55517. */
  55518. getScene(): Scene;
  55519. /** Gets the internal CubeTexture used to render to */
  55520. get cubeTexture(): RenderTargetTexture;
  55521. /** Gets the list of meshes to render */
  55522. get renderList(): Nullable<AbstractMesh[]>;
  55523. /**
  55524. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55525. * @param mesh defines the mesh to attach to
  55526. */
  55527. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55528. /**
  55529. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55530. * @param renderingGroupId The rendering group id corresponding to its index
  55531. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55532. */
  55533. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55534. /**
  55535. * Clean all associated resources
  55536. */
  55537. dispose(): void;
  55538. /**
  55539. * Converts the reflection probe information to a readable string for debug purpose.
  55540. * @param fullDetails Supports for multiple levels of logging within scene loading
  55541. * @returns the human readable reflection probe info
  55542. */
  55543. toString(fullDetails?: boolean): string;
  55544. /**
  55545. * Get the class name of the relfection probe.
  55546. * @returns "ReflectionProbe"
  55547. */
  55548. getClassName(): string;
  55549. /**
  55550. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55551. * @returns The JSON representation of the texture
  55552. */
  55553. serialize(): any;
  55554. /**
  55555. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55556. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55557. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55558. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55559. * @returns The parsed reflection probe if successful
  55560. */
  55561. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55562. }
  55563. }
  55564. declare module BABYLON {
  55565. /** @hidden */
  55566. export var _BabylonLoaderRegistered: boolean;
  55567. /**
  55568. * Helps setting up some configuration for the babylon file loader.
  55569. */
  55570. export class BabylonFileLoaderConfiguration {
  55571. /**
  55572. * The loader does not allow injecting custom physix engine into the plugins.
  55573. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55574. * So you could set this variable to your engine import to make it work.
  55575. */
  55576. static LoaderInjectedPhysicsEngine: any;
  55577. }
  55578. }
  55579. declare module BABYLON {
  55580. /**
  55581. * The Physically based simple base material of BJS.
  55582. *
  55583. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55584. * It is used as the base class for both the specGloss and metalRough conventions.
  55585. */
  55586. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55587. /**
  55588. * Number of Simultaneous lights allowed on the material.
  55589. */
  55590. maxSimultaneousLights: number;
  55591. /**
  55592. * If sets to true, disables all the lights affecting the material.
  55593. */
  55594. disableLighting: boolean;
  55595. /**
  55596. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55597. */
  55598. environmentTexture: BaseTexture;
  55599. /**
  55600. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55601. */
  55602. invertNormalMapX: boolean;
  55603. /**
  55604. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55605. */
  55606. invertNormalMapY: boolean;
  55607. /**
  55608. * Normal map used in the model.
  55609. */
  55610. normalTexture: BaseTexture;
  55611. /**
  55612. * Emissivie color used to self-illuminate the model.
  55613. */
  55614. emissiveColor: Color3;
  55615. /**
  55616. * Emissivie texture used to self-illuminate the model.
  55617. */
  55618. emissiveTexture: BaseTexture;
  55619. /**
  55620. * Occlusion Channel Strenght.
  55621. */
  55622. occlusionStrength: number;
  55623. /**
  55624. * Occlusion Texture of the material (adding extra occlusion effects).
  55625. */
  55626. occlusionTexture: BaseTexture;
  55627. /**
  55628. * Defines the alpha limits in alpha test mode.
  55629. */
  55630. alphaCutOff: number;
  55631. /**
  55632. * Gets the current double sided mode.
  55633. */
  55634. get doubleSided(): boolean;
  55635. /**
  55636. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55637. */
  55638. set doubleSided(value: boolean);
  55639. /**
  55640. * Stores the pre-calculated light information of a mesh in a texture.
  55641. */
  55642. lightmapTexture: BaseTexture;
  55643. /**
  55644. * If true, the light map contains occlusion information instead of lighting info.
  55645. */
  55646. useLightmapAsShadowmap: boolean;
  55647. /**
  55648. * Instantiates a new PBRMaterial instance.
  55649. *
  55650. * @param name The material name
  55651. * @param scene The scene the material will be use in.
  55652. */
  55653. constructor(name: string, scene: Scene);
  55654. getClassName(): string;
  55655. }
  55656. }
  55657. declare module BABYLON {
  55658. /**
  55659. * The PBR material of BJS following the metal roughness convention.
  55660. *
  55661. * This fits to the PBR convention in the GLTF definition:
  55662. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55663. */
  55664. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55665. /**
  55666. * The base color has two different interpretations depending on the value of metalness.
  55667. * When the material is a metal, the base color is the specific measured reflectance value
  55668. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55669. * of the material.
  55670. */
  55671. baseColor: Color3;
  55672. /**
  55673. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55674. * well as opacity information in the alpha channel.
  55675. */
  55676. baseTexture: BaseTexture;
  55677. /**
  55678. * Specifies the metallic scalar value of the material.
  55679. * Can also be used to scale the metalness values of the metallic texture.
  55680. */
  55681. metallic: number;
  55682. /**
  55683. * Specifies the roughness scalar value of the material.
  55684. * Can also be used to scale the roughness values of the metallic texture.
  55685. */
  55686. roughness: number;
  55687. /**
  55688. * Texture containing both the metallic value in the B channel and the
  55689. * roughness value in the G channel to keep better precision.
  55690. */
  55691. metallicRoughnessTexture: BaseTexture;
  55692. /**
  55693. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55694. *
  55695. * @param name The material name
  55696. * @param scene The scene the material will be use in.
  55697. */
  55698. constructor(name: string, scene: Scene);
  55699. /**
  55700. * Return the currrent class name of the material.
  55701. */
  55702. getClassName(): string;
  55703. /**
  55704. * Makes a duplicate of the current material.
  55705. * @param name - name to use for the new material.
  55706. */
  55707. clone(name: string): PBRMetallicRoughnessMaterial;
  55708. /**
  55709. * Serialize the material to a parsable JSON object.
  55710. */
  55711. serialize(): any;
  55712. /**
  55713. * Parses a JSON object correponding to the serialize function.
  55714. */
  55715. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55716. }
  55717. }
  55718. declare module BABYLON {
  55719. /**
  55720. * The PBR material of BJS following the specular glossiness convention.
  55721. *
  55722. * This fits to the PBR convention in the GLTF definition:
  55723. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55724. */
  55725. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55726. /**
  55727. * Specifies the diffuse color of the material.
  55728. */
  55729. diffuseColor: Color3;
  55730. /**
  55731. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55732. * channel.
  55733. */
  55734. diffuseTexture: BaseTexture;
  55735. /**
  55736. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55737. */
  55738. specularColor: Color3;
  55739. /**
  55740. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55741. */
  55742. glossiness: number;
  55743. /**
  55744. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55745. */
  55746. specularGlossinessTexture: BaseTexture;
  55747. /**
  55748. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55749. *
  55750. * @param name The material name
  55751. * @param scene The scene the material will be use in.
  55752. */
  55753. constructor(name: string, scene: Scene);
  55754. /**
  55755. * Return the currrent class name of the material.
  55756. */
  55757. getClassName(): string;
  55758. /**
  55759. * Makes a duplicate of the current material.
  55760. * @param name - name to use for the new material.
  55761. */
  55762. clone(name: string): PBRSpecularGlossinessMaterial;
  55763. /**
  55764. * Serialize the material to a parsable JSON object.
  55765. */
  55766. serialize(): any;
  55767. /**
  55768. * Parses a JSON object correponding to the serialize function.
  55769. */
  55770. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55771. }
  55772. }
  55773. declare module BABYLON {
  55774. /**
  55775. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55776. * It can help converting any input color in a desired output one. This can then be used to create effects
  55777. * from sepia, black and white to sixties or futuristic rendering...
  55778. *
  55779. * The only supported format is currently 3dl.
  55780. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55781. */
  55782. export class ColorGradingTexture extends BaseTexture {
  55783. /**
  55784. * The current texture matrix. (will always be identity in color grading texture)
  55785. */
  55786. private _textureMatrix;
  55787. /**
  55788. * The texture URL.
  55789. */
  55790. url: string;
  55791. /**
  55792. * Empty line regex stored for GC.
  55793. */
  55794. private static _noneEmptyLineRegex;
  55795. private _engine;
  55796. /**
  55797. * Instantiates a ColorGradingTexture from the following parameters.
  55798. *
  55799. * @param url The location of the color gradind data (currently only supporting 3dl)
  55800. * @param scene The scene the texture will be used in
  55801. */
  55802. constructor(url: string, scene: Scene);
  55803. /**
  55804. * Returns the texture matrix used in most of the material.
  55805. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55806. */
  55807. getTextureMatrix(): Matrix;
  55808. /**
  55809. * Occurs when the file being loaded is a .3dl LUT file.
  55810. */
  55811. private load3dlTexture;
  55812. /**
  55813. * Starts the loading process of the texture.
  55814. */
  55815. private loadTexture;
  55816. /**
  55817. * Clones the color gradind texture.
  55818. */
  55819. clone(): ColorGradingTexture;
  55820. /**
  55821. * Called during delayed load for textures.
  55822. */
  55823. delayLoad(): void;
  55824. /**
  55825. * Parses a color grading texture serialized by Babylon.
  55826. * @param parsedTexture The texture information being parsedTexture
  55827. * @param scene The scene to load the texture in
  55828. * @param rootUrl The root url of the data assets to load
  55829. * @return A color gradind texture
  55830. */
  55831. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55832. /**
  55833. * Serializes the LUT texture to json format.
  55834. */
  55835. serialize(): any;
  55836. }
  55837. }
  55838. declare module BABYLON {
  55839. /**
  55840. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55841. */
  55842. export class EquiRectangularCubeTexture extends BaseTexture {
  55843. /** The six faces of the cube. */
  55844. private static _FacesMapping;
  55845. private _noMipmap;
  55846. private _onLoad;
  55847. private _onError;
  55848. /** The size of the cubemap. */
  55849. private _size;
  55850. /** The buffer of the image. */
  55851. private _buffer;
  55852. /** The width of the input image. */
  55853. private _width;
  55854. /** The height of the input image. */
  55855. private _height;
  55856. /** The URL to the image. */
  55857. url: string;
  55858. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55859. coordinatesMode: number;
  55860. /**
  55861. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55862. * @param url The location of the image
  55863. * @param scene The scene the texture will be used in
  55864. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55865. * @param noMipmap Forces to not generate the mipmap if true
  55866. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55867. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55868. * @param onLoad — defines a callback called when texture is loaded
  55869. * @param onError — defines a callback called if there is an error
  55870. */
  55871. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55872. /**
  55873. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55874. */
  55875. private loadImage;
  55876. /**
  55877. * Convert the image buffer into a cubemap and create a CubeTexture.
  55878. */
  55879. private loadTexture;
  55880. /**
  55881. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55882. * @param buffer The ArrayBuffer that should be converted.
  55883. * @returns The buffer as Float32Array.
  55884. */
  55885. private getFloat32ArrayFromArrayBuffer;
  55886. /**
  55887. * Get the current class name of the texture useful for serialization or dynamic coding.
  55888. * @returns "EquiRectangularCubeTexture"
  55889. */
  55890. getClassName(): string;
  55891. /**
  55892. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55893. * @returns A clone of the current EquiRectangularCubeTexture.
  55894. */
  55895. clone(): EquiRectangularCubeTexture;
  55896. }
  55897. }
  55898. declare module BABYLON {
  55899. /**
  55900. * Based on jsTGALoader - Javascript loader for TGA file
  55901. * By Vincent Thibault
  55902. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55903. */
  55904. export class TGATools {
  55905. private static _TYPE_INDEXED;
  55906. private static _TYPE_RGB;
  55907. private static _TYPE_GREY;
  55908. private static _TYPE_RLE_INDEXED;
  55909. private static _TYPE_RLE_RGB;
  55910. private static _TYPE_RLE_GREY;
  55911. private static _ORIGIN_MASK;
  55912. private static _ORIGIN_SHIFT;
  55913. private static _ORIGIN_BL;
  55914. private static _ORIGIN_BR;
  55915. private static _ORIGIN_UL;
  55916. private static _ORIGIN_UR;
  55917. /**
  55918. * Gets the header of a TGA file
  55919. * @param data defines the TGA data
  55920. * @returns the header
  55921. */
  55922. static GetTGAHeader(data: Uint8Array): any;
  55923. /**
  55924. * Uploads TGA content to a Babylon Texture
  55925. * @hidden
  55926. */
  55927. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55928. /** @hidden */
  55929. 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;
  55930. /** @hidden */
  55931. 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;
  55932. /** @hidden */
  55933. 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;
  55934. /** @hidden */
  55935. 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;
  55936. /** @hidden */
  55937. 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;
  55938. /** @hidden */
  55939. 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;
  55940. }
  55941. }
  55942. declare module BABYLON {
  55943. /**
  55944. * Implementation of the TGA Texture Loader.
  55945. * @hidden
  55946. */
  55947. export class _TGATextureLoader implements IInternalTextureLoader {
  55948. /**
  55949. * Defines wether the loader supports cascade loading the different faces.
  55950. */
  55951. readonly supportCascades: boolean;
  55952. /**
  55953. * This returns if the loader support the current file information.
  55954. * @param extension defines the file extension of the file being loaded
  55955. * @returns true if the loader can load the specified file
  55956. */
  55957. canLoad(extension: string): boolean;
  55958. /**
  55959. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55960. * @param data contains the texture data
  55961. * @param texture defines the BabylonJS internal texture
  55962. * @param createPolynomials will be true if polynomials have been requested
  55963. * @param onLoad defines the callback to trigger once the texture is ready
  55964. * @param onError defines the callback to trigger in case of error
  55965. */
  55966. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55967. /**
  55968. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55969. * @param data contains the texture data
  55970. * @param texture defines the BabylonJS internal texture
  55971. * @param callback defines the method to call once ready to upload
  55972. */
  55973. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55974. }
  55975. }
  55976. declare module BABYLON {
  55977. /**
  55978. * Info about the .basis files
  55979. */
  55980. class BasisFileInfo {
  55981. /**
  55982. * If the file has alpha
  55983. */
  55984. hasAlpha: boolean;
  55985. /**
  55986. * Info about each image of the basis file
  55987. */
  55988. images: Array<{
  55989. levels: Array<{
  55990. width: number;
  55991. height: number;
  55992. transcodedPixels: ArrayBufferView;
  55993. }>;
  55994. }>;
  55995. }
  55996. /**
  55997. * Result of transcoding a basis file
  55998. */
  55999. class TranscodeResult {
  56000. /**
  56001. * Info about the .basis file
  56002. */
  56003. fileInfo: BasisFileInfo;
  56004. /**
  56005. * Format to use when loading the file
  56006. */
  56007. format: number;
  56008. }
  56009. /**
  56010. * Configuration options for the Basis transcoder
  56011. */
  56012. export class BasisTranscodeConfiguration {
  56013. /**
  56014. * Supported compression formats used to determine the supported output format of the transcoder
  56015. */
  56016. supportedCompressionFormats?: {
  56017. /**
  56018. * etc1 compression format
  56019. */
  56020. etc1?: boolean;
  56021. /**
  56022. * s3tc compression format
  56023. */
  56024. s3tc?: boolean;
  56025. /**
  56026. * pvrtc compression format
  56027. */
  56028. pvrtc?: boolean;
  56029. /**
  56030. * etc2 compression format
  56031. */
  56032. etc2?: boolean;
  56033. };
  56034. /**
  56035. * If mipmap levels should be loaded for transcoded images (Default: true)
  56036. */
  56037. loadMipmapLevels?: boolean;
  56038. /**
  56039. * Index of a single image to load (Default: all images)
  56040. */
  56041. loadSingleImage?: number;
  56042. }
  56043. /**
  56044. * Used to load .Basis files
  56045. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56046. */
  56047. export class BasisTools {
  56048. private static _IgnoreSupportedFormats;
  56049. /**
  56050. * URL to use when loading the basis transcoder
  56051. */
  56052. static JSModuleURL: string;
  56053. /**
  56054. * URL to use when loading the wasm module for the transcoder
  56055. */
  56056. static WasmModuleURL: string;
  56057. /**
  56058. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56059. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56060. * @returns internal format corresponding to the Basis format
  56061. */
  56062. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56063. private static _WorkerPromise;
  56064. private static _Worker;
  56065. private static _actionId;
  56066. private static _CreateWorkerAsync;
  56067. /**
  56068. * Transcodes a loaded image file to compressed pixel data
  56069. * @param data image data to transcode
  56070. * @param config configuration options for the transcoding
  56071. * @returns a promise resulting in the transcoded image
  56072. */
  56073. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56074. /**
  56075. * Loads a texture from the transcode result
  56076. * @param texture texture load to
  56077. * @param transcodeResult the result of transcoding the basis file to load from
  56078. */
  56079. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56080. }
  56081. }
  56082. declare module BABYLON {
  56083. /**
  56084. * Loader for .basis file format
  56085. */
  56086. export class _BasisTextureLoader implements IInternalTextureLoader {
  56087. /**
  56088. * Defines whether the loader supports cascade loading the different faces.
  56089. */
  56090. readonly supportCascades: boolean;
  56091. /**
  56092. * This returns if the loader support the current file information.
  56093. * @param extension defines the file extension of the file being loaded
  56094. * @returns true if the loader can load the specified file
  56095. */
  56096. canLoad(extension: string): boolean;
  56097. /**
  56098. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56099. * @param data contains the texture data
  56100. * @param texture defines the BabylonJS internal texture
  56101. * @param createPolynomials will be true if polynomials have been requested
  56102. * @param onLoad defines the callback to trigger once the texture is ready
  56103. * @param onError defines the callback to trigger in case of error
  56104. */
  56105. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56106. /**
  56107. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56108. * @param data contains the texture data
  56109. * @param texture defines the BabylonJS internal texture
  56110. * @param callback defines the method to call once ready to upload
  56111. */
  56112. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56113. }
  56114. }
  56115. declare module BABYLON {
  56116. /**
  56117. * 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.
  56118. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56119. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56120. */
  56121. export class CustomProceduralTexture extends ProceduralTexture {
  56122. private _animate;
  56123. private _time;
  56124. private _config;
  56125. private _texturePath;
  56126. /**
  56127. * Instantiates a new Custom Procedural Texture.
  56128. * 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.
  56129. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56130. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56131. * @param name Define the name of the texture
  56132. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56133. * @param size Define the size of the texture to create
  56134. * @param scene Define the scene the texture belongs to
  56135. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56136. * @param generateMipMaps Define if the texture should creates mip maps or not
  56137. */
  56138. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56139. private _loadJson;
  56140. /**
  56141. * Is the texture ready to be used ? (rendered at least once)
  56142. * @returns true if ready, otherwise, false.
  56143. */
  56144. isReady(): boolean;
  56145. /**
  56146. * Render the texture to its associated render target.
  56147. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56148. */
  56149. render(useCameraPostProcess?: boolean): void;
  56150. /**
  56151. * Update the list of dependant textures samplers in the shader.
  56152. */
  56153. updateTextures(): void;
  56154. /**
  56155. * Update the uniform values of the procedural texture in the shader.
  56156. */
  56157. updateShaderUniforms(): void;
  56158. /**
  56159. * Define if the texture animates or not.
  56160. */
  56161. get animate(): boolean;
  56162. set animate(value: boolean);
  56163. }
  56164. }
  56165. declare module BABYLON {
  56166. /** @hidden */
  56167. export var noisePixelShader: {
  56168. name: string;
  56169. shader: string;
  56170. };
  56171. }
  56172. declare module BABYLON {
  56173. /**
  56174. * Class used to generate noise procedural textures
  56175. */
  56176. export class NoiseProceduralTexture extends ProceduralTexture {
  56177. private _time;
  56178. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56179. brightness: number;
  56180. /** Defines the number of octaves to process */
  56181. octaves: number;
  56182. /** Defines the level of persistence (0.8 by default) */
  56183. persistence: number;
  56184. /** Gets or sets animation speed factor (default is 1) */
  56185. animationSpeedFactor: number;
  56186. /**
  56187. * Creates a new NoiseProceduralTexture
  56188. * @param name defines the name fo the texture
  56189. * @param size defines the size of the texture (default is 256)
  56190. * @param scene defines the hosting scene
  56191. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56192. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56193. */
  56194. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56195. private _updateShaderUniforms;
  56196. protected _getDefines(): string;
  56197. /** Generate the current state of the procedural texture */
  56198. render(useCameraPostProcess?: boolean): void;
  56199. /**
  56200. * Serializes this noise procedural texture
  56201. * @returns a serialized noise procedural texture object
  56202. */
  56203. serialize(): any;
  56204. /**
  56205. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56206. * @param parsedTexture defines parsed texture data
  56207. * @param scene defines the current scene
  56208. * @param rootUrl defines the root URL containing noise procedural texture information
  56209. * @returns a parsed NoiseProceduralTexture
  56210. */
  56211. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56212. }
  56213. }
  56214. declare module BABYLON {
  56215. /**
  56216. * Raw cube texture where the raw buffers are passed in
  56217. */
  56218. export class RawCubeTexture extends CubeTexture {
  56219. /**
  56220. * Creates a cube texture where the raw buffers are passed in.
  56221. * @param scene defines the scene the texture is attached to
  56222. * @param data defines the array of data to use to create each face
  56223. * @param size defines the size of the textures
  56224. * @param format defines the format of the data
  56225. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56226. * @param generateMipMaps defines if the engine should generate the mip levels
  56227. * @param invertY defines if data must be stored with Y axis inverted
  56228. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56229. * @param compression defines the compression used (null by default)
  56230. */
  56231. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56232. /**
  56233. * Updates the raw cube texture.
  56234. * @param data defines the data to store
  56235. * @param format defines the data format
  56236. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56237. * @param invertY defines if data must be stored with Y axis inverted
  56238. * @param compression defines the compression used (null by default)
  56239. * @param level defines which level of the texture to update
  56240. */
  56241. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56242. /**
  56243. * Updates a raw cube texture with RGBD encoded data.
  56244. * @param data defines the array of data [mipmap][face] to use to create each face
  56245. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56246. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56247. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56248. * @returns a promsie that resolves when the operation is complete
  56249. */
  56250. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56251. /**
  56252. * Clones the raw cube texture.
  56253. * @return a new cube texture
  56254. */
  56255. clone(): CubeTexture;
  56256. /** @hidden */
  56257. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56258. }
  56259. }
  56260. declare module BABYLON {
  56261. /**
  56262. * Class used to store 3D textures containing user data
  56263. */
  56264. export class RawTexture3D extends Texture {
  56265. /** Gets or sets the texture format to use */
  56266. format: number;
  56267. private _engine;
  56268. /**
  56269. * Create a new RawTexture3D
  56270. * @param data defines the data of the texture
  56271. * @param width defines the width of the texture
  56272. * @param height defines the height of the texture
  56273. * @param depth defines the depth of the texture
  56274. * @param format defines the texture format to use
  56275. * @param scene defines the hosting scene
  56276. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56277. * @param invertY defines if texture must be stored with Y axis inverted
  56278. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56279. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56280. */
  56281. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56282. /** Gets or sets the texture format to use */
  56283. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56284. /**
  56285. * Update the texture with new data
  56286. * @param data defines the data to store in the texture
  56287. */
  56288. update(data: ArrayBufferView): void;
  56289. }
  56290. }
  56291. declare module BABYLON {
  56292. /**
  56293. * Class used to store 2D array textures containing user data
  56294. */
  56295. export class RawTexture2DArray extends Texture {
  56296. /** Gets or sets the texture format to use */
  56297. format: number;
  56298. private _engine;
  56299. /**
  56300. * Create a new RawTexture2DArray
  56301. * @param data defines the data of the texture
  56302. * @param width defines the width of the texture
  56303. * @param height defines the height of the texture
  56304. * @param depth defines the number of layers of the texture
  56305. * @param format defines the texture format to use
  56306. * @param scene defines the hosting scene
  56307. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56308. * @param invertY defines if texture must be stored with Y axis inverted
  56309. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56310. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56311. */
  56312. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56313. /** Gets or sets the texture format to use */
  56314. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56315. /**
  56316. * Update the texture with new data
  56317. * @param data defines the data to store in the texture
  56318. */
  56319. update(data: ArrayBufferView): void;
  56320. }
  56321. }
  56322. declare module BABYLON {
  56323. /**
  56324. * Creates a refraction texture used by refraction channel of the standard material.
  56325. * It is like a mirror but to see through a material.
  56326. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56327. */
  56328. export class RefractionTexture extends RenderTargetTexture {
  56329. /**
  56330. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56331. * 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.
  56332. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56333. */
  56334. refractionPlane: Plane;
  56335. /**
  56336. * Define how deep under the surface we should see.
  56337. */
  56338. depth: number;
  56339. /**
  56340. * Creates a refraction texture used by refraction channel of the standard material.
  56341. * It is like a mirror but to see through a material.
  56342. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56343. * @param name Define the texture name
  56344. * @param size Define the size of the underlying texture
  56345. * @param scene Define the scene the refraction belongs to
  56346. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56347. */
  56348. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56349. /**
  56350. * Clone the refraction texture.
  56351. * @returns the cloned texture
  56352. */
  56353. clone(): RefractionTexture;
  56354. /**
  56355. * Serialize the texture to a JSON representation you could use in Parse later on
  56356. * @returns the serialized JSON representation
  56357. */
  56358. serialize(): any;
  56359. }
  56360. }
  56361. declare module BABYLON {
  56362. /**
  56363. * Defines the options related to the creation of an HtmlElementTexture
  56364. */
  56365. export interface IHtmlElementTextureOptions {
  56366. /**
  56367. * Defines wether mip maps should be created or not.
  56368. */
  56369. generateMipMaps?: boolean;
  56370. /**
  56371. * Defines the sampling mode of the texture.
  56372. */
  56373. samplingMode?: number;
  56374. /**
  56375. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56376. */
  56377. engine: Nullable<ThinEngine>;
  56378. /**
  56379. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56380. */
  56381. scene: Nullable<Scene>;
  56382. }
  56383. /**
  56384. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56385. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56386. * is automatically managed.
  56387. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56388. * in your application.
  56389. *
  56390. * As the update is not automatic, you need to call them manually.
  56391. */
  56392. export class HtmlElementTexture extends BaseTexture {
  56393. /**
  56394. * The texture URL.
  56395. */
  56396. element: HTMLVideoElement | HTMLCanvasElement;
  56397. private static readonly DefaultOptions;
  56398. private _textureMatrix;
  56399. private _engine;
  56400. private _isVideo;
  56401. private _generateMipMaps;
  56402. private _samplingMode;
  56403. /**
  56404. * Instantiates a HtmlElementTexture from the following parameters.
  56405. *
  56406. * @param name Defines the name of the texture
  56407. * @param element Defines the video or canvas the texture is filled with
  56408. * @param options Defines the other none mandatory texture creation options
  56409. */
  56410. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56411. private _createInternalTexture;
  56412. /**
  56413. * Returns the texture matrix used in most of the material.
  56414. */
  56415. getTextureMatrix(): Matrix;
  56416. /**
  56417. * Updates the content of the texture.
  56418. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56419. */
  56420. update(invertY?: Nullable<boolean>): void;
  56421. }
  56422. }
  56423. declare module BABYLON {
  56424. /**
  56425. * Defines the basic options interface of a TexturePacker Frame
  56426. */
  56427. export interface ITexturePackerFrame {
  56428. /**
  56429. * The frame ID
  56430. */
  56431. id: number;
  56432. /**
  56433. * The frames Scale
  56434. */
  56435. scale: Vector2;
  56436. /**
  56437. * The Frames offset
  56438. */
  56439. offset: Vector2;
  56440. }
  56441. /**
  56442. * This is a support class for frame Data on texture packer sets.
  56443. */
  56444. export class TexturePackerFrame implements ITexturePackerFrame {
  56445. /**
  56446. * The frame ID
  56447. */
  56448. id: number;
  56449. /**
  56450. * The frames Scale
  56451. */
  56452. scale: Vector2;
  56453. /**
  56454. * The Frames offset
  56455. */
  56456. offset: Vector2;
  56457. /**
  56458. * Initializes a texture package frame.
  56459. * @param id The numerical frame identifier
  56460. * @param scale Scalar Vector2 for UV frame
  56461. * @param offset Vector2 for the frame position in UV units.
  56462. * @returns TexturePackerFrame
  56463. */
  56464. constructor(id: number, scale: Vector2, offset: Vector2);
  56465. }
  56466. }
  56467. declare module BABYLON {
  56468. /**
  56469. * Defines the basic options interface of a TexturePacker
  56470. */
  56471. export interface ITexturePackerOptions {
  56472. /**
  56473. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56474. */
  56475. map?: string[];
  56476. /**
  56477. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56478. */
  56479. uvsIn?: string;
  56480. /**
  56481. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56482. */
  56483. uvsOut?: string;
  56484. /**
  56485. * number representing the layout style. Defaults to LAYOUT_STRIP
  56486. */
  56487. layout?: number;
  56488. /**
  56489. * number of columns if using custom column count layout(2). This defaults to 4.
  56490. */
  56491. colnum?: number;
  56492. /**
  56493. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56494. */
  56495. updateInputMeshes?: boolean;
  56496. /**
  56497. * boolean flag to dispose all the source textures. Defaults to true.
  56498. */
  56499. disposeSources?: boolean;
  56500. /**
  56501. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56502. */
  56503. fillBlanks?: boolean;
  56504. /**
  56505. * string value representing the context fill style color. Defaults to 'black'.
  56506. */
  56507. customFillColor?: string;
  56508. /**
  56509. * Width and Height Value of each Frame in the TexturePacker Sets
  56510. */
  56511. frameSize?: number;
  56512. /**
  56513. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56514. */
  56515. paddingRatio?: number;
  56516. /**
  56517. * Number that declares the fill method for the padding gutter.
  56518. */
  56519. paddingMode?: number;
  56520. /**
  56521. * If in SUBUV_COLOR padding mode what color to use.
  56522. */
  56523. paddingColor?: Color3 | Color4;
  56524. }
  56525. /**
  56526. * Defines the basic interface of a TexturePacker JSON File
  56527. */
  56528. export interface ITexturePackerJSON {
  56529. /**
  56530. * The frame ID
  56531. */
  56532. name: string;
  56533. /**
  56534. * The base64 channel data
  56535. */
  56536. sets: any;
  56537. /**
  56538. * The options of the Packer
  56539. */
  56540. options: ITexturePackerOptions;
  56541. /**
  56542. * The frame data of the Packer
  56543. */
  56544. frames: Array<number>;
  56545. }
  56546. /**
  56547. * This is a support class that generates a series of packed texture sets.
  56548. * @see https://doc.babylonjs.com/babylon101/materials
  56549. */
  56550. export class TexturePacker {
  56551. /** Packer Layout Constant 0 */
  56552. static readonly LAYOUT_STRIP: number;
  56553. /** Packer Layout Constant 1 */
  56554. static readonly LAYOUT_POWER2: number;
  56555. /** Packer Layout Constant 2 */
  56556. static readonly LAYOUT_COLNUM: number;
  56557. /** Packer Layout Constant 0 */
  56558. static readonly SUBUV_WRAP: number;
  56559. /** Packer Layout Constant 1 */
  56560. static readonly SUBUV_EXTEND: number;
  56561. /** Packer Layout Constant 2 */
  56562. static readonly SUBUV_COLOR: number;
  56563. /** The Name of the Texture Package */
  56564. name: string;
  56565. /** The scene scope of the TexturePacker */
  56566. scene: Scene;
  56567. /** The Meshes to target */
  56568. meshes: AbstractMesh[];
  56569. /** Arguments passed with the Constructor */
  56570. options: ITexturePackerOptions;
  56571. /** The promise that is started upon initialization */
  56572. promise: Nullable<Promise<TexturePacker | string>>;
  56573. /** The Container object for the channel sets that are generated */
  56574. sets: object;
  56575. /** The Container array for the frames that are generated */
  56576. frames: TexturePackerFrame[];
  56577. /** The expected number of textures the system is parsing. */
  56578. private _expecting;
  56579. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56580. private _paddingValue;
  56581. /**
  56582. * Initializes a texture package series from an array of meshes or a single mesh.
  56583. * @param name The name of the package
  56584. * @param meshes The target meshes to compose the package from
  56585. * @param options The arguments that texture packer should follow while building.
  56586. * @param scene The scene which the textures are scoped to.
  56587. * @returns TexturePacker
  56588. */
  56589. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56590. /**
  56591. * Starts the package process
  56592. * @param resolve The promises resolution function
  56593. * @returns TexturePacker
  56594. */
  56595. private _createFrames;
  56596. /**
  56597. * Calculates the Size of the Channel Sets
  56598. * @returns Vector2
  56599. */
  56600. private _calculateSize;
  56601. /**
  56602. * Calculates the UV data for the frames.
  56603. * @param baseSize the base frameSize
  56604. * @param padding the base frame padding
  56605. * @param dtSize size of the Dynamic Texture for that channel
  56606. * @param dtUnits is 1/dtSize
  56607. * @param update flag to update the input meshes
  56608. */
  56609. private _calculateMeshUVFrames;
  56610. /**
  56611. * Calculates the frames Offset.
  56612. * @param index of the frame
  56613. * @returns Vector2
  56614. */
  56615. private _getFrameOffset;
  56616. /**
  56617. * Updates a Mesh to the frame data
  56618. * @param mesh that is the target
  56619. * @param frameID or the frame index
  56620. */
  56621. private _updateMeshUV;
  56622. /**
  56623. * Updates a Meshes materials to use the texture packer channels
  56624. * @param m is the mesh to target
  56625. * @param force all channels on the packer to be set.
  56626. */
  56627. private _updateTextureReferences;
  56628. /**
  56629. * Public method to set a Mesh to a frame
  56630. * @param m that is the target
  56631. * @param frameID or the frame index
  56632. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56633. */
  56634. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56635. /**
  56636. * Starts the async promise to compile the texture packer.
  56637. * @returns Promise<void>
  56638. */
  56639. processAsync(): Promise<void>;
  56640. /**
  56641. * Disposes all textures associated with this packer
  56642. */
  56643. dispose(): void;
  56644. /**
  56645. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56646. * @param imageType is the image type to use.
  56647. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56648. */
  56649. download(imageType?: string, quality?: number): void;
  56650. /**
  56651. * Public method to load a texturePacker JSON file.
  56652. * @param data of the JSON file in string format.
  56653. */
  56654. updateFromJSON(data: string): void;
  56655. }
  56656. }
  56657. declare module BABYLON {
  56658. /**
  56659. * Enum used to define the target of a block
  56660. */
  56661. export enum NodeMaterialBlockTargets {
  56662. /** Vertex shader */
  56663. Vertex = 1,
  56664. /** Fragment shader */
  56665. Fragment = 2,
  56666. /** Neutral */
  56667. Neutral = 4,
  56668. /** Vertex and Fragment */
  56669. VertexAndFragment = 3
  56670. }
  56671. }
  56672. declare module BABYLON {
  56673. /**
  56674. * Defines the kind of connection point for node based material
  56675. */
  56676. export enum NodeMaterialBlockConnectionPointTypes {
  56677. /** Float */
  56678. Float = 1,
  56679. /** Int */
  56680. Int = 2,
  56681. /** Vector2 */
  56682. Vector2 = 4,
  56683. /** Vector3 */
  56684. Vector3 = 8,
  56685. /** Vector4 */
  56686. Vector4 = 16,
  56687. /** Color3 */
  56688. Color3 = 32,
  56689. /** Color4 */
  56690. Color4 = 64,
  56691. /** Matrix */
  56692. Matrix = 128,
  56693. /** Detect type based on connection */
  56694. AutoDetect = 1024,
  56695. /** Output type that will be defined by input type */
  56696. BasedOnInput = 2048
  56697. }
  56698. }
  56699. declare module BABYLON {
  56700. /**
  56701. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56702. */
  56703. export enum NodeMaterialBlockConnectionPointMode {
  56704. /** Value is an uniform */
  56705. Uniform = 0,
  56706. /** Value is a mesh attribute */
  56707. Attribute = 1,
  56708. /** Value is a varying between vertex and fragment shaders */
  56709. Varying = 2,
  56710. /** Mode is undefined */
  56711. Undefined = 3
  56712. }
  56713. }
  56714. declare module BABYLON {
  56715. /**
  56716. * Enum used to define system values e.g. values automatically provided by the system
  56717. */
  56718. export enum NodeMaterialSystemValues {
  56719. /** World */
  56720. World = 1,
  56721. /** View */
  56722. View = 2,
  56723. /** Projection */
  56724. Projection = 3,
  56725. /** ViewProjection */
  56726. ViewProjection = 4,
  56727. /** WorldView */
  56728. WorldView = 5,
  56729. /** WorldViewProjection */
  56730. WorldViewProjection = 6,
  56731. /** CameraPosition */
  56732. CameraPosition = 7,
  56733. /** Fog Color */
  56734. FogColor = 8,
  56735. /** Delta time */
  56736. DeltaTime = 9
  56737. }
  56738. }
  56739. declare module BABYLON {
  56740. /**
  56741. * Root class for all node material optimizers
  56742. */
  56743. export class NodeMaterialOptimizer {
  56744. /**
  56745. * Function used to optimize a NodeMaterial graph
  56746. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56747. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56748. */
  56749. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56750. }
  56751. }
  56752. declare module BABYLON {
  56753. /**
  56754. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56755. */
  56756. export class TransformBlock extends NodeMaterialBlock {
  56757. /**
  56758. * Defines the value to use to complement W value to transform it to a Vector4
  56759. */
  56760. complementW: number;
  56761. /**
  56762. * Defines the value to use to complement z value to transform it to a Vector4
  56763. */
  56764. complementZ: number;
  56765. /**
  56766. * Creates a new TransformBlock
  56767. * @param name defines the block name
  56768. */
  56769. constructor(name: string);
  56770. /**
  56771. * Gets the current class name
  56772. * @returns the class name
  56773. */
  56774. getClassName(): string;
  56775. /**
  56776. * Gets the vector input
  56777. */
  56778. get vector(): NodeMaterialConnectionPoint;
  56779. /**
  56780. * Gets the output component
  56781. */
  56782. get output(): NodeMaterialConnectionPoint;
  56783. /**
  56784. * Gets the xyz output component
  56785. */
  56786. get xyz(): NodeMaterialConnectionPoint;
  56787. /**
  56788. * Gets the matrix transform input
  56789. */
  56790. get transform(): NodeMaterialConnectionPoint;
  56791. protected _buildBlock(state: NodeMaterialBuildState): this;
  56792. serialize(): any;
  56793. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56794. protected _dumpPropertiesCode(): string;
  56795. }
  56796. }
  56797. declare module BABYLON {
  56798. /**
  56799. * Block used to output the vertex position
  56800. */
  56801. export class VertexOutputBlock extends NodeMaterialBlock {
  56802. /**
  56803. * Creates a new VertexOutputBlock
  56804. * @param name defines the block name
  56805. */
  56806. constructor(name: string);
  56807. /**
  56808. * Gets the current class name
  56809. * @returns the class name
  56810. */
  56811. getClassName(): string;
  56812. /**
  56813. * Gets the vector input component
  56814. */
  56815. get vector(): NodeMaterialConnectionPoint;
  56816. protected _buildBlock(state: NodeMaterialBuildState): this;
  56817. }
  56818. }
  56819. declare module BABYLON {
  56820. /**
  56821. * Block used to output the final color
  56822. */
  56823. export class FragmentOutputBlock extends NodeMaterialBlock {
  56824. /**
  56825. * Create a new FragmentOutputBlock
  56826. * @param name defines the block name
  56827. */
  56828. constructor(name: string);
  56829. /**
  56830. * Gets the current class name
  56831. * @returns the class name
  56832. */
  56833. getClassName(): string;
  56834. /**
  56835. * Gets the rgba input component
  56836. */
  56837. get rgba(): NodeMaterialConnectionPoint;
  56838. /**
  56839. * Gets the rgb input component
  56840. */
  56841. get rgb(): NodeMaterialConnectionPoint;
  56842. /**
  56843. * Gets the a input component
  56844. */
  56845. get a(): NodeMaterialConnectionPoint;
  56846. protected _buildBlock(state: NodeMaterialBuildState): this;
  56847. }
  56848. }
  56849. declare module BABYLON {
  56850. /**
  56851. * Block used to read a reflection texture from a sampler
  56852. */
  56853. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56854. private _define3DName;
  56855. private _defineCubicName;
  56856. private _defineExplicitName;
  56857. private _defineProjectionName;
  56858. private _defineLocalCubicName;
  56859. private _defineSphericalName;
  56860. private _definePlanarName;
  56861. private _defineEquirectangularName;
  56862. private _defineMirroredEquirectangularFixedName;
  56863. private _defineEquirectangularFixedName;
  56864. private _defineSkyboxName;
  56865. private _cubeSamplerName;
  56866. private _2DSamplerName;
  56867. private _positionUVWName;
  56868. private _directionWName;
  56869. private _reflectionCoordsName;
  56870. private _reflection2DCoordsName;
  56871. private _reflectionColorName;
  56872. private _reflectionMatrixName;
  56873. /**
  56874. * Gets or sets the texture associated with the node
  56875. */
  56876. texture: Nullable<BaseTexture>;
  56877. /**
  56878. * Create a new TextureBlock
  56879. * @param name defines the block name
  56880. */
  56881. constructor(name: string);
  56882. /**
  56883. * Gets the current class name
  56884. * @returns the class name
  56885. */
  56886. getClassName(): string;
  56887. /**
  56888. * Gets the world position input component
  56889. */
  56890. get position(): NodeMaterialConnectionPoint;
  56891. /**
  56892. * Gets the world position input component
  56893. */
  56894. get worldPosition(): NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the world normal input component
  56897. */
  56898. get worldNormal(): NodeMaterialConnectionPoint;
  56899. /**
  56900. * Gets the world input component
  56901. */
  56902. get world(): NodeMaterialConnectionPoint;
  56903. /**
  56904. * Gets the camera (or eye) position component
  56905. */
  56906. get cameraPosition(): NodeMaterialConnectionPoint;
  56907. /**
  56908. * Gets the view input component
  56909. */
  56910. get view(): NodeMaterialConnectionPoint;
  56911. /**
  56912. * Gets the rgb output component
  56913. */
  56914. get rgb(): NodeMaterialConnectionPoint;
  56915. /**
  56916. * Gets the r output component
  56917. */
  56918. get r(): NodeMaterialConnectionPoint;
  56919. /**
  56920. * Gets the g output component
  56921. */
  56922. get g(): NodeMaterialConnectionPoint;
  56923. /**
  56924. * Gets the b output component
  56925. */
  56926. get b(): NodeMaterialConnectionPoint;
  56927. autoConfigure(material: NodeMaterial): void;
  56928. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56929. isReady(): boolean;
  56930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56931. private _injectVertexCode;
  56932. private _writeOutput;
  56933. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56934. protected _dumpPropertiesCode(): string;
  56935. serialize(): any;
  56936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56937. }
  56938. }
  56939. declare module BABYLON {
  56940. /**
  56941. * Interface used to configure the node material editor
  56942. */
  56943. export interface INodeMaterialEditorOptions {
  56944. /** Define the URl to load node editor script */
  56945. editorURL?: string;
  56946. }
  56947. /** @hidden */
  56948. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56949. NORMAL: boolean;
  56950. TANGENT: boolean;
  56951. UV1: boolean;
  56952. /** BONES */
  56953. NUM_BONE_INFLUENCERS: number;
  56954. BonesPerMesh: number;
  56955. BONETEXTURE: boolean;
  56956. /** MORPH TARGETS */
  56957. MORPHTARGETS: boolean;
  56958. MORPHTARGETS_NORMAL: boolean;
  56959. MORPHTARGETS_TANGENT: boolean;
  56960. MORPHTARGETS_UV: boolean;
  56961. NUM_MORPH_INFLUENCERS: number;
  56962. /** IMAGE PROCESSING */
  56963. IMAGEPROCESSING: boolean;
  56964. VIGNETTE: boolean;
  56965. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56966. VIGNETTEBLENDMODEOPAQUE: boolean;
  56967. TONEMAPPING: boolean;
  56968. TONEMAPPING_ACES: boolean;
  56969. CONTRAST: boolean;
  56970. EXPOSURE: boolean;
  56971. COLORCURVES: boolean;
  56972. COLORGRADING: boolean;
  56973. COLORGRADING3D: boolean;
  56974. SAMPLER3DGREENDEPTH: boolean;
  56975. SAMPLER3DBGRMAP: boolean;
  56976. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56977. /** MISC. */
  56978. BUMPDIRECTUV: number;
  56979. constructor();
  56980. setValue(name: string, value: boolean): void;
  56981. }
  56982. /**
  56983. * Class used to configure NodeMaterial
  56984. */
  56985. export interface INodeMaterialOptions {
  56986. /**
  56987. * Defines if blocks should emit comments
  56988. */
  56989. emitComments: boolean;
  56990. }
  56991. /**
  56992. * Class used to create a node based material built by assembling shader blocks
  56993. */
  56994. export class NodeMaterial extends PushMaterial {
  56995. private static _BuildIdGenerator;
  56996. private _options;
  56997. private _vertexCompilationState;
  56998. private _fragmentCompilationState;
  56999. private _sharedData;
  57000. private _buildId;
  57001. private _buildWasSuccessful;
  57002. private _cachedWorldViewMatrix;
  57003. private _cachedWorldViewProjectionMatrix;
  57004. private _optimizers;
  57005. private _animationFrame;
  57006. /** Define the Url to load node editor script */
  57007. static EditorURL: string;
  57008. /** Define the Url to load snippets */
  57009. static SnippetUrl: string;
  57010. private BJSNODEMATERIALEDITOR;
  57011. /** Get the inspector from bundle or global */
  57012. private _getGlobalNodeMaterialEditor;
  57013. /**
  57014. * Gets or sets data used by visual editor
  57015. * @see https://nme.babylonjs.com
  57016. */
  57017. editorData: any;
  57018. /**
  57019. * 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)
  57020. */
  57021. ignoreAlpha: boolean;
  57022. /**
  57023. * Defines the maximum number of lights that can be used in the material
  57024. */
  57025. maxSimultaneousLights: number;
  57026. /**
  57027. * Observable raised when the material is built
  57028. */
  57029. onBuildObservable: Observable<NodeMaterial>;
  57030. /**
  57031. * Gets or sets the root nodes of the material vertex shader
  57032. */
  57033. _vertexOutputNodes: NodeMaterialBlock[];
  57034. /**
  57035. * Gets or sets the root nodes of the material fragment (pixel) shader
  57036. */
  57037. _fragmentOutputNodes: NodeMaterialBlock[];
  57038. /** Gets or sets options to control the node material overall behavior */
  57039. get options(): INodeMaterialOptions;
  57040. set options(options: INodeMaterialOptions);
  57041. /**
  57042. * Default configuration related to image processing available in the standard Material.
  57043. */
  57044. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57045. /**
  57046. * Gets the image processing configuration used either in this material.
  57047. */
  57048. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57049. /**
  57050. * Sets the Default image processing configuration used either in the this material.
  57051. *
  57052. * If sets to null, the scene one is in use.
  57053. */
  57054. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57055. /**
  57056. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57057. */
  57058. attachedBlocks: NodeMaterialBlock[];
  57059. /**
  57060. * Create a new node based material
  57061. * @param name defines the material name
  57062. * @param scene defines the hosting scene
  57063. * @param options defines creation option
  57064. */
  57065. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57066. /**
  57067. * Gets the current class name of the material e.g. "NodeMaterial"
  57068. * @returns the class name
  57069. */
  57070. getClassName(): string;
  57071. /**
  57072. * Keep track of the image processing observer to allow dispose and replace.
  57073. */
  57074. private _imageProcessingObserver;
  57075. /**
  57076. * Attaches a new image processing configuration to the Standard Material.
  57077. * @param configuration
  57078. */
  57079. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57080. /**
  57081. * Get a block by its name
  57082. * @param name defines the name of the block to retrieve
  57083. * @returns the required block or null if not found
  57084. */
  57085. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57086. /**
  57087. * Get a block by its name
  57088. * @param predicate defines the predicate used to find the good candidate
  57089. * @returns the required block or null if not found
  57090. */
  57091. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57092. /**
  57093. * Get an input block by its name
  57094. * @param predicate defines the predicate used to find the good candidate
  57095. * @returns the required input block or null if not found
  57096. */
  57097. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57098. /**
  57099. * Gets the list of input blocks attached to this material
  57100. * @returns an array of InputBlocks
  57101. */
  57102. getInputBlocks(): InputBlock[];
  57103. /**
  57104. * Adds a new optimizer to the list of optimizers
  57105. * @param optimizer defines the optimizers to add
  57106. * @returns the current material
  57107. */
  57108. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57109. /**
  57110. * Remove an optimizer from the list of optimizers
  57111. * @param optimizer defines the optimizers to remove
  57112. * @returns the current material
  57113. */
  57114. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57115. /**
  57116. * Add a new block to the list of output nodes
  57117. * @param node defines the node to add
  57118. * @returns the current material
  57119. */
  57120. addOutputNode(node: NodeMaterialBlock): this;
  57121. /**
  57122. * Remove a block from the list of root nodes
  57123. * @param node defines the node to remove
  57124. * @returns the current material
  57125. */
  57126. removeOutputNode(node: NodeMaterialBlock): this;
  57127. private _addVertexOutputNode;
  57128. private _removeVertexOutputNode;
  57129. private _addFragmentOutputNode;
  57130. private _removeFragmentOutputNode;
  57131. /**
  57132. * Specifies if the material will require alpha blending
  57133. * @returns a boolean specifying if alpha blending is needed
  57134. */
  57135. needAlphaBlending(): boolean;
  57136. /**
  57137. * Specifies if this material should be rendered in alpha test mode
  57138. * @returns a boolean specifying if an alpha test is needed.
  57139. */
  57140. needAlphaTesting(): boolean;
  57141. private _initializeBlock;
  57142. private _resetDualBlocks;
  57143. /**
  57144. * Remove a block from the current node material
  57145. * @param block defines the block to remove
  57146. */
  57147. removeBlock(block: NodeMaterialBlock): void;
  57148. /**
  57149. * Build the material and generates the inner effect
  57150. * @param verbose defines if the build should log activity
  57151. */
  57152. build(verbose?: boolean): void;
  57153. /**
  57154. * Runs an otpimization phase to try to improve the shader code
  57155. */
  57156. optimize(): void;
  57157. private _prepareDefinesForAttributes;
  57158. /**
  57159. * Get if the submesh is ready to be used and all its information available.
  57160. * Child classes can use it to update shaders
  57161. * @param mesh defines the mesh to check
  57162. * @param subMesh defines which submesh to check
  57163. * @param useInstances specifies that instances should be used
  57164. * @returns a boolean indicating that the submesh is ready or not
  57165. */
  57166. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57167. /**
  57168. * Get a string representing the shaders built by the current node graph
  57169. */
  57170. get compiledShaders(): string;
  57171. /**
  57172. * Binds the world matrix to the material
  57173. * @param world defines the world transformation matrix
  57174. */
  57175. bindOnlyWorldMatrix(world: Matrix): void;
  57176. /**
  57177. * Binds the submesh to this material by preparing the effect and shader to draw
  57178. * @param world defines the world transformation matrix
  57179. * @param mesh defines the mesh containing the submesh
  57180. * @param subMesh defines the submesh to bind the material to
  57181. */
  57182. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57183. /**
  57184. * Gets the active textures from the material
  57185. * @returns an array of textures
  57186. */
  57187. getActiveTextures(): BaseTexture[];
  57188. /**
  57189. * Gets the list of texture blocks
  57190. * @returns an array of texture blocks
  57191. */
  57192. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57193. /**
  57194. * Specifies if the material uses a texture
  57195. * @param texture defines the texture to check against the material
  57196. * @returns a boolean specifying if the material uses the texture
  57197. */
  57198. hasTexture(texture: BaseTexture): boolean;
  57199. /**
  57200. * Disposes the material
  57201. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57202. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57203. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57204. */
  57205. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57206. /** Creates the node editor window. */
  57207. private _createNodeEditor;
  57208. /**
  57209. * Launch the node material editor
  57210. * @param config Define the configuration of the editor
  57211. * @return a promise fulfilled when the node editor is visible
  57212. */
  57213. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57214. /**
  57215. * Clear the current material
  57216. */
  57217. clear(): void;
  57218. /**
  57219. * Clear the current material and set it to a default state
  57220. */
  57221. setToDefault(): void;
  57222. /**
  57223. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57224. * @param url defines the url to load from
  57225. * @returns a promise that will fullfil when the material is fully loaded
  57226. */
  57227. loadAsync(url: string): Promise<void>;
  57228. private _gatherBlocks;
  57229. /**
  57230. * Generate a string containing the code declaration required to create an equivalent of this material
  57231. * @returns a string
  57232. */
  57233. generateCode(): string;
  57234. /**
  57235. * Serializes this material in a JSON representation
  57236. * @returns the serialized material object
  57237. */
  57238. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57239. private _restoreConnections;
  57240. /**
  57241. * Clear the current graph and load a new one from a serialization object
  57242. * @param source defines the JSON representation of the material
  57243. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57244. */
  57245. loadFromSerialization(source: any, rootUrl?: string): void;
  57246. /**
  57247. * Creates a node material from parsed material data
  57248. * @param source defines the JSON representation of the material
  57249. * @param scene defines the hosting scene
  57250. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57251. * @returns a new node material
  57252. */
  57253. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57254. /**
  57255. * Creates a node material from a snippet saved in a remote file
  57256. * @param name defines the name of the material to create
  57257. * @param url defines the url to load from
  57258. * @param scene defines the hosting scene
  57259. * @returns a promise that will resolve to the new node material
  57260. */
  57261. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57262. /**
  57263. * Creates a node material from a snippet saved by the node material editor
  57264. * @param snippetId defines the snippet to load
  57265. * @param scene defines the hosting scene
  57266. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57267. * @returns a promise that will resolve to the new node material
  57268. */
  57269. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57270. /**
  57271. * Creates a new node material set to default basic configuration
  57272. * @param name defines the name of the material
  57273. * @param scene defines the hosting scene
  57274. * @returns a new NodeMaterial
  57275. */
  57276. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57277. }
  57278. }
  57279. declare module BABYLON {
  57280. /**
  57281. * Block used to read a texture from a sampler
  57282. */
  57283. export class TextureBlock extends NodeMaterialBlock {
  57284. private _defineName;
  57285. private _linearDefineName;
  57286. private _tempTextureRead;
  57287. private _samplerName;
  57288. private _transformedUVName;
  57289. private _textureTransformName;
  57290. private _textureInfoName;
  57291. private _mainUVName;
  57292. private _mainUVDefineName;
  57293. /**
  57294. * Gets or sets the texture associated with the node
  57295. */
  57296. texture: Nullable<Texture>;
  57297. /**
  57298. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57299. */
  57300. convertToGammaSpace: boolean;
  57301. /**
  57302. * Create a new TextureBlock
  57303. * @param name defines the block name
  57304. */
  57305. constructor(name: string);
  57306. /**
  57307. * Gets the current class name
  57308. * @returns the class name
  57309. */
  57310. getClassName(): string;
  57311. /**
  57312. * Gets the uv input component
  57313. */
  57314. get uv(): NodeMaterialConnectionPoint;
  57315. /**
  57316. * Gets the rgba output component
  57317. */
  57318. get rgba(): NodeMaterialConnectionPoint;
  57319. /**
  57320. * Gets the rgb output component
  57321. */
  57322. get rgb(): NodeMaterialConnectionPoint;
  57323. /**
  57324. * Gets the r output component
  57325. */
  57326. get r(): NodeMaterialConnectionPoint;
  57327. /**
  57328. * Gets the g output component
  57329. */
  57330. get g(): NodeMaterialConnectionPoint;
  57331. /**
  57332. * Gets the b output component
  57333. */
  57334. get b(): NodeMaterialConnectionPoint;
  57335. /**
  57336. * Gets the a output component
  57337. */
  57338. get a(): NodeMaterialConnectionPoint;
  57339. get target(): NodeMaterialBlockTargets;
  57340. autoConfigure(material: NodeMaterial): void;
  57341. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57343. isReady(): boolean;
  57344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57345. private get _isMixed();
  57346. private _injectVertexCode;
  57347. private _writeTextureRead;
  57348. private _writeOutput;
  57349. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57350. protected _dumpPropertiesCode(): string;
  57351. serialize(): any;
  57352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57353. }
  57354. }
  57355. declare module BABYLON {
  57356. /**
  57357. * Class used to store shared data between 2 NodeMaterialBuildState
  57358. */
  57359. export class NodeMaterialBuildStateSharedData {
  57360. /**
  57361. * Gets the list of emitted varyings
  57362. */
  57363. temps: string[];
  57364. /**
  57365. * Gets the list of emitted varyings
  57366. */
  57367. varyings: string[];
  57368. /**
  57369. * Gets the varying declaration string
  57370. */
  57371. varyingDeclaration: string;
  57372. /**
  57373. * Input blocks
  57374. */
  57375. inputBlocks: InputBlock[];
  57376. /**
  57377. * Input blocks
  57378. */
  57379. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57380. /**
  57381. * Bindable blocks (Blocks that need to set data to the effect)
  57382. */
  57383. bindableBlocks: NodeMaterialBlock[];
  57384. /**
  57385. * List of blocks that can provide a compilation fallback
  57386. */
  57387. blocksWithFallbacks: NodeMaterialBlock[];
  57388. /**
  57389. * List of blocks that can provide a define update
  57390. */
  57391. blocksWithDefines: NodeMaterialBlock[];
  57392. /**
  57393. * List of blocks that can provide a repeatable content
  57394. */
  57395. repeatableContentBlocks: NodeMaterialBlock[];
  57396. /**
  57397. * List of blocks that can provide a dynamic list of uniforms
  57398. */
  57399. dynamicUniformBlocks: NodeMaterialBlock[];
  57400. /**
  57401. * List of blocks that can block the isReady function for the material
  57402. */
  57403. blockingBlocks: NodeMaterialBlock[];
  57404. /**
  57405. * Gets the list of animated inputs
  57406. */
  57407. animatedInputs: InputBlock[];
  57408. /**
  57409. * Build Id used to avoid multiple recompilations
  57410. */
  57411. buildId: number;
  57412. /** List of emitted variables */
  57413. variableNames: {
  57414. [key: string]: number;
  57415. };
  57416. /** List of emitted defines */
  57417. defineNames: {
  57418. [key: string]: number;
  57419. };
  57420. /** Should emit comments? */
  57421. emitComments: boolean;
  57422. /** Emit build activity */
  57423. verbose: boolean;
  57424. /** Gets or sets the hosting scene */
  57425. scene: Scene;
  57426. /**
  57427. * Gets the compilation hints emitted at compilation time
  57428. */
  57429. hints: {
  57430. needWorldViewMatrix: boolean;
  57431. needWorldViewProjectionMatrix: boolean;
  57432. needAlphaBlending: boolean;
  57433. needAlphaTesting: boolean;
  57434. };
  57435. /**
  57436. * List of compilation checks
  57437. */
  57438. checks: {
  57439. emitVertex: boolean;
  57440. emitFragment: boolean;
  57441. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57442. };
  57443. /** Creates a new shared data */
  57444. constructor();
  57445. /**
  57446. * Emits console errors and exceptions if there is a failing check
  57447. */
  57448. emitErrors(): void;
  57449. }
  57450. }
  57451. declare module BABYLON {
  57452. /**
  57453. * Class used to store node based material build state
  57454. */
  57455. export class NodeMaterialBuildState {
  57456. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57457. supportUniformBuffers: boolean;
  57458. /**
  57459. * Gets the list of emitted attributes
  57460. */
  57461. attributes: string[];
  57462. /**
  57463. * Gets the list of emitted uniforms
  57464. */
  57465. uniforms: string[];
  57466. /**
  57467. * Gets the list of emitted constants
  57468. */
  57469. constants: string[];
  57470. /**
  57471. * Gets the list of emitted samplers
  57472. */
  57473. samplers: string[];
  57474. /**
  57475. * Gets the list of emitted functions
  57476. */
  57477. functions: {
  57478. [key: string]: string;
  57479. };
  57480. /**
  57481. * Gets the list of emitted extensions
  57482. */
  57483. extensions: {
  57484. [key: string]: string;
  57485. };
  57486. /**
  57487. * Gets the target of the compilation state
  57488. */
  57489. target: NodeMaterialBlockTargets;
  57490. /**
  57491. * Gets the list of emitted counters
  57492. */
  57493. counters: {
  57494. [key: string]: number;
  57495. };
  57496. /**
  57497. * Shared data between multiple NodeMaterialBuildState instances
  57498. */
  57499. sharedData: NodeMaterialBuildStateSharedData;
  57500. /** @hidden */
  57501. _vertexState: NodeMaterialBuildState;
  57502. /** @hidden */
  57503. _attributeDeclaration: string;
  57504. /** @hidden */
  57505. _uniformDeclaration: string;
  57506. /** @hidden */
  57507. _constantDeclaration: string;
  57508. /** @hidden */
  57509. _samplerDeclaration: string;
  57510. /** @hidden */
  57511. _varyingTransfer: string;
  57512. private _repeatableContentAnchorIndex;
  57513. /** @hidden */
  57514. _builtCompilationString: string;
  57515. /**
  57516. * Gets the emitted compilation strings
  57517. */
  57518. compilationString: string;
  57519. /**
  57520. * Finalize the compilation strings
  57521. * @param state defines the current compilation state
  57522. */
  57523. finalize(state: NodeMaterialBuildState): void;
  57524. /** @hidden */
  57525. get _repeatableContentAnchor(): string;
  57526. /** @hidden */
  57527. _getFreeVariableName(prefix: string): string;
  57528. /** @hidden */
  57529. _getFreeDefineName(prefix: string): string;
  57530. /** @hidden */
  57531. _excludeVariableName(name: string): void;
  57532. /** @hidden */
  57533. _emit2DSampler(name: string): void;
  57534. /** @hidden */
  57535. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57536. /** @hidden */
  57537. _emitExtension(name: string, extension: string): void;
  57538. /** @hidden */
  57539. _emitFunction(name: string, code: string, comments: string): void;
  57540. /** @hidden */
  57541. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57542. replaceStrings?: {
  57543. search: RegExp;
  57544. replace: string;
  57545. }[];
  57546. repeatKey?: string;
  57547. }): string;
  57548. /** @hidden */
  57549. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57550. repeatKey?: string;
  57551. removeAttributes?: boolean;
  57552. removeUniforms?: boolean;
  57553. removeVaryings?: boolean;
  57554. removeIfDef?: boolean;
  57555. replaceStrings?: {
  57556. search: RegExp;
  57557. replace: string;
  57558. }[];
  57559. }, storeKey?: string): void;
  57560. /** @hidden */
  57561. _registerTempVariable(name: string): boolean;
  57562. /** @hidden */
  57563. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57564. /** @hidden */
  57565. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57566. /** @hidden */
  57567. _emitFloat(value: number): string;
  57568. }
  57569. }
  57570. declare module BABYLON {
  57571. /**
  57572. * Defines a block that can be used inside a node based material
  57573. */
  57574. export class NodeMaterialBlock {
  57575. private _buildId;
  57576. private _buildTarget;
  57577. private _target;
  57578. private _isFinalMerger;
  57579. private _isInput;
  57580. protected _isUnique: boolean;
  57581. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57582. inputsAreExclusive: boolean;
  57583. /** @hidden */
  57584. _codeVariableName: string;
  57585. /** @hidden */
  57586. _inputs: NodeMaterialConnectionPoint[];
  57587. /** @hidden */
  57588. _outputs: NodeMaterialConnectionPoint[];
  57589. /** @hidden */
  57590. _preparationId: number;
  57591. /**
  57592. * Gets or sets the name of the block
  57593. */
  57594. name: string;
  57595. /**
  57596. * Gets or sets the unique id of the node
  57597. */
  57598. uniqueId: number;
  57599. /**
  57600. * Gets or sets the comments associated with this block
  57601. */
  57602. comments: string;
  57603. /**
  57604. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57605. */
  57606. get isUnique(): boolean;
  57607. /**
  57608. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57609. */
  57610. get isFinalMerger(): boolean;
  57611. /**
  57612. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57613. */
  57614. get isInput(): boolean;
  57615. /**
  57616. * Gets or sets the build Id
  57617. */
  57618. get buildId(): number;
  57619. set buildId(value: number);
  57620. /**
  57621. * Gets or sets the target of the block
  57622. */
  57623. get target(): NodeMaterialBlockTargets;
  57624. set target(value: NodeMaterialBlockTargets);
  57625. /**
  57626. * Gets the list of input points
  57627. */
  57628. get inputs(): NodeMaterialConnectionPoint[];
  57629. /** Gets the list of output points */
  57630. get outputs(): NodeMaterialConnectionPoint[];
  57631. /**
  57632. * Find an input by its name
  57633. * @param name defines the name of the input to look for
  57634. * @returns the input or null if not found
  57635. */
  57636. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57637. /**
  57638. * Find an output by its name
  57639. * @param name defines the name of the outputto look for
  57640. * @returns the output or null if not found
  57641. */
  57642. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57643. /**
  57644. * Creates a new NodeMaterialBlock
  57645. * @param name defines the block name
  57646. * @param target defines the target of that block (Vertex by default)
  57647. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57648. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57649. */
  57650. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57651. /**
  57652. * Initialize the block and prepare the context for build
  57653. * @param state defines the state that will be used for the build
  57654. */
  57655. initialize(state: NodeMaterialBuildState): void;
  57656. /**
  57657. * Bind data to effect. Will only be called for blocks with isBindable === true
  57658. * @param effect defines the effect to bind data to
  57659. * @param nodeMaterial defines the hosting NodeMaterial
  57660. * @param mesh defines the mesh that will be rendered
  57661. */
  57662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57663. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57664. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57665. protected _writeFloat(value: number): string;
  57666. /**
  57667. * Gets the current class name e.g. "NodeMaterialBlock"
  57668. * @returns the class name
  57669. */
  57670. getClassName(): string;
  57671. /**
  57672. * Register a new input. Must be called inside a block constructor
  57673. * @param name defines the connection point name
  57674. * @param type defines the connection point type
  57675. * @param isOptional defines a boolean indicating that this input can be omitted
  57676. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57677. * @returns the current block
  57678. */
  57679. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57680. /**
  57681. * Register a new output. Must be called inside a block constructor
  57682. * @param name defines the connection point name
  57683. * @param type defines the connection point type
  57684. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57685. * @returns the current block
  57686. */
  57687. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57688. /**
  57689. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57690. * @param forOutput defines an optional connection point to check compatibility with
  57691. * @returns the first available input or null
  57692. */
  57693. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57694. /**
  57695. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57696. * @param forBlock defines an optional block to check compatibility with
  57697. * @returns the first available input or null
  57698. */
  57699. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57700. /**
  57701. * Gets the sibling of the given output
  57702. * @param current defines the current output
  57703. * @returns the next output in the list or null
  57704. */
  57705. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57706. /**
  57707. * Connect current block with another block
  57708. * @param other defines the block to connect with
  57709. * @param options define the various options to help pick the right connections
  57710. * @returns the current block
  57711. */
  57712. connectTo(other: NodeMaterialBlock, options?: {
  57713. input?: string;
  57714. output?: string;
  57715. outputSwizzle?: string;
  57716. }): this | undefined;
  57717. protected _buildBlock(state: NodeMaterialBuildState): void;
  57718. /**
  57719. * Add uniforms, samplers and uniform buffers at compilation time
  57720. * @param state defines the state to update
  57721. * @param nodeMaterial defines the node material requesting the update
  57722. * @param defines defines the material defines to update
  57723. * @param uniformBuffers defines the list of uniform buffer names
  57724. */
  57725. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57726. /**
  57727. * Add potential fallbacks if shader compilation fails
  57728. * @param mesh defines the mesh to be rendered
  57729. * @param fallbacks defines the current prioritized list of fallbacks
  57730. */
  57731. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57732. /**
  57733. * Initialize defines for shader compilation
  57734. * @param mesh defines the mesh to be rendered
  57735. * @param nodeMaterial defines the node material requesting the update
  57736. * @param defines defines the material defines to update
  57737. * @param useInstances specifies that instances should be used
  57738. */
  57739. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57740. /**
  57741. * Update defines for shader compilation
  57742. * @param mesh defines the mesh to be rendered
  57743. * @param nodeMaterial defines the node material requesting the update
  57744. * @param defines defines the material defines to update
  57745. * @param useInstances specifies that instances should be used
  57746. */
  57747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57748. /**
  57749. * Lets the block try to connect some inputs automatically
  57750. * @param material defines the hosting NodeMaterial
  57751. */
  57752. autoConfigure(material: NodeMaterial): void;
  57753. /**
  57754. * Function called when a block is declared as repeatable content generator
  57755. * @param vertexShaderState defines the current compilation state for the vertex shader
  57756. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57757. * @param mesh defines the mesh to be rendered
  57758. * @param defines defines the material defines to update
  57759. */
  57760. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57761. /**
  57762. * Checks if the block is ready
  57763. * @param mesh defines the mesh to be rendered
  57764. * @param nodeMaterial defines the node material requesting the update
  57765. * @param defines defines the material defines to update
  57766. * @param useInstances specifies that instances should be used
  57767. * @returns true if the block is ready
  57768. */
  57769. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57770. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57771. private _processBuild;
  57772. /**
  57773. * Compile the current node and generate the shader code
  57774. * @param state defines the current compilation state (uniforms, samplers, current string)
  57775. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57776. * @returns true if already built
  57777. */
  57778. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57779. protected _inputRename(name: string): string;
  57780. protected _outputRename(name: string): string;
  57781. protected _dumpPropertiesCode(): string;
  57782. /** @hidden */
  57783. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57784. /** @hidden */
  57785. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57786. /**
  57787. * Clone the current block to a new identical block
  57788. * @param scene defines the hosting scene
  57789. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57790. * @returns a copy of the current block
  57791. */
  57792. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57793. /**
  57794. * Serializes this block in a JSON representation
  57795. * @returns the serialized block object
  57796. */
  57797. serialize(): any;
  57798. /** @hidden */
  57799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57800. /**
  57801. * Release resources
  57802. */
  57803. dispose(): void;
  57804. }
  57805. }
  57806. declare module BABYLON {
  57807. /**
  57808. * Enum defining the type of animations supported by InputBlock
  57809. */
  57810. export enum AnimatedInputBlockTypes {
  57811. /** No animation */
  57812. None = 0,
  57813. /** Time based animation. Will only work for floats */
  57814. Time = 1
  57815. }
  57816. }
  57817. declare module BABYLON {
  57818. /**
  57819. * Block used to expose an input value
  57820. */
  57821. export class InputBlock extends NodeMaterialBlock {
  57822. private _mode;
  57823. private _associatedVariableName;
  57824. private _storedValue;
  57825. private _valueCallback;
  57826. private _type;
  57827. private _animationType;
  57828. /** Gets or set a value used to limit the range of float values */
  57829. min: number;
  57830. /** Gets or set a value used to limit the range of float values */
  57831. max: number;
  57832. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57833. isBoolean: boolean;
  57834. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57835. matrixMode: number;
  57836. /** @hidden */
  57837. _systemValue: Nullable<NodeMaterialSystemValues>;
  57838. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57839. visibleInInspector: boolean;
  57840. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57841. isConstant: boolean;
  57842. /** Gets or sets the group to use to display this block in the Inspector */
  57843. groupInInspector: string;
  57844. /** Gets an observable raised when the value is changed */
  57845. onValueChangedObservable: Observable<InputBlock>;
  57846. /**
  57847. * Gets or sets the connection point type (default is float)
  57848. */
  57849. get type(): NodeMaterialBlockConnectionPointTypes;
  57850. /**
  57851. * Creates a new InputBlock
  57852. * @param name defines the block name
  57853. * @param target defines the target of that block (Vertex by default)
  57854. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57855. */
  57856. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57857. /**
  57858. * Gets the output component
  57859. */
  57860. get output(): NodeMaterialConnectionPoint;
  57861. /**
  57862. * Set the source of this connection point to a vertex attribute
  57863. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57864. * @returns the current connection point
  57865. */
  57866. setAsAttribute(attributeName?: string): InputBlock;
  57867. /**
  57868. * Set the source of this connection point to a system value
  57869. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57870. * @returns the current connection point
  57871. */
  57872. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57873. /**
  57874. * Gets or sets the value of that point.
  57875. * Please note that this value will be ignored if valueCallback is defined
  57876. */
  57877. get value(): any;
  57878. set value(value: any);
  57879. /**
  57880. * Gets or sets a callback used to get the value of that point.
  57881. * Please note that setting this value will force the connection point to ignore the value property
  57882. */
  57883. get valueCallback(): () => any;
  57884. set valueCallback(value: () => any);
  57885. /**
  57886. * Gets or sets the associated variable name in the shader
  57887. */
  57888. get associatedVariableName(): string;
  57889. set associatedVariableName(value: string);
  57890. /** Gets or sets the type of animation applied to the input */
  57891. get animationType(): AnimatedInputBlockTypes;
  57892. set animationType(value: AnimatedInputBlockTypes);
  57893. /**
  57894. * Gets a boolean indicating that this connection point not defined yet
  57895. */
  57896. get isUndefined(): boolean;
  57897. /**
  57898. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57899. * In this case the connection point name must be the name of the uniform to use.
  57900. * Can only be set on inputs
  57901. */
  57902. get isUniform(): boolean;
  57903. set isUniform(value: boolean);
  57904. /**
  57905. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57906. * In this case the connection point name must be the name of the attribute to use
  57907. * Can only be set on inputs
  57908. */
  57909. get isAttribute(): boolean;
  57910. set isAttribute(value: boolean);
  57911. /**
  57912. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57913. * Can only be set on exit points
  57914. */
  57915. get isVarying(): boolean;
  57916. set isVarying(value: boolean);
  57917. /**
  57918. * Gets a boolean indicating that the current connection point is a system value
  57919. */
  57920. get isSystemValue(): boolean;
  57921. /**
  57922. * Gets or sets the current well known value or null if not defined as a system value
  57923. */
  57924. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57925. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57926. /**
  57927. * Gets the current class name
  57928. * @returns the class name
  57929. */
  57930. getClassName(): string;
  57931. /**
  57932. * Animate the input if animationType !== None
  57933. * @param scene defines the rendering scene
  57934. */
  57935. animate(scene: Scene): void;
  57936. private _emitDefine;
  57937. initialize(state: NodeMaterialBuildState): void;
  57938. /**
  57939. * Set the input block to its default value (based on its type)
  57940. */
  57941. setDefaultValue(): void;
  57942. private _emitConstant;
  57943. private _emit;
  57944. /** @hidden */
  57945. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57946. /** @hidden */
  57947. _transmit(effect: Effect, scene: Scene): void;
  57948. protected _buildBlock(state: NodeMaterialBuildState): void;
  57949. protected _dumpPropertiesCode(): string;
  57950. dispose(): void;
  57951. serialize(): any;
  57952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57953. }
  57954. }
  57955. declare module BABYLON {
  57956. /**
  57957. * Enum used to define the compatibility state between two connection points
  57958. */
  57959. export enum NodeMaterialConnectionPointCompatibilityStates {
  57960. /** Points are compatibles */
  57961. Compatible = 0,
  57962. /** Points are incompatible because of their types */
  57963. TypeIncompatible = 1,
  57964. /** Points are incompatible because of their targets (vertex vs fragment) */
  57965. TargetIncompatible = 2
  57966. }
  57967. /**
  57968. * Defines the direction of a connection point
  57969. */
  57970. export enum NodeMaterialConnectionPointDirection {
  57971. /** Input */
  57972. Input = 0,
  57973. /** Output */
  57974. Output = 1
  57975. }
  57976. /**
  57977. * Defines a connection point for a block
  57978. */
  57979. export class NodeMaterialConnectionPoint {
  57980. /** @hidden */
  57981. _ownerBlock: NodeMaterialBlock;
  57982. /** @hidden */
  57983. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57984. private _endpoints;
  57985. private _associatedVariableName;
  57986. private _direction;
  57987. /** @hidden */
  57988. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57989. /** @hidden */
  57990. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57991. private _type;
  57992. /** @hidden */
  57993. _enforceAssociatedVariableName: boolean;
  57994. /** Gets the direction of the point */
  57995. get direction(): NodeMaterialConnectionPointDirection;
  57996. /**
  57997. * Gets or sets the additional types supported by this connection point
  57998. */
  57999. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58000. /**
  58001. * Gets or sets the additional types excluded by this connection point
  58002. */
  58003. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58004. /**
  58005. * Observable triggered when this point is connected
  58006. */
  58007. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58008. /**
  58009. * Gets or sets the associated variable name in the shader
  58010. */
  58011. get associatedVariableName(): string;
  58012. set associatedVariableName(value: string);
  58013. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58014. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58015. /**
  58016. * Gets or sets the connection point type (default is float)
  58017. */
  58018. get type(): NodeMaterialBlockConnectionPointTypes;
  58019. set type(value: NodeMaterialBlockConnectionPointTypes);
  58020. /**
  58021. * Gets or sets the connection point name
  58022. */
  58023. name: string;
  58024. /**
  58025. * Gets or sets a boolean indicating that this connection point can be omitted
  58026. */
  58027. isOptional: boolean;
  58028. /**
  58029. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58030. */
  58031. define: string;
  58032. /** @hidden */
  58033. _prioritizeVertex: boolean;
  58034. private _target;
  58035. /** Gets or sets the target of that connection point */
  58036. get target(): NodeMaterialBlockTargets;
  58037. set target(value: NodeMaterialBlockTargets);
  58038. /**
  58039. * Gets a boolean indicating that the current point is connected
  58040. */
  58041. get isConnected(): boolean;
  58042. /**
  58043. * Gets a boolean indicating that the current point is connected to an input block
  58044. */
  58045. get isConnectedToInputBlock(): boolean;
  58046. /**
  58047. * Gets a the connected input block (if any)
  58048. */
  58049. get connectInputBlock(): Nullable<InputBlock>;
  58050. /** Get the other side of the connection (if any) */
  58051. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58052. /** Get the block that owns this connection point */
  58053. get ownerBlock(): NodeMaterialBlock;
  58054. /** Get the block connected on the other side of this connection (if any) */
  58055. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58056. /** Get the block connected on the endpoints of this connection (if any) */
  58057. get connectedBlocks(): Array<NodeMaterialBlock>;
  58058. /** Gets the list of connected endpoints */
  58059. get endpoints(): NodeMaterialConnectionPoint[];
  58060. /** Gets a boolean indicating if that output point is connected to at least one input */
  58061. get hasEndpoints(): boolean;
  58062. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58063. get isConnectedInVertexShader(): boolean;
  58064. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58065. get isConnectedInFragmentShader(): boolean;
  58066. /**
  58067. * Creates a new connection point
  58068. * @param name defines the connection point name
  58069. * @param ownerBlock defines the block hosting this connection point
  58070. * @param direction defines the direction of the connection point
  58071. */
  58072. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58073. /**
  58074. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58075. * @returns the class name
  58076. */
  58077. getClassName(): string;
  58078. /**
  58079. * Gets a boolean indicating if the current point can be connected to another point
  58080. * @param connectionPoint defines the other connection point
  58081. * @returns a boolean
  58082. */
  58083. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58084. /**
  58085. * Gets a number indicating if the current point can be connected to another point
  58086. * @param connectionPoint defines the other connection point
  58087. * @returns a number defining the compatibility state
  58088. */
  58089. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58090. /**
  58091. * Connect this point to another connection point
  58092. * @param connectionPoint defines the other connection point
  58093. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58094. * @returns the current connection point
  58095. */
  58096. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58097. /**
  58098. * Disconnect this point from one of his endpoint
  58099. * @param endpoint defines the other connection point
  58100. * @returns the current connection point
  58101. */
  58102. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58103. /**
  58104. * Serializes this point in a JSON representation
  58105. * @returns the serialized point object
  58106. */
  58107. serialize(): any;
  58108. /**
  58109. * Release resources
  58110. */
  58111. dispose(): void;
  58112. }
  58113. }
  58114. declare module BABYLON {
  58115. /**
  58116. * Block used to add support for vertex skinning (bones)
  58117. */
  58118. export class BonesBlock extends NodeMaterialBlock {
  58119. /**
  58120. * Creates a new BonesBlock
  58121. * @param name defines the block name
  58122. */
  58123. constructor(name: string);
  58124. /**
  58125. * Initialize the block and prepare the context for build
  58126. * @param state defines the state that will be used for the build
  58127. */
  58128. initialize(state: NodeMaterialBuildState): void;
  58129. /**
  58130. * Gets the current class name
  58131. * @returns the class name
  58132. */
  58133. getClassName(): string;
  58134. /**
  58135. * Gets the matrix indices input component
  58136. */
  58137. get matricesIndices(): NodeMaterialConnectionPoint;
  58138. /**
  58139. * Gets the matrix weights input component
  58140. */
  58141. get matricesWeights(): NodeMaterialConnectionPoint;
  58142. /**
  58143. * Gets the extra matrix indices input component
  58144. */
  58145. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58146. /**
  58147. * Gets the extra matrix weights input component
  58148. */
  58149. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58150. /**
  58151. * Gets the world input component
  58152. */
  58153. get world(): NodeMaterialConnectionPoint;
  58154. /**
  58155. * Gets the output component
  58156. */
  58157. get output(): NodeMaterialConnectionPoint;
  58158. autoConfigure(material: NodeMaterial): void;
  58159. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58162. protected _buildBlock(state: NodeMaterialBuildState): this;
  58163. }
  58164. }
  58165. declare module BABYLON {
  58166. /**
  58167. * Block used to add support for instances
  58168. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58169. */
  58170. export class InstancesBlock extends NodeMaterialBlock {
  58171. /**
  58172. * Creates a new InstancesBlock
  58173. * @param name defines the block name
  58174. */
  58175. constructor(name: string);
  58176. /**
  58177. * Gets the current class name
  58178. * @returns the class name
  58179. */
  58180. getClassName(): string;
  58181. /**
  58182. * Gets the first world row input component
  58183. */
  58184. get world0(): NodeMaterialConnectionPoint;
  58185. /**
  58186. * Gets the second world row input component
  58187. */
  58188. get world1(): NodeMaterialConnectionPoint;
  58189. /**
  58190. * Gets the third world row input component
  58191. */
  58192. get world2(): NodeMaterialConnectionPoint;
  58193. /**
  58194. * Gets the forth world row input component
  58195. */
  58196. get world3(): NodeMaterialConnectionPoint;
  58197. /**
  58198. * Gets the world input component
  58199. */
  58200. get world(): NodeMaterialConnectionPoint;
  58201. /**
  58202. * Gets the output component
  58203. */
  58204. get output(): NodeMaterialConnectionPoint;
  58205. /**
  58206. * Gets the isntanceID component
  58207. */
  58208. get instanceID(): NodeMaterialConnectionPoint;
  58209. autoConfigure(material: NodeMaterial): void;
  58210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58211. protected _buildBlock(state: NodeMaterialBuildState): this;
  58212. }
  58213. }
  58214. declare module BABYLON {
  58215. /**
  58216. * Block used to add morph targets support to vertex shader
  58217. */
  58218. export class MorphTargetsBlock extends NodeMaterialBlock {
  58219. private _repeatableContentAnchor;
  58220. /**
  58221. * Create a new MorphTargetsBlock
  58222. * @param name defines the block name
  58223. */
  58224. constructor(name: string);
  58225. /**
  58226. * Gets the current class name
  58227. * @returns the class name
  58228. */
  58229. getClassName(): string;
  58230. /**
  58231. * Gets the position input component
  58232. */
  58233. get position(): NodeMaterialConnectionPoint;
  58234. /**
  58235. * Gets the normal input component
  58236. */
  58237. get normal(): NodeMaterialConnectionPoint;
  58238. /**
  58239. * Gets the tangent input component
  58240. */
  58241. get tangent(): NodeMaterialConnectionPoint;
  58242. /**
  58243. * Gets the tangent input component
  58244. */
  58245. get uv(): NodeMaterialConnectionPoint;
  58246. /**
  58247. * Gets the position output component
  58248. */
  58249. get positionOutput(): NodeMaterialConnectionPoint;
  58250. /**
  58251. * Gets the normal output component
  58252. */
  58253. get normalOutput(): NodeMaterialConnectionPoint;
  58254. /**
  58255. * Gets the tangent output component
  58256. */
  58257. get tangentOutput(): NodeMaterialConnectionPoint;
  58258. /**
  58259. * Gets the tangent output component
  58260. */
  58261. get uvOutput(): NodeMaterialConnectionPoint;
  58262. initialize(state: NodeMaterialBuildState): void;
  58263. autoConfigure(material: NodeMaterial): void;
  58264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58266. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58267. protected _buildBlock(state: NodeMaterialBuildState): this;
  58268. }
  58269. }
  58270. declare module BABYLON {
  58271. /**
  58272. * Block used to get data information from a light
  58273. */
  58274. export class LightInformationBlock extends NodeMaterialBlock {
  58275. private _lightDataUniformName;
  58276. private _lightColorUniformName;
  58277. private _lightTypeDefineName;
  58278. /**
  58279. * Gets or sets the light associated with this block
  58280. */
  58281. light: Nullable<Light>;
  58282. /**
  58283. * Creates a new LightInformationBlock
  58284. * @param name defines the block name
  58285. */
  58286. constructor(name: string);
  58287. /**
  58288. * Gets the current class name
  58289. * @returns the class name
  58290. */
  58291. getClassName(): string;
  58292. /**
  58293. * Gets the world position input component
  58294. */
  58295. get worldPosition(): NodeMaterialConnectionPoint;
  58296. /**
  58297. * Gets the direction output component
  58298. */
  58299. get direction(): NodeMaterialConnectionPoint;
  58300. /**
  58301. * Gets the direction output component
  58302. */
  58303. get color(): NodeMaterialConnectionPoint;
  58304. /**
  58305. * Gets the direction output component
  58306. */
  58307. get intensity(): NodeMaterialConnectionPoint;
  58308. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58310. protected _buildBlock(state: NodeMaterialBuildState): this;
  58311. serialize(): any;
  58312. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58313. }
  58314. }
  58315. declare module BABYLON {
  58316. /**
  58317. * Block used to add image processing support to fragment shader
  58318. */
  58319. export class ImageProcessingBlock extends NodeMaterialBlock {
  58320. /**
  58321. * Create a new ImageProcessingBlock
  58322. * @param name defines the block name
  58323. */
  58324. constructor(name: string);
  58325. /**
  58326. * Gets the current class name
  58327. * @returns the class name
  58328. */
  58329. getClassName(): string;
  58330. /**
  58331. * Gets the color input component
  58332. */
  58333. get color(): NodeMaterialConnectionPoint;
  58334. /**
  58335. * Gets the output component
  58336. */
  58337. get output(): NodeMaterialConnectionPoint;
  58338. /**
  58339. * Initialize the block and prepare the context for build
  58340. * @param state defines the state that will be used for the build
  58341. */
  58342. initialize(state: NodeMaterialBuildState): void;
  58343. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58346. protected _buildBlock(state: NodeMaterialBuildState): this;
  58347. }
  58348. }
  58349. declare module BABYLON {
  58350. /**
  58351. * Block used to pertub normals based on a normal map
  58352. */
  58353. export class PerturbNormalBlock extends NodeMaterialBlock {
  58354. private _tangentSpaceParameterName;
  58355. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58356. invertX: boolean;
  58357. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58358. invertY: boolean;
  58359. /**
  58360. * Create a new PerturbNormalBlock
  58361. * @param name defines the block name
  58362. */
  58363. constructor(name: string);
  58364. /**
  58365. * Gets the current class name
  58366. * @returns the class name
  58367. */
  58368. getClassName(): string;
  58369. /**
  58370. * Gets the world position input component
  58371. */
  58372. get worldPosition(): NodeMaterialConnectionPoint;
  58373. /**
  58374. * Gets the world normal input component
  58375. */
  58376. get worldNormal(): NodeMaterialConnectionPoint;
  58377. /**
  58378. * Gets the world tangent input component
  58379. */
  58380. get worldTangent(): NodeMaterialConnectionPoint;
  58381. /**
  58382. * Gets the uv input component
  58383. */
  58384. get uv(): NodeMaterialConnectionPoint;
  58385. /**
  58386. * Gets the normal map color input component
  58387. */
  58388. get normalMapColor(): NodeMaterialConnectionPoint;
  58389. /**
  58390. * Gets the strength input component
  58391. */
  58392. get strength(): NodeMaterialConnectionPoint;
  58393. /**
  58394. * Gets the output component
  58395. */
  58396. get output(): NodeMaterialConnectionPoint;
  58397. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58398. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58399. autoConfigure(material: NodeMaterial): void;
  58400. protected _buildBlock(state: NodeMaterialBuildState): this;
  58401. protected _dumpPropertiesCode(): string;
  58402. serialize(): any;
  58403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58404. }
  58405. }
  58406. declare module BABYLON {
  58407. /**
  58408. * Block used to discard a pixel if a value is smaller than a cutoff
  58409. */
  58410. export class DiscardBlock extends NodeMaterialBlock {
  58411. /**
  58412. * Create a new DiscardBlock
  58413. * @param name defines the block name
  58414. */
  58415. constructor(name: string);
  58416. /**
  58417. * Gets the current class name
  58418. * @returns the class name
  58419. */
  58420. getClassName(): string;
  58421. /**
  58422. * Gets the color input component
  58423. */
  58424. get value(): NodeMaterialConnectionPoint;
  58425. /**
  58426. * Gets the cutoff input component
  58427. */
  58428. get cutoff(): NodeMaterialConnectionPoint;
  58429. protected _buildBlock(state: NodeMaterialBuildState): this;
  58430. }
  58431. }
  58432. declare module BABYLON {
  58433. /**
  58434. * Block used to test if the fragment shader is front facing
  58435. */
  58436. export class FrontFacingBlock extends NodeMaterialBlock {
  58437. /**
  58438. * Creates a new FrontFacingBlock
  58439. * @param name defines the block name
  58440. */
  58441. constructor(name: string);
  58442. /**
  58443. * Gets the current class name
  58444. * @returns the class name
  58445. */
  58446. getClassName(): string;
  58447. /**
  58448. * Gets the output component
  58449. */
  58450. get output(): NodeMaterialConnectionPoint;
  58451. protected _buildBlock(state: NodeMaterialBuildState): this;
  58452. }
  58453. }
  58454. declare module BABYLON {
  58455. /**
  58456. * Block used to get the derivative value on x and y of a given input
  58457. */
  58458. export class DerivativeBlock extends NodeMaterialBlock {
  58459. /**
  58460. * Create a new DerivativeBlock
  58461. * @param name defines the block name
  58462. */
  58463. constructor(name: string);
  58464. /**
  58465. * Gets the current class name
  58466. * @returns the class name
  58467. */
  58468. getClassName(): string;
  58469. /**
  58470. * Gets the input component
  58471. */
  58472. get input(): NodeMaterialConnectionPoint;
  58473. /**
  58474. * Gets the derivative output on x
  58475. */
  58476. get dx(): NodeMaterialConnectionPoint;
  58477. /**
  58478. * Gets the derivative output on y
  58479. */
  58480. get dy(): NodeMaterialConnectionPoint;
  58481. protected _buildBlock(state: NodeMaterialBuildState): this;
  58482. }
  58483. }
  58484. declare module BABYLON {
  58485. /**
  58486. * Block used to add support for scene fog
  58487. */
  58488. export class FogBlock extends NodeMaterialBlock {
  58489. private _fogDistanceName;
  58490. private _fogParameters;
  58491. /**
  58492. * Create a new FogBlock
  58493. * @param name defines the block name
  58494. */
  58495. constructor(name: string);
  58496. /**
  58497. * Gets the current class name
  58498. * @returns the class name
  58499. */
  58500. getClassName(): string;
  58501. /**
  58502. * Gets the world position input component
  58503. */
  58504. get worldPosition(): NodeMaterialConnectionPoint;
  58505. /**
  58506. * Gets the view input component
  58507. */
  58508. get view(): NodeMaterialConnectionPoint;
  58509. /**
  58510. * Gets the color input component
  58511. */
  58512. get input(): NodeMaterialConnectionPoint;
  58513. /**
  58514. * Gets the fog color input component
  58515. */
  58516. get fogColor(): NodeMaterialConnectionPoint;
  58517. /**
  58518. * Gets the output component
  58519. */
  58520. get output(): NodeMaterialConnectionPoint;
  58521. autoConfigure(material: NodeMaterial): void;
  58522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58523. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58524. protected _buildBlock(state: NodeMaterialBuildState): this;
  58525. }
  58526. }
  58527. declare module BABYLON {
  58528. /**
  58529. * Block used to add light in the fragment shader
  58530. */
  58531. export class LightBlock extends NodeMaterialBlock {
  58532. private _lightId;
  58533. /**
  58534. * Gets or sets the light associated with this block
  58535. */
  58536. light: Nullable<Light>;
  58537. /**
  58538. * Create a new LightBlock
  58539. * @param name defines the block name
  58540. */
  58541. constructor(name: string);
  58542. /**
  58543. * Gets the current class name
  58544. * @returns the class name
  58545. */
  58546. getClassName(): string;
  58547. /**
  58548. * Gets the world position input component
  58549. */
  58550. get worldPosition(): NodeMaterialConnectionPoint;
  58551. /**
  58552. * Gets the world normal input component
  58553. */
  58554. get worldNormal(): NodeMaterialConnectionPoint;
  58555. /**
  58556. * Gets the camera (or eye) position component
  58557. */
  58558. get cameraPosition(): NodeMaterialConnectionPoint;
  58559. /**
  58560. * Gets the glossiness component
  58561. */
  58562. get glossiness(): NodeMaterialConnectionPoint;
  58563. /**
  58564. * Gets the glossinness power component
  58565. */
  58566. get glossPower(): NodeMaterialConnectionPoint;
  58567. /**
  58568. * Gets the diffuse color component
  58569. */
  58570. get diffuseColor(): NodeMaterialConnectionPoint;
  58571. /**
  58572. * Gets the specular color component
  58573. */
  58574. get specularColor(): NodeMaterialConnectionPoint;
  58575. /**
  58576. * Gets the diffuse output component
  58577. */
  58578. get diffuseOutput(): NodeMaterialConnectionPoint;
  58579. /**
  58580. * Gets the specular output component
  58581. */
  58582. get specularOutput(): NodeMaterialConnectionPoint;
  58583. /**
  58584. * Gets the shadow output component
  58585. */
  58586. get shadow(): NodeMaterialConnectionPoint;
  58587. autoConfigure(material: NodeMaterial): void;
  58588. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58589. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58590. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58591. private _injectVertexCode;
  58592. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58593. serialize(): any;
  58594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58595. }
  58596. }
  58597. declare module BABYLON {
  58598. /**
  58599. * Block used to multiply 2 values
  58600. */
  58601. export class MultiplyBlock extends NodeMaterialBlock {
  58602. /**
  58603. * Creates a new MultiplyBlock
  58604. * @param name defines the block name
  58605. */
  58606. constructor(name: string);
  58607. /**
  58608. * Gets the current class name
  58609. * @returns the class name
  58610. */
  58611. getClassName(): string;
  58612. /**
  58613. * Gets the left operand input component
  58614. */
  58615. get left(): NodeMaterialConnectionPoint;
  58616. /**
  58617. * Gets the right operand input component
  58618. */
  58619. get right(): NodeMaterialConnectionPoint;
  58620. /**
  58621. * Gets the output component
  58622. */
  58623. get output(): NodeMaterialConnectionPoint;
  58624. protected _buildBlock(state: NodeMaterialBuildState): this;
  58625. }
  58626. }
  58627. declare module BABYLON {
  58628. /**
  58629. * Block used to add 2 vectors
  58630. */
  58631. export class AddBlock extends NodeMaterialBlock {
  58632. /**
  58633. * Creates a new AddBlock
  58634. * @param name defines the block name
  58635. */
  58636. constructor(name: string);
  58637. /**
  58638. * Gets the current class name
  58639. * @returns the class name
  58640. */
  58641. getClassName(): string;
  58642. /**
  58643. * Gets the left operand input component
  58644. */
  58645. get left(): NodeMaterialConnectionPoint;
  58646. /**
  58647. * Gets the right operand input component
  58648. */
  58649. get right(): NodeMaterialConnectionPoint;
  58650. /**
  58651. * Gets the output component
  58652. */
  58653. get output(): NodeMaterialConnectionPoint;
  58654. protected _buildBlock(state: NodeMaterialBuildState): this;
  58655. }
  58656. }
  58657. declare module BABYLON {
  58658. /**
  58659. * Block used to scale a vector by a float
  58660. */
  58661. export class ScaleBlock extends NodeMaterialBlock {
  58662. /**
  58663. * Creates a new ScaleBlock
  58664. * @param name defines the block name
  58665. */
  58666. constructor(name: string);
  58667. /**
  58668. * Gets the current class name
  58669. * @returns the class name
  58670. */
  58671. getClassName(): string;
  58672. /**
  58673. * Gets the input component
  58674. */
  58675. get input(): NodeMaterialConnectionPoint;
  58676. /**
  58677. * Gets the factor input component
  58678. */
  58679. get factor(): NodeMaterialConnectionPoint;
  58680. /**
  58681. * Gets the output component
  58682. */
  58683. get output(): NodeMaterialConnectionPoint;
  58684. protected _buildBlock(state: NodeMaterialBuildState): this;
  58685. }
  58686. }
  58687. declare module BABYLON {
  58688. /**
  58689. * Block used to clamp a float
  58690. */
  58691. export class ClampBlock extends NodeMaterialBlock {
  58692. /** Gets or sets the minimum range */
  58693. minimum: number;
  58694. /** Gets or sets the maximum range */
  58695. maximum: number;
  58696. /**
  58697. * Creates a new ClampBlock
  58698. * @param name defines the block name
  58699. */
  58700. constructor(name: string);
  58701. /**
  58702. * Gets the current class name
  58703. * @returns the class name
  58704. */
  58705. getClassName(): string;
  58706. /**
  58707. * Gets the value input component
  58708. */
  58709. get value(): NodeMaterialConnectionPoint;
  58710. /**
  58711. * Gets the output component
  58712. */
  58713. get output(): NodeMaterialConnectionPoint;
  58714. protected _buildBlock(state: NodeMaterialBuildState): this;
  58715. protected _dumpPropertiesCode(): string;
  58716. serialize(): any;
  58717. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58718. }
  58719. }
  58720. declare module BABYLON {
  58721. /**
  58722. * Block used to apply a cross product between 2 vectors
  58723. */
  58724. export class CrossBlock extends NodeMaterialBlock {
  58725. /**
  58726. * Creates a new CrossBlock
  58727. * @param name defines the block name
  58728. */
  58729. constructor(name: string);
  58730. /**
  58731. * Gets the current class name
  58732. * @returns the class name
  58733. */
  58734. getClassName(): string;
  58735. /**
  58736. * Gets the left operand input component
  58737. */
  58738. get left(): NodeMaterialConnectionPoint;
  58739. /**
  58740. * Gets the right operand input component
  58741. */
  58742. get right(): NodeMaterialConnectionPoint;
  58743. /**
  58744. * Gets the output component
  58745. */
  58746. get output(): NodeMaterialConnectionPoint;
  58747. protected _buildBlock(state: NodeMaterialBuildState): this;
  58748. }
  58749. }
  58750. declare module BABYLON {
  58751. /**
  58752. * Block used to apply a dot product between 2 vectors
  58753. */
  58754. export class DotBlock extends NodeMaterialBlock {
  58755. /**
  58756. * Creates a new DotBlock
  58757. * @param name defines the block name
  58758. */
  58759. constructor(name: string);
  58760. /**
  58761. * Gets the current class name
  58762. * @returns the class name
  58763. */
  58764. getClassName(): string;
  58765. /**
  58766. * Gets the left operand input component
  58767. */
  58768. get left(): NodeMaterialConnectionPoint;
  58769. /**
  58770. * Gets the right operand input component
  58771. */
  58772. get right(): NodeMaterialConnectionPoint;
  58773. /**
  58774. * Gets the output component
  58775. */
  58776. get output(): NodeMaterialConnectionPoint;
  58777. protected _buildBlock(state: NodeMaterialBuildState): this;
  58778. }
  58779. }
  58780. declare module BABYLON {
  58781. /**
  58782. * Block used to remap a float from a range to a new one
  58783. */
  58784. export class RemapBlock extends NodeMaterialBlock {
  58785. /**
  58786. * Gets or sets the source range
  58787. */
  58788. sourceRange: Vector2;
  58789. /**
  58790. * Gets or sets the target range
  58791. */
  58792. targetRange: Vector2;
  58793. /**
  58794. * Creates a new RemapBlock
  58795. * @param name defines the block name
  58796. */
  58797. constructor(name: string);
  58798. /**
  58799. * Gets the current class name
  58800. * @returns the class name
  58801. */
  58802. getClassName(): string;
  58803. /**
  58804. * Gets the input component
  58805. */
  58806. get input(): NodeMaterialConnectionPoint;
  58807. /**
  58808. * Gets the source min input component
  58809. */
  58810. get sourceMin(): NodeMaterialConnectionPoint;
  58811. /**
  58812. * Gets the source max input component
  58813. */
  58814. get sourceMax(): NodeMaterialConnectionPoint;
  58815. /**
  58816. * Gets the target min input component
  58817. */
  58818. get targetMin(): NodeMaterialConnectionPoint;
  58819. /**
  58820. * Gets the target max input component
  58821. */
  58822. get targetMax(): NodeMaterialConnectionPoint;
  58823. /**
  58824. * Gets the output component
  58825. */
  58826. get output(): NodeMaterialConnectionPoint;
  58827. protected _buildBlock(state: NodeMaterialBuildState): this;
  58828. protected _dumpPropertiesCode(): string;
  58829. serialize(): any;
  58830. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58831. }
  58832. }
  58833. declare module BABYLON {
  58834. /**
  58835. * Block used to normalize a vector
  58836. */
  58837. export class NormalizeBlock extends NodeMaterialBlock {
  58838. /**
  58839. * Creates a new NormalizeBlock
  58840. * @param name defines the block name
  58841. */
  58842. constructor(name: string);
  58843. /**
  58844. * Gets the current class name
  58845. * @returns the class name
  58846. */
  58847. getClassName(): string;
  58848. /**
  58849. * Gets the input component
  58850. */
  58851. get input(): NodeMaterialConnectionPoint;
  58852. /**
  58853. * Gets the output component
  58854. */
  58855. get output(): NodeMaterialConnectionPoint;
  58856. protected _buildBlock(state: NodeMaterialBuildState): this;
  58857. }
  58858. }
  58859. declare module BABYLON {
  58860. /**
  58861. * Operations supported by the Trigonometry block
  58862. */
  58863. export enum TrigonometryBlockOperations {
  58864. /** Cos */
  58865. Cos = 0,
  58866. /** Sin */
  58867. Sin = 1,
  58868. /** Abs */
  58869. Abs = 2,
  58870. /** Exp */
  58871. Exp = 3,
  58872. /** Exp2 */
  58873. Exp2 = 4,
  58874. /** Round */
  58875. Round = 5,
  58876. /** Floor */
  58877. Floor = 6,
  58878. /** Ceiling */
  58879. Ceiling = 7,
  58880. /** Square root */
  58881. Sqrt = 8,
  58882. /** Log */
  58883. Log = 9,
  58884. /** Tangent */
  58885. Tan = 10,
  58886. /** Arc tangent */
  58887. ArcTan = 11,
  58888. /** Arc cosinus */
  58889. ArcCos = 12,
  58890. /** Arc sinus */
  58891. ArcSin = 13,
  58892. /** Fraction */
  58893. Fract = 14,
  58894. /** Sign */
  58895. Sign = 15,
  58896. /** To radians (from degrees) */
  58897. Radians = 16,
  58898. /** To degrees (from radians) */
  58899. Degrees = 17
  58900. }
  58901. /**
  58902. * Block used to apply trigonometry operation to floats
  58903. */
  58904. export class TrigonometryBlock extends NodeMaterialBlock {
  58905. /**
  58906. * Gets or sets the operation applied by the block
  58907. */
  58908. operation: TrigonometryBlockOperations;
  58909. /**
  58910. * Creates a new TrigonometryBlock
  58911. * @param name defines the block name
  58912. */
  58913. constructor(name: string);
  58914. /**
  58915. * Gets the current class name
  58916. * @returns the class name
  58917. */
  58918. getClassName(): string;
  58919. /**
  58920. * Gets the input component
  58921. */
  58922. get input(): NodeMaterialConnectionPoint;
  58923. /**
  58924. * Gets the output component
  58925. */
  58926. get output(): NodeMaterialConnectionPoint;
  58927. protected _buildBlock(state: NodeMaterialBuildState): this;
  58928. serialize(): any;
  58929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58930. protected _dumpPropertiesCode(): string;
  58931. }
  58932. }
  58933. declare module BABYLON {
  58934. /**
  58935. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58936. */
  58937. export class ColorMergerBlock extends NodeMaterialBlock {
  58938. /**
  58939. * Create a new ColorMergerBlock
  58940. * @param name defines the block name
  58941. */
  58942. constructor(name: string);
  58943. /**
  58944. * Gets the current class name
  58945. * @returns the class name
  58946. */
  58947. getClassName(): string;
  58948. /**
  58949. * Gets the rgb component (input)
  58950. */
  58951. get rgbIn(): NodeMaterialConnectionPoint;
  58952. /**
  58953. * Gets the r component (input)
  58954. */
  58955. get r(): NodeMaterialConnectionPoint;
  58956. /**
  58957. * Gets the g component (input)
  58958. */
  58959. get g(): NodeMaterialConnectionPoint;
  58960. /**
  58961. * Gets the b component (input)
  58962. */
  58963. get b(): NodeMaterialConnectionPoint;
  58964. /**
  58965. * Gets the a component (input)
  58966. */
  58967. get a(): NodeMaterialConnectionPoint;
  58968. /**
  58969. * Gets the rgba component (output)
  58970. */
  58971. get rgba(): NodeMaterialConnectionPoint;
  58972. /**
  58973. * Gets the rgb component (output)
  58974. */
  58975. get rgbOut(): NodeMaterialConnectionPoint;
  58976. /**
  58977. * Gets the rgb component (output)
  58978. * @deprecated Please use rgbOut instead.
  58979. */
  58980. get rgb(): NodeMaterialConnectionPoint;
  58981. protected _buildBlock(state: NodeMaterialBuildState): this;
  58982. }
  58983. }
  58984. declare module BABYLON {
  58985. /**
  58986. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58987. */
  58988. export class VectorMergerBlock extends NodeMaterialBlock {
  58989. /**
  58990. * Create a new VectorMergerBlock
  58991. * @param name defines the block name
  58992. */
  58993. constructor(name: string);
  58994. /**
  58995. * Gets the current class name
  58996. * @returns the class name
  58997. */
  58998. getClassName(): string;
  58999. /**
  59000. * Gets the xyz component (input)
  59001. */
  59002. get xyzIn(): NodeMaterialConnectionPoint;
  59003. /**
  59004. * Gets the xy component (input)
  59005. */
  59006. get xyIn(): NodeMaterialConnectionPoint;
  59007. /**
  59008. * Gets the x component (input)
  59009. */
  59010. get x(): NodeMaterialConnectionPoint;
  59011. /**
  59012. * Gets the y component (input)
  59013. */
  59014. get y(): NodeMaterialConnectionPoint;
  59015. /**
  59016. * Gets the z component (input)
  59017. */
  59018. get z(): NodeMaterialConnectionPoint;
  59019. /**
  59020. * Gets the w component (input)
  59021. */
  59022. get w(): NodeMaterialConnectionPoint;
  59023. /**
  59024. * Gets the xyzw component (output)
  59025. */
  59026. get xyzw(): NodeMaterialConnectionPoint;
  59027. /**
  59028. * Gets the xyz component (output)
  59029. */
  59030. get xyzOut(): NodeMaterialConnectionPoint;
  59031. /**
  59032. * Gets the xy component (output)
  59033. */
  59034. get xyOut(): NodeMaterialConnectionPoint;
  59035. /**
  59036. * Gets the xy component (output)
  59037. * @deprecated Please use xyOut instead.
  59038. */
  59039. get xy(): NodeMaterialConnectionPoint;
  59040. /**
  59041. * Gets the xyz component (output)
  59042. * @deprecated Please use xyzOut instead.
  59043. */
  59044. get xyz(): NodeMaterialConnectionPoint;
  59045. protected _buildBlock(state: NodeMaterialBuildState): this;
  59046. }
  59047. }
  59048. declare module BABYLON {
  59049. /**
  59050. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59051. */
  59052. export class ColorSplitterBlock extends NodeMaterialBlock {
  59053. /**
  59054. * Create a new ColorSplitterBlock
  59055. * @param name defines the block name
  59056. */
  59057. constructor(name: string);
  59058. /**
  59059. * Gets the current class name
  59060. * @returns the class name
  59061. */
  59062. getClassName(): string;
  59063. /**
  59064. * Gets the rgba component (input)
  59065. */
  59066. get rgba(): NodeMaterialConnectionPoint;
  59067. /**
  59068. * Gets the rgb component (input)
  59069. */
  59070. get rgbIn(): NodeMaterialConnectionPoint;
  59071. /**
  59072. * Gets the rgb component (output)
  59073. */
  59074. get rgbOut(): NodeMaterialConnectionPoint;
  59075. /**
  59076. * Gets the r component (output)
  59077. */
  59078. get r(): NodeMaterialConnectionPoint;
  59079. /**
  59080. * Gets the g component (output)
  59081. */
  59082. get g(): NodeMaterialConnectionPoint;
  59083. /**
  59084. * Gets the b component (output)
  59085. */
  59086. get b(): NodeMaterialConnectionPoint;
  59087. /**
  59088. * Gets the a component (output)
  59089. */
  59090. get a(): NodeMaterialConnectionPoint;
  59091. protected _inputRename(name: string): string;
  59092. protected _outputRename(name: string): string;
  59093. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59094. }
  59095. }
  59096. declare module BABYLON {
  59097. /**
  59098. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59099. */
  59100. export class VectorSplitterBlock extends NodeMaterialBlock {
  59101. /**
  59102. * Create a new VectorSplitterBlock
  59103. * @param name defines the block name
  59104. */
  59105. constructor(name: string);
  59106. /**
  59107. * Gets the current class name
  59108. * @returns the class name
  59109. */
  59110. getClassName(): string;
  59111. /**
  59112. * Gets the xyzw component (input)
  59113. */
  59114. get xyzw(): NodeMaterialConnectionPoint;
  59115. /**
  59116. * Gets the xyz component (input)
  59117. */
  59118. get xyzIn(): NodeMaterialConnectionPoint;
  59119. /**
  59120. * Gets the xy component (input)
  59121. */
  59122. get xyIn(): NodeMaterialConnectionPoint;
  59123. /**
  59124. * Gets the xyz component (output)
  59125. */
  59126. get xyzOut(): NodeMaterialConnectionPoint;
  59127. /**
  59128. * Gets the xy component (output)
  59129. */
  59130. get xyOut(): NodeMaterialConnectionPoint;
  59131. /**
  59132. * Gets the x component (output)
  59133. */
  59134. get x(): NodeMaterialConnectionPoint;
  59135. /**
  59136. * Gets the y component (output)
  59137. */
  59138. get y(): NodeMaterialConnectionPoint;
  59139. /**
  59140. * Gets the z component (output)
  59141. */
  59142. get z(): NodeMaterialConnectionPoint;
  59143. /**
  59144. * Gets the w component (output)
  59145. */
  59146. get w(): NodeMaterialConnectionPoint;
  59147. protected _inputRename(name: string): string;
  59148. protected _outputRename(name: string): string;
  59149. protected _buildBlock(state: NodeMaterialBuildState): this;
  59150. }
  59151. }
  59152. declare module BABYLON {
  59153. /**
  59154. * Block used to lerp between 2 values
  59155. */
  59156. export class LerpBlock extends NodeMaterialBlock {
  59157. /**
  59158. * Creates a new LerpBlock
  59159. * @param name defines the block name
  59160. */
  59161. constructor(name: string);
  59162. /**
  59163. * Gets the current class name
  59164. * @returns the class name
  59165. */
  59166. getClassName(): string;
  59167. /**
  59168. * Gets the left operand input component
  59169. */
  59170. get left(): NodeMaterialConnectionPoint;
  59171. /**
  59172. * Gets the right operand input component
  59173. */
  59174. get right(): NodeMaterialConnectionPoint;
  59175. /**
  59176. * Gets the gradient operand input component
  59177. */
  59178. get gradient(): NodeMaterialConnectionPoint;
  59179. /**
  59180. * Gets the output component
  59181. */
  59182. get output(): NodeMaterialConnectionPoint;
  59183. protected _buildBlock(state: NodeMaterialBuildState): this;
  59184. }
  59185. }
  59186. declare module BABYLON {
  59187. /**
  59188. * Block used to divide 2 vectors
  59189. */
  59190. export class DivideBlock extends NodeMaterialBlock {
  59191. /**
  59192. * Creates a new DivideBlock
  59193. * @param name defines the block name
  59194. */
  59195. constructor(name: string);
  59196. /**
  59197. * Gets the current class name
  59198. * @returns the class name
  59199. */
  59200. getClassName(): string;
  59201. /**
  59202. * Gets the left operand input component
  59203. */
  59204. get left(): NodeMaterialConnectionPoint;
  59205. /**
  59206. * Gets the right operand input component
  59207. */
  59208. get right(): NodeMaterialConnectionPoint;
  59209. /**
  59210. * Gets the output component
  59211. */
  59212. get output(): NodeMaterialConnectionPoint;
  59213. protected _buildBlock(state: NodeMaterialBuildState): this;
  59214. }
  59215. }
  59216. declare module BABYLON {
  59217. /**
  59218. * Block used to subtract 2 vectors
  59219. */
  59220. export class SubtractBlock extends NodeMaterialBlock {
  59221. /**
  59222. * Creates a new SubtractBlock
  59223. * @param name defines the block name
  59224. */
  59225. constructor(name: string);
  59226. /**
  59227. * Gets the current class name
  59228. * @returns the class name
  59229. */
  59230. getClassName(): string;
  59231. /**
  59232. * Gets the left operand input component
  59233. */
  59234. get left(): NodeMaterialConnectionPoint;
  59235. /**
  59236. * Gets the right operand input component
  59237. */
  59238. get right(): NodeMaterialConnectionPoint;
  59239. /**
  59240. * Gets the output component
  59241. */
  59242. get output(): NodeMaterialConnectionPoint;
  59243. protected _buildBlock(state: NodeMaterialBuildState): this;
  59244. }
  59245. }
  59246. declare module BABYLON {
  59247. /**
  59248. * Block used to step a value
  59249. */
  59250. export class StepBlock extends NodeMaterialBlock {
  59251. /**
  59252. * Creates a new StepBlock
  59253. * @param name defines the block name
  59254. */
  59255. constructor(name: string);
  59256. /**
  59257. * Gets the current class name
  59258. * @returns the class name
  59259. */
  59260. getClassName(): string;
  59261. /**
  59262. * Gets the value operand input component
  59263. */
  59264. get value(): NodeMaterialConnectionPoint;
  59265. /**
  59266. * Gets the edge operand input component
  59267. */
  59268. get edge(): NodeMaterialConnectionPoint;
  59269. /**
  59270. * Gets the output component
  59271. */
  59272. get output(): NodeMaterialConnectionPoint;
  59273. protected _buildBlock(state: NodeMaterialBuildState): this;
  59274. }
  59275. }
  59276. declare module BABYLON {
  59277. /**
  59278. * Block used to get the opposite (1 - x) of a value
  59279. */
  59280. export class OneMinusBlock extends NodeMaterialBlock {
  59281. /**
  59282. * Creates a new OneMinusBlock
  59283. * @param name defines the block name
  59284. */
  59285. constructor(name: string);
  59286. /**
  59287. * Gets the current class name
  59288. * @returns the class name
  59289. */
  59290. getClassName(): string;
  59291. /**
  59292. * Gets the input component
  59293. */
  59294. get input(): NodeMaterialConnectionPoint;
  59295. /**
  59296. * Gets the output component
  59297. */
  59298. get output(): NodeMaterialConnectionPoint;
  59299. protected _buildBlock(state: NodeMaterialBuildState): this;
  59300. }
  59301. }
  59302. declare module BABYLON {
  59303. /**
  59304. * Block used to get the view direction
  59305. */
  59306. export class ViewDirectionBlock extends NodeMaterialBlock {
  59307. /**
  59308. * Creates a new ViewDirectionBlock
  59309. * @param name defines the block name
  59310. */
  59311. constructor(name: string);
  59312. /**
  59313. * Gets the current class name
  59314. * @returns the class name
  59315. */
  59316. getClassName(): string;
  59317. /**
  59318. * Gets the world position component
  59319. */
  59320. get worldPosition(): NodeMaterialConnectionPoint;
  59321. /**
  59322. * Gets the camera position component
  59323. */
  59324. get cameraPosition(): NodeMaterialConnectionPoint;
  59325. /**
  59326. * Gets the output component
  59327. */
  59328. get output(): NodeMaterialConnectionPoint;
  59329. autoConfigure(material: NodeMaterial): void;
  59330. protected _buildBlock(state: NodeMaterialBuildState): this;
  59331. }
  59332. }
  59333. declare module BABYLON {
  59334. /**
  59335. * Block used to compute fresnel value
  59336. */
  59337. export class FresnelBlock extends NodeMaterialBlock {
  59338. /**
  59339. * Create a new FresnelBlock
  59340. * @param name defines the block name
  59341. */
  59342. constructor(name: string);
  59343. /**
  59344. * Gets the current class name
  59345. * @returns the class name
  59346. */
  59347. getClassName(): string;
  59348. /**
  59349. * Gets the world normal input component
  59350. */
  59351. get worldNormal(): NodeMaterialConnectionPoint;
  59352. /**
  59353. * Gets the view direction input component
  59354. */
  59355. get viewDirection(): NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the bias input component
  59358. */
  59359. get bias(): NodeMaterialConnectionPoint;
  59360. /**
  59361. * Gets the camera (or eye) position component
  59362. */
  59363. get power(): NodeMaterialConnectionPoint;
  59364. /**
  59365. * Gets the fresnel output component
  59366. */
  59367. get fresnel(): NodeMaterialConnectionPoint;
  59368. autoConfigure(material: NodeMaterial): void;
  59369. protected _buildBlock(state: NodeMaterialBuildState): this;
  59370. }
  59371. }
  59372. declare module BABYLON {
  59373. /**
  59374. * Block used to get the max of 2 values
  59375. */
  59376. export class MaxBlock extends NodeMaterialBlock {
  59377. /**
  59378. * Creates a new MaxBlock
  59379. * @param name defines the block name
  59380. */
  59381. constructor(name: string);
  59382. /**
  59383. * Gets the current class name
  59384. * @returns the class name
  59385. */
  59386. getClassName(): string;
  59387. /**
  59388. * Gets the left operand input component
  59389. */
  59390. get left(): NodeMaterialConnectionPoint;
  59391. /**
  59392. * Gets the right operand input component
  59393. */
  59394. get right(): NodeMaterialConnectionPoint;
  59395. /**
  59396. * Gets the output component
  59397. */
  59398. get output(): NodeMaterialConnectionPoint;
  59399. protected _buildBlock(state: NodeMaterialBuildState): this;
  59400. }
  59401. }
  59402. declare module BABYLON {
  59403. /**
  59404. * Block used to get the min of 2 values
  59405. */
  59406. export class MinBlock extends NodeMaterialBlock {
  59407. /**
  59408. * Creates a new MinBlock
  59409. * @param name defines the block name
  59410. */
  59411. constructor(name: string);
  59412. /**
  59413. * Gets the current class name
  59414. * @returns the class name
  59415. */
  59416. getClassName(): string;
  59417. /**
  59418. * Gets the left operand input component
  59419. */
  59420. get left(): NodeMaterialConnectionPoint;
  59421. /**
  59422. * Gets the right operand input component
  59423. */
  59424. get right(): NodeMaterialConnectionPoint;
  59425. /**
  59426. * Gets the output component
  59427. */
  59428. get output(): NodeMaterialConnectionPoint;
  59429. protected _buildBlock(state: NodeMaterialBuildState): this;
  59430. }
  59431. }
  59432. declare module BABYLON {
  59433. /**
  59434. * Block used to get the distance between 2 values
  59435. */
  59436. export class DistanceBlock extends NodeMaterialBlock {
  59437. /**
  59438. * Creates a new DistanceBlock
  59439. * @param name defines the block name
  59440. */
  59441. constructor(name: string);
  59442. /**
  59443. * Gets the current class name
  59444. * @returns the class name
  59445. */
  59446. getClassName(): string;
  59447. /**
  59448. * Gets the left operand input component
  59449. */
  59450. get left(): NodeMaterialConnectionPoint;
  59451. /**
  59452. * Gets the right operand input component
  59453. */
  59454. get right(): NodeMaterialConnectionPoint;
  59455. /**
  59456. * Gets the output component
  59457. */
  59458. get output(): NodeMaterialConnectionPoint;
  59459. protected _buildBlock(state: NodeMaterialBuildState): this;
  59460. }
  59461. }
  59462. declare module BABYLON {
  59463. /**
  59464. * Block used to get the length of a vector
  59465. */
  59466. export class LengthBlock extends NodeMaterialBlock {
  59467. /**
  59468. * Creates a new LengthBlock
  59469. * @param name defines the block name
  59470. */
  59471. constructor(name: string);
  59472. /**
  59473. * Gets the current class name
  59474. * @returns the class name
  59475. */
  59476. getClassName(): string;
  59477. /**
  59478. * Gets the value input component
  59479. */
  59480. get value(): NodeMaterialConnectionPoint;
  59481. /**
  59482. * Gets the output component
  59483. */
  59484. get output(): NodeMaterialConnectionPoint;
  59485. protected _buildBlock(state: NodeMaterialBuildState): this;
  59486. }
  59487. }
  59488. declare module BABYLON {
  59489. /**
  59490. * Block used to get negative version of a value (i.e. x * -1)
  59491. */
  59492. export class NegateBlock extends NodeMaterialBlock {
  59493. /**
  59494. * Creates a new NegateBlock
  59495. * @param name defines the block name
  59496. */
  59497. constructor(name: string);
  59498. /**
  59499. * Gets the current class name
  59500. * @returns the class name
  59501. */
  59502. getClassName(): string;
  59503. /**
  59504. * Gets the value input component
  59505. */
  59506. get value(): NodeMaterialConnectionPoint;
  59507. /**
  59508. * Gets the output component
  59509. */
  59510. get output(): NodeMaterialConnectionPoint;
  59511. protected _buildBlock(state: NodeMaterialBuildState): this;
  59512. }
  59513. }
  59514. declare module BABYLON {
  59515. /**
  59516. * Block used to get the value of the first parameter raised to the power of the second
  59517. */
  59518. export class PowBlock extends NodeMaterialBlock {
  59519. /**
  59520. * Creates a new PowBlock
  59521. * @param name defines the block name
  59522. */
  59523. constructor(name: string);
  59524. /**
  59525. * Gets the current class name
  59526. * @returns the class name
  59527. */
  59528. getClassName(): string;
  59529. /**
  59530. * Gets the value operand input component
  59531. */
  59532. get value(): NodeMaterialConnectionPoint;
  59533. /**
  59534. * Gets the power operand input component
  59535. */
  59536. get power(): NodeMaterialConnectionPoint;
  59537. /**
  59538. * Gets the output component
  59539. */
  59540. get output(): NodeMaterialConnectionPoint;
  59541. protected _buildBlock(state: NodeMaterialBuildState): this;
  59542. }
  59543. }
  59544. declare module BABYLON {
  59545. /**
  59546. * Block used to get a random number
  59547. */
  59548. export class RandomNumberBlock extends NodeMaterialBlock {
  59549. /**
  59550. * Creates a new RandomNumberBlock
  59551. * @param name defines the block name
  59552. */
  59553. constructor(name: string);
  59554. /**
  59555. * Gets the current class name
  59556. * @returns the class name
  59557. */
  59558. getClassName(): string;
  59559. /**
  59560. * Gets the seed input component
  59561. */
  59562. get seed(): NodeMaterialConnectionPoint;
  59563. /**
  59564. * Gets the output component
  59565. */
  59566. get output(): NodeMaterialConnectionPoint;
  59567. protected _buildBlock(state: NodeMaterialBuildState): this;
  59568. }
  59569. }
  59570. declare module BABYLON {
  59571. /**
  59572. * Block used to compute arc tangent of 2 values
  59573. */
  59574. export class ArcTan2Block extends NodeMaterialBlock {
  59575. /**
  59576. * Creates a new ArcTan2Block
  59577. * @param name defines the block name
  59578. */
  59579. constructor(name: string);
  59580. /**
  59581. * Gets the current class name
  59582. * @returns the class name
  59583. */
  59584. getClassName(): string;
  59585. /**
  59586. * Gets the x operand input component
  59587. */
  59588. get x(): NodeMaterialConnectionPoint;
  59589. /**
  59590. * Gets the y operand input component
  59591. */
  59592. get y(): NodeMaterialConnectionPoint;
  59593. /**
  59594. * Gets the output component
  59595. */
  59596. get output(): NodeMaterialConnectionPoint;
  59597. protected _buildBlock(state: NodeMaterialBuildState): this;
  59598. }
  59599. }
  59600. declare module BABYLON {
  59601. /**
  59602. * Block used to smooth step a value
  59603. */
  59604. export class SmoothStepBlock extends NodeMaterialBlock {
  59605. /**
  59606. * Creates a new SmoothStepBlock
  59607. * @param name defines the block name
  59608. */
  59609. constructor(name: string);
  59610. /**
  59611. * Gets the current class name
  59612. * @returns the class name
  59613. */
  59614. getClassName(): string;
  59615. /**
  59616. * Gets the value operand input component
  59617. */
  59618. get value(): NodeMaterialConnectionPoint;
  59619. /**
  59620. * Gets the first edge operand input component
  59621. */
  59622. get edge0(): NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the second edge operand input component
  59625. */
  59626. get edge1(): NodeMaterialConnectionPoint;
  59627. /**
  59628. * Gets the output component
  59629. */
  59630. get output(): NodeMaterialConnectionPoint;
  59631. protected _buildBlock(state: NodeMaterialBuildState): this;
  59632. }
  59633. }
  59634. declare module BABYLON {
  59635. /**
  59636. * Block used to get the reciprocal (1 / x) of a value
  59637. */
  59638. export class ReciprocalBlock extends NodeMaterialBlock {
  59639. /**
  59640. * Creates a new ReciprocalBlock
  59641. * @param name defines the block name
  59642. */
  59643. constructor(name: string);
  59644. /**
  59645. * Gets the current class name
  59646. * @returns the class name
  59647. */
  59648. getClassName(): string;
  59649. /**
  59650. * Gets the input component
  59651. */
  59652. get input(): NodeMaterialConnectionPoint;
  59653. /**
  59654. * Gets the output component
  59655. */
  59656. get output(): NodeMaterialConnectionPoint;
  59657. protected _buildBlock(state: NodeMaterialBuildState): this;
  59658. }
  59659. }
  59660. declare module BABYLON {
  59661. /**
  59662. * Block used to replace a color by another one
  59663. */
  59664. export class ReplaceColorBlock extends NodeMaterialBlock {
  59665. /**
  59666. * Creates a new ReplaceColorBlock
  59667. * @param name defines the block name
  59668. */
  59669. constructor(name: string);
  59670. /**
  59671. * Gets the current class name
  59672. * @returns the class name
  59673. */
  59674. getClassName(): string;
  59675. /**
  59676. * Gets the value input component
  59677. */
  59678. get value(): NodeMaterialConnectionPoint;
  59679. /**
  59680. * Gets the reference input component
  59681. */
  59682. get reference(): NodeMaterialConnectionPoint;
  59683. /**
  59684. * Gets the distance input component
  59685. */
  59686. get distance(): NodeMaterialConnectionPoint;
  59687. /**
  59688. * Gets the replacement input component
  59689. */
  59690. get replacement(): NodeMaterialConnectionPoint;
  59691. /**
  59692. * Gets the output component
  59693. */
  59694. get output(): NodeMaterialConnectionPoint;
  59695. protected _buildBlock(state: NodeMaterialBuildState): this;
  59696. }
  59697. }
  59698. declare module BABYLON {
  59699. /**
  59700. * Block used to posterize a value
  59701. * @see https://en.wikipedia.org/wiki/Posterization
  59702. */
  59703. export class PosterizeBlock extends NodeMaterialBlock {
  59704. /**
  59705. * Creates a new PosterizeBlock
  59706. * @param name defines the block name
  59707. */
  59708. constructor(name: string);
  59709. /**
  59710. * Gets the current class name
  59711. * @returns the class name
  59712. */
  59713. getClassName(): string;
  59714. /**
  59715. * Gets the value input component
  59716. */
  59717. get value(): NodeMaterialConnectionPoint;
  59718. /**
  59719. * Gets the steps input component
  59720. */
  59721. get steps(): NodeMaterialConnectionPoint;
  59722. /**
  59723. * Gets the output component
  59724. */
  59725. get output(): NodeMaterialConnectionPoint;
  59726. protected _buildBlock(state: NodeMaterialBuildState): this;
  59727. }
  59728. }
  59729. declare module BABYLON {
  59730. /**
  59731. * Operations supported by the Wave block
  59732. */
  59733. export enum WaveBlockKind {
  59734. /** SawTooth */
  59735. SawTooth = 0,
  59736. /** Square */
  59737. Square = 1,
  59738. /** Triangle */
  59739. Triangle = 2
  59740. }
  59741. /**
  59742. * Block used to apply wave operation to floats
  59743. */
  59744. export class WaveBlock extends NodeMaterialBlock {
  59745. /**
  59746. * Gets or sets the kibnd of wave to be applied by the block
  59747. */
  59748. kind: WaveBlockKind;
  59749. /**
  59750. * Creates a new WaveBlock
  59751. * @param name defines the block name
  59752. */
  59753. constructor(name: string);
  59754. /**
  59755. * Gets the current class name
  59756. * @returns the class name
  59757. */
  59758. getClassName(): string;
  59759. /**
  59760. * Gets the input component
  59761. */
  59762. get input(): NodeMaterialConnectionPoint;
  59763. /**
  59764. * Gets the output component
  59765. */
  59766. get output(): NodeMaterialConnectionPoint;
  59767. protected _buildBlock(state: NodeMaterialBuildState): this;
  59768. serialize(): any;
  59769. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59770. }
  59771. }
  59772. declare module BABYLON {
  59773. /**
  59774. * Class used to store a color step for the GradientBlock
  59775. */
  59776. export class GradientBlockColorStep {
  59777. /**
  59778. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59779. */
  59780. step: number;
  59781. /**
  59782. * Gets or sets the color associated with this step
  59783. */
  59784. color: Color3;
  59785. /**
  59786. * Creates a new GradientBlockColorStep
  59787. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59788. * @param color defines the color associated with this step
  59789. */
  59790. constructor(
  59791. /**
  59792. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59793. */
  59794. step: number,
  59795. /**
  59796. * Gets or sets the color associated with this step
  59797. */
  59798. color: Color3);
  59799. }
  59800. /**
  59801. * Block used to return a color from a gradient based on an input value between 0 and 1
  59802. */
  59803. export class GradientBlock extends NodeMaterialBlock {
  59804. /**
  59805. * Gets or sets the list of color steps
  59806. */
  59807. colorSteps: GradientBlockColorStep[];
  59808. /**
  59809. * Creates a new GradientBlock
  59810. * @param name defines the block name
  59811. */
  59812. constructor(name: string);
  59813. /**
  59814. * Gets the current class name
  59815. * @returns the class name
  59816. */
  59817. getClassName(): string;
  59818. /**
  59819. * Gets the gradient input component
  59820. */
  59821. get gradient(): NodeMaterialConnectionPoint;
  59822. /**
  59823. * Gets the output component
  59824. */
  59825. get output(): NodeMaterialConnectionPoint;
  59826. private _writeColorConstant;
  59827. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59828. serialize(): any;
  59829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59830. protected _dumpPropertiesCode(): string;
  59831. }
  59832. }
  59833. declare module BABYLON {
  59834. /**
  59835. * Block used to normalize lerp between 2 values
  59836. */
  59837. export class NLerpBlock extends NodeMaterialBlock {
  59838. /**
  59839. * Creates a new NLerpBlock
  59840. * @param name defines the block name
  59841. */
  59842. constructor(name: string);
  59843. /**
  59844. * Gets the current class name
  59845. * @returns the class name
  59846. */
  59847. getClassName(): string;
  59848. /**
  59849. * Gets the left operand input component
  59850. */
  59851. get left(): NodeMaterialConnectionPoint;
  59852. /**
  59853. * Gets the right operand input component
  59854. */
  59855. get right(): NodeMaterialConnectionPoint;
  59856. /**
  59857. * Gets the gradient operand input component
  59858. */
  59859. get gradient(): NodeMaterialConnectionPoint;
  59860. /**
  59861. * Gets the output component
  59862. */
  59863. get output(): NodeMaterialConnectionPoint;
  59864. protected _buildBlock(state: NodeMaterialBuildState): this;
  59865. }
  59866. }
  59867. declare module BABYLON {
  59868. /**
  59869. * block used to Generate a Worley Noise 3D Noise Pattern
  59870. */
  59871. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59872. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59873. manhattanDistance: boolean;
  59874. /**
  59875. * Creates a new WorleyNoise3DBlock
  59876. * @param name defines the block name
  59877. */
  59878. constructor(name: string);
  59879. /**
  59880. * Gets the current class name
  59881. * @returns the class name
  59882. */
  59883. getClassName(): string;
  59884. /**
  59885. * Gets the seed input component
  59886. */
  59887. get seed(): NodeMaterialConnectionPoint;
  59888. /**
  59889. * Gets the jitter input component
  59890. */
  59891. get jitter(): NodeMaterialConnectionPoint;
  59892. /**
  59893. * Gets the output component
  59894. */
  59895. get output(): NodeMaterialConnectionPoint;
  59896. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59897. /**
  59898. * Exposes the properties to the UI?
  59899. */
  59900. protected _dumpPropertiesCode(): string;
  59901. /**
  59902. * Exposes the properties to the Seralize?
  59903. */
  59904. serialize(): any;
  59905. /**
  59906. * Exposes the properties to the deseralize?
  59907. */
  59908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59909. }
  59910. }
  59911. declare module BABYLON {
  59912. /**
  59913. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59914. */
  59915. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59916. /**
  59917. * Creates a new SimplexPerlin3DBlock
  59918. * @param name defines the block name
  59919. */
  59920. constructor(name: string);
  59921. /**
  59922. * Gets the current class name
  59923. * @returns the class name
  59924. */
  59925. getClassName(): string;
  59926. /**
  59927. * Gets the seed operand input component
  59928. */
  59929. get seed(): NodeMaterialConnectionPoint;
  59930. /**
  59931. * Gets the output component
  59932. */
  59933. get output(): NodeMaterialConnectionPoint;
  59934. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59935. }
  59936. }
  59937. declare module BABYLON {
  59938. /**
  59939. * Block used to blend normals
  59940. */
  59941. export class NormalBlendBlock extends NodeMaterialBlock {
  59942. /**
  59943. * Creates a new NormalBlendBlock
  59944. * @param name defines the block name
  59945. */
  59946. constructor(name: string);
  59947. /**
  59948. * Gets the current class name
  59949. * @returns the class name
  59950. */
  59951. getClassName(): string;
  59952. /**
  59953. * Gets the first input component
  59954. */
  59955. get normalMap0(): NodeMaterialConnectionPoint;
  59956. /**
  59957. * Gets the second input component
  59958. */
  59959. get normalMap1(): NodeMaterialConnectionPoint;
  59960. /**
  59961. * Gets the output component
  59962. */
  59963. get output(): NodeMaterialConnectionPoint;
  59964. protected _buildBlock(state: NodeMaterialBuildState): this;
  59965. }
  59966. }
  59967. declare module BABYLON {
  59968. /**
  59969. * Block used to rotate a 2d vector by a given angle
  59970. */
  59971. export class Rotate2dBlock extends NodeMaterialBlock {
  59972. /**
  59973. * Creates a new Rotate2dBlock
  59974. * @param name defines the block name
  59975. */
  59976. constructor(name: string);
  59977. /**
  59978. * Gets the current class name
  59979. * @returns the class name
  59980. */
  59981. getClassName(): string;
  59982. /**
  59983. * Gets the input vector
  59984. */
  59985. get input(): NodeMaterialConnectionPoint;
  59986. /**
  59987. * Gets the input angle
  59988. */
  59989. get angle(): NodeMaterialConnectionPoint;
  59990. /**
  59991. * Gets the output component
  59992. */
  59993. get output(): NodeMaterialConnectionPoint;
  59994. autoConfigure(material: NodeMaterial): void;
  59995. protected _buildBlock(state: NodeMaterialBuildState): this;
  59996. }
  59997. }
  59998. declare module BABYLON {
  59999. /**
  60000. * Block used to get the reflected vector from a direction and a normal
  60001. */
  60002. export class ReflectBlock extends NodeMaterialBlock {
  60003. /**
  60004. * Creates a new ReflectBlock
  60005. * @param name defines the block name
  60006. */
  60007. constructor(name: string);
  60008. /**
  60009. * Gets the current class name
  60010. * @returns the class name
  60011. */
  60012. getClassName(): string;
  60013. /**
  60014. * Gets the incident component
  60015. */
  60016. get incident(): NodeMaterialConnectionPoint;
  60017. /**
  60018. * Gets the normal component
  60019. */
  60020. get normal(): NodeMaterialConnectionPoint;
  60021. /**
  60022. * Gets the output component
  60023. */
  60024. get output(): NodeMaterialConnectionPoint;
  60025. protected _buildBlock(state: NodeMaterialBuildState): this;
  60026. }
  60027. }
  60028. declare module BABYLON {
  60029. /**
  60030. * Block used to get the refracted vector from a direction and a normal
  60031. */
  60032. export class RefractBlock extends NodeMaterialBlock {
  60033. /**
  60034. * Creates a new RefractBlock
  60035. * @param name defines the block name
  60036. */
  60037. constructor(name: string);
  60038. /**
  60039. * Gets the current class name
  60040. * @returns the class name
  60041. */
  60042. getClassName(): string;
  60043. /**
  60044. * Gets the incident component
  60045. */
  60046. get incident(): NodeMaterialConnectionPoint;
  60047. /**
  60048. * Gets the normal component
  60049. */
  60050. get normal(): NodeMaterialConnectionPoint;
  60051. /**
  60052. * Gets the index of refraction component
  60053. */
  60054. get ior(): NodeMaterialConnectionPoint;
  60055. /**
  60056. * Gets the output component
  60057. */
  60058. get output(): NodeMaterialConnectionPoint;
  60059. protected _buildBlock(state: NodeMaterialBuildState): this;
  60060. }
  60061. }
  60062. declare module BABYLON {
  60063. /**
  60064. * Block used to desaturate a color
  60065. */
  60066. export class DesaturateBlock extends NodeMaterialBlock {
  60067. /**
  60068. * Creates a new DesaturateBlock
  60069. * @param name defines the block name
  60070. */
  60071. constructor(name: string);
  60072. /**
  60073. * Gets the current class name
  60074. * @returns the class name
  60075. */
  60076. getClassName(): string;
  60077. /**
  60078. * Gets the color operand input component
  60079. */
  60080. get color(): NodeMaterialConnectionPoint;
  60081. /**
  60082. * Gets the level operand input component
  60083. */
  60084. get level(): NodeMaterialConnectionPoint;
  60085. /**
  60086. * Gets the output component
  60087. */
  60088. get output(): NodeMaterialConnectionPoint;
  60089. protected _buildBlock(state: NodeMaterialBuildState): this;
  60090. }
  60091. }
  60092. declare module BABYLON {
  60093. /**
  60094. * Effect Render Options
  60095. */
  60096. export interface IEffectRendererOptions {
  60097. /**
  60098. * Defines the vertices positions.
  60099. */
  60100. positions?: number[];
  60101. /**
  60102. * Defines the indices.
  60103. */
  60104. indices?: number[];
  60105. }
  60106. /**
  60107. * Helper class to render one or more effects
  60108. */
  60109. export class EffectRenderer {
  60110. private engine;
  60111. private static _DefaultOptions;
  60112. private _vertexBuffers;
  60113. private _indexBuffer;
  60114. private _ringBufferIndex;
  60115. private _ringScreenBuffer;
  60116. private _fullscreenViewport;
  60117. private _getNextFrameBuffer;
  60118. /**
  60119. * Creates an effect renderer
  60120. * @param engine the engine to use for rendering
  60121. * @param options defines the options of the effect renderer
  60122. */
  60123. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60124. /**
  60125. * Sets the current viewport in normalized coordinates 0-1
  60126. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60127. */
  60128. setViewport(viewport?: Viewport): void;
  60129. /**
  60130. * Binds the embedded attributes buffer to the effect.
  60131. * @param effect Defines the effect to bind the attributes for
  60132. */
  60133. bindBuffers(effect: Effect): void;
  60134. /**
  60135. * Sets the current effect wrapper to use during draw.
  60136. * The effect needs to be ready before calling this api.
  60137. * This also sets the default full screen position attribute.
  60138. * @param effectWrapper Defines the effect to draw with
  60139. */
  60140. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60141. /**
  60142. * Draws a full screen quad.
  60143. */
  60144. draw(): void;
  60145. /**
  60146. * renders one or more effects to a specified texture
  60147. * @param effectWrappers list of effects to renderer
  60148. * @param outputTexture texture to draw to, if null it will render to the screen
  60149. */
  60150. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60151. /**
  60152. * Disposes of the effect renderer
  60153. */
  60154. dispose(): void;
  60155. }
  60156. /**
  60157. * Options to create an EffectWrapper
  60158. */
  60159. interface EffectWrapperCreationOptions {
  60160. /**
  60161. * Engine to use to create the effect
  60162. */
  60163. engine: ThinEngine;
  60164. /**
  60165. * Fragment shader for the effect
  60166. */
  60167. fragmentShader: string;
  60168. /**
  60169. * Vertex shader for the effect
  60170. */
  60171. vertexShader?: string;
  60172. /**
  60173. * Attributes to use in the shader
  60174. */
  60175. attributeNames?: Array<string>;
  60176. /**
  60177. * Uniforms to use in the shader
  60178. */
  60179. uniformNames?: Array<string>;
  60180. /**
  60181. * Texture sampler names to use in the shader
  60182. */
  60183. samplerNames?: Array<string>;
  60184. /**
  60185. * The friendly name of the effect displayed in Spector.
  60186. */
  60187. name?: string;
  60188. }
  60189. /**
  60190. * Wraps an effect to be used for rendering
  60191. */
  60192. export class EffectWrapper {
  60193. /**
  60194. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60195. */
  60196. onApplyObservable: Observable<{}>;
  60197. /**
  60198. * The underlying effect
  60199. */
  60200. effect: Effect;
  60201. /**
  60202. * Creates an effect to be renderer
  60203. * @param creationOptions options to create the effect
  60204. */
  60205. constructor(creationOptions: EffectWrapperCreationOptions);
  60206. /**
  60207. * Disposes of the effect wrapper
  60208. */
  60209. dispose(): void;
  60210. }
  60211. }
  60212. declare module BABYLON {
  60213. /**
  60214. * Helper class to push actions to a pool of workers.
  60215. */
  60216. export class WorkerPool implements IDisposable {
  60217. private _workerInfos;
  60218. private _pendingActions;
  60219. /**
  60220. * Constructor
  60221. * @param workers Array of workers to use for actions
  60222. */
  60223. constructor(workers: Array<Worker>);
  60224. /**
  60225. * Terminates all workers and clears any pending actions.
  60226. */
  60227. dispose(): void;
  60228. /**
  60229. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60230. * pended until a worker has completed its action.
  60231. * @param action The action to perform. Call onComplete when the action is complete.
  60232. */
  60233. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60234. private _execute;
  60235. }
  60236. }
  60237. declare module BABYLON {
  60238. /**
  60239. * Configuration for Draco compression
  60240. */
  60241. export interface IDracoCompressionConfiguration {
  60242. /**
  60243. * Configuration for the decoder.
  60244. */
  60245. decoder: {
  60246. /**
  60247. * The url to the WebAssembly module.
  60248. */
  60249. wasmUrl?: string;
  60250. /**
  60251. * The url to the WebAssembly binary.
  60252. */
  60253. wasmBinaryUrl?: string;
  60254. /**
  60255. * The url to the fallback JavaScript module.
  60256. */
  60257. fallbackUrl?: string;
  60258. };
  60259. }
  60260. /**
  60261. * Draco compression (https://google.github.io/draco/)
  60262. *
  60263. * This class wraps the Draco module.
  60264. *
  60265. * **Encoder**
  60266. *
  60267. * The encoder is not currently implemented.
  60268. *
  60269. * **Decoder**
  60270. *
  60271. * 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.
  60272. *
  60273. * To update the configuration, use the following code:
  60274. * ```javascript
  60275. * DracoCompression.Configuration = {
  60276. * decoder: {
  60277. * wasmUrl: "<url to the WebAssembly library>",
  60278. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60279. * fallbackUrl: "<url to the fallback JavaScript library>",
  60280. * }
  60281. * };
  60282. * ```
  60283. *
  60284. * 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.
  60285. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60286. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60287. *
  60288. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60289. * ```javascript
  60290. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60291. * ```
  60292. *
  60293. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60294. */
  60295. export class DracoCompression implements IDisposable {
  60296. private _workerPoolPromise?;
  60297. private _decoderModulePromise?;
  60298. /**
  60299. * The configuration. Defaults to the following urls:
  60300. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60301. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60302. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60303. */
  60304. static Configuration: IDracoCompressionConfiguration;
  60305. /**
  60306. * Returns true if the decoder configuration is available.
  60307. */
  60308. static get DecoderAvailable(): boolean;
  60309. /**
  60310. * Default number of workers to create when creating the draco compression object.
  60311. */
  60312. static DefaultNumWorkers: number;
  60313. private static GetDefaultNumWorkers;
  60314. private static _Default;
  60315. /**
  60316. * Default instance for the draco compression object.
  60317. */
  60318. static get Default(): DracoCompression;
  60319. /**
  60320. * Constructor
  60321. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60322. */
  60323. constructor(numWorkers?: number);
  60324. /**
  60325. * Stop all async operations and release resources.
  60326. */
  60327. dispose(): void;
  60328. /**
  60329. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60330. * @returns a promise that resolves when ready
  60331. */
  60332. whenReadyAsync(): Promise<void>;
  60333. /**
  60334. * Decode Draco compressed mesh data to vertex data.
  60335. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60336. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60337. * @returns A promise that resolves with the decoded vertex data
  60338. */
  60339. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60340. [kind: string]: number;
  60341. }): Promise<VertexData>;
  60342. }
  60343. }
  60344. declare module BABYLON {
  60345. /**
  60346. * Class for building Constructive Solid Geometry
  60347. */
  60348. export class CSG {
  60349. private polygons;
  60350. /**
  60351. * The world matrix
  60352. */
  60353. matrix: Matrix;
  60354. /**
  60355. * Stores the position
  60356. */
  60357. position: Vector3;
  60358. /**
  60359. * Stores the rotation
  60360. */
  60361. rotation: Vector3;
  60362. /**
  60363. * Stores the rotation quaternion
  60364. */
  60365. rotationQuaternion: Nullable<Quaternion>;
  60366. /**
  60367. * Stores the scaling vector
  60368. */
  60369. scaling: Vector3;
  60370. /**
  60371. * Convert the Mesh to CSG
  60372. * @param mesh The Mesh to convert to CSG
  60373. * @returns A new CSG from the Mesh
  60374. */
  60375. static FromMesh(mesh: Mesh): CSG;
  60376. /**
  60377. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60378. * @param polygons Polygons used to construct a CSG solid
  60379. */
  60380. private static FromPolygons;
  60381. /**
  60382. * Clones, or makes a deep copy, of the CSG
  60383. * @returns A new CSG
  60384. */
  60385. clone(): CSG;
  60386. /**
  60387. * Unions this CSG with another CSG
  60388. * @param csg The CSG to union against this CSG
  60389. * @returns The unioned CSG
  60390. */
  60391. union(csg: CSG): CSG;
  60392. /**
  60393. * Unions this CSG with another CSG in place
  60394. * @param csg The CSG to union against this CSG
  60395. */
  60396. unionInPlace(csg: CSG): void;
  60397. /**
  60398. * Subtracts this CSG with another CSG
  60399. * @param csg The CSG to subtract against this CSG
  60400. * @returns A new CSG
  60401. */
  60402. subtract(csg: CSG): CSG;
  60403. /**
  60404. * Subtracts this CSG with another CSG in place
  60405. * @param csg The CSG to subtact against this CSG
  60406. */
  60407. subtractInPlace(csg: CSG): void;
  60408. /**
  60409. * Intersect this CSG with another CSG
  60410. * @param csg The CSG to intersect against this CSG
  60411. * @returns A new CSG
  60412. */
  60413. intersect(csg: CSG): CSG;
  60414. /**
  60415. * Intersects this CSG with another CSG in place
  60416. * @param csg The CSG to intersect against this CSG
  60417. */
  60418. intersectInPlace(csg: CSG): void;
  60419. /**
  60420. * Return a new CSG solid with solid and empty space switched. This solid is
  60421. * not modified.
  60422. * @returns A new CSG solid with solid and empty space switched
  60423. */
  60424. inverse(): CSG;
  60425. /**
  60426. * Inverses the CSG in place
  60427. */
  60428. inverseInPlace(): void;
  60429. /**
  60430. * This is used to keep meshes transformations so they can be restored
  60431. * when we build back a Babylon Mesh
  60432. * NB : All CSG operations are performed in world coordinates
  60433. * @param csg The CSG to copy the transform attributes from
  60434. * @returns This CSG
  60435. */
  60436. copyTransformAttributes(csg: CSG): CSG;
  60437. /**
  60438. * Build Raw mesh from CSG
  60439. * Coordinates here are in world space
  60440. * @param name The name of the mesh geometry
  60441. * @param scene The Scene
  60442. * @param keepSubMeshes Specifies if the submeshes should be kept
  60443. * @returns A new Mesh
  60444. */
  60445. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60446. /**
  60447. * Build Mesh from CSG taking material and transforms into account
  60448. * @param name The name of the Mesh
  60449. * @param material The material of the Mesh
  60450. * @param scene The Scene
  60451. * @param keepSubMeshes Specifies if submeshes should be kept
  60452. * @returns The new Mesh
  60453. */
  60454. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60455. }
  60456. }
  60457. declare module BABYLON {
  60458. /**
  60459. * Class used to create a trail following a mesh
  60460. */
  60461. export class TrailMesh extends Mesh {
  60462. private _generator;
  60463. private _autoStart;
  60464. private _running;
  60465. private _diameter;
  60466. private _length;
  60467. private _sectionPolygonPointsCount;
  60468. private _sectionVectors;
  60469. private _sectionNormalVectors;
  60470. private _beforeRenderObserver;
  60471. /**
  60472. * @constructor
  60473. * @param name The value used by scene.getMeshByName() to do a lookup.
  60474. * @param generator The mesh or transform node to generate a trail.
  60475. * @param scene The scene to add this mesh to.
  60476. * @param diameter Diameter of trailing mesh. Default is 1.
  60477. * @param length Length of trailing mesh. Default is 60.
  60478. * @param autoStart Automatically start trailing mesh. Default true.
  60479. */
  60480. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60481. /**
  60482. * "TrailMesh"
  60483. * @returns "TrailMesh"
  60484. */
  60485. getClassName(): string;
  60486. private _createMesh;
  60487. /**
  60488. * Start trailing mesh.
  60489. */
  60490. start(): void;
  60491. /**
  60492. * Stop trailing mesh.
  60493. */
  60494. stop(): void;
  60495. /**
  60496. * Update trailing mesh geometry.
  60497. */
  60498. update(): void;
  60499. /**
  60500. * Returns a new TrailMesh object.
  60501. * @param name is a string, the name given to the new mesh
  60502. * @param newGenerator use new generator object for cloned trail mesh
  60503. * @returns a new mesh
  60504. */
  60505. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60506. /**
  60507. * Serializes this trail mesh
  60508. * @param serializationObject object to write serialization to
  60509. */
  60510. serialize(serializationObject: any): void;
  60511. /**
  60512. * Parses a serialized trail mesh
  60513. * @param parsedMesh the serialized mesh
  60514. * @param scene the scene to create the trail mesh in
  60515. * @returns the created trail mesh
  60516. */
  60517. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60518. }
  60519. }
  60520. declare module BABYLON {
  60521. /**
  60522. * Class containing static functions to help procedurally build meshes
  60523. */
  60524. export class TiledBoxBuilder {
  60525. /**
  60526. * Creates a box mesh
  60527. * 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)
  60528. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60530. * * 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
  60531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60532. * @param name defines the name of the mesh
  60533. * @param options defines the options used to create the mesh
  60534. * @param scene defines the hosting scene
  60535. * @returns the box mesh
  60536. */
  60537. static CreateTiledBox(name: string, options: {
  60538. pattern?: number;
  60539. width?: number;
  60540. height?: number;
  60541. depth?: number;
  60542. tileSize?: number;
  60543. tileWidth?: number;
  60544. tileHeight?: number;
  60545. alignHorizontal?: number;
  60546. alignVertical?: number;
  60547. faceUV?: Vector4[];
  60548. faceColors?: Color4[];
  60549. sideOrientation?: number;
  60550. updatable?: boolean;
  60551. }, scene?: Nullable<Scene>): Mesh;
  60552. }
  60553. }
  60554. declare module BABYLON {
  60555. /**
  60556. * Class containing static functions to help procedurally build meshes
  60557. */
  60558. export class TorusKnotBuilder {
  60559. /**
  60560. * Creates a torus knot mesh
  60561. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60562. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60563. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60564. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60566. * * 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
  60567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60568. * @param name defines the name of the mesh
  60569. * @param options defines the options used to create the mesh
  60570. * @param scene defines the hosting scene
  60571. * @returns the torus knot mesh
  60572. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60573. */
  60574. static CreateTorusKnot(name: string, options: {
  60575. radius?: number;
  60576. tube?: number;
  60577. radialSegments?: number;
  60578. tubularSegments?: number;
  60579. p?: number;
  60580. q?: number;
  60581. updatable?: boolean;
  60582. sideOrientation?: number;
  60583. frontUVs?: Vector4;
  60584. backUVs?: Vector4;
  60585. }, scene: any): Mesh;
  60586. }
  60587. }
  60588. declare module BABYLON {
  60589. /**
  60590. * Polygon
  60591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60592. */
  60593. export class Polygon {
  60594. /**
  60595. * Creates a rectangle
  60596. * @param xmin bottom X coord
  60597. * @param ymin bottom Y coord
  60598. * @param xmax top X coord
  60599. * @param ymax top Y coord
  60600. * @returns points that make the resulting rectation
  60601. */
  60602. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60603. /**
  60604. * Creates a circle
  60605. * @param radius radius of circle
  60606. * @param cx scale in x
  60607. * @param cy scale in y
  60608. * @param numberOfSides number of sides that make up the circle
  60609. * @returns points that make the resulting circle
  60610. */
  60611. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60612. /**
  60613. * Creates a polygon from input string
  60614. * @param input Input polygon data
  60615. * @returns the parsed points
  60616. */
  60617. static Parse(input: string): Vector2[];
  60618. /**
  60619. * Starts building a polygon from x and y coordinates
  60620. * @param x x coordinate
  60621. * @param y y coordinate
  60622. * @returns the started path2
  60623. */
  60624. static StartingAt(x: number, y: number): Path2;
  60625. }
  60626. /**
  60627. * Builds a polygon
  60628. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60629. */
  60630. export class PolygonMeshBuilder {
  60631. private _points;
  60632. private _outlinepoints;
  60633. private _holes;
  60634. private _name;
  60635. private _scene;
  60636. private _epoints;
  60637. private _eholes;
  60638. private _addToepoint;
  60639. /**
  60640. * Babylon reference to the earcut plugin.
  60641. */
  60642. bjsEarcut: any;
  60643. /**
  60644. * Creates a PolygonMeshBuilder
  60645. * @param name name of the builder
  60646. * @param contours Path of the polygon
  60647. * @param scene scene to add to when creating the mesh
  60648. * @param earcutInjection can be used to inject your own earcut reference
  60649. */
  60650. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60651. /**
  60652. * Adds a whole within the polygon
  60653. * @param hole Array of points defining the hole
  60654. * @returns this
  60655. */
  60656. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60657. /**
  60658. * Creates the polygon
  60659. * @param updatable If the mesh should be updatable
  60660. * @param depth The depth of the mesh created
  60661. * @returns the created mesh
  60662. */
  60663. build(updatable?: boolean, depth?: number): Mesh;
  60664. /**
  60665. * Creates the polygon
  60666. * @param depth The depth of the mesh created
  60667. * @returns the created VertexData
  60668. */
  60669. buildVertexData(depth?: number): VertexData;
  60670. /**
  60671. * Adds a side to the polygon
  60672. * @param positions points that make the polygon
  60673. * @param normals normals of the polygon
  60674. * @param uvs uvs of the polygon
  60675. * @param indices indices of the polygon
  60676. * @param bounds bounds of the polygon
  60677. * @param points points of the polygon
  60678. * @param depth depth of the polygon
  60679. * @param flip flip of the polygon
  60680. */
  60681. private addSide;
  60682. }
  60683. }
  60684. declare module BABYLON {
  60685. /**
  60686. * Class containing static functions to help procedurally build meshes
  60687. */
  60688. export class PolygonBuilder {
  60689. /**
  60690. * Creates a polygon mesh
  60691. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60692. * * 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
  60693. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60695. * * 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)
  60696. * * Remember you can only change the shape positions, not their number when updating a polygon
  60697. * @param name defines the name of the mesh
  60698. * @param options defines the options used to create the mesh
  60699. * @param scene defines the hosting scene
  60700. * @param earcutInjection can be used to inject your own earcut reference
  60701. * @returns the polygon mesh
  60702. */
  60703. static CreatePolygon(name: string, options: {
  60704. shape: Vector3[];
  60705. holes?: Vector3[][];
  60706. depth?: number;
  60707. faceUV?: Vector4[];
  60708. faceColors?: Color4[];
  60709. updatable?: boolean;
  60710. sideOrientation?: number;
  60711. frontUVs?: Vector4;
  60712. backUVs?: Vector4;
  60713. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60714. /**
  60715. * Creates an extruded polygon mesh, with depth in the Y direction.
  60716. * * 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)
  60717. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60718. * @param name defines the name of the mesh
  60719. * @param options defines the options used to create the mesh
  60720. * @param scene defines the hosting scene
  60721. * @param earcutInjection can be used to inject your own earcut reference
  60722. * @returns the polygon mesh
  60723. */
  60724. static ExtrudePolygon(name: string, options: {
  60725. shape: Vector3[];
  60726. holes?: Vector3[][];
  60727. depth?: number;
  60728. faceUV?: Vector4[];
  60729. faceColors?: Color4[];
  60730. updatable?: boolean;
  60731. sideOrientation?: number;
  60732. frontUVs?: Vector4;
  60733. backUVs?: Vector4;
  60734. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60735. }
  60736. }
  60737. declare module BABYLON {
  60738. /**
  60739. * Class containing static functions to help procedurally build meshes
  60740. */
  60741. export class LatheBuilder {
  60742. /**
  60743. * Creates lathe mesh.
  60744. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60745. * * 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
  60746. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60747. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60748. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60749. * * 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
  60750. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60751. * * 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
  60752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60753. * * 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
  60754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60756. * @param name defines the name of the mesh
  60757. * @param options defines the options used to create the mesh
  60758. * @param scene defines the hosting scene
  60759. * @returns the lathe mesh
  60760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60761. */
  60762. static CreateLathe(name: string, options: {
  60763. shape: Vector3[];
  60764. radius?: number;
  60765. tessellation?: number;
  60766. clip?: number;
  60767. arc?: number;
  60768. closed?: boolean;
  60769. updatable?: boolean;
  60770. sideOrientation?: number;
  60771. frontUVs?: Vector4;
  60772. backUVs?: Vector4;
  60773. cap?: number;
  60774. invertUV?: boolean;
  60775. }, scene?: Nullable<Scene>): Mesh;
  60776. }
  60777. }
  60778. declare module BABYLON {
  60779. /**
  60780. * Class containing static functions to help procedurally build meshes
  60781. */
  60782. export class TiledPlaneBuilder {
  60783. /**
  60784. * Creates a tiled plane mesh
  60785. * * The parameter `pattern` will, depending on value, do nothing or
  60786. * * * flip (reflect about central vertical) alternate tiles across and up
  60787. * * * flip every tile on alternate rows
  60788. * * * rotate (180 degs) alternate tiles across and up
  60789. * * * rotate every tile on alternate rows
  60790. * * * flip and rotate alternate tiles across and up
  60791. * * * flip and rotate every tile on alternate rows
  60792. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60793. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60794. * * 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
  60795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60796. * * 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)
  60797. * * 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)
  60798. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60799. * @param name defines the name of the mesh
  60800. * @param options defines the options used to create the mesh
  60801. * @param scene defines the hosting scene
  60802. * @returns the box mesh
  60803. */
  60804. static CreateTiledPlane(name: string, options: {
  60805. pattern?: number;
  60806. tileSize?: number;
  60807. tileWidth?: number;
  60808. tileHeight?: number;
  60809. size?: number;
  60810. width?: number;
  60811. height?: number;
  60812. alignHorizontal?: number;
  60813. alignVertical?: number;
  60814. sideOrientation?: number;
  60815. frontUVs?: Vector4;
  60816. backUVs?: Vector4;
  60817. updatable?: boolean;
  60818. }, scene?: Nullable<Scene>): Mesh;
  60819. }
  60820. }
  60821. declare module BABYLON {
  60822. /**
  60823. * Class containing static functions to help procedurally build meshes
  60824. */
  60825. export class TubeBuilder {
  60826. /**
  60827. * Creates a tube mesh.
  60828. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60829. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60830. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60831. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60832. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60833. * * 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)
  60834. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60835. * * 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
  60836. * * 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
  60837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60838. * * 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
  60839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60841. * @param name defines the name of the mesh
  60842. * @param options defines the options used to create the mesh
  60843. * @param scene defines the hosting scene
  60844. * @returns the tube mesh
  60845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60846. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60847. */
  60848. static CreateTube(name: string, options: {
  60849. path: Vector3[];
  60850. radius?: number;
  60851. tessellation?: number;
  60852. radiusFunction?: {
  60853. (i: number, distance: number): number;
  60854. };
  60855. cap?: number;
  60856. arc?: number;
  60857. updatable?: boolean;
  60858. sideOrientation?: number;
  60859. frontUVs?: Vector4;
  60860. backUVs?: Vector4;
  60861. instance?: Mesh;
  60862. invertUV?: boolean;
  60863. }, scene?: Nullable<Scene>): Mesh;
  60864. }
  60865. }
  60866. declare module BABYLON {
  60867. /**
  60868. * Class containing static functions to help procedurally build meshes
  60869. */
  60870. export class IcoSphereBuilder {
  60871. /**
  60872. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60873. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60874. * * 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`)
  60875. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60876. * * 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
  60877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60878. * * 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
  60879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60880. * @param name defines the name of the mesh
  60881. * @param options defines the options used to create the mesh
  60882. * @param scene defines the hosting scene
  60883. * @returns the icosahedron mesh
  60884. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60885. */
  60886. static CreateIcoSphere(name: string, options: {
  60887. radius?: number;
  60888. radiusX?: number;
  60889. radiusY?: number;
  60890. radiusZ?: number;
  60891. flat?: boolean;
  60892. subdivisions?: number;
  60893. sideOrientation?: number;
  60894. frontUVs?: Vector4;
  60895. backUVs?: Vector4;
  60896. updatable?: boolean;
  60897. }, scene?: Nullable<Scene>): Mesh;
  60898. }
  60899. }
  60900. declare module BABYLON {
  60901. /**
  60902. * Class containing static functions to help procedurally build meshes
  60903. */
  60904. export class DecalBuilder {
  60905. /**
  60906. * Creates a decal mesh.
  60907. * 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
  60908. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60909. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60910. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60911. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60912. * @param name defines the name of the mesh
  60913. * @param sourceMesh defines the mesh where the decal must be applied
  60914. * @param options defines the options used to create the mesh
  60915. * @param scene defines the hosting scene
  60916. * @returns the decal mesh
  60917. * @see https://doc.babylonjs.com/how_to/decals
  60918. */
  60919. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60920. position?: Vector3;
  60921. normal?: Vector3;
  60922. size?: Vector3;
  60923. angle?: number;
  60924. }): Mesh;
  60925. }
  60926. }
  60927. declare module BABYLON {
  60928. /**
  60929. * Class containing static functions to help procedurally build meshes
  60930. */
  60931. export class MeshBuilder {
  60932. /**
  60933. * Creates a box mesh
  60934. * * The parameter `size` sets the size (float) of each box side (default 1)
  60935. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60936. * * 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)
  60937. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60939. * * 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
  60940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60941. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60942. * @param name defines the name of the mesh
  60943. * @param options defines the options used to create the mesh
  60944. * @param scene defines the hosting scene
  60945. * @returns the box mesh
  60946. */
  60947. static CreateBox(name: string, options: {
  60948. size?: number;
  60949. width?: number;
  60950. height?: number;
  60951. depth?: number;
  60952. faceUV?: Vector4[];
  60953. faceColors?: Color4[];
  60954. sideOrientation?: number;
  60955. frontUVs?: Vector4;
  60956. backUVs?: Vector4;
  60957. updatable?: boolean;
  60958. }, scene?: Nullable<Scene>): Mesh;
  60959. /**
  60960. * Creates a tiled box mesh
  60961. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60963. * @param name defines the name of the mesh
  60964. * @param options defines the options used to create the mesh
  60965. * @param scene defines the hosting scene
  60966. * @returns the tiled box mesh
  60967. */
  60968. static CreateTiledBox(name: string, options: {
  60969. pattern?: number;
  60970. size?: number;
  60971. width?: number;
  60972. height?: number;
  60973. depth: number;
  60974. tileSize?: number;
  60975. tileWidth?: number;
  60976. tileHeight?: number;
  60977. faceUV?: Vector4[];
  60978. faceColors?: Color4[];
  60979. alignHorizontal?: number;
  60980. alignVertical?: number;
  60981. sideOrientation?: number;
  60982. updatable?: boolean;
  60983. }, scene?: Nullable<Scene>): Mesh;
  60984. /**
  60985. * Creates a sphere mesh
  60986. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60987. * * 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`)
  60988. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60989. * * 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
  60990. * * 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)
  60991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60992. * * 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
  60993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60994. * @param name defines the name of the mesh
  60995. * @param options defines the options used to create the mesh
  60996. * @param scene defines the hosting scene
  60997. * @returns the sphere mesh
  60998. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60999. */
  61000. static CreateSphere(name: string, options: {
  61001. segments?: number;
  61002. diameter?: number;
  61003. diameterX?: number;
  61004. diameterY?: number;
  61005. diameterZ?: number;
  61006. arc?: number;
  61007. slice?: number;
  61008. sideOrientation?: number;
  61009. frontUVs?: Vector4;
  61010. backUVs?: Vector4;
  61011. updatable?: boolean;
  61012. }, scene?: Nullable<Scene>): Mesh;
  61013. /**
  61014. * Creates a plane polygonal mesh. By default, this is a disc
  61015. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61016. * * 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
  61017. * * 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
  61018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61019. * * 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
  61020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61021. * @param name defines the name of the mesh
  61022. * @param options defines the options used to create the mesh
  61023. * @param scene defines the hosting scene
  61024. * @returns the plane polygonal mesh
  61025. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61026. */
  61027. static CreateDisc(name: string, options: {
  61028. radius?: number;
  61029. tessellation?: number;
  61030. arc?: number;
  61031. updatable?: boolean;
  61032. sideOrientation?: number;
  61033. frontUVs?: Vector4;
  61034. backUVs?: Vector4;
  61035. }, scene?: Nullable<Scene>): Mesh;
  61036. /**
  61037. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61038. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61039. * * 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`)
  61040. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61041. * * 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
  61042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61043. * * 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
  61044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61045. * @param name defines the name of the mesh
  61046. * @param options defines the options used to create the mesh
  61047. * @param scene defines the hosting scene
  61048. * @returns the icosahedron mesh
  61049. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61050. */
  61051. static CreateIcoSphere(name: string, options: {
  61052. radius?: number;
  61053. radiusX?: number;
  61054. radiusY?: number;
  61055. radiusZ?: number;
  61056. flat?: boolean;
  61057. subdivisions?: number;
  61058. sideOrientation?: number;
  61059. frontUVs?: Vector4;
  61060. backUVs?: Vector4;
  61061. updatable?: boolean;
  61062. }, scene?: Nullable<Scene>): Mesh;
  61063. /**
  61064. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61065. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61066. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61067. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61068. * * 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
  61069. * * 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
  61070. * * 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
  61071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61072. * * 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
  61073. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61074. * * 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
  61075. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61076. * * 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
  61077. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61079. * @param name defines the name of the mesh
  61080. * @param options defines the options used to create the mesh
  61081. * @param scene defines the hosting scene
  61082. * @returns the ribbon mesh
  61083. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61084. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61085. */
  61086. static CreateRibbon(name: string, options: {
  61087. pathArray: Vector3[][];
  61088. closeArray?: boolean;
  61089. closePath?: boolean;
  61090. offset?: number;
  61091. updatable?: boolean;
  61092. sideOrientation?: number;
  61093. frontUVs?: Vector4;
  61094. backUVs?: Vector4;
  61095. instance?: Mesh;
  61096. invertUV?: boolean;
  61097. uvs?: Vector2[];
  61098. colors?: Color4[];
  61099. }, scene?: Nullable<Scene>): Mesh;
  61100. /**
  61101. * Creates a cylinder or a cone mesh
  61102. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61103. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61104. * * 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.
  61105. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61106. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61107. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61108. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61109. * * 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).
  61110. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61111. * * 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).
  61112. * * 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
  61113. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61114. * * 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
  61115. * * 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.
  61116. * * If `enclose` is false, a ring surface is one element.
  61117. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61118. * * 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
  61119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61120. * * 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
  61121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61122. * @param name defines the name of the mesh
  61123. * @param options defines the options used to create the mesh
  61124. * @param scene defines the hosting scene
  61125. * @returns the cylinder mesh
  61126. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61127. */
  61128. static CreateCylinder(name: string, options: {
  61129. height?: number;
  61130. diameterTop?: number;
  61131. diameterBottom?: number;
  61132. diameter?: number;
  61133. tessellation?: number;
  61134. subdivisions?: number;
  61135. arc?: number;
  61136. faceColors?: Color4[];
  61137. faceUV?: Vector4[];
  61138. updatable?: boolean;
  61139. hasRings?: boolean;
  61140. enclose?: boolean;
  61141. cap?: number;
  61142. sideOrientation?: number;
  61143. frontUVs?: Vector4;
  61144. backUVs?: Vector4;
  61145. }, scene?: Nullable<Scene>): Mesh;
  61146. /**
  61147. * Creates a torus mesh
  61148. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61149. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61150. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61152. * * 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
  61153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61154. * @param name defines the name of the mesh
  61155. * @param options defines the options used to create the mesh
  61156. * @param scene defines the hosting scene
  61157. * @returns the torus mesh
  61158. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61159. */
  61160. static CreateTorus(name: string, options: {
  61161. diameter?: number;
  61162. thickness?: number;
  61163. tessellation?: number;
  61164. updatable?: boolean;
  61165. sideOrientation?: number;
  61166. frontUVs?: Vector4;
  61167. backUVs?: Vector4;
  61168. }, scene?: Nullable<Scene>): Mesh;
  61169. /**
  61170. * Creates a torus knot mesh
  61171. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61172. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61173. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61174. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61176. * * 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
  61177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61178. * @param name defines the name of the mesh
  61179. * @param options defines the options used to create the mesh
  61180. * @param scene defines the hosting scene
  61181. * @returns the torus knot mesh
  61182. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61183. */
  61184. static CreateTorusKnot(name: string, options: {
  61185. radius?: number;
  61186. tube?: number;
  61187. radialSegments?: number;
  61188. tubularSegments?: number;
  61189. p?: number;
  61190. q?: number;
  61191. updatable?: boolean;
  61192. sideOrientation?: number;
  61193. frontUVs?: Vector4;
  61194. backUVs?: Vector4;
  61195. }, scene?: Nullable<Scene>): Mesh;
  61196. /**
  61197. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61198. * * 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
  61199. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61200. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61201. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61202. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61203. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61204. * * 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
  61205. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61208. * @param name defines the name of the new line system
  61209. * @param options defines the options used to create the line system
  61210. * @param scene defines the hosting scene
  61211. * @returns a new line system mesh
  61212. */
  61213. static CreateLineSystem(name: string, options: {
  61214. lines: Vector3[][];
  61215. updatable?: boolean;
  61216. instance?: Nullable<LinesMesh>;
  61217. colors?: Nullable<Color4[][]>;
  61218. useVertexAlpha?: boolean;
  61219. }, scene: Nullable<Scene>): LinesMesh;
  61220. /**
  61221. * Creates a line mesh
  61222. * 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
  61223. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61224. * * The parameter `points` is an array successive Vector3
  61225. * * 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
  61226. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61227. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61228. * * When updating an instance, remember that only point positions can change, not the number of points
  61229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61231. * @param name defines the name of the new line system
  61232. * @param options defines the options used to create the line system
  61233. * @param scene defines the hosting scene
  61234. * @returns a new line mesh
  61235. */
  61236. static CreateLines(name: string, options: {
  61237. points: Vector3[];
  61238. updatable?: boolean;
  61239. instance?: Nullable<LinesMesh>;
  61240. colors?: Color4[];
  61241. useVertexAlpha?: boolean;
  61242. }, scene?: Nullable<Scene>): LinesMesh;
  61243. /**
  61244. * Creates a dashed line mesh
  61245. * * 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
  61246. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61247. * * The parameter `points` is an array successive Vector3
  61248. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61249. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61250. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61251. * * 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
  61252. * * When updating an instance, remember that only point positions can change, not the number of points
  61253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61254. * @param name defines the name of the mesh
  61255. * @param options defines the options used to create the mesh
  61256. * @param scene defines the hosting scene
  61257. * @returns the dashed line mesh
  61258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61259. */
  61260. static CreateDashedLines(name: string, options: {
  61261. points: Vector3[];
  61262. dashSize?: number;
  61263. gapSize?: number;
  61264. dashNb?: number;
  61265. updatable?: boolean;
  61266. instance?: LinesMesh;
  61267. }, scene?: Nullable<Scene>): LinesMesh;
  61268. /**
  61269. * 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.
  61270. * * 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.
  61271. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61272. * * 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.
  61273. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61274. * * 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
  61275. * * 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
  61276. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61278. * * 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
  61279. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61281. * @param name defines the name of the mesh
  61282. * @param options defines the options used to create the mesh
  61283. * @param scene defines the hosting scene
  61284. * @returns the extruded shape mesh
  61285. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61287. */
  61288. static ExtrudeShape(name: string, options: {
  61289. shape: Vector3[];
  61290. path: Vector3[];
  61291. scale?: number;
  61292. rotation?: number;
  61293. cap?: number;
  61294. updatable?: boolean;
  61295. sideOrientation?: number;
  61296. frontUVs?: Vector4;
  61297. backUVs?: Vector4;
  61298. instance?: Mesh;
  61299. invertUV?: boolean;
  61300. }, scene?: Nullable<Scene>): Mesh;
  61301. /**
  61302. * Creates an custom extruded shape mesh.
  61303. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61304. * * 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.
  61305. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61306. * * 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
  61307. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61308. * * 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
  61309. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61310. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61311. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61312. * * 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
  61313. * * 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
  61314. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61317. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61319. * @param name defines the name of the mesh
  61320. * @param options defines the options used to create the mesh
  61321. * @param scene defines the hosting scene
  61322. * @returns the custom extruded shape mesh
  61323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61324. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61326. */
  61327. static ExtrudeShapeCustom(name: string, options: {
  61328. shape: Vector3[];
  61329. path: Vector3[];
  61330. scaleFunction?: any;
  61331. rotationFunction?: any;
  61332. ribbonCloseArray?: boolean;
  61333. ribbonClosePath?: boolean;
  61334. cap?: number;
  61335. updatable?: boolean;
  61336. sideOrientation?: number;
  61337. frontUVs?: Vector4;
  61338. backUVs?: Vector4;
  61339. instance?: Mesh;
  61340. invertUV?: boolean;
  61341. }, scene?: Nullable<Scene>): Mesh;
  61342. /**
  61343. * Creates lathe mesh.
  61344. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61345. * * 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
  61346. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61347. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61348. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61349. * * 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
  61350. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61351. * * 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
  61352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61353. * * 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
  61354. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61356. * @param name defines the name of the mesh
  61357. * @param options defines the options used to create the mesh
  61358. * @param scene defines the hosting scene
  61359. * @returns the lathe mesh
  61360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61361. */
  61362. static CreateLathe(name: string, options: {
  61363. shape: Vector3[];
  61364. radius?: number;
  61365. tessellation?: number;
  61366. clip?: number;
  61367. arc?: number;
  61368. closed?: boolean;
  61369. updatable?: boolean;
  61370. sideOrientation?: number;
  61371. frontUVs?: Vector4;
  61372. backUVs?: Vector4;
  61373. cap?: number;
  61374. invertUV?: boolean;
  61375. }, scene?: Nullable<Scene>): Mesh;
  61376. /**
  61377. * Creates a tiled plane mesh
  61378. * * You can set a limited pattern arrangement with the tiles
  61379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61380. * * 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
  61381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61382. * @param name defines the name of the mesh
  61383. * @param options defines the options used to create the mesh
  61384. * @param scene defines the hosting scene
  61385. * @returns the plane mesh
  61386. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61387. */
  61388. static CreateTiledPlane(name: string, options: {
  61389. pattern?: number;
  61390. tileSize?: number;
  61391. tileWidth?: number;
  61392. tileHeight?: number;
  61393. size?: number;
  61394. width?: number;
  61395. height?: number;
  61396. alignHorizontal?: number;
  61397. alignVertical?: number;
  61398. sideOrientation?: number;
  61399. frontUVs?: Vector4;
  61400. backUVs?: Vector4;
  61401. updatable?: boolean;
  61402. }, scene?: Nullable<Scene>): Mesh;
  61403. /**
  61404. * Creates a plane mesh
  61405. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61406. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61407. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61409. * * 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
  61410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61411. * @param name defines the name of the mesh
  61412. * @param options defines the options used to create the mesh
  61413. * @param scene defines the hosting scene
  61414. * @returns the plane mesh
  61415. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61416. */
  61417. static CreatePlane(name: string, options: {
  61418. size?: number;
  61419. width?: number;
  61420. height?: number;
  61421. sideOrientation?: number;
  61422. frontUVs?: Vector4;
  61423. backUVs?: Vector4;
  61424. updatable?: boolean;
  61425. sourcePlane?: Plane;
  61426. }, scene?: Nullable<Scene>): Mesh;
  61427. /**
  61428. * Creates a ground mesh
  61429. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61430. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61432. * @param name defines the name of the mesh
  61433. * @param options defines the options used to create the mesh
  61434. * @param scene defines the hosting scene
  61435. * @returns the ground mesh
  61436. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61437. */
  61438. static CreateGround(name: string, options: {
  61439. width?: number;
  61440. height?: number;
  61441. subdivisions?: number;
  61442. subdivisionsX?: number;
  61443. subdivisionsY?: number;
  61444. updatable?: boolean;
  61445. }, scene?: Nullable<Scene>): Mesh;
  61446. /**
  61447. * Creates a tiled ground mesh
  61448. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61449. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61450. * * 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
  61451. * * 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
  61452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61453. * @param name defines the name of the mesh
  61454. * @param options defines the options used to create the mesh
  61455. * @param scene defines the hosting scene
  61456. * @returns the tiled ground mesh
  61457. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61458. */
  61459. static CreateTiledGround(name: string, options: {
  61460. xmin: number;
  61461. zmin: number;
  61462. xmax: number;
  61463. zmax: number;
  61464. subdivisions?: {
  61465. w: number;
  61466. h: number;
  61467. };
  61468. precision?: {
  61469. w: number;
  61470. h: number;
  61471. };
  61472. updatable?: boolean;
  61473. }, scene?: Nullable<Scene>): Mesh;
  61474. /**
  61475. * Creates a ground mesh from a height map
  61476. * * The parameter `url` sets the URL of the height map image resource.
  61477. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61478. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61479. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61480. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61481. * * 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.
  61482. * * 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).
  61483. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61485. * @param name defines the name of the mesh
  61486. * @param url defines the url to the height map
  61487. * @param options defines the options used to create the mesh
  61488. * @param scene defines the hosting scene
  61489. * @returns the ground mesh
  61490. * @see https://doc.babylonjs.com/babylon101/height_map
  61491. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61492. */
  61493. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61494. width?: number;
  61495. height?: number;
  61496. subdivisions?: number;
  61497. minHeight?: number;
  61498. maxHeight?: number;
  61499. colorFilter?: Color3;
  61500. alphaFilter?: number;
  61501. updatable?: boolean;
  61502. onReady?: (mesh: GroundMesh) => void;
  61503. }, scene?: Nullable<Scene>): GroundMesh;
  61504. /**
  61505. * Creates a polygon mesh
  61506. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61507. * * 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
  61508. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61510. * * 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)
  61511. * * Remember you can only change the shape positions, not their number when updating a polygon
  61512. * @param name defines the name of the mesh
  61513. * @param options defines the options used to create the mesh
  61514. * @param scene defines the hosting scene
  61515. * @param earcutInjection can be used to inject your own earcut reference
  61516. * @returns the polygon mesh
  61517. */
  61518. static CreatePolygon(name: string, options: {
  61519. shape: Vector3[];
  61520. holes?: Vector3[][];
  61521. depth?: number;
  61522. faceUV?: Vector4[];
  61523. faceColors?: Color4[];
  61524. updatable?: boolean;
  61525. sideOrientation?: number;
  61526. frontUVs?: Vector4;
  61527. backUVs?: Vector4;
  61528. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61529. /**
  61530. * Creates an extruded polygon mesh, with depth in the Y direction.
  61531. * * 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)
  61532. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61533. * @param name defines the name of the mesh
  61534. * @param options defines the options used to create the mesh
  61535. * @param scene defines the hosting scene
  61536. * @param earcutInjection can be used to inject your own earcut reference
  61537. * @returns the polygon mesh
  61538. */
  61539. static ExtrudePolygon(name: string, options: {
  61540. shape: Vector3[];
  61541. holes?: Vector3[][];
  61542. depth?: number;
  61543. faceUV?: Vector4[];
  61544. faceColors?: Color4[];
  61545. updatable?: boolean;
  61546. sideOrientation?: number;
  61547. frontUVs?: Vector4;
  61548. backUVs?: Vector4;
  61549. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61550. /**
  61551. * Creates a tube mesh.
  61552. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61553. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61554. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61555. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61556. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61557. * * 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)
  61558. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61559. * * 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
  61560. * * 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
  61561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61562. * * 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
  61563. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61565. * @param name defines the name of the mesh
  61566. * @param options defines the options used to create the mesh
  61567. * @param scene defines the hosting scene
  61568. * @returns the tube mesh
  61569. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61570. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61571. */
  61572. static CreateTube(name: string, options: {
  61573. path: Vector3[];
  61574. radius?: number;
  61575. tessellation?: number;
  61576. radiusFunction?: {
  61577. (i: number, distance: number): number;
  61578. };
  61579. cap?: number;
  61580. arc?: number;
  61581. updatable?: boolean;
  61582. sideOrientation?: number;
  61583. frontUVs?: Vector4;
  61584. backUVs?: Vector4;
  61585. instance?: Mesh;
  61586. invertUV?: boolean;
  61587. }, scene?: Nullable<Scene>): Mesh;
  61588. /**
  61589. * Creates a polyhedron mesh
  61590. * * 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
  61591. * * The parameter `size` (positive float, default 1) sets the polygon size
  61592. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61593. * * 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`
  61594. * * 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
  61595. * * 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)`)
  61596. * * 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
  61597. * * 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
  61598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61599. * * 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
  61600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61601. * @param name defines the name of the mesh
  61602. * @param options defines the options used to create the mesh
  61603. * @param scene defines the hosting scene
  61604. * @returns the polyhedron mesh
  61605. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61606. */
  61607. static CreatePolyhedron(name: string, options: {
  61608. type?: number;
  61609. size?: number;
  61610. sizeX?: number;
  61611. sizeY?: number;
  61612. sizeZ?: number;
  61613. custom?: any;
  61614. faceUV?: Vector4[];
  61615. faceColors?: Color4[];
  61616. flat?: boolean;
  61617. updatable?: boolean;
  61618. sideOrientation?: number;
  61619. frontUVs?: Vector4;
  61620. backUVs?: Vector4;
  61621. }, scene?: Nullable<Scene>): Mesh;
  61622. /**
  61623. * Creates a decal mesh.
  61624. * 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
  61625. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61626. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61627. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61628. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61629. * @param name defines the name of the mesh
  61630. * @param sourceMesh defines the mesh where the decal must be applied
  61631. * @param options defines the options used to create the mesh
  61632. * @param scene defines the hosting scene
  61633. * @returns the decal mesh
  61634. * @see https://doc.babylonjs.com/how_to/decals
  61635. */
  61636. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61637. position?: Vector3;
  61638. normal?: Vector3;
  61639. size?: Vector3;
  61640. angle?: number;
  61641. }): Mesh;
  61642. }
  61643. }
  61644. declare module BABYLON {
  61645. /**
  61646. * A simplifier interface for future simplification implementations
  61647. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61648. */
  61649. export interface ISimplifier {
  61650. /**
  61651. * Simplification of a given mesh according to the given settings.
  61652. * Since this requires computation, it is assumed that the function runs async.
  61653. * @param settings The settings of the simplification, including quality and distance
  61654. * @param successCallback A callback that will be called after the mesh was simplified.
  61655. * @param errorCallback in case of an error, this callback will be called. optional.
  61656. */
  61657. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61658. }
  61659. /**
  61660. * Expected simplification settings.
  61661. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61662. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61663. */
  61664. export interface ISimplificationSettings {
  61665. /**
  61666. * Gets or sets the expected quality
  61667. */
  61668. quality: number;
  61669. /**
  61670. * Gets or sets the distance when this optimized version should be used
  61671. */
  61672. distance: number;
  61673. /**
  61674. * Gets an already optimized mesh
  61675. */
  61676. optimizeMesh?: boolean;
  61677. }
  61678. /**
  61679. * Class used to specify simplification options
  61680. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61681. */
  61682. export class SimplificationSettings implements ISimplificationSettings {
  61683. /** expected quality */
  61684. quality: number;
  61685. /** distance when this optimized version should be used */
  61686. distance: number;
  61687. /** already optimized mesh */
  61688. optimizeMesh?: boolean | undefined;
  61689. /**
  61690. * Creates a SimplificationSettings
  61691. * @param quality expected quality
  61692. * @param distance distance when this optimized version should be used
  61693. * @param optimizeMesh already optimized mesh
  61694. */
  61695. constructor(
  61696. /** expected quality */
  61697. quality: number,
  61698. /** distance when this optimized version should be used */
  61699. distance: number,
  61700. /** already optimized mesh */
  61701. optimizeMesh?: boolean | undefined);
  61702. }
  61703. /**
  61704. * Interface used to define a simplification task
  61705. */
  61706. export interface ISimplificationTask {
  61707. /**
  61708. * Array of settings
  61709. */
  61710. settings: Array<ISimplificationSettings>;
  61711. /**
  61712. * Simplification type
  61713. */
  61714. simplificationType: SimplificationType;
  61715. /**
  61716. * Mesh to simplify
  61717. */
  61718. mesh: Mesh;
  61719. /**
  61720. * Callback called on success
  61721. */
  61722. successCallback?: () => void;
  61723. /**
  61724. * Defines if parallel processing can be used
  61725. */
  61726. parallelProcessing: boolean;
  61727. }
  61728. /**
  61729. * Queue used to order the simplification tasks
  61730. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61731. */
  61732. export class SimplificationQueue {
  61733. private _simplificationArray;
  61734. /**
  61735. * Gets a boolean indicating that the process is still running
  61736. */
  61737. running: boolean;
  61738. /**
  61739. * Creates a new queue
  61740. */
  61741. constructor();
  61742. /**
  61743. * Adds a new simplification task
  61744. * @param task defines a task to add
  61745. */
  61746. addTask(task: ISimplificationTask): void;
  61747. /**
  61748. * Execute next task
  61749. */
  61750. executeNext(): void;
  61751. /**
  61752. * Execute a simplification task
  61753. * @param task defines the task to run
  61754. */
  61755. runSimplification(task: ISimplificationTask): void;
  61756. private getSimplifier;
  61757. }
  61758. /**
  61759. * The implemented types of simplification
  61760. * At the moment only Quadratic Error Decimation is implemented
  61761. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61762. */
  61763. export enum SimplificationType {
  61764. /** Quadratic error decimation */
  61765. QUADRATIC = 0
  61766. }
  61767. }
  61768. declare module BABYLON {
  61769. interface Scene {
  61770. /** @hidden (Backing field) */
  61771. _simplificationQueue: SimplificationQueue;
  61772. /**
  61773. * Gets or sets the simplification queue attached to the scene
  61774. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61775. */
  61776. simplificationQueue: SimplificationQueue;
  61777. }
  61778. interface Mesh {
  61779. /**
  61780. * Simplify the mesh according to the given array of settings.
  61781. * Function will return immediately and will simplify async
  61782. * @param settings a collection of simplification settings
  61783. * @param parallelProcessing should all levels calculate parallel or one after the other
  61784. * @param simplificationType the type of simplification to run
  61785. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61786. * @returns the current mesh
  61787. */
  61788. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61789. }
  61790. /**
  61791. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61792. * created in a scene
  61793. */
  61794. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61795. /**
  61796. * The component name helpfull to identify the component in the list of scene components.
  61797. */
  61798. readonly name: string;
  61799. /**
  61800. * The scene the component belongs to.
  61801. */
  61802. scene: Scene;
  61803. /**
  61804. * Creates a new instance of the component for the given scene
  61805. * @param scene Defines the scene to register the component in
  61806. */
  61807. constructor(scene: Scene);
  61808. /**
  61809. * Registers the component in a given scene
  61810. */
  61811. register(): void;
  61812. /**
  61813. * Rebuilds the elements related to this component in case of
  61814. * context lost for instance.
  61815. */
  61816. rebuild(): void;
  61817. /**
  61818. * Disposes the component and the associated ressources
  61819. */
  61820. dispose(): void;
  61821. private _beforeCameraUpdate;
  61822. }
  61823. }
  61824. declare module BABYLON {
  61825. /**
  61826. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61827. */
  61828. export interface INavigationEnginePlugin {
  61829. /**
  61830. * plugin name
  61831. */
  61832. name: string;
  61833. /**
  61834. * Creates a navigation mesh
  61835. * @param meshes array of all the geometry used to compute the navigatio mesh
  61836. * @param parameters bunch of parameters used to filter geometry
  61837. */
  61838. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61839. /**
  61840. * Create a navigation mesh debug mesh
  61841. * @param scene is where the mesh will be added
  61842. * @returns debug display mesh
  61843. */
  61844. createDebugNavMesh(scene: Scene): Mesh;
  61845. /**
  61846. * Get a navigation mesh constrained position, closest to the parameter position
  61847. * @param position world position
  61848. * @returns the closest point to position constrained by the navigation mesh
  61849. */
  61850. getClosestPoint(position: Vector3): Vector3;
  61851. /**
  61852. * Get a navigation mesh constrained position, within a particular radius
  61853. * @param position world position
  61854. * @param maxRadius the maximum distance to the constrained world position
  61855. * @returns the closest point to position constrained by the navigation mesh
  61856. */
  61857. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61858. /**
  61859. * Compute the final position from a segment made of destination-position
  61860. * @param position world position
  61861. * @param destination world position
  61862. * @returns the resulting point along the navmesh
  61863. */
  61864. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61865. /**
  61866. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61867. * @param start world position
  61868. * @param end world position
  61869. * @returns array containing world position composing the path
  61870. */
  61871. computePath(start: Vector3, end: Vector3): Vector3[];
  61872. /**
  61873. * If this plugin is supported
  61874. * @returns true if plugin is supported
  61875. */
  61876. isSupported(): boolean;
  61877. /**
  61878. * Create a new Crowd so you can add agents
  61879. * @param maxAgents the maximum agent count in the crowd
  61880. * @param maxAgentRadius the maximum radius an agent can have
  61881. * @param scene to attach the crowd to
  61882. * @returns the crowd you can add agents to
  61883. */
  61884. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61885. /**
  61886. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61887. * The queries will try to find a solution within those bounds
  61888. * default is (1,1,1)
  61889. * @param extent x,y,z value that define the extent around the queries point of reference
  61890. */
  61891. setDefaultQueryExtent(extent: Vector3): void;
  61892. /**
  61893. * Get the Bounding box extent specified by setDefaultQueryExtent
  61894. * @returns the box extent values
  61895. */
  61896. getDefaultQueryExtent(): Vector3;
  61897. /**
  61898. * Release all resources
  61899. */
  61900. dispose(): void;
  61901. }
  61902. /**
  61903. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61904. */
  61905. export interface ICrowd {
  61906. /**
  61907. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61908. * You can attach anything to that node. The node position is updated in the scene update tick.
  61909. * @param pos world position that will be constrained by the navigation mesh
  61910. * @param parameters agent parameters
  61911. * @param transform hooked to the agent that will be update by the scene
  61912. * @returns agent index
  61913. */
  61914. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61915. /**
  61916. * Returns the agent position in world space
  61917. * @param index agent index returned by addAgent
  61918. * @returns world space position
  61919. */
  61920. getAgentPosition(index: number): Vector3;
  61921. /**
  61922. * Gets the agent velocity in world space
  61923. * @param index agent index returned by addAgent
  61924. * @returns world space velocity
  61925. */
  61926. getAgentVelocity(index: number): Vector3;
  61927. /**
  61928. * remove a particular agent previously created
  61929. * @param index agent index returned by addAgent
  61930. */
  61931. removeAgent(index: number): void;
  61932. /**
  61933. * get the list of all agents attached to this crowd
  61934. * @returns list of agent indices
  61935. */
  61936. getAgents(): number[];
  61937. /**
  61938. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61939. * @param deltaTime in seconds
  61940. */
  61941. update(deltaTime: number): void;
  61942. /**
  61943. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61944. * @param index agent index returned by addAgent
  61945. * @param destination targeted world position
  61946. */
  61947. agentGoto(index: number, destination: Vector3): void;
  61948. /**
  61949. * Teleport the agent to a new position
  61950. * @param index agent index returned by addAgent
  61951. * @param destination targeted world position
  61952. */
  61953. agentTeleport(index: number, destination: Vector3): void;
  61954. /**
  61955. * Update agent parameters
  61956. * @param index agent index returned by addAgent
  61957. * @param parameters agent parameters
  61958. */
  61959. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  61960. /**
  61961. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61962. * The queries will try to find a solution within those bounds
  61963. * default is (1,1,1)
  61964. * @param extent x,y,z value that define the extent around the queries point of reference
  61965. */
  61966. setDefaultQueryExtent(extent: Vector3): void;
  61967. /**
  61968. * Get the Bounding box extent specified by setDefaultQueryExtent
  61969. * @returns the box extent values
  61970. */
  61971. getDefaultQueryExtent(): Vector3;
  61972. /**
  61973. * Release all resources
  61974. */
  61975. dispose(): void;
  61976. }
  61977. /**
  61978. * Configures an agent
  61979. */
  61980. export interface IAgentParameters {
  61981. /**
  61982. * Agent radius. [Limit: >= 0]
  61983. */
  61984. radius: number;
  61985. /**
  61986. * Agent height. [Limit: > 0]
  61987. */
  61988. height: number;
  61989. /**
  61990. * Maximum allowed acceleration. [Limit: >= 0]
  61991. */
  61992. maxAcceleration: number;
  61993. /**
  61994. * Maximum allowed speed. [Limit: >= 0]
  61995. */
  61996. maxSpeed: number;
  61997. /**
  61998. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61999. */
  62000. collisionQueryRange: number;
  62001. /**
  62002. * The path visibility optimization range. [Limit: > 0]
  62003. */
  62004. pathOptimizationRange: number;
  62005. /**
  62006. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62007. */
  62008. separationWeight: number;
  62009. }
  62010. /**
  62011. * Configures the navigation mesh creation
  62012. */
  62013. export interface INavMeshParameters {
  62014. /**
  62015. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62016. */
  62017. cs: number;
  62018. /**
  62019. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62020. */
  62021. ch: number;
  62022. /**
  62023. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62024. */
  62025. walkableSlopeAngle: number;
  62026. /**
  62027. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62028. * be considered walkable. [Limit: >= 3] [Units: vx]
  62029. */
  62030. walkableHeight: number;
  62031. /**
  62032. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62033. */
  62034. walkableClimb: number;
  62035. /**
  62036. * The distance to erode/shrink the walkable area of the heightfield away from
  62037. * obstructions. [Limit: >=0] [Units: vx]
  62038. */
  62039. walkableRadius: number;
  62040. /**
  62041. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62042. */
  62043. maxEdgeLen: number;
  62044. /**
  62045. * The maximum distance a simplfied contour's border edges should deviate
  62046. * the original raw contour. [Limit: >=0] [Units: vx]
  62047. */
  62048. maxSimplificationError: number;
  62049. /**
  62050. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62051. */
  62052. minRegionArea: number;
  62053. /**
  62054. * Any regions with a span count smaller than this value will, if possible,
  62055. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62056. */
  62057. mergeRegionArea: number;
  62058. /**
  62059. * The maximum number of vertices allowed for polygons generated during the
  62060. * contour to polygon conversion process. [Limit: >= 3]
  62061. */
  62062. maxVertsPerPoly: number;
  62063. /**
  62064. * Sets the sampling distance to use when generating the detail mesh.
  62065. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62066. */
  62067. detailSampleDist: number;
  62068. /**
  62069. * The maximum distance the detail mesh surface should deviate from heightfield
  62070. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62071. */
  62072. detailSampleMaxError: number;
  62073. }
  62074. }
  62075. declare module BABYLON {
  62076. /**
  62077. * RecastJS navigation plugin
  62078. */
  62079. export class RecastJSPlugin implements INavigationEnginePlugin {
  62080. /**
  62081. * Reference to the Recast library
  62082. */
  62083. bjsRECAST: any;
  62084. /**
  62085. * plugin name
  62086. */
  62087. name: string;
  62088. /**
  62089. * the first navmesh created. We might extend this to support multiple navmeshes
  62090. */
  62091. navMesh: any;
  62092. /**
  62093. * Initializes the recastJS plugin
  62094. * @param recastInjection can be used to inject your own recast reference
  62095. */
  62096. constructor(recastInjection?: any);
  62097. /**
  62098. * Creates a navigation mesh
  62099. * @param meshes array of all the geometry used to compute the navigatio mesh
  62100. * @param parameters bunch of parameters used to filter geometry
  62101. */
  62102. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62103. /**
  62104. * Create a navigation mesh debug mesh
  62105. * @param scene is where the mesh will be added
  62106. * @returns debug display mesh
  62107. */
  62108. createDebugNavMesh(scene: Scene): Mesh;
  62109. /**
  62110. * Get a navigation mesh constrained position, closest to the parameter position
  62111. * @param position world position
  62112. * @returns the closest point to position constrained by the navigation mesh
  62113. */
  62114. getClosestPoint(position: Vector3): Vector3;
  62115. /**
  62116. * Get a navigation mesh constrained position, within a particular radius
  62117. * @param position world position
  62118. * @param maxRadius the maximum distance to the constrained world position
  62119. * @returns the closest point to position constrained by the navigation mesh
  62120. */
  62121. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62122. /**
  62123. * Compute the final position from a segment made of destination-position
  62124. * @param position world position
  62125. * @param destination world position
  62126. * @returns the resulting point along the navmesh
  62127. */
  62128. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62129. /**
  62130. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62131. * @param start world position
  62132. * @param end world position
  62133. * @returns array containing world position composing the path
  62134. */
  62135. computePath(start: Vector3, end: Vector3): Vector3[];
  62136. /**
  62137. * Create a new Crowd so you can add agents
  62138. * @param maxAgents the maximum agent count in the crowd
  62139. * @param maxAgentRadius the maximum radius an agent can have
  62140. * @param scene to attach the crowd to
  62141. * @returns the crowd you can add agents to
  62142. */
  62143. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62144. /**
  62145. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62146. * The queries will try to find a solution within those bounds
  62147. * default is (1,1,1)
  62148. * @param extent x,y,z value that define the extent around the queries point of reference
  62149. */
  62150. setDefaultQueryExtent(extent: Vector3): void;
  62151. /**
  62152. * Get the Bounding box extent specified by setDefaultQueryExtent
  62153. * @returns the box extent values
  62154. */
  62155. getDefaultQueryExtent(): Vector3;
  62156. /**
  62157. * Disposes
  62158. */
  62159. dispose(): void;
  62160. /**
  62161. * If this plugin is supported
  62162. * @returns true if plugin is supported
  62163. */
  62164. isSupported(): boolean;
  62165. }
  62166. /**
  62167. * Recast detour crowd implementation
  62168. */
  62169. export class RecastJSCrowd implements ICrowd {
  62170. /**
  62171. * Recast/detour plugin
  62172. */
  62173. bjsRECASTPlugin: RecastJSPlugin;
  62174. /**
  62175. * Link to the detour crowd
  62176. */
  62177. recastCrowd: any;
  62178. /**
  62179. * One transform per agent
  62180. */
  62181. transforms: TransformNode[];
  62182. /**
  62183. * All agents created
  62184. */
  62185. agents: number[];
  62186. /**
  62187. * Link to the scene is kept to unregister the crowd from the scene
  62188. */
  62189. private _scene;
  62190. /**
  62191. * Observer for crowd updates
  62192. */
  62193. private _onBeforeAnimationsObserver;
  62194. /**
  62195. * Constructor
  62196. * @param plugin recastJS plugin
  62197. * @param maxAgents the maximum agent count in the crowd
  62198. * @param maxAgentRadius the maximum radius an agent can have
  62199. * @param scene to attach the crowd to
  62200. * @returns the crowd you can add agents to
  62201. */
  62202. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62203. /**
  62204. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62205. * You can attach anything to that node. The node position is updated in the scene update tick.
  62206. * @param pos world position that will be constrained by the navigation mesh
  62207. * @param parameters agent parameters
  62208. * @param transform hooked to the agent that will be update by the scene
  62209. * @returns agent index
  62210. */
  62211. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62212. /**
  62213. * Returns the agent position in world space
  62214. * @param index agent index returned by addAgent
  62215. * @returns world space position
  62216. */
  62217. getAgentPosition(index: number): Vector3;
  62218. /**
  62219. * Returns the agent velocity in world space
  62220. * @param index agent index returned by addAgent
  62221. * @returns world space velocity
  62222. */
  62223. getAgentVelocity(index: number): Vector3;
  62224. /**
  62225. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62226. * @param index agent index returned by addAgent
  62227. * @param destination targeted world position
  62228. */
  62229. agentGoto(index: number, destination: Vector3): void;
  62230. /**
  62231. * Teleport the agent to a new position
  62232. * @param index agent index returned by addAgent
  62233. * @param destination targeted world position
  62234. */
  62235. agentTeleport(index: number, destination: Vector3): void;
  62236. /**
  62237. * Update agent parameters
  62238. * @param index agent index returned by addAgent
  62239. * @param parameters agent parameters
  62240. */
  62241. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62242. /**
  62243. * remove a particular agent previously created
  62244. * @param index agent index returned by addAgent
  62245. */
  62246. removeAgent(index: number): void;
  62247. /**
  62248. * get the list of all agents attached to this crowd
  62249. * @returns list of agent indices
  62250. */
  62251. getAgents(): number[];
  62252. /**
  62253. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62254. * @param deltaTime in seconds
  62255. */
  62256. update(deltaTime: number): void;
  62257. /**
  62258. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62259. * The queries will try to find a solution within those bounds
  62260. * default is (1,1,1)
  62261. * @param extent x,y,z value that define the extent around the queries point of reference
  62262. */
  62263. setDefaultQueryExtent(extent: Vector3): void;
  62264. /**
  62265. * Get the Bounding box extent specified by setDefaultQueryExtent
  62266. * @returns the box extent values
  62267. */
  62268. getDefaultQueryExtent(): Vector3;
  62269. /**
  62270. * Release all resources
  62271. */
  62272. dispose(): void;
  62273. }
  62274. }
  62275. declare module BABYLON {
  62276. /**
  62277. * Class used to enable access to IndexedDB
  62278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62279. */
  62280. export class Database implements IOfflineProvider {
  62281. private _callbackManifestChecked;
  62282. private _currentSceneUrl;
  62283. private _db;
  62284. private _enableSceneOffline;
  62285. private _enableTexturesOffline;
  62286. private _manifestVersionFound;
  62287. private _mustUpdateRessources;
  62288. private _hasReachedQuota;
  62289. private _isSupported;
  62290. private _idbFactory;
  62291. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62292. private static IsUASupportingBlobStorage;
  62293. /**
  62294. * Gets a boolean indicating if Database storate is enabled (off by default)
  62295. */
  62296. static IDBStorageEnabled: boolean;
  62297. /**
  62298. * Gets a boolean indicating if scene must be saved in the database
  62299. */
  62300. get enableSceneOffline(): boolean;
  62301. /**
  62302. * Gets a boolean indicating if textures must be saved in the database
  62303. */
  62304. get enableTexturesOffline(): boolean;
  62305. /**
  62306. * Creates a new Database
  62307. * @param urlToScene defines the url to load the scene
  62308. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62309. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62310. */
  62311. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62312. private static _ParseURL;
  62313. private static _ReturnFullUrlLocation;
  62314. private _checkManifestFile;
  62315. /**
  62316. * Open the database and make it available
  62317. * @param successCallback defines the callback to call on success
  62318. * @param errorCallback defines the callback to call on error
  62319. */
  62320. open(successCallback: () => void, errorCallback: () => void): void;
  62321. /**
  62322. * Loads an image from the database
  62323. * @param url defines the url to load from
  62324. * @param image defines the target DOM image
  62325. */
  62326. loadImage(url: string, image: HTMLImageElement): void;
  62327. private _loadImageFromDBAsync;
  62328. private _saveImageIntoDBAsync;
  62329. private _checkVersionFromDB;
  62330. private _loadVersionFromDBAsync;
  62331. private _saveVersionIntoDBAsync;
  62332. /**
  62333. * Loads a file from database
  62334. * @param url defines the URL to load from
  62335. * @param sceneLoaded defines a callback to call on success
  62336. * @param progressCallBack defines a callback to call when progress changed
  62337. * @param errorCallback defines a callback to call on error
  62338. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62339. */
  62340. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62341. private _loadFileAsync;
  62342. private _saveFileAsync;
  62343. /**
  62344. * Validates if xhr data is correct
  62345. * @param xhr defines the request to validate
  62346. * @param dataType defines the expected data type
  62347. * @returns true if data is correct
  62348. */
  62349. private static _ValidateXHRData;
  62350. }
  62351. }
  62352. declare module BABYLON {
  62353. /** @hidden */
  62354. export var gpuUpdateParticlesPixelShader: {
  62355. name: string;
  62356. shader: string;
  62357. };
  62358. }
  62359. declare module BABYLON {
  62360. /** @hidden */
  62361. export var gpuUpdateParticlesVertexShader: {
  62362. name: string;
  62363. shader: string;
  62364. };
  62365. }
  62366. declare module BABYLON {
  62367. /** @hidden */
  62368. export var clipPlaneFragmentDeclaration2: {
  62369. name: string;
  62370. shader: string;
  62371. };
  62372. }
  62373. declare module BABYLON {
  62374. /** @hidden */
  62375. export var gpuRenderParticlesPixelShader: {
  62376. name: string;
  62377. shader: string;
  62378. };
  62379. }
  62380. declare module BABYLON {
  62381. /** @hidden */
  62382. export var clipPlaneVertexDeclaration2: {
  62383. name: string;
  62384. shader: string;
  62385. };
  62386. }
  62387. declare module BABYLON {
  62388. /** @hidden */
  62389. export var gpuRenderParticlesVertexShader: {
  62390. name: string;
  62391. shader: string;
  62392. };
  62393. }
  62394. declare module BABYLON {
  62395. /**
  62396. * This represents a GPU particle system in Babylon
  62397. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62398. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62399. */
  62400. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62401. /**
  62402. * The layer mask we are rendering the particles through.
  62403. */
  62404. layerMask: number;
  62405. private _capacity;
  62406. private _activeCount;
  62407. private _currentActiveCount;
  62408. private _accumulatedCount;
  62409. private _renderEffect;
  62410. private _updateEffect;
  62411. private _buffer0;
  62412. private _buffer1;
  62413. private _spriteBuffer;
  62414. private _updateVAO;
  62415. private _renderVAO;
  62416. private _targetIndex;
  62417. private _sourceBuffer;
  62418. private _targetBuffer;
  62419. private _engine;
  62420. private _currentRenderId;
  62421. private _started;
  62422. private _stopped;
  62423. private _timeDelta;
  62424. private _randomTexture;
  62425. private _randomTexture2;
  62426. private _attributesStrideSize;
  62427. private _updateEffectOptions;
  62428. private _randomTextureSize;
  62429. private _actualFrame;
  62430. private readonly _rawTextureWidth;
  62431. /**
  62432. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62433. */
  62434. static get IsSupported(): boolean;
  62435. /**
  62436. * An event triggered when the system is disposed.
  62437. */
  62438. onDisposeObservable: Observable<GPUParticleSystem>;
  62439. /**
  62440. * Gets the maximum number of particles active at the same time.
  62441. * @returns The max number of active particles.
  62442. */
  62443. getCapacity(): number;
  62444. /**
  62445. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62446. * to override the particles.
  62447. */
  62448. forceDepthWrite: boolean;
  62449. /**
  62450. * Gets or set the number of active particles
  62451. */
  62452. get activeParticleCount(): number;
  62453. set activeParticleCount(value: number);
  62454. private _preWarmDone;
  62455. /**
  62456. * Specifies if the particles are updated in emitter local space or world space.
  62457. * This is always false for GPU particles
  62458. */
  62459. get isLocal(): boolean;
  62460. set isLocal(value: boolean);
  62461. /**
  62462. * Is this system ready to be used/rendered
  62463. * @return true if the system is ready
  62464. */
  62465. isReady(): boolean;
  62466. /**
  62467. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62468. * @returns True if it has been started, otherwise false.
  62469. */
  62470. isStarted(): boolean;
  62471. /**
  62472. * Starts the particle system and begins to emit
  62473. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62474. */
  62475. start(delay?: number): void;
  62476. /**
  62477. * Stops the particle system.
  62478. */
  62479. stop(): void;
  62480. /**
  62481. * Remove all active particles
  62482. */
  62483. reset(): void;
  62484. /**
  62485. * Returns the string "GPUParticleSystem"
  62486. * @returns a string containing the class name
  62487. */
  62488. getClassName(): string;
  62489. private _colorGradientsTexture;
  62490. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62491. /**
  62492. * Adds a new color gradient
  62493. * @param gradient defines the gradient to use (between 0 and 1)
  62494. * @param color1 defines the color to affect to the specified gradient
  62495. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62496. * @returns the current particle system
  62497. */
  62498. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62499. /**
  62500. * Remove a specific color gradient
  62501. * @param gradient defines the gradient to remove
  62502. * @returns the current particle system
  62503. */
  62504. removeColorGradient(gradient: number): GPUParticleSystem;
  62505. private _angularSpeedGradientsTexture;
  62506. private _sizeGradientsTexture;
  62507. private _velocityGradientsTexture;
  62508. private _limitVelocityGradientsTexture;
  62509. private _dragGradientsTexture;
  62510. private _addFactorGradient;
  62511. /**
  62512. * Adds a new size gradient
  62513. * @param gradient defines the gradient to use (between 0 and 1)
  62514. * @param factor defines the size factor to affect to the specified gradient
  62515. * @returns the current particle system
  62516. */
  62517. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62518. /**
  62519. * Remove a specific size gradient
  62520. * @param gradient defines the gradient to remove
  62521. * @returns the current particle system
  62522. */
  62523. removeSizeGradient(gradient: number): GPUParticleSystem;
  62524. /**
  62525. * Adds a new angular speed gradient
  62526. * @param gradient defines the gradient to use (between 0 and 1)
  62527. * @param factor defines the angular speed to affect to the specified gradient
  62528. * @returns the current particle system
  62529. */
  62530. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62531. /**
  62532. * Remove a specific angular speed gradient
  62533. * @param gradient defines the gradient to remove
  62534. * @returns the current particle system
  62535. */
  62536. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62537. /**
  62538. * Adds a new velocity gradient
  62539. * @param gradient defines the gradient to use (between 0 and 1)
  62540. * @param factor defines the velocity to affect to the specified gradient
  62541. * @returns the current particle system
  62542. */
  62543. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62544. /**
  62545. * Remove a specific velocity gradient
  62546. * @param gradient defines the gradient to remove
  62547. * @returns the current particle system
  62548. */
  62549. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62550. /**
  62551. * Adds a new limit velocity gradient
  62552. * @param gradient defines the gradient to use (between 0 and 1)
  62553. * @param factor defines the limit velocity value to affect to the specified gradient
  62554. * @returns the current particle system
  62555. */
  62556. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62557. /**
  62558. * Remove a specific limit velocity gradient
  62559. * @param gradient defines the gradient to remove
  62560. * @returns the current particle system
  62561. */
  62562. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62563. /**
  62564. * Adds a new drag gradient
  62565. * @param gradient defines the gradient to use (between 0 and 1)
  62566. * @param factor defines the drag value to affect to the specified gradient
  62567. * @returns the current particle system
  62568. */
  62569. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62570. /**
  62571. * Remove a specific drag gradient
  62572. * @param gradient defines the gradient to remove
  62573. * @returns the current particle system
  62574. */
  62575. removeDragGradient(gradient: number): GPUParticleSystem;
  62576. /**
  62577. * Not supported by GPUParticleSystem
  62578. * @param gradient defines the gradient to use (between 0 and 1)
  62579. * @param factor defines the emit rate value to affect to the specified gradient
  62580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62581. * @returns the current particle system
  62582. */
  62583. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62584. /**
  62585. * Not supported by GPUParticleSystem
  62586. * @param gradient defines the gradient to remove
  62587. * @returns the current particle system
  62588. */
  62589. removeEmitRateGradient(gradient: number): IParticleSystem;
  62590. /**
  62591. * Not supported by GPUParticleSystem
  62592. * @param gradient defines the gradient to use (between 0 and 1)
  62593. * @param factor defines the start size value to affect to the specified gradient
  62594. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62595. * @returns the current particle system
  62596. */
  62597. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62598. /**
  62599. * Not supported by GPUParticleSystem
  62600. * @param gradient defines the gradient to remove
  62601. * @returns the current particle system
  62602. */
  62603. removeStartSizeGradient(gradient: number): IParticleSystem;
  62604. /**
  62605. * Not supported by GPUParticleSystem
  62606. * @param gradient defines the gradient to use (between 0 and 1)
  62607. * @param min defines the color remap minimal range
  62608. * @param max defines the color remap maximal range
  62609. * @returns the current particle system
  62610. */
  62611. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62612. /**
  62613. * Not supported by GPUParticleSystem
  62614. * @param gradient defines the gradient to remove
  62615. * @returns the current particle system
  62616. */
  62617. removeColorRemapGradient(): IParticleSystem;
  62618. /**
  62619. * Not supported by GPUParticleSystem
  62620. * @param gradient defines the gradient to use (between 0 and 1)
  62621. * @param min defines the alpha remap minimal range
  62622. * @param max defines the alpha remap maximal range
  62623. * @returns the current particle system
  62624. */
  62625. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62626. /**
  62627. * Not supported by GPUParticleSystem
  62628. * @param gradient defines the gradient to remove
  62629. * @returns the current particle system
  62630. */
  62631. removeAlphaRemapGradient(): IParticleSystem;
  62632. /**
  62633. * Not supported by GPUParticleSystem
  62634. * @param gradient defines the gradient to use (between 0 and 1)
  62635. * @param color defines the color to affect to the specified gradient
  62636. * @returns the current particle system
  62637. */
  62638. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62639. /**
  62640. * Not supported by GPUParticleSystem
  62641. * @param gradient defines the gradient to remove
  62642. * @returns the current particle system
  62643. */
  62644. removeRampGradient(): IParticleSystem;
  62645. /**
  62646. * Not supported by GPUParticleSystem
  62647. * @returns the list of ramp gradients
  62648. */
  62649. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62650. /**
  62651. * Not supported by GPUParticleSystem
  62652. * Gets or sets a boolean indicating that ramp gradients must be used
  62653. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62654. */
  62655. get useRampGradients(): boolean;
  62656. set useRampGradients(value: boolean);
  62657. /**
  62658. * Not supported by GPUParticleSystem
  62659. * @param gradient defines the gradient to use (between 0 and 1)
  62660. * @param factor defines the life time factor to affect to the specified gradient
  62661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62662. * @returns the current particle system
  62663. */
  62664. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62665. /**
  62666. * Not supported by GPUParticleSystem
  62667. * @param gradient defines the gradient to remove
  62668. * @returns the current particle system
  62669. */
  62670. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62671. /**
  62672. * Instantiates a GPU particle system.
  62673. * 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.
  62674. * @param name The name of the particle system
  62675. * @param options The options used to create the system
  62676. * @param scene The scene the particle system belongs to
  62677. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62678. */
  62679. constructor(name: string, options: Partial<{
  62680. capacity: number;
  62681. randomTextureSize: number;
  62682. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62683. protected _reset(): void;
  62684. private _createUpdateVAO;
  62685. private _createRenderVAO;
  62686. private _initialize;
  62687. /** @hidden */
  62688. _recreateUpdateEffect(): void;
  62689. /** @hidden */
  62690. _recreateRenderEffect(): void;
  62691. /**
  62692. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62693. * @param preWarm defines if we are in the pre-warmimg phase
  62694. */
  62695. animate(preWarm?: boolean): void;
  62696. private _createFactorGradientTexture;
  62697. private _createSizeGradientTexture;
  62698. private _createAngularSpeedGradientTexture;
  62699. private _createVelocityGradientTexture;
  62700. private _createLimitVelocityGradientTexture;
  62701. private _createDragGradientTexture;
  62702. private _createColorGradientTexture;
  62703. /**
  62704. * Renders the particle system in its current state
  62705. * @param preWarm defines if the system should only update the particles but not render them
  62706. * @returns the current number of particles
  62707. */
  62708. render(preWarm?: boolean): number;
  62709. /**
  62710. * Rebuilds the particle system
  62711. */
  62712. rebuild(): void;
  62713. private _releaseBuffers;
  62714. private _releaseVAOs;
  62715. /**
  62716. * Disposes the particle system and free the associated resources
  62717. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62718. */
  62719. dispose(disposeTexture?: boolean): void;
  62720. /**
  62721. * Clones the particle system.
  62722. * @param name The name of the cloned object
  62723. * @param newEmitter The new emitter to use
  62724. * @returns the cloned particle system
  62725. */
  62726. clone(name: string, newEmitter: any): GPUParticleSystem;
  62727. /**
  62728. * Serializes the particle system to a JSON object.
  62729. * @returns the JSON object
  62730. */
  62731. serialize(): any;
  62732. /**
  62733. * Parses a JSON object to create a GPU particle system.
  62734. * @param parsedParticleSystem The JSON object to parse
  62735. * @param scene The scene to create the particle system in
  62736. * @param rootUrl The root url to use to load external dependencies like texture
  62737. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62738. * @returns the parsed GPU particle system
  62739. */
  62740. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62741. }
  62742. }
  62743. declare module BABYLON {
  62744. /**
  62745. * Represents a set of particle systems working together to create a specific effect
  62746. */
  62747. export class ParticleSystemSet implements IDisposable {
  62748. /**
  62749. * Gets or sets base Assets URL
  62750. */
  62751. static BaseAssetsUrl: string;
  62752. private _emitterCreationOptions;
  62753. private _emitterNode;
  62754. /**
  62755. * Gets the particle system list
  62756. */
  62757. systems: IParticleSystem[];
  62758. /**
  62759. * Gets the emitter node used with this set
  62760. */
  62761. get emitterNode(): Nullable<TransformNode>;
  62762. /**
  62763. * Creates a new emitter mesh as a sphere
  62764. * @param options defines the options used to create the sphere
  62765. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62766. * @param scene defines the hosting scene
  62767. */
  62768. setEmitterAsSphere(options: {
  62769. diameter: number;
  62770. segments: number;
  62771. color: Color3;
  62772. }, renderingGroupId: number, scene: Scene): void;
  62773. /**
  62774. * Starts all particle systems of the set
  62775. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62776. */
  62777. start(emitter?: AbstractMesh): void;
  62778. /**
  62779. * Release all associated resources
  62780. */
  62781. dispose(): void;
  62782. /**
  62783. * Serialize the set into a JSON compatible object
  62784. * @returns a JSON compatible representation of the set
  62785. */
  62786. serialize(): any;
  62787. /**
  62788. * Parse a new ParticleSystemSet from a serialized source
  62789. * @param data defines a JSON compatible representation of the set
  62790. * @param scene defines the hosting scene
  62791. * @param gpu defines if we want GPU particles or CPU particles
  62792. * @returns a new ParticleSystemSet
  62793. */
  62794. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62795. }
  62796. }
  62797. declare module BABYLON {
  62798. /**
  62799. * This class is made for on one-liner static method to help creating particle system set.
  62800. */
  62801. export class ParticleHelper {
  62802. /**
  62803. * Gets or sets base Assets URL
  62804. */
  62805. static BaseAssetsUrl: string;
  62806. /**
  62807. * Create a default particle system that you can tweak
  62808. * @param emitter defines the emitter to use
  62809. * @param capacity defines the system capacity (default is 500 particles)
  62810. * @param scene defines the hosting scene
  62811. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62812. * @returns the new Particle system
  62813. */
  62814. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62815. /**
  62816. * This is the main static method (one-liner) of this helper to create different particle systems
  62817. * @param type This string represents the type to the particle system to create
  62818. * @param scene The scene where the particle system should live
  62819. * @param gpu If the system will use gpu
  62820. * @returns the ParticleSystemSet created
  62821. */
  62822. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62823. /**
  62824. * Static function used to export a particle system to a ParticleSystemSet variable.
  62825. * Please note that the emitter shape is not exported
  62826. * @param systems defines the particle systems to export
  62827. * @returns the created particle system set
  62828. */
  62829. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62830. }
  62831. }
  62832. declare module BABYLON {
  62833. interface Engine {
  62834. /**
  62835. * Create an effect to use with particle systems.
  62836. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62837. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62838. * @param uniformsNames defines a list of attribute names
  62839. * @param samplers defines an array of string used to represent textures
  62840. * @param defines defines the string containing the defines to use to compile the shaders
  62841. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62842. * @param onCompiled defines a function to call when the effect creation is successful
  62843. * @param onError defines a function to call when the effect creation has failed
  62844. * @returns the new Effect
  62845. */
  62846. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62847. }
  62848. interface Mesh {
  62849. /**
  62850. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62851. * @returns an array of IParticleSystem
  62852. */
  62853. getEmittedParticleSystems(): IParticleSystem[];
  62854. /**
  62855. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62856. * @returns an array of IParticleSystem
  62857. */
  62858. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62859. }
  62860. /**
  62861. * @hidden
  62862. */
  62863. export var _IDoNeedToBeInTheBuild: number;
  62864. }
  62865. declare module BABYLON {
  62866. /** Defines the 4 color options */
  62867. export enum PointColor {
  62868. /** color value */
  62869. Color = 2,
  62870. /** uv value */
  62871. UV = 1,
  62872. /** random value */
  62873. Random = 0,
  62874. /** stated value */
  62875. Stated = 3
  62876. }
  62877. /**
  62878. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62879. * 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.
  62880. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62881. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62882. *
  62883. * Full documentation here : TO BE ENTERED
  62884. */
  62885. export class PointsCloudSystem implements IDisposable {
  62886. /**
  62887. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62888. * Example : var p = SPS.particles[i];
  62889. */
  62890. particles: CloudPoint[];
  62891. /**
  62892. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62893. */
  62894. nbParticles: number;
  62895. /**
  62896. * This a counter for your own usage. It's not set by any SPS functions.
  62897. */
  62898. counter: number;
  62899. /**
  62900. * The PCS name. This name is also given to the underlying mesh.
  62901. */
  62902. name: string;
  62903. /**
  62904. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62905. */
  62906. mesh: Mesh;
  62907. /**
  62908. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62909. * Please read :
  62910. */
  62911. vars: any;
  62912. /**
  62913. * @hidden
  62914. */
  62915. _size: number;
  62916. private _scene;
  62917. private _promises;
  62918. private _positions;
  62919. private _indices;
  62920. private _normals;
  62921. private _colors;
  62922. private _uvs;
  62923. private _indices32;
  62924. private _positions32;
  62925. private _colors32;
  62926. private _uvs32;
  62927. private _updatable;
  62928. private _isVisibilityBoxLocked;
  62929. private _alwaysVisible;
  62930. private _groups;
  62931. private _groupCounter;
  62932. private _computeParticleColor;
  62933. private _computeParticleTexture;
  62934. private _computeParticleRotation;
  62935. private _computeBoundingBox;
  62936. private _isReady;
  62937. /**
  62938. * Creates a PCS (Points Cloud System) object
  62939. * @param name (String) is the PCS name, this will be the underlying mesh name
  62940. * @param pointSize (number) is the size for each point
  62941. * @param scene (Scene) is the scene in which the PCS is added
  62942. * @param options defines the options of the PCS e.g.
  62943. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62944. */
  62945. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62946. updatable?: boolean;
  62947. });
  62948. /**
  62949. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62950. * If no points were added to the PCS, the returned mesh is just a single point.
  62951. * @returns a promise for the created mesh
  62952. */
  62953. buildMeshAsync(): Promise<Mesh>;
  62954. /**
  62955. * @hidden
  62956. */
  62957. private _buildMesh;
  62958. private _addParticle;
  62959. private _randomUnitVector;
  62960. private _getColorIndicesForCoord;
  62961. private _setPointsColorOrUV;
  62962. private _colorFromTexture;
  62963. private _calculateDensity;
  62964. /**
  62965. * Adds points to the PCS in random positions within a unit sphere
  62966. * @param nb (positive integer) the number of particles to be created from this model
  62967. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62968. * @returns the number of groups in the system
  62969. */
  62970. addPoints(nb: number, pointFunction?: any): number;
  62971. /**
  62972. * Adds points to the PCS from the surface of the model shape
  62973. * @param mesh is any Mesh object that will be used as a surface model for the points
  62974. * @param nb (positive integer) the number of particles to be created from this model
  62975. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62976. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62977. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62978. * @returns the number of groups in the system
  62979. */
  62980. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62981. /**
  62982. * Adds points to the PCS inside the model shape
  62983. * @param mesh is any Mesh object that will be used as a surface model for the points
  62984. * @param nb (positive integer) the number of particles to be created from this model
  62985. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62986. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62987. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62988. * @returns the number of groups in the system
  62989. */
  62990. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62991. /**
  62992. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62993. * This method calls `updateParticle()` for each particle of the SPS.
  62994. * For an animated SPS, it is usually called within the render loop.
  62995. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62996. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62997. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62998. * @returns the PCS.
  62999. */
  63000. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63001. /**
  63002. * Disposes the PCS.
  63003. */
  63004. dispose(): void;
  63005. /**
  63006. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63007. * doc :
  63008. * @returns the PCS.
  63009. */
  63010. refreshVisibleSize(): PointsCloudSystem;
  63011. /**
  63012. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63013. * @param size the size (float) of the visibility box
  63014. * note : this doesn't lock the PCS mesh bounding box.
  63015. * doc :
  63016. */
  63017. setVisibilityBox(size: number): void;
  63018. /**
  63019. * Gets whether the PCS is always visible or not
  63020. * doc :
  63021. */
  63022. get isAlwaysVisible(): boolean;
  63023. /**
  63024. * Sets the PCS as always visible or not
  63025. * doc :
  63026. */
  63027. set isAlwaysVisible(val: boolean);
  63028. /**
  63029. * Tells to `setParticles()` to compute the particle rotations or not
  63030. * Default value : false. The PCS is faster when it's set to false
  63031. * Note : particle rotations are only applied to parent particles
  63032. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63033. */
  63034. set computeParticleRotation(val: boolean);
  63035. /**
  63036. * Tells to `setParticles()` to compute the particle colors or not.
  63037. * Default value : true. The PCS is faster when it's set to false.
  63038. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63039. */
  63040. set computeParticleColor(val: boolean);
  63041. set computeParticleTexture(val: boolean);
  63042. /**
  63043. * Gets if `setParticles()` computes the particle colors or not.
  63044. * Default value : false. The PCS is faster when it's set to false.
  63045. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63046. */
  63047. get computeParticleColor(): boolean;
  63048. /**
  63049. * Gets if `setParticles()` computes the particle textures or not.
  63050. * Default value : false. The PCS is faster when it's set to false.
  63051. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63052. */
  63053. get computeParticleTexture(): boolean;
  63054. /**
  63055. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63056. */
  63057. set computeBoundingBox(val: boolean);
  63058. /**
  63059. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63060. */
  63061. get computeBoundingBox(): boolean;
  63062. /**
  63063. * This function does nothing. It may be overwritten to set all the particle first values.
  63064. * The PCS doesn't call this function, you may have to call it by your own.
  63065. * doc :
  63066. */
  63067. initParticles(): void;
  63068. /**
  63069. * This function does nothing. It may be overwritten to recycle a particle
  63070. * The PCS doesn't call this function, you can to call it
  63071. * doc :
  63072. * @param particle The particle to recycle
  63073. * @returns the recycled particle
  63074. */
  63075. recycleParticle(particle: CloudPoint): CloudPoint;
  63076. /**
  63077. * Updates a particle : this function should be overwritten by the user.
  63078. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63079. * doc :
  63080. * @example : just set a particle position or velocity and recycle conditions
  63081. * @param particle The particle to update
  63082. * @returns the updated particle
  63083. */
  63084. updateParticle(particle: CloudPoint): CloudPoint;
  63085. /**
  63086. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63087. * This does nothing and may be overwritten by the user.
  63088. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63089. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63090. * @param update the boolean update value actually passed to setParticles()
  63091. */
  63092. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63093. /**
  63094. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63095. * This will be passed three parameters.
  63096. * This does nothing and may be overwritten by the user.
  63097. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63098. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63099. * @param update the boolean update value actually passed to setParticles()
  63100. */
  63101. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63102. }
  63103. }
  63104. declare module BABYLON {
  63105. /**
  63106. * Represents one particle of a points cloud system.
  63107. */
  63108. export class CloudPoint {
  63109. /**
  63110. * particle global index
  63111. */
  63112. idx: number;
  63113. /**
  63114. * The color of the particle
  63115. */
  63116. color: Nullable<Color4>;
  63117. /**
  63118. * The world space position of the particle.
  63119. */
  63120. position: Vector3;
  63121. /**
  63122. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63123. */
  63124. rotation: Vector3;
  63125. /**
  63126. * The world space rotation quaternion of the particle.
  63127. */
  63128. rotationQuaternion: Nullable<Quaternion>;
  63129. /**
  63130. * The uv of the particle.
  63131. */
  63132. uv: Nullable<Vector2>;
  63133. /**
  63134. * The current speed of the particle.
  63135. */
  63136. velocity: Vector3;
  63137. /**
  63138. * The pivot point in the particle local space.
  63139. */
  63140. pivot: Vector3;
  63141. /**
  63142. * Must the particle be translated from its pivot point in its local space ?
  63143. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63144. * Default : false
  63145. */
  63146. translateFromPivot: boolean;
  63147. /**
  63148. * Index of this particle in the global "positions" array (Internal use)
  63149. * @hidden
  63150. */
  63151. _pos: number;
  63152. /**
  63153. * @hidden Index of this particle in the global "indices" array (Internal use)
  63154. */
  63155. _ind: number;
  63156. /**
  63157. * Group this particle belongs to
  63158. */
  63159. _group: PointsGroup;
  63160. /**
  63161. * Group id of this particle
  63162. */
  63163. groupId: number;
  63164. /**
  63165. * Index of the particle in its group id (Internal use)
  63166. */
  63167. idxInGroup: number;
  63168. /**
  63169. * @hidden Particle BoundingInfo object (Internal use)
  63170. */
  63171. _boundingInfo: BoundingInfo;
  63172. /**
  63173. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63174. */
  63175. _pcs: PointsCloudSystem;
  63176. /**
  63177. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63178. */
  63179. _stillInvisible: boolean;
  63180. /**
  63181. * @hidden Last computed particle rotation matrix
  63182. */
  63183. _rotationMatrix: number[];
  63184. /**
  63185. * Parent particle Id, if any.
  63186. * Default null.
  63187. */
  63188. parentId: Nullable<number>;
  63189. /**
  63190. * @hidden Internal global position in the PCS.
  63191. */
  63192. _globalPosition: Vector3;
  63193. /**
  63194. * Creates a Point Cloud object.
  63195. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63196. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63197. * @param group (PointsGroup) is the group the particle belongs to
  63198. * @param groupId (integer) is the group identifier in the PCS.
  63199. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63200. * @param pcs defines the PCS it is associated to
  63201. */
  63202. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63203. /**
  63204. * get point size
  63205. */
  63206. get size(): Vector3;
  63207. /**
  63208. * Set point size
  63209. */
  63210. set size(scale: Vector3);
  63211. /**
  63212. * Legacy support, changed quaternion to rotationQuaternion
  63213. */
  63214. get quaternion(): Nullable<Quaternion>;
  63215. /**
  63216. * Legacy support, changed quaternion to rotationQuaternion
  63217. */
  63218. set quaternion(q: Nullable<Quaternion>);
  63219. /**
  63220. * Returns a boolean. True if the particle intersects a mesh, else false
  63221. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63222. * @param target is the object (point or mesh) what the intersection is computed against
  63223. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63224. * @returns true if it intersects
  63225. */
  63226. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63227. /**
  63228. * get the rotation matrix of the particle
  63229. * @hidden
  63230. */
  63231. getRotationMatrix(m: Matrix): void;
  63232. }
  63233. /**
  63234. * Represents a group of points in a points cloud system
  63235. * * PCS internal tool, don't use it manually.
  63236. */
  63237. export class PointsGroup {
  63238. /**
  63239. * The group id
  63240. * @hidden
  63241. */
  63242. groupID: number;
  63243. /**
  63244. * image data for group (internal use)
  63245. * @hidden
  63246. */
  63247. _groupImageData: Nullable<ArrayBufferView>;
  63248. /**
  63249. * Image Width (internal use)
  63250. * @hidden
  63251. */
  63252. _groupImgWidth: number;
  63253. /**
  63254. * Image Height (internal use)
  63255. * @hidden
  63256. */
  63257. _groupImgHeight: number;
  63258. /**
  63259. * Custom position function (internal use)
  63260. * @hidden
  63261. */
  63262. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63263. /**
  63264. * density per facet for surface points
  63265. * @hidden
  63266. */
  63267. _groupDensity: number[];
  63268. /**
  63269. * Only when points are colored by texture carries pointer to texture list array
  63270. * @hidden
  63271. */
  63272. _textureNb: number;
  63273. /**
  63274. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63275. * PCS internal tool, don't use it manually.
  63276. * @hidden
  63277. */
  63278. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63279. }
  63280. }
  63281. declare module BABYLON {
  63282. interface Scene {
  63283. /** @hidden (Backing field) */
  63284. _physicsEngine: Nullable<IPhysicsEngine>;
  63285. /** @hidden */
  63286. _physicsTimeAccumulator: number;
  63287. /**
  63288. * Gets the current physics engine
  63289. * @returns a IPhysicsEngine or null if none attached
  63290. */
  63291. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63292. /**
  63293. * Enables physics to the current scene
  63294. * @param gravity defines the scene's gravity for the physics engine
  63295. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63296. * @return a boolean indicating if the physics engine was initialized
  63297. */
  63298. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63299. /**
  63300. * Disables and disposes the physics engine associated with the scene
  63301. */
  63302. disablePhysicsEngine(): void;
  63303. /**
  63304. * Gets a boolean indicating if there is an active physics engine
  63305. * @returns a boolean indicating if there is an active physics engine
  63306. */
  63307. isPhysicsEnabled(): boolean;
  63308. /**
  63309. * Deletes a physics compound impostor
  63310. * @param compound defines the compound to delete
  63311. */
  63312. deleteCompoundImpostor(compound: any): void;
  63313. /**
  63314. * An event triggered when physic simulation is about to be run
  63315. */
  63316. onBeforePhysicsObservable: Observable<Scene>;
  63317. /**
  63318. * An event triggered when physic simulation has been done
  63319. */
  63320. onAfterPhysicsObservable: Observable<Scene>;
  63321. }
  63322. interface AbstractMesh {
  63323. /** @hidden */
  63324. _physicsImpostor: Nullable<PhysicsImpostor>;
  63325. /**
  63326. * Gets or sets impostor used for physic simulation
  63327. * @see http://doc.babylonjs.com/features/physics_engine
  63328. */
  63329. physicsImpostor: Nullable<PhysicsImpostor>;
  63330. /**
  63331. * Gets the current physics impostor
  63332. * @see http://doc.babylonjs.com/features/physics_engine
  63333. * @returns a physics impostor or null
  63334. */
  63335. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63336. /** Apply a physic impulse to the mesh
  63337. * @param force defines the force to apply
  63338. * @param contactPoint defines where to apply the force
  63339. * @returns the current mesh
  63340. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63341. */
  63342. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63343. /**
  63344. * Creates a physic joint between two meshes
  63345. * @param otherMesh defines the other mesh to use
  63346. * @param pivot1 defines the pivot to use on this mesh
  63347. * @param pivot2 defines the pivot to use on the other mesh
  63348. * @param options defines additional options (can be plugin dependent)
  63349. * @returns the current mesh
  63350. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63351. */
  63352. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63353. /** @hidden */
  63354. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63355. }
  63356. /**
  63357. * Defines the physics engine scene component responsible to manage a physics engine
  63358. */
  63359. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63360. /**
  63361. * The component name helpful to identify the component in the list of scene components.
  63362. */
  63363. readonly name: string;
  63364. /**
  63365. * The scene the component belongs to.
  63366. */
  63367. scene: Scene;
  63368. /**
  63369. * Creates a new instance of the component for the given scene
  63370. * @param scene Defines the scene to register the component in
  63371. */
  63372. constructor(scene: Scene);
  63373. /**
  63374. * Registers the component in a given scene
  63375. */
  63376. register(): void;
  63377. /**
  63378. * Rebuilds the elements related to this component in case of
  63379. * context lost for instance.
  63380. */
  63381. rebuild(): void;
  63382. /**
  63383. * Disposes the component and the associated ressources
  63384. */
  63385. dispose(): void;
  63386. }
  63387. }
  63388. declare module BABYLON {
  63389. /**
  63390. * A helper for physics simulations
  63391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63392. */
  63393. export class PhysicsHelper {
  63394. private _scene;
  63395. private _physicsEngine;
  63396. /**
  63397. * Initializes the Physics helper
  63398. * @param scene Babylon.js scene
  63399. */
  63400. constructor(scene: Scene);
  63401. /**
  63402. * Applies a radial explosion impulse
  63403. * @param origin the origin of the explosion
  63404. * @param radiusOrEventOptions the radius or the options of radial explosion
  63405. * @param strength the explosion strength
  63406. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63407. * @returns A physics radial explosion event, or null
  63408. */
  63409. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63410. /**
  63411. * Applies a radial explosion force
  63412. * @param origin the origin of the explosion
  63413. * @param radiusOrEventOptions the radius or the options of radial explosion
  63414. * @param strength the explosion strength
  63415. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63416. * @returns A physics radial explosion event, or null
  63417. */
  63418. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63419. /**
  63420. * Creates a gravitational field
  63421. * @param origin the origin of the explosion
  63422. * @param radiusOrEventOptions the radius or the options of radial explosion
  63423. * @param strength the explosion strength
  63424. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63425. * @returns A physics gravitational field event, or null
  63426. */
  63427. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63428. /**
  63429. * Creates a physics updraft event
  63430. * @param origin the origin of the updraft
  63431. * @param radiusOrEventOptions the radius or the options of the updraft
  63432. * @param strength the strength of the updraft
  63433. * @param height the height of the updraft
  63434. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63435. * @returns A physics updraft event, or null
  63436. */
  63437. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63438. /**
  63439. * Creates a physics vortex event
  63440. * @param origin the of the vortex
  63441. * @param radiusOrEventOptions the radius or the options of the vortex
  63442. * @param strength the strength of the vortex
  63443. * @param height the height of the vortex
  63444. * @returns a Physics vortex event, or null
  63445. * A physics vortex event or null
  63446. */
  63447. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63448. }
  63449. /**
  63450. * Represents a physics radial explosion event
  63451. */
  63452. class PhysicsRadialExplosionEvent {
  63453. private _scene;
  63454. private _options;
  63455. private _sphere;
  63456. private _dataFetched;
  63457. /**
  63458. * Initializes a radial explosioin event
  63459. * @param _scene BabylonJS scene
  63460. * @param _options The options for the vortex event
  63461. */
  63462. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63463. /**
  63464. * Returns the data related to the radial explosion event (sphere).
  63465. * @returns The radial explosion event data
  63466. */
  63467. getData(): PhysicsRadialExplosionEventData;
  63468. /**
  63469. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63470. * @param impostor A physics imposter
  63471. * @param origin the origin of the explosion
  63472. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63473. */
  63474. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63475. /**
  63476. * Triggers affecterd impostors callbacks
  63477. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63478. */
  63479. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63480. /**
  63481. * Disposes the sphere.
  63482. * @param force Specifies if the sphere should be disposed by force
  63483. */
  63484. dispose(force?: boolean): void;
  63485. /*** Helpers ***/
  63486. private _prepareSphere;
  63487. private _intersectsWithSphere;
  63488. }
  63489. /**
  63490. * Represents a gravitational field event
  63491. */
  63492. class PhysicsGravitationalFieldEvent {
  63493. private _physicsHelper;
  63494. private _scene;
  63495. private _origin;
  63496. private _options;
  63497. private _tickCallback;
  63498. private _sphere;
  63499. private _dataFetched;
  63500. /**
  63501. * Initializes the physics gravitational field event
  63502. * @param _physicsHelper A physics helper
  63503. * @param _scene BabylonJS scene
  63504. * @param _origin The origin position of the gravitational field event
  63505. * @param _options The options for the vortex event
  63506. */
  63507. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63508. /**
  63509. * Returns the data related to the gravitational field event (sphere).
  63510. * @returns A gravitational field event
  63511. */
  63512. getData(): PhysicsGravitationalFieldEventData;
  63513. /**
  63514. * Enables the gravitational field.
  63515. */
  63516. enable(): void;
  63517. /**
  63518. * Disables the gravitational field.
  63519. */
  63520. disable(): void;
  63521. /**
  63522. * Disposes the sphere.
  63523. * @param force The force to dispose from the gravitational field event
  63524. */
  63525. dispose(force?: boolean): void;
  63526. private _tick;
  63527. }
  63528. /**
  63529. * Represents a physics updraft event
  63530. */
  63531. class PhysicsUpdraftEvent {
  63532. private _scene;
  63533. private _origin;
  63534. private _options;
  63535. private _physicsEngine;
  63536. private _originTop;
  63537. private _originDirection;
  63538. private _tickCallback;
  63539. private _cylinder;
  63540. private _cylinderPosition;
  63541. private _dataFetched;
  63542. /**
  63543. * Initializes the physics updraft event
  63544. * @param _scene BabylonJS scene
  63545. * @param _origin The origin position of the updraft
  63546. * @param _options The options for the updraft event
  63547. */
  63548. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63549. /**
  63550. * Returns the data related to the updraft event (cylinder).
  63551. * @returns A physics updraft event
  63552. */
  63553. getData(): PhysicsUpdraftEventData;
  63554. /**
  63555. * Enables the updraft.
  63556. */
  63557. enable(): void;
  63558. /**
  63559. * Disables the updraft.
  63560. */
  63561. disable(): void;
  63562. /**
  63563. * Disposes the cylinder.
  63564. * @param force Specifies if the updraft should be disposed by force
  63565. */
  63566. dispose(force?: boolean): void;
  63567. private getImpostorHitData;
  63568. private _tick;
  63569. /*** Helpers ***/
  63570. private _prepareCylinder;
  63571. private _intersectsWithCylinder;
  63572. }
  63573. /**
  63574. * Represents a physics vortex event
  63575. */
  63576. class PhysicsVortexEvent {
  63577. private _scene;
  63578. private _origin;
  63579. private _options;
  63580. private _physicsEngine;
  63581. private _originTop;
  63582. private _tickCallback;
  63583. private _cylinder;
  63584. private _cylinderPosition;
  63585. private _dataFetched;
  63586. /**
  63587. * Initializes the physics vortex event
  63588. * @param _scene The BabylonJS scene
  63589. * @param _origin The origin position of the vortex
  63590. * @param _options The options for the vortex event
  63591. */
  63592. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63593. /**
  63594. * Returns the data related to the vortex event (cylinder).
  63595. * @returns The physics vortex event data
  63596. */
  63597. getData(): PhysicsVortexEventData;
  63598. /**
  63599. * Enables the vortex.
  63600. */
  63601. enable(): void;
  63602. /**
  63603. * Disables the cortex.
  63604. */
  63605. disable(): void;
  63606. /**
  63607. * Disposes the sphere.
  63608. * @param force
  63609. */
  63610. dispose(force?: boolean): void;
  63611. private getImpostorHitData;
  63612. private _tick;
  63613. /*** Helpers ***/
  63614. private _prepareCylinder;
  63615. private _intersectsWithCylinder;
  63616. }
  63617. /**
  63618. * Options fot the radial explosion event
  63619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63620. */
  63621. export class PhysicsRadialExplosionEventOptions {
  63622. /**
  63623. * The radius of the sphere for the radial explosion.
  63624. */
  63625. radius: number;
  63626. /**
  63627. * The strenth of the explosion.
  63628. */
  63629. strength: number;
  63630. /**
  63631. * The strenght of the force in correspondence to the distance of the affected object
  63632. */
  63633. falloff: PhysicsRadialImpulseFalloff;
  63634. /**
  63635. * Sphere options for the radial explosion.
  63636. */
  63637. sphere: {
  63638. segments: number;
  63639. diameter: number;
  63640. };
  63641. /**
  63642. * Sphere options for the radial explosion.
  63643. */
  63644. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63645. }
  63646. /**
  63647. * Options fot the updraft event
  63648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63649. */
  63650. export class PhysicsUpdraftEventOptions {
  63651. /**
  63652. * The radius of the cylinder for the vortex
  63653. */
  63654. radius: number;
  63655. /**
  63656. * The strenth of the updraft.
  63657. */
  63658. strength: number;
  63659. /**
  63660. * The height of the cylinder for the updraft.
  63661. */
  63662. height: number;
  63663. /**
  63664. * The mode for the the updraft.
  63665. */
  63666. updraftMode: PhysicsUpdraftMode;
  63667. }
  63668. /**
  63669. * Options fot the vortex event
  63670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63671. */
  63672. export class PhysicsVortexEventOptions {
  63673. /**
  63674. * The radius of the cylinder for the vortex
  63675. */
  63676. radius: number;
  63677. /**
  63678. * The strenth of the vortex.
  63679. */
  63680. strength: number;
  63681. /**
  63682. * The height of the cylinder for the vortex.
  63683. */
  63684. height: number;
  63685. /**
  63686. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63687. */
  63688. centripetalForceThreshold: number;
  63689. /**
  63690. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63691. */
  63692. centripetalForceMultiplier: number;
  63693. /**
  63694. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63695. */
  63696. centrifugalForceMultiplier: number;
  63697. /**
  63698. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63699. */
  63700. updraftForceMultiplier: number;
  63701. }
  63702. /**
  63703. * The strenght of the force in correspondence to the distance of the affected object
  63704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63705. */
  63706. export enum PhysicsRadialImpulseFalloff {
  63707. /** Defines that impulse is constant in strength across it's whole radius */
  63708. Constant = 0,
  63709. /** Defines that impulse gets weaker if it's further from the origin */
  63710. Linear = 1
  63711. }
  63712. /**
  63713. * The strength of the force in correspondence to the distance of the affected object
  63714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63715. */
  63716. export enum PhysicsUpdraftMode {
  63717. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63718. Center = 0,
  63719. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63720. Perpendicular = 1
  63721. }
  63722. /**
  63723. * Interface for a physics hit data
  63724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63725. */
  63726. export interface PhysicsHitData {
  63727. /**
  63728. * The force applied at the contact point
  63729. */
  63730. force: Vector3;
  63731. /**
  63732. * The contact point
  63733. */
  63734. contactPoint: Vector3;
  63735. /**
  63736. * The distance from the origin to the contact point
  63737. */
  63738. distanceFromOrigin: number;
  63739. }
  63740. /**
  63741. * Interface for radial explosion event data
  63742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63743. */
  63744. export interface PhysicsRadialExplosionEventData {
  63745. /**
  63746. * A sphere used for the radial explosion event
  63747. */
  63748. sphere: Mesh;
  63749. }
  63750. /**
  63751. * Interface for gravitational field event data
  63752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63753. */
  63754. export interface PhysicsGravitationalFieldEventData {
  63755. /**
  63756. * A sphere mesh used for the gravitational field event
  63757. */
  63758. sphere: Mesh;
  63759. }
  63760. /**
  63761. * Interface for updraft event data
  63762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63763. */
  63764. export interface PhysicsUpdraftEventData {
  63765. /**
  63766. * A cylinder used for the updraft event
  63767. */
  63768. cylinder: Mesh;
  63769. }
  63770. /**
  63771. * Interface for vortex event data
  63772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63773. */
  63774. export interface PhysicsVortexEventData {
  63775. /**
  63776. * A cylinder used for the vortex event
  63777. */
  63778. cylinder: Mesh;
  63779. }
  63780. /**
  63781. * Interface for an affected physics impostor
  63782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63783. */
  63784. export interface PhysicsAffectedImpostorWithData {
  63785. /**
  63786. * The impostor affected by the effect
  63787. */
  63788. impostor: PhysicsImpostor;
  63789. /**
  63790. * The data about the hit/horce from the explosion
  63791. */
  63792. hitData: PhysicsHitData;
  63793. }
  63794. }
  63795. declare module BABYLON {
  63796. /** @hidden */
  63797. export var blackAndWhitePixelShader: {
  63798. name: string;
  63799. shader: string;
  63800. };
  63801. }
  63802. declare module BABYLON {
  63803. /**
  63804. * Post process used to render in black and white
  63805. */
  63806. export class BlackAndWhitePostProcess extends PostProcess {
  63807. /**
  63808. * Linear about to convert he result to black and white (default: 1)
  63809. */
  63810. degree: number;
  63811. /**
  63812. * Creates a black and white post process
  63813. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63814. * @param name The name of the effect.
  63815. * @param options The required width/height ratio to downsize to before computing the render pass.
  63816. * @param camera The camera to apply the render pass to.
  63817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63818. * @param engine The engine which the post process will be applied. (default: current engine)
  63819. * @param reusable If the post process can be reused on the same frame. (default: false)
  63820. */
  63821. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63822. }
  63823. }
  63824. declare module BABYLON {
  63825. /**
  63826. * This represents a set of one or more post processes in Babylon.
  63827. * A post process can be used to apply a shader to a texture after it is rendered.
  63828. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63829. */
  63830. export class PostProcessRenderEffect {
  63831. private _postProcesses;
  63832. private _getPostProcesses;
  63833. private _singleInstance;
  63834. private _cameras;
  63835. private _indicesForCamera;
  63836. /**
  63837. * Name of the effect
  63838. * @hidden
  63839. */
  63840. _name: string;
  63841. /**
  63842. * Instantiates a post process render effect.
  63843. * A post process can be used to apply a shader to a texture after it is rendered.
  63844. * @param engine The engine the effect is tied to
  63845. * @param name The name of the effect
  63846. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63847. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63848. */
  63849. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63850. /**
  63851. * Checks if all the post processes in the effect are supported.
  63852. */
  63853. get isSupported(): boolean;
  63854. /**
  63855. * Updates the current state of the effect
  63856. * @hidden
  63857. */
  63858. _update(): void;
  63859. /**
  63860. * Attaches the effect on cameras
  63861. * @param cameras The camera to attach to.
  63862. * @hidden
  63863. */
  63864. _attachCameras(cameras: Camera): void;
  63865. /**
  63866. * Attaches the effect on cameras
  63867. * @param cameras The camera to attach to.
  63868. * @hidden
  63869. */
  63870. _attachCameras(cameras: Camera[]): void;
  63871. /**
  63872. * Detaches the effect on cameras
  63873. * @param cameras The camera to detatch from.
  63874. * @hidden
  63875. */
  63876. _detachCameras(cameras: Camera): void;
  63877. /**
  63878. * Detatches the effect on cameras
  63879. * @param cameras The camera to detatch from.
  63880. * @hidden
  63881. */
  63882. _detachCameras(cameras: Camera[]): void;
  63883. /**
  63884. * Enables the effect on given cameras
  63885. * @param cameras The camera to enable.
  63886. * @hidden
  63887. */
  63888. _enable(cameras: Camera): void;
  63889. /**
  63890. * Enables the effect on given cameras
  63891. * @param cameras The camera to enable.
  63892. * @hidden
  63893. */
  63894. _enable(cameras: Nullable<Camera[]>): void;
  63895. /**
  63896. * Disables the effect on the given cameras
  63897. * @param cameras The camera to disable.
  63898. * @hidden
  63899. */
  63900. _disable(cameras: Camera): void;
  63901. /**
  63902. * Disables the effect on the given cameras
  63903. * @param cameras The camera to disable.
  63904. * @hidden
  63905. */
  63906. _disable(cameras: Nullable<Camera[]>): void;
  63907. /**
  63908. * Gets a list of the post processes contained in the effect.
  63909. * @param camera The camera to get the post processes on.
  63910. * @returns The list of the post processes in the effect.
  63911. */
  63912. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63913. }
  63914. }
  63915. declare module BABYLON {
  63916. /** @hidden */
  63917. export var extractHighlightsPixelShader: {
  63918. name: string;
  63919. shader: string;
  63920. };
  63921. }
  63922. declare module BABYLON {
  63923. /**
  63924. * 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.
  63925. */
  63926. export class ExtractHighlightsPostProcess extends PostProcess {
  63927. /**
  63928. * The luminance threshold, pixels below this value will be set to black.
  63929. */
  63930. threshold: number;
  63931. /** @hidden */
  63932. _exposure: number;
  63933. /**
  63934. * Post process which has the input texture to be used when performing highlight extraction
  63935. * @hidden
  63936. */
  63937. _inputPostProcess: Nullable<PostProcess>;
  63938. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63939. }
  63940. }
  63941. declare module BABYLON {
  63942. /** @hidden */
  63943. export var bloomMergePixelShader: {
  63944. name: string;
  63945. shader: string;
  63946. };
  63947. }
  63948. declare module BABYLON {
  63949. /**
  63950. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63951. */
  63952. export class BloomMergePostProcess extends PostProcess {
  63953. /** Weight of the bloom to be added to the original input. */
  63954. weight: number;
  63955. /**
  63956. * Creates a new instance of @see BloomMergePostProcess
  63957. * @param name The name of the effect.
  63958. * @param originalFromInput Post process which's input will be used for the merge.
  63959. * @param blurred Blurred highlights post process which's output will be used.
  63960. * @param weight Weight of the bloom to be added to the original input.
  63961. * @param options The required width/height ratio to downsize to before computing the render pass.
  63962. * @param camera The camera to apply the render pass to.
  63963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63964. * @param engine The engine which the post process will be applied. (default: current engine)
  63965. * @param reusable If the post process can be reused on the same frame. (default: false)
  63966. * @param textureType Type of textures used when performing the post process. (default: 0)
  63967. * @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)
  63968. */
  63969. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63970. /** Weight of the bloom to be added to the original input. */
  63971. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63972. }
  63973. }
  63974. declare module BABYLON {
  63975. /**
  63976. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63977. */
  63978. export class BloomEffect extends PostProcessRenderEffect {
  63979. private bloomScale;
  63980. /**
  63981. * @hidden Internal
  63982. */
  63983. _effects: Array<PostProcess>;
  63984. /**
  63985. * @hidden Internal
  63986. */
  63987. _downscale: ExtractHighlightsPostProcess;
  63988. private _blurX;
  63989. private _blurY;
  63990. private _merge;
  63991. /**
  63992. * The luminance threshold to find bright areas of the image to bloom.
  63993. */
  63994. get threshold(): number;
  63995. set threshold(value: number);
  63996. /**
  63997. * The strength of the bloom.
  63998. */
  63999. get weight(): number;
  64000. set weight(value: number);
  64001. /**
  64002. * Specifies the size of the bloom blur kernel, relative to the final output size
  64003. */
  64004. get kernel(): number;
  64005. set kernel(value: number);
  64006. /**
  64007. * Creates a new instance of @see BloomEffect
  64008. * @param scene The scene the effect belongs to.
  64009. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64010. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64011. * @param bloomWeight The the strength of bloom.
  64012. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64013. * @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)
  64014. */
  64015. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64016. /**
  64017. * Disposes each of the internal effects for a given camera.
  64018. * @param camera The camera to dispose the effect on.
  64019. */
  64020. disposeEffects(camera: Camera): void;
  64021. /**
  64022. * @hidden Internal
  64023. */
  64024. _updateEffects(): void;
  64025. /**
  64026. * Internal
  64027. * @returns if all the contained post processes are ready.
  64028. * @hidden
  64029. */
  64030. _isReady(): boolean;
  64031. }
  64032. }
  64033. declare module BABYLON {
  64034. /** @hidden */
  64035. export var chromaticAberrationPixelShader: {
  64036. name: string;
  64037. shader: string;
  64038. };
  64039. }
  64040. declare module BABYLON {
  64041. /**
  64042. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64043. */
  64044. export class ChromaticAberrationPostProcess extends PostProcess {
  64045. /**
  64046. * The amount of seperation of rgb channels (default: 30)
  64047. */
  64048. aberrationAmount: number;
  64049. /**
  64050. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64051. */
  64052. radialIntensity: number;
  64053. /**
  64054. * 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))
  64055. */
  64056. direction: Vector2;
  64057. /**
  64058. * 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))
  64059. */
  64060. centerPosition: Vector2;
  64061. /**
  64062. * Creates a new instance ChromaticAberrationPostProcess
  64063. * @param name The name of the effect.
  64064. * @param screenWidth The width of the screen to apply the effect on.
  64065. * @param screenHeight The height of the screen to apply the effect on.
  64066. * @param options The required width/height ratio to downsize to before computing the render pass.
  64067. * @param camera The camera to apply the render pass to.
  64068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64069. * @param engine The engine which the post process will be applied. (default: current engine)
  64070. * @param reusable If the post process can be reused on the same frame. (default: false)
  64071. * @param textureType Type of textures used when performing the post process. (default: 0)
  64072. * @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)
  64073. */
  64074. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64075. }
  64076. }
  64077. declare module BABYLON {
  64078. /** @hidden */
  64079. export var circleOfConfusionPixelShader: {
  64080. name: string;
  64081. shader: string;
  64082. };
  64083. }
  64084. declare module BABYLON {
  64085. /**
  64086. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64087. */
  64088. export class CircleOfConfusionPostProcess extends PostProcess {
  64089. /**
  64090. * 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.
  64091. */
  64092. lensSize: number;
  64093. /**
  64094. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64095. */
  64096. fStop: number;
  64097. /**
  64098. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64099. */
  64100. focusDistance: number;
  64101. /**
  64102. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64103. */
  64104. focalLength: number;
  64105. private _depthTexture;
  64106. /**
  64107. * Creates a new instance CircleOfConfusionPostProcess
  64108. * @param name The name of the effect.
  64109. * @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.
  64110. * @param options The required width/height ratio to downsize to before computing the render pass.
  64111. * @param camera The camera to apply the render pass to.
  64112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64113. * @param engine The engine which the post process will be applied. (default: current engine)
  64114. * @param reusable If the post process can be reused on the same frame. (default: false)
  64115. * @param textureType Type of textures used when performing the post process. (default: 0)
  64116. * @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)
  64117. */
  64118. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64119. /**
  64120. * 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.
  64121. */
  64122. set depthTexture(value: RenderTargetTexture);
  64123. }
  64124. }
  64125. declare module BABYLON {
  64126. /** @hidden */
  64127. export var colorCorrectionPixelShader: {
  64128. name: string;
  64129. shader: string;
  64130. };
  64131. }
  64132. declare module BABYLON {
  64133. /**
  64134. *
  64135. * This post-process allows the modification of rendered colors by using
  64136. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64137. *
  64138. * The object needs to be provided an url to a texture containing the color
  64139. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64140. * Use an image editing software to tweak the LUT to match your needs.
  64141. *
  64142. * For an example of a color LUT, see here:
  64143. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64144. * For explanations on color grading, see here:
  64145. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64146. *
  64147. */
  64148. export class ColorCorrectionPostProcess extends PostProcess {
  64149. private _colorTableTexture;
  64150. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64151. }
  64152. }
  64153. declare module BABYLON {
  64154. /** @hidden */
  64155. export var convolutionPixelShader: {
  64156. name: string;
  64157. shader: string;
  64158. };
  64159. }
  64160. declare module BABYLON {
  64161. /**
  64162. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64163. * input texture to perform effects such as edge detection or sharpening
  64164. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64165. */
  64166. export class ConvolutionPostProcess extends PostProcess {
  64167. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64168. kernel: number[];
  64169. /**
  64170. * Creates a new instance ConvolutionPostProcess
  64171. * @param name The name of the effect.
  64172. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64173. * @param options The required width/height ratio to downsize to before computing the render pass.
  64174. * @param camera The camera to apply the render pass to.
  64175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64176. * @param engine The engine which the post process will be applied. (default: current engine)
  64177. * @param reusable If the post process can be reused on the same frame. (default: false)
  64178. * @param textureType Type of textures used when performing the post process. (default: 0)
  64179. */
  64180. constructor(name: string,
  64181. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64182. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64183. /**
  64184. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64185. */
  64186. static EdgeDetect0Kernel: number[];
  64187. /**
  64188. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64189. */
  64190. static EdgeDetect1Kernel: number[];
  64191. /**
  64192. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64193. */
  64194. static EdgeDetect2Kernel: number[];
  64195. /**
  64196. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64197. */
  64198. static SharpenKernel: number[];
  64199. /**
  64200. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64201. */
  64202. static EmbossKernel: number[];
  64203. /**
  64204. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64205. */
  64206. static GaussianKernel: number[];
  64207. }
  64208. }
  64209. declare module BABYLON {
  64210. /**
  64211. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64212. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64213. * based on samples that have a large difference in distance than the center pixel.
  64214. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64215. */
  64216. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64217. direction: Vector2;
  64218. /**
  64219. * Creates a new instance CircleOfConfusionPostProcess
  64220. * @param name The name of the effect.
  64221. * @param scene The scene the effect belongs to.
  64222. * @param direction The direction the blur should be applied.
  64223. * @param kernel The size of the kernel used to blur.
  64224. * @param options The required width/height ratio to downsize to before computing the render pass.
  64225. * @param camera The camera to apply the render pass to.
  64226. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64227. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64229. * @param engine The engine which the post process will be applied. (default: current engine)
  64230. * @param reusable If the post process can be reused on the same frame. (default: false)
  64231. * @param textureType Type of textures used when performing the post process. (default: 0)
  64232. * @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)
  64233. */
  64234. 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);
  64235. }
  64236. }
  64237. declare module BABYLON {
  64238. /** @hidden */
  64239. export var depthOfFieldMergePixelShader: {
  64240. name: string;
  64241. shader: string;
  64242. };
  64243. }
  64244. declare module BABYLON {
  64245. /**
  64246. * Options to be set when merging outputs from the default pipeline.
  64247. */
  64248. export class DepthOfFieldMergePostProcessOptions {
  64249. /**
  64250. * The original image to merge on top of
  64251. */
  64252. originalFromInput: PostProcess;
  64253. /**
  64254. * Parameters to perform the merge of the depth of field effect
  64255. */
  64256. depthOfField?: {
  64257. circleOfConfusion: PostProcess;
  64258. blurSteps: Array<PostProcess>;
  64259. };
  64260. /**
  64261. * Parameters to perform the merge of bloom effect
  64262. */
  64263. bloom?: {
  64264. blurred: PostProcess;
  64265. weight: number;
  64266. };
  64267. }
  64268. /**
  64269. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64270. */
  64271. export class DepthOfFieldMergePostProcess extends PostProcess {
  64272. private blurSteps;
  64273. /**
  64274. * Creates a new instance of DepthOfFieldMergePostProcess
  64275. * @param name The name of the effect.
  64276. * @param originalFromInput Post process which's input will be used for the merge.
  64277. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64278. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64279. * @param options The required width/height ratio to downsize to before computing the render pass.
  64280. * @param camera The camera to apply the render pass to.
  64281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64282. * @param engine The engine which the post process will be applied. (default: current engine)
  64283. * @param reusable If the post process can be reused on the same frame. (default: false)
  64284. * @param textureType Type of textures used when performing the post process. (default: 0)
  64285. * @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)
  64286. */
  64287. 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);
  64288. /**
  64289. * Updates the effect with the current post process compile time values and recompiles the shader.
  64290. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64291. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64292. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64293. * @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
  64294. * @param onCompiled Called when the shader has been compiled.
  64295. * @param onError Called if there is an error when compiling a shader.
  64296. */
  64297. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64298. }
  64299. }
  64300. declare module BABYLON {
  64301. /**
  64302. * Specifies the level of max blur that should be applied when using the depth of field effect
  64303. */
  64304. export enum DepthOfFieldEffectBlurLevel {
  64305. /**
  64306. * Subtle blur
  64307. */
  64308. Low = 0,
  64309. /**
  64310. * Medium blur
  64311. */
  64312. Medium = 1,
  64313. /**
  64314. * Large blur
  64315. */
  64316. High = 2
  64317. }
  64318. /**
  64319. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64320. */
  64321. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64322. private _circleOfConfusion;
  64323. /**
  64324. * @hidden Internal, blurs from high to low
  64325. */
  64326. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64327. private _depthOfFieldBlurY;
  64328. private _dofMerge;
  64329. /**
  64330. * @hidden Internal post processes in depth of field effect
  64331. */
  64332. _effects: Array<PostProcess>;
  64333. /**
  64334. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64335. */
  64336. set focalLength(value: number);
  64337. get focalLength(): number;
  64338. /**
  64339. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64340. */
  64341. set fStop(value: number);
  64342. get fStop(): number;
  64343. /**
  64344. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64345. */
  64346. set focusDistance(value: number);
  64347. get focusDistance(): number;
  64348. /**
  64349. * 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.
  64350. */
  64351. set lensSize(value: number);
  64352. get lensSize(): number;
  64353. /**
  64354. * Creates a new instance DepthOfFieldEffect
  64355. * @param scene The scene the effect belongs to.
  64356. * @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.
  64357. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64358. * @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)
  64359. */
  64360. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64361. /**
  64362. * Get the current class name of the current effet
  64363. * @returns "DepthOfFieldEffect"
  64364. */
  64365. getClassName(): string;
  64366. /**
  64367. * 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.
  64368. */
  64369. set depthTexture(value: RenderTargetTexture);
  64370. /**
  64371. * Disposes each of the internal effects for a given camera.
  64372. * @param camera The camera to dispose the effect on.
  64373. */
  64374. disposeEffects(camera: Camera): void;
  64375. /**
  64376. * @hidden Internal
  64377. */
  64378. _updateEffects(): void;
  64379. /**
  64380. * Internal
  64381. * @returns if all the contained post processes are ready.
  64382. * @hidden
  64383. */
  64384. _isReady(): boolean;
  64385. }
  64386. }
  64387. declare module BABYLON {
  64388. /** @hidden */
  64389. export var displayPassPixelShader: {
  64390. name: string;
  64391. shader: string;
  64392. };
  64393. }
  64394. declare module BABYLON {
  64395. /**
  64396. * DisplayPassPostProcess which produces an output the same as it's input
  64397. */
  64398. export class DisplayPassPostProcess extends PostProcess {
  64399. /**
  64400. * Creates the DisplayPassPostProcess
  64401. * @param name The name of the effect.
  64402. * @param options The required width/height ratio to downsize to before computing the render pass.
  64403. * @param camera The camera to apply the render pass to.
  64404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64405. * @param engine The engine which the post process will be applied. (default: current engine)
  64406. * @param reusable If the post process can be reused on the same frame. (default: false)
  64407. */
  64408. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64409. }
  64410. }
  64411. declare module BABYLON {
  64412. /** @hidden */
  64413. export var filterPixelShader: {
  64414. name: string;
  64415. shader: string;
  64416. };
  64417. }
  64418. declare module BABYLON {
  64419. /**
  64420. * Applies a kernel filter to the image
  64421. */
  64422. export class FilterPostProcess extends PostProcess {
  64423. /** The matrix to be applied to the image */
  64424. kernelMatrix: Matrix;
  64425. /**
  64426. *
  64427. * @param name The name of the effect.
  64428. * @param kernelMatrix The matrix to be applied to the image
  64429. * @param options The required width/height ratio to downsize to before computing the render pass.
  64430. * @param camera The camera to apply the render pass to.
  64431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64432. * @param engine The engine which the post process will be applied. (default: current engine)
  64433. * @param reusable If the post process can be reused on the same frame. (default: false)
  64434. */
  64435. constructor(name: string,
  64436. /** The matrix to be applied to the image */
  64437. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64438. }
  64439. }
  64440. declare module BABYLON {
  64441. /** @hidden */
  64442. export var fxaaPixelShader: {
  64443. name: string;
  64444. shader: string;
  64445. };
  64446. }
  64447. declare module BABYLON {
  64448. /** @hidden */
  64449. export var fxaaVertexShader: {
  64450. name: string;
  64451. shader: string;
  64452. };
  64453. }
  64454. declare module BABYLON {
  64455. /**
  64456. * Fxaa post process
  64457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64458. */
  64459. export class FxaaPostProcess extends PostProcess {
  64460. /** @hidden */
  64461. texelWidth: number;
  64462. /** @hidden */
  64463. texelHeight: number;
  64464. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64465. private _getDefines;
  64466. }
  64467. }
  64468. declare module BABYLON {
  64469. /** @hidden */
  64470. export var grainPixelShader: {
  64471. name: string;
  64472. shader: string;
  64473. };
  64474. }
  64475. declare module BABYLON {
  64476. /**
  64477. * The GrainPostProcess adds noise to the image at mid luminance levels
  64478. */
  64479. export class GrainPostProcess extends PostProcess {
  64480. /**
  64481. * The intensity of the grain added (default: 30)
  64482. */
  64483. intensity: number;
  64484. /**
  64485. * If the grain should be randomized on every frame
  64486. */
  64487. animated: boolean;
  64488. /**
  64489. * Creates a new instance of @see GrainPostProcess
  64490. * @param name The name of the effect.
  64491. * @param options The required width/height ratio to downsize to before computing the render pass.
  64492. * @param camera The camera to apply the render pass to.
  64493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64494. * @param engine The engine which the post process will be applied. (default: current engine)
  64495. * @param reusable If the post process can be reused on the same frame. (default: false)
  64496. * @param textureType Type of textures used when performing the post process. (default: 0)
  64497. * @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)
  64498. */
  64499. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64500. }
  64501. }
  64502. declare module BABYLON {
  64503. /** @hidden */
  64504. export var highlightsPixelShader: {
  64505. name: string;
  64506. shader: string;
  64507. };
  64508. }
  64509. declare module BABYLON {
  64510. /**
  64511. * Extracts highlights from the image
  64512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64513. */
  64514. export class HighlightsPostProcess extends PostProcess {
  64515. /**
  64516. * Extracts highlights from the image
  64517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64518. * @param name The name of the effect.
  64519. * @param options The required width/height ratio to downsize to before computing the render pass.
  64520. * @param camera The camera to apply the render pass to.
  64521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64522. * @param engine The engine which the post process will be applied. (default: current engine)
  64523. * @param reusable If the post process can be reused on the same frame. (default: false)
  64524. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64525. */
  64526. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64527. }
  64528. }
  64529. declare module BABYLON {
  64530. /** @hidden */
  64531. export var mrtFragmentDeclaration: {
  64532. name: string;
  64533. shader: string;
  64534. };
  64535. }
  64536. declare module BABYLON {
  64537. /** @hidden */
  64538. export var geometryPixelShader: {
  64539. name: string;
  64540. shader: string;
  64541. };
  64542. }
  64543. declare module BABYLON {
  64544. /** @hidden */
  64545. export var geometryVertexShader: {
  64546. name: string;
  64547. shader: string;
  64548. };
  64549. }
  64550. declare module BABYLON {
  64551. /** @hidden */
  64552. interface ISavedTransformationMatrix {
  64553. world: Matrix;
  64554. viewProjection: Matrix;
  64555. }
  64556. /**
  64557. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64558. */
  64559. export class GeometryBufferRenderer {
  64560. /**
  64561. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64562. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64563. */
  64564. static readonly POSITION_TEXTURE_TYPE: number;
  64565. /**
  64566. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64567. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64568. */
  64569. static readonly VELOCITY_TEXTURE_TYPE: number;
  64570. /**
  64571. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64572. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64573. */
  64574. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64575. /**
  64576. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64577. * in order to compute objects velocities when enableVelocity is set to "true"
  64578. * @hidden
  64579. */
  64580. _previousTransformationMatrices: {
  64581. [index: number]: ISavedTransformationMatrix;
  64582. };
  64583. /**
  64584. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64585. * in order to compute objects velocities when enableVelocity is set to "true"
  64586. * @hidden
  64587. */
  64588. _previousBonesTransformationMatrices: {
  64589. [index: number]: Float32Array;
  64590. };
  64591. /**
  64592. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64593. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64594. */
  64595. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64596. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64597. renderTransparentMeshes: boolean;
  64598. private _scene;
  64599. private _multiRenderTarget;
  64600. private _ratio;
  64601. private _enablePosition;
  64602. private _enableVelocity;
  64603. private _enableReflectivity;
  64604. private _positionIndex;
  64605. private _velocityIndex;
  64606. private _reflectivityIndex;
  64607. protected _effect: Effect;
  64608. protected _cachedDefines: string;
  64609. /**
  64610. * Set the render list (meshes to be rendered) used in the G buffer.
  64611. */
  64612. set renderList(meshes: Mesh[]);
  64613. /**
  64614. * Gets wether or not G buffer are supported by the running hardware.
  64615. * This requires draw buffer supports
  64616. */
  64617. get isSupported(): boolean;
  64618. /**
  64619. * Returns the index of the given texture type in the G-Buffer textures array
  64620. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64621. * @returns the index of the given texture type in the G-Buffer textures array
  64622. */
  64623. getTextureIndex(textureType: number): number;
  64624. /**
  64625. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64626. */
  64627. get enablePosition(): boolean;
  64628. /**
  64629. * Sets whether or not objects positions are enabled for the G buffer.
  64630. */
  64631. set enablePosition(enable: boolean);
  64632. /**
  64633. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64634. */
  64635. get enableVelocity(): boolean;
  64636. /**
  64637. * Sets wether or not objects velocities are enabled for the G buffer.
  64638. */
  64639. set enableVelocity(enable: boolean);
  64640. /**
  64641. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64642. */
  64643. get enableReflectivity(): boolean;
  64644. /**
  64645. * Sets wether or not objects roughness are enabled for the G buffer.
  64646. */
  64647. set enableReflectivity(enable: boolean);
  64648. /**
  64649. * Gets the scene associated with the buffer.
  64650. */
  64651. get scene(): Scene;
  64652. /**
  64653. * Gets the ratio used by the buffer during its creation.
  64654. * How big is the buffer related to the main canvas.
  64655. */
  64656. get ratio(): number;
  64657. /** @hidden */
  64658. static _SceneComponentInitialization: (scene: Scene) => void;
  64659. /**
  64660. * Creates a new G Buffer for the scene
  64661. * @param scene The scene the buffer belongs to
  64662. * @param ratio How big is the buffer related to the main canvas.
  64663. */
  64664. constructor(scene: Scene, ratio?: number);
  64665. /**
  64666. * Checks wether everything is ready to render a submesh to the G buffer.
  64667. * @param subMesh the submesh to check readiness for
  64668. * @param useInstances is the mesh drawn using instance or not
  64669. * @returns true if ready otherwise false
  64670. */
  64671. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64672. /**
  64673. * Gets the current underlying G Buffer.
  64674. * @returns the buffer
  64675. */
  64676. getGBuffer(): MultiRenderTarget;
  64677. /**
  64678. * Gets the number of samples used to render the buffer (anti aliasing).
  64679. */
  64680. get samples(): number;
  64681. /**
  64682. * Sets the number of samples used to render the buffer (anti aliasing).
  64683. */
  64684. set samples(value: number);
  64685. /**
  64686. * Disposes the renderer and frees up associated resources.
  64687. */
  64688. dispose(): void;
  64689. protected _createRenderTargets(): void;
  64690. private _copyBonesTransformationMatrices;
  64691. }
  64692. }
  64693. declare module BABYLON {
  64694. interface Scene {
  64695. /** @hidden (Backing field) */
  64696. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64697. /**
  64698. * Gets or Sets the current geometry buffer associated to the scene.
  64699. */
  64700. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64701. /**
  64702. * Enables a GeometryBufferRender and associates it with the scene
  64703. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64704. * @returns the GeometryBufferRenderer
  64705. */
  64706. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64707. /**
  64708. * Disables the GeometryBufferRender associated with the scene
  64709. */
  64710. disableGeometryBufferRenderer(): void;
  64711. }
  64712. /**
  64713. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64714. * in several rendering techniques.
  64715. */
  64716. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64717. /**
  64718. * The component name helpful to identify the component in the list of scene components.
  64719. */
  64720. readonly name: string;
  64721. /**
  64722. * The scene the component belongs to.
  64723. */
  64724. scene: Scene;
  64725. /**
  64726. * Creates a new instance of the component for the given scene
  64727. * @param scene Defines the scene to register the component in
  64728. */
  64729. constructor(scene: Scene);
  64730. /**
  64731. * Registers the component in a given scene
  64732. */
  64733. register(): void;
  64734. /**
  64735. * Rebuilds the elements related to this component in case of
  64736. * context lost for instance.
  64737. */
  64738. rebuild(): void;
  64739. /**
  64740. * Disposes the component and the associated ressources
  64741. */
  64742. dispose(): void;
  64743. private _gatherRenderTargets;
  64744. }
  64745. }
  64746. declare module BABYLON {
  64747. /** @hidden */
  64748. export var motionBlurPixelShader: {
  64749. name: string;
  64750. shader: string;
  64751. };
  64752. }
  64753. declare module BABYLON {
  64754. /**
  64755. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64756. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64757. * As an example, all you have to do is to create the post-process:
  64758. * var mb = new BABYLON.MotionBlurPostProcess(
  64759. * 'mb', // The name of the effect.
  64760. * scene, // The scene containing the objects to blur according to their velocity.
  64761. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64762. * camera // The camera to apply the render pass to.
  64763. * );
  64764. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64765. */
  64766. export class MotionBlurPostProcess extends PostProcess {
  64767. /**
  64768. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64769. */
  64770. motionStrength: number;
  64771. /**
  64772. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64773. */
  64774. get motionBlurSamples(): number;
  64775. /**
  64776. * Sets the number of iterations to be used for motion blur quality
  64777. */
  64778. set motionBlurSamples(samples: number);
  64779. private _motionBlurSamples;
  64780. private _geometryBufferRenderer;
  64781. /**
  64782. * Creates a new instance MotionBlurPostProcess
  64783. * @param name The name of the effect.
  64784. * @param scene The scene containing the objects to blur according to their velocity.
  64785. * @param options The required width/height ratio to downsize to before computing the render pass.
  64786. * @param camera The camera to apply the render pass to.
  64787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64788. * @param engine The engine which the post process will be applied. (default: current engine)
  64789. * @param reusable If the post process can be reused on the same frame. (default: false)
  64790. * @param textureType Type of textures used when performing the post process. (default: 0)
  64791. * @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)
  64792. */
  64793. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64794. /**
  64795. * Excludes the given skinned mesh from computing bones velocities.
  64796. * 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.
  64797. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64798. */
  64799. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64800. /**
  64801. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64802. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64803. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64804. */
  64805. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64806. /**
  64807. * Disposes the post process.
  64808. * @param camera The camera to dispose the post process on.
  64809. */
  64810. dispose(camera?: Camera): void;
  64811. }
  64812. }
  64813. declare module BABYLON {
  64814. /** @hidden */
  64815. export var refractionPixelShader: {
  64816. name: string;
  64817. shader: string;
  64818. };
  64819. }
  64820. declare module BABYLON {
  64821. /**
  64822. * Post process which applies a refractin texture
  64823. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64824. */
  64825. export class RefractionPostProcess extends PostProcess {
  64826. /** the base color of the refraction (used to taint the rendering) */
  64827. color: Color3;
  64828. /** simulated refraction depth */
  64829. depth: number;
  64830. /** the coefficient of the base color (0 to remove base color tainting) */
  64831. colorLevel: number;
  64832. private _refTexture;
  64833. private _ownRefractionTexture;
  64834. /**
  64835. * Gets or sets the refraction texture
  64836. * Please note that you are responsible for disposing the texture if you set it manually
  64837. */
  64838. get refractionTexture(): Texture;
  64839. set refractionTexture(value: Texture);
  64840. /**
  64841. * Initializes the RefractionPostProcess
  64842. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64843. * @param name The name of the effect.
  64844. * @param refractionTextureUrl Url of the refraction texture to use
  64845. * @param color the base color of the refraction (used to taint the rendering)
  64846. * @param depth simulated refraction depth
  64847. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64848. * @param camera The camera to apply the render pass to.
  64849. * @param options The required width/height ratio to downsize to before computing the render pass.
  64850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64851. * @param engine The engine which the post process will be applied. (default: current engine)
  64852. * @param reusable If the post process can be reused on the same frame. (default: false)
  64853. */
  64854. constructor(name: string, refractionTextureUrl: string,
  64855. /** the base color of the refraction (used to taint the rendering) */
  64856. color: Color3,
  64857. /** simulated refraction depth */
  64858. depth: number,
  64859. /** the coefficient of the base color (0 to remove base color tainting) */
  64860. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64861. /**
  64862. * Disposes of the post process
  64863. * @param camera Camera to dispose post process on
  64864. */
  64865. dispose(camera: Camera): void;
  64866. }
  64867. }
  64868. declare module BABYLON {
  64869. /** @hidden */
  64870. export var sharpenPixelShader: {
  64871. name: string;
  64872. shader: string;
  64873. };
  64874. }
  64875. declare module BABYLON {
  64876. /**
  64877. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64878. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64879. */
  64880. export class SharpenPostProcess extends PostProcess {
  64881. /**
  64882. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64883. */
  64884. colorAmount: number;
  64885. /**
  64886. * How much sharpness should be applied (default: 0.3)
  64887. */
  64888. edgeAmount: number;
  64889. /**
  64890. * Creates a new instance ConvolutionPostProcess
  64891. * @param name The name of the effect.
  64892. * @param options The required width/height ratio to downsize to before computing the render pass.
  64893. * @param camera The camera to apply the render pass to.
  64894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64895. * @param engine The engine which the post process will be applied. (default: current engine)
  64896. * @param reusable If the post process can be reused on the same frame. (default: false)
  64897. * @param textureType Type of textures used when performing the post process. (default: 0)
  64898. * @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)
  64899. */
  64900. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64901. }
  64902. }
  64903. declare module BABYLON {
  64904. /**
  64905. * PostProcessRenderPipeline
  64906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64907. */
  64908. export class PostProcessRenderPipeline {
  64909. private engine;
  64910. private _renderEffects;
  64911. private _renderEffectsForIsolatedPass;
  64912. /**
  64913. * List of inspectable custom properties (used by the Inspector)
  64914. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64915. */
  64916. inspectableCustomProperties: IInspectable[];
  64917. /**
  64918. * @hidden
  64919. */
  64920. protected _cameras: Camera[];
  64921. /** @hidden */
  64922. _name: string;
  64923. /**
  64924. * Gets pipeline name
  64925. */
  64926. get name(): string;
  64927. /** Gets the list of attached cameras */
  64928. get cameras(): Camera[];
  64929. /**
  64930. * Initializes a PostProcessRenderPipeline
  64931. * @param engine engine to add the pipeline to
  64932. * @param name name of the pipeline
  64933. */
  64934. constructor(engine: Engine, name: string);
  64935. /**
  64936. * Gets the class name
  64937. * @returns "PostProcessRenderPipeline"
  64938. */
  64939. getClassName(): string;
  64940. /**
  64941. * If all the render effects in the pipeline are supported
  64942. */
  64943. get isSupported(): boolean;
  64944. /**
  64945. * Adds an effect to the pipeline
  64946. * @param renderEffect the effect to add
  64947. */
  64948. addEffect(renderEffect: PostProcessRenderEffect): void;
  64949. /** @hidden */
  64950. _rebuild(): void;
  64951. /** @hidden */
  64952. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64953. /** @hidden */
  64954. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64955. /** @hidden */
  64956. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64957. /** @hidden */
  64958. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64959. /** @hidden */
  64960. _attachCameras(cameras: Camera, unique: boolean): void;
  64961. /** @hidden */
  64962. _attachCameras(cameras: Camera[], unique: boolean): void;
  64963. /** @hidden */
  64964. _detachCameras(cameras: Camera): void;
  64965. /** @hidden */
  64966. _detachCameras(cameras: Nullable<Camera[]>): void;
  64967. /** @hidden */
  64968. _update(): void;
  64969. /** @hidden */
  64970. _reset(): void;
  64971. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64972. /**
  64973. * Disposes of the pipeline
  64974. */
  64975. dispose(): void;
  64976. }
  64977. }
  64978. declare module BABYLON {
  64979. /**
  64980. * PostProcessRenderPipelineManager class
  64981. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64982. */
  64983. export class PostProcessRenderPipelineManager {
  64984. private _renderPipelines;
  64985. /**
  64986. * Initializes a PostProcessRenderPipelineManager
  64987. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64988. */
  64989. constructor();
  64990. /**
  64991. * Gets the list of supported render pipelines
  64992. */
  64993. get supportedPipelines(): PostProcessRenderPipeline[];
  64994. /**
  64995. * Adds a pipeline to the manager
  64996. * @param renderPipeline The pipeline to add
  64997. */
  64998. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64999. /**
  65000. * Attaches a camera to the pipeline
  65001. * @param renderPipelineName The name of the pipeline to attach to
  65002. * @param cameras the camera to attach
  65003. * @param unique if the camera can be attached multiple times to the pipeline
  65004. */
  65005. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65006. /**
  65007. * Detaches a camera from the pipeline
  65008. * @param renderPipelineName The name of the pipeline to detach from
  65009. * @param cameras the camera to detach
  65010. */
  65011. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65012. /**
  65013. * Enables an effect by name on a pipeline
  65014. * @param renderPipelineName the name of the pipeline to enable the effect in
  65015. * @param renderEffectName the name of the effect to enable
  65016. * @param cameras the cameras that the effect should be enabled on
  65017. */
  65018. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65019. /**
  65020. * Disables an effect by name on a pipeline
  65021. * @param renderPipelineName the name of the pipeline to disable the effect in
  65022. * @param renderEffectName the name of the effect to disable
  65023. * @param cameras the cameras that the effect should be disabled on
  65024. */
  65025. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65026. /**
  65027. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65028. */
  65029. update(): void;
  65030. /** @hidden */
  65031. _rebuild(): void;
  65032. /**
  65033. * Disposes of the manager and pipelines
  65034. */
  65035. dispose(): void;
  65036. }
  65037. }
  65038. declare module BABYLON {
  65039. interface Scene {
  65040. /** @hidden (Backing field) */
  65041. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65042. /**
  65043. * Gets the postprocess render pipeline manager
  65044. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65045. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65046. */
  65047. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65048. }
  65049. /**
  65050. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65051. */
  65052. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65053. /**
  65054. * The component name helpfull to identify the component in the list of scene components.
  65055. */
  65056. readonly name: string;
  65057. /**
  65058. * The scene the component belongs to.
  65059. */
  65060. scene: Scene;
  65061. /**
  65062. * Creates a new instance of the component for the given scene
  65063. * @param scene Defines the scene to register the component in
  65064. */
  65065. constructor(scene: Scene);
  65066. /**
  65067. * Registers the component in a given scene
  65068. */
  65069. register(): void;
  65070. /**
  65071. * Rebuilds the elements related to this component in case of
  65072. * context lost for instance.
  65073. */
  65074. rebuild(): void;
  65075. /**
  65076. * Disposes the component and the associated ressources
  65077. */
  65078. dispose(): void;
  65079. private _gatherRenderTargets;
  65080. }
  65081. }
  65082. declare module BABYLON {
  65083. /**
  65084. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65085. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65086. */
  65087. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65088. private _scene;
  65089. private _camerasToBeAttached;
  65090. /**
  65091. * ID of the sharpen post process,
  65092. */
  65093. private readonly SharpenPostProcessId;
  65094. /**
  65095. * @ignore
  65096. * ID of the image processing post process;
  65097. */
  65098. readonly ImageProcessingPostProcessId: string;
  65099. /**
  65100. * @ignore
  65101. * ID of the Fast Approximate Anti-Aliasing post process;
  65102. */
  65103. readonly FxaaPostProcessId: string;
  65104. /**
  65105. * ID of the chromatic aberration post process,
  65106. */
  65107. private readonly ChromaticAberrationPostProcessId;
  65108. /**
  65109. * ID of the grain post process
  65110. */
  65111. private readonly GrainPostProcessId;
  65112. /**
  65113. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65114. */
  65115. sharpen: SharpenPostProcess;
  65116. private _sharpenEffect;
  65117. private bloom;
  65118. /**
  65119. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65120. */
  65121. depthOfField: DepthOfFieldEffect;
  65122. /**
  65123. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65124. */
  65125. fxaa: FxaaPostProcess;
  65126. /**
  65127. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65128. */
  65129. imageProcessing: ImageProcessingPostProcess;
  65130. /**
  65131. * Chromatic aberration post process which will shift rgb colors in the image
  65132. */
  65133. chromaticAberration: ChromaticAberrationPostProcess;
  65134. private _chromaticAberrationEffect;
  65135. /**
  65136. * Grain post process which add noise to the image
  65137. */
  65138. grain: GrainPostProcess;
  65139. private _grainEffect;
  65140. /**
  65141. * Glow post process which adds a glow to emissive areas of the image
  65142. */
  65143. private _glowLayer;
  65144. /**
  65145. * Animations which can be used to tweak settings over a period of time
  65146. */
  65147. animations: Animation[];
  65148. private _imageProcessingConfigurationObserver;
  65149. private _sharpenEnabled;
  65150. private _bloomEnabled;
  65151. private _depthOfFieldEnabled;
  65152. private _depthOfFieldBlurLevel;
  65153. private _fxaaEnabled;
  65154. private _imageProcessingEnabled;
  65155. private _defaultPipelineTextureType;
  65156. private _bloomScale;
  65157. private _chromaticAberrationEnabled;
  65158. private _grainEnabled;
  65159. private _buildAllowed;
  65160. /**
  65161. * Gets active scene
  65162. */
  65163. get scene(): Scene;
  65164. /**
  65165. * Enable or disable the sharpen process from the pipeline
  65166. */
  65167. set sharpenEnabled(enabled: boolean);
  65168. get sharpenEnabled(): boolean;
  65169. private _resizeObserver;
  65170. private _hardwareScaleLevel;
  65171. private _bloomKernel;
  65172. /**
  65173. * Specifies the size of the bloom blur kernel, relative to the final output size
  65174. */
  65175. get bloomKernel(): number;
  65176. set bloomKernel(value: number);
  65177. /**
  65178. * Specifies the weight of the bloom in the final rendering
  65179. */
  65180. private _bloomWeight;
  65181. /**
  65182. * Specifies the luma threshold for the area that will be blurred by the bloom
  65183. */
  65184. private _bloomThreshold;
  65185. private _hdr;
  65186. /**
  65187. * The strength of the bloom.
  65188. */
  65189. set bloomWeight(value: number);
  65190. get bloomWeight(): number;
  65191. /**
  65192. * The strength of the bloom.
  65193. */
  65194. set bloomThreshold(value: number);
  65195. get bloomThreshold(): number;
  65196. /**
  65197. * The scale of the bloom, lower value will provide better performance.
  65198. */
  65199. set bloomScale(value: number);
  65200. get bloomScale(): number;
  65201. /**
  65202. * Enable or disable the bloom from the pipeline
  65203. */
  65204. set bloomEnabled(enabled: boolean);
  65205. get bloomEnabled(): boolean;
  65206. private _rebuildBloom;
  65207. /**
  65208. * If the depth of field is enabled.
  65209. */
  65210. get depthOfFieldEnabled(): boolean;
  65211. set depthOfFieldEnabled(enabled: boolean);
  65212. /**
  65213. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65214. */
  65215. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65216. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65217. /**
  65218. * If the anti aliasing is enabled.
  65219. */
  65220. set fxaaEnabled(enabled: boolean);
  65221. get fxaaEnabled(): boolean;
  65222. private _samples;
  65223. /**
  65224. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65225. */
  65226. set samples(sampleCount: number);
  65227. get samples(): number;
  65228. /**
  65229. * If image processing is enabled.
  65230. */
  65231. set imageProcessingEnabled(enabled: boolean);
  65232. get imageProcessingEnabled(): boolean;
  65233. /**
  65234. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65235. */
  65236. set glowLayerEnabled(enabled: boolean);
  65237. get glowLayerEnabled(): boolean;
  65238. /**
  65239. * Gets the glow layer (or null if not defined)
  65240. */
  65241. get glowLayer(): Nullable<GlowLayer>;
  65242. /**
  65243. * Enable or disable the chromaticAberration process from the pipeline
  65244. */
  65245. set chromaticAberrationEnabled(enabled: boolean);
  65246. get chromaticAberrationEnabled(): boolean;
  65247. /**
  65248. * Enable or disable the grain process from the pipeline
  65249. */
  65250. set grainEnabled(enabled: boolean);
  65251. get grainEnabled(): boolean;
  65252. /**
  65253. * @constructor
  65254. * @param name - The rendering pipeline name (default: "")
  65255. * @param hdr - If high dynamic range textures should be used (default: true)
  65256. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65257. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65258. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65259. */
  65260. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65261. /**
  65262. * Get the class name
  65263. * @returns "DefaultRenderingPipeline"
  65264. */
  65265. getClassName(): string;
  65266. /**
  65267. * Force the compilation of the entire pipeline.
  65268. */
  65269. prepare(): void;
  65270. private _hasCleared;
  65271. private _prevPostProcess;
  65272. private _prevPrevPostProcess;
  65273. private _setAutoClearAndTextureSharing;
  65274. private _depthOfFieldSceneObserver;
  65275. private _buildPipeline;
  65276. private _disposePostProcesses;
  65277. /**
  65278. * Adds a camera to the pipeline
  65279. * @param camera the camera to be added
  65280. */
  65281. addCamera(camera: Camera): void;
  65282. /**
  65283. * Removes a camera from the pipeline
  65284. * @param camera the camera to remove
  65285. */
  65286. removeCamera(camera: Camera): void;
  65287. /**
  65288. * Dispose of the pipeline and stop all post processes
  65289. */
  65290. dispose(): void;
  65291. /**
  65292. * Serialize the rendering pipeline (Used when exporting)
  65293. * @returns the serialized object
  65294. */
  65295. serialize(): any;
  65296. /**
  65297. * Parse the serialized pipeline
  65298. * @param source Source pipeline.
  65299. * @param scene The scene to load the pipeline to.
  65300. * @param rootUrl The URL of the serialized pipeline.
  65301. * @returns An instantiated pipeline from the serialized object.
  65302. */
  65303. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65304. }
  65305. }
  65306. declare module BABYLON {
  65307. /** @hidden */
  65308. export var lensHighlightsPixelShader: {
  65309. name: string;
  65310. shader: string;
  65311. };
  65312. }
  65313. declare module BABYLON {
  65314. /** @hidden */
  65315. export var depthOfFieldPixelShader: {
  65316. name: string;
  65317. shader: string;
  65318. };
  65319. }
  65320. declare module BABYLON {
  65321. /**
  65322. * BABYLON.JS Chromatic Aberration GLSL Shader
  65323. * Author: Olivier Guyot
  65324. * Separates very slightly R, G and B colors on the edges of the screen
  65325. * Inspired by Francois Tarlier & Martins Upitis
  65326. */
  65327. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65328. /**
  65329. * @ignore
  65330. * The chromatic aberration PostProcess id in the pipeline
  65331. */
  65332. LensChromaticAberrationEffect: string;
  65333. /**
  65334. * @ignore
  65335. * The highlights enhancing PostProcess id in the pipeline
  65336. */
  65337. HighlightsEnhancingEffect: string;
  65338. /**
  65339. * @ignore
  65340. * The depth-of-field PostProcess id in the pipeline
  65341. */
  65342. LensDepthOfFieldEffect: string;
  65343. private _scene;
  65344. private _depthTexture;
  65345. private _grainTexture;
  65346. private _chromaticAberrationPostProcess;
  65347. private _highlightsPostProcess;
  65348. private _depthOfFieldPostProcess;
  65349. private _edgeBlur;
  65350. private _grainAmount;
  65351. private _chromaticAberration;
  65352. private _distortion;
  65353. private _highlightsGain;
  65354. private _highlightsThreshold;
  65355. private _dofDistance;
  65356. private _dofAperture;
  65357. private _dofDarken;
  65358. private _dofPentagon;
  65359. private _blurNoise;
  65360. /**
  65361. * @constructor
  65362. *
  65363. * Effect parameters are as follow:
  65364. * {
  65365. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65366. * edge_blur: number; // from 0 to x (1 for realism)
  65367. * distortion: number; // from 0 to x (1 for realism)
  65368. * grain_amount: number; // from 0 to 1
  65369. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65370. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65371. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65372. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65373. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65374. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65375. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65376. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65377. * }
  65378. * Note: if an effect parameter is unset, effect is disabled
  65379. *
  65380. * @param name The rendering pipeline name
  65381. * @param parameters - An object containing all parameters (see above)
  65382. * @param scene The scene linked to this pipeline
  65383. * @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)
  65384. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65385. */
  65386. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65387. /**
  65388. * Get the class name
  65389. * @returns "LensRenderingPipeline"
  65390. */
  65391. getClassName(): string;
  65392. /**
  65393. * Gets associated scene
  65394. */
  65395. get scene(): Scene;
  65396. /**
  65397. * Gets or sets the edge blur
  65398. */
  65399. get edgeBlur(): number;
  65400. set edgeBlur(value: number);
  65401. /**
  65402. * Gets or sets the grain amount
  65403. */
  65404. get grainAmount(): number;
  65405. set grainAmount(value: number);
  65406. /**
  65407. * Gets or sets the chromatic aberration amount
  65408. */
  65409. get chromaticAberration(): number;
  65410. set chromaticAberration(value: number);
  65411. /**
  65412. * Gets or sets the depth of field aperture
  65413. */
  65414. get dofAperture(): number;
  65415. set dofAperture(value: number);
  65416. /**
  65417. * Gets or sets the edge distortion
  65418. */
  65419. get edgeDistortion(): number;
  65420. set edgeDistortion(value: number);
  65421. /**
  65422. * Gets or sets the depth of field distortion
  65423. */
  65424. get dofDistortion(): number;
  65425. set dofDistortion(value: number);
  65426. /**
  65427. * Gets or sets the darken out of focus amount
  65428. */
  65429. get darkenOutOfFocus(): number;
  65430. set darkenOutOfFocus(value: number);
  65431. /**
  65432. * Gets or sets a boolean indicating if blur noise is enabled
  65433. */
  65434. get blurNoise(): boolean;
  65435. set blurNoise(value: boolean);
  65436. /**
  65437. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65438. */
  65439. get pentagonBokeh(): boolean;
  65440. set pentagonBokeh(value: boolean);
  65441. /**
  65442. * Gets or sets the highlight grain amount
  65443. */
  65444. get highlightsGain(): number;
  65445. set highlightsGain(value: number);
  65446. /**
  65447. * Gets or sets the highlight threshold
  65448. */
  65449. get highlightsThreshold(): number;
  65450. set highlightsThreshold(value: number);
  65451. /**
  65452. * Sets the amount of blur at the edges
  65453. * @param amount blur amount
  65454. */
  65455. setEdgeBlur(amount: number): void;
  65456. /**
  65457. * Sets edge blur to 0
  65458. */
  65459. disableEdgeBlur(): void;
  65460. /**
  65461. * Sets the amout of grain
  65462. * @param amount Amount of grain
  65463. */
  65464. setGrainAmount(amount: number): void;
  65465. /**
  65466. * Set grain amount to 0
  65467. */
  65468. disableGrain(): void;
  65469. /**
  65470. * Sets the chromatic aberration amount
  65471. * @param amount amount of chromatic aberration
  65472. */
  65473. setChromaticAberration(amount: number): void;
  65474. /**
  65475. * Sets chromatic aberration amount to 0
  65476. */
  65477. disableChromaticAberration(): void;
  65478. /**
  65479. * Sets the EdgeDistortion amount
  65480. * @param amount amount of EdgeDistortion
  65481. */
  65482. setEdgeDistortion(amount: number): void;
  65483. /**
  65484. * Sets edge distortion to 0
  65485. */
  65486. disableEdgeDistortion(): void;
  65487. /**
  65488. * Sets the FocusDistance amount
  65489. * @param amount amount of FocusDistance
  65490. */
  65491. setFocusDistance(amount: number): void;
  65492. /**
  65493. * Disables depth of field
  65494. */
  65495. disableDepthOfField(): void;
  65496. /**
  65497. * Sets the Aperture amount
  65498. * @param amount amount of Aperture
  65499. */
  65500. setAperture(amount: number): void;
  65501. /**
  65502. * Sets the DarkenOutOfFocus amount
  65503. * @param amount amount of DarkenOutOfFocus
  65504. */
  65505. setDarkenOutOfFocus(amount: number): void;
  65506. private _pentagonBokehIsEnabled;
  65507. /**
  65508. * Creates a pentagon bokeh effect
  65509. */
  65510. enablePentagonBokeh(): void;
  65511. /**
  65512. * Disables the pentagon bokeh effect
  65513. */
  65514. disablePentagonBokeh(): void;
  65515. /**
  65516. * Enables noise blur
  65517. */
  65518. enableNoiseBlur(): void;
  65519. /**
  65520. * Disables noise blur
  65521. */
  65522. disableNoiseBlur(): void;
  65523. /**
  65524. * Sets the HighlightsGain amount
  65525. * @param amount amount of HighlightsGain
  65526. */
  65527. setHighlightsGain(amount: number): void;
  65528. /**
  65529. * Sets the HighlightsThreshold amount
  65530. * @param amount amount of HighlightsThreshold
  65531. */
  65532. setHighlightsThreshold(amount: number): void;
  65533. /**
  65534. * Disables highlights
  65535. */
  65536. disableHighlights(): void;
  65537. /**
  65538. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65539. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65540. */
  65541. dispose(disableDepthRender?: boolean): void;
  65542. private _createChromaticAberrationPostProcess;
  65543. private _createHighlightsPostProcess;
  65544. private _createDepthOfFieldPostProcess;
  65545. private _createGrainTexture;
  65546. }
  65547. }
  65548. declare module BABYLON {
  65549. /** @hidden */
  65550. export var ssao2PixelShader: {
  65551. name: string;
  65552. shader: string;
  65553. };
  65554. }
  65555. declare module BABYLON {
  65556. /** @hidden */
  65557. export var ssaoCombinePixelShader: {
  65558. name: string;
  65559. shader: string;
  65560. };
  65561. }
  65562. declare module BABYLON {
  65563. /**
  65564. * Render pipeline to produce ssao effect
  65565. */
  65566. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65567. /**
  65568. * @ignore
  65569. * The PassPostProcess id in the pipeline that contains the original scene color
  65570. */
  65571. SSAOOriginalSceneColorEffect: string;
  65572. /**
  65573. * @ignore
  65574. * The SSAO PostProcess id in the pipeline
  65575. */
  65576. SSAORenderEffect: string;
  65577. /**
  65578. * @ignore
  65579. * The horizontal blur PostProcess id in the pipeline
  65580. */
  65581. SSAOBlurHRenderEffect: string;
  65582. /**
  65583. * @ignore
  65584. * The vertical blur PostProcess id in the pipeline
  65585. */
  65586. SSAOBlurVRenderEffect: string;
  65587. /**
  65588. * @ignore
  65589. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65590. */
  65591. SSAOCombineRenderEffect: string;
  65592. /**
  65593. * The output strength of the SSAO post-process. Default value is 1.0.
  65594. */
  65595. totalStrength: number;
  65596. /**
  65597. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65598. */
  65599. maxZ: number;
  65600. /**
  65601. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65602. */
  65603. minZAspect: number;
  65604. private _samples;
  65605. /**
  65606. * Number of samples used for the SSAO calculations. Default value is 8
  65607. */
  65608. set samples(n: number);
  65609. get samples(): number;
  65610. private _textureSamples;
  65611. /**
  65612. * Number of samples to use for antialiasing
  65613. */
  65614. set textureSamples(n: number);
  65615. get textureSamples(): number;
  65616. /**
  65617. * Ratio object used for SSAO ratio and blur ratio
  65618. */
  65619. private _ratio;
  65620. /**
  65621. * Dynamically generated sphere sampler.
  65622. */
  65623. private _sampleSphere;
  65624. /**
  65625. * Blur filter offsets
  65626. */
  65627. private _samplerOffsets;
  65628. private _expensiveBlur;
  65629. /**
  65630. * If bilateral blur should be used
  65631. */
  65632. set expensiveBlur(b: boolean);
  65633. get expensiveBlur(): boolean;
  65634. /**
  65635. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65636. */
  65637. radius: number;
  65638. /**
  65639. * The base color of the SSAO post-process
  65640. * The final result is "base + ssao" between [0, 1]
  65641. */
  65642. base: number;
  65643. /**
  65644. * Support test.
  65645. */
  65646. static get IsSupported(): boolean;
  65647. private _scene;
  65648. private _depthTexture;
  65649. private _normalTexture;
  65650. private _randomTexture;
  65651. private _originalColorPostProcess;
  65652. private _ssaoPostProcess;
  65653. private _blurHPostProcess;
  65654. private _blurVPostProcess;
  65655. private _ssaoCombinePostProcess;
  65656. /**
  65657. * Gets active scene
  65658. */
  65659. get scene(): Scene;
  65660. /**
  65661. * @constructor
  65662. * @param name The rendering pipeline name
  65663. * @param scene The scene linked to this pipeline
  65664. * @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 }
  65665. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65666. */
  65667. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65668. /**
  65669. * Get the class name
  65670. * @returns "SSAO2RenderingPipeline"
  65671. */
  65672. getClassName(): string;
  65673. /**
  65674. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65675. */
  65676. dispose(disableGeometryBufferRenderer?: boolean): void;
  65677. private _createBlurPostProcess;
  65678. /** @hidden */
  65679. _rebuild(): void;
  65680. private _bits;
  65681. private _radicalInverse_VdC;
  65682. private _hammersley;
  65683. private _hemisphereSample_uniform;
  65684. private _generateHemisphere;
  65685. private _createSSAOPostProcess;
  65686. private _createSSAOCombinePostProcess;
  65687. private _createRandomTexture;
  65688. /**
  65689. * Serialize the rendering pipeline (Used when exporting)
  65690. * @returns the serialized object
  65691. */
  65692. serialize(): any;
  65693. /**
  65694. * Parse the serialized pipeline
  65695. * @param source Source pipeline.
  65696. * @param scene The scene to load the pipeline to.
  65697. * @param rootUrl The URL of the serialized pipeline.
  65698. * @returns An instantiated pipeline from the serialized object.
  65699. */
  65700. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65701. }
  65702. }
  65703. declare module BABYLON {
  65704. /** @hidden */
  65705. export var ssaoPixelShader: {
  65706. name: string;
  65707. shader: string;
  65708. };
  65709. }
  65710. declare module BABYLON {
  65711. /**
  65712. * Render pipeline to produce ssao effect
  65713. */
  65714. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65715. /**
  65716. * @ignore
  65717. * The PassPostProcess id in the pipeline that contains the original scene color
  65718. */
  65719. SSAOOriginalSceneColorEffect: string;
  65720. /**
  65721. * @ignore
  65722. * The SSAO PostProcess id in the pipeline
  65723. */
  65724. SSAORenderEffect: string;
  65725. /**
  65726. * @ignore
  65727. * The horizontal blur PostProcess id in the pipeline
  65728. */
  65729. SSAOBlurHRenderEffect: string;
  65730. /**
  65731. * @ignore
  65732. * The vertical blur PostProcess id in the pipeline
  65733. */
  65734. SSAOBlurVRenderEffect: string;
  65735. /**
  65736. * @ignore
  65737. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65738. */
  65739. SSAOCombineRenderEffect: string;
  65740. /**
  65741. * The output strength of the SSAO post-process. Default value is 1.0.
  65742. */
  65743. totalStrength: number;
  65744. /**
  65745. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65746. */
  65747. radius: number;
  65748. /**
  65749. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65750. * Must not be equal to fallOff and superior to fallOff.
  65751. * Default value is 0.0075
  65752. */
  65753. area: number;
  65754. /**
  65755. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65756. * Must not be equal to area and inferior to area.
  65757. * Default value is 0.000001
  65758. */
  65759. fallOff: number;
  65760. /**
  65761. * The base color of the SSAO post-process
  65762. * The final result is "base + ssao" between [0, 1]
  65763. */
  65764. base: number;
  65765. private _scene;
  65766. private _depthTexture;
  65767. private _randomTexture;
  65768. private _originalColorPostProcess;
  65769. private _ssaoPostProcess;
  65770. private _blurHPostProcess;
  65771. private _blurVPostProcess;
  65772. private _ssaoCombinePostProcess;
  65773. private _firstUpdate;
  65774. /**
  65775. * Gets active scene
  65776. */
  65777. get scene(): Scene;
  65778. /**
  65779. * @constructor
  65780. * @param name - The rendering pipeline name
  65781. * @param scene - The scene linked to this pipeline
  65782. * @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 }
  65783. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65784. */
  65785. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65786. /**
  65787. * Get the class name
  65788. * @returns "SSAORenderingPipeline"
  65789. */
  65790. getClassName(): string;
  65791. /**
  65792. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65793. */
  65794. dispose(disableDepthRender?: boolean): void;
  65795. private _createBlurPostProcess;
  65796. /** @hidden */
  65797. _rebuild(): void;
  65798. private _createSSAOPostProcess;
  65799. private _createSSAOCombinePostProcess;
  65800. private _createRandomTexture;
  65801. }
  65802. }
  65803. declare module BABYLON {
  65804. /** @hidden */
  65805. export var screenSpaceReflectionPixelShader: {
  65806. name: string;
  65807. shader: string;
  65808. };
  65809. }
  65810. declare module BABYLON {
  65811. /**
  65812. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65813. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65814. */
  65815. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65816. /**
  65817. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65818. */
  65819. threshold: number;
  65820. /**
  65821. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65822. */
  65823. strength: number;
  65824. /**
  65825. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65826. */
  65827. reflectionSpecularFalloffExponent: number;
  65828. /**
  65829. * 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]
  65830. */
  65831. step: number;
  65832. /**
  65833. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65834. */
  65835. roughnessFactor: number;
  65836. private _geometryBufferRenderer;
  65837. private _enableSmoothReflections;
  65838. private _reflectionSamples;
  65839. private _smoothSteps;
  65840. /**
  65841. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65842. * @param name The name of the effect.
  65843. * @param scene The scene containing the objects to calculate reflections.
  65844. * @param options The required width/height ratio to downsize to before computing the render pass.
  65845. * @param camera The camera to apply the render pass to.
  65846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65847. * @param engine The engine which the post process will be applied. (default: current engine)
  65848. * @param reusable If the post process can be reused on the same frame. (default: false)
  65849. * @param textureType Type of textures used when performing the post process. (default: 0)
  65850. * @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)
  65851. */
  65852. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65853. /**
  65854. * Gets wether or not smoothing reflections is enabled.
  65855. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65856. */
  65857. get enableSmoothReflections(): boolean;
  65858. /**
  65859. * Sets wether or not smoothing reflections is enabled.
  65860. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65861. */
  65862. set enableSmoothReflections(enabled: boolean);
  65863. /**
  65864. * Gets the number of samples taken while computing reflections. More samples count is high,
  65865. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65866. */
  65867. get reflectionSamples(): number;
  65868. /**
  65869. * Sets the number of samples taken while computing reflections. More samples count is high,
  65870. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65871. */
  65872. set reflectionSamples(samples: number);
  65873. /**
  65874. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65875. * more the post-process will require GPU power and can generate a drop in FPS.
  65876. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65877. */
  65878. get smoothSteps(): number;
  65879. set smoothSteps(steps: number);
  65880. private _updateEffectDefines;
  65881. }
  65882. }
  65883. declare module BABYLON {
  65884. /** @hidden */
  65885. export var standardPixelShader: {
  65886. name: string;
  65887. shader: string;
  65888. };
  65889. }
  65890. declare module BABYLON {
  65891. /**
  65892. * Standard rendering pipeline
  65893. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65894. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65895. */
  65896. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65897. /**
  65898. * Public members
  65899. */
  65900. /**
  65901. * Post-process which contains the original scene color before the pipeline applies all the effects
  65902. */
  65903. originalPostProcess: Nullable<PostProcess>;
  65904. /**
  65905. * Post-process used to down scale an image x4
  65906. */
  65907. downSampleX4PostProcess: Nullable<PostProcess>;
  65908. /**
  65909. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65910. */
  65911. brightPassPostProcess: Nullable<PostProcess>;
  65912. /**
  65913. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65914. */
  65915. blurHPostProcesses: PostProcess[];
  65916. /**
  65917. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65918. */
  65919. blurVPostProcesses: PostProcess[];
  65920. /**
  65921. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65922. */
  65923. textureAdderPostProcess: Nullable<PostProcess>;
  65924. /**
  65925. * Post-process used to create volumetric lighting effect
  65926. */
  65927. volumetricLightPostProcess: Nullable<PostProcess>;
  65928. /**
  65929. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65930. */
  65931. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65932. /**
  65933. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65934. */
  65935. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65936. /**
  65937. * Post-process used to merge the volumetric light effect and the real scene color
  65938. */
  65939. volumetricLightMergePostProces: Nullable<PostProcess>;
  65940. /**
  65941. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65942. */
  65943. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65944. /**
  65945. * Base post-process used to calculate the average luminance of the final image for HDR
  65946. */
  65947. luminancePostProcess: Nullable<PostProcess>;
  65948. /**
  65949. * Post-processes used to create down sample post-processes in order to get
  65950. * the average luminance of the final image for HDR
  65951. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65952. */
  65953. luminanceDownSamplePostProcesses: PostProcess[];
  65954. /**
  65955. * Post-process used to create a HDR effect (light adaptation)
  65956. */
  65957. hdrPostProcess: Nullable<PostProcess>;
  65958. /**
  65959. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65960. */
  65961. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65962. /**
  65963. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65964. */
  65965. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65966. /**
  65967. * Post-process used to merge the final HDR post-process and the real scene color
  65968. */
  65969. hdrFinalPostProcess: Nullable<PostProcess>;
  65970. /**
  65971. * Post-process used to create a lens flare effect
  65972. */
  65973. lensFlarePostProcess: Nullable<PostProcess>;
  65974. /**
  65975. * Post-process that merges the result of the lens flare post-process and the real scene color
  65976. */
  65977. lensFlareComposePostProcess: Nullable<PostProcess>;
  65978. /**
  65979. * Post-process used to create a motion blur effect
  65980. */
  65981. motionBlurPostProcess: Nullable<PostProcess>;
  65982. /**
  65983. * Post-process used to create a depth of field effect
  65984. */
  65985. depthOfFieldPostProcess: Nullable<PostProcess>;
  65986. /**
  65987. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65988. */
  65989. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65990. /**
  65991. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  65992. */
  65993. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  65994. /**
  65995. * Represents the brightness threshold in order to configure the illuminated surfaces
  65996. */
  65997. brightThreshold: number;
  65998. /**
  65999. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66000. */
  66001. blurWidth: number;
  66002. /**
  66003. * Sets if the blur for highlighted surfaces must be only horizontal
  66004. */
  66005. horizontalBlur: boolean;
  66006. /**
  66007. * Gets the overall exposure used by the pipeline
  66008. */
  66009. get exposure(): number;
  66010. /**
  66011. * Sets the overall exposure used by the pipeline
  66012. */
  66013. set exposure(value: number);
  66014. /**
  66015. * Texture used typically to simulate "dirty" on camera lens
  66016. */
  66017. lensTexture: Nullable<Texture>;
  66018. /**
  66019. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66020. */
  66021. volumetricLightCoefficient: number;
  66022. /**
  66023. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66024. */
  66025. volumetricLightPower: number;
  66026. /**
  66027. * Used the set the blur intensity to smooth the volumetric lights
  66028. */
  66029. volumetricLightBlurScale: number;
  66030. /**
  66031. * Light (spot or directional) used to generate the volumetric lights rays
  66032. * The source light must have a shadow generate so the pipeline can get its
  66033. * depth map
  66034. */
  66035. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66036. /**
  66037. * For eye adaptation, represents the minimum luminance the eye can see
  66038. */
  66039. hdrMinimumLuminance: number;
  66040. /**
  66041. * For eye adaptation, represents the decrease luminance speed
  66042. */
  66043. hdrDecreaseRate: number;
  66044. /**
  66045. * For eye adaptation, represents the increase luminance speed
  66046. */
  66047. hdrIncreaseRate: number;
  66048. /**
  66049. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66050. */
  66051. get hdrAutoExposure(): boolean;
  66052. /**
  66053. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66054. */
  66055. set hdrAutoExposure(value: boolean);
  66056. /**
  66057. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66058. */
  66059. lensColorTexture: Nullable<Texture>;
  66060. /**
  66061. * The overall strengh for the lens flare effect
  66062. */
  66063. lensFlareStrength: number;
  66064. /**
  66065. * Dispersion coefficient for lens flare ghosts
  66066. */
  66067. lensFlareGhostDispersal: number;
  66068. /**
  66069. * Main lens flare halo width
  66070. */
  66071. lensFlareHaloWidth: number;
  66072. /**
  66073. * Based on the lens distortion effect, defines how much the lens flare result
  66074. * is distorted
  66075. */
  66076. lensFlareDistortionStrength: number;
  66077. /**
  66078. * Configures the blur intensity used for for lens flare (halo)
  66079. */
  66080. lensFlareBlurWidth: number;
  66081. /**
  66082. * Lens star texture must be used to simulate rays on the flares and is available
  66083. * in the documentation
  66084. */
  66085. lensStarTexture: Nullable<Texture>;
  66086. /**
  66087. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66088. * flare effect by taking account of the dirt texture
  66089. */
  66090. lensFlareDirtTexture: Nullable<Texture>;
  66091. /**
  66092. * Represents the focal length for the depth of field effect
  66093. */
  66094. depthOfFieldDistance: number;
  66095. /**
  66096. * Represents the blur intensity for the blurred part of the depth of field effect
  66097. */
  66098. depthOfFieldBlurWidth: number;
  66099. /**
  66100. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66101. */
  66102. get motionStrength(): number;
  66103. /**
  66104. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66105. */
  66106. set motionStrength(strength: number);
  66107. /**
  66108. * Gets wether or not the motion blur post-process is object based or screen based.
  66109. */
  66110. get objectBasedMotionBlur(): boolean;
  66111. /**
  66112. * Sets wether or not the motion blur post-process should be object based or screen based
  66113. */
  66114. set objectBasedMotionBlur(value: boolean);
  66115. /**
  66116. * List of animations for the pipeline (IAnimatable implementation)
  66117. */
  66118. animations: Animation[];
  66119. /**
  66120. * Private members
  66121. */
  66122. private _scene;
  66123. private _currentDepthOfFieldSource;
  66124. private _basePostProcess;
  66125. private _fixedExposure;
  66126. private _currentExposure;
  66127. private _hdrAutoExposure;
  66128. private _hdrCurrentLuminance;
  66129. private _motionStrength;
  66130. private _isObjectBasedMotionBlur;
  66131. private _floatTextureType;
  66132. private _camerasToBeAttached;
  66133. private _ratio;
  66134. private _bloomEnabled;
  66135. private _depthOfFieldEnabled;
  66136. private _vlsEnabled;
  66137. private _lensFlareEnabled;
  66138. private _hdrEnabled;
  66139. private _motionBlurEnabled;
  66140. private _fxaaEnabled;
  66141. private _screenSpaceReflectionsEnabled;
  66142. private _motionBlurSamples;
  66143. private _volumetricLightStepsCount;
  66144. private _samples;
  66145. /**
  66146. * @ignore
  66147. * Specifies if the bloom pipeline is enabled
  66148. */
  66149. get BloomEnabled(): boolean;
  66150. set BloomEnabled(enabled: boolean);
  66151. /**
  66152. * @ignore
  66153. * Specifies if the depth of field pipeline is enabed
  66154. */
  66155. get DepthOfFieldEnabled(): boolean;
  66156. set DepthOfFieldEnabled(enabled: boolean);
  66157. /**
  66158. * @ignore
  66159. * Specifies if the lens flare pipeline is enabed
  66160. */
  66161. get LensFlareEnabled(): boolean;
  66162. set LensFlareEnabled(enabled: boolean);
  66163. /**
  66164. * @ignore
  66165. * Specifies if the HDR pipeline is enabled
  66166. */
  66167. get HDREnabled(): boolean;
  66168. set HDREnabled(enabled: boolean);
  66169. /**
  66170. * @ignore
  66171. * Specifies if the volumetric lights scattering effect is enabled
  66172. */
  66173. get VLSEnabled(): boolean;
  66174. set VLSEnabled(enabled: boolean);
  66175. /**
  66176. * @ignore
  66177. * Specifies if the motion blur effect is enabled
  66178. */
  66179. get MotionBlurEnabled(): boolean;
  66180. set MotionBlurEnabled(enabled: boolean);
  66181. /**
  66182. * Specifies if anti-aliasing is enabled
  66183. */
  66184. get fxaaEnabled(): boolean;
  66185. set fxaaEnabled(enabled: boolean);
  66186. /**
  66187. * Specifies if screen space reflections are enabled.
  66188. */
  66189. get screenSpaceReflectionsEnabled(): boolean;
  66190. set screenSpaceReflectionsEnabled(enabled: boolean);
  66191. /**
  66192. * Specifies the number of steps used to calculate the volumetric lights
  66193. * Typically in interval [50, 200]
  66194. */
  66195. get volumetricLightStepsCount(): number;
  66196. set volumetricLightStepsCount(count: number);
  66197. /**
  66198. * Specifies the number of samples used for the motion blur effect
  66199. * Typically in interval [16, 64]
  66200. */
  66201. get motionBlurSamples(): number;
  66202. set motionBlurSamples(samples: number);
  66203. /**
  66204. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66205. */
  66206. get samples(): number;
  66207. set samples(sampleCount: number);
  66208. /**
  66209. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66210. * @constructor
  66211. * @param name The rendering pipeline name
  66212. * @param scene The scene linked to this pipeline
  66213. * @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)
  66214. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66215. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66216. */
  66217. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66218. private _buildPipeline;
  66219. private _createDownSampleX4PostProcess;
  66220. private _createBrightPassPostProcess;
  66221. private _createBlurPostProcesses;
  66222. private _createTextureAdderPostProcess;
  66223. private _createVolumetricLightPostProcess;
  66224. private _createLuminancePostProcesses;
  66225. private _createHdrPostProcess;
  66226. private _createLensFlarePostProcess;
  66227. private _createDepthOfFieldPostProcess;
  66228. private _createMotionBlurPostProcess;
  66229. private _getDepthTexture;
  66230. private _disposePostProcesses;
  66231. /**
  66232. * Dispose of the pipeline and stop all post processes
  66233. */
  66234. dispose(): void;
  66235. /**
  66236. * Serialize the rendering pipeline (Used when exporting)
  66237. * @returns the serialized object
  66238. */
  66239. serialize(): any;
  66240. /**
  66241. * Parse the serialized pipeline
  66242. * @param source Source pipeline.
  66243. * @param scene The scene to load the pipeline to.
  66244. * @param rootUrl The URL of the serialized pipeline.
  66245. * @returns An instantiated pipeline from the serialized object.
  66246. */
  66247. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66248. /**
  66249. * Luminance steps
  66250. */
  66251. static LuminanceSteps: number;
  66252. }
  66253. }
  66254. declare module BABYLON {
  66255. /** @hidden */
  66256. export var tonemapPixelShader: {
  66257. name: string;
  66258. shader: string;
  66259. };
  66260. }
  66261. declare module BABYLON {
  66262. /** Defines operator used for tonemapping */
  66263. export enum TonemappingOperator {
  66264. /** Hable */
  66265. Hable = 0,
  66266. /** Reinhard */
  66267. Reinhard = 1,
  66268. /** HejiDawson */
  66269. HejiDawson = 2,
  66270. /** Photographic */
  66271. Photographic = 3
  66272. }
  66273. /**
  66274. * Defines a post process to apply tone mapping
  66275. */
  66276. export class TonemapPostProcess extends PostProcess {
  66277. private _operator;
  66278. /** Defines the required exposure adjustement */
  66279. exposureAdjustment: number;
  66280. /**
  66281. * Creates a new TonemapPostProcess
  66282. * @param name defines the name of the postprocess
  66283. * @param _operator defines the operator to use
  66284. * @param exposureAdjustment defines the required exposure adjustement
  66285. * @param camera defines the camera to use (can be null)
  66286. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66287. * @param engine defines the hosting engine (can be ignore if camera is set)
  66288. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66289. */
  66290. constructor(name: string, _operator: TonemappingOperator,
  66291. /** Defines the required exposure adjustement */
  66292. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66293. }
  66294. }
  66295. declare module BABYLON {
  66296. /** @hidden */
  66297. export var volumetricLightScatteringPixelShader: {
  66298. name: string;
  66299. shader: string;
  66300. };
  66301. }
  66302. declare module BABYLON {
  66303. /** @hidden */
  66304. export var volumetricLightScatteringPassVertexShader: {
  66305. name: string;
  66306. shader: string;
  66307. };
  66308. }
  66309. declare module BABYLON {
  66310. /** @hidden */
  66311. export var volumetricLightScatteringPassPixelShader: {
  66312. name: string;
  66313. shader: string;
  66314. };
  66315. }
  66316. declare module BABYLON {
  66317. /**
  66318. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66319. */
  66320. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66321. private _volumetricLightScatteringPass;
  66322. private _volumetricLightScatteringRTT;
  66323. private _viewPort;
  66324. private _screenCoordinates;
  66325. private _cachedDefines;
  66326. /**
  66327. * If not undefined, the mesh position is computed from the attached node position
  66328. */
  66329. attachedNode: {
  66330. position: Vector3;
  66331. };
  66332. /**
  66333. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66334. */
  66335. customMeshPosition: Vector3;
  66336. /**
  66337. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66338. */
  66339. useCustomMeshPosition: boolean;
  66340. /**
  66341. * If the post-process should inverse the light scattering direction
  66342. */
  66343. invert: boolean;
  66344. /**
  66345. * The internal mesh used by the post-process
  66346. */
  66347. mesh: Mesh;
  66348. /**
  66349. * @hidden
  66350. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66351. */
  66352. get useDiffuseColor(): boolean;
  66353. set useDiffuseColor(useDiffuseColor: boolean);
  66354. /**
  66355. * Array containing the excluded meshes not rendered in the internal pass
  66356. */
  66357. excludedMeshes: AbstractMesh[];
  66358. /**
  66359. * Controls the overall intensity of the post-process
  66360. */
  66361. exposure: number;
  66362. /**
  66363. * Dissipates each sample's contribution in range [0, 1]
  66364. */
  66365. decay: number;
  66366. /**
  66367. * Controls the overall intensity of each sample
  66368. */
  66369. weight: number;
  66370. /**
  66371. * Controls the density of each sample
  66372. */
  66373. density: number;
  66374. /**
  66375. * @constructor
  66376. * @param name The post-process name
  66377. * @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)
  66378. * @param camera The camera that the post-process will be attached to
  66379. * @param mesh The mesh used to create the light scattering
  66380. * @param samples The post-process quality, default 100
  66381. * @param samplingModeThe post-process filtering mode
  66382. * @param engine The babylon engine
  66383. * @param reusable If the post-process is reusable
  66384. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66385. */
  66386. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66387. /**
  66388. * Returns the string "VolumetricLightScatteringPostProcess"
  66389. * @returns "VolumetricLightScatteringPostProcess"
  66390. */
  66391. getClassName(): string;
  66392. private _isReady;
  66393. /**
  66394. * Sets the new light position for light scattering effect
  66395. * @param position The new custom light position
  66396. */
  66397. setCustomMeshPosition(position: Vector3): void;
  66398. /**
  66399. * Returns the light position for light scattering effect
  66400. * @return Vector3 The custom light position
  66401. */
  66402. getCustomMeshPosition(): Vector3;
  66403. /**
  66404. * Disposes the internal assets and detaches the post-process from the camera
  66405. */
  66406. dispose(camera: Camera): void;
  66407. /**
  66408. * Returns the render target texture used by the post-process
  66409. * @return the render target texture used by the post-process
  66410. */
  66411. getPass(): RenderTargetTexture;
  66412. private _meshExcluded;
  66413. private _createPass;
  66414. private _updateMeshScreenCoordinates;
  66415. /**
  66416. * Creates a default mesh for the Volumeric Light Scattering post-process
  66417. * @param name The mesh name
  66418. * @param scene The scene where to create the mesh
  66419. * @return the default mesh
  66420. */
  66421. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66422. }
  66423. }
  66424. declare module BABYLON {
  66425. interface Scene {
  66426. /** @hidden (Backing field) */
  66427. _boundingBoxRenderer: BoundingBoxRenderer;
  66428. /** @hidden (Backing field) */
  66429. _forceShowBoundingBoxes: boolean;
  66430. /**
  66431. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66432. */
  66433. forceShowBoundingBoxes: boolean;
  66434. /**
  66435. * Gets the bounding box renderer associated with the scene
  66436. * @returns a BoundingBoxRenderer
  66437. */
  66438. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66439. }
  66440. interface AbstractMesh {
  66441. /** @hidden (Backing field) */
  66442. _showBoundingBox: boolean;
  66443. /**
  66444. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66445. */
  66446. showBoundingBox: boolean;
  66447. }
  66448. /**
  66449. * Component responsible of rendering the bounding box of the meshes in a scene.
  66450. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66451. */
  66452. export class BoundingBoxRenderer implements ISceneComponent {
  66453. /**
  66454. * The component name helpfull to identify the component in the list of scene components.
  66455. */
  66456. readonly name: string;
  66457. /**
  66458. * The scene the component belongs to.
  66459. */
  66460. scene: Scene;
  66461. /**
  66462. * Color of the bounding box lines placed in front of an object
  66463. */
  66464. frontColor: Color3;
  66465. /**
  66466. * Color of the bounding box lines placed behind an object
  66467. */
  66468. backColor: Color3;
  66469. /**
  66470. * Defines if the renderer should show the back lines or not
  66471. */
  66472. showBackLines: boolean;
  66473. /**
  66474. * @hidden
  66475. */
  66476. renderList: SmartArray<BoundingBox>;
  66477. private _colorShader;
  66478. private _vertexBuffers;
  66479. private _indexBuffer;
  66480. private _fillIndexBuffer;
  66481. private _fillIndexData;
  66482. /**
  66483. * Instantiates a new bounding box renderer in a scene.
  66484. * @param scene the scene the renderer renders in
  66485. */
  66486. constructor(scene: Scene);
  66487. /**
  66488. * Registers the component in a given scene
  66489. */
  66490. register(): void;
  66491. private _evaluateSubMesh;
  66492. private _activeMesh;
  66493. private _prepareRessources;
  66494. private _createIndexBuffer;
  66495. /**
  66496. * Rebuilds the elements related to this component in case of
  66497. * context lost for instance.
  66498. */
  66499. rebuild(): void;
  66500. /**
  66501. * @hidden
  66502. */
  66503. reset(): void;
  66504. /**
  66505. * Render the bounding boxes of a specific rendering group
  66506. * @param renderingGroupId defines the rendering group to render
  66507. */
  66508. render(renderingGroupId: number): void;
  66509. /**
  66510. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66511. * @param mesh Define the mesh to render the occlusion bounding box for
  66512. */
  66513. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66514. /**
  66515. * Dispose and release the resources attached to this renderer.
  66516. */
  66517. dispose(): void;
  66518. }
  66519. }
  66520. declare module BABYLON {
  66521. interface Scene {
  66522. /** @hidden (Backing field) */
  66523. _depthRenderer: {
  66524. [id: string]: DepthRenderer;
  66525. };
  66526. /**
  66527. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66528. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66529. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66530. * @returns the created depth renderer
  66531. */
  66532. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66533. /**
  66534. * Disables a depth renderer for a given camera
  66535. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66536. */
  66537. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66538. }
  66539. /**
  66540. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66541. * in several rendering techniques.
  66542. */
  66543. export class DepthRendererSceneComponent implements ISceneComponent {
  66544. /**
  66545. * The component name helpfull to identify the component in the list of scene components.
  66546. */
  66547. readonly name: string;
  66548. /**
  66549. * The scene the component belongs to.
  66550. */
  66551. scene: Scene;
  66552. /**
  66553. * Creates a new instance of the component for the given scene
  66554. * @param scene Defines the scene to register the component in
  66555. */
  66556. constructor(scene: Scene);
  66557. /**
  66558. * Registers the component in a given scene
  66559. */
  66560. register(): void;
  66561. /**
  66562. * Rebuilds the elements related to this component in case of
  66563. * context lost for instance.
  66564. */
  66565. rebuild(): void;
  66566. /**
  66567. * Disposes the component and the associated ressources
  66568. */
  66569. dispose(): void;
  66570. private _gatherRenderTargets;
  66571. private _gatherActiveCameraRenderTargets;
  66572. }
  66573. }
  66574. declare module BABYLON {
  66575. /** @hidden */
  66576. export var outlinePixelShader: {
  66577. name: string;
  66578. shader: string;
  66579. };
  66580. }
  66581. declare module BABYLON {
  66582. /** @hidden */
  66583. export var outlineVertexShader: {
  66584. name: string;
  66585. shader: string;
  66586. };
  66587. }
  66588. declare module BABYLON {
  66589. interface Scene {
  66590. /** @hidden */
  66591. _outlineRenderer: OutlineRenderer;
  66592. /**
  66593. * Gets the outline renderer associated with the scene
  66594. * @returns a OutlineRenderer
  66595. */
  66596. getOutlineRenderer(): OutlineRenderer;
  66597. }
  66598. interface AbstractMesh {
  66599. /** @hidden (Backing field) */
  66600. _renderOutline: boolean;
  66601. /**
  66602. * Gets or sets a boolean indicating if the outline must be rendered as well
  66603. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66604. */
  66605. renderOutline: boolean;
  66606. /** @hidden (Backing field) */
  66607. _renderOverlay: boolean;
  66608. /**
  66609. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66610. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66611. */
  66612. renderOverlay: boolean;
  66613. }
  66614. /**
  66615. * This class is responsible to draw bothe outline/overlay of meshes.
  66616. * It should not be used directly but through the available method on mesh.
  66617. */
  66618. export class OutlineRenderer implements ISceneComponent {
  66619. /**
  66620. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66621. */
  66622. private static _StencilReference;
  66623. /**
  66624. * The name of the component. Each component must have a unique name.
  66625. */
  66626. name: string;
  66627. /**
  66628. * The scene the component belongs to.
  66629. */
  66630. scene: Scene;
  66631. /**
  66632. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66633. */
  66634. zOffset: number;
  66635. private _engine;
  66636. private _effect;
  66637. private _cachedDefines;
  66638. private _savedDepthWrite;
  66639. /**
  66640. * Instantiates a new outline renderer. (There could be only one per scene).
  66641. * @param scene Defines the scene it belongs to
  66642. */
  66643. constructor(scene: Scene);
  66644. /**
  66645. * Register the component to one instance of a scene.
  66646. */
  66647. register(): void;
  66648. /**
  66649. * Rebuilds the elements related to this component in case of
  66650. * context lost for instance.
  66651. */
  66652. rebuild(): void;
  66653. /**
  66654. * Disposes the component and the associated ressources.
  66655. */
  66656. dispose(): void;
  66657. /**
  66658. * Renders the outline in the canvas.
  66659. * @param subMesh Defines the sumesh to render
  66660. * @param batch Defines the batch of meshes in case of instances
  66661. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66662. */
  66663. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66664. /**
  66665. * Returns whether or not the outline renderer is ready for a given submesh.
  66666. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66667. * @param subMesh Defines the submesh to check readyness for
  66668. * @param useInstances Defines wheter wee are trying to render instances or not
  66669. * @returns true if ready otherwise false
  66670. */
  66671. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66672. private _beforeRenderingMesh;
  66673. private _afterRenderingMesh;
  66674. }
  66675. }
  66676. declare module BABYLON {
  66677. /**
  66678. * Defines the basic options interface of a Sprite Frame Source Size.
  66679. */
  66680. export interface ISpriteJSONSpriteSourceSize {
  66681. /**
  66682. * number of the original width of the Frame
  66683. */
  66684. w: number;
  66685. /**
  66686. * number of the original height of the Frame
  66687. */
  66688. h: number;
  66689. }
  66690. /**
  66691. * Defines the basic options interface of a Sprite Frame Data.
  66692. */
  66693. export interface ISpriteJSONSpriteFrameData {
  66694. /**
  66695. * number of the x offset of the Frame
  66696. */
  66697. x: number;
  66698. /**
  66699. * number of the y offset of the Frame
  66700. */
  66701. y: number;
  66702. /**
  66703. * number of the width of the Frame
  66704. */
  66705. w: number;
  66706. /**
  66707. * number of the height of the Frame
  66708. */
  66709. h: number;
  66710. }
  66711. /**
  66712. * Defines the basic options interface of a JSON Sprite.
  66713. */
  66714. export interface ISpriteJSONSprite {
  66715. /**
  66716. * string name of the Frame
  66717. */
  66718. filename: string;
  66719. /**
  66720. * ISpriteJSONSpriteFrame basic object of the frame data
  66721. */
  66722. frame: ISpriteJSONSpriteFrameData;
  66723. /**
  66724. * boolean to flag is the frame was rotated.
  66725. */
  66726. rotated: boolean;
  66727. /**
  66728. * boolean to flag is the frame was trimmed.
  66729. */
  66730. trimmed: boolean;
  66731. /**
  66732. * ISpriteJSONSpriteFrame basic object of the source data
  66733. */
  66734. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66735. /**
  66736. * ISpriteJSONSpriteFrame basic object of the source data
  66737. */
  66738. sourceSize: ISpriteJSONSpriteSourceSize;
  66739. }
  66740. /**
  66741. * Defines the basic options interface of a JSON atlas.
  66742. */
  66743. export interface ISpriteJSONAtlas {
  66744. /**
  66745. * Array of objects that contain the frame data.
  66746. */
  66747. frames: Array<ISpriteJSONSprite>;
  66748. /**
  66749. * object basic object containing the sprite meta data.
  66750. */
  66751. meta?: object;
  66752. }
  66753. }
  66754. declare module BABYLON {
  66755. /** @hidden */
  66756. export var spriteMapPixelShader: {
  66757. name: string;
  66758. shader: string;
  66759. };
  66760. }
  66761. declare module BABYLON {
  66762. /** @hidden */
  66763. export var spriteMapVertexShader: {
  66764. name: string;
  66765. shader: string;
  66766. };
  66767. }
  66768. declare module BABYLON {
  66769. /**
  66770. * Defines the basic options interface of a SpriteMap
  66771. */
  66772. export interface ISpriteMapOptions {
  66773. /**
  66774. * Vector2 of the number of cells in the grid.
  66775. */
  66776. stageSize?: Vector2;
  66777. /**
  66778. * Vector2 of the size of the output plane in World Units.
  66779. */
  66780. outputSize?: Vector2;
  66781. /**
  66782. * Vector3 of the position of the output plane in World Units.
  66783. */
  66784. outputPosition?: Vector3;
  66785. /**
  66786. * Vector3 of the rotation of the output plane.
  66787. */
  66788. outputRotation?: Vector3;
  66789. /**
  66790. * number of layers that the system will reserve in resources.
  66791. */
  66792. layerCount?: number;
  66793. /**
  66794. * number of max animation frames a single cell will reserve in resources.
  66795. */
  66796. maxAnimationFrames?: number;
  66797. /**
  66798. * number cell index of the base tile when the system compiles.
  66799. */
  66800. baseTile?: number;
  66801. /**
  66802. * boolean flip the sprite after its been repositioned by the framing data.
  66803. */
  66804. flipU?: boolean;
  66805. /**
  66806. * Vector3 scalar of the global RGB values of the SpriteMap.
  66807. */
  66808. colorMultiply?: Vector3;
  66809. }
  66810. /**
  66811. * Defines the IDisposable interface in order to be cleanable from resources.
  66812. */
  66813. export interface ISpriteMap extends IDisposable {
  66814. /**
  66815. * String name of the SpriteMap.
  66816. */
  66817. name: string;
  66818. /**
  66819. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66820. */
  66821. atlasJSON: ISpriteJSONAtlas;
  66822. /**
  66823. * Texture of the SpriteMap.
  66824. */
  66825. spriteSheet: Texture;
  66826. /**
  66827. * The parameters to initialize the SpriteMap with.
  66828. */
  66829. options: ISpriteMapOptions;
  66830. }
  66831. /**
  66832. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66833. */
  66834. export class SpriteMap implements ISpriteMap {
  66835. /** The Name of the spriteMap */
  66836. name: string;
  66837. /** The JSON file with the frame and meta data */
  66838. atlasJSON: ISpriteJSONAtlas;
  66839. /** The systems Sprite Sheet Texture */
  66840. spriteSheet: Texture;
  66841. /** Arguments passed with the Constructor */
  66842. options: ISpriteMapOptions;
  66843. /** Public Sprite Storage array, parsed from atlasJSON */
  66844. sprites: Array<ISpriteJSONSprite>;
  66845. /** Returns the Number of Sprites in the System */
  66846. get spriteCount(): number;
  66847. /** Returns the Position of Output Plane*/
  66848. get position(): Vector3;
  66849. /** Returns the Position of Output Plane*/
  66850. set position(v: Vector3);
  66851. /** Returns the Rotation of Output Plane*/
  66852. get rotation(): Vector3;
  66853. /** Returns the Rotation of Output Plane*/
  66854. set rotation(v: Vector3);
  66855. /** Sets the AnimationMap*/
  66856. get animationMap(): RawTexture;
  66857. /** Sets the AnimationMap*/
  66858. set animationMap(v: RawTexture);
  66859. /** Scene that the SpriteMap was created in */
  66860. private _scene;
  66861. /** Texture Buffer of Float32 that holds tile frame data*/
  66862. private _frameMap;
  66863. /** Texture Buffers of Float32 that holds tileMap data*/
  66864. private _tileMaps;
  66865. /** Texture Buffer of Float32 that holds Animation Data*/
  66866. private _animationMap;
  66867. /** Custom ShaderMaterial Central to the System*/
  66868. private _material;
  66869. /** Custom ShaderMaterial Central to the System*/
  66870. private _output;
  66871. /** Systems Time Ticker*/
  66872. private _time;
  66873. /**
  66874. * Creates a new SpriteMap
  66875. * @param name defines the SpriteMaps Name
  66876. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66877. * @param spriteSheet is the Texture that the Sprites are on.
  66878. * @param options a basic deployment configuration
  66879. * @param scene The Scene that the map is deployed on
  66880. */
  66881. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66882. /**
  66883. * Returns tileID location
  66884. * @returns Vector2 the cell position ID
  66885. */
  66886. getTileID(): Vector2;
  66887. /**
  66888. * Gets the UV location of the mouse over the SpriteMap.
  66889. * @returns Vector2 the UV position of the mouse interaction
  66890. */
  66891. getMousePosition(): Vector2;
  66892. /**
  66893. * Creates the "frame" texture Buffer
  66894. * -------------------------------------
  66895. * Structure of frames
  66896. * "filename": "Falling-Water-2.png",
  66897. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66898. * "rotated": true,
  66899. * "trimmed": true,
  66900. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66901. * "sourceSize": {"w":32,"h":32}
  66902. * @returns RawTexture of the frameMap
  66903. */
  66904. private _createFrameBuffer;
  66905. /**
  66906. * Creates the tileMap texture Buffer
  66907. * @param buffer normally and array of numbers, or a false to generate from scratch
  66908. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66909. * @returns RawTexture of the tileMap
  66910. */
  66911. private _createTileBuffer;
  66912. /**
  66913. * Modifies the data of the tileMaps
  66914. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66915. * @param pos is the iVector2 Coordinates of the Tile
  66916. * @param tile The SpriteIndex of the new Tile
  66917. */
  66918. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66919. /**
  66920. * Creates the animationMap texture Buffer
  66921. * @param buffer normally and array of numbers, or a false to generate from scratch
  66922. * @returns RawTexture of the animationMap
  66923. */
  66924. private _createTileAnimationBuffer;
  66925. /**
  66926. * Modifies the data of the animationMap
  66927. * @param cellID is the Index of the Sprite
  66928. * @param _frame is the target Animation frame
  66929. * @param toCell is the Target Index of the next frame of the animation
  66930. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66931. * @param speed is a global scalar of the time variable on the map.
  66932. */
  66933. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66934. /**
  66935. * Exports the .tilemaps file
  66936. */
  66937. saveTileMaps(): void;
  66938. /**
  66939. * Imports the .tilemaps file
  66940. * @param url of the .tilemaps file
  66941. */
  66942. loadTileMaps(url: string): void;
  66943. /**
  66944. * Release associated resources
  66945. */
  66946. dispose(): void;
  66947. }
  66948. }
  66949. declare module BABYLON {
  66950. /**
  66951. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66952. * @see http://doc.babylonjs.com/babylon101/sprites
  66953. */
  66954. export class SpritePackedManager extends SpriteManager {
  66955. /** defines the packed manager's name */
  66956. name: string;
  66957. /**
  66958. * Creates a new sprite manager from a packed sprite sheet
  66959. * @param name defines the manager's name
  66960. * @param imgUrl defines the sprite sheet url
  66961. * @param capacity defines the maximum allowed number of sprites
  66962. * @param scene defines the hosting scene
  66963. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66964. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66965. * @param samplingMode defines the smapling mode to use with spritesheet
  66966. * @param fromPacked set to true; do not alter
  66967. */
  66968. constructor(
  66969. /** defines the packed manager's name */
  66970. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66971. }
  66972. }
  66973. declare module BABYLON {
  66974. /**
  66975. * Defines the list of states available for a task inside a AssetsManager
  66976. */
  66977. export enum AssetTaskState {
  66978. /**
  66979. * Initialization
  66980. */
  66981. INIT = 0,
  66982. /**
  66983. * Running
  66984. */
  66985. RUNNING = 1,
  66986. /**
  66987. * Done
  66988. */
  66989. DONE = 2,
  66990. /**
  66991. * Error
  66992. */
  66993. ERROR = 3
  66994. }
  66995. /**
  66996. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66997. */
  66998. export abstract class AbstractAssetTask {
  66999. /**
  67000. * Task name
  67001. */ name: string;
  67002. /**
  67003. * Callback called when the task is successful
  67004. */
  67005. onSuccess: (task: any) => void;
  67006. /**
  67007. * Callback called when the task is not successful
  67008. */
  67009. onError: (task: any, message?: string, exception?: any) => void;
  67010. /**
  67011. * Creates a new AssetsManager
  67012. * @param name defines the name of the task
  67013. */
  67014. constructor(
  67015. /**
  67016. * Task name
  67017. */ name: string);
  67018. private _isCompleted;
  67019. private _taskState;
  67020. private _errorObject;
  67021. /**
  67022. * Get if the task is completed
  67023. */
  67024. get isCompleted(): boolean;
  67025. /**
  67026. * Gets the current state of the task
  67027. */
  67028. get taskState(): AssetTaskState;
  67029. /**
  67030. * Gets the current error object (if task is in error)
  67031. */
  67032. get errorObject(): {
  67033. message?: string;
  67034. exception?: any;
  67035. };
  67036. /**
  67037. * Internal only
  67038. * @hidden
  67039. */
  67040. _setErrorObject(message?: string, exception?: any): void;
  67041. /**
  67042. * Execute the current task
  67043. * @param scene defines the scene where you want your assets to be loaded
  67044. * @param onSuccess is a callback called when the task is successfully executed
  67045. * @param onError is a callback called if an error occurs
  67046. */
  67047. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67048. /**
  67049. * Execute the current task
  67050. * @param scene defines the scene where you want your assets to be loaded
  67051. * @param onSuccess is a callback called when the task is successfully executed
  67052. * @param onError is a callback called if an error occurs
  67053. */
  67054. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67055. /**
  67056. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67057. * This can be used with failed tasks that have the reason for failure fixed.
  67058. */
  67059. reset(): void;
  67060. private onErrorCallback;
  67061. private onDoneCallback;
  67062. }
  67063. /**
  67064. * Define the interface used by progress events raised during assets loading
  67065. */
  67066. export interface IAssetsProgressEvent {
  67067. /**
  67068. * Defines the number of remaining tasks to process
  67069. */
  67070. remainingCount: number;
  67071. /**
  67072. * Defines the total number of tasks
  67073. */
  67074. totalCount: number;
  67075. /**
  67076. * Defines the task that was just processed
  67077. */
  67078. task: AbstractAssetTask;
  67079. }
  67080. /**
  67081. * Class used to share progress information about assets loading
  67082. */
  67083. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67084. /**
  67085. * Defines the number of remaining tasks to process
  67086. */
  67087. remainingCount: number;
  67088. /**
  67089. * Defines the total number of tasks
  67090. */
  67091. totalCount: number;
  67092. /**
  67093. * Defines the task that was just processed
  67094. */
  67095. task: AbstractAssetTask;
  67096. /**
  67097. * Creates a AssetsProgressEvent
  67098. * @param remainingCount defines the number of remaining tasks to process
  67099. * @param totalCount defines the total number of tasks
  67100. * @param task defines the task that was just processed
  67101. */
  67102. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67103. }
  67104. /**
  67105. * Define a task used by AssetsManager to load meshes
  67106. */
  67107. export class MeshAssetTask extends AbstractAssetTask {
  67108. /**
  67109. * Defines the name of the task
  67110. */
  67111. name: string;
  67112. /**
  67113. * Defines the list of mesh's names you want to load
  67114. */
  67115. meshesNames: any;
  67116. /**
  67117. * Defines the root url to use as a base to load your meshes and associated resources
  67118. */
  67119. rootUrl: string;
  67120. /**
  67121. * Defines the filename of the scene to load from
  67122. */
  67123. sceneFilename: string;
  67124. /**
  67125. * Gets the list of loaded meshes
  67126. */
  67127. loadedMeshes: Array<AbstractMesh>;
  67128. /**
  67129. * Gets the list of loaded particle systems
  67130. */
  67131. loadedParticleSystems: Array<IParticleSystem>;
  67132. /**
  67133. * Gets the list of loaded skeletons
  67134. */
  67135. loadedSkeletons: Array<Skeleton>;
  67136. /**
  67137. * Gets the list of loaded animation groups
  67138. */
  67139. loadedAnimationGroups: Array<AnimationGroup>;
  67140. /**
  67141. * Callback called when the task is successful
  67142. */
  67143. onSuccess: (task: MeshAssetTask) => void;
  67144. /**
  67145. * Callback called when the task is successful
  67146. */
  67147. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67148. /**
  67149. * Creates a new MeshAssetTask
  67150. * @param name defines the name of the task
  67151. * @param meshesNames defines the list of mesh's names you want to load
  67152. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67153. * @param sceneFilename defines the filename of the scene to load from
  67154. */
  67155. constructor(
  67156. /**
  67157. * Defines the name of the task
  67158. */
  67159. name: string,
  67160. /**
  67161. * Defines the list of mesh's names you want to load
  67162. */
  67163. meshesNames: any,
  67164. /**
  67165. * Defines the root url to use as a base to load your meshes and associated resources
  67166. */
  67167. rootUrl: string,
  67168. /**
  67169. * Defines the filename of the scene to load from
  67170. */
  67171. sceneFilename: string);
  67172. /**
  67173. * Execute the current task
  67174. * @param scene defines the scene where you want your assets to be loaded
  67175. * @param onSuccess is a callback called when the task is successfully executed
  67176. * @param onError is a callback called if an error occurs
  67177. */
  67178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67179. }
  67180. /**
  67181. * Define a task used by AssetsManager to load text content
  67182. */
  67183. export class TextFileAssetTask extends AbstractAssetTask {
  67184. /**
  67185. * Defines the name of the task
  67186. */
  67187. name: string;
  67188. /**
  67189. * Defines the location of the file to load
  67190. */
  67191. url: string;
  67192. /**
  67193. * Gets the loaded text string
  67194. */
  67195. text: string;
  67196. /**
  67197. * Callback called when the task is successful
  67198. */
  67199. onSuccess: (task: TextFileAssetTask) => void;
  67200. /**
  67201. * Callback called when the task is successful
  67202. */
  67203. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67204. /**
  67205. * Creates a new TextFileAssetTask object
  67206. * @param name defines the name of the task
  67207. * @param url defines the location of the file to load
  67208. */
  67209. constructor(
  67210. /**
  67211. * Defines the name of the task
  67212. */
  67213. name: string,
  67214. /**
  67215. * Defines the location of the file to load
  67216. */
  67217. url: string);
  67218. /**
  67219. * Execute the current task
  67220. * @param scene defines the scene where you want your assets to be loaded
  67221. * @param onSuccess is a callback called when the task is successfully executed
  67222. * @param onError is a callback called if an error occurs
  67223. */
  67224. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67225. }
  67226. /**
  67227. * Define a task used by AssetsManager to load binary data
  67228. */
  67229. export class BinaryFileAssetTask extends AbstractAssetTask {
  67230. /**
  67231. * Defines the name of the task
  67232. */
  67233. name: string;
  67234. /**
  67235. * Defines the location of the file to load
  67236. */
  67237. url: string;
  67238. /**
  67239. * Gets the lodaded data (as an array buffer)
  67240. */
  67241. data: ArrayBuffer;
  67242. /**
  67243. * Callback called when the task is successful
  67244. */
  67245. onSuccess: (task: BinaryFileAssetTask) => void;
  67246. /**
  67247. * Callback called when the task is successful
  67248. */
  67249. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67250. /**
  67251. * Creates a new BinaryFileAssetTask object
  67252. * @param name defines the name of the new task
  67253. * @param url defines the location of the file to load
  67254. */
  67255. constructor(
  67256. /**
  67257. * Defines the name of the task
  67258. */
  67259. name: string,
  67260. /**
  67261. * Defines the location of the file to load
  67262. */
  67263. url: string);
  67264. /**
  67265. * Execute the current task
  67266. * @param scene defines the scene where you want your assets to be loaded
  67267. * @param onSuccess is a callback called when the task is successfully executed
  67268. * @param onError is a callback called if an error occurs
  67269. */
  67270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67271. }
  67272. /**
  67273. * Define a task used by AssetsManager to load images
  67274. */
  67275. export class ImageAssetTask extends AbstractAssetTask {
  67276. /**
  67277. * Defines the name of the task
  67278. */
  67279. name: string;
  67280. /**
  67281. * Defines the location of the image to load
  67282. */
  67283. url: string;
  67284. /**
  67285. * Gets the loaded images
  67286. */
  67287. image: HTMLImageElement;
  67288. /**
  67289. * Callback called when the task is successful
  67290. */
  67291. onSuccess: (task: ImageAssetTask) => void;
  67292. /**
  67293. * Callback called when the task is successful
  67294. */
  67295. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67296. /**
  67297. * Creates a new ImageAssetTask
  67298. * @param name defines the name of the task
  67299. * @param url defines the location of the image to load
  67300. */
  67301. constructor(
  67302. /**
  67303. * Defines the name of the task
  67304. */
  67305. name: string,
  67306. /**
  67307. * Defines the location of the image to load
  67308. */
  67309. url: string);
  67310. /**
  67311. * Execute the current task
  67312. * @param scene defines the scene where you want your assets to be loaded
  67313. * @param onSuccess is a callback called when the task is successfully executed
  67314. * @param onError is a callback called if an error occurs
  67315. */
  67316. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67317. }
  67318. /**
  67319. * Defines the interface used by texture loading tasks
  67320. */
  67321. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67322. /**
  67323. * Gets the loaded texture
  67324. */
  67325. texture: TEX;
  67326. }
  67327. /**
  67328. * Define a task used by AssetsManager to load 2D textures
  67329. */
  67330. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67331. /**
  67332. * Defines the name of the task
  67333. */
  67334. name: string;
  67335. /**
  67336. * Defines the location of the file to load
  67337. */
  67338. url: string;
  67339. /**
  67340. * Defines if mipmap should not be generated (default is false)
  67341. */
  67342. noMipmap?: boolean | undefined;
  67343. /**
  67344. * Defines if texture must be inverted on Y axis (default is false)
  67345. */
  67346. invertY?: boolean | undefined;
  67347. /**
  67348. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67349. */
  67350. samplingMode: number;
  67351. /**
  67352. * Gets the loaded texture
  67353. */
  67354. texture: Texture;
  67355. /**
  67356. * Callback called when the task is successful
  67357. */
  67358. onSuccess: (task: TextureAssetTask) => void;
  67359. /**
  67360. * Callback called when the task is successful
  67361. */
  67362. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67363. /**
  67364. * Creates a new TextureAssetTask object
  67365. * @param name defines the name of the task
  67366. * @param url defines the location of the file to load
  67367. * @param noMipmap defines if mipmap should not be generated (default is false)
  67368. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67369. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67370. */
  67371. constructor(
  67372. /**
  67373. * Defines the name of the task
  67374. */
  67375. name: string,
  67376. /**
  67377. * Defines the location of the file to load
  67378. */
  67379. url: string,
  67380. /**
  67381. * Defines if mipmap should not be generated (default is false)
  67382. */
  67383. noMipmap?: boolean | undefined,
  67384. /**
  67385. * Defines if texture must be inverted on Y axis (default is false)
  67386. */
  67387. invertY?: boolean | undefined,
  67388. /**
  67389. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67390. */
  67391. samplingMode?: number);
  67392. /**
  67393. * Execute the current task
  67394. * @param scene defines the scene where you want your assets to be loaded
  67395. * @param onSuccess is a callback called when the task is successfully executed
  67396. * @param onError is a callback called if an error occurs
  67397. */
  67398. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67399. }
  67400. /**
  67401. * Define a task used by AssetsManager to load cube textures
  67402. */
  67403. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67404. /**
  67405. * Defines the name of the task
  67406. */
  67407. name: string;
  67408. /**
  67409. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67410. */
  67411. url: string;
  67412. /**
  67413. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67414. */
  67415. extensions?: string[] | undefined;
  67416. /**
  67417. * Defines if mipmaps should not be generated (default is false)
  67418. */
  67419. noMipmap?: boolean | undefined;
  67420. /**
  67421. * Defines the explicit list of files (undefined by default)
  67422. */
  67423. files?: string[] | undefined;
  67424. /**
  67425. * Gets the loaded texture
  67426. */
  67427. texture: CubeTexture;
  67428. /**
  67429. * Callback called when the task is successful
  67430. */
  67431. onSuccess: (task: CubeTextureAssetTask) => void;
  67432. /**
  67433. * Callback called when the task is successful
  67434. */
  67435. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67436. /**
  67437. * Creates a new CubeTextureAssetTask
  67438. * @param name defines the name of the task
  67439. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67440. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67441. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67442. * @param files defines the explicit list of files (undefined by default)
  67443. */
  67444. constructor(
  67445. /**
  67446. * Defines the name of the task
  67447. */
  67448. name: string,
  67449. /**
  67450. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67451. */
  67452. url: string,
  67453. /**
  67454. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67455. */
  67456. extensions?: string[] | undefined,
  67457. /**
  67458. * Defines if mipmaps should not be generated (default is false)
  67459. */
  67460. noMipmap?: boolean | undefined,
  67461. /**
  67462. * Defines the explicit list of files (undefined by default)
  67463. */
  67464. files?: string[] | undefined);
  67465. /**
  67466. * Execute the current task
  67467. * @param scene defines the scene where you want your assets to be loaded
  67468. * @param onSuccess is a callback called when the task is successfully executed
  67469. * @param onError is a callback called if an error occurs
  67470. */
  67471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67472. }
  67473. /**
  67474. * Define a task used by AssetsManager to load HDR cube textures
  67475. */
  67476. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67477. /**
  67478. * Defines the name of the task
  67479. */
  67480. name: string;
  67481. /**
  67482. * Defines the location of the file to load
  67483. */
  67484. url: string;
  67485. /**
  67486. * Defines the desired size (the more it increases the longer the generation will be)
  67487. */
  67488. size: number;
  67489. /**
  67490. * Defines if mipmaps should not be generated (default is false)
  67491. */
  67492. noMipmap: boolean;
  67493. /**
  67494. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67495. */
  67496. generateHarmonics: boolean;
  67497. /**
  67498. * 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)
  67499. */
  67500. gammaSpace: boolean;
  67501. /**
  67502. * Internal Use Only
  67503. */
  67504. reserved: boolean;
  67505. /**
  67506. * Gets the loaded texture
  67507. */
  67508. texture: HDRCubeTexture;
  67509. /**
  67510. * Callback called when the task is successful
  67511. */
  67512. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67513. /**
  67514. * Callback called when the task is successful
  67515. */
  67516. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67517. /**
  67518. * Creates a new HDRCubeTextureAssetTask object
  67519. * @param name defines the name of the task
  67520. * @param url defines the location of the file to load
  67521. * @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.
  67522. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67523. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67524. * @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)
  67525. * @param reserved Internal use only
  67526. */
  67527. constructor(
  67528. /**
  67529. * Defines the name of the task
  67530. */
  67531. name: string,
  67532. /**
  67533. * Defines the location of the file to load
  67534. */
  67535. url: string,
  67536. /**
  67537. * Defines the desired size (the more it increases the longer the generation will be)
  67538. */
  67539. size: number,
  67540. /**
  67541. * Defines if mipmaps should not be generated (default is false)
  67542. */
  67543. noMipmap?: boolean,
  67544. /**
  67545. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67546. */
  67547. generateHarmonics?: boolean,
  67548. /**
  67549. * 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)
  67550. */
  67551. gammaSpace?: boolean,
  67552. /**
  67553. * Internal Use Only
  67554. */
  67555. reserved?: boolean);
  67556. /**
  67557. * Execute the current task
  67558. * @param scene defines the scene where you want your assets to be loaded
  67559. * @param onSuccess is a callback called when the task is successfully executed
  67560. * @param onError is a callback called if an error occurs
  67561. */
  67562. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67563. }
  67564. /**
  67565. * Define a task used by AssetsManager to load Equirectangular cube textures
  67566. */
  67567. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67568. /**
  67569. * Defines the name of the task
  67570. */
  67571. name: string;
  67572. /**
  67573. * Defines the location of the file to load
  67574. */
  67575. url: string;
  67576. /**
  67577. * Defines the desired size (the more it increases the longer the generation will be)
  67578. */
  67579. size: number;
  67580. /**
  67581. * Defines if mipmaps should not be generated (default is false)
  67582. */
  67583. noMipmap: boolean;
  67584. /**
  67585. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67586. * but the standard material would require them in Gamma space) (default is true)
  67587. */
  67588. gammaSpace: boolean;
  67589. /**
  67590. * Gets the loaded texture
  67591. */
  67592. texture: EquiRectangularCubeTexture;
  67593. /**
  67594. * Callback called when the task is successful
  67595. */
  67596. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67597. /**
  67598. * Callback called when the task is successful
  67599. */
  67600. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67601. /**
  67602. * Creates a new EquiRectangularCubeTextureAssetTask object
  67603. * @param name defines the name of the task
  67604. * @param url defines the location of the file to load
  67605. * @param size defines the desired size (the more it increases the longer the generation will be)
  67606. * If the size is omitted this implies you are using a preprocessed cubemap.
  67607. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67608. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67609. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67610. * (default is true)
  67611. */
  67612. constructor(
  67613. /**
  67614. * Defines the name of the task
  67615. */
  67616. name: string,
  67617. /**
  67618. * Defines the location of the file to load
  67619. */
  67620. url: string,
  67621. /**
  67622. * Defines the desired size (the more it increases the longer the generation will be)
  67623. */
  67624. size: number,
  67625. /**
  67626. * Defines if mipmaps should not be generated (default is false)
  67627. */
  67628. noMipmap?: boolean,
  67629. /**
  67630. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67631. * but the standard material would require them in Gamma space) (default is true)
  67632. */
  67633. gammaSpace?: boolean);
  67634. /**
  67635. * Execute the current task
  67636. * @param scene defines the scene where you want your assets to be loaded
  67637. * @param onSuccess is a callback called when the task is successfully executed
  67638. * @param onError is a callback called if an error occurs
  67639. */
  67640. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67641. }
  67642. /**
  67643. * This class can be used to easily import assets into a scene
  67644. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67645. */
  67646. export class AssetsManager {
  67647. private _scene;
  67648. private _isLoading;
  67649. protected _tasks: AbstractAssetTask[];
  67650. protected _waitingTasksCount: number;
  67651. protected _totalTasksCount: number;
  67652. /**
  67653. * Callback called when all tasks are processed
  67654. */
  67655. onFinish: (tasks: AbstractAssetTask[]) => void;
  67656. /**
  67657. * Callback called when a task is successful
  67658. */
  67659. onTaskSuccess: (task: AbstractAssetTask) => void;
  67660. /**
  67661. * Callback called when a task had an error
  67662. */
  67663. onTaskError: (task: AbstractAssetTask) => void;
  67664. /**
  67665. * Callback called when a task is done (whatever the result is)
  67666. */
  67667. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67668. /**
  67669. * Observable called when all tasks are processed
  67670. */
  67671. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67672. /**
  67673. * Observable called when a task had an error
  67674. */
  67675. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67676. /**
  67677. * Observable called when all tasks were executed
  67678. */
  67679. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67680. /**
  67681. * Observable called when a task is done (whatever the result is)
  67682. */
  67683. onProgressObservable: Observable<IAssetsProgressEvent>;
  67684. /**
  67685. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67686. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67687. */
  67688. useDefaultLoadingScreen: boolean;
  67689. /**
  67690. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67691. * when all assets have been downloaded.
  67692. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67693. */
  67694. autoHideLoadingUI: boolean;
  67695. /**
  67696. * Creates a new AssetsManager
  67697. * @param scene defines the scene to work on
  67698. */
  67699. constructor(scene: Scene);
  67700. /**
  67701. * Add a MeshAssetTask to the list of active tasks
  67702. * @param taskName defines the name of the new task
  67703. * @param meshesNames defines the name of meshes to load
  67704. * @param rootUrl defines the root url to use to locate files
  67705. * @param sceneFilename defines the filename of the scene file
  67706. * @returns a new MeshAssetTask object
  67707. */
  67708. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67709. /**
  67710. * Add a TextFileAssetTask to the list of active tasks
  67711. * @param taskName defines the name of the new task
  67712. * @param url defines the url of the file to load
  67713. * @returns a new TextFileAssetTask object
  67714. */
  67715. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67716. /**
  67717. * Add a BinaryFileAssetTask to the list of active tasks
  67718. * @param taskName defines the name of the new task
  67719. * @param url defines the url of the file to load
  67720. * @returns a new BinaryFileAssetTask object
  67721. */
  67722. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67723. /**
  67724. * Add a ImageAssetTask to the list of active tasks
  67725. * @param taskName defines the name of the new task
  67726. * @param url defines the url of the file to load
  67727. * @returns a new ImageAssetTask object
  67728. */
  67729. addImageTask(taskName: string, url: string): ImageAssetTask;
  67730. /**
  67731. * Add a TextureAssetTask to the list of active tasks
  67732. * @param taskName defines the name of the new task
  67733. * @param url defines the url of the file to load
  67734. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67735. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67736. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67737. * @returns a new TextureAssetTask object
  67738. */
  67739. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67740. /**
  67741. * Add a CubeTextureAssetTask to the list of active tasks
  67742. * @param taskName defines the name of the new task
  67743. * @param url defines the url of the file to load
  67744. * @param extensions defines the extension to use to load the cube map (can be null)
  67745. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67746. * @param files defines the list of files to load (can be null)
  67747. * @returns a new CubeTextureAssetTask object
  67748. */
  67749. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67750. /**
  67751. *
  67752. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67753. * @param taskName defines the name of the new task
  67754. * @param url defines the url of the file to load
  67755. * @param size defines the size you want for the cubemap (can be null)
  67756. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67757. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67758. * @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)
  67759. * @param reserved Internal use only
  67760. * @returns a new HDRCubeTextureAssetTask object
  67761. */
  67762. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67763. /**
  67764. *
  67765. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67766. * @param taskName defines the name of the new task
  67767. * @param url defines the url of the file to load
  67768. * @param size defines the size you want for the cubemap (can be null)
  67769. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67770. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67771. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67772. * @returns a new EquiRectangularCubeTextureAssetTask object
  67773. */
  67774. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67775. /**
  67776. * Remove a task from the assets manager.
  67777. * @param task the task to remove
  67778. */
  67779. removeTask(task: AbstractAssetTask): void;
  67780. private _decreaseWaitingTasksCount;
  67781. private _runTask;
  67782. /**
  67783. * Reset the AssetsManager and remove all tasks
  67784. * @return the current instance of the AssetsManager
  67785. */
  67786. reset(): AssetsManager;
  67787. /**
  67788. * Start the loading process
  67789. * @return the current instance of the AssetsManager
  67790. */
  67791. load(): AssetsManager;
  67792. /**
  67793. * Start the loading process as an async operation
  67794. * @return a promise returning the list of failed tasks
  67795. */
  67796. loadAsync(): Promise<void>;
  67797. }
  67798. }
  67799. declare module BABYLON {
  67800. /**
  67801. * Wrapper class for promise with external resolve and reject.
  67802. */
  67803. export class Deferred<T> {
  67804. /**
  67805. * The promise associated with this deferred object.
  67806. */
  67807. readonly promise: Promise<T>;
  67808. private _resolve;
  67809. private _reject;
  67810. /**
  67811. * The resolve method of the promise associated with this deferred object.
  67812. */
  67813. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67814. /**
  67815. * The reject method of the promise associated with this deferred object.
  67816. */
  67817. get reject(): (reason?: any) => void;
  67818. /**
  67819. * Constructor for this deferred object.
  67820. */
  67821. constructor();
  67822. }
  67823. }
  67824. declare module BABYLON {
  67825. /**
  67826. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67827. */
  67828. export class MeshExploder {
  67829. private _centerMesh;
  67830. private _meshes;
  67831. private _meshesOrigins;
  67832. private _toCenterVectors;
  67833. private _scaledDirection;
  67834. private _newPosition;
  67835. private _centerPosition;
  67836. /**
  67837. * Explodes meshes from a center mesh.
  67838. * @param meshes The meshes to explode.
  67839. * @param centerMesh The mesh to be center of explosion.
  67840. */
  67841. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67842. private _setCenterMesh;
  67843. /**
  67844. * Get class name
  67845. * @returns "MeshExploder"
  67846. */
  67847. getClassName(): string;
  67848. /**
  67849. * "Exploded meshes"
  67850. * @returns Array of meshes with the centerMesh at index 0.
  67851. */
  67852. getMeshes(): Array<Mesh>;
  67853. /**
  67854. * Explodes meshes giving a specific direction
  67855. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67856. */
  67857. explode(direction?: number): void;
  67858. }
  67859. }
  67860. declare module BABYLON {
  67861. /**
  67862. * Class used to help managing file picking and drag'n'drop
  67863. */
  67864. export class FilesInput {
  67865. /**
  67866. * List of files ready to be loaded
  67867. */
  67868. static get FilesToLoad(): {
  67869. [key: string]: File;
  67870. };
  67871. /**
  67872. * Callback called when a file is processed
  67873. */
  67874. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67875. private _engine;
  67876. private _currentScene;
  67877. private _sceneLoadedCallback;
  67878. private _progressCallback;
  67879. private _additionalRenderLoopLogicCallback;
  67880. private _textureLoadingCallback;
  67881. private _startingProcessingFilesCallback;
  67882. private _onReloadCallback;
  67883. private _errorCallback;
  67884. private _elementToMonitor;
  67885. private _sceneFileToLoad;
  67886. private _filesToLoad;
  67887. /**
  67888. * Creates a new FilesInput
  67889. * @param engine defines the rendering engine
  67890. * @param scene defines the hosting scene
  67891. * @param sceneLoadedCallback callback called when scene is loaded
  67892. * @param progressCallback callback called to track progress
  67893. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67894. * @param textureLoadingCallback callback called when a texture is loading
  67895. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67896. * @param onReloadCallback callback called when a reload is requested
  67897. * @param errorCallback callback call if an error occurs
  67898. */
  67899. 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);
  67900. private _dragEnterHandler;
  67901. private _dragOverHandler;
  67902. private _dropHandler;
  67903. /**
  67904. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67905. * @param elementToMonitor defines the DOM element to track
  67906. */
  67907. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67908. /**
  67909. * Release all associated resources
  67910. */
  67911. dispose(): void;
  67912. private renderFunction;
  67913. private drag;
  67914. private drop;
  67915. private _traverseFolder;
  67916. private _processFiles;
  67917. /**
  67918. * Load files from a drop event
  67919. * @param event defines the drop event to use as source
  67920. */
  67921. loadFiles(event: any): void;
  67922. private _processReload;
  67923. /**
  67924. * Reload the current scene from the loaded files
  67925. */
  67926. reload(): void;
  67927. }
  67928. }
  67929. declare module BABYLON {
  67930. /**
  67931. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67933. */
  67934. export class SceneOptimization {
  67935. /**
  67936. * Defines the priority of this optimization (0 by default which means first in the list)
  67937. */
  67938. priority: number;
  67939. /**
  67940. * Gets a string describing the action executed by the current optimization
  67941. * @returns description string
  67942. */
  67943. getDescription(): string;
  67944. /**
  67945. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67946. * @param scene defines the current scene where to apply this optimization
  67947. * @param optimizer defines the current optimizer
  67948. * @returns true if everything that can be done was applied
  67949. */
  67950. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67951. /**
  67952. * Creates the SceneOptimization object
  67953. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67954. * @param desc defines the description associated with the optimization
  67955. */
  67956. constructor(
  67957. /**
  67958. * Defines the priority of this optimization (0 by default which means first in the list)
  67959. */
  67960. priority?: number);
  67961. }
  67962. /**
  67963. * Defines an optimization used to reduce the size of render target textures
  67964. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67965. */
  67966. export class TextureOptimization extends SceneOptimization {
  67967. /**
  67968. * Defines the priority of this optimization (0 by default which means first in the list)
  67969. */
  67970. priority: number;
  67971. /**
  67972. * 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
  67973. */
  67974. maximumSize: number;
  67975. /**
  67976. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67977. */
  67978. step: number;
  67979. /**
  67980. * Gets a string describing the action executed by the current optimization
  67981. * @returns description string
  67982. */
  67983. getDescription(): string;
  67984. /**
  67985. * Creates the TextureOptimization object
  67986. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67987. * @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
  67988. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67989. */
  67990. constructor(
  67991. /**
  67992. * Defines the priority of this optimization (0 by default which means first in the list)
  67993. */
  67994. priority?: number,
  67995. /**
  67996. * 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
  67997. */
  67998. maximumSize?: number,
  67999. /**
  68000. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68001. */
  68002. step?: number);
  68003. /**
  68004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68005. * @param scene defines the current scene where to apply this optimization
  68006. * @param optimizer defines the current optimizer
  68007. * @returns true if everything that can be done was applied
  68008. */
  68009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68010. }
  68011. /**
  68012. * Defines an optimization used to increase or decrease the rendering resolution
  68013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68014. */
  68015. export class HardwareScalingOptimization extends SceneOptimization {
  68016. /**
  68017. * Defines the priority of this optimization (0 by default which means first in the list)
  68018. */
  68019. priority: number;
  68020. /**
  68021. * Defines the maximum scale to use (2 by default)
  68022. */
  68023. maximumScale: number;
  68024. /**
  68025. * Defines the step to use between two passes (0.5 by default)
  68026. */
  68027. step: number;
  68028. private _currentScale;
  68029. private _directionOffset;
  68030. /**
  68031. * Gets a string describing the action executed by the current optimization
  68032. * @return description string
  68033. */
  68034. getDescription(): string;
  68035. /**
  68036. * Creates the HardwareScalingOptimization object
  68037. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68038. * @param maximumScale defines the maximum scale to use (2 by default)
  68039. * @param step defines the step to use between two passes (0.5 by default)
  68040. */
  68041. constructor(
  68042. /**
  68043. * Defines the priority of this optimization (0 by default which means first in the list)
  68044. */
  68045. priority?: number,
  68046. /**
  68047. * Defines the maximum scale to use (2 by default)
  68048. */
  68049. maximumScale?: number,
  68050. /**
  68051. * Defines the step to use between two passes (0.5 by default)
  68052. */
  68053. step?: number);
  68054. /**
  68055. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68056. * @param scene defines the current scene where to apply this optimization
  68057. * @param optimizer defines the current optimizer
  68058. * @returns true if everything that can be done was applied
  68059. */
  68060. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68061. }
  68062. /**
  68063. * Defines an optimization used to remove shadows
  68064. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68065. */
  68066. export class ShadowsOptimization extends SceneOptimization {
  68067. /**
  68068. * Gets a string describing the action executed by the current optimization
  68069. * @return description string
  68070. */
  68071. getDescription(): string;
  68072. /**
  68073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68074. * @param scene defines the current scene where to apply this optimization
  68075. * @param optimizer defines the current optimizer
  68076. * @returns true if everything that can be done was applied
  68077. */
  68078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68079. }
  68080. /**
  68081. * Defines an optimization used to turn post-processes off
  68082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68083. */
  68084. export class PostProcessesOptimization extends SceneOptimization {
  68085. /**
  68086. * Gets a string describing the action executed by the current optimization
  68087. * @return description string
  68088. */
  68089. getDescription(): string;
  68090. /**
  68091. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68092. * @param scene defines the current scene where to apply this optimization
  68093. * @param optimizer defines the current optimizer
  68094. * @returns true if everything that can be done was applied
  68095. */
  68096. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68097. }
  68098. /**
  68099. * Defines an optimization used to turn lens flares off
  68100. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68101. */
  68102. export class LensFlaresOptimization extends SceneOptimization {
  68103. /**
  68104. * Gets a string describing the action executed by the current optimization
  68105. * @return description string
  68106. */
  68107. getDescription(): string;
  68108. /**
  68109. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68110. * @param scene defines the current scene where to apply this optimization
  68111. * @param optimizer defines the current optimizer
  68112. * @returns true if everything that can be done was applied
  68113. */
  68114. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68115. }
  68116. /**
  68117. * Defines an optimization based on user defined callback.
  68118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68119. */
  68120. export class CustomOptimization extends SceneOptimization {
  68121. /**
  68122. * Callback called to apply the custom optimization.
  68123. */
  68124. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68125. /**
  68126. * Callback called to get custom description
  68127. */
  68128. onGetDescription: () => string;
  68129. /**
  68130. * Gets a string describing the action executed by the current optimization
  68131. * @returns description string
  68132. */
  68133. getDescription(): string;
  68134. /**
  68135. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68136. * @param scene defines the current scene where to apply this optimization
  68137. * @param optimizer defines the current optimizer
  68138. * @returns true if everything that can be done was applied
  68139. */
  68140. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68141. }
  68142. /**
  68143. * Defines an optimization used to turn particles off
  68144. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68145. */
  68146. export class ParticlesOptimization extends SceneOptimization {
  68147. /**
  68148. * Gets a string describing the action executed by the current optimization
  68149. * @return description string
  68150. */
  68151. getDescription(): string;
  68152. /**
  68153. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68154. * @param scene defines the current scene where to apply this optimization
  68155. * @param optimizer defines the current optimizer
  68156. * @returns true if everything that can be done was applied
  68157. */
  68158. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68159. }
  68160. /**
  68161. * Defines an optimization used to turn render targets off
  68162. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68163. */
  68164. export class RenderTargetsOptimization extends SceneOptimization {
  68165. /**
  68166. * Gets a string describing the action executed by the current optimization
  68167. * @return description string
  68168. */
  68169. getDescription(): string;
  68170. /**
  68171. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68172. * @param scene defines the current scene where to apply this optimization
  68173. * @param optimizer defines the current optimizer
  68174. * @returns true if everything that can be done was applied
  68175. */
  68176. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68177. }
  68178. /**
  68179. * Defines an optimization used to merge meshes with compatible materials
  68180. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68181. */
  68182. export class MergeMeshesOptimization extends SceneOptimization {
  68183. private static _UpdateSelectionTree;
  68184. /**
  68185. * Gets or sets a boolean which defines if optimization octree has to be updated
  68186. */
  68187. static get UpdateSelectionTree(): boolean;
  68188. /**
  68189. * Gets or sets a boolean which defines if optimization octree has to be updated
  68190. */
  68191. static set UpdateSelectionTree(value: boolean);
  68192. /**
  68193. * Gets a string describing the action executed by the current optimization
  68194. * @return description string
  68195. */
  68196. getDescription(): string;
  68197. private _canBeMerged;
  68198. /**
  68199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68200. * @param scene defines the current scene where to apply this optimization
  68201. * @param optimizer defines the current optimizer
  68202. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68203. * @returns true if everything that can be done was applied
  68204. */
  68205. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68206. }
  68207. /**
  68208. * Defines a list of options used by SceneOptimizer
  68209. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68210. */
  68211. export class SceneOptimizerOptions {
  68212. /**
  68213. * Defines the target frame rate to reach (60 by default)
  68214. */
  68215. targetFrameRate: number;
  68216. /**
  68217. * Defines the interval between two checkes (2000ms by default)
  68218. */
  68219. trackerDuration: number;
  68220. /**
  68221. * Gets the list of optimizations to apply
  68222. */
  68223. optimizations: SceneOptimization[];
  68224. /**
  68225. * Creates a new list of options used by SceneOptimizer
  68226. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68227. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68228. */
  68229. constructor(
  68230. /**
  68231. * Defines the target frame rate to reach (60 by default)
  68232. */
  68233. targetFrameRate?: number,
  68234. /**
  68235. * Defines the interval between two checkes (2000ms by default)
  68236. */
  68237. trackerDuration?: number);
  68238. /**
  68239. * Add a new optimization
  68240. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68241. * @returns the current SceneOptimizerOptions
  68242. */
  68243. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68244. /**
  68245. * Add a new custom optimization
  68246. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68247. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68248. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68249. * @returns the current SceneOptimizerOptions
  68250. */
  68251. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68252. /**
  68253. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68254. * @param targetFrameRate defines the target frame rate (60 by default)
  68255. * @returns a SceneOptimizerOptions object
  68256. */
  68257. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68258. /**
  68259. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68260. * @param targetFrameRate defines the target frame rate (60 by default)
  68261. * @returns a SceneOptimizerOptions object
  68262. */
  68263. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68264. /**
  68265. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68266. * @param targetFrameRate defines the target frame rate (60 by default)
  68267. * @returns a SceneOptimizerOptions object
  68268. */
  68269. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68270. }
  68271. /**
  68272. * Class used to run optimizations in order to reach a target frame rate
  68273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68274. */
  68275. export class SceneOptimizer implements IDisposable {
  68276. private _isRunning;
  68277. private _options;
  68278. private _scene;
  68279. private _currentPriorityLevel;
  68280. private _targetFrameRate;
  68281. private _trackerDuration;
  68282. private _currentFrameRate;
  68283. private _sceneDisposeObserver;
  68284. private _improvementMode;
  68285. /**
  68286. * Defines an observable called when the optimizer reaches the target frame rate
  68287. */
  68288. onSuccessObservable: Observable<SceneOptimizer>;
  68289. /**
  68290. * Defines an observable called when the optimizer enables an optimization
  68291. */
  68292. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68293. /**
  68294. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68295. */
  68296. onFailureObservable: Observable<SceneOptimizer>;
  68297. /**
  68298. * Gets a boolean indicating if the optimizer is in improvement mode
  68299. */
  68300. get isInImprovementMode(): boolean;
  68301. /**
  68302. * Gets the current priority level (0 at start)
  68303. */
  68304. get currentPriorityLevel(): number;
  68305. /**
  68306. * Gets the current frame rate checked by the SceneOptimizer
  68307. */
  68308. get currentFrameRate(): number;
  68309. /**
  68310. * Gets or sets the current target frame rate (60 by default)
  68311. */
  68312. get targetFrameRate(): number;
  68313. /**
  68314. * Gets or sets the current target frame rate (60 by default)
  68315. */
  68316. set targetFrameRate(value: number);
  68317. /**
  68318. * Gets or sets the current interval between two checks (every 2000ms by default)
  68319. */
  68320. get trackerDuration(): number;
  68321. /**
  68322. * Gets or sets the current interval between two checks (every 2000ms by default)
  68323. */
  68324. set trackerDuration(value: number);
  68325. /**
  68326. * Gets the list of active optimizations
  68327. */
  68328. get optimizations(): SceneOptimization[];
  68329. /**
  68330. * Creates a new SceneOptimizer
  68331. * @param scene defines the scene to work on
  68332. * @param options defines the options to use with the SceneOptimizer
  68333. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68334. * @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)
  68335. */
  68336. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68337. /**
  68338. * Stops the current optimizer
  68339. */
  68340. stop(): void;
  68341. /**
  68342. * Reset the optimizer to initial step (current priority level = 0)
  68343. */
  68344. reset(): void;
  68345. /**
  68346. * Start the optimizer. By default it will try to reach a specific framerate
  68347. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68348. */
  68349. start(): void;
  68350. private _checkCurrentState;
  68351. /**
  68352. * Release all resources
  68353. */
  68354. dispose(): void;
  68355. /**
  68356. * Helper function to create a SceneOptimizer with one single line of code
  68357. * @param scene defines the scene to work on
  68358. * @param options defines the options to use with the SceneOptimizer
  68359. * @param onSuccess defines a callback to call on success
  68360. * @param onFailure defines a callback to call on failure
  68361. * @returns the new SceneOptimizer object
  68362. */
  68363. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68364. }
  68365. }
  68366. declare module BABYLON {
  68367. /**
  68368. * Class used to serialize a scene into a string
  68369. */
  68370. export class SceneSerializer {
  68371. /**
  68372. * Clear cache used by a previous serialization
  68373. */
  68374. static ClearCache(): void;
  68375. /**
  68376. * Serialize a scene into a JSON compatible object
  68377. * @param scene defines the scene to serialize
  68378. * @returns a JSON compatible object
  68379. */
  68380. static Serialize(scene: Scene): any;
  68381. /**
  68382. * Serialize a mesh into a JSON compatible object
  68383. * @param toSerialize defines the mesh to serialize
  68384. * @param withParents defines if parents must be serialized as well
  68385. * @param withChildren defines if children must be serialized as well
  68386. * @returns a JSON compatible object
  68387. */
  68388. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68389. }
  68390. }
  68391. declare module BABYLON {
  68392. /**
  68393. * Class used to host texture specific utilities
  68394. */
  68395. export class TextureTools {
  68396. /**
  68397. * Uses the GPU to create a copy texture rescaled at a given size
  68398. * @param texture Texture to copy from
  68399. * @param width defines the desired width
  68400. * @param height defines the desired height
  68401. * @param useBilinearMode defines if bilinear mode has to be used
  68402. * @return the generated texture
  68403. */
  68404. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68405. }
  68406. }
  68407. declare module BABYLON {
  68408. /**
  68409. * This represents the different options available for the video capture.
  68410. */
  68411. export interface VideoRecorderOptions {
  68412. /** Defines the mime type of the video. */
  68413. mimeType: string;
  68414. /** Defines the FPS the video should be recorded at. */
  68415. fps: number;
  68416. /** Defines the chunk size for the recording data. */
  68417. recordChunckSize: number;
  68418. /** The audio tracks to attach to the recording. */
  68419. audioTracks?: MediaStreamTrack[];
  68420. }
  68421. /**
  68422. * This can help with recording videos from BabylonJS.
  68423. * This is based on the available WebRTC functionalities of the browser.
  68424. *
  68425. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68426. */
  68427. export class VideoRecorder {
  68428. private static readonly _defaultOptions;
  68429. /**
  68430. * Returns whether or not the VideoRecorder is available in your browser.
  68431. * @param engine Defines the Babylon Engine.
  68432. * @returns true if supported otherwise false.
  68433. */
  68434. static IsSupported(engine: Engine): boolean;
  68435. private readonly _options;
  68436. private _canvas;
  68437. private _mediaRecorder;
  68438. private _recordedChunks;
  68439. private _fileName;
  68440. private _resolve;
  68441. private _reject;
  68442. /**
  68443. * True when a recording is already in progress.
  68444. */
  68445. get isRecording(): boolean;
  68446. /**
  68447. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68448. * @param engine Defines the BabylonJS Engine you wish to record.
  68449. * @param options Defines options that can be used to customize the capture.
  68450. */
  68451. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68452. /**
  68453. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68454. */
  68455. stopRecording(): void;
  68456. /**
  68457. * Starts recording the canvas for a max duration specified in parameters.
  68458. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68459. * If null no automatic download will start and you can rely on the promise to get the data back.
  68460. * @param maxDuration Defines the maximum recording time in seconds.
  68461. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68462. * @return A promise callback at the end of the recording with the video data in Blob.
  68463. */
  68464. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68465. /**
  68466. * Releases internal resources used during the recording.
  68467. */
  68468. dispose(): void;
  68469. private _handleDataAvailable;
  68470. private _handleError;
  68471. private _handleStop;
  68472. }
  68473. }
  68474. declare module BABYLON {
  68475. /**
  68476. * Class containing a set of static utilities functions for screenshots
  68477. */
  68478. export class ScreenshotTools {
  68479. /**
  68480. * Captures a screenshot of the current rendering
  68481. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68482. * @param engine defines the rendering engine
  68483. * @param camera defines the source camera
  68484. * @param size This parameter can be set to a single number or to an object with the
  68485. * following (optional) properties: precision, width, height. If a single number is passed,
  68486. * it will be used for both width and height. If an object is passed, the screenshot size
  68487. * will be derived from the parameters. The precision property is a multiplier allowing
  68488. * rendering at a higher or lower resolution
  68489. * @param successCallback defines the callback receives a single parameter which contains the
  68490. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68491. * src parameter of an <img> to display it
  68492. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68493. * Check your browser for supported MIME types
  68494. */
  68495. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68496. /**
  68497. * Captures a screenshot of the current rendering
  68498. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68499. * @param engine defines the rendering engine
  68500. * @param camera defines the source camera
  68501. * @param size This parameter can be set to a single number or to an object with the
  68502. * following (optional) properties: precision, width, height. If a single number is passed,
  68503. * it will be used for both width and height. If an object is passed, the screenshot size
  68504. * will be derived from the parameters. The precision property is a multiplier allowing
  68505. * rendering at a higher or lower resolution
  68506. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68507. * Check your browser for supported MIME types
  68508. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68509. * to the src parameter of an <img> to display it
  68510. */
  68511. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68512. /**
  68513. * Generates an image screenshot from the specified camera.
  68514. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68515. * @param engine The engine to use for rendering
  68516. * @param camera The camera to use for rendering
  68517. * @param size This parameter can be set to a single number or to an object with the
  68518. * following (optional) properties: precision, width, height. If a single number is passed,
  68519. * it will be used for both width and height. If an object is passed, the screenshot size
  68520. * will be derived from the parameters. The precision property is a multiplier allowing
  68521. * rendering at a higher or lower resolution
  68522. * @param successCallback The callback receives a single parameter which contains the
  68523. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68524. * src parameter of an <img> to display it
  68525. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68526. * Check your browser for supported MIME types
  68527. * @param samples Texture samples (default: 1)
  68528. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68529. * @param fileName A name for for the downloaded file.
  68530. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68531. */
  68532. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68533. /**
  68534. * Generates an image screenshot from the specified camera.
  68535. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68536. * @param engine The engine to use for rendering
  68537. * @param camera The camera to use for rendering
  68538. * @param size This parameter can be set to a single number or to an object with the
  68539. * following (optional) properties: precision, width, height. If a single number is passed,
  68540. * it will be used for both width and height. If an object is passed, the screenshot size
  68541. * will be derived from the parameters. The precision property is a multiplier allowing
  68542. * rendering at a higher or lower resolution
  68543. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68544. * Check your browser for supported MIME types
  68545. * @param samples Texture samples (default: 1)
  68546. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68547. * @param fileName A name for for the downloaded file.
  68548. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68549. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68550. * to the src parameter of an <img> to display it
  68551. */
  68552. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  68553. /**
  68554. * Gets height and width for screenshot size
  68555. * @private
  68556. */
  68557. private static _getScreenshotSize;
  68558. }
  68559. }
  68560. declare module BABYLON {
  68561. /**
  68562. * Interface for a data buffer
  68563. */
  68564. export interface IDataBuffer {
  68565. /**
  68566. * Reads bytes from the data buffer.
  68567. * @param byteOffset The byte offset to read
  68568. * @param byteLength The byte length to read
  68569. * @returns A promise that resolves when the bytes are read
  68570. */
  68571. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68572. /**
  68573. * The byte length of the buffer.
  68574. */
  68575. readonly byteLength: number;
  68576. }
  68577. /**
  68578. * Utility class for reading from a data buffer
  68579. */
  68580. export class DataReader {
  68581. /**
  68582. * The data buffer associated with this data reader.
  68583. */
  68584. readonly buffer: IDataBuffer;
  68585. /**
  68586. * The current byte offset from the beginning of the data buffer.
  68587. */
  68588. byteOffset: number;
  68589. private _dataView;
  68590. private _dataByteOffset;
  68591. /**
  68592. * Constructor
  68593. * @param buffer The buffer to read
  68594. */
  68595. constructor(buffer: IDataBuffer);
  68596. /**
  68597. * Loads the given byte length.
  68598. * @param byteLength The byte length to load
  68599. * @returns A promise that resolves when the load is complete
  68600. */
  68601. loadAsync(byteLength: number): Promise<void>;
  68602. /**
  68603. * Read a unsigned 32-bit integer from the currently loaded data range.
  68604. * @returns The 32-bit integer read
  68605. */
  68606. readUint32(): number;
  68607. /**
  68608. * Read a byte array from the currently loaded data range.
  68609. * @param byteLength The byte length to read
  68610. * @returns The byte array read
  68611. */
  68612. readUint8Array(byteLength: number): Uint8Array;
  68613. /**
  68614. * Read a string from the currently loaded data range.
  68615. * @param byteLength The byte length to read
  68616. * @returns The string read
  68617. */
  68618. readString(byteLength: number): string;
  68619. /**
  68620. * Skips the given byte length the currently loaded data range.
  68621. * @param byteLength The byte length to skip
  68622. */
  68623. skipBytes(byteLength: number): void;
  68624. }
  68625. }
  68626. declare module BABYLON {
  68627. /**
  68628. * Options used for hit testing
  68629. */
  68630. export interface IWebXRHitTestOptions {
  68631. /**
  68632. * Only test when user interacted with the scene. Default - hit test every frame
  68633. */
  68634. testOnPointerDownOnly?: boolean;
  68635. /**
  68636. * The node to use to transform the local results to world coordinates
  68637. */
  68638. worldParentNode?: TransformNode;
  68639. }
  68640. /**
  68641. * Interface defining the babylon result of raycasting/hit-test
  68642. */
  68643. export interface IWebXRHitResult {
  68644. /**
  68645. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68646. */
  68647. transformationMatrix: Matrix;
  68648. /**
  68649. * The native hit test result
  68650. */
  68651. xrHitResult: XRHitResult;
  68652. }
  68653. /**
  68654. * The currently-working hit-test module.
  68655. * Hit test (or Ray-casting) is used to interact with the real world.
  68656. * For further information read here - https://github.com/immersive-web/hit-test
  68657. */
  68658. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68659. /**
  68660. * options to use when constructing this feature
  68661. */
  68662. readonly options: IWebXRHitTestOptions;
  68663. private _direction;
  68664. private _mat;
  68665. private _onSelectEnabled;
  68666. private _origin;
  68667. /**
  68668. * The module's name
  68669. */
  68670. static readonly Name: string;
  68671. /**
  68672. * The (Babylon) version of this module.
  68673. * This is an integer representing the implementation version.
  68674. * This number does not correspond to the WebXR specs version
  68675. */
  68676. static readonly Version: number;
  68677. /**
  68678. * Populated with the last native XR Hit Results
  68679. */
  68680. lastNativeXRHitResults: XRHitResult[];
  68681. /**
  68682. * Triggered when new babylon (transformed) hit test results are available
  68683. */
  68684. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68685. /**
  68686. * Creates a new instance of the (legacy version) hit test feature
  68687. * @param _xrSessionManager an instance of WebXRSessionManager
  68688. * @param options options to use when constructing this feature
  68689. */
  68690. constructor(_xrSessionManager: WebXRSessionManager,
  68691. /**
  68692. * options to use when constructing this feature
  68693. */
  68694. options?: IWebXRHitTestOptions);
  68695. /**
  68696. * execute a hit test with an XR Ray
  68697. *
  68698. * @param xrSession a native xrSession that will execute this hit test
  68699. * @param xrRay the ray (position and direction) to use for ray-casting
  68700. * @param referenceSpace native XR reference space to use for the hit-test
  68701. * @param filter filter function that will filter the results
  68702. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68703. */
  68704. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68705. /**
  68706. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68707. * @param event the (select) event to use to select with
  68708. * @param referenceSpace the reference space to use for this hit test
  68709. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68710. */
  68711. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68712. /**
  68713. * attach this feature
  68714. * Will usually be called by the features manager
  68715. *
  68716. * @returns true if successful.
  68717. */
  68718. attach(): boolean;
  68719. /**
  68720. * detach this feature.
  68721. * Will usually be called by the features manager
  68722. *
  68723. * @returns true if successful.
  68724. */
  68725. detach(): boolean;
  68726. /**
  68727. * Dispose this feature and all of the resources attached
  68728. */
  68729. dispose(): void;
  68730. protected _onXRFrame(frame: XRFrame): void;
  68731. private _onHitTestResults;
  68732. private _onSelect;
  68733. }
  68734. }
  68735. declare module BABYLON {
  68736. /**
  68737. * Options used in the plane detector module
  68738. */
  68739. export interface IWebXRPlaneDetectorOptions {
  68740. /**
  68741. * The node to use to transform the local results to world coordinates
  68742. */
  68743. worldParentNode?: TransformNode;
  68744. }
  68745. /**
  68746. * A babylon interface for a WebXR plane.
  68747. * A Plane is actually a polygon, built from N points in space
  68748. *
  68749. * Supported in chrome 79, not supported in canary 81 ATM
  68750. */
  68751. export interface IWebXRPlane {
  68752. /**
  68753. * a babylon-assigned ID for this polygon
  68754. */
  68755. id: number;
  68756. /**
  68757. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68758. */
  68759. polygonDefinition: Array<Vector3>;
  68760. /**
  68761. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68762. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68763. */
  68764. transformationMatrix: Matrix;
  68765. /**
  68766. * the native xr-plane object
  68767. */
  68768. xrPlane: XRPlane;
  68769. }
  68770. /**
  68771. * The plane detector is used to detect planes in the real world when in AR
  68772. * For more information see https://github.com/immersive-web/real-world-geometry/
  68773. */
  68774. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68775. private _options;
  68776. private _detectedPlanes;
  68777. private _enabled;
  68778. private _lastFrameDetected;
  68779. /**
  68780. * The module's name
  68781. */
  68782. static readonly Name: string;
  68783. /**
  68784. * The (Babylon) version of this module.
  68785. * This is an integer representing the implementation version.
  68786. * This number does not correspond to the WebXR specs version
  68787. */
  68788. static readonly Version: number;
  68789. /**
  68790. * Observers registered here will be executed when a new plane was added to the session
  68791. */
  68792. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68793. /**
  68794. * Observers registered here will be executed when a plane is no longer detected in the session
  68795. */
  68796. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68797. /**
  68798. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68799. * This can execute N times every frame
  68800. */
  68801. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68802. /**
  68803. * construct a new Plane Detector
  68804. * @param _xrSessionManager an instance of xr Session manager
  68805. * @param _options configuration to use when constructing this feature
  68806. */
  68807. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68808. /**
  68809. * Dispose this feature and all of the resources attached
  68810. */
  68811. dispose(): void;
  68812. protected _onXRFrame(frame: XRFrame): void;
  68813. private _init;
  68814. private _updatePlaneWithXRPlane;
  68815. /**
  68816. * avoiding using Array.find for global support.
  68817. * @param xrPlane the plane to find in the array
  68818. */
  68819. private findIndexInPlaneArray;
  68820. }
  68821. }
  68822. declare module BABYLON {
  68823. /**
  68824. * Configuration options of the anchor system
  68825. */
  68826. export interface IWebXRAnchorSystemOptions {
  68827. /**
  68828. * Should a new anchor be added every time a select event is triggered
  68829. */
  68830. addAnchorOnSelect?: boolean;
  68831. /**
  68832. * should the anchor system use plane detection.
  68833. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68834. */
  68835. usePlaneDetection?: boolean;
  68836. /**
  68837. * a node that will be used to convert local to world coordinates
  68838. */
  68839. worldParentNode?: TransformNode;
  68840. }
  68841. /**
  68842. * A babylon container for an XR Anchor
  68843. */
  68844. export interface IWebXRAnchor {
  68845. /**
  68846. * A babylon-assigned ID for this anchor
  68847. */
  68848. id: number;
  68849. /**
  68850. * Transformation matrix to apply to an object attached to this anchor
  68851. */
  68852. transformationMatrix: Matrix;
  68853. /**
  68854. * The native anchor object
  68855. */
  68856. xrAnchor: XRAnchor;
  68857. }
  68858. /**
  68859. * An implementation of the anchor system of WebXR.
  68860. * Note that the current documented implementation is not available in any browser. Future implementations
  68861. * will use the frame to create an anchor and not the session or a detected plane
  68862. * For further information see https://github.com/immersive-web/anchors/
  68863. */
  68864. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68865. private _options;
  68866. private _enabled;
  68867. private _hitTestModule;
  68868. private _lastFrameDetected;
  68869. private _onSelect;
  68870. private _planeDetector;
  68871. private _trackedAnchors;
  68872. /**
  68873. * The module's name
  68874. */
  68875. static readonly Name: string;
  68876. /**
  68877. * The (Babylon) version of this module.
  68878. * This is an integer representing the implementation version.
  68879. * This number does not correspond to the WebXR specs version
  68880. */
  68881. static readonly Version: number;
  68882. /**
  68883. * Observers registered here will be executed when a new anchor was added to the session
  68884. */
  68885. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  68886. /**
  68887. * Observers registered here will be executed when an anchor was removed from the session
  68888. */
  68889. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  68890. /**
  68891. * Observers registered here will be executed when an existing anchor updates
  68892. * This can execute N times every frame
  68893. */
  68894. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  68895. /**
  68896. * constructs a new anchor system
  68897. * @param _xrSessionManager an instance of WebXRSessionManager
  68898. * @param _options configuration object for this feature
  68899. */
  68900. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  68901. /**
  68902. * Add anchor at a specific XR point.
  68903. *
  68904. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  68905. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  68906. * @returns a promise the fulfills when the anchor was created
  68907. */
  68908. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  68909. /**
  68910. * attach this feature
  68911. * Will usually be called by the features manager
  68912. *
  68913. * @returns true if successful.
  68914. */
  68915. attach(): boolean;
  68916. /**
  68917. * detach this feature.
  68918. * Will usually be called by the features manager
  68919. *
  68920. * @returns true if successful.
  68921. */
  68922. detach(): boolean;
  68923. /**
  68924. * Dispose this feature and all of the resources attached
  68925. */
  68926. dispose(): void;
  68927. /**
  68928. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  68929. * @param hitTestModule the hit-test module to use.
  68930. */
  68931. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  68932. /**
  68933. * set the plane detector to use in order to create anchors from frames
  68934. * @param planeDetector the plane-detector module to use
  68935. * @param enable enable plane-anchors. default is true
  68936. */
  68937. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  68938. protected _onXRFrame(frame: XRFrame): void;
  68939. /**
  68940. * avoiding using Array.find for global support.
  68941. * @param xrAnchor the plane to find in the array
  68942. */
  68943. private _findIndexInAnchorArray;
  68944. private _updateAnchorWithXRFrame;
  68945. }
  68946. }
  68947. declare module BABYLON {
  68948. /**
  68949. * Options interface for the background remover plugin
  68950. */
  68951. export interface IWebXRBackgroundRemoverOptions {
  68952. /**
  68953. * Further background meshes to disable when entering AR
  68954. */
  68955. backgroundMeshes?: AbstractMesh[];
  68956. /**
  68957. * flags to configure the removal of the environment helper.
  68958. * If not set, the entire background will be removed. If set, flags should be set as well.
  68959. */
  68960. environmentHelperRemovalFlags?: {
  68961. /**
  68962. * Should the skybox be removed (default false)
  68963. */
  68964. skyBox?: boolean;
  68965. /**
  68966. * Should the ground be removed (default false)
  68967. */
  68968. ground?: boolean;
  68969. };
  68970. /**
  68971. * don't disable the environment helper
  68972. */
  68973. ignoreEnvironmentHelper?: boolean;
  68974. }
  68975. /**
  68976. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  68977. */
  68978. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  68979. /**
  68980. * read-only options to be used in this module
  68981. */
  68982. readonly options: IWebXRBackgroundRemoverOptions;
  68983. /**
  68984. * The module's name
  68985. */
  68986. static readonly Name: string;
  68987. /**
  68988. * The (Babylon) version of this module.
  68989. * This is an integer representing the implementation version.
  68990. * This number does not correspond to the WebXR specs version
  68991. */
  68992. static readonly Version: number;
  68993. /**
  68994. * registered observers will be triggered when the background state changes
  68995. */
  68996. onBackgroundStateChangedObservable: Observable<boolean>;
  68997. /**
  68998. * constructs a new background remover module
  68999. * @param _xrSessionManager the session manager for this module
  69000. * @param options read-only options to be used in this module
  69001. */
  69002. constructor(_xrSessionManager: WebXRSessionManager,
  69003. /**
  69004. * read-only options to be used in this module
  69005. */
  69006. options?: IWebXRBackgroundRemoverOptions);
  69007. /**
  69008. * attach this feature
  69009. * Will usually be called by the features manager
  69010. *
  69011. * @returns true if successful.
  69012. */
  69013. attach(): boolean;
  69014. /**
  69015. * detach this feature.
  69016. * Will usually be called by the features manager
  69017. *
  69018. * @returns true if successful.
  69019. */
  69020. detach(): boolean;
  69021. /**
  69022. * Dispose this feature and all of the resources attached
  69023. */
  69024. dispose(): void;
  69025. protected _onXRFrame(_xrFrame: XRFrame): void;
  69026. private _setBackgroundState;
  69027. }
  69028. }
  69029. declare module BABYLON {
  69030. /**
  69031. * Options for the controller physics feature
  69032. */
  69033. export class IWebXRControllerPhysicsOptions {
  69034. /**
  69035. * Should the headset get its own impostor
  69036. */
  69037. enableHeadsetImpostor?: boolean;
  69038. /**
  69039. * Optional parameters for the headset impostor
  69040. */
  69041. headsetImpostorParams?: {
  69042. /**
  69043. * The type of impostor to create. Default is sphere
  69044. */
  69045. impostorType: number;
  69046. /**
  69047. * the size of the impostor. Defaults to 10cm
  69048. */
  69049. impostorSize?: number | {
  69050. width: number;
  69051. height: number;
  69052. depth: number;
  69053. };
  69054. /**
  69055. * Friction definitions
  69056. */
  69057. friction?: number;
  69058. /**
  69059. * Restitution
  69060. */
  69061. restitution?: number;
  69062. };
  69063. /**
  69064. * The physics properties of the future impostors
  69065. */
  69066. physicsProperties?: {
  69067. /**
  69068. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69069. * Note that this requires a physics engine that supports mesh impostors!
  69070. */
  69071. useControllerMesh?: boolean;
  69072. /**
  69073. * The type of impostor to create. Default is sphere
  69074. */
  69075. impostorType?: number;
  69076. /**
  69077. * the size of the impostor. Defaults to 10cm
  69078. */
  69079. impostorSize?: number | {
  69080. width: number;
  69081. height: number;
  69082. depth: number;
  69083. };
  69084. /**
  69085. * Friction definitions
  69086. */
  69087. friction?: number;
  69088. /**
  69089. * Restitution
  69090. */
  69091. restitution?: number;
  69092. };
  69093. /**
  69094. * the xr input to use with this pointer selection
  69095. */
  69096. xrInput: WebXRInput;
  69097. }
  69098. /**
  69099. * Add physics impostor to your webxr controllers,
  69100. * including naive calculation of their linear and angular velocity
  69101. */
  69102. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69103. private readonly _options;
  69104. private _attachController;
  69105. private _controllers;
  69106. private _debugMode;
  69107. private _delta;
  69108. private _headsetImpostor?;
  69109. private _headsetMesh?;
  69110. private _lastTimestamp;
  69111. private _tmpQuaternion;
  69112. private _tmpVector;
  69113. /**
  69114. * The module's name
  69115. */
  69116. static readonly Name: string;
  69117. /**
  69118. * The (Babylon) version of this module.
  69119. * This is an integer representing the implementation version.
  69120. * This number does not correspond to the webxr specs version
  69121. */
  69122. static readonly Version: number;
  69123. /**
  69124. * Construct a new Controller Physics Feature
  69125. * @param _xrSessionManager the corresponding xr session manager
  69126. * @param _options options to create this feature with
  69127. */
  69128. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69129. /**
  69130. * @hidden
  69131. * enable debugging - will show console outputs and the impostor mesh
  69132. */
  69133. _enablePhysicsDebug(): void;
  69134. /**
  69135. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69136. * @param xrController the controller to add
  69137. */
  69138. addController(xrController: WebXRInputSource): void;
  69139. /**
  69140. * attach this feature
  69141. * Will usually be called by the features manager
  69142. *
  69143. * @returns true if successful.
  69144. */
  69145. attach(): boolean;
  69146. /**
  69147. * detach this feature.
  69148. * Will usually be called by the features manager
  69149. *
  69150. * @returns true if successful.
  69151. */
  69152. detach(): boolean;
  69153. /**
  69154. * Get the headset impostor, if enabled
  69155. * @returns the impostor
  69156. */
  69157. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69158. /**
  69159. * Get the physics impostor of a specific controller.
  69160. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69161. * @param controller the controller or the controller id of which to get the impostor
  69162. * @returns the impostor or null
  69163. */
  69164. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69165. /**
  69166. * Update the physics properties provided in the constructor
  69167. * @param newProperties the new properties object
  69168. */
  69169. setPhysicsProperties(newProperties: {
  69170. impostorType?: number;
  69171. impostorSize?: number | {
  69172. width: number;
  69173. height: number;
  69174. depth: number;
  69175. };
  69176. friction?: number;
  69177. restitution?: number;
  69178. }): void;
  69179. protected _onXRFrame(_xrFrame: any): void;
  69180. private _detachController;
  69181. }
  69182. }
  69183. declare module BABYLON {
  69184. /**
  69185. * The motion controller class for all microsoft mixed reality controllers
  69186. */
  69187. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69188. protected readonly _mapping: {
  69189. defaultButton: {
  69190. "valueNodeName": string;
  69191. "unpressedNodeName": string;
  69192. "pressedNodeName": string;
  69193. };
  69194. defaultAxis: {
  69195. "valueNodeName": string;
  69196. "minNodeName": string;
  69197. "maxNodeName": string;
  69198. };
  69199. buttons: {
  69200. "xr-standard-trigger": {
  69201. "rootNodeName": string;
  69202. "componentProperty": string;
  69203. "states": string[];
  69204. };
  69205. "xr-standard-squeeze": {
  69206. "rootNodeName": string;
  69207. "componentProperty": string;
  69208. "states": string[];
  69209. };
  69210. "xr-standard-touchpad": {
  69211. "rootNodeName": string;
  69212. "labelAnchorNodeName": string;
  69213. "touchPointNodeName": string;
  69214. };
  69215. "xr-standard-thumbstick": {
  69216. "rootNodeName": string;
  69217. "componentProperty": string;
  69218. "states": string[];
  69219. };
  69220. };
  69221. axes: {
  69222. "xr-standard-touchpad": {
  69223. "x-axis": {
  69224. "rootNodeName": string;
  69225. };
  69226. "y-axis": {
  69227. "rootNodeName": string;
  69228. };
  69229. };
  69230. "xr-standard-thumbstick": {
  69231. "x-axis": {
  69232. "rootNodeName": string;
  69233. };
  69234. "y-axis": {
  69235. "rootNodeName": string;
  69236. };
  69237. };
  69238. };
  69239. };
  69240. /**
  69241. * The base url used to load the left and right controller models
  69242. */
  69243. static MODEL_BASE_URL: string;
  69244. /**
  69245. * The name of the left controller model file
  69246. */
  69247. static MODEL_LEFT_FILENAME: string;
  69248. /**
  69249. * The name of the right controller model file
  69250. */
  69251. static MODEL_RIGHT_FILENAME: string;
  69252. profileId: string;
  69253. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69254. protected _getFilenameAndPath(): {
  69255. filename: string;
  69256. path: string;
  69257. };
  69258. protected _getModelLoadingConstraints(): boolean;
  69259. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69260. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69261. protected _updateModel(): void;
  69262. }
  69263. }
  69264. declare module BABYLON {
  69265. /**
  69266. * The motion controller class for oculus touch (quest, rift).
  69267. * This class supports legacy mapping as well the standard xr mapping
  69268. */
  69269. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69270. private _forceLegacyControllers;
  69271. private _modelRootNode;
  69272. /**
  69273. * The base url used to load the left and right controller models
  69274. */
  69275. static MODEL_BASE_URL: string;
  69276. /**
  69277. * The name of the left controller model file
  69278. */
  69279. static MODEL_LEFT_FILENAME: string;
  69280. /**
  69281. * The name of the right controller model file
  69282. */
  69283. static MODEL_RIGHT_FILENAME: string;
  69284. /**
  69285. * Base Url for the Quest controller model.
  69286. */
  69287. static QUEST_MODEL_BASE_URL: string;
  69288. profileId: string;
  69289. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69290. protected _getFilenameAndPath(): {
  69291. filename: string;
  69292. path: string;
  69293. };
  69294. protected _getModelLoadingConstraints(): boolean;
  69295. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69296. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69297. protected _updateModel(): void;
  69298. /**
  69299. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69300. * between the touch and touch 2.
  69301. */
  69302. private _isQuest;
  69303. }
  69304. }
  69305. declare module BABYLON {
  69306. /**
  69307. * The motion controller class for the standard HTC-Vive controllers
  69308. */
  69309. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69310. private _modelRootNode;
  69311. /**
  69312. * The base url used to load the left and right controller models
  69313. */
  69314. static MODEL_BASE_URL: string;
  69315. /**
  69316. * File name for the controller model.
  69317. */
  69318. static MODEL_FILENAME: string;
  69319. profileId: string;
  69320. /**
  69321. * Create a new Vive motion controller object
  69322. * @param scene the scene to use to create this controller
  69323. * @param gamepadObject the corresponding gamepad object
  69324. * @param handness the handness of the controller
  69325. */
  69326. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69327. protected _getFilenameAndPath(): {
  69328. filename: string;
  69329. path: string;
  69330. };
  69331. protected _getModelLoadingConstraints(): boolean;
  69332. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69333. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69334. protected _updateModel(): void;
  69335. }
  69336. }
  69337. declare module BABYLON {
  69338. /**
  69339. * A cursor which tracks a point on a path
  69340. */
  69341. export class PathCursor {
  69342. private path;
  69343. /**
  69344. * Stores path cursor callbacks for when an onchange event is triggered
  69345. */
  69346. private _onchange;
  69347. /**
  69348. * The value of the path cursor
  69349. */
  69350. value: number;
  69351. /**
  69352. * The animation array of the path cursor
  69353. */
  69354. animations: Animation[];
  69355. /**
  69356. * Initializes the path cursor
  69357. * @param path The path to track
  69358. */
  69359. constructor(path: Path2);
  69360. /**
  69361. * Gets the cursor point on the path
  69362. * @returns A point on the path cursor at the cursor location
  69363. */
  69364. getPoint(): Vector3;
  69365. /**
  69366. * Moves the cursor ahead by the step amount
  69367. * @param step The amount to move the cursor forward
  69368. * @returns This path cursor
  69369. */
  69370. moveAhead(step?: number): PathCursor;
  69371. /**
  69372. * Moves the cursor behind by the step amount
  69373. * @param step The amount to move the cursor back
  69374. * @returns This path cursor
  69375. */
  69376. moveBack(step?: number): PathCursor;
  69377. /**
  69378. * Moves the cursor by the step amount
  69379. * If the step amount is greater than one, an exception is thrown
  69380. * @param step The amount to move the cursor
  69381. * @returns This path cursor
  69382. */
  69383. move(step: number): PathCursor;
  69384. /**
  69385. * Ensures that the value is limited between zero and one
  69386. * @returns This path cursor
  69387. */
  69388. private ensureLimits;
  69389. /**
  69390. * Runs onchange callbacks on change (used by the animation engine)
  69391. * @returns This path cursor
  69392. */
  69393. private raiseOnChange;
  69394. /**
  69395. * Executes a function on change
  69396. * @param f A path cursor onchange callback
  69397. * @returns This path cursor
  69398. */
  69399. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69400. }
  69401. }
  69402. declare module BABYLON {
  69403. /** @hidden */
  69404. export var blurPixelShader: {
  69405. name: string;
  69406. shader: string;
  69407. };
  69408. }
  69409. declare module BABYLON {
  69410. /** @hidden */
  69411. export var pointCloudVertexDeclaration: {
  69412. name: string;
  69413. shader: string;
  69414. };
  69415. }
  69416. // Mixins
  69417. interface Window {
  69418. mozIndexedDB: IDBFactory;
  69419. webkitIndexedDB: IDBFactory;
  69420. msIndexedDB: IDBFactory;
  69421. webkitURL: typeof URL;
  69422. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69423. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69424. WebGLRenderingContext: WebGLRenderingContext;
  69425. MSGesture: MSGesture;
  69426. CANNON: any;
  69427. AudioContext: AudioContext;
  69428. webkitAudioContext: AudioContext;
  69429. PointerEvent: any;
  69430. Math: Math;
  69431. Uint8Array: Uint8ArrayConstructor;
  69432. Float32Array: Float32ArrayConstructor;
  69433. mozURL: typeof URL;
  69434. msURL: typeof URL;
  69435. VRFrameData: any; // WebVR, from specs 1.1
  69436. DracoDecoderModule: any;
  69437. setImmediate(handler: (...args: any[]) => void): number;
  69438. }
  69439. interface HTMLCanvasElement {
  69440. requestPointerLock(): void;
  69441. msRequestPointerLock?(): void;
  69442. mozRequestPointerLock?(): void;
  69443. webkitRequestPointerLock?(): void;
  69444. /** Track wether a record is in progress */
  69445. isRecording: boolean;
  69446. /** Capture Stream method defined by some browsers */
  69447. captureStream(fps?: number): MediaStream;
  69448. }
  69449. interface CanvasRenderingContext2D {
  69450. msImageSmoothingEnabled: boolean;
  69451. }
  69452. interface MouseEvent {
  69453. mozMovementX: number;
  69454. mozMovementY: number;
  69455. webkitMovementX: number;
  69456. webkitMovementY: number;
  69457. msMovementX: number;
  69458. msMovementY: number;
  69459. }
  69460. interface Navigator {
  69461. mozGetVRDevices: (any: any) => any;
  69462. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69463. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69464. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69465. webkitGetGamepads(): Gamepad[];
  69466. msGetGamepads(): Gamepad[];
  69467. webkitGamepads(): Gamepad[];
  69468. }
  69469. interface HTMLVideoElement {
  69470. mozSrcObject: any;
  69471. }
  69472. interface Math {
  69473. fround(x: number): number;
  69474. imul(a: number, b: number): number;
  69475. }
  69476. interface WebGLRenderingContext {
  69477. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69478. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69479. vertexAttribDivisor(index: number, divisor: number): void;
  69480. createVertexArray(): any;
  69481. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69482. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69483. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69484. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69485. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69486. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69487. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69488. // Queries
  69489. createQuery(): WebGLQuery;
  69490. deleteQuery(query: WebGLQuery): void;
  69491. beginQuery(target: number, query: WebGLQuery): void;
  69492. endQuery(target: number): void;
  69493. getQueryParameter(query: WebGLQuery, pname: number): any;
  69494. getQuery(target: number, pname: number): any;
  69495. MAX_SAMPLES: number;
  69496. RGBA8: number;
  69497. READ_FRAMEBUFFER: number;
  69498. DRAW_FRAMEBUFFER: number;
  69499. UNIFORM_BUFFER: number;
  69500. HALF_FLOAT_OES: number;
  69501. RGBA16F: number;
  69502. RGBA32F: number;
  69503. R32F: number;
  69504. RG32F: number;
  69505. RGB32F: number;
  69506. R16F: number;
  69507. RG16F: number;
  69508. RGB16F: number;
  69509. RED: number;
  69510. RG: number;
  69511. R8: number;
  69512. RG8: number;
  69513. UNSIGNED_INT_24_8: number;
  69514. DEPTH24_STENCIL8: number;
  69515. MIN: number;
  69516. MAX: number;
  69517. /* Multiple Render Targets */
  69518. drawBuffers(buffers: number[]): void;
  69519. readBuffer(src: number): void;
  69520. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69521. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69522. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69523. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69524. // Occlusion Query
  69525. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69526. ANY_SAMPLES_PASSED: number;
  69527. QUERY_RESULT_AVAILABLE: number;
  69528. QUERY_RESULT: number;
  69529. }
  69530. interface WebGLProgram {
  69531. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69532. }
  69533. interface EXT_disjoint_timer_query {
  69534. QUERY_COUNTER_BITS_EXT: number;
  69535. TIME_ELAPSED_EXT: number;
  69536. TIMESTAMP_EXT: number;
  69537. GPU_DISJOINT_EXT: number;
  69538. QUERY_RESULT_EXT: number;
  69539. QUERY_RESULT_AVAILABLE_EXT: number;
  69540. queryCounterEXT(query: WebGLQuery, target: number): void;
  69541. createQueryEXT(): WebGLQuery;
  69542. beginQueryEXT(target: number, query: WebGLQuery): void;
  69543. endQueryEXT(target: number): void;
  69544. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69545. deleteQueryEXT(query: WebGLQuery): void;
  69546. }
  69547. interface WebGLUniformLocation {
  69548. _currentState: any;
  69549. }
  69550. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69551. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69552. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69553. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69554. interface WebGLRenderingContext {
  69555. readonly RASTERIZER_DISCARD: number;
  69556. readonly DEPTH_COMPONENT24: number;
  69557. readonly TEXTURE_3D: number;
  69558. readonly TEXTURE_2D_ARRAY: number;
  69559. readonly TEXTURE_COMPARE_FUNC: number;
  69560. readonly TEXTURE_COMPARE_MODE: number;
  69561. readonly COMPARE_REF_TO_TEXTURE: number;
  69562. readonly TEXTURE_WRAP_R: number;
  69563. readonly HALF_FLOAT: number;
  69564. readonly RGB8: number;
  69565. readonly RED_INTEGER: number;
  69566. readonly RG_INTEGER: number;
  69567. readonly RGB_INTEGER: number;
  69568. readonly RGBA_INTEGER: number;
  69569. readonly R8_SNORM: number;
  69570. readonly RG8_SNORM: number;
  69571. readonly RGB8_SNORM: number;
  69572. readonly RGBA8_SNORM: number;
  69573. readonly R8I: number;
  69574. readonly RG8I: number;
  69575. readonly RGB8I: number;
  69576. readonly RGBA8I: number;
  69577. readonly R8UI: number;
  69578. readonly RG8UI: number;
  69579. readonly RGB8UI: number;
  69580. readonly RGBA8UI: number;
  69581. readonly R16I: number;
  69582. readonly RG16I: number;
  69583. readonly RGB16I: number;
  69584. readonly RGBA16I: number;
  69585. readonly R16UI: number;
  69586. readonly RG16UI: number;
  69587. readonly RGB16UI: number;
  69588. readonly RGBA16UI: number;
  69589. readonly R32I: number;
  69590. readonly RG32I: number;
  69591. readonly RGB32I: number;
  69592. readonly RGBA32I: number;
  69593. readonly R32UI: number;
  69594. readonly RG32UI: number;
  69595. readonly RGB32UI: number;
  69596. readonly RGBA32UI: number;
  69597. readonly RGB10_A2UI: number;
  69598. readonly R11F_G11F_B10F: number;
  69599. readonly RGB9_E5: number;
  69600. readonly RGB10_A2: number;
  69601. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69602. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69603. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69604. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69605. readonly DEPTH_COMPONENT32F: number;
  69606. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69607. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69608. 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;
  69609. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69610. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69611. readonly TRANSFORM_FEEDBACK: number;
  69612. readonly INTERLEAVED_ATTRIBS: number;
  69613. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69614. createTransformFeedback(): WebGLTransformFeedback;
  69615. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69616. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69617. beginTransformFeedback(primitiveMode: number): void;
  69618. endTransformFeedback(): void;
  69619. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69620. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69621. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69622. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69623. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69624. }
  69625. interface ImageBitmap {
  69626. readonly width: number;
  69627. readonly height: number;
  69628. close(): void;
  69629. }
  69630. interface WebGLQuery extends WebGLObject {
  69631. }
  69632. declare var WebGLQuery: {
  69633. prototype: WebGLQuery;
  69634. new(): WebGLQuery;
  69635. };
  69636. interface WebGLSampler extends WebGLObject {
  69637. }
  69638. declare var WebGLSampler: {
  69639. prototype: WebGLSampler;
  69640. new(): WebGLSampler;
  69641. };
  69642. interface WebGLSync extends WebGLObject {
  69643. }
  69644. declare var WebGLSync: {
  69645. prototype: WebGLSync;
  69646. new(): WebGLSync;
  69647. };
  69648. interface WebGLTransformFeedback extends WebGLObject {
  69649. }
  69650. declare var WebGLTransformFeedback: {
  69651. prototype: WebGLTransformFeedback;
  69652. new(): WebGLTransformFeedback;
  69653. };
  69654. interface WebGLVertexArrayObject extends WebGLObject {
  69655. }
  69656. declare var WebGLVertexArrayObject: {
  69657. prototype: WebGLVertexArrayObject;
  69658. new(): WebGLVertexArrayObject;
  69659. };
  69660. // Type definitions for WebVR API
  69661. // Project: https://w3c.github.io/webvr/
  69662. // Definitions by: six a <https://github.com/lostfictions>
  69663. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69664. interface VRDisplay extends EventTarget {
  69665. /**
  69666. * Dictionary of capabilities describing the VRDisplay.
  69667. */
  69668. readonly capabilities: VRDisplayCapabilities;
  69669. /**
  69670. * z-depth defining the far plane of the eye view frustum
  69671. * enables mapping of values in the render target depth
  69672. * attachment to scene coordinates. Initially set to 10000.0.
  69673. */
  69674. depthFar: number;
  69675. /**
  69676. * z-depth defining the near plane of the eye view frustum
  69677. * enables mapping of values in the render target depth
  69678. * attachment to scene coordinates. Initially set to 0.01.
  69679. */
  69680. depthNear: number;
  69681. /**
  69682. * An identifier for this distinct VRDisplay. Used as an
  69683. * association point in the Gamepad API.
  69684. */
  69685. readonly displayId: number;
  69686. /**
  69687. * A display name, a user-readable name identifying it.
  69688. */
  69689. readonly displayName: string;
  69690. readonly isConnected: boolean;
  69691. readonly isPresenting: boolean;
  69692. /**
  69693. * If this VRDisplay supports room-scale experiences, the optional
  69694. * stage attribute contains details on the room-scale parameters.
  69695. */
  69696. readonly stageParameters: VRStageParameters | null;
  69697. /**
  69698. * Passing the value returned by `requestAnimationFrame` to
  69699. * `cancelAnimationFrame` will unregister the callback.
  69700. * @param handle Define the hanle of the request to cancel
  69701. */
  69702. cancelAnimationFrame(handle: number): void;
  69703. /**
  69704. * Stops presenting to the VRDisplay.
  69705. * @returns a promise to know when it stopped
  69706. */
  69707. exitPresent(): Promise<void>;
  69708. /**
  69709. * Return the current VREyeParameters for the given eye.
  69710. * @param whichEye Define the eye we want the parameter for
  69711. * @returns the eye parameters
  69712. */
  69713. getEyeParameters(whichEye: string): VREyeParameters;
  69714. /**
  69715. * Populates the passed VRFrameData with the information required to render
  69716. * the current frame.
  69717. * @param frameData Define the data structure to populate
  69718. * @returns true if ok otherwise false
  69719. */
  69720. getFrameData(frameData: VRFrameData): boolean;
  69721. /**
  69722. * Get the layers currently being presented.
  69723. * @returns the list of VR layers
  69724. */
  69725. getLayers(): VRLayer[];
  69726. /**
  69727. * Return a VRPose containing the future predicted pose of the VRDisplay
  69728. * when the current frame will be presented. The value returned will not
  69729. * change until JavaScript has returned control to the browser.
  69730. *
  69731. * The VRPose will contain the position, orientation, velocity,
  69732. * and acceleration of each of these properties.
  69733. * @returns the pose object
  69734. */
  69735. getPose(): VRPose;
  69736. /**
  69737. * Return the current instantaneous pose of the VRDisplay, with no
  69738. * prediction applied.
  69739. * @returns the current instantaneous pose
  69740. */
  69741. getImmediatePose(): VRPose;
  69742. /**
  69743. * The callback passed to `requestAnimationFrame` will be called
  69744. * any time a new frame should be rendered. When the VRDisplay is
  69745. * presenting the callback will be called at the native refresh
  69746. * rate of the HMD. When not presenting this function acts
  69747. * identically to how window.requestAnimationFrame acts. Content should
  69748. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69749. * asynchronously from other displays and at differing refresh rates.
  69750. * @param callback Define the eaction to run next frame
  69751. * @returns the request handle it
  69752. */
  69753. requestAnimationFrame(callback: FrameRequestCallback): number;
  69754. /**
  69755. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69756. * Repeat calls while already presenting will update the VRLayers being displayed.
  69757. * @param layers Define the list of layer to present
  69758. * @returns a promise to know when the request has been fulfilled
  69759. */
  69760. requestPresent(layers: VRLayer[]): Promise<void>;
  69761. /**
  69762. * Reset the pose for this display, treating its current position and
  69763. * orientation as the "origin/zero" values. VRPose.position,
  69764. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69765. * updated when calling resetPose(). This should be called in only
  69766. * sitting-space experiences.
  69767. */
  69768. resetPose(): void;
  69769. /**
  69770. * The VRLayer provided to the VRDisplay will be captured and presented
  69771. * in the HMD. Calling this function has the same effect on the source
  69772. * canvas as any other operation that uses its source image, and canvases
  69773. * created without preserveDrawingBuffer set to true will be cleared.
  69774. * @param pose Define the pose to submit
  69775. */
  69776. submitFrame(pose?: VRPose): void;
  69777. }
  69778. declare var VRDisplay: {
  69779. prototype: VRDisplay;
  69780. new(): VRDisplay;
  69781. };
  69782. interface VRLayer {
  69783. leftBounds?: number[] | Float32Array | null;
  69784. rightBounds?: number[] | Float32Array | null;
  69785. source?: HTMLCanvasElement | null;
  69786. }
  69787. interface VRDisplayCapabilities {
  69788. readonly canPresent: boolean;
  69789. readonly hasExternalDisplay: boolean;
  69790. readonly hasOrientation: boolean;
  69791. readonly hasPosition: boolean;
  69792. readonly maxLayers: number;
  69793. }
  69794. interface VREyeParameters {
  69795. /** @deprecated */
  69796. readonly fieldOfView: VRFieldOfView;
  69797. readonly offset: Float32Array;
  69798. readonly renderHeight: number;
  69799. readonly renderWidth: number;
  69800. }
  69801. interface VRFieldOfView {
  69802. readonly downDegrees: number;
  69803. readonly leftDegrees: number;
  69804. readonly rightDegrees: number;
  69805. readonly upDegrees: number;
  69806. }
  69807. interface VRFrameData {
  69808. readonly leftProjectionMatrix: Float32Array;
  69809. readonly leftViewMatrix: Float32Array;
  69810. readonly pose: VRPose;
  69811. readonly rightProjectionMatrix: Float32Array;
  69812. readonly rightViewMatrix: Float32Array;
  69813. readonly timestamp: number;
  69814. }
  69815. interface VRPose {
  69816. readonly angularAcceleration: Float32Array | null;
  69817. readonly angularVelocity: Float32Array | null;
  69818. readonly linearAcceleration: Float32Array | null;
  69819. readonly linearVelocity: Float32Array | null;
  69820. readonly orientation: Float32Array | null;
  69821. readonly position: Float32Array | null;
  69822. readonly timestamp: number;
  69823. }
  69824. interface VRStageParameters {
  69825. sittingToStandingTransform?: Float32Array;
  69826. sizeX?: number;
  69827. sizeY?: number;
  69828. }
  69829. interface Navigator {
  69830. getVRDisplays(): Promise<VRDisplay[]>;
  69831. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69832. }
  69833. interface Window {
  69834. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69835. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69836. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69837. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69838. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69839. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69840. }
  69841. interface Gamepad {
  69842. readonly displayId: number;
  69843. }
  69844. type XRSessionMode =
  69845. | "inline"
  69846. | "immersive-vr"
  69847. | "immersive-ar";
  69848. type XRReferenceSpaceType =
  69849. | "viewer"
  69850. | "local"
  69851. | "local-floor"
  69852. | "bounded-floor"
  69853. | "unbounded";
  69854. type XREnvironmentBlendMode =
  69855. | "opaque"
  69856. | "additive"
  69857. | "alpha-blend";
  69858. type XRVisibilityState =
  69859. | "visible"
  69860. | "visible-blurred"
  69861. | "hidden";
  69862. type XRHandedness =
  69863. | "none"
  69864. | "left"
  69865. | "right";
  69866. type XRTargetRayMode =
  69867. | "gaze"
  69868. | "tracked-pointer"
  69869. | "screen";
  69870. type XREye =
  69871. | "none"
  69872. | "left"
  69873. | "right";
  69874. interface XRSpace extends EventTarget {
  69875. }
  69876. interface XRRenderState {
  69877. depthNear?: number;
  69878. depthFar?: number;
  69879. inlineVerticalFieldOfView?: number;
  69880. baseLayer?: XRWebGLLayer;
  69881. }
  69882. interface XRInputSource {
  69883. handedness: XRHandedness;
  69884. targetRayMode: XRTargetRayMode;
  69885. targetRaySpace: XRSpace;
  69886. gripSpace: XRSpace | undefined;
  69887. gamepad: Gamepad | undefined;
  69888. profiles: Array<string>;
  69889. }
  69890. interface XRSessionInit {
  69891. optionalFeatures?: XRReferenceSpaceType[];
  69892. requiredFeatures?: XRReferenceSpaceType[];
  69893. }
  69894. interface XRSession extends XRAnchorCreator {
  69895. addEventListener: Function;
  69896. removeEventListener: Function;
  69897. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69898. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69899. requestAnimationFrame: Function;
  69900. end(): Promise<void>;
  69901. renderState: XRRenderState;
  69902. inputSources: Array<XRInputSource>;
  69903. // AR hit test
  69904. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69905. updateWorldTrackingState(options: {
  69906. planeDetectionState?: { enabled: boolean; }
  69907. }): void;
  69908. }
  69909. interface XRReferenceSpace extends XRSpace {
  69910. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69911. onreset: any;
  69912. }
  69913. type XRPlaneSet = Set<XRPlane>;
  69914. type XRAnchorSet = Set<XRAnchor>;
  69915. interface XRFrame {
  69916. session: XRSession;
  69917. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69918. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69919. // Anchors
  69920. trackedAnchors?: XRAnchorSet;
  69921. // Planes
  69922. worldInformation: {
  69923. detectedPlanes?: XRPlaneSet;
  69924. };
  69925. }
  69926. interface XRViewerPose extends XRPose {
  69927. views: Array<XRView>;
  69928. }
  69929. interface XRPose {
  69930. transform: XRRigidTransform;
  69931. emulatedPosition: boolean;
  69932. }
  69933. interface XRWebGLLayerOptions {
  69934. antialias?: boolean;
  69935. depth?: boolean;
  69936. stencil?: boolean;
  69937. alpha?: boolean;
  69938. multiview?: boolean;
  69939. framebufferScaleFactor?: number;
  69940. }
  69941. declare var XRWebGLLayer: {
  69942. prototype: XRWebGLLayer;
  69943. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69944. };
  69945. interface XRWebGLLayer {
  69946. framebuffer: WebGLFramebuffer;
  69947. framebufferWidth: number;
  69948. framebufferHeight: number;
  69949. getViewport: Function;
  69950. }
  69951. declare class XRRigidTransform {
  69952. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69953. position: DOMPointReadOnly;
  69954. orientation: DOMPointReadOnly;
  69955. matrix: Float32Array;
  69956. inverse: XRRigidTransform;
  69957. }
  69958. interface XRView {
  69959. eye: XREye;
  69960. projectionMatrix: Float32Array;
  69961. transform: XRRigidTransform;
  69962. }
  69963. interface XRInputSourceChangeEvent {
  69964. session: XRSession;
  69965. removed: Array<XRInputSource>;
  69966. added: Array<XRInputSource>;
  69967. }
  69968. interface XRInputSourceEvent extends Event {
  69969. readonly frame: XRFrame;
  69970. readonly inputSource: XRInputSource;
  69971. }
  69972. // Experimental(er) features
  69973. declare class XRRay {
  69974. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69975. origin: DOMPointReadOnly;
  69976. direction: DOMPointReadOnly;
  69977. matrix: Float32Array;
  69978. }
  69979. interface XRHitResult {
  69980. hitMatrix: Float32Array;
  69981. }
  69982. interface XRAnchor {
  69983. // remove?
  69984. id?: string;
  69985. anchorSpace: XRSpace;
  69986. lastChangedTime: number;
  69987. detach(): void;
  69988. }
  69989. interface XRPlane extends XRAnchorCreator {
  69990. orientation: "Horizontal" | "Vertical";
  69991. planeSpace: XRSpace;
  69992. polygon: Array<DOMPointReadOnly>;
  69993. lastChangedTime: number;
  69994. }
  69995. interface XRAnchorCreator {
  69996. // AR Anchors
  69997. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69998. }