babylon.d.ts 2.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * 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".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * 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"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * 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"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * 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)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * 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
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Inserts the translation vector in the current matrix
  2943. * @param vector3 defines the translation to insert
  2944. * @returns the current updated matrix
  2945. */
  2946. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2947. /**
  2948. * Gets the translation value of the current matrix
  2949. * @returns a new Vector3 as the extracted translation from the matrix
  2950. */
  2951. getTranslation(): Vector3;
  2952. /**
  2953. * Fill a Vector3 with the extracted translation from the matrix
  2954. * @param result defines the Vector3 where to store the translation
  2955. * @returns the current matrix
  2956. */
  2957. getTranslationToRef(result: Vector3): Matrix;
  2958. /**
  2959. * Remove rotation and scaling part from the matrix
  2960. * @returns the updated matrix
  2961. */
  2962. removeRotationAndScaling(): Matrix;
  2963. /**
  2964. * Multiply two matrices
  2965. * @param other defines the second operand
  2966. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2967. */
  2968. multiply(other: DeepImmutable<Matrix>): Matrix;
  2969. /**
  2970. * Copy the current matrix from the given one
  2971. * @param other defines the source matrix
  2972. * @returns the current updated matrix
  2973. */
  2974. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Populates the given array from the starting index with the current matrix values
  2977. * @param array defines the target array
  2978. * @param offset defines the offset in the target array where to start storing values
  2979. * @returns the current matrix
  2980. */
  2981. copyToArray(array: Float32Array, offset?: number): Matrix;
  2982. /**
  2983. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2984. * @param other defines the second operand
  2985. * @param result defines the matrix where to store the multiplication
  2986. * @returns the current matrix
  2987. */
  2988. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2989. /**
  2990. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2991. * @param other defines the second operand
  2992. * @param result defines the array where to store the multiplication
  2993. * @param offset defines the offset in the target array where to start storing values
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2997. /**
  2998. * Check equality between this matrix and a second one
  2999. * @param value defines the second matrix to compare
  3000. * @returns true is the current matrix and the given one values are strictly equal
  3001. */
  3002. equals(value: DeepImmutable<Matrix>): boolean;
  3003. /**
  3004. * Clone the current matrix
  3005. * @returns a new matrix from the current matrix
  3006. */
  3007. clone(): Matrix;
  3008. /**
  3009. * Returns the name of the current matrix class
  3010. * @returns the string "Matrix"
  3011. */
  3012. getClassName(): string;
  3013. /**
  3014. * Gets the hash code of the current matrix
  3015. * @returns the hash code
  3016. */
  3017. getHashCode(): number;
  3018. /**
  3019. * Decomposes the current Matrix into a translation, rotation and scaling components
  3020. * @param scale defines the scale vector3 given as a reference to update
  3021. * @param rotation defines the rotation quaternion given as a reference to update
  3022. * @param translation defines the translation vector3 given as a reference to update
  3023. * @returns true if operation was successful
  3024. */
  3025. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3026. /**
  3027. * Gets specific row of the matrix
  3028. * @param index defines the number of the row to get
  3029. * @returns the index-th row of the current matrix as a new Vector4
  3030. */
  3031. getRow(index: number): Nullable<Vector4>;
  3032. /**
  3033. * Sets the index-th row of the current matrix to the vector4 values
  3034. * @param index defines the number of the row to set
  3035. * @param row defines the target vector4
  3036. * @returns the updated current matrix
  3037. */
  3038. setRow(index: number, row: Vector4): Matrix;
  3039. /**
  3040. * Compute the transpose of the matrix
  3041. * @returns the new transposed matrix
  3042. */
  3043. transpose(): Matrix;
  3044. /**
  3045. * Compute the transpose of the matrix and store it in a given matrix
  3046. * @param result defines the target matrix
  3047. * @returns the current matrix
  3048. */
  3049. transposeToRef(result: Matrix): Matrix;
  3050. /**
  3051. * Sets the index-th row of the current matrix with the given 4 x float values
  3052. * @param index defines the row index
  3053. * @param x defines the x component to set
  3054. * @param y defines the y component to set
  3055. * @param z defines the z component to set
  3056. * @param w defines the w component to set
  3057. * @returns the updated current matrix
  3058. */
  3059. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3060. /**
  3061. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3062. * @param scale defines the scale factor
  3063. * @returns a new matrix
  3064. */
  3065. scale(scale: number): Matrix;
  3066. /**
  3067. * Scale the current matrix values by a factor to a given result matrix
  3068. * @param scale defines the scale factor
  3069. * @param result defines the matrix to store the result
  3070. * @returns the current matrix
  3071. */
  3072. scaleToRef(scale: number, result: Matrix): Matrix;
  3073. /**
  3074. * Scale the current matrix values by a factor and add the result to a given matrix
  3075. * @param scale defines the scale factor
  3076. * @param result defines the Matrix to store the result
  3077. * @returns the current matrix
  3078. */
  3079. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3080. /**
  3081. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3082. * @param ref matrix to store the result
  3083. */
  3084. toNormalMatrix(ref: Matrix): void;
  3085. /**
  3086. * Gets only rotation part of the current matrix
  3087. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3088. */
  3089. getRotationMatrix(): Matrix;
  3090. /**
  3091. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3092. * @param result defines the target matrix to store data to
  3093. * @returns the current matrix
  3094. */
  3095. getRotationMatrixToRef(result: Matrix): Matrix;
  3096. /**
  3097. * Toggles model matrix from being right handed to left handed in place and vice versa
  3098. */
  3099. toggleModelMatrixHandInPlace(): void;
  3100. /**
  3101. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3102. */
  3103. toggleProjectionMatrixHandInPlace(): void;
  3104. /**
  3105. * Creates a matrix from an array
  3106. * @param array defines the source array
  3107. * @param offset defines an offset in the source array
  3108. * @returns a new Matrix set from the starting index of the given array
  3109. */
  3110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3111. /**
  3112. * Copy the content of an array into a given matrix
  3113. * @param array defines the source array
  3114. * @param offset defines an offset in the source array
  3115. * @param result defines the target matrix
  3116. */
  3117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3118. /**
  3119. * Stores an array into a matrix after having multiplied each component by a given factor
  3120. * @param array defines the source array
  3121. * @param offset defines the offset in the source array
  3122. * @param scale defines the scaling factor
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3126. /**
  3127. * Gets an identity matrix that must not be updated
  3128. */
  3129. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3130. /**
  3131. * Stores a list of values (16) inside a given matrix
  3132. * @param initialM11 defines 1st value of 1st row
  3133. * @param initialM12 defines 2nd value of 1st row
  3134. * @param initialM13 defines 3rd value of 1st row
  3135. * @param initialM14 defines 4th value of 1st row
  3136. * @param initialM21 defines 1st value of 2nd row
  3137. * @param initialM22 defines 2nd value of 2nd row
  3138. * @param initialM23 defines 3rd value of 2nd row
  3139. * @param initialM24 defines 4th value of 2nd row
  3140. * @param initialM31 defines 1st value of 3rd row
  3141. * @param initialM32 defines 2nd value of 3rd row
  3142. * @param initialM33 defines 3rd value of 3rd row
  3143. * @param initialM34 defines 4th value of 3rd row
  3144. * @param initialM41 defines 1st value of 4th row
  3145. * @param initialM42 defines 2nd value of 4th row
  3146. * @param initialM43 defines 3rd value of 4th row
  3147. * @param initialM44 defines 4th value of 4th row
  3148. * @param result defines the target matrix
  3149. */
  3150. 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;
  3151. /**
  3152. * Creates new matrix from a list of values (16)
  3153. * @param initialM11 defines 1st value of 1st row
  3154. * @param initialM12 defines 2nd value of 1st row
  3155. * @param initialM13 defines 3rd value of 1st row
  3156. * @param initialM14 defines 4th value of 1st row
  3157. * @param initialM21 defines 1st value of 2nd row
  3158. * @param initialM22 defines 2nd value of 2nd row
  3159. * @param initialM23 defines 3rd value of 2nd row
  3160. * @param initialM24 defines 4th value of 2nd row
  3161. * @param initialM31 defines 1st value of 3rd row
  3162. * @param initialM32 defines 2nd value of 3rd row
  3163. * @param initialM33 defines 3rd value of 3rd row
  3164. * @param initialM34 defines 4th value of 3rd row
  3165. * @param initialM41 defines 1st value of 4th row
  3166. * @param initialM42 defines 2nd value of 4th row
  3167. * @param initialM43 defines 3rd value of 4th row
  3168. * @param initialM44 defines 4th value of 4th row
  3169. * @returns the new matrix
  3170. */
  3171. 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;
  3172. /**
  3173. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3174. * @param scale defines the scale vector3
  3175. * @param rotation defines the rotation quaternion
  3176. * @param translation defines the translation vector3
  3177. * @returns a new matrix
  3178. */
  3179. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3180. /**
  3181. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @param result defines the target matrix
  3186. */
  3187. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3188. /**
  3189. * Creates a new identity matrix
  3190. * @returns a new identity matrix
  3191. */
  3192. static Identity(): Matrix;
  3193. /**
  3194. * Creates a new identity matrix and stores the result in a given matrix
  3195. * @param result defines the target matrix
  3196. */
  3197. static IdentityToRef(result: Matrix): void;
  3198. /**
  3199. * Creates a new zero matrix
  3200. * @returns a new zero matrix
  3201. */
  3202. static Zero(): Matrix;
  3203. /**
  3204. * Creates a new rotation matrix for "angle" radians around the X axis
  3205. * @param angle defines the angle (in radians) to use
  3206. * @return the new matrix
  3207. */
  3208. static RotationX(angle: number): Matrix;
  3209. /**
  3210. * Creates a new matrix as the invert of a given matrix
  3211. * @param source defines the source matrix
  3212. * @returns the new matrix
  3213. */
  3214. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3215. /**
  3216. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3217. * @param angle defines the angle (in radians) to use
  3218. * @param result defines the target matrix
  3219. */
  3220. static RotationXToRef(angle: number, result: Matrix): void;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the Y axis
  3223. * @param angle defines the angle (in radians) to use
  3224. * @return the new matrix
  3225. */
  3226. static RotationY(angle: number): Matrix;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3229. * @param angle defines the angle (in radians) to use
  3230. * @param result defines the target matrix
  3231. */
  3232. static RotationYToRef(angle: number, result: Matrix): void;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Z axis
  3235. * @param angle defines the angle (in radians) to use
  3236. * @return the new matrix
  3237. */
  3238. static RotationZ(angle: number): Matrix;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3241. * @param angle defines the angle (in radians) to use
  3242. * @param result defines the target matrix
  3243. */
  3244. static RotationZToRef(angle: number, result: Matrix): void;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the given axis
  3247. * @param axis defines the axis to use
  3248. * @param angle defines the angle (in radians) to use
  3249. * @return the new matrix
  3250. */
  3251. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3254. * @param axis defines the axis to use
  3255. * @param angle defines the angle (in radians) to use
  3256. * @param result defines the target matrix
  3257. */
  3258. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3259. /**
  3260. * Creates a rotation matrix
  3261. * @param yaw defines the yaw angle in radians (Y axis)
  3262. * @param pitch defines the pitch angle in radians (X axis)
  3263. * @param roll defines the roll angle in radians (X axis)
  3264. * @returns the new rotation matrix
  3265. */
  3266. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3267. /**
  3268. * Creates a rotation matrix and stores it in a given matrix
  3269. * @param yaw defines the yaw angle in radians (Y axis)
  3270. * @param pitch defines the pitch angle in radians (X axis)
  3271. * @param roll defines the roll angle in radians (X axis)
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3275. /**
  3276. * Creates a scaling matrix
  3277. * @param x defines the scale factor on X axis
  3278. * @param y defines the scale factor on Y axis
  3279. * @param z defines the scale factor on Z axis
  3280. * @returns the new matrix
  3281. */
  3282. static Scaling(x: number, y: number, z: number): Matrix;
  3283. /**
  3284. * Creates a scaling matrix and stores it in a given matrix
  3285. * @param x defines the scale factor on X axis
  3286. * @param y defines the scale factor on Y axis
  3287. * @param z defines the scale factor on Z axis
  3288. * @param result defines the target matrix
  3289. */
  3290. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3291. /**
  3292. * Creates a translation matrix
  3293. * @param x defines the translation on X axis
  3294. * @param y defines the translation on Y axis
  3295. * @param z defines the translationon Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Translation(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a translation matrix and stores it in a given matrix
  3301. * @param x defines the translation on X axis
  3302. * @param y defines the translation on Y axis
  3303. * @param z defines the translationon Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3309. * @param startValue defines the start value
  3310. * @param endValue defines the end value
  3311. * @param gradient defines the gradient factor
  3312. * @returns the new matrix
  3313. */
  3314. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3315. /**
  3316. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3317. * @param startValue defines the start value
  3318. * @param endValue defines the end value
  3319. * @param gradient defines the gradient factor
  3320. * @param result defines the Matrix object where to store data
  3321. */
  3322. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3323. /**
  3324. * Builds a new matrix whose values are computed by:
  3325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3328. * @param startValue defines the first matrix
  3329. * @param endValue defines the second matrix
  3330. * @param gradient defines the gradient between the two matrices
  3331. * @returns the new matrix
  3332. */
  3333. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3334. /**
  3335. * Update a matrix to values which are computed by:
  3336. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3337. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3338. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3339. * @param startValue defines the first matrix
  3340. * @param endValue defines the second matrix
  3341. * @param gradient defines the gradient between the two matrices
  3342. * @param result defines the target matrix
  3343. */
  3344. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3345. /**
  3346. * 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"
  3347. * This function works in left handed mode
  3348. * @param eye defines the final position of the entity
  3349. * @param target defines where the entity should look at
  3350. * @param up defines the up vector for the entity
  3351. * @returns the new matrix
  3352. */
  3353. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3354. /**
  3355. * 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".
  3356. * This function works in left handed mode
  3357. * @param eye defines the final position of the entity
  3358. * @param target defines where the entity should look at
  3359. * @param up defines the up vector for the entity
  3360. * @param result defines the target matrix
  3361. */
  3362. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3363. /**
  3364. * 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"
  3365. * This function works in right handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * 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".
  3374. * This function works in right handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Create a left-handed orthographic projection matrix
  3383. * @param width defines the viewport width
  3384. * @param height defines the viewport height
  3385. * @param znear defines the near clip plane
  3386. * @param zfar defines the far clip plane
  3387. * @returns a new matrix as a left-handed orthographic projection matrix
  3388. */
  3389. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3390. /**
  3391. * Store a left-handed orthographic projection to a given matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @param result defines the target matrix
  3397. */
  3398. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param left defines the viewport left coordinate
  3402. * @param right defines the viewport right coordinate
  3403. * @param bottom defines the viewport bottom coordinate
  3404. * @param top defines the viewport top coordinate
  3405. * @param znear defines the near clip plane
  3406. * @param zfar defines the far clip plane
  3407. * @returns a new matrix as a left-handed orthographic projection matrix
  3408. */
  3409. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3410. /**
  3411. * Stores a left-handed orthographic projection into a given matrix
  3412. * @param left defines the viewport left coordinate
  3413. * @param right defines the viewport right coordinate
  3414. * @param bottom defines the viewport bottom coordinate
  3415. * @param top defines the viewport top coordinate
  3416. * @param znear defines the near clip plane
  3417. * @param zfar defines the far clip plane
  3418. * @param result defines the target matrix
  3419. */
  3420. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3421. /**
  3422. * Creates a right-handed orthographic projection matrix
  3423. * @param left defines the viewport left coordinate
  3424. * @param right defines the viewport right coordinate
  3425. * @param bottom defines the viewport bottom coordinate
  3426. * @param top defines the viewport top coordinate
  3427. * @param znear defines the near clip plane
  3428. * @param zfar defines the far clip plane
  3429. * @returns a new matrix as a right-handed orthographic projection matrix
  3430. */
  3431. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3432. /**
  3433. * Stores a right-handed orthographic projection into a given matrix
  3434. * @param left defines the viewport left coordinate
  3435. * @param right defines the viewport right coordinate
  3436. * @param bottom defines the viewport bottom coordinate
  3437. * @param top defines the viewport top coordinate
  3438. * @param znear defines the near clip plane
  3439. * @param zfar defines the far clip plane
  3440. * @param result defines the target matrix
  3441. */
  3442. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3443. /**
  3444. * Creates a left-handed perspective projection matrix
  3445. * @param width defines the viewport width
  3446. * @param height defines the viewport height
  3447. * @param znear defines the near clip plane
  3448. * @param zfar defines the far clip plane
  3449. * @returns a new matrix as a left-handed perspective projection matrix
  3450. */
  3451. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3452. /**
  3453. * Creates a left-handed perspective projection matrix
  3454. * @param fov defines the horizontal field of view
  3455. * @param aspect defines the aspect ratio
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @returns a new matrix as a left-handed perspective projection matrix
  3459. */
  3460. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3461. /**
  3462. * Stores a left-handed perspective projection into a given matrix
  3463. * @param fov defines the horizontal field of view
  3464. * @param aspect defines the aspect ratio
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @param result defines the target matrix
  3468. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3469. */
  3470. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3471. /**
  3472. * Creates a right-handed perspective projection matrix
  3473. * @param fov defines the horizontal field of view
  3474. * @param aspect defines the aspect ratio
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @returns a new matrix as a right-handed perspective projection matrix
  3478. */
  3479. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3480. /**
  3481. * Stores a right-handed perspective projection into a given matrix
  3482. * @param fov defines the horizontal field of view
  3483. * @param aspect defines the aspect ratio
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @param result defines the target matrix
  3487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3488. */
  3489. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3490. /**
  3491. * Stores a perspective projection for WebVR info a given matrix
  3492. * @param fov defines the field of view
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @param result defines the target matrix
  3496. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3497. */
  3498. static PerspectiveFovWebVRToRef(fov: {
  3499. upDegrees: number;
  3500. downDegrees: number;
  3501. leftDegrees: number;
  3502. rightDegrees: number;
  3503. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3504. /**
  3505. * Computes a complete transformation matrix
  3506. * @param viewport defines the viewport to use
  3507. * @param world defines the world matrix
  3508. * @param view defines the view matrix
  3509. * @param projection defines the projection matrix
  3510. * @param zmin defines the near clip plane
  3511. * @param zmax defines the far clip plane
  3512. * @returns the transformation matrix
  3513. */
  3514. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3515. /**
  3516. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3517. * @param matrix defines the matrix to use
  3518. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3519. */
  3520. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3521. /**
  3522. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3523. * @param matrix defines the matrix to use
  3524. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3525. */
  3526. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3527. /**
  3528. * Compute the transpose of a given matrix
  3529. * @param matrix defines the matrix to transpose
  3530. * @returns the new matrix
  3531. */
  3532. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3533. /**
  3534. * Compute the transpose of a matrix and store it in a target matrix
  3535. * @param matrix defines the matrix to transpose
  3536. * @param result defines the target matrix
  3537. */
  3538. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3539. /**
  3540. * Computes a reflection matrix from a plane
  3541. * @param plane defines the reflection plane
  3542. * @returns a new matrix
  3543. */
  3544. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3545. /**
  3546. * Computes a reflection matrix from a plane
  3547. * @param plane defines the reflection plane
  3548. * @param result defines the target matrix
  3549. */
  3550. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3551. /**
  3552. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3553. * @param xaxis defines the value of the 1st axis
  3554. * @param yaxis defines the value of the 2nd axis
  3555. * @param zaxis defines the value of the 3rd axis
  3556. * @param result defines the target matrix
  3557. */
  3558. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3559. /**
  3560. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3561. * @param quat defines the quaternion to use
  3562. * @param result defines the target matrix
  3563. */
  3564. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3565. }
  3566. /**
  3567. * Represens a plane by the equation ax + by + cz + d = 0
  3568. */
  3569. export class Plane {
  3570. /**
  3571. * Normal of the plane (a,b,c)
  3572. */
  3573. normal: Vector3;
  3574. /**
  3575. * d component of the plane
  3576. */
  3577. d: number;
  3578. /**
  3579. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3580. * @param a a component of the plane
  3581. * @param b b component of the plane
  3582. * @param c c component of the plane
  3583. * @param d d component of the plane
  3584. */
  3585. constructor(a: number, b: number, c: number, d: number);
  3586. /**
  3587. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3588. */
  3589. asArray(): number[];
  3590. /**
  3591. * @returns a new plane copied from the current Plane.
  3592. */
  3593. clone(): Plane;
  3594. /**
  3595. * @returns the string "Plane".
  3596. */
  3597. getClassName(): string;
  3598. /**
  3599. * @returns the Plane hash code.
  3600. */
  3601. getHashCode(): number;
  3602. /**
  3603. * Normalize the current Plane in place.
  3604. * @returns the updated Plane.
  3605. */
  3606. normalize(): Plane;
  3607. /**
  3608. * Applies a transformation the plane and returns the result
  3609. * @param transformation the transformation matrix to be applied to the plane
  3610. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3611. */
  3612. transform(transformation: DeepImmutable<Matrix>): Plane;
  3613. /**
  3614. * Calcualtte the dot product between the point and the plane normal
  3615. * @param point point to calculate the dot product with
  3616. * @returns the dot product (float) of the point coordinates and the plane normal.
  3617. */
  3618. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3619. /**
  3620. * Updates the current Plane from the plane defined by the three given points.
  3621. * @param point1 one of the points used to contruct the plane
  3622. * @param point2 one of the points used to contruct the plane
  3623. * @param point3 one of the points used to contruct the plane
  3624. * @returns the updated Plane.
  3625. */
  3626. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3627. /**
  3628. * Checks if the plane is facing a given direction
  3629. * @param direction the direction to check if the plane is facing
  3630. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3631. * @returns True is the vector "direction" is the same side than the plane normal.
  3632. */
  3633. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3634. /**
  3635. * Calculates the distance to a point
  3636. * @param point point to calculate distance to
  3637. * @returns the signed distance (float) from the given point to the Plane.
  3638. */
  3639. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3640. /**
  3641. * Creates a plane from an array
  3642. * @param array the array to create a plane from
  3643. * @returns a new Plane from the given array.
  3644. */
  3645. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3646. /**
  3647. * Creates a plane from three points
  3648. * @param point1 point used to create the plane
  3649. * @param point2 point used to create the plane
  3650. * @param point3 point used to create the plane
  3651. * @returns a new Plane defined by the three given points.
  3652. */
  3653. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3654. /**
  3655. * Creates a plane from an origin point and a normal
  3656. * @param origin origin of the plane to be constructed
  3657. * @param normal normal of the plane to be constructed
  3658. * @returns a new Plane the normal vector to this plane at the given origin point.
  3659. * Note : the vector "normal" is updated because normalized.
  3660. */
  3661. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3662. /**
  3663. * Calculates the distance from a plane and a point
  3664. * @param origin origin of the plane to be constructed
  3665. * @param normal normal of the plane to be constructed
  3666. * @param point point to calculate distance to
  3667. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3668. */
  3669. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3670. }
  3671. /**
  3672. * Class used to represent a viewport on screen
  3673. */
  3674. export class Viewport {
  3675. /** viewport left coordinate */
  3676. x: number;
  3677. /** viewport top coordinate */
  3678. y: number;
  3679. /**viewport width */
  3680. width: number;
  3681. /** viewport height */
  3682. height: number;
  3683. /**
  3684. * Creates a Viewport object located at (x, y) and sized (width, height)
  3685. * @param x defines viewport left coordinate
  3686. * @param y defines viewport top coordinate
  3687. * @param width defines the viewport width
  3688. * @param height defines the viewport height
  3689. */
  3690. constructor(
  3691. /** viewport left coordinate */
  3692. x: number,
  3693. /** viewport top coordinate */
  3694. y: number,
  3695. /**viewport width */
  3696. width: number,
  3697. /** viewport height */
  3698. height: number);
  3699. /**
  3700. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3701. * @param renderWidth defines the rendering width
  3702. * @param renderHeight defines the rendering height
  3703. * @returns a new Viewport
  3704. */
  3705. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3706. /**
  3707. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3708. * @param renderWidth defines the rendering width
  3709. * @param renderHeight defines the rendering height
  3710. * @param ref defines the target viewport
  3711. * @returns the current viewport
  3712. */
  3713. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3714. /**
  3715. * Returns a new Viewport copied from the current one
  3716. * @returns a new Viewport
  3717. */
  3718. clone(): Viewport;
  3719. }
  3720. /**
  3721. * Reprasents a camera frustum
  3722. */
  3723. export class Frustum {
  3724. /**
  3725. * Gets the planes representing the frustum
  3726. * @param transform matrix to be applied to the returned planes
  3727. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3728. */
  3729. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3730. /**
  3731. * Gets the near frustum plane transformed by the transform matrix
  3732. * @param transform transformation matrix to be applied to the resulting frustum plane
  3733. * @param frustumPlane the resuling frustum plane
  3734. */
  3735. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3736. /**
  3737. * Gets the far frustum plane transformed by the transform matrix
  3738. * @param transform transformation matrix to be applied to the resulting frustum plane
  3739. * @param frustumPlane the resuling frustum plane
  3740. */
  3741. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3742. /**
  3743. * Gets the left frustum plane transformed by the transform matrix
  3744. * @param transform transformation matrix to be applied to the resulting frustum plane
  3745. * @param frustumPlane the resuling frustum plane
  3746. */
  3747. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3748. /**
  3749. * Gets the right frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the top frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the bottom frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3768. * @param transform transformation matrix to be applied to the resulting frustum planes
  3769. * @param frustumPlanes the resuling frustum planes
  3770. */
  3771. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3772. }
  3773. /** Defines supported spaces */
  3774. export enum Space {
  3775. /** Local (object) space */
  3776. LOCAL = 0,
  3777. /** World space */
  3778. WORLD = 1,
  3779. /** Bone space */
  3780. BONE = 2
  3781. }
  3782. /** Defines the 3 main axes */
  3783. export class Axis {
  3784. /** X axis */
  3785. static X: Vector3;
  3786. /** Y axis */
  3787. static Y: Vector3;
  3788. /** Z axis */
  3789. static Z: Vector3;
  3790. }
  3791. /** Class used to represent a Bezier curve */
  3792. export class BezierCurve {
  3793. /**
  3794. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3795. * @param t defines the time
  3796. * @param x1 defines the left coordinate on X axis
  3797. * @param y1 defines the left coordinate on Y axis
  3798. * @param x2 defines the right coordinate on X axis
  3799. * @param y2 defines the right coordinate on Y axis
  3800. * @returns the interpolated value
  3801. */
  3802. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3803. }
  3804. /**
  3805. * Defines potential orientation for back face culling
  3806. */
  3807. export enum Orientation {
  3808. /**
  3809. * Clockwise
  3810. */
  3811. CW = 0,
  3812. /** Counter clockwise */
  3813. CCW = 1
  3814. }
  3815. /**
  3816. * Defines angle representation
  3817. */
  3818. export class Angle {
  3819. private _radians;
  3820. /**
  3821. * Creates an Angle object of "radians" radians (float).
  3822. * @param radians the angle in radians
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * 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.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module BABYLON {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * A class serves as a medium between the observable and its observers
  4201. */
  4202. export class EventState {
  4203. /**
  4204. * Create a new EventState
  4205. * @param mask defines the mask associated with this state
  4206. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4207. * @param target defines the original target of the state
  4208. * @param currentTarget defines the current target of the state
  4209. */
  4210. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4211. /**
  4212. * Initialize the current event state
  4213. * @param mask defines the mask associated with this state
  4214. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4215. * @param target defines the original target of the state
  4216. * @param currentTarget defines the current target of the state
  4217. * @returns the current event state
  4218. */
  4219. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4220. /**
  4221. * An Observer can set this property to true to prevent subsequent observers of being notified
  4222. */
  4223. skipNextObservers: boolean;
  4224. /**
  4225. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4226. */
  4227. mask: number;
  4228. /**
  4229. * The object that originally notified the event
  4230. */
  4231. target?: any;
  4232. /**
  4233. * The current object in the bubbling phase
  4234. */
  4235. currentTarget?: any;
  4236. /**
  4237. * This will be populated with the return value of the last function that was executed.
  4238. * If it is the first function in the callback chain it will be the event data.
  4239. */
  4240. lastReturnValue?: any;
  4241. }
  4242. /**
  4243. * Represent an Observer registered to a given Observable object.
  4244. */
  4245. export class Observer<T> {
  4246. /**
  4247. * Defines the callback to call when the observer is notified
  4248. */
  4249. callback: (eventData: T, eventState: EventState) => void;
  4250. /**
  4251. * Defines the mask of the observer (used to filter notifications)
  4252. */
  4253. mask: number;
  4254. /**
  4255. * Defines the current scope used to restore the JS context
  4256. */
  4257. scope: any;
  4258. /** @hidden */
  4259. _willBeUnregistered: boolean;
  4260. /**
  4261. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4262. */
  4263. unregisterOnNextCall: boolean;
  4264. /**
  4265. * Creates a new observer
  4266. * @param callback defines the callback to call when the observer is notified
  4267. * @param mask defines the mask of the observer (used to filter notifications)
  4268. * @param scope defines the current scope used to restore the JS context
  4269. */
  4270. constructor(
  4271. /**
  4272. * Defines the callback to call when the observer is notified
  4273. */
  4274. callback: (eventData: T, eventState: EventState) => void,
  4275. /**
  4276. * Defines the mask of the observer (used to filter notifications)
  4277. */
  4278. mask: number,
  4279. /**
  4280. * Defines the current scope used to restore the JS context
  4281. */
  4282. scope?: any);
  4283. }
  4284. /**
  4285. * Represent a list of observers registered to multiple Observables object.
  4286. */
  4287. export class MultiObserver<T> {
  4288. private _observers;
  4289. private _observables;
  4290. /**
  4291. * Release associated resources
  4292. */
  4293. dispose(): void;
  4294. /**
  4295. * Raise a callback when one of the observable will notify
  4296. * @param observables defines a list of observables to watch
  4297. * @param callback defines the callback to call on notification
  4298. * @param mask defines the mask used to filter notifications
  4299. * @param scope defines the current scope used to restore the JS context
  4300. * @returns the new MultiObserver
  4301. */
  4302. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4303. }
  4304. /**
  4305. * The Observable class is a simple implementation of the Observable pattern.
  4306. *
  4307. * 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.
  4308. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4309. * 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).
  4310. * 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.
  4311. */
  4312. export class Observable<T> {
  4313. private _observers;
  4314. private _eventState;
  4315. private _onObserverAdded;
  4316. /**
  4317. * Creates a new observable
  4318. * @param onObserverAdded defines a callback to call when a new observer is added
  4319. */
  4320. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4321. /**
  4322. * Create a new Observer with the specified callback
  4323. * @param callback the callback that will be executed for that Observer
  4324. * @param mask the mask used to filter observers
  4325. * @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.
  4326. * @param scope optional scope for the callback to be called from
  4327. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4328. * @returns the new observer created for the callback
  4329. */
  4330. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4331. /**
  4332. * Create a new Observer with the specified callback and unregisters after the next notification
  4333. * @param callback the callback that will be executed for that Observer
  4334. * @returns the new observer created for the callback
  4335. */
  4336. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4337. /**
  4338. * Remove an Observer from the Observable object
  4339. * @param observer the instance of the Observer to remove
  4340. * @returns false if it doesn't belong to this Observable
  4341. */
  4342. remove(observer: Nullable<Observer<T>>): boolean;
  4343. /**
  4344. * Remove a callback from the Observable object
  4345. * @param callback the callback to remove
  4346. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4347. * @returns false if it doesn't belong to this Observable
  4348. */
  4349. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4350. private _deferUnregister;
  4351. private _remove;
  4352. /**
  4353. * Moves the observable to the top of the observer list making it get called first when notified
  4354. * @param observer the observer to move
  4355. */
  4356. makeObserverTopPriority(observer: Observer<T>): void;
  4357. /**
  4358. * Moves the observable to the bottom of the observer list making it get called last when notified
  4359. * @param observer the observer to move
  4360. */
  4361. makeObserverBottomPriority(observer: Observer<T>): void;
  4362. /**
  4363. * Notify all Observers by calling their respective callback with the given data
  4364. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4365. * @param eventData defines the data to send to all observers
  4366. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4367. * @param target defines the original target of the state
  4368. * @param currentTarget defines the current target of the state
  4369. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4370. */
  4371. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4372. /**
  4373. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4374. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4375. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4376. * and it is crucial that all callbacks will be executed.
  4377. * The order of the callbacks is kept, callbacks are not executed parallel.
  4378. *
  4379. * @param eventData The data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. * @param target defines the callback target (see EventState)
  4382. * @param currentTarget defines he current object in the bubbling phase
  4383. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4384. */
  4385. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4386. /**
  4387. * Notify a specific observer
  4388. * @param observer defines the observer to notify
  4389. * @param eventData defines the data to be sent to each callback
  4390. * @param mask is used to filter observers defaults to -1
  4391. */
  4392. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4393. /**
  4394. * Gets a boolean indicating if the observable has at least one observer
  4395. * @returns true is the Observable has at least one Observer registered
  4396. */
  4397. hasObservers(): boolean;
  4398. /**
  4399. * Clear the list of observers
  4400. */
  4401. clear(): void;
  4402. /**
  4403. * Clone the current observable
  4404. * @returns a new observable
  4405. */
  4406. clone(): Observable<T>;
  4407. /**
  4408. * Does this observable handles observer registered with a given mask
  4409. * @param mask defines the mask to be tested
  4410. * @return whether or not one observer registered with the given mask is handeled
  4411. **/
  4412. hasSpecificMask(mask?: number): boolean;
  4413. }
  4414. }
  4415. declare module BABYLON {
  4416. /**
  4417. * Class used to help managing file picking and drag'n'drop
  4418. * File Storage
  4419. */
  4420. export class FilesInputStore {
  4421. /**
  4422. * List of files ready to be loaded
  4423. */
  4424. static FilesToLoad: {
  4425. [key: string]: File;
  4426. };
  4427. }
  4428. }
  4429. declare module BABYLON {
  4430. /** Defines the cross module used constants to avoid circular dependncies */
  4431. export class Constants {
  4432. /** Defines that alpha blending is disabled */
  4433. static readonly ALPHA_DISABLE: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4435. static readonly ALPHA_ADD: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_COMBINE: number;
  4438. /** Defines that alpha blending to DEST - SRC * DEST */
  4439. static readonly ALPHA_SUBTRACT: number;
  4440. /** Defines that alpha blending to SRC * DEST */
  4441. static readonly ALPHA_MULTIPLY: number;
  4442. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4443. static readonly ALPHA_MAXIMIZED: number;
  4444. /** Defines that alpha blending to SRC + DEST */
  4445. static readonly ALPHA_ONEONE: number;
  4446. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4447. static readonly ALPHA_PREMULTIPLIED: number;
  4448. /**
  4449. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4450. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4451. */
  4452. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4453. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4454. static readonly ALPHA_INTERPOLATE: number;
  4455. /**
  4456. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4457. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4458. */
  4459. static readonly ALPHA_SCREENMODE: number;
  4460. /** Defines that the ressource is not delayed*/
  4461. static readonly DELAYLOADSTATE_NONE: number;
  4462. /** Defines that the ressource was successfully delay loaded */
  4463. static readonly DELAYLOADSTATE_LOADED: number;
  4464. /** Defines that the ressource is currently delay loading */
  4465. static readonly DELAYLOADSTATE_LOADING: number;
  4466. /** Defines that the ressource is delayed and has not started loading */
  4467. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4469. static readonly NEVER: number;
  4470. /** 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 */
  4471. static readonly ALWAYS: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4473. static readonly LESS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4475. static readonly EQUAL: number;
  4476. /** 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 */
  4477. static readonly LEQUAL: number;
  4478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4479. static readonly GREATER: number;
  4480. /** 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 */
  4481. static readonly GEQUAL: number;
  4482. /** 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 */
  4483. static readonly NOTEQUAL: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be kept */
  4485. static readonly KEEP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4487. static readonly REPLACE: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4489. static readonly INCR: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4491. static readonly DECR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4493. static readonly INVERT: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4495. static readonly INCR_WRAP: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4497. static readonly DECR_WRAP: number;
  4498. /** Texture is not repeating outside of 0..1 UVs */
  4499. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4500. /** Texture is repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4502. /** Texture is repeating and mirrored */
  4503. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4504. /** ALPHA */
  4505. static readonly TEXTUREFORMAT_ALPHA: number;
  4506. /** LUMINANCE */
  4507. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4508. /** LUMINANCE_ALPHA */
  4509. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4510. /** RGB */
  4511. static readonly TEXTUREFORMAT_RGB: number;
  4512. /** RGBA */
  4513. static readonly TEXTUREFORMAT_RGBA: number;
  4514. /** RED */
  4515. static readonly TEXTUREFORMAT_RED: number;
  4516. /** RED (2nd reference) */
  4517. static readonly TEXTUREFORMAT_R: number;
  4518. /** RG */
  4519. static readonly TEXTUREFORMAT_RG: number;
  4520. /** RED_INTEGER */
  4521. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4522. /** RED_INTEGER (2nd reference) */
  4523. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4524. /** RG_INTEGER */
  4525. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4526. /** RGB_INTEGER */
  4527. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4528. /** RGBA_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4530. /** UNSIGNED_BYTE */
  4531. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4532. /** UNSIGNED_BYTE (2nd reference) */
  4533. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4534. /** FLOAT */
  4535. static readonly TEXTURETYPE_FLOAT: number;
  4536. /** HALF_FLOAT */
  4537. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4538. /** BYTE */
  4539. static readonly TEXTURETYPE_BYTE: number;
  4540. /** SHORT */
  4541. static readonly TEXTURETYPE_SHORT: number;
  4542. /** UNSIGNED_SHORT */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4544. /** INT */
  4545. static readonly TEXTURETYPE_INT: number;
  4546. /** UNSIGNED_INT */
  4547. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4548. /** UNSIGNED_SHORT_4_4_4_4 */
  4549. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4550. /** UNSIGNED_SHORT_5_5_5_1 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4552. /** UNSIGNED_SHORT_5_6_5 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4554. /** UNSIGNED_INT_2_10_10_10_REV */
  4555. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4556. /** UNSIGNED_INT_24_8 */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4558. /** UNSIGNED_INT_10F_11F_11F_REV */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4560. /** UNSIGNED_INT_5_9_9_9_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4562. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4563. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4564. /** nearest is mag = nearest and min = nearest and mip = linear */
  4565. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4567. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4568. /** Trilinear is mag = linear and min = linear and mip = linear */
  4569. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4570. /** nearest is mag = nearest and min = nearest and mip = linear */
  4571. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4572. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4573. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4574. /** Trilinear is mag = linear and min = linear and mip = linear */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4578. /** mag = nearest and min = linear and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = linear */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4582. /** mag = nearest and min = linear and mip = none */
  4583. static readonly TEXTURE_NEAREST_LINEAR: number;
  4584. /** mag = nearest and min = nearest and mip = none */
  4585. static readonly TEXTURE_NEAREST_NEAREST: number;
  4586. /** mag = linear and min = nearest and mip = nearest */
  4587. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4588. /** mag = linear and min = nearest and mip = linear */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4590. /** mag = linear and min = linear and mip = none */
  4591. static readonly TEXTURE_LINEAR_LINEAR: number;
  4592. /** mag = linear and min = nearest and mip = none */
  4593. static readonly TEXTURE_LINEAR_NEAREST: number;
  4594. /** Explicit coordinates mode */
  4595. static readonly TEXTURE_EXPLICIT_MODE: number;
  4596. /** Spherical coordinates mode */
  4597. static readonly TEXTURE_SPHERICAL_MODE: number;
  4598. /** Planar coordinates mode */
  4599. static readonly TEXTURE_PLANAR_MODE: number;
  4600. /** Cubic coordinates mode */
  4601. static readonly TEXTURE_CUBIC_MODE: number;
  4602. /** Projection coordinates mode */
  4603. static readonly TEXTURE_PROJECTION_MODE: number;
  4604. /** Skybox coordinates mode */
  4605. static readonly TEXTURE_SKYBOX_MODE: number;
  4606. /** Inverse Cubic coordinates mode */
  4607. static readonly TEXTURE_INVCUBIC_MODE: number;
  4608. /** Equirectangular coordinates mode */
  4609. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4610. /** Equirectangular Fixed coordinates mode */
  4611. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed Mirrored coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4614. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4615. static readonly SCALEMODE_FLOOR: number;
  4616. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4617. static readonly SCALEMODE_NEAREST: number;
  4618. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4619. static readonly SCALEMODE_CEILING: number;
  4620. /**
  4621. * The dirty texture flag value
  4622. */
  4623. static readonly MATERIAL_TextureDirtyFlag: number;
  4624. /**
  4625. * The dirty light flag value
  4626. */
  4627. static readonly MATERIAL_LightDirtyFlag: number;
  4628. /**
  4629. * The dirty fresnel flag value
  4630. */
  4631. static readonly MATERIAL_FresnelDirtyFlag: number;
  4632. /**
  4633. * The dirty attribute flag value
  4634. */
  4635. static readonly MATERIAL_AttributesDirtyFlag: number;
  4636. /**
  4637. * The dirty misc flag value
  4638. */
  4639. static readonly MATERIAL_MiscDirtyFlag: number;
  4640. /**
  4641. * The all dirty flag value
  4642. */
  4643. static readonly MATERIAL_AllDirtyFlag: number;
  4644. /**
  4645. * Returns the triangle fill mode
  4646. */
  4647. static readonly MATERIAL_TriangleFillMode: number;
  4648. /**
  4649. * Returns the wireframe mode
  4650. */
  4651. static readonly MATERIAL_WireFrameFillMode: number;
  4652. /**
  4653. * Returns the point fill mode
  4654. */
  4655. static readonly MATERIAL_PointFillMode: number;
  4656. /**
  4657. * Returns the point list draw mode
  4658. */
  4659. static readonly MATERIAL_PointListDrawMode: number;
  4660. /**
  4661. * Returns the line list draw mode
  4662. */
  4663. static readonly MATERIAL_LineListDrawMode: number;
  4664. /**
  4665. * Returns the line loop draw mode
  4666. */
  4667. static readonly MATERIAL_LineLoopDrawMode: number;
  4668. /**
  4669. * Returns the line strip draw mode
  4670. */
  4671. static readonly MATERIAL_LineStripDrawMode: number;
  4672. /**
  4673. * Returns the triangle strip draw mode
  4674. */
  4675. static readonly MATERIAL_TriangleStripDrawMode: number;
  4676. /**
  4677. * Returns the triangle fan draw mode
  4678. */
  4679. static readonly MATERIAL_TriangleFanDrawMode: number;
  4680. /**
  4681. * Stores the clock-wise side orientation
  4682. */
  4683. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4684. /**
  4685. * Stores the counter clock-wise side orientation
  4686. */
  4687. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4688. /**
  4689. * Nothing
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_NothingTrigger: number;
  4693. /**
  4694. * On pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnPickTrigger: number;
  4698. /**
  4699. * On left pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnLeftPickTrigger: number;
  4703. /**
  4704. * On right pick
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnRightPickTrigger: number;
  4708. /**
  4709. * On center pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnCenterPickTrigger: number;
  4713. /**
  4714. * On pick down
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickDownTrigger: number;
  4718. /**
  4719. * On double pick
  4720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4721. */
  4722. static readonly ACTION_OnDoublePickTrigger: number;
  4723. /**
  4724. * On pick up
  4725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4726. */
  4727. static readonly ACTION_OnPickUpTrigger: number;
  4728. /**
  4729. * On pick out.
  4730. * This trigger will only be raised if you also declared a OnPickDown
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickOutTrigger: number;
  4734. /**
  4735. * On long press
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnLongPressTrigger: number;
  4739. /**
  4740. * On pointer over
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPointerOverTrigger: number;
  4744. /**
  4745. * On pointer out
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnPointerOutTrigger: number;
  4749. /**
  4750. * On every frame
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnEveryFrameTrigger: number;
  4754. /**
  4755. * On intersection enter
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4759. /**
  4760. * On intersection exit
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnIntersectionExitTrigger: number;
  4764. /**
  4765. * On key down
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnKeyDownTrigger: number;
  4769. /**
  4770. * On key up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnKeyUpTrigger: number;
  4774. /**
  4775. * Billboard mode will only apply to Y axis
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4778. /**
  4779. * Billboard mode will apply to all axes
  4780. */
  4781. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4782. /**
  4783. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4784. */
  4785. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4786. /**
  4787. * Gets or sets base Assets URL
  4788. */
  4789. static readonly PARTICLES_BaseAssetsUrl: string;
  4790. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4791. * Test order :
  4792. * Is the bounding sphere outside the frustum ?
  4793. * If not, are the bounding box vertices outside the frustum ?
  4794. * It not, then the cullable object is in the frustum.
  4795. */
  4796. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4797. /** Culling strategy : Bounding Sphere Only.
  4798. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4799. * It's also less accurate than the standard because some not visible objects can still be selected.
  4800. * Test : is the bounding sphere outside the frustum ?
  4801. * If not, then the cullable object is in the frustum.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4804. /** Culling strategy : Optimistic Inclusion.
  4805. * This in an inclusion test first, then the standard exclusion test.
  4806. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4807. * 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.
  4808. * Anyway, it's as accurate as the standard strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the default culling strategy.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4814. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4815. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4816. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4817. * 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.
  4818. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4819. * Test :
  4820. * Is the cullable object bounding sphere center in the frustum ?
  4821. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4822. */
  4823. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4824. /**
  4825. * No logging while loading
  4826. */
  4827. static readonly SCENELOADER_NO_LOGGING: number;
  4828. /**
  4829. * Minimal logging while loading
  4830. */
  4831. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4832. /**
  4833. * Summary logging while loading
  4834. */
  4835. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4836. /**
  4837. * Detailled logging while loading
  4838. */
  4839. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4840. }
  4841. }
  4842. declare module BABYLON {
  4843. /**
  4844. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4845. * Babylon.js
  4846. */
  4847. export class DomManagement {
  4848. /**
  4849. * Checks if the window object exists
  4850. * @returns true if the window object exists
  4851. */
  4852. static IsWindowObjectExist(): boolean;
  4853. /**
  4854. * Extracts text content from a DOM element hierarchy
  4855. * @param element defines the root element
  4856. * @returns a string
  4857. */
  4858. static GetDOMTextContent(element: HTMLElement): string;
  4859. }
  4860. }
  4861. declare module BABYLON {
  4862. /**
  4863. * Logger used througouht the application to allow configuration of
  4864. * the log level required for the messages.
  4865. */
  4866. export class Logger {
  4867. /**
  4868. * No log
  4869. */
  4870. static readonly NoneLogLevel: number;
  4871. /**
  4872. * Only message logs
  4873. */
  4874. static readonly MessageLogLevel: number;
  4875. /**
  4876. * Only warning logs
  4877. */
  4878. static readonly WarningLogLevel: number;
  4879. /**
  4880. * Only error logs
  4881. */
  4882. static readonly ErrorLogLevel: number;
  4883. /**
  4884. * All logs
  4885. */
  4886. static readonly AllLogLevel: number;
  4887. private static _LogCache;
  4888. /**
  4889. * Gets a value indicating the number of loading errors
  4890. * @ignorenaming
  4891. */
  4892. static errorsCount: number;
  4893. /**
  4894. * Callback called when a new log is added
  4895. */
  4896. static OnNewCacheEntry: (entry: string) => void;
  4897. private static _AddLogEntry;
  4898. private static _FormatMessage;
  4899. private static _LogDisabled;
  4900. private static _LogEnabled;
  4901. private static _WarnDisabled;
  4902. private static _WarnEnabled;
  4903. private static _ErrorDisabled;
  4904. private static _ErrorEnabled;
  4905. /**
  4906. * Log a message to the console
  4907. */
  4908. static Log: (message: string) => void;
  4909. /**
  4910. * Write a warning message to the console
  4911. */
  4912. static Warn: (message: string) => void;
  4913. /**
  4914. * Write an error message to the console
  4915. */
  4916. static Error: (message: string) => void;
  4917. /**
  4918. * Gets current log cache (list of logs)
  4919. */
  4920. static readonly LogCache: string;
  4921. /**
  4922. * Clears the log cache
  4923. */
  4924. static ClearLogCache(): void;
  4925. /**
  4926. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4927. */
  4928. static LogLevels: number;
  4929. }
  4930. }
  4931. declare module BABYLON {
  4932. /** @hidden */
  4933. export class _TypeStore {
  4934. /** @hidden */
  4935. static RegisteredTypes: {
  4936. [key: string]: Object;
  4937. };
  4938. /** @hidden */
  4939. static GetClass(fqdn: string): any;
  4940. }
  4941. }
  4942. declare module BABYLON {
  4943. /**
  4944. * Class containing a set of static utilities functions for deep copy.
  4945. */
  4946. export class DeepCopier {
  4947. /**
  4948. * Tries to copy an object by duplicating every property
  4949. * @param source defines the source object
  4950. * @param destination defines the target object
  4951. * @param doNotCopyList defines a list of properties to avoid
  4952. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4953. */
  4954. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4955. }
  4956. }
  4957. declare module BABYLON {
  4958. /**
  4959. * Class containing a set of static utilities functions for precision date
  4960. */
  4961. export class PrecisionDate {
  4962. /**
  4963. * Gets either window.performance.now() if supported or Date.now() else
  4964. */
  4965. static readonly Now: number;
  4966. }
  4967. }
  4968. declare module BABYLON {
  4969. /** @hidden */
  4970. export class _DevTools {
  4971. static WarnImport(name: string): string;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /**
  4976. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4977. */
  4978. export class WebRequest {
  4979. private _xhr;
  4980. /**
  4981. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4982. * i.e. when loading files, where the server/service expects an Authorization header
  4983. */
  4984. static CustomRequestHeaders: {
  4985. [key: string]: string;
  4986. };
  4987. /**
  4988. * Add callback functions in this array to update all the requests before they get sent to the network
  4989. */
  4990. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4991. private _injectCustomRequestHeaders;
  4992. /**
  4993. * Gets or sets a function to be called when loading progress changes
  4994. */
  4995. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4996. /**
  4997. * Returns client's state
  4998. */
  4999. readonly readyState: number;
  5000. /**
  5001. * Returns client's status
  5002. */
  5003. readonly status: number;
  5004. /**
  5005. * Returns client's status as a text
  5006. */
  5007. readonly statusText: string;
  5008. /**
  5009. * Returns client's response
  5010. */
  5011. readonly response: any;
  5012. /**
  5013. * Returns client's response url
  5014. */
  5015. readonly responseURL: string;
  5016. /**
  5017. * Returns client's response as text
  5018. */
  5019. readonly responseText: string;
  5020. /**
  5021. * Gets or sets the expected response type
  5022. */
  5023. responseType: XMLHttpRequestResponseType;
  5024. /** @hidden */
  5025. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5026. /** @hidden */
  5027. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5028. /**
  5029. * Cancels any network activity
  5030. */
  5031. abort(): void;
  5032. /**
  5033. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5034. * @param body defines an optional request body
  5035. */
  5036. send(body?: Document | BodyInit | null): void;
  5037. /**
  5038. * Sets the request method, request URL
  5039. * @param method defines the method to use (GET, POST, etc..)
  5040. * @param url defines the url to connect with
  5041. */
  5042. open(method: string, url: string): void;
  5043. }
  5044. }
  5045. declare module BABYLON {
  5046. /**
  5047. * Class used to evalaute queries containing `and` and `or` operators
  5048. */
  5049. export class AndOrNotEvaluator {
  5050. /**
  5051. * Evaluate a query
  5052. * @param query defines the query to evaluate
  5053. * @param evaluateCallback defines the callback used to filter result
  5054. * @returns true if the query matches
  5055. */
  5056. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5057. private static _HandleParenthesisContent;
  5058. private static _SimplifyNegation;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to store custom tags
  5064. */
  5065. export class Tags {
  5066. /**
  5067. * Adds support for tags on the given object
  5068. * @param obj defines the object to use
  5069. */
  5070. static EnableFor(obj: any): void;
  5071. /**
  5072. * Removes tags support
  5073. * @param obj defines the object to use
  5074. */
  5075. static DisableFor(obj: any): void;
  5076. /**
  5077. * Gets a boolean indicating if the given object has tags
  5078. * @param obj defines the object to use
  5079. * @returns a boolean
  5080. */
  5081. static HasTags(obj: any): boolean;
  5082. /**
  5083. * Gets the tags available on a given object
  5084. * @param obj defines the object to use
  5085. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5086. * @returns the tags
  5087. */
  5088. static GetTags(obj: any, asString?: boolean): any;
  5089. /**
  5090. * Adds tags to an object
  5091. * @param obj defines the object to use
  5092. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5093. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5094. */
  5095. static AddTagsTo(obj: any, tagsString: string): void;
  5096. /**
  5097. * @hidden
  5098. */
  5099. static _AddTagTo(obj: any, tag: string): void;
  5100. /**
  5101. * Removes specific tags from a specific object
  5102. * @param obj defines the object to use
  5103. * @param tagsString defines the tags to remove
  5104. */
  5105. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5106. /**
  5107. * @hidden
  5108. */
  5109. static _RemoveTagFrom(obj: any, tag: string): void;
  5110. /**
  5111. * Defines if tags hosted on an object match a given query
  5112. * @param obj defines the object to use
  5113. * @param tagsQuery defines the tag query
  5114. * @returns a boolean
  5115. */
  5116. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5117. }
  5118. }
  5119. declare module BABYLON {
  5120. /**
  5121. * Manages the defines for the Material
  5122. */
  5123. export class MaterialDefines {
  5124. private _keys;
  5125. private _isDirty;
  5126. /** @hidden */
  5127. _renderId: number;
  5128. /** @hidden */
  5129. _areLightsDirty: boolean;
  5130. /** @hidden */
  5131. _areAttributesDirty: boolean;
  5132. /** @hidden */
  5133. _areTexturesDirty: boolean;
  5134. /** @hidden */
  5135. _areFresnelDirty: boolean;
  5136. /** @hidden */
  5137. _areMiscDirty: boolean;
  5138. /** @hidden */
  5139. _areImageProcessingDirty: boolean;
  5140. /** @hidden */
  5141. _normals: boolean;
  5142. /** @hidden */
  5143. _uvs: boolean;
  5144. /** @hidden */
  5145. _needNormals: boolean;
  5146. /** @hidden */
  5147. _needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5217. */
  5218. export class PerformanceMonitor {
  5219. private _enabled;
  5220. private _rollingFrameTime;
  5221. private _lastFrameTimeMs;
  5222. /**
  5223. * constructor
  5224. * @param frameSampleSize The number of samples required to saturate the sliding window
  5225. */
  5226. constructor(frameSampleSize?: number);
  5227. /**
  5228. * Samples current frame
  5229. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5230. */
  5231. sampleFrame(timeMs?: number): void;
  5232. /**
  5233. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5234. */
  5235. readonly averageFrameTime: number;
  5236. /**
  5237. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFrameTimeVariance: number;
  5240. /**
  5241. * Returns the frame time of the most recent frame
  5242. */
  5243. readonly instantaneousFrameTime: number;
  5244. /**
  5245. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5246. */
  5247. readonly averageFPS: number;
  5248. /**
  5249. * Returns the average framerate in frames per second using the most recent frame time
  5250. */
  5251. readonly instantaneousFPS: number;
  5252. /**
  5253. * Returns true if enough samples have been taken to completely fill the sliding window
  5254. */
  5255. readonly isSaturated: boolean;
  5256. /**
  5257. * Enables contributions to the sliding window sample set
  5258. */
  5259. enable(): void;
  5260. /**
  5261. * Disables contributions to the sliding window sample set
  5262. * Samples will not be interpolated over the disabled period
  5263. */
  5264. disable(): void;
  5265. /**
  5266. * Returns true if sampling is enabled
  5267. */
  5268. readonly isEnabled: boolean;
  5269. /**
  5270. * Resets performance monitor
  5271. */
  5272. reset(): void;
  5273. }
  5274. /**
  5275. * RollingAverage
  5276. *
  5277. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5278. */
  5279. export class RollingAverage {
  5280. /**
  5281. * Current average
  5282. */
  5283. average: number;
  5284. /**
  5285. * Current variance
  5286. */
  5287. variance: number;
  5288. protected _samples: Array<number>;
  5289. protected _sampleCount: number;
  5290. protected _pos: number;
  5291. protected _m2: number;
  5292. /**
  5293. * constructor
  5294. * @param length The number of samples required to saturate the sliding window
  5295. */
  5296. constructor(length: number);
  5297. /**
  5298. * Adds a sample to the sample set
  5299. * @param v The sample value
  5300. */
  5301. add(v: number): void;
  5302. /**
  5303. * Returns previously added values or null if outside of history or outside the sliding window domain
  5304. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5305. * @return Value previously recorded with add() or null if outside of range
  5306. */
  5307. history(i: number): number;
  5308. /**
  5309. * Returns true if enough samples have been taken to completely fill the sliding window
  5310. * @return true if sample-set saturated
  5311. */
  5312. isSaturated(): boolean;
  5313. /**
  5314. * Resets the rolling average (equivalent to 0 samples taken so far)
  5315. */
  5316. reset(): void;
  5317. /**
  5318. * Wraps a value around the sample range boundaries
  5319. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5320. * @return Wrapped position in sample range
  5321. */
  5322. protected _wrapPosition(i: number): number;
  5323. }
  5324. }
  5325. declare module BABYLON {
  5326. /**
  5327. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5328. * The underlying implementation relies on an associative array to ensure the best performances.
  5329. * The value can be anything including 'null' but except 'undefined'
  5330. */
  5331. export class StringDictionary<T> {
  5332. /**
  5333. * This will clear this dictionary and copy the content from the 'source' one.
  5334. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5335. * @param source the dictionary to take the content from and copy to this dictionary
  5336. */
  5337. copyFrom(source: StringDictionary<T>): void;
  5338. /**
  5339. * Get a value based from its key
  5340. * @param key the given key to get the matching value from
  5341. * @return the value if found, otherwise undefined is returned
  5342. */
  5343. get(key: string): T | undefined;
  5344. /**
  5345. * Get a value from its key or add it if it doesn't exist.
  5346. * This method will ensure you that a given key/data will be present in the dictionary.
  5347. * @param key the given key to get the matching value from
  5348. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5349. * The factory will only be invoked if there's no data for the given key.
  5350. * @return the value corresponding to the key.
  5351. */
  5352. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5353. /**
  5354. * Get a value from its key if present in the dictionary otherwise add it
  5355. * @param key the key to get the value from
  5356. * @param val if there's no such key/value pair in the dictionary add it with this value
  5357. * @return the value corresponding to the key
  5358. */
  5359. getOrAdd(key: string, val: T): T;
  5360. /**
  5361. * Check if there's a given key in the dictionary
  5362. * @param key the key to check for
  5363. * @return true if the key is present, false otherwise
  5364. */
  5365. contains(key: string): boolean;
  5366. /**
  5367. * Add a new key and its corresponding value
  5368. * @param key the key to add
  5369. * @param value the value corresponding to the key
  5370. * @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
  5371. */
  5372. add(key: string, value: T): boolean;
  5373. /**
  5374. * Update a specific value associated to a key
  5375. * @param key defines the key to use
  5376. * @param value defines the value to store
  5377. * @returns true if the value was updated (or false if the key was not found)
  5378. */
  5379. set(key: string, value: T): boolean;
  5380. /**
  5381. * Get the element of the given key and remove it from the dictionary
  5382. * @param key defines the key to search
  5383. * @returns the value associated with the key or null if not found
  5384. */
  5385. getAndRemove(key: string): Nullable<T>;
  5386. /**
  5387. * Remove a key/value from the dictionary.
  5388. * @param key the key to remove
  5389. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5390. */
  5391. remove(key: string): boolean;
  5392. /**
  5393. * Clear the whole content of the dictionary
  5394. */
  5395. clear(): void;
  5396. /**
  5397. * Gets the current count
  5398. */
  5399. readonly count: number;
  5400. /**
  5401. * Execute a callback on each key/val of the dictionary.
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute on a given key/value pair
  5404. */
  5405. forEach(callback: (key: string, val: T) => void): void;
  5406. /**
  5407. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5408. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5409. * Note that you can remove any element in this dictionary in the callback implementation
  5410. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5411. * @returns the first item
  5412. */
  5413. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5414. private _count;
  5415. private _data;
  5416. }
  5417. }
  5418. declare module BABYLON {
  5419. /**
  5420. * Helper class that provides a small promise polyfill
  5421. */
  5422. export class PromisePolyfill {
  5423. /**
  5424. * Static function used to check if the polyfill is required
  5425. * If this is the case then the function will inject the polyfill to window.Promise
  5426. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5427. */
  5428. static Apply(force?: boolean): void;
  5429. }
  5430. }
  5431. declare module BABYLON {
  5432. /**
  5433. * Class used to store data that will be store in GPU memory
  5434. */
  5435. export class Buffer {
  5436. private _engine;
  5437. private _buffer;
  5438. /** @hidden */
  5439. _data: Nullable<DataArray>;
  5440. private _updatable;
  5441. private _instanced;
  5442. /**
  5443. * Gets the byte stride.
  5444. */
  5445. readonly byteStride: number;
  5446. /**
  5447. * Constructor
  5448. * @param engine the engine
  5449. * @param data the data to use for this buffer
  5450. * @param updatable whether the data is updatable
  5451. * @param stride the stride (optional)
  5452. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5453. * @param instanced whether the buffer is instanced (optional)
  5454. * @param useBytes set to true if the stride in in bytes (optional)
  5455. */
  5456. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5457. /**
  5458. * Create a new VertexBuffer based on the current buffer
  5459. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5460. * @param offset defines offset in the buffer (0 by default)
  5461. * @param size defines the size in floats of attributes (position is 3 for instance)
  5462. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5463. * @param instanced defines if the vertex buffer contains indexed data
  5464. * @param useBytes defines if the offset and stride are in bytes
  5465. * @returns the new vertex buffer
  5466. */
  5467. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5468. /**
  5469. * Gets a boolean indicating if the Buffer is updatable?
  5470. * @returns true if the buffer is updatable
  5471. */
  5472. isUpdatable(): boolean;
  5473. /**
  5474. * Gets current buffer's data
  5475. * @returns a DataArray or null
  5476. */
  5477. getData(): Nullable<DataArray>;
  5478. /**
  5479. * Gets underlying native buffer
  5480. * @returns underlying native buffer
  5481. */
  5482. getBuffer(): Nullable<WebGLBuffer>;
  5483. /**
  5484. * Gets the stride in float32 units (i.e. byte stride / 4).
  5485. * May not be an integer if the byte stride is not divisible by 4.
  5486. * DEPRECATED. Use byteStride instead.
  5487. * @returns the stride in float32 units
  5488. */
  5489. getStrideSize(): number;
  5490. /**
  5491. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5492. * @param data defines the data to store
  5493. */
  5494. create(data?: Nullable<DataArray>): void;
  5495. /** @hidden */
  5496. _rebuild(): void;
  5497. /**
  5498. * Update current buffer data
  5499. * @param data defines the data to store
  5500. */
  5501. update(data: DataArray): void;
  5502. /**
  5503. * Updates the data directly.
  5504. * @param data the new data
  5505. * @param offset the new offset
  5506. * @param vertexCount the vertex count (optional)
  5507. * @param useBytes set to true if the offset is in bytes
  5508. */
  5509. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5510. /**
  5511. * Release all resources
  5512. */
  5513. dispose(): void;
  5514. }
  5515. /**
  5516. * Specialized buffer used to store vertex data
  5517. */
  5518. export class VertexBuffer {
  5519. /** @hidden */
  5520. _buffer: Buffer;
  5521. private _kind;
  5522. private _size;
  5523. private _ownsBuffer;
  5524. private _instanced;
  5525. private _instanceDivisor;
  5526. /**
  5527. * The byte type.
  5528. */
  5529. static readonly BYTE: number;
  5530. /**
  5531. * The unsigned byte type.
  5532. */
  5533. static readonly UNSIGNED_BYTE: number;
  5534. /**
  5535. * The short type.
  5536. */
  5537. static readonly SHORT: number;
  5538. /**
  5539. * The unsigned short type.
  5540. */
  5541. static readonly UNSIGNED_SHORT: number;
  5542. /**
  5543. * The integer type.
  5544. */
  5545. static readonly INT: number;
  5546. /**
  5547. * The unsigned integer type.
  5548. */
  5549. static readonly UNSIGNED_INT: number;
  5550. /**
  5551. * The float type.
  5552. */
  5553. static readonly FLOAT: number;
  5554. /**
  5555. * Gets or sets the instance divisor when in instanced mode
  5556. */
  5557. instanceDivisor: number;
  5558. /**
  5559. * Gets the byte stride.
  5560. */
  5561. readonly byteStride: number;
  5562. /**
  5563. * Gets the byte offset.
  5564. */
  5565. readonly byteOffset: number;
  5566. /**
  5567. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5568. */
  5569. readonly normalized: boolean;
  5570. /**
  5571. * Gets the data type of each component in the array.
  5572. */
  5573. readonly type: number;
  5574. /**
  5575. * Constructor
  5576. * @param engine the engine
  5577. * @param data the data to use for this vertex buffer
  5578. * @param kind the vertex buffer kind
  5579. * @param updatable whether the data is updatable
  5580. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5581. * @param stride the stride (optional)
  5582. * @param instanced whether the buffer is instanced (optional)
  5583. * @param offset the offset of the data (optional)
  5584. * @param size the number of components (optional)
  5585. * @param type the type of the component (optional)
  5586. * @param normalized whether the data contains normalized data (optional)
  5587. * @param useBytes set to true if stride and offset are in bytes (optional)
  5588. */
  5589. 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);
  5590. /** @hidden */
  5591. _rebuild(): void;
  5592. /**
  5593. * Returns the kind of the VertexBuffer (string)
  5594. * @returns a string
  5595. */
  5596. getKind(): string;
  5597. /**
  5598. * Gets a boolean indicating if the VertexBuffer is updatable?
  5599. * @returns true if the buffer is updatable
  5600. */
  5601. isUpdatable(): boolean;
  5602. /**
  5603. * Gets current buffer's data
  5604. * @returns a DataArray or null
  5605. */
  5606. getData(): Nullable<DataArray>;
  5607. /**
  5608. * Gets underlying native buffer
  5609. * @returns underlying native buffer
  5610. */
  5611. getBuffer(): Nullable<WebGLBuffer>;
  5612. /**
  5613. * Gets the stride in float32 units (i.e. byte stride / 4).
  5614. * May not be an integer if the byte stride is not divisible by 4.
  5615. * DEPRECATED. Use byteStride instead.
  5616. * @returns the stride in float32 units
  5617. */
  5618. getStrideSize(): number;
  5619. /**
  5620. * Returns the offset as a multiple of the type byte length.
  5621. * DEPRECATED. Use byteOffset instead.
  5622. * @returns the offset in bytes
  5623. */
  5624. getOffset(): number;
  5625. /**
  5626. * Returns the number of components per vertex attribute (integer)
  5627. * @returns the size in float
  5628. */
  5629. getSize(): number;
  5630. /**
  5631. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5632. * @returns true if this buffer is instanced
  5633. */
  5634. getIsInstanced(): boolean;
  5635. /**
  5636. * Returns the instancing divisor, zero for non-instanced (integer).
  5637. * @returns a number
  5638. */
  5639. getInstanceDivisor(): number;
  5640. /**
  5641. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5642. * @param data defines the data to store
  5643. */
  5644. create(data?: DataArray): void;
  5645. /**
  5646. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5647. * This function will create a new buffer if the current one is not updatable
  5648. * @param data defines the data to store
  5649. */
  5650. update(data: DataArray): void;
  5651. /**
  5652. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5653. * Returns the directly updated WebGLBuffer.
  5654. * @param data the new data
  5655. * @param offset the new offset
  5656. * @param useBytes set to true if the offset is in bytes
  5657. */
  5658. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5659. /**
  5660. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5661. */
  5662. dispose(): void;
  5663. /**
  5664. * Enumerates each value of this vertex buffer as numbers.
  5665. * @param count the number of values to enumerate
  5666. * @param callback the callback function called for each value
  5667. */
  5668. forEach(count: number, callback: (value: number, index: number) => void): void;
  5669. /**
  5670. * Positions
  5671. */
  5672. static readonly PositionKind: string;
  5673. /**
  5674. * Normals
  5675. */
  5676. static readonly NormalKind: string;
  5677. /**
  5678. * Tangents
  5679. */
  5680. static readonly TangentKind: string;
  5681. /**
  5682. * Texture coordinates
  5683. */
  5684. static readonly UVKind: string;
  5685. /**
  5686. * Texture coordinates 2
  5687. */
  5688. static readonly UV2Kind: string;
  5689. /**
  5690. * Texture coordinates 3
  5691. */
  5692. static readonly UV3Kind: string;
  5693. /**
  5694. * Texture coordinates 4
  5695. */
  5696. static readonly UV4Kind: string;
  5697. /**
  5698. * Texture coordinates 5
  5699. */
  5700. static readonly UV5Kind: string;
  5701. /**
  5702. * Texture coordinates 6
  5703. */
  5704. static readonly UV6Kind: string;
  5705. /**
  5706. * Colors
  5707. */
  5708. static readonly ColorKind: string;
  5709. /**
  5710. * Matrix indices (for bones)
  5711. */
  5712. static readonly MatricesIndicesKind: string;
  5713. /**
  5714. * Matrix weights (for bones)
  5715. */
  5716. static readonly MatricesWeightsKind: string;
  5717. /**
  5718. * Additional matrix indices (for bones)
  5719. */
  5720. static readonly MatricesIndicesExtraKind: string;
  5721. /**
  5722. * Additional matrix weights (for bones)
  5723. */
  5724. static readonly MatricesWeightsExtraKind: string;
  5725. /**
  5726. * Deduces the stride given a kind.
  5727. * @param kind The kind string to deduce
  5728. * @returns The deduced stride
  5729. */
  5730. static DeduceStride(kind: string): number;
  5731. /**
  5732. * Gets the byte length of the given type.
  5733. * @param type the type
  5734. * @returns the number of bytes
  5735. */
  5736. static GetTypeByteLength(type: number): number;
  5737. /**
  5738. * Enumerates each value of the given parameters as numbers.
  5739. * @param data the data to enumerate
  5740. * @param byteOffset the byte offset of the data
  5741. * @param byteStride the byte stride of the data
  5742. * @param componentCount the number of components per element
  5743. * @param componentType the type of the component
  5744. * @param count the total number of components
  5745. * @param normalized whether the data is normalized
  5746. * @param callback the callback function called for each value
  5747. */
  5748. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5749. private static _GetFloatValue;
  5750. }
  5751. }
  5752. declare module BABYLON {
  5753. /**
  5754. * Class representing spherical polynomial coefficients to the 3rd degree
  5755. */
  5756. export class SphericalPolynomial {
  5757. /**
  5758. * The x coefficients of the spherical polynomial
  5759. */
  5760. x: Vector3;
  5761. /**
  5762. * The y coefficients of the spherical polynomial
  5763. */
  5764. y: Vector3;
  5765. /**
  5766. * The z coefficients of the spherical polynomial
  5767. */
  5768. z: Vector3;
  5769. /**
  5770. * The xx coefficients of the spherical polynomial
  5771. */
  5772. xx: Vector3;
  5773. /**
  5774. * The yy coefficients of the spherical polynomial
  5775. */
  5776. yy: Vector3;
  5777. /**
  5778. * The zz coefficients of the spherical polynomial
  5779. */
  5780. zz: Vector3;
  5781. /**
  5782. * The xy coefficients of the spherical polynomial
  5783. */
  5784. xy: Vector3;
  5785. /**
  5786. * The yz coefficients of the spherical polynomial
  5787. */
  5788. yz: Vector3;
  5789. /**
  5790. * The zx coefficients of the spherical polynomial
  5791. */
  5792. zx: Vector3;
  5793. /**
  5794. * Adds an ambient color to the spherical polynomial
  5795. * @param color the color to add
  5796. */
  5797. addAmbient(color: Color3): void;
  5798. /**
  5799. * Scales the spherical polynomial by the given amount
  5800. * @param scale the amount to scale
  5801. */
  5802. scale(scale: number): void;
  5803. /**
  5804. * Gets the spherical polynomial from harmonics
  5805. * @param harmonics the spherical harmonics
  5806. * @returns the spherical polynomial
  5807. */
  5808. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5809. /**
  5810. * Constructs a spherical polynomial from an array.
  5811. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5812. * @returns the spherical polynomial
  5813. */
  5814. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5815. }
  5816. /**
  5817. * Class representing spherical harmonics coefficients to the 3rd degree
  5818. */
  5819. export class SphericalHarmonics {
  5820. /**
  5821. * The l0,0 coefficients of the spherical harmonics
  5822. */
  5823. l00: Vector3;
  5824. /**
  5825. * The l1,-1 coefficients of the spherical harmonics
  5826. */
  5827. l1_1: Vector3;
  5828. /**
  5829. * The l1,0 coefficients of the spherical harmonics
  5830. */
  5831. l10: Vector3;
  5832. /**
  5833. * The l1,1 coefficients of the spherical harmonics
  5834. */
  5835. l11: Vector3;
  5836. /**
  5837. * The l2,-2 coefficients of the spherical harmonics
  5838. */
  5839. l2_2: Vector3;
  5840. /**
  5841. * The l2,-1 coefficients of the spherical harmonics
  5842. */
  5843. l2_1: Vector3;
  5844. /**
  5845. * The l2,0 coefficients of the spherical harmonics
  5846. */
  5847. l20: Vector3;
  5848. /**
  5849. * The l2,1 coefficients of the spherical harmonics
  5850. */
  5851. l21: Vector3;
  5852. /**
  5853. * The l2,2 coefficients of the spherical harmonics
  5854. */
  5855. lL22: Vector3;
  5856. /**
  5857. * Adds a light to the spherical harmonics
  5858. * @param direction the direction of the light
  5859. * @param color the color of the light
  5860. * @param deltaSolidAngle the delta solid angle of the light
  5861. */
  5862. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5863. /**
  5864. * Scales the spherical harmonics by the given amount
  5865. * @param scale the amount to scale
  5866. */
  5867. scale(scale: number): void;
  5868. /**
  5869. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5870. *
  5871. * ```
  5872. * E_lm = A_l * L_lm
  5873. * ```
  5874. *
  5875. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5876. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5877. * the scaling factors are given in equation 9.
  5878. */
  5879. convertIncidentRadianceToIrradiance(): void;
  5880. /**
  5881. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5882. *
  5883. * ```
  5884. * L = (1/pi) * E * rho
  5885. * ```
  5886. *
  5887. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5888. */
  5889. convertIrradianceToLambertianRadiance(): void;
  5890. /**
  5891. * Gets the spherical harmonics from polynomial
  5892. * @param polynomial the spherical polynomial
  5893. * @returns the spherical harmonics
  5894. */
  5895. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5896. /**
  5897. * Constructs a spherical harmonics from an array.
  5898. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5899. * @returns the spherical harmonics
  5900. */
  5901. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5902. }
  5903. }
  5904. declare module BABYLON {
  5905. /**
  5906. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5907. */
  5908. export interface CubeMapInfo {
  5909. /**
  5910. * The pixel array for the front face.
  5911. * This is stored in format, left to right, up to down format.
  5912. */
  5913. front: Nullable<ArrayBufferView>;
  5914. /**
  5915. * The pixel array for the back face.
  5916. * This is stored in format, left to right, up to down format.
  5917. */
  5918. back: Nullable<ArrayBufferView>;
  5919. /**
  5920. * The pixel array for the left face.
  5921. * This is stored in format, left to right, up to down format.
  5922. */
  5923. left: Nullable<ArrayBufferView>;
  5924. /**
  5925. * The pixel array for the right face.
  5926. * This is stored in format, left to right, up to down format.
  5927. */
  5928. right: Nullable<ArrayBufferView>;
  5929. /**
  5930. * The pixel array for the up face.
  5931. * This is stored in format, left to right, up to down format.
  5932. */
  5933. up: Nullable<ArrayBufferView>;
  5934. /**
  5935. * The pixel array for the down face.
  5936. * This is stored in format, left to right, up to down format.
  5937. */
  5938. down: Nullable<ArrayBufferView>;
  5939. /**
  5940. * The size of the cubemap stored.
  5941. *
  5942. * Each faces will be size * size pixels.
  5943. */
  5944. size: number;
  5945. /**
  5946. * The format of the texture.
  5947. *
  5948. * RGBA, RGB.
  5949. */
  5950. format: number;
  5951. /**
  5952. * The type of the texture data.
  5953. *
  5954. * UNSIGNED_INT, FLOAT.
  5955. */
  5956. type: number;
  5957. /**
  5958. * Specifies whether the texture is in gamma space.
  5959. */
  5960. gammaSpace: boolean;
  5961. }
  5962. /**
  5963. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5964. */
  5965. export class PanoramaToCubeMapTools {
  5966. private static FACE_FRONT;
  5967. private static FACE_BACK;
  5968. private static FACE_RIGHT;
  5969. private static FACE_LEFT;
  5970. private static FACE_DOWN;
  5971. private static FACE_UP;
  5972. /**
  5973. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5974. *
  5975. * @param float32Array The source data.
  5976. * @param inputWidth The width of the input panorama.
  5977. * @param inputHeight The height of the input panorama.
  5978. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5979. * @return The cubemap data
  5980. */
  5981. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5982. private static CreateCubemapTexture;
  5983. private static CalcProjectionSpherical;
  5984. }
  5985. }
  5986. declare module BABYLON {
  5987. /**
  5988. * Helper class dealing with the extraction of spherical polynomial dataArray
  5989. * from a cube map.
  5990. */
  5991. export class CubeMapToSphericalPolynomialTools {
  5992. private static FileFaces;
  5993. /**
  5994. * Converts a texture to the according Spherical Polynomial data.
  5995. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5996. *
  5997. * @param texture The texture to extract the information from.
  5998. * @return The Spherical Polynomial data.
  5999. */
  6000. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6001. /**
  6002. * Converts a cubemap to the according Spherical Polynomial data.
  6003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6004. *
  6005. * @param cubeInfo The Cube map to extract the information from.
  6006. * @return The Spherical Polynomial data.
  6007. */
  6008. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6009. }
  6010. }
  6011. declare module BABYLON {
  6012. /**
  6013. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6014. * during the life time of the application.
  6015. */
  6016. export class EngineStore {
  6017. /** Gets the list of created engines */
  6018. static Instances: Engine[];
  6019. /**
  6020. * Gets the latest created engine
  6021. */
  6022. static readonly LastCreatedEngine: Nullable<Engine>;
  6023. /**
  6024. * Gets the latest created scene
  6025. */
  6026. static readonly LastCreatedScene: Nullable<Scene>;
  6027. }
  6028. }
  6029. declare module BABYLON {
  6030. /**
  6031. * Define options used to create a render target texture
  6032. */
  6033. export class RenderTargetCreationOptions {
  6034. /**
  6035. * Specifies is mipmaps must be generated
  6036. */
  6037. generateMipMaps?: boolean;
  6038. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6039. generateDepthBuffer?: boolean;
  6040. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6041. generateStencilBuffer?: boolean;
  6042. /** Defines texture type (int by default) */
  6043. type?: number;
  6044. /** Defines sampling mode (trilinear by default) */
  6045. samplingMode?: number;
  6046. /** Defines format (RGBA by default) */
  6047. format?: number;
  6048. }
  6049. }
  6050. declare module BABYLON {
  6051. /**
  6052. * @hidden
  6053. **/
  6054. export class _AlphaState {
  6055. private _isAlphaBlendDirty;
  6056. private _isBlendFunctionParametersDirty;
  6057. private _isBlendEquationParametersDirty;
  6058. private _isBlendConstantsDirty;
  6059. private _alphaBlend;
  6060. private _blendFunctionParameters;
  6061. private _blendEquationParameters;
  6062. private _blendConstants;
  6063. /**
  6064. * Initializes the state.
  6065. */
  6066. constructor();
  6067. readonly isDirty: boolean;
  6068. alphaBlend: boolean;
  6069. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6070. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6071. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6072. reset(): void;
  6073. apply(gl: WebGLRenderingContext): void;
  6074. }
  6075. }
  6076. declare module BABYLON {
  6077. /**
  6078. * @hidden
  6079. **/
  6080. export class _DepthCullingState {
  6081. private _isDepthTestDirty;
  6082. private _isDepthMaskDirty;
  6083. private _isDepthFuncDirty;
  6084. private _isCullFaceDirty;
  6085. private _isCullDirty;
  6086. private _isZOffsetDirty;
  6087. private _isFrontFaceDirty;
  6088. private _depthTest;
  6089. private _depthMask;
  6090. private _depthFunc;
  6091. private _cull;
  6092. private _cullFace;
  6093. private _zOffset;
  6094. private _frontFace;
  6095. /**
  6096. * Initializes the state.
  6097. */
  6098. constructor();
  6099. readonly isDirty: boolean;
  6100. zOffset: number;
  6101. cullFace: Nullable<number>;
  6102. cull: Nullable<boolean>;
  6103. depthFunc: Nullable<number>;
  6104. depthMask: boolean;
  6105. depthTest: boolean;
  6106. frontFace: Nullable<number>;
  6107. reset(): void;
  6108. apply(gl: WebGLRenderingContext): void;
  6109. }
  6110. }
  6111. declare module BABYLON {
  6112. /**
  6113. * @hidden
  6114. **/
  6115. export class _StencilState {
  6116. /** 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 */
  6117. static readonly ALWAYS: number;
  6118. /** Passed to stencilOperation to specify that stencil value must be kept */
  6119. static readonly KEEP: number;
  6120. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6121. static readonly REPLACE: number;
  6122. private _isStencilTestDirty;
  6123. private _isStencilMaskDirty;
  6124. private _isStencilFuncDirty;
  6125. private _isStencilOpDirty;
  6126. private _stencilTest;
  6127. private _stencilMask;
  6128. private _stencilFunc;
  6129. private _stencilFuncRef;
  6130. private _stencilFuncMask;
  6131. private _stencilOpStencilFail;
  6132. private _stencilOpDepthFail;
  6133. private _stencilOpStencilDepthPass;
  6134. readonly isDirty: boolean;
  6135. stencilFunc: number;
  6136. stencilFuncRef: number;
  6137. stencilFuncMask: number;
  6138. stencilOpStencilFail: number;
  6139. stencilOpDepthFail: number;
  6140. stencilOpStencilDepthPass: number;
  6141. stencilMask: number;
  6142. stencilTest: boolean;
  6143. constructor();
  6144. reset(): void;
  6145. apply(gl: WebGLRenderingContext): void;
  6146. }
  6147. }
  6148. declare module BABYLON {
  6149. /**
  6150. * @hidden
  6151. **/
  6152. export class _TimeToken {
  6153. _startTimeQuery: Nullable<WebGLQuery>;
  6154. _endTimeQuery: Nullable<WebGLQuery>;
  6155. _timeElapsedQuery: Nullable<WebGLQuery>;
  6156. _timeElapsedQueryEnded: boolean;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Internal interface used to track InternalTexture already bound to the GL context
  6162. */
  6163. export interface IInternalTextureTracker {
  6164. /**
  6165. * Gets or set the previous tracker in the list
  6166. */
  6167. previous: Nullable<IInternalTextureTracker>;
  6168. /**
  6169. * Gets or set the next tracker in the list
  6170. */
  6171. next: Nullable<IInternalTextureTracker>;
  6172. }
  6173. /**
  6174. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6175. */
  6176. export class DummyInternalTextureTracker {
  6177. /**
  6178. * Gets or set the previous tracker in the list
  6179. */
  6180. previous: Nullable<IInternalTextureTracker>;
  6181. /**
  6182. * Gets or set the next tracker in the list
  6183. */
  6184. next: Nullable<IInternalTextureTracker>;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Class used to store data associated with WebGL texture data for the engine
  6190. * This class should not be used directly
  6191. */
  6192. export class InternalTexture implements IInternalTextureTracker {
  6193. /** hidden */
  6194. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6195. /**
  6196. * The source of the texture data is unknown
  6197. */
  6198. static DATASOURCE_UNKNOWN: number;
  6199. /**
  6200. * Texture data comes from an URL
  6201. */
  6202. static DATASOURCE_URL: number;
  6203. /**
  6204. * Texture data is only used for temporary storage
  6205. */
  6206. static DATASOURCE_TEMP: number;
  6207. /**
  6208. * Texture data comes from raw data (ArrayBuffer)
  6209. */
  6210. static DATASOURCE_RAW: number;
  6211. /**
  6212. * Texture content is dynamic (video or dynamic texture)
  6213. */
  6214. static DATASOURCE_DYNAMIC: number;
  6215. /**
  6216. * Texture content is generated by rendering to it
  6217. */
  6218. static DATASOURCE_RENDERTARGET: number;
  6219. /**
  6220. * Texture content is part of a multi render target process
  6221. */
  6222. static DATASOURCE_MULTIRENDERTARGET: number;
  6223. /**
  6224. * Texture data comes from a cube data file
  6225. */
  6226. static DATASOURCE_CUBE: number;
  6227. /**
  6228. * Texture data comes from a raw cube data
  6229. */
  6230. static DATASOURCE_CUBERAW: number;
  6231. /**
  6232. * Texture data come from a prefiltered cube data file
  6233. */
  6234. static DATASOURCE_CUBEPREFILTERED: number;
  6235. /**
  6236. * Texture content is raw 3D data
  6237. */
  6238. static DATASOURCE_RAW3D: number;
  6239. /**
  6240. * Texture content is a depth texture
  6241. */
  6242. static DATASOURCE_DEPTHTEXTURE: number;
  6243. /**
  6244. * Texture data comes from a raw cube data encoded with RGBD
  6245. */
  6246. static DATASOURCE_CUBERAW_RGBD: number;
  6247. /**
  6248. * Defines if the texture is ready
  6249. */
  6250. isReady: boolean;
  6251. /**
  6252. * Defines if the texture is a cube texture
  6253. */
  6254. isCube: boolean;
  6255. /**
  6256. * Defines if the texture contains 3D data
  6257. */
  6258. is3D: boolean;
  6259. /**
  6260. * Defines if the texture contains multiview data
  6261. */
  6262. isMultiview: boolean;
  6263. /**
  6264. * Gets the URL used to load this texture
  6265. */
  6266. url: string;
  6267. /**
  6268. * Gets the sampling mode of the texture
  6269. */
  6270. samplingMode: number;
  6271. /**
  6272. * Gets a boolean indicating if the texture needs mipmaps generation
  6273. */
  6274. generateMipMaps: boolean;
  6275. /**
  6276. * Gets the number of samples used by the texture (WebGL2+ only)
  6277. */
  6278. samples: number;
  6279. /**
  6280. * Gets the type of the texture (int, float...)
  6281. */
  6282. type: number;
  6283. /**
  6284. * Gets the format of the texture (RGB, RGBA...)
  6285. */
  6286. format: number;
  6287. /**
  6288. * Observable called when the texture is loaded
  6289. */
  6290. onLoadedObservable: Observable<InternalTexture>;
  6291. /**
  6292. * Gets the width of the texture
  6293. */
  6294. width: number;
  6295. /**
  6296. * Gets the height of the texture
  6297. */
  6298. height: number;
  6299. /**
  6300. * Gets the depth of the texture
  6301. */
  6302. depth: number;
  6303. /**
  6304. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6305. */
  6306. baseWidth: number;
  6307. /**
  6308. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6309. */
  6310. baseHeight: number;
  6311. /**
  6312. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6313. */
  6314. baseDepth: number;
  6315. /**
  6316. * Gets a boolean indicating if the texture is inverted on Y axis
  6317. */
  6318. invertY: boolean;
  6319. /**
  6320. * Gets or set the previous tracker in the list
  6321. */
  6322. previous: Nullable<IInternalTextureTracker>;
  6323. /**
  6324. * Gets or set the next tracker in the list
  6325. */
  6326. next: Nullable<IInternalTextureTracker>;
  6327. /** @hidden */
  6328. _invertVScale: boolean;
  6329. /** @hidden */
  6330. _initialSlot: number;
  6331. /** @hidden */
  6332. _designatedSlot: number;
  6333. /** @hidden */
  6334. _dataSource: number;
  6335. /** @hidden */
  6336. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6337. /** @hidden */
  6338. _bufferView: Nullable<ArrayBufferView>;
  6339. /** @hidden */
  6340. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6341. /** @hidden */
  6342. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6343. /** @hidden */
  6344. _size: number;
  6345. /** @hidden */
  6346. _extension: string;
  6347. /** @hidden */
  6348. _files: Nullable<string[]>;
  6349. /** @hidden */
  6350. _workingCanvas: HTMLCanvasElement;
  6351. /** @hidden */
  6352. _workingContext: CanvasRenderingContext2D;
  6353. /** @hidden */
  6354. _framebuffer: Nullable<WebGLFramebuffer>;
  6355. /** @hidden */
  6356. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6357. /** @hidden */
  6358. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6359. /** @hidden */
  6360. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6361. /** @hidden */
  6362. _attachments: Nullable<number[]>;
  6363. /** @hidden */
  6364. _cachedCoordinatesMode: Nullable<number>;
  6365. /** @hidden */
  6366. _cachedWrapU: Nullable<number>;
  6367. /** @hidden */
  6368. _cachedWrapV: Nullable<number>;
  6369. /** @hidden */
  6370. _cachedWrapR: Nullable<number>;
  6371. /** @hidden */
  6372. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6373. /** @hidden */
  6374. _isDisabled: boolean;
  6375. /** @hidden */
  6376. _compression: Nullable<string>;
  6377. /** @hidden */
  6378. _generateStencilBuffer: boolean;
  6379. /** @hidden */
  6380. _generateDepthBuffer: boolean;
  6381. /** @hidden */
  6382. _comparisonFunction: number;
  6383. /** @hidden */
  6384. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6385. /** @hidden */
  6386. _lodGenerationScale: number;
  6387. /** @hidden */
  6388. _lodGenerationOffset: number;
  6389. /** @hidden */
  6390. _colorTextureArray: Nullable<WebGLTexture>;
  6391. /** @hidden */
  6392. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6393. /** @hidden */
  6394. _lodTextureHigh: BaseTexture;
  6395. /** @hidden */
  6396. _lodTextureMid: BaseTexture;
  6397. /** @hidden */
  6398. _lodTextureLow: BaseTexture;
  6399. /** @hidden */
  6400. _isRGBD: boolean;
  6401. /** @hidden */
  6402. _webGLTexture: Nullable<WebGLTexture>;
  6403. /** @hidden */
  6404. _references: number;
  6405. private _engine;
  6406. /**
  6407. * Gets the Engine the texture belongs to.
  6408. * @returns The babylon engine
  6409. */
  6410. getEngine(): Engine;
  6411. /**
  6412. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6413. */
  6414. readonly dataSource: number;
  6415. /**
  6416. * Creates a new InternalTexture
  6417. * @param engine defines the engine to use
  6418. * @param dataSource defines the type of data that will be used
  6419. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6420. */
  6421. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6422. /**
  6423. * Increments the number of references (ie. the number of Texture that point to it)
  6424. */
  6425. incrementReferences(): void;
  6426. /**
  6427. * Change the size of the texture (not the size of the content)
  6428. * @param width defines the new width
  6429. * @param height defines the new height
  6430. * @param depth defines the new depth (1 by default)
  6431. */
  6432. updateSize(width: int, height: int, depth?: int): void;
  6433. /** @hidden */
  6434. _rebuild(): void;
  6435. /** @hidden */
  6436. _swapAndDie(target: InternalTexture): void;
  6437. /**
  6438. * Dispose the current allocated resources
  6439. */
  6440. dispose(): void;
  6441. }
  6442. }
  6443. declare module BABYLON {
  6444. /**
  6445. * This represents the main contract an easing function should follow.
  6446. * Easing functions are used throughout the animation system.
  6447. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6448. */
  6449. export interface IEasingFunction {
  6450. /**
  6451. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6452. * of the easing function.
  6453. * The link below provides some of the most common examples of easing functions.
  6454. * @see https://easings.net/
  6455. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6456. * @returns the corresponding value on the curve defined by the easing function
  6457. */
  6458. ease(gradient: number): number;
  6459. }
  6460. /**
  6461. * Base class used for every default easing function.
  6462. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6463. */
  6464. export class EasingFunction implements IEasingFunction {
  6465. /**
  6466. * Interpolation follows the mathematical formula associated with the easing function.
  6467. */
  6468. static readonly EASINGMODE_EASEIN: number;
  6469. /**
  6470. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6471. */
  6472. static readonly EASINGMODE_EASEOUT: number;
  6473. /**
  6474. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6475. */
  6476. static readonly EASINGMODE_EASEINOUT: number;
  6477. private _easingMode;
  6478. /**
  6479. * Sets the easing mode of the current function.
  6480. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6481. */
  6482. setEasingMode(easingMode: number): void;
  6483. /**
  6484. * Gets the current easing mode.
  6485. * @returns the easing mode
  6486. */
  6487. getEasingMode(): number;
  6488. /**
  6489. * @hidden
  6490. */
  6491. easeInCore(gradient: number): number;
  6492. /**
  6493. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6494. * of the easing function.
  6495. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6496. * @returns the corresponding value on the curve defined by the easing function
  6497. */
  6498. ease(gradient: number): number;
  6499. }
  6500. /**
  6501. * Easing function with a circle shape (see link below).
  6502. * @see https://easings.net/#easeInCirc
  6503. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6504. */
  6505. export class CircleEase extends EasingFunction implements IEasingFunction {
  6506. /** @hidden */
  6507. easeInCore(gradient: number): number;
  6508. }
  6509. /**
  6510. * Easing function with a ease back shape (see link below).
  6511. * @see https://easings.net/#easeInBack
  6512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6513. */
  6514. export class BackEase extends EasingFunction implements IEasingFunction {
  6515. /** Defines the amplitude of the function */
  6516. amplitude: number;
  6517. /**
  6518. * Instantiates a back ease easing
  6519. * @see https://easings.net/#easeInBack
  6520. * @param amplitude Defines the amplitude of the function
  6521. */
  6522. constructor(
  6523. /** Defines the amplitude of the function */
  6524. amplitude?: number);
  6525. /** @hidden */
  6526. easeInCore(gradient: number): number;
  6527. }
  6528. /**
  6529. * Easing function with a bouncing shape (see link below).
  6530. * @see https://easings.net/#easeInBounce
  6531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6532. */
  6533. export class BounceEase extends EasingFunction implements IEasingFunction {
  6534. /** Defines the number of bounces */
  6535. bounces: number;
  6536. /** Defines the amplitude of the bounce */
  6537. bounciness: number;
  6538. /**
  6539. * Instantiates a bounce easing
  6540. * @see https://easings.net/#easeInBounce
  6541. * @param bounces Defines the number of bounces
  6542. * @param bounciness Defines the amplitude of the bounce
  6543. */
  6544. constructor(
  6545. /** Defines the number of bounces */
  6546. bounces?: number,
  6547. /** Defines the amplitude of the bounce */
  6548. bounciness?: number);
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with a power of 3 shape (see link below).
  6554. * @see https://easings.net/#easeInCubic
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class CubicEase extends EasingFunction implements IEasingFunction {
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with an elastic shape (see link below).
  6563. * @see https://easings.net/#easeInElastic
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6567. /** Defines the number of oscillations*/
  6568. oscillations: number;
  6569. /** Defines the amplitude of the oscillations*/
  6570. springiness: number;
  6571. /**
  6572. * Instantiates an elastic easing function
  6573. * @see https://easings.net/#easeInElastic
  6574. * @param oscillations Defines the number of oscillations
  6575. * @param springiness Defines the amplitude of the oscillations
  6576. */
  6577. constructor(
  6578. /** Defines the number of oscillations*/
  6579. oscillations?: number,
  6580. /** Defines the amplitude of the oscillations*/
  6581. springiness?: number);
  6582. /** @hidden */
  6583. easeInCore(gradient: number): number;
  6584. }
  6585. /**
  6586. * Easing function with an exponential shape (see link below).
  6587. * @see https://easings.net/#easeInExpo
  6588. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6589. */
  6590. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6591. /** Defines the exponent of the function */
  6592. exponent: number;
  6593. /**
  6594. * Instantiates an exponential easing function
  6595. * @see https://easings.net/#easeInExpo
  6596. * @param exponent Defines the exponent of the function
  6597. */
  6598. constructor(
  6599. /** Defines the exponent of the function */
  6600. exponent?: number);
  6601. /** @hidden */
  6602. easeInCore(gradient: number): number;
  6603. }
  6604. /**
  6605. * Easing function with a power shape (see link below).
  6606. * @see https://easings.net/#easeInQuad
  6607. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6608. */
  6609. export class PowerEase extends EasingFunction implements IEasingFunction {
  6610. /** Defines the power of the function */
  6611. power: number;
  6612. /**
  6613. * Instantiates an power base easing function
  6614. * @see https://easings.net/#easeInQuad
  6615. * @param power Defines the power of the function
  6616. */
  6617. constructor(
  6618. /** Defines the power of the function */
  6619. power?: number);
  6620. /** @hidden */
  6621. easeInCore(gradient: number): number;
  6622. }
  6623. /**
  6624. * Easing function with a power of 2 shape (see link below).
  6625. * @see https://easings.net/#easeInQuad
  6626. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6627. */
  6628. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6629. /** @hidden */
  6630. easeInCore(gradient: number): number;
  6631. }
  6632. /**
  6633. * Easing function with a power of 4 shape (see link below).
  6634. * @see https://easings.net/#easeInQuart
  6635. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6636. */
  6637. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6638. /** @hidden */
  6639. easeInCore(gradient: number): number;
  6640. }
  6641. /**
  6642. * Easing function with a power of 5 shape (see link below).
  6643. * @see https://easings.net/#easeInQuint
  6644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6645. */
  6646. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6647. /** @hidden */
  6648. easeInCore(gradient: number): number;
  6649. }
  6650. /**
  6651. * Easing function with a sin shape (see link below).
  6652. * @see https://easings.net/#easeInSine
  6653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6654. */
  6655. export class SineEase extends EasingFunction implements IEasingFunction {
  6656. /** @hidden */
  6657. easeInCore(gradient: number): number;
  6658. }
  6659. /**
  6660. * Easing function with a bezier shape (see link below).
  6661. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6663. */
  6664. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6665. /** Defines the x component of the start tangent in the bezier curve */
  6666. x1: number;
  6667. /** Defines the y component of the start tangent in the bezier curve */
  6668. y1: number;
  6669. /** Defines the x component of the end tangent in the bezier curve */
  6670. x2: number;
  6671. /** Defines the y component of the end tangent in the bezier curve */
  6672. y2: number;
  6673. /**
  6674. * Instantiates a bezier function
  6675. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6676. * @param x1 Defines the x component of the start tangent in the bezier curve
  6677. * @param y1 Defines the y component of the start tangent in the bezier curve
  6678. * @param x2 Defines the x component of the end tangent in the bezier curve
  6679. * @param y2 Defines the y component of the end tangent in the bezier curve
  6680. */
  6681. constructor(
  6682. /** Defines the x component of the start tangent in the bezier curve */
  6683. x1?: number,
  6684. /** Defines the y component of the start tangent in the bezier curve */
  6685. y1?: number,
  6686. /** Defines the x component of the end tangent in the bezier curve */
  6687. x2?: number,
  6688. /** Defines the y component of the end tangent in the bezier curve */
  6689. y2?: number);
  6690. /** @hidden */
  6691. easeInCore(gradient: number): number;
  6692. }
  6693. }
  6694. declare module BABYLON {
  6695. /**
  6696. * Defines an interface which represents an animation key frame
  6697. */
  6698. export interface IAnimationKey {
  6699. /**
  6700. * Frame of the key frame
  6701. */
  6702. frame: number;
  6703. /**
  6704. * Value at the specifies key frame
  6705. */
  6706. value: any;
  6707. /**
  6708. * The input tangent for the cubic hermite spline
  6709. */
  6710. inTangent?: any;
  6711. /**
  6712. * The output tangent for the cubic hermite spline
  6713. */
  6714. outTangent?: any;
  6715. /**
  6716. * The animation interpolation type
  6717. */
  6718. interpolation?: AnimationKeyInterpolation;
  6719. }
  6720. /**
  6721. * Enum for the animation key frame interpolation type
  6722. */
  6723. export enum AnimationKeyInterpolation {
  6724. /**
  6725. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6726. */
  6727. STEP = 1
  6728. }
  6729. }
  6730. declare module BABYLON {
  6731. /**
  6732. * Represents the range of an animation
  6733. */
  6734. export class AnimationRange {
  6735. /**The name of the animation range**/
  6736. name: string;
  6737. /**The starting frame of the animation */
  6738. from: number;
  6739. /**The ending frame of the animation*/
  6740. to: number;
  6741. /**
  6742. * Initializes the range of an animation
  6743. * @param name The name of the animation range
  6744. * @param from The starting frame of the animation
  6745. * @param to The ending frame of the animation
  6746. */
  6747. constructor(
  6748. /**The name of the animation range**/
  6749. name: string,
  6750. /**The starting frame of the animation */
  6751. from: number,
  6752. /**The ending frame of the animation*/
  6753. to: number);
  6754. /**
  6755. * Makes a copy of the animation range
  6756. * @returns A copy of the animation range
  6757. */
  6758. clone(): AnimationRange;
  6759. }
  6760. }
  6761. declare module BABYLON {
  6762. /**
  6763. * Composed of a frame, and an action function
  6764. */
  6765. export class AnimationEvent {
  6766. /** The frame for which the event is triggered **/
  6767. frame: number;
  6768. /** The event to perform when triggered **/
  6769. action: (currentFrame: number) => void;
  6770. /** Specifies if the event should be triggered only once**/
  6771. onlyOnce?: boolean | undefined;
  6772. /**
  6773. * Specifies if the animation event is done
  6774. */
  6775. isDone: boolean;
  6776. /**
  6777. * Initializes the animation event
  6778. * @param frame The frame for which the event is triggered
  6779. * @param action The event to perform when triggered
  6780. * @param onlyOnce Specifies if the event should be triggered only once
  6781. */
  6782. constructor(
  6783. /** The frame for which the event is triggered **/
  6784. frame: number,
  6785. /** The event to perform when triggered **/
  6786. action: (currentFrame: number) => void,
  6787. /** Specifies if the event should be triggered only once**/
  6788. onlyOnce?: boolean | undefined);
  6789. /** @hidden */
  6790. _clone(): AnimationEvent;
  6791. }
  6792. }
  6793. declare module BABYLON {
  6794. /**
  6795. * Interface used to define a behavior
  6796. */
  6797. export interface Behavior<T> {
  6798. /** gets or sets behavior's name */
  6799. name: string;
  6800. /**
  6801. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6802. */
  6803. init(): void;
  6804. /**
  6805. * Called when the behavior is attached to a target
  6806. * @param target defines the target where the behavior is attached to
  6807. */
  6808. attach(target: T): void;
  6809. /**
  6810. * Called when the behavior is detached from its target
  6811. */
  6812. detach(): void;
  6813. }
  6814. /**
  6815. * Interface implemented by classes supporting behaviors
  6816. */
  6817. export interface IBehaviorAware<T> {
  6818. /**
  6819. * Attach a behavior
  6820. * @param behavior defines the behavior to attach
  6821. * @returns the current host
  6822. */
  6823. addBehavior(behavior: Behavior<T>): T;
  6824. /**
  6825. * Remove a behavior from the current object
  6826. * @param behavior defines the behavior to detach
  6827. * @returns the current host
  6828. */
  6829. removeBehavior(behavior: Behavior<T>): T;
  6830. /**
  6831. * Gets a behavior using its name to search
  6832. * @param name defines the name to search
  6833. * @returns the behavior or null if not found
  6834. */
  6835. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6836. }
  6837. }
  6838. declare module BABYLON {
  6839. /**
  6840. * @hidden
  6841. */
  6842. export class IntersectionInfo {
  6843. bu: Nullable<number>;
  6844. bv: Nullable<number>;
  6845. distance: number;
  6846. faceId: number;
  6847. subMeshId: number;
  6848. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6849. }
  6850. }
  6851. declare module BABYLON {
  6852. /**
  6853. * Class used to store bounding sphere information
  6854. */
  6855. export class BoundingSphere {
  6856. /**
  6857. * Gets the center of the bounding sphere in local space
  6858. */
  6859. readonly center: Vector3;
  6860. /**
  6861. * Radius of the bounding sphere in local space
  6862. */
  6863. radius: number;
  6864. /**
  6865. * Gets the center of the bounding sphere in world space
  6866. */
  6867. readonly centerWorld: Vector3;
  6868. /**
  6869. * Radius of the bounding sphere in world space
  6870. */
  6871. radiusWorld: number;
  6872. /**
  6873. * Gets the minimum vector in local space
  6874. */
  6875. readonly minimum: Vector3;
  6876. /**
  6877. * Gets the maximum vector in local space
  6878. */
  6879. readonly maximum: Vector3;
  6880. private _worldMatrix;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * Creates a new bounding sphere
  6884. * @param min defines the minimum vector (in local space)
  6885. * @param max defines the maximum vector (in local space)
  6886. * @param worldMatrix defines the new world matrix
  6887. */
  6888. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6889. /**
  6890. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6891. * @param min defines the new minimum vector (in local space)
  6892. * @param max defines the new maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6896. /**
  6897. * Scale the current bounding sphere by applying a scale factor
  6898. * @param factor defines the scale factor to apply
  6899. * @returns the current bounding box
  6900. */
  6901. scale(factor: number): BoundingSphere;
  6902. /**
  6903. * Gets the world matrix of the bounding box
  6904. * @returns a matrix
  6905. */
  6906. getWorldMatrix(): DeepImmutable<Matrix>;
  6907. /** @hidden */
  6908. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6909. /**
  6910. * Tests if the bounding sphere is intersecting the frustum planes
  6911. * @param frustumPlanes defines the frustum planes to test
  6912. * @returns true if there is an intersection
  6913. */
  6914. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6915. /**
  6916. * Tests if the bounding sphere center is in between the frustum planes.
  6917. * Used for optimistic fast inclusion.
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if the sphere center is in between the frustum planes
  6920. */
  6921. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if a point is inside the bounding sphere
  6924. * @param point defines the point to test
  6925. * @returns true if the point is inside the bounding sphere
  6926. */
  6927. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6928. /**
  6929. * Checks if two sphere intersct
  6930. * @param sphere0 sphere 0
  6931. * @param sphere1 sphere 1
  6932. * @returns true if the speres intersect
  6933. */
  6934. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6935. }
  6936. }
  6937. declare module BABYLON {
  6938. /**
  6939. * Class used to store bounding box information
  6940. */
  6941. export class BoundingBox implements ICullable {
  6942. /**
  6943. * Gets the 8 vectors representing the bounding box in local space
  6944. */
  6945. readonly vectors: Vector3[];
  6946. /**
  6947. * Gets the center of the bounding box in local space
  6948. */
  6949. readonly center: Vector3;
  6950. /**
  6951. * Gets the center of the bounding box in world space
  6952. */
  6953. readonly centerWorld: Vector3;
  6954. /**
  6955. * Gets the extend size in local space
  6956. */
  6957. readonly extendSize: Vector3;
  6958. /**
  6959. * Gets the extend size in world space
  6960. */
  6961. readonly extendSizeWorld: Vector3;
  6962. /**
  6963. * Gets the OBB (object bounding box) directions
  6964. */
  6965. readonly directions: Vector3[];
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in world space
  6968. */
  6969. readonly vectorsWorld: Vector3[];
  6970. /**
  6971. * Gets the minimum vector in world space
  6972. */
  6973. readonly minimumWorld: Vector3;
  6974. /**
  6975. * Gets the maximum vector in world space
  6976. */
  6977. readonly maximumWorld: Vector3;
  6978. /**
  6979. * Gets the minimum vector in local space
  6980. */
  6981. readonly minimum: Vector3;
  6982. /**
  6983. * Gets the maximum vector in local space
  6984. */
  6985. readonly maximum: Vector3;
  6986. private _worldMatrix;
  6987. private static readonly TmpVector3;
  6988. /**
  6989. * @hidden
  6990. */
  6991. _tag: number;
  6992. /**
  6993. * Creates a new bounding box
  6994. * @param min defines the minimum vector (in local space)
  6995. * @param max defines the maximum vector (in local space)
  6996. * @param worldMatrix defines the new world matrix
  6997. */
  6998. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6999. /**
  7000. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7001. * @param min defines the new minimum vector (in local space)
  7002. * @param max defines the new maximum vector (in local space)
  7003. * @param worldMatrix defines the new world matrix
  7004. */
  7005. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7006. /**
  7007. * Scale the current bounding box by applying a scale factor
  7008. * @param factor defines the scale factor to apply
  7009. * @returns the current bounding box
  7010. */
  7011. scale(factor: number): BoundingBox;
  7012. /**
  7013. * Gets the world matrix of the bounding box
  7014. * @returns a matrix
  7015. */
  7016. getWorldMatrix(): DeepImmutable<Matrix>;
  7017. /** @hidden */
  7018. _update(world: DeepImmutable<Matrix>): void;
  7019. /**
  7020. * Tests if the bounding box is intersecting the frustum planes
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @returns true if there is an intersection
  7023. */
  7024. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. /**
  7026. * Tests if the bounding box is entirely inside the frustum planes
  7027. * @param frustumPlanes defines the frustum planes to test
  7028. * @returns true if there is an inclusion
  7029. */
  7030. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7031. /**
  7032. * Tests if a point is inside the bounding box
  7033. * @param point defines the point to test
  7034. * @returns true if the point is inside the bounding box
  7035. */
  7036. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7037. /**
  7038. * Tests if the bounding box intersects with a bounding sphere
  7039. * @param sphere defines the sphere to test
  7040. * @returns true if there is an intersection
  7041. */
  7042. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7043. /**
  7044. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7045. * @param min defines the min vector to use
  7046. * @param max defines the max vector to use
  7047. * @returns true if there is an intersection
  7048. */
  7049. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7050. /**
  7051. * Tests if two bounding boxes are intersections
  7052. * @param box0 defines the first box to test
  7053. * @param box1 defines the second box to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7057. /**
  7058. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7059. * @param minPoint defines the minimum vector of the bounding box
  7060. * @param maxPoint defines the maximum vector of the bounding box
  7061. * @param sphereCenter defines the sphere center
  7062. * @param sphereRadius defines the sphere radius
  7063. * @returns true if there is an intersection
  7064. */
  7065. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7066. /**
  7067. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7068. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7069. * @param frustumPlanes defines the frustum planes to test
  7070. * @return true if there is an inclusion
  7071. */
  7072. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7073. /**
  7074. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7075. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7076. * @param frustumPlanes defines the frustum planes to test
  7077. * @return true if there is an intersection
  7078. */
  7079. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7080. }
  7081. }
  7082. declare module BABYLON {
  7083. /** @hidden */
  7084. export class Collider {
  7085. /** Define if a collision was found */
  7086. collisionFound: boolean;
  7087. /**
  7088. * Define last intersection point in local space
  7089. */
  7090. intersectionPoint: Vector3;
  7091. /**
  7092. * Define last collided mesh
  7093. */
  7094. collidedMesh: Nullable<AbstractMesh>;
  7095. private _collisionPoint;
  7096. private _planeIntersectionPoint;
  7097. private _tempVector;
  7098. private _tempVector2;
  7099. private _tempVector3;
  7100. private _tempVector4;
  7101. private _edge;
  7102. private _baseToVertex;
  7103. private _destinationPoint;
  7104. private _slidePlaneNormal;
  7105. private _displacementVector;
  7106. /** @hidden */
  7107. _radius: Vector3;
  7108. /** @hidden */
  7109. _retry: number;
  7110. private _velocity;
  7111. private _basePoint;
  7112. private _epsilon;
  7113. /** @hidden */
  7114. _velocityWorldLength: number;
  7115. /** @hidden */
  7116. _basePointWorld: Vector3;
  7117. private _velocityWorld;
  7118. private _normalizedVelocity;
  7119. /** @hidden */
  7120. _initialVelocity: Vector3;
  7121. /** @hidden */
  7122. _initialPosition: Vector3;
  7123. private _nearestDistance;
  7124. private _collisionMask;
  7125. collisionMask: number;
  7126. /**
  7127. * Gets the plane normal used to compute the sliding response (in local space)
  7128. */
  7129. readonly slidePlaneNormal: Vector3;
  7130. /** @hidden */
  7131. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7132. /** @hidden */
  7133. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7134. /** @hidden */
  7135. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7136. /** @hidden */
  7137. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7138. /** @hidden */
  7139. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7140. /** @hidden */
  7141. _getResponse(pos: Vector3, vel: Vector3): void;
  7142. }
  7143. }
  7144. declare module BABYLON {
  7145. /**
  7146. * Interface for cullable objects
  7147. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7148. */
  7149. export interface ICullable {
  7150. /**
  7151. * Checks if the object or part of the object is in the frustum
  7152. * @param frustumPlanes Camera near/planes
  7153. * @returns true if the object is in frustum otherwise false
  7154. */
  7155. isInFrustum(frustumPlanes: Plane[]): boolean;
  7156. /**
  7157. * Checks if a cullable object (mesh...) is in the camera frustum
  7158. * Unlike isInFrustum this cheks the full bounding box
  7159. * @param frustumPlanes Camera near/planes
  7160. * @returns true if the object is in frustum otherwise false
  7161. */
  7162. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7163. }
  7164. /**
  7165. * Info for a bounding data of a mesh
  7166. */
  7167. export class BoundingInfo implements ICullable {
  7168. /**
  7169. * Bounding box for the mesh
  7170. */
  7171. readonly boundingBox: BoundingBox;
  7172. /**
  7173. * Bounding sphere for the mesh
  7174. */
  7175. readonly boundingSphere: BoundingSphere;
  7176. private _isLocked;
  7177. private static readonly TmpVector3;
  7178. /**
  7179. * Constructs bounding info
  7180. * @param minimum min vector of the bounding box/sphere
  7181. * @param maximum max vector of the bounding box/sphere
  7182. * @param worldMatrix defines the new world matrix
  7183. */
  7184. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7185. /**
  7186. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7187. * @param min defines the new minimum vector (in local space)
  7188. * @param max defines the new maximum vector (in local space)
  7189. * @param worldMatrix defines the new world matrix
  7190. */
  7191. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7192. /**
  7193. * min vector of the bounding box/sphere
  7194. */
  7195. readonly minimum: Vector3;
  7196. /**
  7197. * max vector of the bounding box/sphere
  7198. */
  7199. readonly maximum: Vector3;
  7200. /**
  7201. * If the info is locked and won't be updated to avoid perf overhead
  7202. */
  7203. isLocked: boolean;
  7204. /**
  7205. * Updates the bounding sphere and box
  7206. * @param world world matrix to be used to update
  7207. */
  7208. update(world: DeepImmutable<Matrix>): void;
  7209. /**
  7210. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7211. * @param center New center of the bounding info
  7212. * @param extend New extend of the bounding info
  7213. * @returns the current bounding info
  7214. */
  7215. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7216. /**
  7217. * Scale the current bounding info by applying a scale factor
  7218. * @param factor defines the scale factor to apply
  7219. * @returns the current bounding info
  7220. */
  7221. scale(factor: number): BoundingInfo;
  7222. /**
  7223. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7224. * @param frustumPlanes defines the frustum to test
  7225. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7226. * @returns true if the bounding info is in the frustum planes
  7227. */
  7228. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7229. /**
  7230. * Gets the world distance between the min and max points of the bounding box
  7231. */
  7232. readonly diagonalLength: number;
  7233. /**
  7234. * Checks if a cullable object (mesh...) is in the camera frustum
  7235. * Unlike isInFrustum this cheks the full bounding box
  7236. * @param frustumPlanes Camera near/planes
  7237. * @returns true if the object is in frustum otherwise false
  7238. */
  7239. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7240. /** @hidden */
  7241. _checkCollision(collider: Collider): boolean;
  7242. /**
  7243. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7244. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7245. * @param point the point to check intersection with
  7246. * @returns if the point intersects
  7247. */
  7248. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7249. /**
  7250. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7251. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7252. * @param boundingInfo the bounding info to check intersection with
  7253. * @param precise if the intersection should be done using OBB
  7254. * @returns if the bounding info intersects
  7255. */
  7256. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Defines an array and its length.
  7262. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7263. */
  7264. export interface ISmartArrayLike<T> {
  7265. /**
  7266. * The data of the array.
  7267. */
  7268. data: Array<T>;
  7269. /**
  7270. * The active length of the array.
  7271. */
  7272. length: number;
  7273. }
  7274. /**
  7275. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7276. */
  7277. export class SmartArray<T> implements ISmartArrayLike<T> {
  7278. /**
  7279. * The full set of data from the array.
  7280. */
  7281. data: Array<T>;
  7282. /**
  7283. * The active length of the array.
  7284. */
  7285. length: number;
  7286. protected _id: number;
  7287. /**
  7288. * Instantiates a Smart Array.
  7289. * @param capacity defines the default capacity of the array.
  7290. */
  7291. constructor(capacity: number);
  7292. /**
  7293. * Pushes a value at the end of the active data.
  7294. * @param value defines the object to push in the array.
  7295. */
  7296. push(value: T): void;
  7297. /**
  7298. * Iterates over the active data and apply the lambda to them.
  7299. * @param func defines the action to apply on each value.
  7300. */
  7301. forEach(func: (content: T) => void): void;
  7302. /**
  7303. * Sorts the full sets of data.
  7304. * @param compareFn defines the comparison function to apply.
  7305. */
  7306. sort(compareFn: (a: T, b: T) => number): void;
  7307. /**
  7308. * Resets the active data to an empty array.
  7309. */
  7310. reset(): void;
  7311. /**
  7312. * Releases all the data from the array as well as the array.
  7313. */
  7314. dispose(): void;
  7315. /**
  7316. * Concats the active data with a given array.
  7317. * @param array defines the data to concatenate with.
  7318. */
  7319. concat(array: any): void;
  7320. /**
  7321. * Returns the position of a value in the active data.
  7322. * @param value defines the value to find the index for
  7323. * @returns the index if found in the active data otherwise -1
  7324. */
  7325. indexOf(value: T): number;
  7326. /**
  7327. * Returns whether an element is part of the active data.
  7328. * @param value defines the value to look for
  7329. * @returns true if found in the active data otherwise false
  7330. */
  7331. contains(value: T): boolean;
  7332. private static _GlobalId;
  7333. }
  7334. /**
  7335. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7336. * The data in this array can only be present once
  7337. */
  7338. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7339. private _duplicateId;
  7340. /**
  7341. * Pushes a value at the end of the active data.
  7342. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7343. * @param value defines the object to push in the array.
  7344. */
  7345. push(value: T): void;
  7346. /**
  7347. * Pushes a value at the end of the active data.
  7348. * If the data is already present, it won t be added again
  7349. * @param value defines the object to push in the array.
  7350. * @returns true if added false if it was already present
  7351. */
  7352. pushNoDuplicate(value: T): boolean;
  7353. /**
  7354. * Resets the active data to an empty array.
  7355. */
  7356. reset(): void;
  7357. /**
  7358. * Concats the active data with a given array.
  7359. * This ensures no dupplicate will be present in the result.
  7360. * @param array defines the data to concatenate with.
  7361. */
  7362. concatWithNoDuplicate(array: any): void;
  7363. }
  7364. }
  7365. declare module BABYLON {
  7366. /**
  7367. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7368. * separate meshes. This can be use to improve performances.
  7369. * @see http://doc.babylonjs.com/how_to/multi_materials
  7370. */
  7371. export class MultiMaterial extends Material {
  7372. private _subMaterials;
  7373. /**
  7374. * Gets or Sets the list of Materials used within the multi material.
  7375. * They need to be ordered according to the submeshes order in the associated mesh
  7376. */
  7377. subMaterials: Nullable<Material>[];
  7378. /**
  7379. * Function used to align with Node.getChildren()
  7380. * @returns the list of Materials used within the multi material
  7381. */
  7382. getChildren(): Nullable<Material>[];
  7383. /**
  7384. * Instantiates a new Multi Material
  7385. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7386. * separate meshes. This can be use to improve performances.
  7387. * @see http://doc.babylonjs.com/how_to/multi_materials
  7388. * @param name Define the name in the scene
  7389. * @param scene Define the scene the material belongs to
  7390. */
  7391. constructor(name: string, scene: Scene);
  7392. private _hookArray;
  7393. /**
  7394. * Get one of the submaterial by its index in the submaterials array
  7395. * @param index The index to look the sub material at
  7396. * @returns The Material if the index has been defined
  7397. */
  7398. getSubMaterial(index: number): Nullable<Material>;
  7399. /**
  7400. * Get the list of active textures for the whole sub materials list.
  7401. * @returns All the textures that will be used during the rendering
  7402. */
  7403. getActiveTextures(): BaseTexture[];
  7404. /**
  7405. * Gets the current class name of the material e.g. "MultiMaterial"
  7406. * Mainly use in serialization.
  7407. * @returns the class name
  7408. */
  7409. getClassName(): string;
  7410. /**
  7411. * Checks if the material is ready to render the requested sub mesh
  7412. * @param mesh Define the mesh the submesh belongs to
  7413. * @param subMesh Define the sub mesh to look readyness for
  7414. * @param useInstances Define whether or not the material is used with instances
  7415. * @returns true if ready, otherwise false
  7416. */
  7417. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7418. /**
  7419. * Clones the current material and its related sub materials
  7420. * @param name Define the name of the newly cloned material
  7421. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7422. * @returns the cloned material
  7423. */
  7424. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7425. /**
  7426. * Serializes the materials into a JSON representation.
  7427. * @returns the JSON representation
  7428. */
  7429. serialize(): any;
  7430. /**
  7431. * Dispose the material and release its associated resources
  7432. * @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)
  7433. * @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)
  7434. * @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)
  7435. */
  7436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7437. /**
  7438. * Creates a MultiMaterial from parsed MultiMaterial data.
  7439. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7440. * @param scene defines the hosting scene
  7441. * @returns a new MultiMaterial
  7442. */
  7443. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7444. }
  7445. }
  7446. declare module BABYLON {
  7447. /**
  7448. * Class used to represent data loading progression
  7449. */
  7450. export class SceneLoaderFlags {
  7451. private static _ForceFullSceneLoadingForIncremental;
  7452. private static _ShowLoadingScreen;
  7453. private static _CleanBoneMatrixWeights;
  7454. private static _loggingLevel;
  7455. /**
  7456. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7457. */
  7458. static ForceFullSceneLoadingForIncremental: boolean;
  7459. /**
  7460. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7461. */
  7462. static ShowLoadingScreen: boolean;
  7463. /**
  7464. * Defines the current logging level (while loading the scene)
  7465. * @ignorenaming
  7466. */
  7467. static loggingLevel: number;
  7468. /**
  7469. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7470. */
  7471. static CleanBoneMatrixWeights: boolean;
  7472. }
  7473. }
  7474. declare module BABYLON {
  7475. /**
  7476. * 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.
  7477. * @see https://doc.babylonjs.com/how_to/transformnode
  7478. */
  7479. export class TransformNode extends Node {
  7480. /**
  7481. * Object will not rotate to face the camera
  7482. */
  7483. static BILLBOARDMODE_NONE: number;
  7484. /**
  7485. * Object will rotate to face the camera but only on the x axis
  7486. */
  7487. static BILLBOARDMODE_X: number;
  7488. /**
  7489. * Object will rotate to face the camera but only on the y axis
  7490. */
  7491. static BILLBOARDMODE_Y: number;
  7492. /**
  7493. * Object will rotate to face the camera but only on the z axis
  7494. */
  7495. static BILLBOARDMODE_Z: number;
  7496. /**
  7497. * Object will rotate to face the camera
  7498. */
  7499. static BILLBOARDMODE_ALL: number;
  7500. private _forward;
  7501. private _forwardInverted;
  7502. private _up;
  7503. private _right;
  7504. private _rightInverted;
  7505. private _position;
  7506. private _rotation;
  7507. private _rotationQuaternion;
  7508. protected _scaling: Vector3;
  7509. protected _isDirty: boolean;
  7510. private _transformToBoneReferal;
  7511. /**
  7512. * Set the billboard mode. Default is 0.
  7513. *
  7514. * | Value | Type | Description |
  7515. * | --- | --- | --- |
  7516. * | 0 | BILLBOARDMODE_NONE | |
  7517. * | 1 | BILLBOARDMODE_X | |
  7518. * | 2 | BILLBOARDMODE_Y | |
  7519. * | 4 | BILLBOARDMODE_Z | |
  7520. * | 7 | BILLBOARDMODE_ALL | |
  7521. *
  7522. */
  7523. billboardMode: number;
  7524. /**
  7525. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7526. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7527. */
  7528. preserveParentRotationForBillboard: boolean;
  7529. /**
  7530. * 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
  7531. */
  7532. scalingDeterminant: number;
  7533. /**
  7534. * Sets the distance of the object to max, often used by skybox
  7535. */
  7536. infiniteDistance: boolean;
  7537. /**
  7538. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7539. * By default the system will update normals to compensate
  7540. */
  7541. ignoreNonUniformScaling: boolean;
  7542. /** @hidden */
  7543. _poseMatrix: Matrix;
  7544. /** @hidden */
  7545. _localMatrix: Matrix;
  7546. private _absolutePosition;
  7547. private _pivotMatrix;
  7548. private _pivotMatrixInverse;
  7549. protected _postMultiplyPivotMatrix: boolean;
  7550. private _tempMatrix;
  7551. private _tempMatrix2;
  7552. protected _isWorldMatrixFrozen: boolean;
  7553. /** @hidden */
  7554. _indexInSceneTransformNodesArray: number;
  7555. /**
  7556. * An event triggered after the world matrix is updated
  7557. */
  7558. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7559. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7560. /**
  7561. * Gets a string identifying the name of the class
  7562. * @returns "TransformNode" string
  7563. */
  7564. getClassName(): string;
  7565. /**
  7566. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7567. */
  7568. position: Vector3;
  7569. /**
  7570. * 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)).
  7571. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7572. */
  7573. rotation: Vector3;
  7574. /**
  7575. * 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)).
  7576. */
  7577. scaling: Vector3;
  7578. /**
  7579. * 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).
  7580. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7581. */
  7582. rotationQuaternion: Nullable<Quaternion>;
  7583. /**
  7584. * The forward direction of that transform in world space.
  7585. */
  7586. readonly forward: Vector3;
  7587. /**
  7588. * The up direction of that transform in world space.
  7589. */
  7590. readonly up: Vector3;
  7591. /**
  7592. * The right direction of that transform in world space.
  7593. */
  7594. readonly right: Vector3;
  7595. /**
  7596. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7597. * @param matrix the matrix to copy the pose from
  7598. * @returns this TransformNode.
  7599. */
  7600. updatePoseMatrix(matrix: Matrix): TransformNode;
  7601. /**
  7602. * Returns the mesh Pose matrix.
  7603. * @returns the pose matrix
  7604. */
  7605. getPoseMatrix(): Matrix;
  7606. /** @hidden */
  7607. _isSynchronized(): boolean;
  7608. /** @hidden */
  7609. _initCache(): void;
  7610. /**
  7611. * Flag the transform node as dirty (Forcing it to update everything)
  7612. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7613. * @returns this transform node
  7614. */
  7615. markAsDirty(property: string): TransformNode;
  7616. /**
  7617. * Returns the current mesh absolute position.
  7618. * Returns a Vector3.
  7619. */
  7620. readonly absolutePosition: Vector3;
  7621. /**
  7622. * Sets a new matrix to apply before all other transformation
  7623. * @param matrix defines the transform matrix
  7624. * @returns the current TransformNode
  7625. */
  7626. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7627. /**
  7628. * Sets a new pivot matrix to the current node
  7629. * @param matrix defines the new pivot matrix to use
  7630. * @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
  7631. * @returns the current TransformNode
  7632. */
  7633. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7634. /**
  7635. * Returns the mesh pivot matrix.
  7636. * Default : Identity.
  7637. * @returns the matrix
  7638. */
  7639. getPivotMatrix(): Matrix;
  7640. /**
  7641. * Prevents the World matrix to be computed any longer.
  7642. * @returns the TransformNode.
  7643. */
  7644. freezeWorldMatrix(): TransformNode;
  7645. /**
  7646. * Allows back the World matrix computation.
  7647. * @returns the TransformNode.
  7648. */
  7649. unfreezeWorldMatrix(): this;
  7650. /**
  7651. * True if the World matrix has been frozen.
  7652. */
  7653. readonly isWorldMatrixFrozen: boolean;
  7654. /**
  7655. * Retuns the mesh absolute position in the World.
  7656. * @returns a Vector3.
  7657. */
  7658. getAbsolutePosition(): Vector3;
  7659. /**
  7660. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7661. * @param absolutePosition the absolute position to set
  7662. * @returns the TransformNode.
  7663. */
  7664. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7665. /**
  7666. * Sets the mesh position in its local space.
  7667. * @param vector3 the position to set in localspace
  7668. * @returns the TransformNode.
  7669. */
  7670. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7671. /**
  7672. * Returns the mesh position in the local space from the current World matrix values.
  7673. * @returns a new Vector3.
  7674. */
  7675. getPositionExpressedInLocalSpace(): Vector3;
  7676. /**
  7677. * Translates the mesh along the passed Vector3 in its local space.
  7678. * @param vector3 the distance to translate in localspace
  7679. * @returns the TransformNode.
  7680. */
  7681. locallyTranslate(vector3: Vector3): TransformNode;
  7682. private static _lookAtVectorCache;
  7683. /**
  7684. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7685. * @param targetPoint the position (must be in same space as current mesh) to look at
  7686. * @param yawCor optional yaw (y-axis) correction in radians
  7687. * @param pitchCor optional pitch (x-axis) correction in radians
  7688. * @param rollCor optional roll (z-axis) correction in radians
  7689. * @param space the choosen space of the target
  7690. * @returns the TransformNode.
  7691. */
  7692. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7693. /**
  7694. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7695. * This Vector3 is expressed in the World space.
  7696. * @param localAxis axis to rotate
  7697. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7698. */
  7699. getDirection(localAxis: Vector3): Vector3;
  7700. /**
  7701. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7702. * localAxis is expressed in the mesh local space.
  7703. * result is computed in the Wordl space from the mesh World matrix.
  7704. * @param localAxis axis to rotate
  7705. * @param result the resulting transformnode
  7706. * @returns this TransformNode.
  7707. */
  7708. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7709. /**
  7710. * Sets this transform node rotation to the given local axis.
  7711. * @param localAxis the axis in local space
  7712. * @param yawCor optional yaw (y-axis) correction in radians
  7713. * @param pitchCor optional pitch (x-axis) correction in radians
  7714. * @param rollCor optional roll (z-axis) correction in radians
  7715. * @returns this TransformNode
  7716. */
  7717. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7718. /**
  7719. * Sets a new pivot point to the current node
  7720. * @param point defines the new pivot point to use
  7721. * @param space defines if the point is in world or local space (local by default)
  7722. * @returns the current TransformNode
  7723. */
  7724. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7725. /**
  7726. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7727. * @returns the pivot point
  7728. */
  7729. getPivotPoint(): Vector3;
  7730. /**
  7731. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7732. * @param result the vector3 to store the result
  7733. * @returns this TransformNode.
  7734. */
  7735. getPivotPointToRef(result: Vector3): TransformNode;
  7736. /**
  7737. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7738. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7739. */
  7740. getAbsolutePivotPoint(): Vector3;
  7741. /**
  7742. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7743. * @param result vector3 to store the result
  7744. * @returns this TransformNode.
  7745. */
  7746. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7747. /**
  7748. * Defines the passed node as the parent of the current node.
  7749. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7750. * @see https://doc.babylonjs.com/how_to/parenting
  7751. * @param node the node ot set as the parent
  7752. * @returns this TransformNode.
  7753. */
  7754. setParent(node: Nullable<Node>): TransformNode;
  7755. private _nonUniformScaling;
  7756. /**
  7757. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7758. */
  7759. readonly nonUniformScaling: boolean;
  7760. /** @hidden */
  7761. _updateNonUniformScalingState(value: boolean): boolean;
  7762. /**
  7763. * Attach the current TransformNode to another TransformNode associated with a bone
  7764. * @param bone Bone affecting the TransformNode
  7765. * @param affectedTransformNode TransformNode associated with the bone
  7766. * @returns this object
  7767. */
  7768. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7769. /**
  7770. * Detach the transform node if its associated with a bone
  7771. * @returns this object
  7772. */
  7773. detachFromBone(): TransformNode;
  7774. private static _rotationAxisCache;
  7775. /**
  7776. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7777. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7778. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7779. * The passed axis is also normalized.
  7780. * @param axis the axis to rotate around
  7781. * @param amount the amount to rotate in radians
  7782. * @param space Space to rotate in (Default: local)
  7783. * @returns the TransformNode.
  7784. */
  7785. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7786. /**
  7787. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7788. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7789. * The passed axis is also normalized. .
  7790. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7791. * @param point the point to rotate around
  7792. * @param axis the axis to rotate around
  7793. * @param amount the amount to rotate in radians
  7794. * @returns the TransformNode
  7795. */
  7796. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7797. /**
  7798. * Translates the mesh along the axis vector for the passed distance in the given space.
  7799. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7800. * @param axis the axis to translate in
  7801. * @param distance the distance to translate
  7802. * @param space Space to rotate in (Default: local)
  7803. * @returns the TransformNode.
  7804. */
  7805. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7806. /**
  7807. * Adds a rotation step to the mesh current rotation.
  7808. * x, y, z are Euler angles expressed in radians.
  7809. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7810. * This means this rotation is made in the mesh local space only.
  7811. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7812. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7813. * ```javascript
  7814. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7815. * ```
  7816. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7817. * 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.
  7818. * @param x Rotation to add
  7819. * @param y Rotation to add
  7820. * @param z Rotation to add
  7821. * @returns the TransformNode.
  7822. */
  7823. addRotation(x: number, y: number, z: number): TransformNode;
  7824. /**
  7825. * @hidden
  7826. */
  7827. protected _getEffectiveParent(): Nullable<Node>;
  7828. /**
  7829. * Computes the world matrix of the node
  7830. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7831. * @returns the world matrix
  7832. */
  7833. computeWorldMatrix(force?: boolean): Matrix;
  7834. protected _afterComputeWorldMatrix(): void;
  7835. /**
  7836. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7837. * @param func callback function to add
  7838. *
  7839. * @returns the TransformNode.
  7840. */
  7841. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7842. /**
  7843. * Removes a registered callback function.
  7844. * @param func callback function to remove
  7845. * @returns the TransformNode.
  7846. */
  7847. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7848. /**
  7849. * Gets the position of the current mesh in camera space
  7850. * @param camera defines the camera to use
  7851. * @returns a position
  7852. */
  7853. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7854. /**
  7855. * Returns the distance from the mesh to the active camera
  7856. * @param camera defines the camera to use
  7857. * @returns the distance
  7858. */
  7859. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7860. /**
  7861. * Clone the current transform node
  7862. * @param name Name of the new clone
  7863. * @param newParent New parent for the clone
  7864. * @param doNotCloneChildren Do not clone children hierarchy
  7865. * @returns the new transform node
  7866. */
  7867. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7868. /**
  7869. * Serializes the objects information.
  7870. * @param currentSerializationObject defines the object to serialize in
  7871. * @returns the serialized object
  7872. */
  7873. serialize(currentSerializationObject?: any): any;
  7874. /**
  7875. * Returns a new TransformNode object parsed from the source provided.
  7876. * @param parsedTransformNode is the source.
  7877. * @param scene the scne the object belongs to
  7878. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7879. * @returns a new TransformNode object parsed from the source provided.
  7880. */
  7881. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7882. /**
  7883. * Get all child-transformNodes of this node
  7884. * @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
  7885. * @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
  7886. * @returns an array of TransformNode
  7887. */
  7888. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7889. /**
  7890. * Releases resources associated with this transform node.
  7891. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7892. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7893. */
  7894. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7895. }
  7896. }
  7897. declare module BABYLON {
  7898. /**
  7899. * Class used to override all child animations of a given target
  7900. */
  7901. export class AnimationPropertiesOverride {
  7902. /**
  7903. * Gets or sets a value indicating if animation blending must be used
  7904. */
  7905. enableBlending: boolean;
  7906. /**
  7907. * Gets or sets the blending speed to use when enableBlending is true
  7908. */
  7909. blendingSpeed: number;
  7910. /**
  7911. * Gets or sets the default loop mode to use
  7912. */
  7913. loopMode: number;
  7914. }
  7915. }
  7916. declare module BABYLON {
  7917. /**
  7918. * Class used to store bone information
  7919. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7920. */
  7921. export class Bone extends Node {
  7922. /**
  7923. * defines the bone name
  7924. */
  7925. name: string;
  7926. private static _tmpVecs;
  7927. private static _tmpQuat;
  7928. private static _tmpMats;
  7929. /**
  7930. * Gets the list of child bones
  7931. */
  7932. children: Bone[];
  7933. /** Gets the animations associated with this bone */
  7934. animations: Animation[];
  7935. /**
  7936. * Gets or sets bone length
  7937. */
  7938. length: number;
  7939. /**
  7940. * @hidden Internal only
  7941. * Set this value to map this bone to a different index in the transform matrices
  7942. * Set this value to -1 to exclude the bone from the transform matrices
  7943. */
  7944. _index: Nullable<number>;
  7945. private _skeleton;
  7946. private _localMatrix;
  7947. private _restPose;
  7948. private _baseMatrix;
  7949. private _absoluteTransform;
  7950. private _invertedAbsoluteTransform;
  7951. private _parent;
  7952. private _scalingDeterminant;
  7953. private _worldTransform;
  7954. private _localScaling;
  7955. private _localRotation;
  7956. private _localPosition;
  7957. private _needToDecompose;
  7958. private _needToCompose;
  7959. /** @hidden */
  7960. _linkedTransformNode: Nullable<TransformNode>;
  7961. /** @hidden */
  7962. /** @hidden */
  7963. _matrix: Matrix;
  7964. /**
  7965. * Create a new bone
  7966. * @param name defines the bone name
  7967. * @param skeleton defines the parent skeleton
  7968. * @param parentBone defines the parent (can be null if the bone is the root)
  7969. * @param localMatrix defines the local matrix
  7970. * @param restPose defines the rest pose matrix
  7971. * @param baseMatrix defines the base matrix
  7972. * @param index defines index of the bone in the hiearchy
  7973. */
  7974. constructor(
  7975. /**
  7976. * defines the bone name
  7977. */
  7978. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7979. /**
  7980. * Gets the current object class name.
  7981. * @return the class name
  7982. */
  7983. getClassName(): string;
  7984. /**
  7985. * Gets the parent skeleton
  7986. * @returns a skeleton
  7987. */
  7988. getSkeleton(): Skeleton;
  7989. /**
  7990. * Gets parent bone
  7991. * @returns a bone or null if the bone is the root of the bone hierarchy
  7992. */
  7993. getParent(): Nullable<Bone>;
  7994. /**
  7995. * Returns an array containing the root bones
  7996. * @returns an array containing the root bones
  7997. */
  7998. getChildren(): Array<Bone>;
  7999. /**
  8000. * Sets the parent bone
  8001. * @param parent defines the parent (can be null if the bone is the root)
  8002. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8003. */
  8004. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8005. /**
  8006. * Gets the local matrix
  8007. * @returns a matrix
  8008. */
  8009. getLocalMatrix(): Matrix;
  8010. /**
  8011. * Gets the base matrix (initial matrix which remains unchanged)
  8012. * @returns a matrix
  8013. */
  8014. getBaseMatrix(): Matrix;
  8015. /**
  8016. * Gets the rest pose matrix
  8017. * @returns a matrix
  8018. */
  8019. getRestPose(): Matrix;
  8020. /**
  8021. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8022. */
  8023. getWorldMatrix(): Matrix;
  8024. /**
  8025. * Sets the local matrix to rest pose matrix
  8026. */
  8027. returnToRest(): void;
  8028. /**
  8029. * Gets the inverse of the absolute transform matrix.
  8030. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8031. * @returns a matrix
  8032. */
  8033. getInvertedAbsoluteTransform(): Matrix;
  8034. /**
  8035. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8036. * @returns a matrix
  8037. */
  8038. getAbsoluteTransform(): Matrix;
  8039. /**
  8040. * Links with the given transform node.
  8041. * The local matrix of this bone is copied from the transform node every frame.
  8042. * @param transformNode defines the transform node to link to
  8043. */
  8044. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8045. /** Gets or sets current position (in local space) */
  8046. position: Vector3;
  8047. /** Gets or sets current rotation (in local space) */
  8048. rotation: Vector3;
  8049. /** Gets or sets current rotation quaternion (in local space) */
  8050. rotationQuaternion: Quaternion;
  8051. /** Gets or sets current scaling (in local space) */
  8052. scaling: Vector3;
  8053. /**
  8054. * Gets the animation properties override
  8055. */
  8056. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8057. private _decompose;
  8058. private _compose;
  8059. /**
  8060. * Update the base and local matrices
  8061. * @param matrix defines the new base or local matrix
  8062. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8063. * @param updateLocalMatrix defines if the local matrix should be updated
  8064. */
  8065. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8066. /** @hidden */
  8067. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8068. /**
  8069. * Flag the bone as dirty (Forcing it to update everything)
  8070. */
  8071. markAsDirty(): void;
  8072. private _markAsDirtyAndCompose;
  8073. private _markAsDirtyAndDecompose;
  8074. /**
  8075. * Translate the bone in local or world space
  8076. * @param vec The amount to translate the bone
  8077. * @param space The space that the translation is in
  8078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8079. */
  8080. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8081. /**
  8082. * Set the postion of the bone in local or world space
  8083. * @param position The position to set the bone
  8084. * @param space The space that the position is in
  8085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8086. */
  8087. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8088. /**
  8089. * Set the absolute position of the bone (world space)
  8090. * @param position The position to set the bone
  8091. * @param mesh The mesh that this bone is attached to
  8092. */
  8093. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8094. /**
  8095. * Scale the bone on the x, y and z axes (in local space)
  8096. * @param x The amount to scale the bone on the x axis
  8097. * @param y The amount to scale the bone on the y axis
  8098. * @param z The amount to scale the bone on the z axis
  8099. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8100. */
  8101. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8102. /**
  8103. * Set the bone scaling in local space
  8104. * @param scale defines the scaling vector
  8105. */
  8106. setScale(scale: Vector3): void;
  8107. /**
  8108. * Gets the current scaling in local space
  8109. * @returns the current scaling vector
  8110. */
  8111. getScale(): Vector3;
  8112. /**
  8113. * Gets the current scaling in local space and stores it in a target vector
  8114. * @param result defines the target vector
  8115. */
  8116. getScaleToRef(result: Vector3): void;
  8117. /**
  8118. * Set the yaw, pitch, and roll of the bone in local or world space
  8119. * @param yaw The rotation of the bone on the y axis
  8120. * @param pitch The rotation of the bone on the x axis
  8121. * @param roll The rotation of the bone on the z axis
  8122. * @param space The space that the axes of rotation are in
  8123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8124. */
  8125. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8126. /**
  8127. * Add a rotation to the bone on an axis in local or world space
  8128. * @param axis The axis to rotate the bone on
  8129. * @param amount The amount to rotate the bone
  8130. * @param space The space that the axis is in
  8131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8132. */
  8133. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8134. /**
  8135. * Set the rotation of the bone to a particular axis angle in local or world space
  8136. * @param axis The axis to rotate the bone on
  8137. * @param angle The angle that the bone should be rotated to
  8138. * @param space The space that the axis is in
  8139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8140. */
  8141. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8142. /**
  8143. * Set the euler rotation of the bone in local of world space
  8144. * @param rotation The euler rotation that the bone should be set to
  8145. * @param space The space that the rotation is in
  8146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8147. */
  8148. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8149. /**
  8150. * Set the quaternion rotation of the bone in local of world space
  8151. * @param quat The quaternion rotation that the bone should be set to
  8152. * @param space The space that the rotation is in
  8153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8154. */
  8155. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8156. /**
  8157. * Set the rotation matrix of the bone in local of world space
  8158. * @param rotMat The rotation matrix that the bone should be set to
  8159. * @param space The space that the rotation is in
  8160. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8161. */
  8162. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8163. private _rotateWithMatrix;
  8164. private _getNegativeRotationToRef;
  8165. /**
  8166. * Get the position of the bone in local or world space
  8167. * @param space The space that the returned position is in
  8168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8169. * @returns The position of the bone
  8170. */
  8171. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8172. /**
  8173. * Copy the position of the bone to a vector3 in local or world space
  8174. * @param space The space that the returned position is in
  8175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8176. * @param result The vector3 to copy the position to
  8177. */
  8178. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8179. /**
  8180. * Get the absolute position of the bone (world space)
  8181. * @param mesh The mesh that this bone is attached to
  8182. * @returns The absolute position of the bone
  8183. */
  8184. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8185. /**
  8186. * Copy the absolute position of the bone (world space) to the result param
  8187. * @param mesh The mesh that this bone is attached to
  8188. * @param result The vector3 to copy the absolute position to
  8189. */
  8190. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8191. /**
  8192. * Compute the absolute transforms of this bone and its children
  8193. */
  8194. computeAbsoluteTransforms(): void;
  8195. /**
  8196. * Get the world direction from an axis that is in the local space of the bone
  8197. * @param localAxis The local direction that is used to compute the world direction
  8198. * @param mesh The mesh that this bone is attached to
  8199. * @returns The world direction
  8200. */
  8201. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8202. /**
  8203. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8204. * @param localAxis The local direction that is used to compute the world direction
  8205. * @param mesh The mesh that this bone is attached to
  8206. * @param result The vector3 that the world direction will be copied to
  8207. */
  8208. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8209. /**
  8210. * Get the euler rotation of the bone in local or world space
  8211. * @param space The space that the rotation should be in
  8212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8213. * @returns The euler rotation
  8214. */
  8215. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8216. /**
  8217. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8218. * @param space The space that the rotation should be in
  8219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8220. * @param result The vector3 that the rotation should be copied to
  8221. */
  8222. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8223. /**
  8224. * Get the quaternion rotation of the bone in either local or world space
  8225. * @param space The space that the rotation should be in
  8226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8227. * @returns The quaternion rotation
  8228. */
  8229. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8230. /**
  8231. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8232. * @param space The space that the rotation should be in
  8233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8234. * @param result The quaternion that the rotation should be copied to
  8235. */
  8236. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8237. /**
  8238. * Get the rotation matrix of the bone in local or world space
  8239. * @param space The space that the rotation should be in
  8240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8241. * @returns The rotation matrix
  8242. */
  8243. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8244. /**
  8245. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8246. * @param space The space that the rotation should be in
  8247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8248. * @param result The quaternion that the rotation should be copied to
  8249. */
  8250. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8251. /**
  8252. * Get the world position of a point that is in the local space of the bone
  8253. * @param position The local position
  8254. * @param mesh The mesh that this bone is attached to
  8255. * @returns The world position
  8256. */
  8257. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8258. /**
  8259. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8260. * @param position The local position
  8261. * @param mesh The mesh that this bone is attached to
  8262. * @param result The vector3 that the world position should be copied to
  8263. */
  8264. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8265. /**
  8266. * Get the local position of a point that is in world space
  8267. * @param position The world position
  8268. * @param mesh The mesh that this bone is attached to
  8269. * @returns The local position
  8270. */
  8271. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8272. /**
  8273. * Get the local position of a point that is in world space and copy it to the result param
  8274. * @param position The world position
  8275. * @param mesh The mesh that this bone is attached to
  8276. * @param result The vector3 that the local position should be copied to
  8277. */
  8278. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8279. }
  8280. }
  8281. declare module BABYLON {
  8282. /**
  8283. * Enum that determines the text-wrapping mode to use.
  8284. */
  8285. export enum InspectableType {
  8286. /**
  8287. * Checkbox for booleans
  8288. */
  8289. Checkbox = 0,
  8290. /**
  8291. * Sliders for numbers
  8292. */
  8293. Slider = 1,
  8294. /**
  8295. * Vector3
  8296. */
  8297. Vector3 = 2,
  8298. /**
  8299. * Quaternions
  8300. */
  8301. Quaternion = 3,
  8302. /**
  8303. * Color3
  8304. */
  8305. Color3 = 4
  8306. }
  8307. /**
  8308. * Interface used to define custom inspectable properties.
  8309. * This interface is used by the inspector to display custom property grids
  8310. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8311. */
  8312. export interface IInspectable {
  8313. /**
  8314. * Gets the label to display
  8315. */
  8316. label: string;
  8317. /**
  8318. * Gets the name of the property to edit
  8319. */
  8320. propertyName: string;
  8321. /**
  8322. * Gets the type of the editor to use
  8323. */
  8324. type: InspectableType;
  8325. /**
  8326. * Gets the minimum value of the property when using in "slider" mode
  8327. */
  8328. min?: number;
  8329. /**
  8330. * Gets the maximum value of the property when using in "slider" mode
  8331. */
  8332. max?: number;
  8333. /**
  8334. * Gets the setp to use when using in "slider" mode
  8335. */
  8336. step?: number;
  8337. }
  8338. }
  8339. declare module BABYLON {
  8340. /**
  8341. * Class for creating a cube texture
  8342. */
  8343. export class CubeTexture extends BaseTexture {
  8344. private _delayedOnLoad;
  8345. /**
  8346. * The url of the texture
  8347. */
  8348. url: string;
  8349. /**
  8350. * Gets or sets the center of the bounding box associated with the cube texture.
  8351. * It must define where the camera used to render the texture was set
  8352. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8353. */
  8354. boundingBoxPosition: Vector3;
  8355. private _boundingBoxSize;
  8356. /**
  8357. * Gets or sets the size of the bounding box associated with the cube texture
  8358. * When defined, the cubemap will switch to local mode
  8359. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8360. * @example https://www.babylonjs-playground.com/#RNASML
  8361. */
  8362. /**
  8363. * Returns the bounding box size
  8364. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8365. */
  8366. boundingBoxSize: Vector3;
  8367. protected _rotationY: number;
  8368. /**
  8369. * Sets texture matrix rotation angle around Y axis in radians.
  8370. */
  8371. /**
  8372. * Gets texture matrix rotation angle around Y axis radians.
  8373. */
  8374. rotationY: number;
  8375. /**
  8376. * Are mip maps generated for this texture or not.
  8377. */
  8378. readonly noMipmap: boolean;
  8379. private _noMipmap;
  8380. private _files;
  8381. private _extensions;
  8382. private _textureMatrix;
  8383. private _format;
  8384. private _createPolynomials;
  8385. /** @hidden */
  8386. _prefiltered: boolean;
  8387. /**
  8388. * Creates a cube texture from an array of image urls
  8389. * @param files defines an array of image urls
  8390. * @param scene defines the hosting scene
  8391. * @param noMipmap specifies if mip maps are not used
  8392. * @returns a cube texture
  8393. */
  8394. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8395. /**
  8396. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8397. * @param url defines the url of the prefiltered texture
  8398. * @param scene defines the scene the texture is attached to
  8399. * @param forcedExtension defines the extension of the file if different from the url
  8400. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8401. * @return the prefiltered texture
  8402. */
  8403. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8404. /**
  8405. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8406. * as prefiltered data.
  8407. * @param rootUrl defines the url of the texture or the root name of the six images
  8408. * @param scene defines the scene the texture is attached to
  8409. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8410. * @param noMipmap defines if mipmaps should be created or not
  8411. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8412. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8413. * @param onError defines a callback triggered in case of error during load
  8414. * @param format defines the internal format to use for the texture once loaded
  8415. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8416. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8417. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8418. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8419. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8420. * @return the cube texture
  8421. */
  8422. 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);
  8423. /**
  8424. * Get the current class name of the texture useful for serialization or dynamic coding.
  8425. * @returns "CubeTexture"
  8426. */
  8427. getClassName(): string;
  8428. /**
  8429. * Update the url (and optional buffer) of this texture if url was null during construction.
  8430. * @param url the url of the texture
  8431. * @param forcedExtension defines the extension to use
  8432. * @param onLoad callback called when the texture is loaded (defaults to null)
  8433. */
  8434. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8435. /**
  8436. * Delays loading of the cube texture
  8437. * @param forcedExtension defines the extension to use
  8438. */
  8439. delayLoad(forcedExtension?: string): void;
  8440. /**
  8441. * Returns the reflection texture matrix
  8442. * @returns the reflection texture matrix
  8443. */
  8444. getReflectionTextureMatrix(): Matrix;
  8445. /**
  8446. * Sets the reflection texture matrix
  8447. * @param value Reflection texture matrix
  8448. */
  8449. setReflectionTextureMatrix(value: Matrix): void;
  8450. /**
  8451. * Parses text to create a cube texture
  8452. * @param parsedTexture define the serialized text to read from
  8453. * @param scene defines the hosting scene
  8454. * @param rootUrl defines the root url of the cube texture
  8455. * @returns a cube texture
  8456. */
  8457. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8458. /**
  8459. * Makes a clone, or deep copy, of the cube texture
  8460. * @returns a new cube texture
  8461. */
  8462. clone(): CubeTexture;
  8463. }
  8464. }
  8465. declare module BABYLON {
  8466. /** @hidden */
  8467. export var postprocessVertexShader: {
  8468. name: string;
  8469. shader: string;
  8470. };
  8471. }
  8472. declare module BABYLON {
  8473. /**
  8474. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8475. * This is the base of the follow, arc rotate cameras and Free camera
  8476. * @see http://doc.babylonjs.com/features/cameras
  8477. */
  8478. export class TargetCamera extends Camera {
  8479. private static _RigCamTransformMatrix;
  8480. private static _TargetTransformMatrix;
  8481. private static _TargetFocalPoint;
  8482. /**
  8483. * Define the current direction the camera is moving to
  8484. */
  8485. cameraDirection: Vector3;
  8486. /**
  8487. * Define the current rotation the camera is rotating to
  8488. */
  8489. cameraRotation: Vector2;
  8490. /**
  8491. * When set, the up vector of the camera will be updated by the rotation of the camera
  8492. */
  8493. updateUpVectorFromRotation: boolean;
  8494. private _tmpQuaternion;
  8495. /**
  8496. * Define the current rotation of the camera
  8497. */
  8498. rotation: Vector3;
  8499. /**
  8500. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8501. */
  8502. rotationQuaternion: Quaternion;
  8503. /**
  8504. * Define the current speed of the camera
  8505. */
  8506. speed: number;
  8507. /**
  8508. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8509. * around all axis.
  8510. */
  8511. noRotationConstraint: boolean;
  8512. /**
  8513. * Define the current target of the camera as an object or a position.
  8514. */
  8515. lockedTarget: any;
  8516. /** @hidden */
  8517. _currentTarget: Vector3;
  8518. /** @hidden */
  8519. _initialFocalDistance: number;
  8520. /** @hidden */
  8521. _viewMatrix: Matrix;
  8522. /** @hidden */
  8523. _camMatrix: Matrix;
  8524. /** @hidden */
  8525. _cameraTransformMatrix: Matrix;
  8526. /** @hidden */
  8527. _cameraRotationMatrix: Matrix;
  8528. /** @hidden */
  8529. _referencePoint: Vector3;
  8530. /** @hidden */
  8531. _transformedReferencePoint: Vector3;
  8532. protected _globalCurrentTarget: Vector3;
  8533. protected _globalCurrentUpVector: Vector3;
  8534. /** @hidden */
  8535. _reset: () => void;
  8536. private _defaultUp;
  8537. /**
  8538. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8539. * This is the base of the follow, arc rotate cameras and Free camera
  8540. * @see http://doc.babylonjs.com/features/cameras
  8541. * @param name Defines the name of the camera in the scene
  8542. * @param position Defines the start position of the camera in the scene
  8543. * @param scene Defines the scene the camera belongs to
  8544. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8545. */
  8546. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8547. /**
  8548. * Gets the position in front of the camera at a given distance.
  8549. * @param distance The distance from the camera we want the position to be
  8550. * @returns the position
  8551. */
  8552. getFrontPosition(distance: number): Vector3;
  8553. /** @hidden */
  8554. _getLockedTargetPosition(): Nullable<Vector3>;
  8555. private _storedPosition;
  8556. private _storedRotation;
  8557. private _storedRotationQuaternion;
  8558. /**
  8559. * Store current camera state of the camera (fov, position, rotation, etc..)
  8560. * @returns the camera
  8561. */
  8562. storeState(): Camera;
  8563. /**
  8564. * Restored camera state. You must call storeState() first
  8565. * @returns whether it was successful or not
  8566. * @hidden
  8567. */
  8568. _restoreStateValues(): boolean;
  8569. /** @hidden */
  8570. _initCache(): void;
  8571. /** @hidden */
  8572. _updateCache(ignoreParentClass?: boolean): void;
  8573. /** @hidden */
  8574. _isSynchronizedViewMatrix(): boolean;
  8575. /** @hidden */
  8576. _computeLocalCameraSpeed(): number;
  8577. /**
  8578. * Defines the target the camera should look at.
  8579. * This will automatically adapt alpha beta and radius to fit within the new target.
  8580. * @param target Defines the new target as a Vector or a mesh
  8581. */
  8582. setTarget(target: Vector3): void;
  8583. /**
  8584. * Return the current target position of the camera. This value is expressed in local space.
  8585. * @returns the target position
  8586. */
  8587. getTarget(): Vector3;
  8588. /** @hidden */
  8589. _decideIfNeedsToMove(): boolean;
  8590. /** @hidden */
  8591. _updatePosition(): void;
  8592. /** @hidden */
  8593. _checkInputs(): void;
  8594. protected _updateCameraRotationMatrix(): void;
  8595. /**
  8596. * 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)
  8597. * @returns the current camera
  8598. */
  8599. private _rotateUpVectorWithCameraRotationMatrix;
  8600. private _cachedRotationZ;
  8601. private _cachedQuaternionRotationZ;
  8602. /** @hidden */
  8603. _getViewMatrix(): Matrix;
  8604. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8605. /**
  8606. * @hidden
  8607. */
  8608. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8609. /**
  8610. * @hidden
  8611. */
  8612. _updateRigCameras(): void;
  8613. private _getRigCamPositionAndTarget;
  8614. /**
  8615. * Gets the current object class name.
  8616. * @return the class name
  8617. */
  8618. getClassName(): string;
  8619. }
  8620. }
  8621. declare module BABYLON {
  8622. /**
  8623. * @ignore
  8624. * This is a list of all the different input types that are available in the application.
  8625. * Fo instance: ArcRotateCameraGamepadInput...
  8626. */
  8627. export var CameraInputTypes: {};
  8628. /**
  8629. * This is the contract to implement in order to create a new input class.
  8630. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8631. */
  8632. export interface ICameraInput<TCamera extends Camera> {
  8633. /**
  8634. * Defines the camera the input is attached to.
  8635. */
  8636. camera: Nullable<TCamera>;
  8637. /**
  8638. * Gets the class name of the current intput.
  8639. * @returns the class name
  8640. */
  8641. getClassName(): string;
  8642. /**
  8643. * Get the friendly name associated with the input class.
  8644. * @returns the input friendly name
  8645. */
  8646. getSimpleName(): string;
  8647. /**
  8648. * Attach the input controls to a specific dom element to get the input from.
  8649. * @param element Defines the element the controls should be listened from
  8650. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8651. */
  8652. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8653. /**
  8654. * Detach the current controls from the specified dom element.
  8655. * @param element Defines the element to stop listening the inputs from
  8656. */
  8657. detachControl(element: Nullable<HTMLElement>): void;
  8658. /**
  8659. * Update the current camera state depending on the inputs that have been used this frame.
  8660. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8661. */
  8662. checkInputs?: () => void;
  8663. }
  8664. /**
  8665. * Represents a map of input types to input instance or input index to input instance.
  8666. */
  8667. export interface CameraInputsMap<TCamera extends Camera> {
  8668. /**
  8669. * Accessor to the input by input type.
  8670. */
  8671. [name: string]: ICameraInput<TCamera>;
  8672. /**
  8673. * Accessor to the input by input index.
  8674. */
  8675. [idx: number]: ICameraInput<TCamera>;
  8676. }
  8677. /**
  8678. * This represents the input manager used within a camera.
  8679. * It helps dealing with all the different kind of input attached to a camera.
  8680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8681. */
  8682. export class CameraInputsManager<TCamera extends Camera> {
  8683. /**
  8684. * Defines the list of inputs attahed to the camera.
  8685. */
  8686. attached: CameraInputsMap<TCamera>;
  8687. /**
  8688. * Defines the dom element the camera is collecting inputs from.
  8689. * This is null if the controls have not been attached.
  8690. */
  8691. attachedElement: Nullable<HTMLElement>;
  8692. /**
  8693. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8694. */
  8695. noPreventDefault: boolean;
  8696. /**
  8697. * Defined the camera the input manager belongs to.
  8698. */
  8699. camera: TCamera;
  8700. /**
  8701. * Update the current camera state depending on the inputs that have been used this frame.
  8702. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8703. */
  8704. checkInputs: () => void;
  8705. /**
  8706. * Instantiate a new Camera Input Manager.
  8707. * @param camera Defines the camera the input manager blongs to
  8708. */
  8709. constructor(camera: TCamera);
  8710. /**
  8711. * Add an input method to a camera
  8712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8713. * @param input camera input method
  8714. */
  8715. add(input: ICameraInput<TCamera>): void;
  8716. /**
  8717. * Remove a specific input method from a camera
  8718. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8719. * @param inputToRemove camera input method
  8720. */
  8721. remove(inputToRemove: ICameraInput<TCamera>): void;
  8722. /**
  8723. * Remove a specific input type from a camera
  8724. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8725. * @param inputType the type of the input to remove
  8726. */
  8727. removeByType(inputType: string): void;
  8728. private _addCheckInputs;
  8729. /**
  8730. * Attach the input controls to the currently attached dom element to listen the events from.
  8731. * @param input Defines the input to attach
  8732. */
  8733. attachInput(input: ICameraInput<TCamera>): void;
  8734. /**
  8735. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8736. * @param element Defines the dom element to collect the events from
  8737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8738. */
  8739. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8740. /**
  8741. * Detach the current manager inputs controls from a specific dom element.
  8742. * @param element Defines the dom element to collect the events from
  8743. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8744. */
  8745. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8746. /**
  8747. * Rebuild the dynamic inputCheck function from the current list of
  8748. * defined inputs in the manager.
  8749. */
  8750. rebuildInputCheck(): void;
  8751. /**
  8752. * Remove all attached input methods from a camera
  8753. */
  8754. clear(): void;
  8755. /**
  8756. * Serialize the current input manager attached to a camera.
  8757. * This ensures than once parsed,
  8758. * the input associated to the camera will be identical to the current ones
  8759. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8760. */
  8761. serialize(serializedCamera: any): void;
  8762. /**
  8763. * Parses an input manager serialized JSON to restore the previous list of inputs
  8764. * and states associated to a camera.
  8765. * @param parsedCamera Defines the JSON to parse
  8766. */
  8767. parse(parsedCamera: any): void;
  8768. }
  8769. }
  8770. declare module BABYLON {
  8771. /**
  8772. * Gather the list of keyboard event types as constants.
  8773. */
  8774. export class KeyboardEventTypes {
  8775. /**
  8776. * The keydown event is fired when a key becomes active (pressed).
  8777. */
  8778. static readonly KEYDOWN: number;
  8779. /**
  8780. * The keyup event is fired when a key has been released.
  8781. */
  8782. static readonly KEYUP: number;
  8783. }
  8784. /**
  8785. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8786. */
  8787. export class KeyboardInfo {
  8788. /**
  8789. * Defines the type of event (KeyboardEventTypes)
  8790. */
  8791. type: number;
  8792. /**
  8793. * Defines the related dom event
  8794. */
  8795. event: KeyboardEvent;
  8796. /**
  8797. * Instantiates a new keyboard info.
  8798. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8799. * @param type Defines the type of event (KeyboardEventTypes)
  8800. * @param event Defines the related dom event
  8801. */
  8802. constructor(
  8803. /**
  8804. * Defines the type of event (KeyboardEventTypes)
  8805. */
  8806. type: number,
  8807. /**
  8808. * Defines the related dom event
  8809. */
  8810. event: KeyboardEvent);
  8811. }
  8812. /**
  8813. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8814. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8815. */
  8816. export class KeyboardInfoPre extends KeyboardInfo {
  8817. /**
  8818. * Defines the type of event (KeyboardEventTypes)
  8819. */
  8820. type: number;
  8821. /**
  8822. * Defines the related dom event
  8823. */
  8824. event: KeyboardEvent;
  8825. /**
  8826. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8827. */
  8828. skipOnPointerObservable: boolean;
  8829. /**
  8830. * Instantiates a new keyboard pre info.
  8831. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8832. * @param type Defines the type of event (KeyboardEventTypes)
  8833. * @param event Defines the related dom event
  8834. */
  8835. constructor(
  8836. /**
  8837. * Defines the type of event (KeyboardEventTypes)
  8838. */
  8839. type: number,
  8840. /**
  8841. * Defines the related dom event
  8842. */
  8843. event: KeyboardEvent);
  8844. }
  8845. }
  8846. declare module BABYLON {
  8847. /**
  8848. * Manage the keyboard inputs to control the movement of a free camera.
  8849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8850. */
  8851. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8852. /**
  8853. * Defines the camera the input is attached to.
  8854. */
  8855. camera: FreeCamera;
  8856. /**
  8857. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8858. */
  8859. keysUp: number[];
  8860. /**
  8861. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8862. */
  8863. keysDown: number[];
  8864. /**
  8865. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8866. */
  8867. keysLeft: number[];
  8868. /**
  8869. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8870. */
  8871. keysRight: number[];
  8872. private _keys;
  8873. private _onCanvasBlurObserver;
  8874. private _onKeyboardObserver;
  8875. private _engine;
  8876. private _scene;
  8877. /**
  8878. * Attach the input controls to a specific dom element to get the input from.
  8879. * @param element Defines the element the controls should be listened from
  8880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8881. */
  8882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8883. /**
  8884. * Detach the current controls from the specified dom element.
  8885. * @param element Defines the element to stop listening the inputs from
  8886. */
  8887. detachControl(element: Nullable<HTMLElement>): void;
  8888. /**
  8889. * Update the current camera state depending on the inputs that have been used this frame.
  8890. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8891. */
  8892. checkInputs(): void;
  8893. /**
  8894. * Gets the class name of the current intput.
  8895. * @returns the class name
  8896. */
  8897. getClassName(): string;
  8898. /** @hidden */
  8899. _onLostFocus(): void;
  8900. /**
  8901. * Get the friendly name associated with the input class.
  8902. * @returns the input friendly name
  8903. */
  8904. getSimpleName(): string;
  8905. }
  8906. }
  8907. declare module BABYLON {
  8908. /**
  8909. * Interface describing all the common properties and methods a shadow light needs to implement.
  8910. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8911. * as well as binding the different shadow properties to the effects.
  8912. */
  8913. export interface IShadowLight extends Light {
  8914. /**
  8915. * The light id in the scene (used in scene.findLighById for instance)
  8916. */
  8917. id: string;
  8918. /**
  8919. * The position the shdow will be casted from.
  8920. */
  8921. position: Vector3;
  8922. /**
  8923. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8924. */
  8925. direction: Vector3;
  8926. /**
  8927. * The transformed position. Position of the light in world space taking parenting in account.
  8928. */
  8929. transformedPosition: Vector3;
  8930. /**
  8931. * The transformed direction. Direction of the light in world space taking parenting in account.
  8932. */
  8933. transformedDirection: Vector3;
  8934. /**
  8935. * The friendly name of the light in the scene.
  8936. */
  8937. name: string;
  8938. /**
  8939. * Defines the shadow projection clipping minimum z value.
  8940. */
  8941. shadowMinZ: number;
  8942. /**
  8943. * Defines the shadow projection clipping maximum z value.
  8944. */
  8945. shadowMaxZ: number;
  8946. /**
  8947. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8948. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8949. */
  8950. computeTransformedInformation(): boolean;
  8951. /**
  8952. * Gets the scene the light belongs to.
  8953. * @returns The scene
  8954. */
  8955. getScene(): Scene;
  8956. /**
  8957. * Callback defining a custom Projection Matrix Builder.
  8958. * This can be used to override the default projection matrix computation.
  8959. */
  8960. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8961. /**
  8962. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8963. * @param matrix The materix to updated with the projection information
  8964. * @param viewMatrix The transform matrix of the light
  8965. * @param renderList The list of mesh to render in the map
  8966. * @returns The current light
  8967. */
  8968. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8969. /**
  8970. * Gets the current depth scale used in ESM.
  8971. * @returns The scale
  8972. */
  8973. getDepthScale(): number;
  8974. /**
  8975. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8976. * @returns true if a cube texture needs to be use
  8977. */
  8978. needCube(): boolean;
  8979. /**
  8980. * Detects if the projection matrix requires to be recomputed this frame.
  8981. * @returns true if it requires to be recomputed otherwise, false.
  8982. */
  8983. needProjectionMatrixCompute(): boolean;
  8984. /**
  8985. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8986. */
  8987. forceProjectionMatrixCompute(): void;
  8988. /**
  8989. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8990. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8991. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8992. */
  8993. getShadowDirection(faceIndex?: number): Vector3;
  8994. /**
  8995. * Gets the minZ used for shadow according to both the scene and the light.
  8996. * @param activeCamera The camera we are returning the min for
  8997. * @returns the depth min z
  8998. */
  8999. getDepthMinZ(activeCamera: Camera): number;
  9000. /**
  9001. * Gets the maxZ used for shadow according to both the scene and the light.
  9002. * @param activeCamera The camera we are returning the max for
  9003. * @returns the depth max z
  9004. */
  9005. getDepthMaxZ(activeCamera: Camera): number;
  9006. }
  9007. /**
  9008. * Base implementation IShadowLight
  9009. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9010. */
  9011. export abstract class ShadowLight extends Light implements IShadowLight {
  9012. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9013. protected _position: Vector3;
  9014. protected _setPosition(value: Vector3): void;
  9015. /**
  9016. * Sets the position the shadow will be casted from. Also use as the light position for both
  9017. * point and spot lights.
  9018. */
  9019. /**
  9020. * Sets the position the shadow will be casted from. Also use as the light position for both
  9021. * point and spot lights.
  9022. */
  9023. position: Vector3;
  9024. protected _direction: Vector3;
  9025. protected _setDirection(value: Vector3): void;
  9026. /**
  9027. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9028. * Also use as the light direction on spot and directional lights.
  9029. */
  9030. /**
  9031. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9032. * Also use as the light direction on spot and directional lights.
  9033. */
  9034. direction: Vector3;
  9035. private _shadowMinZ;
  9036. /**
  9037. * Gets the shadow projection clipping minimum z value.
  9038. */
  9039. /**
  9040. * Sets the shadow projection clipping minimum z value.
  9041. */
  9042. shadowMinZ: number;
  9043. private _shadowMaxZ;
  9044. /**
  9045. * Sets the shadow projection clipping maximum z value.
  9046. */
  9047. /**
  9048. * Gets the shadow projection clipping maximum z value.
  9049. */
  9050. shadowMaxZ: number;
  9051. /**
  9052. * Callback defining a custom Projection Matrix Builder.
  9053. * This can be used to override the default projection matrix computation.
  9054. */
  9055. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9056. /**
  9057. * The transformed position. Position of the light in world space taking parenting in account.
  9058. */
  9059. transformedPosition: Vector3;
  9060. /**
  9061. * The transformed direction. Direction of the light in world space taking parenting in account.
  9062. */
  9063. transformedDirection: Vector3;
  9064. private _needProjectionMatrixCompute;
  9065. /**
  9066. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9067. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9068. */
  9069. computeTransformedInformation(): boolean;
  9070. /**
  9071. * Return the depth scale used for the shadow map.
  9072. * @returns the depth scale.
  9073. */
  9074. getDepthScale(): number;
  9075. /**
  9076. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9077. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9078. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9079. */
  9080. getShadowDirection(faceIndex?: number): Vector3;
  9081. /**
  9082. * Returns the ShadowLight absolute position in the World.
  9083. * @returns the position vector in world space
  9084. */
  9085. getAbsolutePosition(): Vector3;
  9086. /**
  9087. * Sets the ShadowLight direction toward the passed target.
  9088. * @param target The point to target in local space
  9089. * @returns the updated ShadowLight direction
  9090. */
  9091. setDirectionToTarget(target: Vector3): Vector3;
  9092. /**
  9093. * Returns the light rotation in euler definition.
  9094. * @returns the x y z rotation in local space.
  9095. */
  9096. getRotation(): Vector3;
  9097. /**
  9098. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9099. * @returns true if a cube texture needs to be use
  9100. */
  9101. needCube(): boolean;
  9102. /**
  9103. * Detects if the projection matrix requires to be recomputed this frame.
  9104. * @returns true if it requires to be recomputed otherwise, false.
  9105. */
  9106. needProjectionMatrixCompute(): boolean;
  9107. /**
  9108. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9109. */
  9110. forceProjectionMatrixCompute(): void;
  9111. /** @hidden */
  9112. _initCache(): void;
  9113. /** @hidden */
  9114. _isSynchronized(): boolean;
  9115. /**
  9116. * Computes the world matrix of the node
  9117. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9118. * @returns the world matrix
  9119. */
  9120. computeWorldMatrix(force?: boolean): Matrix;
  9121. /**
  9122. * Gets the minZ used for shadow according to both the scene and the light.
  9123. * @param activeCamera The camera we are returning the min for
  9124. * @returns the depth min z
  9125. */
  9126. getDepthMinZ(activeCamera: Camera): number;
  9127. /**
  9128. * Gets the maxZ used for shadow according to both the scene and the light.
  9129. * @param activeCamera The camera we are returning the max for
  9130. * @returns the depth max z
  9131. */
  9132. getDepthMaxZ(activeCamera: Camera): number;
  9133. /**
  9134. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9135. * @param matrix The materix to updated with the projection information
  9136. * @param viewMatrix The transform matrix of the light
  9137. * @param renderList The list of mesh to render in the map
  9138. * @returns The current light
  9139. */
  9140. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9141. }
  9142. }
  9143. declare module BABYLON {
  9144. /**
  9145. * "Static Class" containing the most commonly used helper while dealing with material for
  9146. * rendering purpose.
  9147. *
  9148. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9149. *
  9150. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9151. */
  9152. export class MaterialHelper {
  9153. /**
  9154. * Bind the current view position to an effect.
  9155. * @param effect The effect to be bound
  9156. * @param scene The scene the eyes position is used from
  9157. */
  9158. static BindEyePosition(effect: Effect, scene: Scene): void;
  9159. /**
  9160. * Helps preparing the defines values about the UVs in used in the effect.
  9161. * UVs are shared as much as we can accross channels in the shaders.
  9162. * @param texture The texture we are preparing the UVs for
  9163. * @param defines The defines to update
  9164. * @param key The channel key "diffuse", "specular"... used in the shader
  9165. */
  9166. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9167. /**
  9168. * Binds a texture matrix value to its corrsponding uniform
  9169. * @param texture The texture to bind the matrix for
  9170. * @param uniformBuffer The uniform buffer receivin the data
  9171. * @param key The channel key "diffuse", "specular"... used in the shader
  9172. */
  9173. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9174. /**
  9175. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9176. * @param mesh defines the current mesh
  9177. * @param scene defines the current scene
  9178. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9179. * @param pointsCloud defines if point cloud rendering has to be turned on
  9180. * @param fogEnabled defines if fog has to be turned on
  9181. * @param alphaTest defines if alpha testing has to be turned on
  9182. * @param defines defines the current list of defines
  9183. */
  9184. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9185. /**
  9186. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9187. * @param scene defines the current scene
  9188. * @param engine defines the current engine
  9189. * @param defines specifies the list of active defines
  9190. * @param useInstances defines if instances have to be turned on
  9191. * @param useClipPlane defines if clip plane have to be turned on
  9192. */
  9193. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9194. /**
  9195. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9196. * @param mesh The mesh containing the geometry data we will draw
  9197. * @param defines The defines to update
  9198. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9199. * @param useBones Precise whether bones should be used or not (override mesh info)
  9200. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9201. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9202. * @returns false if defines are considered not dirty and have not been checked
  9203. */
  9204. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9205. /**
  9206. * Prepares the defines related to multiview
  9207. * @param scene The scene we are intending to draw
  9208. * @param defines The defines to update
  9209. */
  9210. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9211. /**
  9212. * Prepares the defines related to the light information passed in parameter
  9213. * @param scene The scene we are intending to draw
  9214. * @param mesh The mesh the effect is compiling for
  9215. * @param defines The defines to update
  9216. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9217. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9218. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9219. * @returns true if normals will be required for the rest of the effect
  9220. */
  9221. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9222. /**
  9223. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9224. * that won t be acctive due to defines being turned off.
  9225. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9226. * @param samplersList The samplers list
  9227. * @param defines The defines helping in the list generation
  9228. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9229. */
  9230. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9231. /**
  9232. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9233. * @param defines The defines to update while falling back
  9234. * @param fallbacks The authorized effect fallbacks
  9235. * @param maxSimultaneousLights The maximum number of lights allowed
  9236. * @param rank the current rank of the Effect
  9237. * @returns The newly affected rank
  9238. */
  9239. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9240. /**
  9241. * Prepares the list of attributes required for morph targets according to the effect defines.
  9242. * @param attribs The current list of supported attribs
  9243. * @param mesh The mesh to prepare the morph targets attributes for
  9244. * @param defines The current Defines of the effect
  9245. */
  9246. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9247. /**
  9248. * Prepares the list of attributes required for bones according to the effect defines.
  9249. * @param attribs The current list of supported attribs
  9250. * @param mesh The mesh to prepare the bones attributes for
  9251. * @param defines The current Defines of the effect
  9252. * @param fallbacks The current efffect fallback strategy
  9253. */
  9254. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9255. /**
  9256. * Prepares the list of attributes required for instances according to the effect defines.
  9257. * @param attribs The current list of supported attribs
  9258. * @param defines The current Defines of the effect
  9259. */
  9260. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9261. /**
  9262. * Binds the light shadow information to the effect for the given mesh.
  9263. * @param light The light containing the generator
  9264. * @param scene The scene the lights belongs to
  9265. * @param mesh The mesh we are binding the information to render
  9266. * @param lightIndex The light index in the effect used to render the mesh
  9267. * @param effect The effect we are binding the data to
  9268. */
  9269. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9270. /**
  9271. * Binds the light information to the effect.
  9272. * @param light The light containing the generator
  9273. * @param effect The effect we are binding the data to
  9274. * @param lightIndex The light index in the effect used to render
  9275. */
  9276. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9277. /**
  9278. * Binds the lights information from the scene to the effect for the given mesh.
  9279. * @param scene The scene the lights belongs to
  9280. * @param mesh The mesh we are binding the information to render
  9281. * @param effect The effect we are binding the data to
  9282. * @param defines The generated defines for the effect
  9283. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9284. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9285. */
  9286. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9287. private static _tempFogColor;
  9288. /**
  9289. * Binds the fog information from the scene to the effect for the given mesh.
  9290. * @param scene The scene the lights belongs to
  9291. * @param mesh The mesh we are binding the information to render
  9292. * @param effect The effect we are binding the data to
  9293. * @param linearSpace Defines if the fog effect is applied in linear space
  9294. */
  9295. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9296. /**
  9297. * Binds the bones information from the mesh to the effect.
  9298. * @param mesh The mesh we are binding the information to render
  9299. * @param effect The effect we are binding the data to
  9300. */
  9301. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9302. /**
  9303. * Binds the morph targets information from the mesh to the effect.
  9304. * @param abstractMesh The mesh we are binding the information to render
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9308. /**
  9309. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9310. * @param defines The generated defines used in the effect
  9311. * @param effect The effect we are binding the data to
  9312. * @param scene The scene we are willing to render with logarithmic scale for
  9313. */
  9314. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9315. /**
  9316. * Binds the clip plane information from the scene to the effect.
  9317. * @param scene The scene the clip plane information are extracted from
  9318. * @param effect The effect we are binding the data to
  9319. */
  9320. static BindClipPlane(effect: Effect, scene: Scene): void;
  9321. }
  9322. }
  9323. declare module BABYLON {
  9324. /** @hidden */
  9325. export var kernelBlurVaryingDeclaration: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module BABYLON {
  9331. /** @hidden */
  9332. export var kernelBlurFragment: {
  9333. name: string;
  9334. shader: string;
  9335. };
  9336. }
  9337. declare module BABYLON {
  9338. /** @hidden */
  9339. export var kernelBlurFragment2: {
  9340. name: string;
  9341. shader: string;
  9342. };
  9343. }
  9344. declare module BABYLON {
  9345. /** @hidden */
  9346. export var kernelBlurPixelShader: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module BABYLON {
  9352. /** @hidden */
  9353. export var kernelBlurVertex: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module BABYLON {
  9359. /** @hidden */
  9360. export var kernelBlurVertexShader: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module BABYLON {
  9366. /**
  9367. * The Blur Post Process which blurs an image based on a kernel and direction.
  9368. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9369. */
  9370. export class BlurPostProcess extends PostProcess {
  9371. /** The direction in which to blur the image. */
  9372. direction: Vector2;
  9373. private blockCompilation;
  9374. protected _kernel: number;
  9375. protected _idealKernel: number;
  9376. protected _packedFloat: boolean;
  9377. private _staticDefines;
  9378. /**
  9379. * Sets the length in pixels of the blur sample region
  9380. */
  9381. /**
  9382. * Gets the length in pixels of the blur sample region
  9383. */
  9384. kernel: number;
  9385. /**
  9386. * Sets wether or not the blur needs to unpack/repack floats
  9387. */
  9388. /**
  9389. * Gets wether or not the blur is unpacking/repacking floats
  9390. */
  9391. packedFloat: boolean;
  9392. /**
  9393. * Creates a new instance BlurPostProcess
  9394. * @param name The name of the effect.
  9395. * @param direction The direction in which to blur the image.
  9396. * @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.
  9397. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9398. * @param camera The camera to apply the render pass to.
  9399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9400. * @param engine The engine which the post process will be applied. (default: current engine)
  9401. * @param reusable If the post process can be reused on the same frame. (default: false)
  9402. * @param textureType Type of textures used when performing the post process. (default: 0)
  9403. * @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)
  9404. */
  9405. constructor(name: string,
  9406. /** The direction in which to blur the image. */
  9407. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9408. /**
  9409. * Updates the effect with the current post process compile time values and recompiles the shader.
  9410. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9411. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9412. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9413. * @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
  9414. * @param onCompiled Called when the shader has been compiled.
  9415. * @param onError Called if there is an error when compiling a shader.
  9416. */
  9417. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9418. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9419. /**
  9420. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9421. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9422. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9423. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9424. * The gaps between physical kernels are compensated for in the weighting of the samples
  9425. * @param idealKernel Ideal blur kernel.
  9426. * @return Nearest best kernel.
  9427. */
  9428. protected _nearestBestKernel(idealKernel: number): number;
  9429. /**
  9430. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9431. * @param x The point on the Gaussian distribution to sample.
  9432. * @return the value of the Gaussian function at x.
  9433. */
  9434. protected _gaussianWeight(x: number): number;
  9435. /**
  9436. * Generates a string that can be used as a floating point number in GLSL.
  9437. * @param x Value to print.
  9438. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9439. * @return GLSL float string.
  9440. */
  9441. protected _glslFloat(x: number, decimalFigures?: number): string;
  9442. }
  9443. }
  9444. declare module BABYLON {
  9445. /** @hidden */
  9446. export var shadowMapPixelShader: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module BABYLON {
  9452. /** @hidden */
  9453. export var bonesDeclaration: {
  9454. name: string;
  9455. shader: string;
  9456. };
  9457. }
  9458. declare module BABYLON {
  9459. /** @hidden */
  9460. export var morphTargetsVertexGlobalDeclaration: {
  9461. name: string;
  9462. shader: string;
  9463. };
  9464. }
  9465. declare module BABYLON {
  9466. /** @hidden */
  9467. export var morphTargetsVertexDeclaration: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module BABYLON {
  9473. /** @hidden */
  9474. export var instancesDeclaration: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module BABYLON {
  9480. /** @hidden */
  9481. export var helperFunctions: {
  9482. name: string;
  9483. shader: string;
  9484. };
  9485. }
  9486. declare module BABYLON {
  9487. /** @hidden */
  9488. export var morphTargetsVertex: {
  9489. name: string;
  9490. shader: string;
  9491. };
  9492. }
  9493. declare module BABYLON {
  9494. /** @hidden */
  9495. export var instancesVertex: {
  9496. name: string;
  9497. shader: string;
  9498. };
  9499. }
  9500. declare module BABYLON {
  9501. /** @hidden */
  9502. export var bonesVertex: {
  9503. name: string;
  9504. shader: string;
  9505. };
  9506. }
  9507. declare module BABYLON {
  9508. /** @hidden */
  9509. export var shadowMapVertexShader: {
  9510. name: string;
  9511. shader: string;
  9512. };
  9513. }
  9514. declare module BABYLON {
  9515. /** @hidden */
  9516. export var depthBoxBlurPixelShader: {
  9517. name: string;
  9518. shader: string;
  9519. };
  9520. }
  9521. declare module BABYLON {
  9522. /**
  9523. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9524. */
  9525. export interface ICustomShaderOptions {
  9526. /**
  9527. * Gets or sets the custom shader name to use
  9528. */
  9529. shaderName: string;
  9530. /**
  9531. * The list of attribute names used in the shader
  9532. */
  9533. attributes?: string[];
  9534. /**
  9535. * The list of unifrom names used in the shader
  9536. */
  9537. uniforms?: string[];
  9538. /**
  9539. * The list of sampler names used in the shader
  9540. */
  9541. samplers?: string[];
  9542. /**
  9543. * The list of defines used in the shader
  9544. */
  9545. defines?: string[];
  9546. }
  9547. /**
  9548. * Interface to implement to create a shadow generator compatible with BJS.
  9549. */
  9550. export interface IShadowGenerator {
  9551. /**
  9552. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9553. * @returns The render target texture if present otherwise, null
  9554. */
  9555. getShadowMap(): Nullable<RenderTargetTexture>;
  9556. /**
  9557. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9558. * @returns The render target texture if the shadow map is present otherwise, null
  9559. */
  9560. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9561. /**
  9562. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9563. * @param subMesh The submesh we want to render in the shadow map
  9564. * @param useInstances Defines wether will draw in the map using instances
  9565. * @returns true if ready otherwise, false
  9566. */
  9567. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9568. /**
  9569. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9570. * @param defines Defines of the material we want to update
  9571. * @param lightIndex Index of the light in the enabled light list of the material
  9572. */
  9573. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9574. /**
  9575. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9576. * defined in the generator but impacting the effect).
  9577. * It implies the unifroms available on the materials are the standard BJS ones.
  9578. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9579. * @param effect The effect we are binfing the information for
  9580. */
  9581. bindShadowLight(lightIndex: string, effect: Effect): void;
  9582. /**
  9583. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9584. * (eq to shadow prjection matrix * light transform matrix)
  9585. * @returns The transform matrix used to create the shadow map
  9586. */
  9587. getTransformMatrix(): Matrix;
  9588. /**
  9589. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9590. * Cube and 2D textures for instance.
  9591. */
  9592. recreateShadowMap(): void;
  9593. /**
  9594. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9595. * @param onCompiled Callback triggered at the and of the effects compilation
  9596. * @param options Sets of optional options forcing the compilation with different modes
  9597. */
  9598. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9599. useInstances: boolean;
  9600. }>): void;
  9601. /**
  9602. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9603. * @param options Sets of optional options forcing the compilation with different modes
  9604. * @returns A promise that resolves when the compilation completes
  9605. */
  9606. forceCompilationAsync(options?: Partial<{
  9607. useInstances: boolean;
  9608. }>): Promise<void>;
  9609. /**
  9610. * Serializes the shadow generator setup to a json object.
  9611. * @returns The serialized JSON object
  9612. */
  9613. serialize(): any;
  9614. /**
  9615. * Disposes the Shadow map and related Textures and effects.
  9616. */
  9617. dispose(): void;
  9618. }
  9619. /**
  9620. * Default implementation IShadowGenerator.
  9621. * This is the main object responsible of generating shadows in the framework.
  9622. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9623. */
  9624. export class ShadowGenerator implements IShadowGenerator {
  9625. /**
  9626. * Shadow generator mode None: no filtering applied.
  9627. */
  9628. static readonly FILTER_NONE: number;
  9629. /**
  9630. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9631. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9632. */
  9633. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9634. /**
  9635. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9636. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9637. */
  9638. static readonly FILTER_POISSONSAMPLING: number;
  9639. /**
  9640. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9641. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9642. */
  9643. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9644. /**
  9645. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9646. * edge artifacts on steep falloff.
  9647. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9648. */
  9649. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9650. /**
  9651. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9652. * edge artifacts on steep falloff.
  9653. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9654. */
  9655. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9656. /**
  9657. * Shadow generator mode PCF: Percentage Closer Filtering
  9658. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9659. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9660. */
  9661. static readonly FILTER_PCF: number;
  9662. /**
  9663. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9664. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9665. * Contact Hardening
  9666. */
  9667. static readonly FILTER_PCSS: number;
  9668. /**
  9669. * Reserved for PCF and PCSS
  9670. * Highest Quality.
  9671. *
  9672. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9673. *
  9674. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9675. */
  9676. static readonly QUALITY_HIGH: number;
  9677. /**
  9678. * Reserved for PCF and PCSS
  9679. * Good tradeoff for quality/perf cross devices
  9680. *
  9681. * Execute PCF on a 3*3 kernel.
  9682. *
  9683. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9684. */
  9685. static readonly QUALITY_MEDIUM: number;
  9686. /**
  9687. * Reserved for PCF and PCSS
  9688. * The lowest quality but the fastest.
  9689. *
  9690. * Execute PCF on a 1*1 kernel.
  9691. *
  9692. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9693. */
  9694. static readonly QUALITY_LOW: number;
  9695. /** Gets or sets the custom shader name to use */
  9696. customShaderOptions: ICustomShaderOptions;
  9697. /**
  9698. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9699. */
  9700. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9701. /**
  9702. * Observable triggered before a mesh is rendered in the shadow map.
  9703. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9704. */
  9705. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9706. private _bias;
  9707. /**
  9708. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9709. */
  9710. /**
  9711. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9712. */
  9713. bias: number;
  9714. private _normalBias;
  9715. /**
  9716. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9717. */
  9718. /**
  9719. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9720. */
  9721. normalBias: number;
  9722. private _blurBoxOffset;
  9723. /**
  9724. * Gets the blur box offset: offset applied during the blur pass.
  9725. * Only useful if useKernelBlur = false
  9726. */
  9727. /**
  9728. * Sets the blur box offset: offset applied during the blur pass.
  9729. * Only useful if useKernelBlur = false
  9730. */
  9731. blurBoxOffset: number;
  9732. private _blurScale;
  9733. /**
  9734. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9735. * 2 means half of the size.
  9736. */
  9737. /**
  9738. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9739. * 2 means half of the size.
  9740. */
  9741. blurScale: number;
  9742. private _blurKernel;
  9743. /**
  9744. * Gets the blur kernel: kernel size of the blur pass.
  9745. * Only useful if useKernelBlur = true
  9746. */
  9747. /**
  9748. * Sets the blur kernel: kernel size of the blur pass.
  9749. * Only useful if useKernelBlur = true
  9750. */
  9751. blurKernel: number;
  9752. private _useKernelBlur;
  9753. /**
  9754. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9755. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9756. */
  9757. /**
  9758. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9759. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9760. */
  9761. useKernelBlur: boolean;
  9762. private _depthScale;
  9763. /**
  9764. * Gets the depth scale used in ESM mode.
  9765. */
  9766. /**
  9767. * Sets the depth scale used in ESM mode.
  9768. * This can override the scale stored on the light.
  9769. */
  9770. depthScale: number;
  9771. private _filter;
  9772. /**
  9773. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9774. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9775. */
  9776. /**
  9777. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9778. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9779. */
  9780. filter: number;
  9781. /**
  9782. * Gets if the current filter is set to Poisson Sampling.
  9783. */
  9784. /**
  9785. * Sets the current filter to Poisson Sampling.
  9786. */
  9787. usePoissonSampling: boolean;
  9788. /**
  9789. * Gets if the current filter is set to ESM.
  9790. */
  9791. /**
  9792. * Sets the current filter is to ESM.
  9793. */
  9794. useExponentialShadowMap: boolean;
  9795. /**
  9796. * Gets if the current filter is set to filtered ESM.
  9797. */
  9798. /**
  9799. * Gets if the current filter is set to filtered ESM.
  9800. */
  9801. useBlurExponentialShadowMap: boolean;
  9802. /**
  9803. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9804. * exponential to prevent steep falloff artifacts).
  9805. */
  9806. /**
  9807. * Sets the current filter to "close ESM" (using the inverse of the
  9808. * exponential to prevent steep falloff artifacts).
  9809. */
  9810. useCloseExponentialShadowMap: boolean;
  9811. /**
  9812. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9813. * exponential to prevent steep falloff artifacts).
  9814. */
  9815. /**
  9816. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9817. * exponential to prevent steep falloff artifacts).
  9818. */
  9819. useBlurCloseExponentialShadowMap: boolean;
  9820. /**
  9821. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9822. */
  9823. /**
  9824. * Sets the current filter to "PCF" (percentage closer filtering).
  9825. */
  9826. usePercentageCloserFiltering: boolean;
  9827. private _filteringQuality;
  9828. /**
  9829. * Gets the PCF or PCSS Quality.
  9830. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9831. */
  9832. /**
  9833. * Sets the PCF or PCSS Quality.
  9834. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9835. */
  9836. filteringQuality: number;
  9837. /**
  9838. * Gets if the current filter is set to "PCSS" (contact hardening).
  9839. */
  9840. /**
  9841. * Sets the current filter to "PCSS" (contact hardening).
  9842. */
  9843. useContactHardeningShadow: boolean;
  9844. private _contactHardeningLightSizeUVRatio;
  9845. /**
  9846. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9847. * Using a ratio helps keeping shape stability independently of the map size.
  9848. *
  9849. * It does not account for the light projection as it was having too much
  9850. * instability during the light setup or during light position changes.
  9851. *
  9852. * Only valid if useContactHardeningShadow is true.
  9853. */
  9854. /**
  9855. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9856. * Using a ratio helps keeping shape stability independently of the map size.
  9857. *
  9858. * It does not account for the light projection as it was having too much
  9859. * instability during the light setup or during light position changes.
  9860. *
  9861. * Only valid if useContactHardeningShadow is true.
  9862. */
  9863. contactHardeningLightSizeUVRatio: number;
  9864. private _darkness;
  9865. /**
  9866. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9867. * 0 means strongest and 1 would means no shadow.
  9868. * @returns the darkness.
  9869. */
  9870. getDarkness(): number;
  9871. /**
  9872. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9873. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9874. * @returns the shadow generator allowing fluent coding.
  9875. */
  9876. setDarkness(darkness: number): ShadowGenerator;
  9877. private _transparencyShadow;
  9878. /**
  9879. * Sets the ability to have transparent shadow (boolean).
  9880. * @param transparent True if transparent else False
  9881. * @returns the shadow generator allowing fluent coding
  9882. */
  9883. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9884. private _shadowMap;
  9885. private _shadowMap2;
  9886. /**
  9887. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9888. * @returns The render target texture if present otherwise, null
  9889. */
  9890. getShadowMap(): Nullable<RenderTargetTexture>;
  9891. /**
  9892. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9893. * @returns The render target texture if the shadow map is present otherwise, null
  9894. */
  9895. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9896. /**
  9897. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9898. * @param mesh Mesh to add
  9899. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9900. * @returns the Shadow Generator itself
  9901. */
  9902. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9903. /**
  9904. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9905. * @param mesh Mesh to remove
  9906. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9907. * @returns the Shadow Generator itself
  9908. */
  9909. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9910. /**
  9911. * Controls the extent to which the shadows fade out at the edge of the frustum
  9912. * Used only by directionals and spots
  9913. */
  9914. frustumEdgeFalloff: number;
  9915. private _light;
  9916. /**
  9917. * Returns the associated light object.
  9918. * @returns the light generating the shadow
  9919. */
  9920. getLight(): IShadowLight;
  9921. /**
  9922. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9923. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9924. * It might on the other hand introduce peter panning.
  9925. */
  9926. forceBackFacesOnly: boolean;
  9927. private _scene;
  9928. private _lightDirection;
  9929. private _effect;
  9930. private _viewMatrix;
  9931. private _projectionMatrix;
  9932. private _transformMatrix;
  9933. private _cachedPosition;
  9934. private _cachedDirection;
  9935. private _cachedDefines;
  9936. private _currentRenderID;
  9937. private _boxBlurPostprocess;
  9938. private _kernelBlurXPostprocess;
  9939. private _kernelBlurYPostprocess;
  9940. private _blurPostProcesses;
  9941. private _mapSize;
  9942. private _currentFaceIndex;
  9943. private _currentFaceIndexCache;
  9944. private _textureType;
  9945. private _defaultTextureMatrix;
  9946. /** @hidden */
  9947. static _SceneComponentInitialization: (scene: Scene) => void;
  9948. /**
  9949. * Creates a ShadowGenerator object.
  9950. * A ShadowGenerator is the required tool to use the shadows.
  9951. * Each light casting shadows needs to use its own ShadowGenerator.
  9952. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9953. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9954. * @param light The light object generating the shadows.
  9955. * @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.
  9956. */
  9957. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9958. private _initializeGenerator;
  9959. private _initializeShadowMap;
  9960. private _initializeBlurRTTAndPostProcesses;
  9961. private _renderForShadowMap;
  9962. private _renderSubMeshForShadowMap;
  9963. private _applyFilterValues;
  9964. /**
  9965. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9966. * @param onCompiled Callback triggered at the and of the effects compilation
  9967. * @param options Sets of optional options forcing the compilation with different modes
  9968. */
  9969. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9970. useInstances: boolean;
  9971. }>): void;
  9972. /**
  9973. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9974. * @param options Sets of optional options forcing the compilation with different modes
  9975. * @returns A promise that resolves when the compilation completes
  9976. */
  9977. forceCompilationAsync(options?: Partial<{
  9978. useInstances: boolean;
  9979. }>): Promise<void>;
  9980. /**
  9981. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9982. * @param subMesh The submesh we want to render in the shadow map
  9983. * @param useInstances Defines wether will draw in the map using instances
  9984. * @returns true if ready otherwise, false
  9985. */
  9986. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9987. /**
  9988. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9989. * @param defines Defines of the material we want to update
  9990. * @param lightIndex Index of the light in the enabled light list of the material
  9991. */
  9992. prepareDefines(defines: any, lightIndex: number): void;
  9993. /**
  9994. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9995. * defined in the generator but impacting the effect).
  9996. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9997. * @param effect The effect we are binfing the information for
  9998. */
  9999. bindShadowLight(lightIndex: string, effect: Effect): void;
  10000. /**
  10001. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10002. * (eq to shadow prjection matrix * light transform matrix)
  10003. * @returns The transform matrix used to create the shadow map
  10004. */
  10005. getTransformMatrix(): Matrix;
  10006. /**
  10007. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10008. * Cube and 2D textures for instance.
  10009. */
  10010. recreateShadowMap(): void;
  10011. private _disposeBlurPostProcesses;
  10012. private _disposeRTTandPostProcesses;
  10013. /**
  10014. * Disposes the ShadowGenerator.
  10015. * Returns nothing.
  10016. */
  10017. dispose(): void;
  10018. /**
  10019. * Serializes the shadow generator setup to a json object.
  10020. * @returns The serialized JSON object
  10021. */
  10022. serialize(): any;
  10023. /**
  10024. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10025. * @param parsedShadowGenerator The JSON object to parse
  10026. * @param scene The scene to create the shadow map for
  10027. * @returns The parsed shadow generator
  10028. */
  10029. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10030. }
  10031. }
  10032. declare module BABYLON {
  10033. /**
  10034. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10035. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10036. * 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.
  10037. */
  10038. export abstract class Light extends Node {
  10039. /**
  10040. * Falloff Default: light is falling off following the material specification:
  10041. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10042. */
  10043. static readonly FALLOFF_DEFAULT: number;
  10044. /**
  10045. * Falloff Physical: light is falling off following the inverse squared distance law.
  10046. */
  10047. static readonly FALLOFF_PHYSICAL: number;
  10048. /**
  10049. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10050. * to enhance interoperability with other engines.
  10051. */
  10052. static readonly FALLOFF_GLTF: number;
  10053. /**
  10054. * Falloff Standard: light is falling off like in the standard material
  10055. * to enhance interoperability with other materials.
  10056. */
  10057. static readonly FALLOFF_STANDARD: number;
  10058. /**
  10059. * If every light affecting the material is in this lightmapMode,
  10060. * material.lightmapTexture adds or multiplies
  10061. * (depends on material.useLightmapAsShadowmap)
  10062. * after every other light calculations.
  10063. */
  10064. static readonly LIGHTMAP_DEFAULT: number;
  10065. /**
  10066. * material.lightmapTexture as only diffuse lighting from this light
  10067. * adds only specular lighting from this light
  10068. * adds dynamic shadows
  10069. */
  10070. static readonly LIGHTMAP_SPECULAR: number;
  10071. /**
  10072. * material.lightmapTexture as only lighting
  10073. * no light calculation from this light
  10074. * only adds dynamic shadows from this light
  10075. */
  10076. static readonly LIGHTMAP_SHADOWSONLY: number;
  10077. /**
  10078. * Each light type uses the default quantity according to its type:
  10079. * point/spot lights use luminous intensity
  10080. * directional lights use illuminance
  10081. */
  10082. static readonly INTENSITYMODE_AUTOMATIC: number;
  10083. /**
  10084. * lumen (lm)
  10085. */
  10086. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10087. /**
  10088. * candela (lm/sr)
  10089. */
  10090. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10091. /**
  10092. * lux (lm/m^2)
  10093. */
  10094. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10095. /**
  10096. * nit (cd/m^2)
  10097. */
  10098. static readonly INTENSITYMODE_LUMINANCE: number;
  10099. /**
  10100. * Light type const id of the point light.
  10101. */
  10102. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10103. /**
  10104. * Light type const id of the directional light.
  10105. */
  10106. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10107. /**
  10108. * Light type const id of the spot light.
  10109. */
  10110. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10111. /**
  10112. * Light type const id of the hemispheric light.
  10113. */
  10114. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10115. /**
  10116. * Diffuse gives the basic color to an object.
  10117. */
  10118. diffuse: Color3;
  10119. /**
  10120. * Specular produces a highlight color on an object.
  10121. * Note: This is note affecting PBR materials.
  10122. */
  10123. specular: Color3;
  10124. /**
  10125. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10126. * falling off base on range or angle.
  10127. * This can be set to any values in Light.FALLOFF_x.
  10128. *
  10129. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10130. * other types of materials.
  10131. */
  10132. falloffType: number;
  10133. /**
  10134. * Strength of the light.
  10135. * Note: By default it is define in the framework own unit.
  10136. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10137. */
  10138. intensity: number;
  10139. private _range;
  10140. protected _inverseSquaredRange: number;
  10141. /**
  10142. * Defines how far from the source the light is impacting in scene units.
  10143. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10144. */
  10145. /**
  10146. * Defines how far from the source the light is impacting in scene units.
  10147. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10148. */
  10149. range: number;
  10150. /**
  10151. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10152. * of light.
  10153. */
  10154. private _photometricScale;
  10155. private _intensityMode;
  10156. /**
  10157. * Gets the photometric scale used to interpret the intensity.
  10158. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10159. */
  10160. /**
  10161. * Sets the photometric scale used to interpret the intensity.
  10162. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10163. */
  10164. intensityMode: number;
  10165. private _radius;
  10166. /**
  10167. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10168. */
  10169. /**
  10170. * sets the light radius used by PBR Materials to simulate soft area lights.
  10171. */
  10172. radius: number;
  10173. private _renderPriority;
  10174. /**
  10175. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10176. * exceeding the number allowed of the materials.
  10177. */
  10178. renderPriority: number;
  10179. private _shadowEnabled;
  10180. /**
  10181. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10182. * the current shadow generator.
  10183. */
  10184. /**
  10185. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10186. * the current shadow generator.
  10187. */
  10188. shadowEnabled: boolean;
  10189. private _includedOnlyMeshes;
  10190. /**
  10191. * Gets the only meshes impacted by this light.
  10192. */
  10193. /**
  10194. * Sets the only meshes impacted by this light.
  10195. */
  10196. includedOnlyMeshes: AbstractMesh[];
  10197. private _excludedMeshes;
  10198. /**
  10199. * Gets the meshes not impacted by this light.
  10200. */
  10201. /**
  10202. * Sets the meshes not impacted by this light.
  10203. */
  10204. excludedMeshes: AbstractMesh[];
  10205. private _excludeWithLayerMask;
  10206. /**
  10207. * Gets the layer id use to find what meshes are not impacted by the light.
  10208. * Inactive if 0
  10209. */
  10210. /**
  10211. * Sets the layer id use to find what meshes are not impacted by the light.
  10212. * Inactive if 0
  10213. */
  10214. excludeWithLayerMask: number;
  10215. private _includeOnlyWithLayerMask;
  10216. /**
  10217. * Gets the layer id use to find what meshes are impacted by the light.
  10218. * Inactive if 0
  10219. */
  10220. /**
  10221. * Sets the layer id use to find what meshes are impacted by the light.
  10222. * Inactive if 0
  10223. */
  10224. includeOnlyWithLayerMask: number;
  10225. private _lightmapMode;
  10226. /**
  10227. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10228. */
  10229. /**
  10230. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10231. */
  10232. lightmapMode: number;
  10233. /**
  10234. * Shadow generator associted to the light.
  10235. * @hidden Internal use only.
  10236. */
  10237. _shadowGenerator: Nullable<IShadowGenerator>;
  10238. /**
  10239. * @hidden Internal use only.
  10240. */
  10241. _excludedMeshesIds: string[];
  10242. /**
  10243. * @hidden Internal use only.
  10244. */
  10245. _includedOnlyMeshesIds: string[];
  10246. /**
  10247. * The current light unifom buffer.
  10248. * @hidden Internal use only.
  10249. */
  10250. _uniformBuffer: UniformBuffer;
  10251. /**
  10252. * Creates a Light object in the scene.
  10253. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10254. * @param name The firendly name of the light
  10255. * @param scene The scene the light belongs too
  10256. */
  10257. constructor(name: string, scene: Scene);
  10258. protected abstract _buildUniformLayout(): void;
  10259. /**
  10260. * Sets the passed Effect "effect" with the Light information.
  10261. * @param effect The effect to update
  10262. * @param lightIndex The index of the light in the effect to update
  10263. * @returns The light
  10264. */
  10265. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10266. /**
  10267. * Returns the string "Light".
  10268. * @returns the class name
  10269. */
  10270. getClassName(): string;
  10271. /** @hidden */
  10272. readonly _isLight: boolean;
  10273. /**
  10274. * Converts the light information to a readable string for debug purpose.
  10275. * @param fullDetails Supports for multiple levels of logging within scene loading
  10276. * @returns the human readable light info
  10277. */
  10278. toString(fullDetails?: boolean): string;
  10279. /** @hidden */
  10280. protected _syncParentEnabledState(): void;
  10281. /**
  10282. * Set the enabled state of this node.
  10283. * @param value - the new enabled state
  10284. */
  10285. setEnabled(value: boolean): void;
  10286. /**
  10287. * Returns the Light associated shadow generator if any.
  10288. * @return the associated shadow generator.
  10289. */
  10290. getShadowGenerator(): Nullable<IShadowGenerator>;
  10291. /**
  10292. * Returns a Vector3, the absolute light position in the World.
  10293. * @returns the world space position of the light
  10294. */
  10295. getAbsolutePosition(): Vector3;
  10296. /**
  10297. * Specifies if the light will affect the passed mesh.
  10298. * @param mesh The mesh to test against the light
  10299. * @return true the mesh is affected otherwise, false.
  10300. */
  10301. canAffectMesh(mesh: AbstractMesh): boolean;
  10302. /**
  10303. * Sort function to order lights for rendering.
  10304. * @param a First Light object to compare to second.
  10305. * @param b Second Light object to compare first.
  10306. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10307. */
  10308. static CompareLightsPriority(a: Light, b: Light): number;
  10309. /**
  10310. * Releases resources associated with this node.
  10311. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10312. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10313. */
  10314. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10315. /**
  10316. * Returns the light type ID (integer).
  10317. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10318. */
  10319. getTypeID(): number;
  10320. /**
  10321. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10322. * @returns the scaled intensity in intensity mode unit
  10323. */
  10324. getScaledIntensity(): number;
  10325. /**
  10326. * Returns a new Light object, named "name", from the current one.
  10327. * @param name The name of the cloned light
  10328. * @returns the new created light
  10329. */
  10330. clone(name: string): Nullable<Light>;
  10331. /**
  10332. * Serializes the current light into a Serialization object.
  10333. * @returns the serialized object.
  10334. */
  10335. serialize(): any;
  10336. /**
  10337. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10338. * This new light is named "name" and added to the passed scene.
  10339. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10340. * @param name The friendly name of the light
  10341. * @param scene The scene the new light will belong to
  10342. * @returns the constructor function
  10343. */
  10344. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10345. /**
  10346. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10347. * @param parsedLight The JSON representation of the light
  10348. * @param scene The scene to create the parsed light in
  10349. * @returns the created light after parsing
  10350. */
  10351. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10352. private _hookArrayForExcluded;
  10353. private _hookArrayForIncludedOnly;
  10354. private _resyncMeshes;
  10355. /**
  10356. * Forces the meshes to update their light related information in their rendering used effects
  10357. * @hidden Internal Use Only
  10358. */
  10359. _markMeshesAsLightDirty(): void;
  10360. /**
  10361. * Recomputes the cached photometric scale if needed.
  10362. */
  10363. private _computePhotometricScale;
  10364. /**
  10365. * Returns the Photometric Scale according to the light type and intensity mode.
  10366. */
  10367. private _getPhotometricScale;
  10368. /**
  10369. * Reorder the light in the scene according to their defined priority.
  10370. * @hidden Internal Use Only
  10371. */
  10372. _reorderLightsInScene(): void;
  10373. /**
  10374. * Prepares the list of defines specific to the light type.
  10375. * @param defines the list of defines
  10376. * @param lightIndex defines the index of the light for the effect
  10377. */
  10378. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10379. }
  10380. }
  10381. declare module BABYLON {
  10382. /**
  10383. * Interface used to define Action
  10384. */
  10385. export interface IAction {
  10386. /**
  10387. * Trigger for the action
  10388. */
  10389. trigger: number;
  10390. /** Options of the trigger */
  10391. triggerOptions: any;
  10392. /**
  10393. * Gets the trigger parameters
  10394. * @returns the trigger parameters
  10395. */
  10396. getTriggerParameter(): any;
  10397. /**
  10398. * Internal only - executes current action event
  10399. * @hidden
  10400. */
  10401. _executeCurrent(evt?: ActionEvent): void;
  10402. /**
  10403. * Serialize placeholder for child classes
  10404. * @param parent of child
  10405. * @returns the serialized object
  10406. */
  10407. serialize(parent: any): any;
  10408. /**
  10409. * Internal only
  10410. * @hidden
  10411. */
  10412. _prepare(): void;
  10413. /**
  10414. * Internal only - manager for action
  10415. * @hidden
  10416. */
  10417. _actionManager: AbstractActionManager;
  10418. }
  10419. /**
  10420. * The action to be carried out following a trigger
  10421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10422. */
  10423. export class Action implements IAction {
  10424. /** the trigger, with or without parameters, for the action */
  10425. triggerOptions: any;
  10426. /**
  10427. * Trigger for the action
  10428. */
  10429. trigger: number;
  10430. /**
  10431. * Internal only - manager for action
  10432. * @hidden
  10433. */
  10434. _actionManager: ActionManager;
  10435. private _nextActiveAction;
  10436. private _child;
  10437. private _condition?;
  10438. private _triggerParameter;
  10439. /**
  10440. * An event triggered prior to action being executed.
  10441. */
  10442. onBeforeExecuteObservable: Observable<Action>;
  10443. /**
  10444. * Creates a new Action
  10445. * @param triggerOptions the trigger, with or without parameters, for the action
  10446. * @param condition an optional determinant of action
  10447. */
  10448. constructor(
  10449. /** the trigger, with or without parameters, for the action */
  10450. triggerOptions: any, condition?: Condition);
  10451. /**
  10452. * Internal only
  10453. * @hidden
  10454. */
  10455. _prepare(): void;
  10456. /**
  10457. * Gets the trigger parameters
  10458. * @returns the trigger parameters
  10459. */
  10460. getTriggerParameter(): any;
  10461. /**
  10462. * Internal only - executes current action event
  10463. * @hidden
  10464. */
  10465. _executeCurrent(evt?: ActionEvent): void;
  10466. /**
  10467. * Execute placeholder for child classes
  10468. * @param evt optional action event
  10469. */
  10470. execute(evt?: ActionEvent): void;
  10471. /**
  10472. * Skips to next active action
  10473. */
  10474. skipToNextActiveAction(): void;
  10475. /**
  10476. * Adds action to chain of actions, may be a DoNothingAction
  10477. * @param action defines the next action to execute
  10478. * @returns The action passed in
  10479. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10480. */
  10481. then(action: Action): Action;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. _getProperty(propertyPath: string): string;
  10487. /**
  10488. * Internal only
  10489. * @hidden
  10490. */
  10491. _getEffectiveTarget(target: any, propertyPath: string): any;
  10492. /**
  10493. * Serialize placeholder for child classes
  10494. * @param parent of child
  10495. * @returns the serialized object
  10496. */
  10497. serialize(parent: any): any;
  10498. /**
  10499. * Internal only called by serialize
  10500. * @hidden
  10501. */
  10502. protected _serialize(serializedAction: any, parent?: any): any;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. static _SerializeValueAsString: (value: any) => string;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. static _GetTargetProperty: (target: Scene | Node) => {
  10513. name: string;
  10514. targetType: string;
  10515. value: string;
  10516. };
  10517. }
  10518. }
  10519. declare module BABYLON {
  10520. /**
  10521. * A Condition applied to an Action
  10522. */
  10523. export class Condition {
  10524. /**
  10525. * Internal only - manager for action
  10526. * @hidden
  10527. */
  10528. _actionManager: ActionManager;
  10529. /**
  10530. * Internal only
  10531. * @hidden
  10532. */
  10533. _evaluationId: number;
  10534. /**
  10535. * Internal only
  10536. * @hidden
  10537. */
  10538. _currentResult: boolean;
  10539. /**
  10540. * Creates a new Condition
  10541. * @param actionManager the manager of the action the condition is applied to
  10542. */
  10543. constructor(actionManager: ActionManager);
  10544. /**
  10545. * Check if the current condition is valid
  10546. * @returns a boolean
  10547. */
  10548. isValid(): boolean;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. _getProperty(propertyPath: string): string;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. _getEffectiveTarget(target: any, propertyPath: string): any;
  10559. /**
  10560. * Serialize placeholder for child classes
  10561. * @returns the serialized object
  10562. */
  10563. serialize(): any;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. protected _serialize(serializedCondition: any): any;
  10569. }
  10570. /**
  10571. * Defines specific conditional operators as extensions of Condition
  10572. */
  10573. export class ValueCondition extends Condition {
  10574. /** path to specify the property of the target the conditional operator uses */
  10575. propertyPath: string;
  10576. /** the value compared by the conditional operator against the current value of the property */
  10577. value: any;
  10578. /** the conditional operator, default ValueCondition.IsEqual */
  10579. operator: number;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. private static _IsEqual;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. private static _IsDifferent;
  10590. /**
  10591. * Internal only
  10592. * @hidden
  10593. */
  10594. private static _IsGreater;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. private static _IsLesser;
  10600. /**
  10601. * returns the number for IsEqual
  10602. */
  10603. static readonly IsEqual: number;
  10604. /**
  10605. * Returns the number for IsDifferent
  10606. */
  10607. static readonly IsDifferent: number;
  10608. /**
  10609. * Returns the number for IsGreater
  10610. */
  10611. static readonly IsGreater: number;
  10612. /**
  10613. * Returns the number for IsLesser
  10614. */
  10615. static readonly IsLesser: number;
  10616. /**
  10617. * Internal only The action manager for the condition
  10618. * @hidden
  10619. */
  10620. _actionManager: ActionManager;
  10621. /**
  10622. * Internal only
  10623. * @hidden
  10624. */
  10625. private _target;
  10626. /**
  10627. * Internal only
  10628. * @hidden
  10629. */
  10630. private _effectiveTarget;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. private _property;
  10636. /**
  10637. * Creates a new ValueCondition
  10638. * @param actionManager manager for the action the condition applies to
  10639. * @param target for the action
  10640. * @param propertyPath path to specify the property of the target the conditional operator uses
  10641. * @param value the value compared by the conditional operator against the current value of the property
  10642. * @param operator the conditional operator, default ValueCondition.IsEqual
  10643. */
  10644. constructor(actionManager: ActionManager, target: any,
  10645. /** path to specify the property of the target the conditional operator uses */
  10646. propertyPath: string,
  10647. /** the value compared by the conditional operator against the current value of the property */
  10648. value: any,
  10649. /** the conditional operator, default ValueCondition.IsEqual */
  10650. operator?: number);
  10651. /**
  10652. * Compares the given value with the property value for the specified conditional operator
  10653. * @returns the result of the comparison
  10654. */
  10655. isValid(): boolean;
  10656. /**
  10657. * Serialize the ValueCondition into a JSON compatible object
  10658. * @returns serialization object
  10659. */
  10660. serialize(): any;
  10661. /**
  10662. * Gets the name of the conditional operator for the ValueCondition
  10663. * @param operator the conditional operator
  10664. * @returns the name
  10665. */
  10666. static GetOperatorName(operator: number): string;
  10667. }
  10668. /**
  10669. * Defines a predicate condition as an extension of Condition
  10670. */
  10671. export class PredicateCondition extends Condition {
  10672. /** defines the predicate function used to validate the condition */
  10673. predicate: () => boolean;
  10674. /**
  10675. * Internal only - manager for action
  10676. * @hidden
  10677. */
  10678. _actionManager: ActionManager;
  10679. /**
  10680. * Creates a new PredicateCondition
  10681. * @param actionManager manager for the action the condition applies to
  10682. * @param predicate defines the predicate function used to validate the condition
  10683. */
  10684. constructor(actionManager: ActionManager,
  10685. /** defines the predicate function used to validate the condition */
  10686. predicate: () => boolean);
  10687. /**
  10688. * @returns the validity of the predicate condition
  10689. */
  10690. isValid(): boolean;
  10691. }
  10692. /**
  10693. * Defines a state condition as an extension of Condition
  10694. */
  10695. export class StateCondition extends Condition {
  10696. /** Value to compare with target state */
  10697. value: string;
  10698. /**
  10699. * Internal only - manager for action
  10700. * @hidden
  10701. */
  10702. _actionManager: ActionManager;
  10703. /**
  10704. * Internal only
  10705. * @hidden
  10706. */
  10707. private _target;
  10708. /**
  10709. * Creates a new StateCondition
  10710. * @param actionManager manager for the action the condition applies to
  10711. * @param target of the condition
  10712. * @param value to compare with target state
  10713. */
  10714. constructor(actionManager: ActionManager, target: any,
  10715. /** Value to compare with target state */
  10716. value: string);
  10717. /**
  10718. * Gets a boolean indicating if the current condition is met
  10719. * @returns the validity of the state
  10720. */
  10721. isValid(): boolean;
  10722. /**
  10723. * Serialize the StateCondition into a JSON compatible object
  10724. * @returns serialization object
  10725. */
  10726. serialize(): any;
  10727. }
  10728. }
  10729. declare module BABYLON {
  10730. /**
  10731. * This defines an action responsible to toggle a boolean once triggered.
  10732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10733. */
  10734. export class SwitchBooleanAction extends Action {
  10735. /**
  10736. * The path to the boolean property in the target object
  10737. */
  10738. propertyPath: string;
  10739. private _target;
  10740. private _effectiveTarget;
  10741. private _property;
  10742. /**
  10743. * Instantiate the action
  10744. * @param triggerOptions defines the trigger options
  10745. * @param target defines the object containing the boolean
  10746. * @param propertyPath defines the path to the boolean property in the target object
  10747. * @param condition defines the trigger related conditions
  10748. */
  10749. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10750. /** @hidden */
  10751. _prepare(): void;
  10752. /**
  10753. * Execute the action toggle the boolean value.
  10754. */
  10755. execute(): void;
  10756. /**
  10757. * Serializes the actions and its related information.
  10758. * @param parent defines the object to serialize in
  10759. * @returns the serialized object
  10760. */
  10761. serialize(parent: any): any;
  10762. }
  10763. /**
  10764. * This defines an action responsible to set a the state field of the target
  10765. * to a desired value once triggered.
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10767. */
  10768. export class SetStateAction extends Action {
  10769. /**
  10770. * The value to store in the state field.
  10771. */
  10772. value: string;
  10773. private _target;
  10774. /**
  10775. * Instantiate the action
  10776. * @param triggerOptions defines the trigger options
  10777. * @param target defines the object containing the state property
  10778. * @param value defines the value to store in the state field
  10779. * @param condition defines the trigger related conditions
  10780. */
  10781. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10782. /**
  10783. * Execute the action and store the value on the target state property.
  10784. */
  10785. execute(): void;
  10786. /**
  10787. * Serializes the actions and its related information.
  10788. * @param parent defines the object to serialize in
  10789. * @returns the serialized object
  10790. */
  10791. serialize(parent: any): any;
  10792. }
  10793. /**
  10794. * This defines an action responsible to set a property of the target
  10795. * to a desired value once triggered.
  10796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10797. */
  10798. export class SetValueAction extends Action {
  10799. /**
  10800. * The path of the property to set in the target.
  10801. */
  10802. propertyPath: string;
  10803. /**
  10804. * The value to set in the property
  10805. */
  10806. value: any;
  10807. private _target;
  10808. private _effectiveTarget;
  10809. private _property;
  10810. /**
  10811. * Instantiate the action
  10812. * @param triggerOptions defines the trigger options
  10813. * @param target defines the object containing the property
  10814. * @param propertyPath defines the path of the property to set in the target
  10815. * @param value defines the value to set in the property
  10816. * @param condition defines the trigger related conditions
  10817. */
  10818. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10819. /** @hidden */
  10820. _prepare(): void;
  10821. /**
  10822. * Execute the action and set the targetted property to the desired value.
  10823. */
  10824. execute(): void;
  10825. /**
  10826. * Serializes the actions and its related information.
  10827. * @param parent defines the object to serialize in
  10828. * @returns the serialized object
  10829. */
  10830. serialize(parent: any): any;
  10831. }
  10832. /**
  10833. * This defines an action responsible to increment the target value
  10834. * to a desired value once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class IncrementValueAction extends Action {
  10838. /**
  10839. * The path of the property to increment in the target.
  10840. */
  10841. propertyPath: string;
  10842. /**
  10843. * The value we should increment the property by.
  10844. */
  10845. value: any;
  10846. private _target;
  10847. private _effectiveTarget;
  10848. private _property;
  10849. /**
  10850. * Instantiate the action
  10851. * @param triggerOptions defines the trigger options
  10852. * @param target defines the object containing the property
  10853. * @param propertyPath defines the path of the property to increment in the target
  10854. * @param value defines the value value we should increment the property by
  10855. * @param condition defines the trigger related conditions
  10856. */
  10857. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10858. /** @hidden */
  10859. _prepare(): void;
  10860. /**
  10861. * Execute the action and increment the target of the value amount.
  10862. */
  10863. execute(): void;
  10864. /**
  10865. * Serializes the actions and its related information.
  10866. * @param parent defines the object to serialize in
  10867. * @returns the serialized object
  10868. */
  10869. serialize(parent: any): any;
  10870. }
  10871. /**
  10872. * This defines an action responsible to start an animation once triggered.
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10874. */
  10875. export class PlayAnimationAction extends Action {
  10876. /**
  10877. * Where the animation should start (animation frame)
  10878. */
  10879. from: number;
  10880. /**
  10881. * Where the animation should stop (animation frame)
  10882. */
  10883. to: number;
  10884. /**
  10885. * Define if the animation should loop or stop after the first play.
  10886. */
  10887. loop?: boolean;
  10888. private _target;
  10889. /**
  10890. * Instantiate the action
  10891. * @param triggerOptions defines the trigger options
  10892. * @param target defines the target animation or animation name
  10893. * @param from defines from where the animation should start (animation frame)
  10894. * @param end defines where the animation should stop (animation frame)
  10895. * @param loop defines if the animation should loop or stop after the first play
  10896. * @param condition defines the trigger related conditions
  10897. */
  10898. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10899. /** @hidden */
  10900. _prepare(): void;
  10901. /**
  10902. * Execute the action and play the animation.
  10903. */
  10904. execute(): void;
  10905. /**
  10906. * Serializes the actions and its related information.
  10907. * @param parent defines the object to serialize in
  10908. * @returns the serialized object
  10909. */
  10910. serialize(parent: any): any;
  10911. }
  10912. /**
  10913. * This defines an action responsible to stop an animation once triggered.
  10914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10915. */
  10916. export class StopAnimationAction extends Action {
  10917. private _target;
  10918. /**
  10919. * Instantiate the action
  10920. * @param triggerOptions defines the trigger options
  10921. * @param target defines the target animation or animation name
  10922. * @param condition defines the trigger related conditions
  10923. */
  10924. constructor(triggerOptions: any, target: any, condition?: Condition);
  10925. /** @hidden */
  10926. _prepare(): void;
  10927. /**
  10928. * Execute the action and stop the animation.
  10929. */
  10930. execute(): void;
  10931. /**
  10932. * Serializes the actions and its related information.
  10933. * @param parent defines the object to serialize in
  10934. * @returns the serialized object
  10935. */
  10936. serialize(parent: any): any;
  10937. }
  10938. /**
  10939. * This defines an action responsible that does nothing once triggered.
  10940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10941. */
  10942. export class DoNothingAction extends Action {
  10943. /**
  10944. * Instantiate the action
  10945. * @param triggerOptions defines the trigger options
  10946. * @param condition defines the trigger related conditions
  10947. */
  10948. constructor(triggerOptions?: any, condition?: Condition);
  10949. /**
  10950. * Execute the action and do nothing.
  10951. */
  10952. execute(): void;
  10953. /**
  10954. * Serializes the actions and its related information.
  10955. * @param parent defines the object to serialize in
  10956. * @returns the serialized object
  10957. */
  10958. serialize(parent: any): any;
  10959. }
  10960. /**
  10961. * This defines an action responsible to trigger several actions once triggered.
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10963. */
  10964. export class CombineAction extends Action {
  10965. /**
  10966. * The list of aggregated animations to run.
  10967. */
  10968. children: Action[];
  10969. /**
  10970. * Instantiate the action
  10971. * @param triggerOptions defines the trigger options
  10972. * @param children defines the list of aggregated animations to run
  10973. * @param condition defines the trigger related conditions
  10974. */
  10975. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10976. /** @hidden */
  10977. _prepare(): void;
  10978. /**
  10979. * Execute the action and executes all the aggregated actions.
  10980. */
  10981. execute(evt: ActionEvent): void;
  10982. /**
  10983. * Serializes the actions and its related information.
  10984. * @param parent defines the object to serialize in
  10985. * @returns the serialized object
  10986. */
  10987. serialize(parent: any): any;
  10988. }
  10989. /**
  10990. * This defines an action responsible to run code (external event) once triggered.
  10991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10992. */
  10993. export class ExecuteCodeAction extends Action {
  10994. /**
  10995. * The callback function to run.
  10996. */
  10997. func: (evt: ActionEvent) => void;
  10998. /**
  10999. * Instantiate the action
  11000. * @param triggerOptions defines the trigger options
  11001. * @param func defines the callback function to run
  11002. * @param condition defines the trigger related conditions
  11003. */
  11004. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11005. /**
  11006. * Execute the action and run the attached code.
  11007. */
  11008. execute(evt: ActionEvent): void;
  11009. }
  11010. /**
  11011. * This defines an action responsible to set the parent property of the target once triggered.
  11012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11013. */
  11014. export class SetParentAction extends Action {
  11015. private _parent;
  11016. private _target;
  11017. /**
  11018. * Instantiate the action
  11019. * @param triggerOptions defines the trigger options
  11020. * @param target defines the target containing the parent property
  11021. * @param parent defines from where the animation should start (animation frame)
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11025. /** @hidden */
  11026. _prepare(): void;
  11027. /**
  11028. * Execute the action and set the parent property.
  11029. */
  11030. execute(): void;
  11031. /**
  11032. * Serializes the actions and its related information.
  11033. * @param parent defines the object to serialize in
  11034. * @returns the serialized object
  11035. */
  11036. serialize(parent: any): any;
  11037. }
  11038. }
  11039. declare module BABYLON {
  11040. /**
  11041. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11042. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11044. */
  11045. export class ActionManager extends AbstractActionManager {
  11046. /**
  11047. * Nothing
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11049. */
  11050. static readonly NothingTrigger: number;
  11051. /**
  11052. * On pick
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly OnPickTrigger: number;
  11056. /**
  11057. * On left pick
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnLeftPickTrigger: number;
  11061. /**
  11062. * On right pick
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnRightPickTrigger: number;
  11066. /**
  11067. * On center pick
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnCenterPickTrigger: number;
  11071. /**
  11072. * On pick down
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnPickDownTrigger: number;
  11076. /**
  11077. * On double pick
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnDoublePickTrigger: number;
  11081. /**
  11082. * On pick up
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnPickUpTrigger: number;
  11086. /**
  11087. * On pick out.
  11088. * This trigger will only be raised if you also declared a OnPickDown
  11089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11090. */
  11091. static readonly OnPickOutTrigger: number;
  11092. /**
  11093. * On long press
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnLongPressTrigger: number;
  11097. /**
  11098. * On pointer over
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnPointerOverTrigger: number;
  11102. /**
  11103. * On pointer out
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnPointerOutTrigger: number;
  11107. /**
  11108. * On every frame
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnEveryFrameTrigger: number;
  11112. /**
  11113. * On intersection enter
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnIntersectionEnterTrigger: number;
  11117. /**
  11118. * On intersection exit
  11119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11120. */
  11121. static readonly OnIntersectionExitTrigger: number;
  11122. /**
  11123. * On key down
  11124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11125. */
  11126. static readonly OnKeyDownTrigger: number;
  11127. /**
  11128. * On key up
  11129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11130. */
  11131. static readonly OnKeyUpTrigger: number;
  11132. private _scene;
  11133. /**
  11134. * Creates a new action manager
  11135. * @param scene defines the hosting scene
  11136. */
  11137. constructor(scene: Scene);
  11138. /**
  11139. * Releases all associated resources
  11140. */
  11141. dispose(): void;
  11142. /**
  11143. * Gets hosting scene
  11144. * @returns the hosting scene
  11145. */
  11146. getScene(): Scene;
  11147. /**
  11148. * Does this action manager handles actions of any of the given triggers
  11149. * @param triggers defines the triggers to be tested
  11150. * @return a boolean indicating whether one (or more) of the triggers is handled
  11151. */
  11152. hasSpecificTriggers(triggers: number[]): boolean;
  11153. /**
  11154. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11155. * speed.
  11156. * @param triggerA defines the trigger to be tested
  11157. * @param triggerB defines the trigger to be tested
  11158. * @return a boolean indicating whether one (or more) of the triggers is handled
  11159. */
  11160. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11161. /**
  11162. * Does this action manager handles actions of a given trigger
  11163. * @param trigger defines the trigger to be tested
  11164. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11165. * @return whether the trigger is handled
  11166. */
  11167. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11168. /**
  11169. * Does this action manager has pointer triggers
  11170. */
  11171. readonly hasPointerTriggers: boolean;
  11172. /**
  11173. * Does this action manager has pick triggers
  11174. */
  11175. readonly hasPickTriggers: boolean;
  11176. /**
  11177. * Registers an action to this action manager
  11178. * @param action defines the action to be registered
  11179. * @return the action amended (prepared) after registration
  11180. */
  11181. registerAction(action: IAction): Nullable<IAction>;
  11182. /**
  11183. * Unregisters an action to this action manager
  11184. * @param action defines the action to be unregistered
  11185. * @return a boolean indicating whether the action has been unregistered
  11186. */
  11187. unregisterAction(action: IAction): Boolean;
  11188. /**
  11189. * Process a specific trigger
  11190. * @param trigger defines the trigger to process
  11191. * @param evt defines the event details to be processed
  11192. */
  11193. processTrigger(trigger: number, evt?: IActionEvent): void;
  11194. /** @hidden */
  11195. _getEffectiveTarget(target: any, propertyPath: string): any;
  11196. /** @hidden */
  11197. _getProperty(propertyPath: string): string;
  11198. /**
  11199. * Serialize this manager to a JSON object
  11200. * @param name defines the property name to store this manager
  11201. * @returns a JSON representation of this manager
  11202. */
  11203. serialize(name: string): any;
  11204. /**
  11205. * Creates a new ActionManager from a JSON data
  11206. * @param parsedActions defines the JSON data to read from
  11207. * @param object defines the hosting mesh
  11208. * @param scene defines the hosting scene
  11209. */
  11210. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11211. /**
  11212. * Get a trigger name by index
  11213. * @param trigger defines the trigger index
  11214. * @returns a trigger name
  11215. */
  11216. static GetTriggerName(trigger: number): string;
  11217. }
  11218. }
  11219. declare module BABYLON {
  11220. /**
  11221. * Class representing a ray with position and direction
  11222. */
  11223. export class Ray {
  11224. /** origin point */
  11225. origin: Vector3;
  11226. /** direction */
  11227. direction: Vector3;
  11228. /** length of the ray */
  11229. length: number;
  11230. private static readonly TmpVector3;
  11231. private _tmpRay;
  11232. /**
  11233. * Creates a new ray
  11234. * @param origin origin point
  11235. * @param direction direction
  11236. * @param length length of the ray
  11237. */
  11238. constructor(
  11239. /** origin point */
  11240. origin: Vector3,
  11241. /** direction */
  11242. direction: Vector3,
  11243. /** length of the ray */
  11244. length?: number);
  11245. /**
  11246. * Checks if the ray intersects a box
  11247. * @param minimum bound of the box
  11248. * @param maximum bound of the box
  11249. * @param intersectionTreshold extra extend to be added to the box in all direction
  11250. * @returns if the box was hit
  11251. */
  11252. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11253. /**
  11254. * Checks if the ray intersects a box
  11255. * @param box the bounding box to check
  11256. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11257. * @returns if the box was hit
  11258. */
  11259. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11260. /**
  11261. * If the ray hits a sphere
  11262. * @param sphere the bounding sphere to check
  11263. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11264. * @returns true if it hits the sphere
  11265. */
  11266. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11267. /**
  11268. * If the ray hits a triange
  11269. * @param vertex0 triangle vertex
  11270. * @param vertex1 triangle vertex
  11271. * @param vertex2 triangle vertex
  11272. * @returns intersection information if hit
  11273. */
  11274. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11275. /**
  11276. * Checks if ray intersects a plane
  11277. * @param plane the plane to check
  11278. * @returns the distance away it was hit
  11279. */
  11280. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11281. /**
  11282. * Checks if ray intersects a mesh
  11283. * @param mesh the mesh to check
  11284. * @param fastCheck if only the bounding box should checked
  11285. * @returns picking info of the intersecton
  11286. */
  11287. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11288. /**
  11289. * Checks if ray intersects a mesh
  11290. * @param meshes the meshes to check
  11291. * @param fastCheck if only the bounding box should checked
  11292. * @param results array to store result in
  11293. * @returns Array of picking infos
  11294. */
  11295. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11296. private _comparePickingInfo;
  11297. private static smallnum;
  11298. private static rayl;
  11299. /**
  11300. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11301. * @param sega the first point of the segment to test the intersection against
  11302. * @param segb the second point of the segment to test the intersection against
  11303. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11304. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11305. */
  11306. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11307. /**
  11308. * Update the ray from viewport position
  11309. * @param x position
  11310. * @param y y position
  11311. * @param viewportWidth viewport width
  11312. * @param viewportHeight viewport height
  11313. * @param world world matrix
  11314. * @param view view matrix
  11315. * @param projection projection matrix
  11316. * @returns this ray updated
  11317. */
  11318. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11319. /**
  11320. * Creates a ray with origin and direction of 0,0,0
  11321. * @returns the new ray
  11322. */
  11323. static Zero(): Ray;
  11324. /**
  11325. * Creates a new ray from screen space and viewport
  11326. * @param x position
  11327. * @param y y position
  11328. * @param viewportWidth viewport width
  11329. * @param viewportHeight viewport height
  11330. * @param world world matrix
  11331. * @param view view matrix
  11332. * @param projection projection matrix
  11333. * @returns new ray
  11334. */
  11335. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11336. /**
  11337. * 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
  11338. * transformed to the given world matrix.
  11339. * @param origin The origin point
  11340. * @param end The end point
  11341. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11342. * @returns the new ray
  11343. */
  11344. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11345. /**
  11346. * Transforms a ray by a matrix
  11347. * @param ray ray to transform
  11348. * @param matrix matrix to apply
  11349. * @returns the resulting new ray
  11350. */
  11351. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11352. /**
  11353. * Transforms a ray by a matrix
  11354. * @param ray ray to transform
  11355. * @param matrix matrix to apply
  11356. * @param result ray to store result in
  11357. */
  11358. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11359. /**
  11360. * Unproject a ray from screen space to object space
  11361. * @param sourceX defines the screen space x coordinate to use
  11362. * @param sourceY defines the screen space y coordinate to use
  11363. * @param viewportWidth defines the current width of the viewport
  11364. * @param viewportHeight defines the current height of the viewport
  11365. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11366. * @param view defines the view matrix to use
  11367. * @param projection defines the projection matrix to use
  11368. */
  11369. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11370. }
  11371. /**
  11372. * Type used to define predicate used to select faces when a mesh intersection is detected
  11373. */
  11374. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11375. interface Scene {
  11376. /** @hidden */
  11377. _tempPickingRay: Nullable<Ray>;
  11378. /** @hidden */
  11379. _cachedRayForTransform: Ray;
  11380. /** @hidden */
  11381. _pickWithRayInverseMatrix: Matrix;
  11382. /** @hidden */
  11383. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11384. /** @hidden */
  11385. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11386. }
  11387. }
  11388. declare module BABYLON {
  11389. /**
  11390. * Groups all the scene component constants in one place to ease maintenance.
  11391. * @hidden
  11392. */
  11393. export class SceneComponentConstants {
  11394. static readonly NAME_EFFECTLAYER: string;
  11395. static readonly NAME_LAYER: string;
  11396. static readonly NAME_LENSFLARESYSTEM: string;
  11397. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11398. static readonly NAME_PARTICLESYSTEM: string;
  11399. static readonly NAME_GAMEPAD: string;
  11400. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11401. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11402. static readonly NAME_DEPTHRENDERER: string;
  11403. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11404. static readonly NAME_SPRITE: string;
  11405. static readonly NAME_OUTLINERENDERER: string;
  11406. static readonly NAME_PROCEDURALTEXTURE: string;
  11407. static readonly NAME_SHADOWGENERATOR: string;
  11408. static readonly NAME_OCTREE: string;
  11409. static readonly NAME_PHYSICSENGINE: string;
  11410. static readonly NAME_AUDIO: string;
  11411. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11412. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11413. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11414. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11415. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11416. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11417. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11418. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11419. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11420. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11421. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11422. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11423. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11424. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11425. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11426. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11427. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11428. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11429. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11430. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11431. static readonly STEP_AFTERRENDER_AUDIO: number;
  11432. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11433. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11434. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11435. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11436. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11437. static readonly STEP_POINTERMOVE_SPRITE: number;
  11438. static readonly STEP_POINTERDOWN_SPRITE: number;
  11439. static readonly STEP_POINTERUP_SPRITE: number;
  11440. }
  11441. /**
  11442. * This represents a scene component.
  11443. *
  11444. * This is used to decouple the dependency the scene is having on the different workloads like
  11445. * layers, post processes...
  11446. */
  11447. export interface ISceneComponent {
  11448. /**
  11449. * The name of the component. Each component must have a unique name.
  11450. */
  11451. name: string;
  11452. /**
  11453. * The scene the component belongs to.
  11454. */
  11455. scene: Scene;
  11456. /**
  11457. * Register the component to one instance of a scene.
  11458. */
  11459. register(): void;
  11460. /**
  11461. * Rebuilds the elements related to this component in case of
  11462. * context lost for instance.
  11463. */
  11464. rebuild(): void;
  11465. /**
  11466. * Disposes the component and the associated ressources.
  11467. */
  11468. dispose(): void;
  11469. }
  11470. /**
  11471. * This represents a SERIALIZABLE scene component.
  11472. *
  11473. * This extends Scene Component to add Serialization methods on top.
  11474. */
  11475. export interface ISceneSerializableComponent extends ISceneComponent {
  11476. /**
  11477. * Adds all the element from the container to the scene
  11478. * @param container the container holding the elements
  11479. */
  11480. addFromContainer(container: AbstractScene): void;
  11481. /**
  11482. * Removes all the elements in the container from the scene
  11483. * @param container contains the elements to remove
  11484. * @param dispose if the removed element should be disposed (default: false)
  11485. */
  11486. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11487. /**
  11488. * Serializes the component data to the specified json object
  11489. * @param serializationObject The object to serialize to
  11490. */
  11491. serialize(serializationObject: any): void;
  11492. }
  11493. /**
  11494. * Strong typing of a Mesh related stage step action
  11495. */
  11496. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11497. /**
  11498. * Strong typing of a Evaluate Sub Mesh related stage step action
  11499. */
  11500. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11501. /**
  11502. * Strong typing of a Active Mesh related stage step action
  11503. */
  11504. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11505. /**
  11506. * Strong typing of a Camera related stage step action
  11507. */
  11508. export type CameraStageAction = (camera: Camera) => void;
  11509. /**
  11510. * Strong typing of a Render Target related stage step action
  11511. */
  11512. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11513. /**
  11514. * Strong typing of a RenderingGroup related stage step action
  11515. */
  11516. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11517. /**
  11518. * Strong typing of a Mesh Render related stage step action
  11519. */
  11520. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11521. /**
  11522. * Strong typing of a simple stage step action
  11523. */
  11524. export type SimpleStageAction = () => void;
  11525. /**
  11526. * Strong typing of a render target action.
  11527. */
  11528. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11529. /**
  11530. * Strong typing of a pointer move action.
  11531. */
  11532. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11533. /**
  11534. * Strong typing of a pointer up/down action.
  11535. */
  11536. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11537. /**
  11538. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11539. * @hidden
  11540. */
  11541. export class Stage<T extends Function> extends Array<{
  11542. index: number;
  11543. component: ISceneComponent;
  11544. action: T;
  11545. }> {
  11546. /**
  11547. * Hide ctor from the rest of the world.
  11548. * @param items The items to add.
  11549. */
  11550. private constructor();
  11551. /**
  11552. * Creates a new Stage.
  11553. * @returns A new instance of a Stage
  11554. */
  11555. static Create<T extends Function>(): Stage<T>;
  11556. /**
  11557. * Registers a step in an ordered way in the targeted stage.
  11558. * @param index Defines the position to register the step in
  11559. * @param component Defines the component attached to the step
  11560. * @param action Defines the action to launch during the step
  11561. */
  11562. registerStep(index: number, component: ISceneComponent, action: T): void;
  11563. /**
  11564. * Clears all the steps from the stage.
  11565. */
  11566. clear(): void;
  11567. }
  11568. }
  11569. declare module BABYLON {
  11570. interface Scene {
  11571. /** @hidden */
  11572. _pointerOverSprite: Nullable<Sprite>;
  11573. /** @hidden */
  11574. _pickedDownSprite: Nullable<Sprite>;
  11575. /** @hidden */
  11576. _tempSpritePickingRay: Nullable<Ray>;
  11577. /**
  11578. * All of the sprite managers added to this scene
  11579. * @see http://doc.babylonjs.com/babylon101/sprites
  11580. */
  11581. spriteManagers: Array<ISpriteManager>;
  11582. /**
  11583. * An event triggered when sprites rendering is about to start
  11584. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11585. */
  11586. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11587. /**
  11588. * An event triggered when sprites rendering is done
  11589. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11590. */
  11591. onAfterSpritesRenderingObservable: Observable<Scene>;
  11592. /** @hidden */
  11593. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11594. /** Launch a ray to try to pick a sprite in the scene
  11595. * @param x position on screen
  11596. * @param y position on screen
  11597. * @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
  11598. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11599. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11600. * @returns a PickingInfo
  11601. */
  11602. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11603. /** Use the given ray to pick a sprite in the scene
  11604. * @param ray The ray (in world space) to use to pick meshes
  11605. * @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
  11606. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11607. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11608. * @returns a PickingInfo
  11609. */
  11610. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11611. /**
  11612. * Force the sprite under the pointer
  11613. * @param sprite defines the sprite to use
  11614. */
  11615. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11616. /**
  11617. * Gets the sprite under the pointer
  11618. * @returns a Sprite or null if no sprite is under the pointer
  11619. */
  11620. getPointerOverSprite(): Nullable<Sprite>;
  11621. }
  11622. /**
  11623. * Defines the sprite scene component responsible to manage sprites
  11624. * in a given scene.
  11625. */
  11626. export class SpriteSceneComponent implements ISceneComponent {
  11627. /**
  11628. * The component name helpfull to identify the component in the list of scene components.
  11629. */
  11630. readonly name: string;
  11631. /**
  11632. * The scene the component belongs to.
  11633. */
  11634. scene: Scene;
  11635. /** @hidden */
  11636. private _spritePredicate;
  11637. /**
  11638. * Creates a new instance of the component for the given scene
  11639. * @param scene Defines the scene to register the component in
  11640. */
  11641. constructor(scene: Scene);
  11642. /**
  11643. * Registers the component in a given scene
  11644. */
  11645. register(): void;
  11646. /**
  11647. * Rebuilds the elements related to this component in case of
  11648. * context lost for instance.
  11649. */
  11650. rebuild(): void;
  11651. /**
  11652. * Disposes the component and the associated ressources.
  11653. */
  11654. dispose(): void;
  11655. private _pickSpriteButKeepRay;
  11656. private _pointerMove;
  11657. private _pointerDown;
  11658. private _pointerUp;
  11659. }
  11660. }
  11661. declare module BABYLON {
  11662. /** @hidden */
  11663. export var fogFragmentDeclaration: {
  11664. name: string;
  11665. shader: string;
  11666. };
  11667. }
  11668. declare module BABYLON {
  11669. /** @hidden */
  11670. export var fogFragment: {
  11671. name: string;
  11672. shader: string;
  11673. };
  11674. }
  11675. declare module BABYLON {
  11676. /** @hidden */
  11677. export var spritesPixelShader: {
  11678. name: string;
  11679. shader: string;
  11680. };
  11681. }
  11682. declare module BABYLON {
  11683. /** @hidden */
  11684. export var fogVertexDeclaration: {
  11685. name: string;
  11686. shader: string;
  11687. };
  11688. }
  11689. declare module BABYLON {
  11690. /** @hidden */
  11691. export var spritesVertexShader: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module BABYLON {
  11697. /**
  11698. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11699. */
  11700. export interface ISpriteManager extends IDisposable {
  11701. /**
  11702. * Restricts the camera to viewing objects with the same layerMask.
  11703. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11704. */
  11705. layerMask: number;
  11706. /**
  11707. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11708. */
  11709. isPickable: boolean;
  11710. /**
  11711. * Specifies the rendering group id for this mesh (0 by default)
  11712. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11713. */
  11714. renderingGroupId: number;
  11715. /**
  11716. * Defines the list of sprites managed by the manager.
  11717. */
  11718. sprites: Array<Sprite>;
  11719. /**
  11720. * Tests the intersection of a sprite with a specific ray.
  11721. * @param ray The ray we are sending to test the collision
  11722. * @param camera The camera space we are sending rays in
  11723. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11724. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11725. * @returns picking info or null.
  11726. */
  11727. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11728. /**
  11729. * Renders the list of sprites on screen.
  11730. */
  11731. render(): void;
  11732. }
  11733. /**
  11734. * Class used to manage multiple sprites on the same spritesheet
  11735. * @see http://doc.babylonjs.com/babylon101/sprites
  11736. */
  11737. export class SpriteManager implements ISpriteManager {
  11738. /** defines the manager's name */
  11739. name: string;
  11740. /** Gets the list of sprites */
  11741. sprites: Sprite[];
  11742. /** Gets or sets the rendering group id (0 by default) */
  11743. renderingGroupId: number;
  11744. /** Gets or sets camera layer mask */
  11745. layerMask: number;
  11746. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11747. fogEnabled: boolean;
  11748. /** Gets or sets a boolean indicating if the sprites are pickable */
  11749. isPickable: boolean;
  11750. /** Defines the default width of a cell in the spritesheet */
  11751. cellWidth: number;
  11752. /** Defines the default height of a cell in the spritesheet */
  11753. cellHeight: number;
  11754. /**
  11755. * An event triggered when the manager is disposed.
  11756. */
  11757. onDisposeObservable: Observable<SpriteManager>;
  11758. private _onDisposeObserver;
  11759. /**
  11760. * Callback called when the manager is disposed
  11761. */
  11762. onDispose: () => void;
  11763. private _capacity;
  11764. private _spriteTexture;
  11765. private _epsilon;
  11766. private _scene;
  11767. private _vertexData;
  11768. private _buffer;
  11769. private _vertexBuffers;
  11770. private _indexBuffer;
  11771. private _effectBase;
  11772. private _effectFog;
  11773. /**
  11774. * Gets or sets the spritesheet texture
  11775. */
  11776. texture: Texture;
  11777. /**
  11778. * Creates a new sprite manager
  11779. * @param name defines the manager's name
  11780. * @param imgUrl defines the sprite sheet url
  11781. * @param capacity defines the maximum allowed number of sprites
  11782. * @param cellSize defines the size of a sprite cell
  11783. * @param scene defines the hosting scene
  11784. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11785. * @param samplingMode defines the smapling mode to use with spritesheet
  11786. */
  11787. constructor(
  11788. /** defines the manager's name */
  11789. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11790. private _appendSpriteVertex;
  11791. /**
  11792. * Intersects the sprites with a ray
  11793. * @param ray defines the ray to intersect with
  11794. * @param camera defines the current active camera
  11795. * @param predicate defines a predicate used to select candidate sprites
  11796. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11797. * @returns null if no hit or a PickingInfo
  11798. */
  11799. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11800. /**
  11801. * Render all child sprites
  11802. */
  11803. render(): void;
  11804. /**
  11805. * Release associated resources
  11806. */
  11807. dispose(): void;
  11808. }
  11809. }
  11810. declare module BABYLON {
  11811. /**
  11812. * Class used to represent a sprite
  11813. * @see http://doc.babylonjs.com/babylon101/sprites
  11814. */
  11815. export class Sprite {
  11816. /** defines the name */
  11817. name: string;
  11818. /** Gets or sets the current world position */
  11819. position: Vector3;
  11820. /** Gets or sets the main color */
  11821. color: Color4;
  11822. /** Gets or sets the width */
  11823. width: number;
  11824. /** Gets or sets the height */
  11825. height: number;
  11826. /** Gets or sets rotation angle */
  11827. angle: number;
  11828. /** Gets or sets the cell index in the sprite sheet */
  11829. cellIndex: number;
  11830. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11831. invertU: number;
  11832. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11833. invertV: number;
  11834. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11835. disposeWhenFinishedAnimating: boolean;
  11836. /** Gets the list of attached animations */
  11837. animations: Animation[];
  11838. /** Gets or sets a boolean indicating if the sprite can be picked */
  11839. isPickable: boolean;
  11840. /**
  11841. * Gets or sets the associated action manager
  11842. */
  11843. actionManager: Nullable<ActionManager>;
  11844. private _animationStarted;
  11845. private _loopAnimation;
  11846. private _fromIndex;
  11847. private _toIndex;
  11848. private _delay;
  11849. private _direction;
  11850. private _manager;
  11851. private _time;
  11852. private _onAnimationEnd;
  11853. /**
  11854. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11855. */
  11856. isVisible: boolean;
  11857. /**
  11858. * Gets or sets the sprite size
  11859. */
  11860. size: number;
  11861. /**
  11862. * Creates a new Sprite
  11863. * @param name defines the name
  11864. * @param manager defines the manager
  11865. */
  11866. constructor(
  11867. /** defines the name */
  11868. name: string, manager: ISpriteManager);
  11869. /**
  11870. * Starts an animation
  11871. * @param from defines the initial key
  11872. * @param to defines the end key
  11873. * @param loop defines if the animation must loop
  11874. * @param delay defines the start delay (in ms)
  11875. * @param onAnimationEnd defines a callback to call when animation ends
  11876. */
  11877. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11878. /** Stops current animation (if any) */
  11879. stopAnimation(): void;
  11880. /** @hidden */
  11881. _animate(deltaTime: number): void;
  11882. /** Release associated resources */
  11883. dispose(): void;
  11884. }
  11885. }
  11886. declare module BABYLON {
  11887. /**
  11888. * Information about the result of picking within a scene
  11889. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11890. */
  11891. export class PickingInfo {
  11892. /** @hidden */
  11893. _pickingUnavailable: boolean;
  11894. /**
  11895. * If the pick collided with an object
  11896. */
  11897. hit: boolean;
  11898. /**
  11899. * Distance away where the pick collided
  11900. */
  11901. distance: number;
  11902. /**
  11903. * The location of pick collision
  11904. */
  11905. pickedPoint: Nullable<Vector3>;
  11906. /**
  11907. * The mesh corresponding the the pick collision
  11908. */
  11909. pickedMesh: Nullable<AbstractMesh>;
  11910. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11911. bu: number;
  11912. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11913. bv: number;
  11914. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11915. faceId: number;
  11916. /** Id of the the submesh that was picked */
  11917. subMeshId: number;
  11918. /** If a sprite was picked, this will be the sprite the pick collided with */
  11919. pickedSprite: Nullable<Sprite>;
  11920. /**
  11921. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11922. */
  11923. originMesh: Nullable<AbstractMesh>;
  11924. /**
  11925. * The ray that was used to perform the picking.
  11926. */
  11927. ray: Nullable<Ray>;
  11928. /**
  11929. * Gets the normal correspodning to the face the pick collided with
  11930. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11931. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11932. * @returns The normal correspodning to the face the pick collided with
  11933. */
  11934. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11935. /**
  11936. * Gets the texture coordinates of where the pick occured
  11937. * @returns the vector containing the coordnates of the texture
  11938. */
  11939. getTextureCoordinates(): Nullable<Vector2>;
  11940. }
  11941. }
  11942. declare module BABYLON {
  11943. /**
  11944. * Gather the list of pointer event types as constants.
  11945. */
  11946. export class PointerEventTypes {
  11947. /**
  11948. * 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.
  11949. */
  11950. static readonly POINTERDOWN: number;
  11951. /**
  11952. * The pointerup event is fired when a pointer is no longer active.
  11953. */
  11954. static readonly POINTERUP: number;
  11955. /**
  11956. * The pointermove event is fired when a pointer changes coordinates.
  11957. */
  11958. static readonly POINTERMOVE: number;
  11959. /**
  11960. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11961. */
  11962. static readonly POINTERWHEEL: number;
  11963. /**
  11964. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11965. */
  11966. static readonly POINTERPICK: number;
  11967. /**
  11968. * The pointertap event is fired when a the object has been touched and released without drag.
  11969. */
  11970. static readonly POINTERTAP: number;
  11971. /**
  11972. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11973. */
  11974. static readonly POINTERDOUBLETAP: number;
  11975. }
  11976. /**
  11977. * Base class of pointer info types.
  11978. */
  11979. export class PointerInfoBase {
  11980. /**
  11981. * Defines the type of event (PointerEventTypes)
  11982. */
  11983. type: number;
  11984. /**
  11985. * Defines the related dom event
  11986. */
  11987. event: PointerEvent | MouseWheelEvent;
  11988. /**
  11989. * Instantiates the base class of pointers info.
  11990. * @param type Defines the type of event (PointerEventTypes)
  11991. * @param event Defines the related dom event
  11992. */
  11993. constructor(
  11994. /**
  11995. * Defines the type of event (PointerEventTypes)
  11996. */
  11997. type: number,
  11998. /**
  11999. * Defines the related dom event
  12000. */
  12001. event: PointerEvent | MouseWheelEvent);
  12002. }
  12003. /**
  12004. * This class is used to store pointer related info for the onPrePointerObservable event.
  12005. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12006. */
  12007. export class PointerInfoPre extends PointerInfoBase {
  12008. /**
  12009. * Ray from a pointer if availible (eg. 6dof controller)
  12010. */
  12011. ray: Nullable<Ray>;
  12012. /**
  12013. * Defines the local position of the pointer on the canvas.
  12014. */
  12015. localPosition: Vector2;
  12016. /**
  12017. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12018. */
  12019. skipOnPointerObservable: boolean;
  12020. /**
  12021. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12022. * @param type Defines the type of event (PointerEventTypes)
  12023. * @param event Defines the related dom event
  12024. * @param localX Defines the local x coordinates of the pointer when the event occured
  12025. * @param localY Defines the local y coordinates of the pointer when the event occured
  12026. */
  12027. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12028. }
  12029. /**
  12030. * This type contains all the data related to a pointer event in Babylon.js.
  12031. * 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.
  12032. */
  12033. export class PointerInfo extends PointerInfoBase {
  12034. /**
  12035. * Defines the picking info associated to the info (if any)\
  12036. */
  12037. pickInfo: Nullable<PickingInfo>;
  12038. /**
  12039. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12040. * @param type Defines the type of event (PointerEventTypes)
  12041. * @param event Defines the related dom event
  12042. * @param pickInfo Defines the picking info associated to the info (if any)\
  12043. */
  12044. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12045. /**
  12046. * Defines the picking info associated to the info (if any)\
  12047. */
  12048. pickInfo: Nullable<PickingInfo>);
  12049. }
  12050. /**
  12051. * Data relating to a touch event on the screen.
  12052. */
  12053. export interface PointerTouch {
  12054. /**
  12055. * X coordinate of touch.
  12056. */
  12057. x: number;
  12058. /**
  12059. * Y coordinate of touch.
  12060. */
  12061. y: number;
  12062. /**
  12063. * Id of touch. Unique for each finger.
  12064. */
  12065. pointerId: number;
  12066. /**
  12067. * Event type passed from DOM.
  12068. */
  12069. type: any;
  12070. }
  12071. }
  12072. declare module BABYLON {
  12073. /**
  12074. * Manage the mouse inputs to control the movement of a free camera.
  12075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12076. */
  12077. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12078. /**
  12079. * Define if touch is enabled in the mouse input
  12080. */
  12081. touchEnabled: boolean;
  12082. /**
  12083. * Defines the camera the input is attached to.
  12084. */
  12085. camera: FreeCamera;
  12086. /**
  12087. * Defines the buttons associated with the input to handle camera move.
  12088. */
  12089. buttons: number[];
  12090. /**
  12091. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12092. */
  12093. angularSensibility: number;
  12094. private _pointerInput;
  12095. private _onMouseMove;
  12096. private _observer;
  12097. private previousPosition;
  12098. /**
  12099. * Observable for when a pointer move event occurs containing the move offset
  12100. */
  12101. onPointerMovedObservable: Observable<{
  12102. offsetX: number;
  12103. offsetY: number;
  12104. }>;
  12105. /**
  12106. * @hidden
  12107. * If the camera should be rotated automatically based on pointer movement
  12108. */
  12109. _allowCameraRotation: boolean;
  12110. /**
  12111. * Manage the mouse inputs to control the movement of a free camera.
  12112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12113. * @param touchEnabled Defines if touch is enabled or not
  12114. */
  12115. constructor(
  12116. /**
  12117. * Define if touch is enabled in the mouse input
  12118. */
  12119. touchEnabled?: boolean);
  12120. /**
  12121. * Attach the input controls to a specific dom element to get the input from.
  12122. * @param element Defines the element the controls should be listened from
  12123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12124. */
  12125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12126. /**
  12127. * Called on JS contextmenu event.
  12128. * Override this method to provide functionality.
  12129. */
  12130. protected onContextMenu(evt: PointerEvent): void;
  12131. /**
  12132. * Detach the current controls from the specified dom element.
  12133. * @param element Defines the element to stop listening the inputs from
  12134. */
  12135. detachControl(element: Nullable<HTMLElement>): void;
  12136. /**
  12137. * Gets the class name of the current intput.
  12138. * @returns the class name
  12139. */
  12140. getClassName(): string;
  12141. /**
  12142. * Get the friendly name associated with the input class.
  12143. * @returns the input friendly name
  12144. */
  12145. getSimpleName(): string;
  12146. }
  12147. }
  12148. declare module BABYLON {
  12149. /**
  12150. * Manage the touch inputs to control the movement of a free camera.
  12151. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12152. */
  12153. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12154. /**
  12155. * Defines the camera the input is attached to.
  12156. */
  12157. camera: FreeCamera;
  12158. /**
  12159. * Defines the touch sensibility for rotation.
  12160. * The higher the faster.
  12161. */
  12162. touchAngularSensibility: number;
  12163. /**
  12164. * Defines the touch sensibility for move.
  12165. * The higher the faster.
  12166. */
  12167. touchMoveSensibility: number;
  12168. private _offsetX;
  12169. private _offsetY;
  12170. private _pointerPressed;
  12171. private _pointerInput;
  12172. private _observer;
  12173. private _onLostFocus;
  12174. /**
  12175. * Attach the input controls to a specific dom element to get the input from.
  12176. * @param element Defines the element the controls should be listened from
  12177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12178. */
  12179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12180. /**
  12181. * Detach the current controls from the specified dom element.
  12182. * @param element Defines the element to stop listening the inputs from
  12183. */
  12184. detachControl(element: Nullable<HTMLElement>): void;
  12185. /**
  12186. * Update the current camera state depending on the inputs that have been used this frame.
  12187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12188. */
  12189. checkInputs(): void;
  12190. /**
  12191. * Gets the class name of the current intput.
  12192. * @returns the class name
  12193. */
  12194. getClassName(): string;
  12195. /**
  12196. * Get the friendly name associated with the input class.
  12197. * @returns the input friendly name
  12198. */
  12199. getSimpleName(): string;
  12200. }
  12201. }
  12202. declare module BABYLON {
  12203. /**
  12204. * Default Inputs manager for the FreeCamera.
  12205. * It groups all the default supported inputs for ease of use.
  12206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12207. */
  12208. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12209. /**
  12210. * @hidden
  12211. */
  12212. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12213. /**
  12214. * @hidden
  12215. */
  12216. _mouseInput: Nullable<FreeCameraMouseInput>;
  12217. /**
  12218. * Instantiates a new FreeCameraInputsManager.
  12219. * @param camera Defines the camera the inputs belong to
  12220. */
  12221. constructor(camera: FreeCamera);
  12222. /**
  12223. * Add keyboard input support to the input manager.
  12224. * @returns the current input manager
  12225. */
  12226. addKeyboard(): FreeCameraInputsManager;
  12227. /**
  12228. * Add mouse input support to the input manager.
  12229. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12230. * @returns the current input manager
  12231. */
  12232. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12233. /**
  12234. * Removes the mouse input support from the manager
  12235. * @returns the current input manager
  12236. */
  12237. removeMouse(): FreeCameraInputsManager;
  12238. /**
  12239. * Add touch input support to the input manager.
  12240. * @returns the current input manager
  12241. */
  12242. addTouch(): FreeCameraInputsManager;
  12243. }
  12244. }
  12245. declare module BABYLON {
  12246. /**
  12247. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12248. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12249. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12250. */
  12251. export class FreeCamera extends TargetCamera {
  12252. /**
  12253. * Define the collision ellipsoid of the camera.
  12254. * This is helpful to simulate a camera body like the player body around the camera
  12255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12256. */
  12257. ellipsoid: Vector3;
  12258. /**
  12259. * Define an offset for the position of the ellipsoid around the camera.
  12260. * This can be helpful to determine the center of the body near the gravity center of the body
  12261. * instead of its head.
  12262. */
  12263. ellipsoidOffset: Vector3;
  12264. /**
  12265. * Enable or disable collisions of the camera with the rest of the scene objects.
  12266. */
  12267. checkCollisions: boolean;
  12268. /**
  12269. * Enable or disable gravity on the camera.
  12270. */
  12271. applyGravity: boolean;
  12272. /**
  12273. * Define the input manager associated to the camera.
  12274. */
  12275. inputs: FreeCameraInputsManager;
  12276. /**
  12277. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12278. * Higher values reduce sensitivity.
  12279. */
  12280. /**
  12281. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12282. * Higher values reduce sensitivity.
  12283. */
  12284. angularSensibility: number;
  12285. /**
  12286. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12287. */
  12288. keysUp: number[];
  12289. /**
  12290. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12291. */
  12292. keysDown: number[];
  12293. /**
  12294. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12295. */
  12296. keysLeft: number[];
  12297. /**
  12298. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12299. */
  12300. keysRight: number[];
  12301. /**
  12302. * Event raised when the camera collide with a mesh in the scene.
  12303. */
  12304. onCollide: (collidedMesh: AbstractMesh) => void;
  12305. private _collider;
  12306. private _needMoveForGravity;
  12307. private _oldPosition;
  12308. private _diffPosition;
  12309. private _newPosition;
  12310. /** @hidden */
  12311. _localDirection: Vector3;
  12312. /** @hidden */
  12313. _transformedDirection: Vector3;
  12314. /**
  12315. * Instantiates a Free Camera.
  12316. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12317. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12318. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12319. * @param name Define the name of the camera in the scene
  12320. * @param position Define the start position of the camera in the scene
  12321. * @param scene Define the scene the camera belongs to
  12322. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12323. */
  12324. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12325. /**
  12326. * Attached controls to the current camera.
  12327. * @param element Defines the element the controls should be listened from
  12328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12329. */
  12330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12331. /**
  12332. * Detach the current controls from the camera.
  12333. * The camera will stop reacting to inputs.
  12334. * @param element Defines the element to stop listening the inputs from
  12335. */
  12336. detachControl(element: HTMLElement): void;
  12337. private _collisionMask;
  12338. /**
  12339. * Define a collision mask to limit the list of object the camera can collide with
  12340. */
  12341. collisionMask: number;
  12342. /** @hidden */
  12343. _collideWithWorld(displacement: Vector3): void;
  12344. private _onCollisionPositionChange;
  12345. /** @hidden */
  12346. _checkInputs(): void;
  12347. /** @hidden */
  12348. _decideIfNeedsToMove(): boolean;
  12349. /** @hidden */
  12350. _updatePosition(): void;
  12351. /**
  12352. * Destroy the camera and release the current resources hold by it.
  12353. */
  12354. dispose(): void;
  12355. /**
  12356. * Gets the current object class name.
  12357. * @return the class name
  12358. */
  12359. getClassName(): string;
  12360. }
  12361. }
  12362. declare module BABYLON {
  12363. /**
  12364. * Represents a gamepad control stick position
  12365. */
  12366. export class StickValues {
  12367. /**
  12368. * The x component of the control stick
  12369. */
  12370. x: number;
  12371. /**
  12372. * The y component of the control stick
  12373. */
  12374. y: number;
  12375. /**
  12376. * Initializes the gamepad x and y control stick values
  12377. * @param x The x component of the gamepad control stick value
  12378. * @param y The y component of the gamepad control stick value
  12379. */
  12380. constructor(
  12381. /**
  12382. * The x component of the control stick
  12383. */
  12384. x: number,
  12385. /**
  12386. * The y component of the control stick
  12387. */
  12388. y: number);
  12389. }
  12390. /**
  12391. * An interface which manages callbacks for gamepad button changes
  12392. */
  12393. export interface GamepadButtonChanges {
  12394. /**
  12395. * Called when a gamepad has been changed
  12396. */
  12397. changed: boolean;
  12398. /**
  12399. * Called when a gamepad press event has been triggered
  12400. */
  12401. pressChanged: boolean;
  12402. /**
  12403. * Called when a touch event has been triggered
  12404. */
  12405. touchChanged: boolean;
  12406. /**
  12407. * Called when a value has changed
  12408. */
  12409. valueChanged: boolean;
  12410. }
  12411. /**
  12412. * Represents a gamepad
  12413. */
  12414. export class Gamepad {
  12415. /**
  12416. * The id of the gamepad
  12417. */
  12418. id: string;
  12419. /**
  12420. * The index of the gamepad
  12421. */
  12422. index: number;
  12423. /**
  12424. * The browser gamepad
  12425. */
  12426. browserGamepad: any;
  12427. /**
  12428. * Specifies what type of gamepad this represents
  12429. */
  12430. type: number;
  12431. private _leftStick;
  12432. private _rightStick;
  12433. /** @hidden */
  12434. _isConnected: boolean;
  12435. private _leftStickAxisX;
  12436. private _leftStickAxisY;
  12437. private _rightStickAxisX;
  12438. private _rightStickAxisY;
  12439. /**
  12440. * Triggered when the left control stick has been changed
  12441. */
  12442. private _onleftstickchanged;
  12443. /**
  12444. * Triggered when the right control stick has been changed
  12445. */
  12446. private _onrightstickchanged;
  12447. /**
  12448. * Represents a gamepad controller
  12449. */
  12450. static GAMEPAD: number;
  12451. /**
  12452. * Represents a generic controller
  12453. */
  12454. static GENERIC: number;
  12455. /**
  12456. * Represents an XBox controller
  12457. */
  12458. static XBOX: number;
  12459. /**
  12460. * Represents a pose-enabled controller
  12461. */
  12462. static POSE_ENABLED: number;
  12463. /**
  12464. * Specifies whether the left control stick should be Y-inverted
  12465. */
  12466. protected _invertLeftStickY: boolean;
  12467. /**
  12468. * Specifies if the gamepad has been connected
  12469. */
  12470. readonly isConnected: boolean;
  12471. /**
  12472. * Initializes the gamepad
  12473. * @param id The id of the gamepad
  12474. * @param index The index of the gamepad
  12475. * @param browserGamepad The browser gamepad
  12476. * @param leftStickX The x component of the left joystick
  12477. * @param leftStickY The y component of the left joystick
  12478. * @param rightStickX The x component of the right joystick
  12479. * @param rightStickY The y component of the right joystick
  12480. */
  12481. constructor(
  12482. /**
  12483. * The id of the gamepad
  12484. */
  12485. id: string,
  12486. /**
  12487. * The index of the gamepad
  12488. */
  12489. index: number,
  12490. /**
  12491. * The browser gamepad
  12492. */
  12493. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12494. /**
  12495. * Callback triggered when the left joystick has changed
  12496. * @param callback
  12497. */
  12498. onleftstickchanged(callback: (values: StickValues) => void): void;
  12499. /**
  12500. * Callback triggered when the right joystick has changed
  12501. * @param callback
  12502. */
  12503. onrightstickchanged(callback: (values: StickValues) => void): void;
  12504. /**
  12505. * Gets the left joystick
  12506. */
  12507. /**
  12508. * Sets the left joystick values
  12509. */
  12510. leftStick: StickValues;
  12511. /**
  12512. * Gets the right joystick
  12513. */
  12514. /**
  12515. * Sets the right joystick value
  12516. */
  12517. rightStick: StickValues;
  12518. /**
  12519. * Updates the gamepad joystick positions
  12520. */
  12521. update(): void;
  12522. /**
  12523. * Disposes the gamepad
  12524. */
  12525. dispose(): void;
  12526. }
  12527. /**
  12528. * Represents a generic gamepad
  12529. */
  12530. export class GenericPad extends Gamepad {
  12531. private _buttons;
  12532. private _onbuttondown;
  12533. private _onbuttonup;
  12534. /**
  12535. * Observable triggered when a button has been pressed
  12536. */
  12537. onButtonDownObservable: Observable<number>;
  12538. /**
  12539. * Observable triggered when a button has been released
  12540. */
  12541. onButtonUpObservable: Observable<number>;
  12542. /**
  12543. * Callback triggered when a button has been pressed
  12544. * @param callback Called when a button has been pressed
  12545. */
  12546. onbuttondown(callback: (buttonPressed: number) => void): void;
  12547. /**
  12548. * Callback triggered when a button has been released
  12549. * @param callback Called when a button has been released
  12550. */
  12551. onbuttonup(callback: (buttonReleased: number) => void): void;
  12552. /**
  12553. * Initializes the generic gamepad
  12554. * @param id The id of the generic gamepad
  12555. * @param index The index of the generic gamepad
  12556. * @param browserGamepad The browser gamepad
  12557. */
  12558. constructor(id: string, index: number, browserGamepad: any);
  12559. private _setButtonValue;
  12560. /**
  12561. * Updates the generic gamepad
  12562. */
  12563. update(): void;
  12564. /**
  12565. * Disposes the generic gamepad
  12566. */
  12567. dispose(): void;
  12568. }
  12569. }
  12570. declare module BABYLON {
  12571. /**
  12572. * Defines the types of pose enabled controllers that are supported
  12573. */
  12574. export enum PoseEnabledControllerType {
  12575. /**
  12576. * HTC Vive
  12577. */
  12578. VIVE = 0,
  12579. /**
  12580. * Oculus Rift
  12581. */
  12582. OCULUS = 1,
  12583. /**
  12584. * Windows mixed reality
  12585. */
  12586. WINDOWS = 2,
  12587. /**
  12588. * Samsung gear VR
  12589. */
  12590. GEAR_VR = 3,
  12591. /**
  12592. * Google Daydream
  12593. */
  12594. DAYDREAM = 4,
  12595. /**
  12596. * Generic
  12597. */
  12598. GENERIC = 5
  12599. }
  12600. /**
  12601. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12602. */
  12603. export interface MutableGamepadButton {
  12604. /**
  12605. * Value of the button/trigger
  12606. */
  12607. value: number;
  12608. /**
  12609. * If the button/trigger is currently touched
  12610. */
  12611. touched: boolean;
  12612. /**
  12613. * If the button/trigger is currently pressed
  12614. */
  12615. pressed: boolean;
  12616. }
  12617. /**
  12618. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12619. * @hidden
  12620. */
  12621. export interface ExtendedGamepadButton extends GamepadButton {
  12622. /**
  12623. * If the button/trigger is currently pressed
  12624. */
  12625. readonly pressed: boolean;
  12626. /**
  12627. * If the button/trigger is currently touched
  12628. */
  12629. readonly touched: boolean;
  12630. /**
  12631. * Value of the button/trigger
  12632. */
  12633. readonly value: number;
  12634. }
  12635. /** @hidden */
  12636. export interface _GamePadFactory {
  12637. /**
  12638. * Returns wether or not the current gamepad can be created for this type of controller.
  12639. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12640. * @returns true if it can be created, otherwise false
  12641. */
  12642. canCreate(gamepadInfo: any): boolean;
  12643. /**
  12644. * Creates a new instance of the Gamepad.
  12645. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12646. * @returns the new gamepad instance
  12647. */
  12648. create(gamepadInfo: any): Gamepad;
  12649. }
  12650. /**
  12651. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12652. */
  12653. export class PoseEnabledControllerHelper {
  12654. /** @hidden */
  12655. static _ControllerFactories: _GamePadFactory[];
  12656. /** @hidden */
  12657. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12658. /**
  12659. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12660. * @param vrGamepad the gamepad to initialized
  12661. * @returns a vr controller of the type the gamepad identified as
  12662. */
  12663. static InitiateController(vrGamepad: any): Gamepad;
  12664. }
  12665. /**
  12666. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12667. */
  12668. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12669. private _deviceRoomPosition;
  12670. private _deviceRoomRotationQuaternion;
  12671. /**
  12672. * The device position in babylon space
  12673. */
  12674. devicePosition: Vector3;
  12675. /**
  12676. * The device rotation in babylon space
  12677. */
  12678. deviceRotationQuaternion: Quaternion;
  12679. /**
  12680. * The scale factor of the device in babylon space
  12681. */
  12682. deviceScaleFactor: number;
  12683. /**
  12684. * (Likely devicePosition should be used instead) The device position in its room space
  12685. */
  12686. position: Vector3;
  12687. /**
  12688. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12689. */
  12690. rotationQuaternion: Quaternion;
  12691. /**
  12692. * The type of controller (Eg. Windows mixed reality)
  12693. */
  12694. controllerType: PoseEnabledControllerType;
  12695. protected _calculatedPosition: Vector3;
  12696. private _calculatedRotation;
  12697. /**
  12698. * The raw pose from the device
  12699. */
  12700. rawPose: DevicePose;
  12701. private _trackPosition;
  12702. private _maxRotationDistFromHeadset;
  12703. private _draggedRoomRotation;
  12704. /**
  12705. * @hidden
  12706. */
  12707. _disableTrackPosition(fixedPosition: Vector3): void;
  12708. /**
  12709. * Internal, the mesh attached to the controller
  12710. * @hidden
  12711. */
  12712. _mesh: Nullable<AbstractMesh>;
  12713. private _poseControlledCamera;
  12714. private _leftHandSystemQuaternion;
  12715. /**
  12716. * Internal, matrix used to convert room space to babylon space
  12717. * @hidden
  12718. */
  12719. _deviceToWorld: Matrix;
  12720. /**
  12721. * Node to be used when casting a ray from the controller
  12722. * @hidden
  12723. */
  12724. _pointingPoseNode: Nullable<TransformNode>;
  12725. /**
  12726. * Name of the child mesh that can be used to cast a ray from the controller
  12727. */
  12728. static readonly POINTING_POSE: string;
  12729. /**
  12730. * Creates a new PoseEnabledController from a gamepad
  12731. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12732. */
  12733. constructor(browserGamepad: any);
  12734. private _workingMatrix;
  12735. /**
  12736. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12737. */
  12738. update(): void;
  12739. /**
  12740. * Updates only the pose device and mesh without doing any button event checking
  12741. */
  12742. protected _updatePoseAndMesh(): void;
  12743. /**
  12744. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12745. * @param poseData raw pose fromthe device
  12746. */
  12747. updateFromDevice(poseData: DevicePose): void;
  12748. /**
  12749. * @hidden
  12750. */
  12751. _meshAttachedObservable: Observable<AbstractMesh>;
  12752. /**
  12753. * Attaches a mesh to the controller
  12754. * @param mesh the mesh to be attached
  12755. */
  12756. attachToMesh(mesh: AbstractMesh): void;
  12757. /**
  12758. * Attaches the controllers mesh to a camera
  12759. * @param camera the camera the mesh should be attached to
  12760. */
  12761. attachToPoseControlledCamera(camera: TargetCamera): void;
  12762. /**
  12763. * Disposes of the controller
  12764. */
  12765. dispose(): void;
  12766. /**
  12767. * The mesh that is attached to the controller
  12768. */
  12769. readonly mesh: Nullable<AbstractMesh>;
  12770. /**
  12771. * Gets the ray of the controller in the direction the controller is pointing
  12772. * @param length the length the resulting ray should be
  12773. * @returns a ray in the direction the controller is pointing
  12774. */
  12775. getForwardRay(length?: number): Ray;
  12776. }
  12777. }
  12778. declare module BABYLON {
  12779. /**
  12780. * Defines the WebVRController object that represents controllers tracked in 3D space
  12781. */
  12782. export abstract class WebVRController extends PoseEnabledController {
  12783. /**
  12784. * Internal, the default controller model for the controller
  12785. */
  12786. protected _defaultModel: AbstractMesh;
  12787. /**
  12788. * Fired when the trigger state has changed
  12789. */
  12790. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12791. /**
  12792. * Fired when the main button state has changed
  12793. */
  12794. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12795. /**
  12796. * Fired when the secondary button state has changed
  12797. */
  12798. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12799. /**
  12800. * Fired when the pad state has changed
  12801. */
  12802. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12803. /**
  12804. * Fired when controllers stick values have changed
  12805. */
  12806. onPadValuesChangedObservable: Observable<StickValues>;
  12807. /**
  12808. * Array of button availible on the controller
  12809. */
  12810. protected _buttons: Array<MutableGamepadButton>;
  12811. private _onButtonStateChange;
  12812. /**
  12813. * Fired when a controller button's state has changed
  12814. * @param callback the callback containing the button that was modified
  12815. */
  12816. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12817. /**
  12818. * X and Y axis corrisponding to the controllers joystick
  12819. */
  12820. pad: StickValues;
  12821. /**
  12822. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12823. */
  12824. hand: string;
  12825. /**
  12826. * The default controller model for the controller
  12827. */
  12828. readonly defaultModel: AbstractMesh;
  12829. /**
  12830. * Creates a new WebVRController from a gamepad
  12831. * @param vrGamepad the gamepad that the WebVRController should be created from
  12832. */
  12833. constructor(vrGamepad: any);
  12834. /**
  12835. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12836. */
  12837. update(): void;
  12838. /**
  12839. * Function to be called when a button is modified
  12840. */
  12841. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12842. /**
  12843. * Loads a mesh and attaches it to the controller
  12844. * @param scene the scene the mesh should be added to
  12845. * @param meshLoaded callback for when the mesh has been loaded
  12846. */
  12847. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12848. private _setButtonValue;
  12849. private _changes;
  12850. private _checkChanges;
  12851. /**
  12852. * Disposes of th webVRCOntroller
  12853. */
  12854. dispose(): void;
  12855. }
  12856. }
  12857. declare module BABYLON {
  12858. /**
  12859. * The HemisphericLight simulates the ambient environment light,
  12860. * so the passed direction is the light reflection direction, not the incoming direction.
  12861. */
  12862. export class HemisphericLight extends Light {
  12863. /**
  12864. * The groundColor is the light in the opposite direction to the one specified during creation.
  12865. * 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.
  12866. */
  12867. groundColor: Color3;
  12868. /**
  12869. * The light reflection direction, not the incoming direction.
  12870. */
  12871. direction: Vector3;
  12872. /**
  12873. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12874. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12875. * The HemisphericLight can't cast shadows.
  12876. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12877. * @param name The friendly name of the light
  12878. * @param direction The direction of the light reflection
  12879. * @param scene The scene the light belongs to
  12880. */
  12881. constructor(name: string, direction: Vector3, scene: Scene);
  12882. protected _buildUniformLayout(): void;
  12883. /**
  12884. * Returns the string "HemisphericLight".
  12885. * @return The class name
  12886. */
  12887. getClassName(): string;
  12888. /**
  12889. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12890. * Returns the updated direction.
  12891. * @param target The target the direction should point to
  12892. * @return The computed direction
  12893. */
  12894. setDirectionToTarget(target: Vector3): Vector3;
  12895. /**
  12896. * Returns the shadow generator associated to the light.
  12897. * @returns Always null for hemispheric lights because it does not support shadows.
  12898. */
  12899. getShadowGenerator(): Nullable<IShadowGenerator>;
  12900. /**
  12901. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12902. * @param effect The effect to update
  12903. * @param lightIndex The index of the light in the effect to update
  12904. * @returns The hemispheric light
  12905. */
  12906. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12907. /**
  12908. * Computes the world matrix of the node
  12909. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12910. * @param useWasUpdatedFlag defines a reserved property
  12911. * @returns the world matrix
  12912. */
  12913. computeWorldMatrix(): Matrix;
  12914. /**
  12915. * Returns the integer 3.
  12916. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12917. */
  12918. getTypeID(): number;
  12919. /**
  12920. * Prepares the list of defines specific to the light type.
  12921. * @param defines the list of defines
  12922. * @param lightIndex defines the index of the light for the effect
  12923. */
  12924. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12925. }
  12926. }
  12927. declare module BABYLON {
  12928. /** @hidden */
  12929. export var vrMultiviewToSingleviewPixelShader: {
  12930. name: string;
  12931. shader: string;
  12932. };
  12933. }
  12934. declare module BABYLON {
  12935. /**
  12936. * Renders to multiple views with a single draw call
  12937. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12938. */
  12939. export class MultiviewRenderTarget extends RenderTargetTexture {
  12940. /**
  12941. * Creates a multiview render target
  12942. * @param scene scene used with the render target
  12943. * @param size the size of the render target (used for each view)
  12944. */
  12945. constructor(scene: Scene, size?: number | {
  12946. width: number;
  12947. height: number;
  12948. } | {
  12949. ratio: number;
  12950. });
  12951. /**
  12952. * @hidden
  12953. * @param faceIndex the face index, if its a cube texture
  12954. */
  12955. _bindFrameBuffer(faceIndex?: number): void;
  12956. /**
  12957. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12958. * @returns the view count
  12959. */
  12960. getViewCount(): number;
  12961. }
  12962. }
  12963. declare module BABYLON {
  12964. interface Engine {
  12965. /**
  12966. * Creates a new multiview render target
  12967. * @param width defines the width of the texture
  12968. * @param height defines the height of the texture
  12969. * @returns the created multiview texture
  12970. */
  12971. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12972. /**
  12973. * Binds a multiview framebuffer to be drawn to
  12974. * @param multiviewTexture texture to bind
  12975. */
  12976. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12977. }
  12978. interface Camera {
  12979. /**
  12980. * @hidden
  12981. * 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)
  12982. */
  12983. _useMultiviewToSingleView: boolean;
  12984. /**
  12985. * @hidden
  12986. * 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)
  12987. */
  12988. _multiviewTexture: Nullable<RenderTargetTexture>;
  12989. /**
  12990. * @hidden
  12991. * ensures the multiview texture of the camera exists and has the specified width/height
  12992. * @param width height to set on the multiview texture
  12993. * @param height width to set on the multiview texture
  12994. */
  12995. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12996. }
  12997. interface Scene {
  12998. /** @hidden */
  12999. _transformMatrixR: Matrix;
  13000. /** @hidden */
  13001. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13002. /** @hidden */
  13003. _createMultiviewUbo(): void;
  13004. /** @hidden */
  13005. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13006. /** @hidden */
  13007. _renderMultiviewToSingleView(camera: Camera): void;
  13008. }
  13009. }
  13010. declare module BABYLON {
  13011. /**
  13012. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13013. * This will not be used for webXR as it supports displaying texture arrays directly
  13014. */
  13015. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13016. /**
  13017. * Initializes a VRMultiviewToSingleview
  13018. * @param name name of the post process
  13019. * @param camera camera to be applied to
  13020. * @param scaleFactor scaling factor to the size of the output texture
  13021. */
  13022. constructor(name: string, camera: Camera, scaleFactor: number);
  13023. }
  13024. }
  13025. declare module BABYLON {
  13026. /**
  13027. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13028. * IMPORTANT!! The data is right-hand data.
  13029. * @export
  13030. * @interface DevicePose
  13031. */
  13032. export interface DevicePose {
  13033. /**
  13034. * The position of the device, values in array are [x,y,z].
  13035. */
  13036. readonly position: Nullable<Float32Array>;
  13037. /**
  13038. * The linearVelocity of the device, values in array are [x,y,z].
  13039. */
  13040. readonly linearVelocity: Nullable<Float32Array>;
  13041. /**
  13042. * The linearAcceleration of the device, values in array are [x,y,z].
  13043. */
  13044. readonly linearAcceleration: Nullable<Float32Array>;
  13045. /**
  13046. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13047. */
  13048. readonly orientation: Nullable<Float32Array>;
  13049. /**
  13050. * The angularVelocity of the device, values in array are [x,y,z].
  13051. */
  13052. readonly angularVelocity: Nullable<Float32Array>;
  13053. /**
  13054. * The angularAcceleration of the device, values in array are [x,y,z].
  13055. */
  13056. readonly angularAcceleration: Nullable<Float32Array>;
  13057. }
  13058. /**
  13059. * Interface representing a pose controlled object in Babylon.
  13060. * A pose controlled object has both regular pose values as well as pose values
  13061. * from an external device such as a VR head mounted display
  13062. */
  13063. export interface PoseControlled {
  13064. /**
  13065. * The position of the object in babylon space.
  13066. */
  13067. position: Vector3;
  13068. /**
  13069. * The rotation quaternion of the object in babylon space.
  13070. */
  13071. rotationQuaternion: Quaternion;
  13072. /**
  13073. * The position of the device in babylon space.
  13074. */
  13075. devicePosition?: Vector3;
  13076. /**
  13077. * The rotation quaternion of the device in babylon space.
  13078. */
  13079. deviceRotationQuaternion: Quaternion;
  13080. /**
  13081. * The raw pose coming from the device.
  13082. */
  13083. rawPose: Nullable<DevicePose>;
  13084. /**
  13085. * The scale of the device to be used when translating from device space to babylon space.
  13086. */
  13087. deviceScaleFactor: number;
  13088. /**
  13089. * Updates the poseControlled values based on the input device pose.
  13090. * @param poseData the pose data to update the object with
  13091. */
  13092. updateFromDevice(poseData: DevicePose): void;
  13093. }
  13094. /**
  13095. * Set of options to customize the webVRCamera
  13096. */
  13097. export interface WebVROptions {
  13098. /**
  13099. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13100. */
  13101. trackPosition?: boolean;
  13102. /**
  13103. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13104. */
  13105. positionScale?: number;
  13106. /**
  13107. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13108. */
  13109. displayName?: string;
  13110. /**
  13111. * Should the native controller meshes be initialized. (default: true)
  13112. */
  13113. controllerMeshes?: boolean;
  13114. /**
  13115. * Creating a default HemiLight only on controllers. (default: true)
  13116. */
  13117. defaultLightingOnControllers?: boolean;
  13118. /**
  13119. * If you don't want to use the default VR button of the helper. (default: false)
  13120. */
  13121. useCustomVRButton?: boolean;
  13122. /**
  13123. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13124. */
  13125. customVRButton?: HTMLButtonElement;
  13126. /**
  13127. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13128. */
  13129. rayLength?: number;
  13130. /**
  13131. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13132. */
  13133. defaultHeight?: number;
  13134. /**
  13135. * If multiview should be used if availible (default: false)
  13136. */
  13137. useMultiview?: boolean;
  13138. }
  13139. /**
  13140. * This represents a WebVR camera.
  13141. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13142. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13143. */
  13144. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13145. private webVROptions;
  13146. /**
  13147. * @hidden
  13148. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13149. */
  13150. _vrDevice: any;
  13151. /**
  13152. * The rawPose of the vrDevice.
  13153. */
  13154. rawPose: Nullable<DevicePose>;
  13155. private _onVREnabled;
  13156. private _specsVersion;
  13157. private _attached;
  13158. private _frameData;
  13159. protected _descendants: Array<Node>;
  13160. private _deviceRoomPosition;
  13161. /** @hidden */
  13162. _deviceRoomRotationQuaternion: Quaternion;
  13163. private _standingMatrix;
  13164. /**
  13165. * Represents device position in babylon space.
  13166. */
  13167. devicePosition: Vector3;
  13168. /**
  13169. * Represents device rotation in babylon space.
  13170. */
  13171. deviceRotationQuaternion: Quaternion;
  13172. /**
  13173. * The scale of the device to be used when translating from device space to babylon space.
  13174. */
  13175. deviceScaleFactor: number;
  13176. private _deviceToWorld;
  13177. private _worldToDevice;
  13178. /**
  13179. * References to the webVR controllers for the vrDevice.
  13180. */
  13181. controllers: Array<WebVRController>;
  13182. /**
  13183. * Emits an event when a controller is attached.
  13184. */
  13185. onControllersAttachedObservable: Observable<WebVRController[]>;
  13186. /**
  13187. * Emits an event when a controller's mesh has been loaded;
  13188. */
  13189. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13190. /**
  13191. * Emits an event when the HMD's pose has been updated.
  13192. */
  13193. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13194. private _poseSet;
  13195. /**
  13196. * If the rig cameras be used as parent instead of this camera.
  13197. */
  13198. rigParenting: boolean;
  13199. private _lightOnControllers;
  13200. private _defaultHeight?;
  13201. /**
  13202. * Instantiates a WebVRFreeCamera.
  13203. * @param name The name of the WebVRFreeCamera
  13204. * @param position The starting anchor position for the camera
  13205. * @param scene The scene the camera belongs to
  13206. * @param webVROptions a set of customizable options for the webVRCamera
  13207. */
  13208. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13209. /**
  13210. * Gets the device distance from the ground in meters.
  13211. * @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.
  13212. */
  13213. deviceDistanceToRoomGround(): number;
  13214. /**
  13215. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13216. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13217. */
  13218. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13219. /**
  13220. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13221. * @returns A promise with a boolean set to if the standing matrix is supported.
  13222. */
  13223. useStandingMatrixAsync(): Promise<boolean>;
  13224. /**
  13225. * Disposes the camera
  13226. */
  13227. dispose(): void;
  13228. /**
  13229. * Gets a vrController by name.
  13230. * @param name The name of the controller to retreive
  13231. * @returns the controller matching the name specified or null if not found
  13232. */
  13233. getControllerByName(name: string): Nullable<WebVRController>;
  13234. private _leftController;
  13235. /**
  13236. * The controller corrisponding to the users left hand.
  13237. */
  13238. readonly leftController: Nullable<WebVRController>;
  13239. private _rightController;
  13240. /**
  13241. * The controller corrisponding to the users right hand.
  13242. */
  13243. readonly rightController: Nullable<WebVRController>;
  13244. /**
  13245. * Casts a ray forward from the vrCamera's gaze.
  13246. * @param length Length of the ray (default: 100)
  13247. * @returns the ray corrisponding to the gaze
  13248. */
  13249. getForwardRay(length?: number): Ray;
  13250. /**
  13251. * @hidden
  13252. * Updates the camera based on device's frame data
  13253. */
  13254. _checkInputs(): void;
  13255. /**
  13256. * Updates the poseControlled values based on the input device pose.
  13257. * @param poseData Pose coming from the device
  13258. */
  13259. updateFromDevice(poseData: DevicePose): void;
  13260. private _htmlElementAttached;
  13261. private _detachIfAttached;
  13262. /**
  13263. * WebVR's attach control will start broadcasting frames to the device.
  13264. * Note that in certain browsers (chrome for example) this function must be called
  13265. * within a user-interaction callback. Example:
  13266. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13267. *
  13268. * @param element html element to attach the vrDevice to
  13269. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13270. */
  13271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13272. /**
  13273. * Detaches the camera from the html element and disables VR
  13274. *
  13275. * @param element html element to detach from
  13276. */
  13277. detachControl(element: HTMLElement): void;
  13278. /**
  13279. * @returns the name of this class
  13280. */
  13281. getClassName(): string;
  13282. /**
  13283. * Calls resetPose on the vrDisplay
  13284. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13285. */
  13286. resetToCurrentRotation(): void;
  13287. /**
  13288. * @hidden
  13289. * Updates the rig cameras (left and right eye)
  13290. */
  13291. _updateRigCameras(): void;
  13292. private _workingVector;
  13293. private _oneVector;
  13294. private _workingMatrix;
  13295. private updateCacheCalled;
  13296. private _correctPositionIfNotTrackPosition;
  13297. /**
  13298. * @hidden
  13299. * Updates the cached values of the camera
  13300. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13301. */
  13302. _updateCache(ignoreParentClass?: boolean): void;
  13303. /**
  13304. * @hidden
  13305. * Get current device position in babylon world
  13306. */
  13307. _computeDevicePosition(): void;
  13308. /**
  13309. * Updates the current device position and rotation in the babylon world
  13310. */
  13311. update(): void;
  13312. /**
  13313. * @hidden
  13314. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13315. * @returns an identity matrix
  13316. */
  13317. _getViewMatrix(): Matrix;
  13318. private _tmpMatrix;
  13319. /**
  13320. * This function is called by the two RIG cameras.
  13321. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13322. * @hidden
  13323. */
  13324. _getWebVRViewMatrix(): Matrix;
  13325. /** @hidden */
  13326. _getWebVRProjectionMatrix(): Matrix;
  13327. private _onGamepadConnectedObserver;
  13328. private _onGamepadDisconnectedObserver;
  13329. private _updateCacheWhenTrackingDisabledObserver;
  13330. /**
  13331. * Initializes the controllers and their meshes
  13332. */
  13333. initControllers(): void;
  13334. }
  13335. }
  13336. declare module BABYLON {
  13337. /**
  13338. * Size options for a post process
  13339. */
  13340. export type PostProcessOptions = {
  13341. width: number;
  13342. height: number;
  13343. };
  13344. /**
  13345. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13346. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13347. */
  13348. export class PostProcess {
  13349. /** Name of the PostProcess. */
  13350. name: string;
  13351. /**
  13352. * Gets or sets the unique id of the post process
  13353. */
  13354. uniqueId: number;
  13355. /**
  13356. * Width of the texture to apply the post process on
  13357. */
  13358. width: number;
  13359. /**
  13360. * Height of the texture to apply the post process on
  13361. */
  13362. height: number;
  13363. /**
  13364. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13365. * @hidden
  13366. */
  13367. _outputTexture: Nullable<InternalTexture>;
  13368. /**
  13369. * Sampling mode used by the shader
  13370. * See https://doc.babylonjs.com/classes/3.1/texture
  13371. */
  13372. renderTargetSamplingMode: number;
  13373. /**
  13374. * Clear color to use when screen clearing
  13375. */
  13376. clearColor: Color4;
  13377. /**
  13378. * If the buffer needs to be cleared before applying the post process. (default: true)
  13379. * Should be set to false if shader will overwrite all previous pixels.
  13380. */
  13381. autoClear: boolean;
  13382. /**
  13383. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13384. */
  13385. alphaMode: number;
  13386. /**
  13387. * Sets the setAlphaBlendConstants of the babylon engine
  13388. */
  13389. alphaConstants: Color4;
  13390. /**
  13391. * Animations to be used for the post processing
  13392. */
  13393. animations: Animation[];
  13394. /**
  13395. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13396. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13397. */
  13398. enablePixelPerfectMode: boolean;
  13399. /**
  13400. * Force the postprocess to be applied without taking in account viewport
  13401. */
  13402. forceFullscreenViewport: boolean;
  13403. /**
  13404. * List of inspectable custom properties (used by the Inspector)
  13405. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13406. */
  13407. inspectableCustomProperties: IInspectable[];
  13408. /**
  13409. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13410. *
  13411. * | Value | Type | Description |
  13412. * | ----- | ----------------------------------- | ----------- |
  13413. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13414. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13415. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13416. *
  13417. */
  13418. scaleMode: number;
  13419. /**
  13420. * Force textures to be a power of two (default: false)
  13421. */
  13422. alwaysForcePOT: boolean;
  13423. private _samples;
  13424. /**
  13425. * Number of sample textures (default: 1)
  13426. */
  13427. samples: number;
  13428. /**
  13429. * Modify the scale of the post process to be the same as the viewport (default: false)
  13430. */
  13431. adaptScaleToCurrentViewport: boolean;
  13432. private _camera;
  13433. private _scene;
  13434. private _engine;
  13435. private _options;
  13436. private _reusable;
  13437. private _textureType;
  13438. /**
  13439. * Smart array of input and output textures for the post process.
  13440. * @hidden
  13441. */
  13442. _textures: SmartArray<InternalTexture>;
  13443. /**
  13444. * The index in _textures that corresponds to the output texture.
  13445. * @hidden
  13446. */
  13447. _currentRenderTextureInd: number;
  13448. private _effect;
  13449. private _samplers;
  13450. private _fragmentUrl;
  13451. private _vertexUrl;
  13452. private _parameters;
  13453. private _scaleRatio;
  13454. protected _indexParameters: any;
  13455. private _shareOutputWithPostProcess;
  13456. private _texelSize;
  13457. private _forcedOutputTexture;
  13458. /**
  13459. * Returns the fragment url or shader name used in the post process.
  13460. * @returns the fragment url or name in the shader store.
  13461. */
  13462. getEffectName(): string;
  13463. /**
  13464. * An event triggered when the postprocess is activated.
  13465. */
  13466. onActivateObservable: Observable<Camera>;
  13467. private _onActivateObserver;
  13468. /**
  13469. * A function that is added to the onActivateObservable
  13470. */
  13471. onActivate: Nullable<(camera: Camera) => void>;
  13472. /**
  13473. * An event triggered when the postprocess changes its size.
  13474. */
  13475. onSizeChangedObservable: Observable<PostProcess>;
  13476. private _onSizeChangedObserver;
  13477. /**
  13478. * A function that is added to the onSizeChangedObservable
  13479. */
  13480. onSizeChanged: (postProcess: PostProcess) => void;
  13481. /**
  13482. * An event triggered when the postprocess applies its effect.
  13483. */
  13484. onApplyObservable: Observable<Effect>;
  13485. private _onApplyObserver;
  13486. /**
  13487. * A function that is added to the onApplyObservable
  13488. */
  13489. onApply: (effect: Effect) => void;
  13490. /**
  13491. * An event triggered before rendering the postprocess
  13492. */
  13493. onBeforeRenderObservable: Observable<Effect>;
  13494. private _onBeforeRenderObserver;
  13495. /**
  13496. * A function that is added to the onBeforeRenderObservable
  13497. */
  13498. onBeforeRender: (effect: Effect) => void;
  13499. /**
  13500. * An event triggered after rendering the postprocess
  13501. */
  13502. onAfterRenderObservable: Observable<Effect>;
  13503. private _onAfterRenderObserver;
  13504. /**
  13505. * A function that is added to the onAfterRenderObservable
  13506. */
  13507. onAfterRender: (efect: Effect) => void;
  13508. /**
  13509. * 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
  13510. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13511. */
  13512. inputTexture: InternalTexture;
  13513. /**
  13514. * Gets the camera which post process is applied to.
  13515. * @returns The camera the post process is applied to.
  13516. */
  13517. getCamera(): Camera;
  13518. /**
  13519. * Gets the texel size of the postprocess.
  13520. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13521. */
  13522. readonly texelSize: Vector2;
  13523. /**
  13524. * Creates a new instance PostProcess
  13525. * @param name The name of the PostProcess.
  13526. * @param fragmentUrl The url of the fragment shader to be used.
  13527. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13528. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13529. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13530. * @param camera The camera to apply the render pass to.
  13531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13532. * @param engine The engine which the post process will be applied. (default: current engine)
  13533. * @param reusable If the post process can be reused on the same frame. (default: false)
  13534. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13535. * @param textureType Type of textures used when performing the post process. (default: 0)
  13536. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13537. * @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
  13538. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13539. */
  13540. constructor(
  13541. /** Name of the PostProcess. */
  13542. 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);
  13543. /**
  13544. * Gets a string idenfifying the name of the class
  13545. * @returns "PostProcess" string
  13546. */
  13547. getClassName(): string;
  13548. /**
  13549. * Gets the engine which this post process belongs to.
  13550. * @returns The engine the post process was enabled with.
  13551. */
  13552. getEngine(): Engine;
  13553. /**
  13554. * The effect that is created when initializing the post process.
  13555. * @returns The created effect corrisponding the the postprocess.
  13556. */
  13557. getEffect(): Effect;
  13558. /**
  13559. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13560. * @param postProcess The post process to share the output with.
  13561. * @returns This post process.
  13562. */
  13563. shareOutputWith(postProcess: PostProcess): PostProcess;
  13564. /**
  13565. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13566. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13567. */
  13568. useOwnOutput(): void;
  13569. /**
  13570. * Updates the effect with the current post process compile time values and recompiles the shader.
  13571. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13572. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13573. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13574. * @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
  13575. * @param onCompiled Called when the shader has been compiled.
  13576. * @param onError Called if there is an error when compiling a shader.
  13577. */
  13578. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13579. /**
  13580. * The post process is reusable if it can be used multiple times within one frame.
  13581. * @returns If the post process is reusable
  13582. */
  13583. isReusable(): boolean;
  13584. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13585. markTextureDirty(): void;
  13586. /**
  13587. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13588. * 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.
  13589. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13590. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13591. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13592. * @returns The target texture that was bound to be written to.
  13593. */
  13594. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13595. /**
  13596. * If the post process is supported.
  13597. */
  13598. readonly isSupported: boolean;
  13599. /**
  13600. * The aspect ratio of the output texture.
  13601. */
  13602. readonly aspectRatio: number;
  13603. /**
  13604. * Get a value indicating if the post-process is ready to be used
  13605. * @returns true if the post-process is ready (shader is compiled)
  13606. */
  13607. isReady(): boolean;
  13608. /**
  13609. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13610. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13611. */
  13612. apply(): Nullable<Effect>;
  13613. private _disposeTextures;
  13614. /**
  13615. * Disposes the post process.
  13616. * @param camera The camera to dispose the post process on.
  13617. */
  13618. dispose(camera?: Camera): void;
  13619. }
  13620. }
  13621. declare module BABYLON {
  13622. /**
  13623. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13624. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13625. */
  13626. export class PostProcessManager {
  13627. private _scene;
  13628. private _indexBuffer;
  13629. private _vertexBuffers;
  13630. /**
  13631. * Creates a new instance PostProcess
  13632. * @param scene The scene that the post process is associated with.
  13633. */
  13634. constructor(scene: Scene);
  13635. private _prepareBuffers;
  13636. private _buildIndexBuffer;
  13637. /**
  13638. * Rebuilds the vertex buffers of the manager.
  13639. * @hidden
  13640. */
  13641. _rebuild(): void;
  13642. /**
  13643. * Prepares a frame to be run through a post process.
  13644. * @param sourceTexture The input texture to the post procesess. (default: null)
  13645. * @param postProcesses An array of post processes to be run. (default: null)
  13646. * @returns True if the post processes were able to be run.
  13647. * @hidden
  13648. */
  13649. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13650. /**
  13651. * Manually render a set of post processes to a texture.
  13652. * @param postProcesses An array of post processes to be run.
  13653. * @param targetTexture The target texture to render to.
  13654. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13655. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13656. * @param lodLevel defines which lod of the texture to render to
  13657. */
  13658. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13659. /**
  13660. * Finalize the result of the output of the postprocesses.
  13661. * @param doNotPresent If true the result will not be displayed to the screen.
  13662. * @param targetTexture The target texture to render to.
  13663. * @param faceIndex The index of the face to bind the target texture to.
  13664. * @param postProcesses The array of post processes to render.
  13665. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13666. * @hidden
  13667. */
  13668. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13669. /**
  13670. * Disposes of the post process manager.
  13671. */
  13672. dispose(): void;
  13673. }
  13674. }
  13675. declare module BABYLON {
  13676. interface AbstractScene {
  13677. /**
  13678. * The list of layers (background and foreground) of the scene
  13679. */
  13680. layers: Array<Layer>;
  13681. }
  13682. /**
  13683. * Defines the layer scene component responsible to manage any layers
  13684. * in a given scene.
  13685. */
  13686. export class LayerSceneComponent implements ISceneComponent {
  13687. /**
  13688. * The component name helpfull to identify the component in the list of scene components.
  13689. */
  13690. readonly name: string;
  13691. /**
  13692. * The scene the component belongs to.
  13693. */
  13694. scene: Scene;
  13695. private _engine;
  13696. /**
  13697. * Creates a new instance of the component for the given scene
  13698. * @param scene Defines the scene to register the component in
  13699. */
  13700. constructor(scene: Scene);
  13701. /**
  13702. * Registers the component in a given scene
  13703. */
  13704. register(): void;
  13705. /**
  13706. * Rebuilds the elements related to this component in case of
  13707. * context lost for instance.
  13708. */
  13709. rebuild(): void;
  13710. /**
  13711. * Disposes the component and the associated ressources.
  13712. */
  13713. dispose(): void;
  13714. private _draw;
  13715. private _drawCameraPredicate;
  13716. private _drawCameraBackground;
  13717. private _drawCameraForeground;
  13718. private _drawRenderTargetPredicate;
  13719. private _drawRenderTargetBackground;
  13720. private _drawRenderTargetForeground;
  13721. }
  13722. }
  13723. declare module BABYLON {
  13724. /** @hidden */
  13725. export var layerPixelShader: {
  13726. name: string;
  13727. shader: string;
  13728. };
  13729. }
  13730. declare module BABYLON {
  13731. /** @hidden */
  13732. export var layerVertexShader: {
  13733. name: string;
  13734. shader: string;
  13735. };
  13736. }
  13737. declare module BABYLON {
  13738. /**
  13739. * This represents a full screen 2d layer.
  13740. * This can be useful to display a picture in the background of your scene for instance.
  13741. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13742. */
  13743. export class Layer {
  13744. /**
  13745. * Define the name of the layer.
  13746. */
  13747. name: string;
  13748. /**
  13749. * Define the texture the layer should display.
  13750. */
  13751. texture: Nullable<Texture>;
  13752. /**
  13753. * Is the layer in background or foreground.
  13754. */
  13755. isBackground: boolean;
  13756. /**
  13757. * Define the color of the layer (instead of texture).
  13758. */
  13759. color: Color4;
  13760. /**
  13761. * Define the scale of the layer in order to zoom in out of the texture.
  13762. */
  13763. scale: Vector2;
  13764. /**
  13765. * Define an offset for the layer in order to shift the texture.
  13766. */
  13767. offset: Vector2;
  13768. /**
  13769. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13770. */
  13771. alphaBlendingMode: number;
  13772. /**
  13773. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13774. * Alpha test will not mix with the background color in case of transparency.
  13775. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13776. */
  13777. alphaTest: boolean;
  13778. /**
  13779. * Define a mask to restrict the layer to only some of the scene cameras.
  13780. */
  13781. layerMask: number;
  13782. /**
  13783. * Define the list of render target the layer is visible into.
  13784. */
  13785. renderTargetTextures: RenderTargetTexture[];
  13786. /**
  13787. * Define if the layer is only used in renderTarget or if it also
  13788. * renders in the main frame buffer of the canvas.
  13789. */
  13790. renderOnlyInRenderTargetTextures: boolean;
  13791. private _scene;
  13792. private _vertexBuffers;
  13793. private _indexBuffer;
  13794. private _effect;
  13795. private _alphaTestEffect;
  13796. /**
  13797. * An event triggered when the layer is disposed.
  13798. */
  13799. onDisposeObservable: Observable<Layer>;
  13800. private _onDisposeObserver;
  13801. /**
  13802. * Back compatibility with callback before the onDisposeObservable existed.
  13803. * The set callback will be triggered when the layer has been disposed.
  13804. */
  13805. onDispose: () => void;
  13806. /**
  13807. * An event triggered before rendering the scene
  13808. */
  13809. onBeforeRenderObservable: Observable<Layer>;
  13810. private _onBeforeRenderObserver;
  13811. /**
  13812. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13813. * The set callback will be triggered just before rendering the layer.
  13814. */
  13815. onBeforeRender: () => void;
  13816. /**
  13817. * An event triggered after rendering the scene
  13818. */
  13819. onAfterRenderObservable: Observable<Layer>;
  13820. private _onAfterRenderObserver;
  13821. /**
  13822. * Back compatibility with callback before the onAfterRenderObservable existed.
  13823. * The set callback will be triggered just after rendering the layer.
  13824. */
  13825. onAfterRender: () => void;
  13826. /**
  13827. * Instantiates a new layer.
  13828. * This represents a full screen 2d layer.
  13829. * This can be useful to display a picture in the background of your scene for instance.
  13830. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13831. * @param name Define the name of the layer in the scene
  13832. * @param imgUrl Define the url of the texture to display in the layer
  13833. * @param scene Define the scene the layer belongs to
  13834. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13835. * @param color Defines a color for the layer
  13836. */
  13837. constructor(
  13838. /**
  13839. * Define the name of the layer.
  13840. */
  13841. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13842. private _createIndexBuffer;
  13843. /** @hidden */
  13844. _rebuild(): void;
  13845. /**
  13846. * Renders the layer in the scene.
  13847. */
  13848. render(): void;
  13849. /**
  13850. * Disposes and releases the associated ressources.
  13851. */
  13852. dispose(): void;
  13853. }
  13854. }
  13855. declare module BABYLON {
  13856. interface AbstractScene {
  13857. /**
  13858. * The list of procedural textures added to the scene
  13859. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13860. */
  13861. proceduralTextures: Array<ProceduralTexture>;
  13862. }
  13863. /**
  13864. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13865. * in a given scene.
  13866. */
  13867. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13868. /**
  13869. * The component name helpfull to identify the component in the list of scene components.
  13870. */
  13871. readonly name: string;
  13872. /**
  13873. * The scene the component belongs to.
  13874. */
  13875. scene: Scene;
  13876. /**
  13877. * Creates a new instance of the component for the given scene
  13878. * @param scene Defines the scene to register the component in
  13879. */
  13880. constructor(scene: Scene);
  13881. /**
  13882. * Registers the component in a given scene
  13883. */
  13884. register(): void;
  13885. /**
  13886. * Rebuilds the elements related to this component in case of
  13887. * context lost for instance.
  13888. */
  13889. rebuild(): void;
  13890. /**
  13891. * Disposes the component and the associated ressources.
  13892. */
  13893. dispose(): void;
  13894. private _beforeClear;
  13895. }
  13896. }
  13897. declare module BABYLON {
  13898. /** @hidden */
  13899. export var proceduralVertexShader: {
  13900. name: string;
  13901. shader: string;
  13902. };
  13903. }
  13904. declare module BABYLON {
  13905. /**
  13906. * 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.
  13907. * This is the base class of any Procedural texture and contains most of the shareable code.
  13908. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13909. */
  13910. export class ProceduralTexture extends Texture {
  13911. isCube: boolean;
  13912. /**
  13913. * Define if the texture is enabled or not (disabled texture will not render)
  13914. */
  13915. isEnabled: boolean;
  13916. /**
  13917. * Define if the texture must be cleared before rendering (default is true)
  13918. */
  13919. autoClear: boolean;
  13920. /**
  13921. * Callback called when the texture is generated
  13922. */
  13923. onGenerated: () => void;
  13924. /**
  13925. * Event raised when the texture is generated
  13926. */
  13927. onGeneratedObservable: Observable<ProceduralTexture>;
  13928. /** @hidden */
  13929. _generateMipMaps: boolean;
  13930. /** @hidden **/
  13931. _effect: Effect;
  13932. /** @hidden */
  13933. _textures: {
  13934. [key: string]: Texture;
  13935. };
  13936. private _size;
  13937. private _currentRefreshId;
  13938. private _refreshRate;
  13939. private _vertexBuffers;
  13940. private _indexBuffer;
  13941. private _uniforms;
  13942. private _samplers;
  13943. private _fragment;
  13944. private _floats;
  13945. private _ints;
  13946. private _floatsArrays;
  13947. private _colors3;
  13948. private _colors4;
  13949. private _vectors2;
  13950. private _vectors3;
  13951. private _matrices;
  13952. private _fallbackTexture;
  13953. private _fallbackTextureUsed;
  13954. private _engine;
  13955. private _cachedDefines;
  13956. private _contentUpdateId;
  13957. private _contentData;
  13958. /**
  13959. * Instantiates a new procedural texture.
  13960. * 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.
  13961. * This is the base class of any Procedural texture and contains most of the shareable code.
  13962. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13963. * @param name Define the name of the texture
  13964. * @param size Define the size of the texture to create
  13965. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13966. * @param scene Define the scene the texture belongs to
  13967. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13968. * @param generateMipMaps Define if the texture should creates mip maps or not
  13969. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13970. */
  13971. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13972. /**
  13973. * The effect that is created when initializing the post process.
  13974. * @returns The created effect corrisponding the the postprocess.
  13975. */
  13976. getEffect(): Effect;
  13977. /**
  13978. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13979. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13980. */
  13981. getContent(): Nullable<ArrayBufferView>;
  13982. private _createIndexBuffer;
  13983. /** @hidden */
  13984. _rebuild(): void;
  13985. /**
  13986. * Resets the texture in order to recreate its associated resources.
  13987. * This can be called in case of context loss
  13988. */
  13989. reset(): void;
  13990. protected _getDefines(): string;
  13991. /**
  13992. * Is the texture ready to be used ? (rendered at least once)
  13993. * @returns true if ready, otherwise, false.
  13994. */
  13995. isReady(): boolean;
  13996. /**
  13997. * Resets the refresh counter of the texture and start bak from scratch.
  13998. * Could be useful to regenerate the texture if it is setup to render only once.
  13999. */
  14000. resetRefreshCounter(): void;
  14001. /**
  14002. * Set the fragment shader to use in order to render the texture.
  14003. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14004. */
  14005. setFragment(fragment: any): void;
  14006. /**
  14007. * Define the refresh rate of the texture or the rendering frequency.
  14008. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14009. */
  14010. refreshRate: number;
  14011. /** @hidden */
  14012. _shouldRender(): boolean;
  14013. /**
  14014. * Get the size the texture is rendering at.
  14015. * @returns the size (texture is always squared)
  14016. */
  14017. getRenderSize(): number;
  14018. /**
  14019. * Resize the texture to new value.
  14020. * @param size Define the new size the texture should have
  14021. * @param generateMipMaps Define whether the new texture should create mip maps
  14022. */
  14023. resize(size: number, generateMipMaps: boolean): void;
  14024. private _checkUniform;
  14025. /**
  14026. * Set a texture in the shader program used to render.
  14027. * @param name Define the name of the uniform samplers as defined in the shader
  14028. * @param texture Define the texture to bind to this sampler
  14029. * @return the texture itself allowing "fluent" like uniform updates
  14030. */
  14031. setTexture(name: string, texture: Texture): ProceduralTexture;
  14032. /**
  14033. * Set a float in the shader.
  14034. * @param name Define the name of the uniform as defined in the shader
  14035. * @param value Define the value to give to the uniform
  14036. * @return the texture itself allowing "fluent" like uniform updates
  14037. */
  14038. setFloat(name: string, value: number): ProceduralTexture;
  14039. /**
  14040. * Set a int in the shader.
  14041. * @param name Define the name of the uniform as defined in the shader
  14042. * @param value Define the value to give to the uniform
  14043. * @return the texture itself allowing "fluent" like uniform updates
  14044. */
  14045. setInt(name: string, value: number): ProceduralTexture;
  14046. /**
  14047. * Set an array of floats in the shader.
  14048. * @param name Define the name of the uniform as defined in the shader
  14049. * @param value Define the value to give to the uniform
  14050. * @return the texture itself allowing "fluent" like uniform updates
  14051. */
  14052. setFloats(name: string, value: number[]): ProceduralTexture;
  14053. /**
  14054. * Set a vec3 in the shader from a Color3.
  14055. * @param name Define the name of the uniform as defined in the shader
  14056. * @param value Define the value to give to the uniform
  14057. * @return the texture itself allowing "fluent" like uniform updates
  14058. */
  14059. setColor3(name: string, value: Color3): ProceduralTexture;
  14060. /**
  14061. * Set a vec4 in the shader from a Color4.
  14062. * @param name Define the name of the uniform as defined in the shader
  14063. * @param value Define the value to give to the uniform
  14064. * @return the texture itself allowing "fluent" like uniform updates
  14065. */
  14066. setColor4(name: string, value: Color4): ProceduralTexture;
  14067. /**
  14068. * Set a vec2 in the shader from a Vector2.
  14069. * @param name Define the name of the uniform as defined in the shader
  14070. * @param value Define the value to give to the uniform
  14071. * @return the texture itself allowing "fluent" like uniform updates
  14072. */
  14073. setVector2(name: string, value: Vector2): ProceduralTexture;
  14074. /**
  14075. * Set a vec3 in the shader from a Vector3.
  14076. * @param name Define the name of the uniform as defined in the shader
  14077. * @param value Define the value to give to the uniform
  14078. * @return the texture itself allowing "fluent" like uniform updates
  14079. */
  14080. setVector3(name: string, value: Vector3): ProceduralTexture;
  14081. /**
  14082. * Set a mat4 in the shader from a MAtrix.
  14083. * @param name Define the name of the uniform as defined in the shader
  14084. * @param value Define the value to give to the uniform
  14085. * @return the texture itself allowing "fluent" like uniform updates
  14086. */
  14087. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14088. /**
  14089. * Render the texture to its associated render target.
  14090. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14091. */
  14092. render(useCameraPostProcess?: boolean): void;
  14093. /**
  14094. * Clone the texture.
  14095. * @returns the cloned texture
  14096. */
  14097. clone(): ProceduralTexture;
  14098. /**
  14099. * Dispose the texture and release its asoociated resources.
  14100. */
  14101. dispose(): void;
  14102. }
  14103. }
  14104. declare module BABYLON {
  14105. /**
  14106. * This represents the base class for particle system in Babylon.
  14107. * 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.
  14108. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14109. * @example https://doc.babylonjs.com/babylon101/particles
  14110. */
  14111. export class BaseParticleSystem {
  14112. /**
  14113. * Source color is added to the destination color without alpha affecting the result
  14114. */
  14115. static BLENDMODE_ONEONE: number;
  14116. /**
  14117. * Blend current color and particle color using particle’s alpha
  14118. */
  14119. static BLENDMODE_STANDARD: number;
  14120. /**
  14121. * Add current color and particle color multiplied by particle’s alpha
  14122. */
  14123. static BLENDMODE_ADD: number;
  14124. /**
  14125. * Multiply current color with particle color
  14126. */
  14127. static BLENDMODE_MULTIPLY: number;
  14128. /**
  14129. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14130. */
  14131. static BLENDMODE_MULTIPLYADD: number;
  14132. /**
  14133. * List of animations used by the particle system.
  14134. */
  14135. animations: Animation[];
  14136. /**
  14137. * The id of the Particle system.
  14138. */
  14139. id: string;
  14140. /**
  14141. * The friendly name of the Particle system.
  14142. */
  14143. name: string;
  14144. /**
  14145. * The rendering group used by the Particle system to chose when to render.
  14146. */
  14147. renderingGroupId: number;
  14148. /**
  14149. * The emitter represents the Mesh or position we are attaching the particle system to.
  14150. */
  14151. emitter: Nullable<AbstractMesh | Vector3>;
  14152. /**
  14153. * The maximum number of particles to emit per frame
  14154. */
  14155. emitRate: number;
  14156. /**
  14157. * If you want to launch only a few particles at once, that can be done, as well.
  14158. */
  14159. manualEmitCount: number;
  14160. /**
  14161. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14162. */
  14163. updateSpeed: number;
  14164. /**
  14165. * The amount of time the particle system is running (depends of the overall update speed).
  14166. */
  14167. targetStopDuration: number;
  14168. /**
  14169. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14170. */
  14171. disposeOnStop: boolean;
  14172. /**
  14173. * Minimum power of emitting particles.
  14174. */
  14175. minEmitPower: number;
  14176. /**
  14177. * Maximum power of emitting particles.
  14178. */
  14179. maxEmitPower: number;
  14180. /**
  14181. * Minimum life time of emitting particles.
  14182. */
  14183. minLifeTime: number;
  14184. /**
  14185. * Maximum life time of emitting particles.
  14186. */
  14187. maxLifeTime: number;
  14188. /**
  14189. * Minimum Size of emitting particles.
  14190. */
  14191. minSize: number;
  14192. /**
  14193. * Maximum Size of emitting particles.
  14194. */
  14195. maxSize: number;
  14196. /**
  14197. * Minimum scale of emitting particles on X axis.
  14198. */
  14199. minScaleX: number;
  14200. /**
  14201. * Maximum scale of emitting particles on X axis.
  14202. */
  14203. maxScaleX: number;
  14204. /**
  14205. * Minimum scale of emitting particles on Y axis.
  14206. */
  14207. minScaleY: number;
  14208. /**
  14209. * Maximum scale of emitting particles on Y axis.
  14210. */
  14211. maxScaleY: number;
  14212. /**
  14213. * Gets or sets the minimal initial rotation in radians.
  14214. */
  14215. minInitialRotation: number;
  14216. /**
  14217. * Gets or sets the maximal initial rotation in radians.
  14218. */
  14219. maxInitialRotation: number;
  14220. /**
  14221. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14222. */
  14223. minAngularSpeed: number;
  14224. /**
  14225. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14226. */
  14227. maxAngularSpeed: number;
  14228. /**
  14229. * The texture used to render each particle. (this can be a spritesheet)
  14230. */
  14231. particleTexture: Nullable<Texture>;
  14232. /**
  14233. * The layer mask we are rendering the particles through.
  14234. */
  14235. layerMask: number;
  14236. /**
  14237. * This can help using your own shader to render the particle system.
  14238. * The according effect will be created
  14239. */
  14240. customShader: any;
  14241. /**
  14242. * By default particle system starts as soon as they are created. This prevents the
  14243. * automatic start to happen and let you decide when to start emitting particles.
  14244. */
  14245. preventAutoStart: boolean;
  14246. private _noiseTexture;
  14247. /**
  14248. * Gets or sets a texture used to add random noise to particle positions
  14249. */
  14250. noiseTexture: Nullable<ProceduralTexture>;
  14251. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14252. noiseStrength: Vector3;
  14253. /**
  14254. * Callback triggered when the particle animation is ending.
  14255. */
  14256. onAnimationEnd: Nullable<() => void>;
  14257. /**
  14258. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14259. */
  14260. blendMode: number;
  14261. /**
  14262. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14263. * to override the particles.
  14264. */
  14265. forceDepthWrite: boolean;
  14266. /** 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 */
  14267. preWarmCycles: number;
  14268. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14269. preWarmStepOffset: number;
  14270. /**
  14271. * 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)
  14272. */
  14273. spriteCellChangeSpeed: number;
  14274. /**
  14275. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14276. */
  14277. startSpriteCellID: number;
  14278. /**
  14279. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14280. */
  14281. endSpriteCellID: number;
  14282. /**
  14283. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14284. */
  14285. spriteCellWidth: number;
  14286. /**
  14287. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14288. */
  14289. spriteCellHeight: number;
  14290. /**
  14291. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14292. */
  14293. spriteRandomStartCell: boolean;
  14294. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14295. translationPivot: Vector2;
  14296. /** @hidden */
  14297. protected _isAnimationSheetEnabled: boolean;
  14298. /**
  14299. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14300. */
  14301. beginAnimationOnStart: boolean;
  14302. /**
  14303. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14304. */
  14305. beginAnimationFrom: number;
  14306. /**
  14307. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14308. */
  14309. beginAnimationTo: number;
  14310. /**
  14311. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14312. */
  14313. beginAnimationLoop: boolean;
  14314. /**
  14315. * Gets or sets a world offset applied to all particles
  14316. */
  14317. worldOffset: Vector3;
  14318. /**
  14319. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14320. */
  14321. isAnimationSheetEnabled: boolean;
  14322. /**
  14323. * Get hosting scene
  14324. * @returns the scene
  14325. */
  14326. getScene(): Scene;
  14327. /**
  14328. * You can use gravity if you want to give an orientation to your particles.
  14329. */
  14330. gravity: Vector3;
  14331. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14332. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14333. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14334. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14335. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14336. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14337. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14338. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14339. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14340. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14341. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14342. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14343. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14344. /**
  14345. * Defines the delay in milliseconds before starting the system (0 by default)
  14346. */
  14347. startDelay: number;
  14348. /**
  14349. * Gets the current list of drag gradients.
  14350. * You must use addDragGradient and removeDragGradient to udpate this list
  14351. * @returns the list of drag gradients
  14352. */
  14353. getDragGradients(): Nullable<Array<FactorGradient>>;
  14354. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14355. limitVelocityDamping: number;
  14356. /**
  14357. * Gets the current list of limit velocity gradients.
  14358. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14359. * @returns the list of limit velocity gradients
  14360. */
  14361. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14362. /**
  14363. * Gets the current list of color gradients.
  14364. * You must use addColorGradient and removeColorGradient to udpate this list
  14365. * @returns the list of color gradients
  14366. */
  14367. getColorGradients(): Nullable<Array<ColorGradient>>;
  14368. /**
  14369. * Gets the current list of size gradients.
  14370. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14371. * @returns the list of size gradients
  14372. */
  14373. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14374. /**
  14375. * Gets the current list of color remap gradients.
  14376. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14377. * @returns the list of color remap gradients
  14378. */
  14379. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14380. /**
  14381. * Gets the current list of alpha remap gradients.
  14382. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14383. * @returns the list of alpha remap gradients
  14384. */
  14385. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14386. /**
  14387. * Gets the current list of life time gradients.
  14388. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14389. * @returns the list of life time gradients
  14390. */
  14391. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14392. /**
  14393. * Gets the current list of angular speed gradients.
  14394. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14395. * @returns the list of angular speed gradients
  14396. */
  14397. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14398. /**
  14399. * Gets the current list of velocity gradients.
  14400. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14401. * @returns the list of velocity gradients
  14402. */
  14403. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14404. /**
  14405. * Gets the current list of start size gradients.
  14406. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14407. * @returns the list of start size gradients
  14408. */
  14409. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14410. /**
  14411. * Gets the current list of emit rate gradients.
  14412. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14413. * @returns the list of emit rate gradients
  14414. */
  14415. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14416. /**
  14417. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14418. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14419. */
  14420. direction1: Vector3;
  14421. /**
  14422. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14423. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14424. */
  14425. direction2: Vector3;
  14426. /**
  14427. * 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.
  14428. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14429. */
  14430. minEmitBox: Vector3;
  14431. /**
  14432. * 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.
  14433. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14434. */
  14435. maxEmitBox: Vector3;
  14436. /**
  14437. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14438. */
  14439. color1: Color4;
  14440. /**
  14441. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14442. */
  14443. color2: Color4;
  14444. /**
  14445. * Color the particle will have at the end of its lifetime
  14446. */
  14447. colorDead: Color4;
  14448. /**
  14449. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14450. */
  14451. textureMask: Color4;
  14452. /**
  14453. * The particle emitter type defines the emitter used by the particle system.
  14454. * It can be for example box, sphere, or cone...
  14455. */
  14456. particleEmitterType: IParticleEmitterType;
  14457. /** @hidden */
  14458. _isSubEmitter: boolean;
  14459. /**
  14460. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14461. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14462. */
  14463. billboardMode: number;
  14464. protected _isBillboardBased: boolean;
  14465. /**
  14466. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14467. */
  14468. isBillboardBased: boolean;
  14469. /**
  14470. * The scene the particle system belongs to.
  14471. */
  14472. protected _scene: Scene;
  14473. /**
  14474. * Local cache of defines for image processing.
  14475. */
  14476. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14477. /**
  14478. * Default configuration related to image processing available in the standard Material.
  14479. */
  14480. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14481. /**
  14482. * Gets the image processing configuration used either in this material.
  14483. */
  14484. /**
  14485. * Sets the Default image processing configuration used either in the this material.
  14486. *
  14487. * If sets to null, the scene one is in use.
  14488. */
  14489. imageProcessingConfiguration: ImageProcessingConfiguration;
  14490. /**
  14491. * Attaches a new image processing configuration to the Standard Material.
  14492. * @param configuration
  14493. */
  14494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14495. /** @hidden */
  14496. protected _reset(): void;
  14497. /** @hidden */
  14498. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14499. /**
  14500. * Instantiates a particle system.
  14501. * 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.
  14502. * @param name The name of the particle system
  14503. */
  14504. constructor(name: string);
  14505. /**
  14506. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14509. * @returns the emitter
  14510. */
  14511. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14512. /**
  14513. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14514. * @param radius The radius of the hemisphere to emit from
  14515. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14516. * @returns the emitter
  14517. */
  14518. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14519. /**
  14520. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14521. * @param radius The radius of the sphere to emit from
  14522. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14523. * @returns the emitter
  14524. */
  14525. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14526. /**
  14527. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14528. * @param radius The radius of the sphere to emit from
  14529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14531. * @returns the emitter
  14532. */
  14533. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14534. /**
  14535. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14536. * @param radius The radius of the emission cylinder
  14537. * @param height The height of the emission cylinder
  14538. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14539. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14540. * @returns the emitter
  14541. */
  14542. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14543. /**
  14544. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14545. * @param radius The radius of the cylinder to emit from
  14546. * @param height The height of the emission cylinder
  14547. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14550. * @returns the emitter
  14551. */
  14552. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14553. /**
  14554. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14555. * @param radius The radius of the cone to emit from
  14556. * @param angle The base angle of the cone
  14557. * @returns the emitter
  14558. */
  14559. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14560. /**
  14561. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14564. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14565. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14566. * @returns the emitter
  14567. */
  14568. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14569. }
  14570. }
  14571. declare module BABYLON {
  14572. /**
  14573. * Type of sub emitter
  14574. */
  14575. export enum SubEmitterType {
  14576. /**
  14577. * Attached to the particle over it's lifetime
  14578. */
  14579. ATTACHED = 0,
  14580. /**
  14581. * Created when the particle dies
  14582. */
  14583. END = 1
  14584. }
  14585. /**
  14586. * Sub emitter class used to emit particles from an existing particle
  14587. */
  14588. export class SubEmitter {
  14589. /**
  14590. * the particle system to be used by the sub emitter
  14591. */
  14592. particleSystem: ParticleSystem;
  14593. /**
  14594. * Type of the submitter (Default: END)
  14595. */
  14596. type: SubEmitterType;
  14597. /**
  14598. * 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)
  14599. * Note: This only is supported when using an emitter of type Mesh
  14600. */
  14601. inheritDirection: boolean;
  14602. /**
  14603. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14604. */
  14605. inheritedVelocityAmount: number;
  14606. /**
  14607. * Creates a sub emitter
  14608. * @param particleSystem the particle system to be used by the sub emitter
  14609. */
  14610. constructor(
  14611. /**
  14612. * the particle system to be used by the sub emitter
  14613. */
  14614. particleSystem: ParticleSystem);
  14615. /**
  14616. * Clones the sub emitter
  14617. * @returns the cloned sub emitter
  14618. */
  14619. clone(): SubEmitter;
  14620. /**
  14621. * Serialize current object to a JSON object
  14622. * @returns the serialized object
  14623. */
  14624. serialize(): any;
  14625. /** @hidden */
  14626. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14627. /**
  14628. * Creates a new SubEmitter from a serialized JSON version
  14629. * @param serializationObject defines the JSON object to read from
  14630. * @param scene defines the hosting scene
  14631. * @param rootUrl defines the rootUrl for data loading
  14632. * @returns a new SubEmitter
  14633. */
  14634. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14635. /** Release associated resources */
  14636. dispose(): void;
  14637. }
  14638. }
  14639. declare module BABYLON {
  14640. /** @hidden */
  14641. export var clipPlaneFragmentDeclaration: {
  14642. name: string;
  14643. shader: string;
  14644. };
  14645. }
  14646. declare module BABYLON {
  14647. /** @hidden */
  14648. export var imageProcessingDeclaration: {
  14649. name: string;
  14650. shader: string;
  14651. };
  14652. }
  14653. declare module BABYLON {
  14654. /** @hidden */
  14655. export var imageProcessingFunctions: {
  14656. name: string;
  14657. shader: string;
  14658. };
  14659. }
  14660. declare module BABYLON {
  14661. /** @hidden */
  14662. export var clipPlaneFragment: {
  14663. name: string;
  14664. shader: string;
  14665. };
  14666. }
  14667. declare module BABYLON {
  14668. /** @hidden */
  14669. export var particlesPixelShader: {
  14670. name: string;
  14671. shader: string;
  14672. };
  14673. }
  14674. declare module BABYLON {
  14675. /** @hidden */
  14676. export var clipPlaneVertexDeclaration: {
  14677. name: string;
  14678. shader: string;
  14679. };
  14680. }
  14681. declare module BABYLON {
  14682. /** @hidden */
  14683. export var clipPlaneVertex: {
  14684. name: string;
  14685. shader: string;
  14686. };
  14687. }
  14688. declare module BABYLON {
  14689. /** @hidden */
  14690. export var particlesVertexShader: {
  14691. name: string;
  14692. shader: string;
  14693. };
  14694. }
  14695. declare module BABYLON {
  14696. /**
  14697. * This represents a particle system in Babylon.
  14698. * 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.
  14699. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14700. * @example https://doc.babylonjs.com/babylon101/particles
  14701. */
  14702. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14703. /**
  14704. * Billboard mode will only apply to Y axis
  14705. */
  14706. static readonly BILLBOARDMODE_Y: number;
  14707. /**
  14708. * Billboard mode will apply to all axes
  14709. */
  14710. static readonly BILLBOARDMODE_ALL: number;
  14711. /**
  14712. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14713. */
  14714. static readonly BILLBOARDMODE_STRETCHED: number;
  14715. /**
  14716. * This function can be defined to provide custom update for active particles.
  14717. * This function will be called instead of regular update (age, position, color, etc.).
  14718. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14719. */
  14720. updateFunction: (particles: Particle[]) => void;
  14721. private _emitterWorldMatrix;
  14722. /**
  14723. * This function can be defined to specify initial direction for every new particle.
  14724. * It by default use the emitterType defined function
  14725. */
  14726. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14727. /**
  14728. * This function can be defined to specify initial position for every new particle.
  14729. * It by default use the emitterType defined function
  14730. */
  14731. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14732. /**
  14733. * @hidden
  14734. */
  14735. _inheritedVelocityOffset: Vector3;
  14736. /**
  14737. * An event triggered when the system is disposed
  14738. */
  14739. onDisposeObservable: Observable<ParticleSystem>;
  14740. private _onDisposeObserver;
  14741. /**
  14742. * Sets a callback that will be triggered when the system is disposed
  14743. */
  14744. onDispose: () => void;
  14745. private _particles;
  14746. private _epsilon;
  14747. private _capacity;
  14748. private _stockParticles;
  14749. private _newPartsExcess;
  14750. private _vertexData;
  14751. private _vertexBuffer;
  14752. private _vertexBuffers;
  14753. private _spriteBuffer;
  14754. private _indexBuffer;
  14755. private _effect;
  14756. private _customEffect;
  14757. private _cachedDefines;
  14758. private _scaledColorStep;
  14759. private _colorDiff;
  14760. private _scaledDirection;
  14761. private _scaledGravity;
  14762. private _currentRenderId;
  14763. private _alive;
  14764. private _useInstancing;
  14765. private _started;
  14766. private _stopped;
  14767. private _actualFrame;
  14768. private _scaledUpdateSpeed;
  14769. private _vertexBufferSize;
  14770. /** @hidden */
  14771. _currentEmitRateGradient: Nullable<FactorGradient>;
  14772. /** @hidden */
  14773. _currentEmitRate1: number;
  14774. /** @hidden */
  14775. _currentEmitRate2: number;
  14776. /** @hidden */
  14777. _currentStartSizeGradient: Nullable<FactorGradient>;
  14778. /** @hidden */
  14779. _currentStartSize1: number;
  14780. /** @hidden */
  14781. _currentStartSize2: number;
  14782. private readonly _rawTextureWidth;
  14783. private _rampGradientsTexture;
  14784. private _useRampGradients;
  14785. /** Gets or sets a boolean indicating that ramp gradients must be used
  14786. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14787. */
  14788. useRampGradients: boolean;
  14789. /**
  14790. * 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.
  14791. * 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: [])
  14792. */
  14793. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14794. private _subEmitters;
  14795. /**
  14796. * @hidden
  14797. * If the particle systems emitter should be disposed when the particle system is disposed
  14798. */
  14799. _disposeEmitterOnDispose: boolean;
  14800. /**
  14801. * The current active Sub-systems, this property is used by the root particle system only.
  14802. */
  14803. activeSubSystems: Array<ParticleSystem>;
  14804. private _rootParticleSystem;
  14805. /**
  14806. * Gets the current list of active particles
  14807. */
  14808. readonly particles: Particle[];
  14809. /**
  14810. * Returns the string "ParticleSystem"
  14811. * @returns a string containing the class name
  14812. */
  14813. getClassName(): string;
  14814. /**
  14815. * Instantiates a particle system.
  14816. * 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.
  14817. * @param name The name of the particle system
  14818. * @param capacity The max number of particles alive at the same time
  14819. * @param scene The scene the particle system belongs to
  14820. * @param customEffect a custom effect used to change the way particles are rendered by default
  14821. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14822. * @param epsilon Offset used to render the particles
  14823. */
  14824. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14825. private _addFactorGradient;
  14826. private _removeFactorGradient;
  14827. /**
  14828. * Adds a new life time gradient
  14829. * @param gradient defines the gradient to use (between 0 and 1)
  14830. * @param factor defines the life time factor to affect to the specified gradient
  14831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14832. * @returns the current particle system
  14833. */
  14834. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14835. /**
  14836. * Remove a specific life time gradient
  14837. * @param gradient defines the gradient to remove
  14838. * @returns the current particle system
  14839. */
  14840. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14841. /**
  14842. * Adds a new size gradient
  14843. * @param gradient defines the gradient to use (between 0 and 1)
  14844. * @param factor defines the size factor to affect to the specified gradient
  14845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14846. * @returns the current particle system
  14847. */
  14848. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14849. /**
  14850. * Remove a specific size gradient
  14851. * @param gradient defines the gradient to remove
  14852. * @returns the current particle system
  14853. */
  14854. removeSizeGradient(gradient: number): IParticleSystem;
  14855. /**
  14856. * Adds a new color remap gradient
  14857. * @param gradient defines the gradient to use (between 0 and 1)
  14858. * @param min defines the color remap minimal range
  14859. * @param max defines the color remap maximal range
  14860. * @returns the current particle system
  14861. */
  14862. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14863. /**
  14864. * Remove a specific color remap gradient
  14865. * @param gradient defines the gradient to remove
  14866. * @returns the current particle system
  14867. */
  14868. removeColorRemapGradient(gradient: number): IParticleSystem;
  14869. /**
  14870. * Adds a new alpha remap gradient
  14871. * @param gradient defines the gradient to use (between 0 and 1)
  14872. * @param min defines the alpha remap minimal range
  14873. * @param max defines the alpha remap maximal range
  14874. * @returns the current particle system
  14875. */
  14876. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14877. /**
  14878. * Remove a specific alpha remap gradient
  14879. * @param gradient defines the gradient to remove
  14880. * @returns the current particle system
  14881. */
  14882. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14883. /**
  14884. * Adds a new angular speed gradient
  14885. * @param gradient defines the gradient to use (between 0 and 1)
  14886. * @param factor defines the angular speed to affect to the specified gradient
  14887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14888. * @returns the current particle system
  14889. */
  14890. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14891. /**
  14892. * Remove a specific angular speed gradient
  14893. * @param gradient defines the gradient to remove
  14894. * @returns the current particle system
  14895. */
  14896. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14897. /**
  14898. * Adds a new velocity gradient
  14899. * @param gradient defines the gradient to use (between 0 and 1)
  14900. * @param factor defines the velocity to affect to the specified gradient
  14901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14902. * @returns the current particle system
  14903. */
  14904. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14905. /**
  14906. * Remove a specific velocity gradient
  14907. * @param gradient defines the gradient to remove
  14908. * @returns the current particle system
  14909. */
  14910. removeVelocityGradient(gradient: number): IParticleSystem;
  14911. /**
  14912. * Adds a new limit velocity gradient
  14913. * @param gradient defines the gradient to use (between 0 and 1)
  14914. * @param factor defines the limit velocity value to affect to the specified gradient
  14915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14916. * @returns the current particle system
  14917. */
  14918. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14919. /**
  14920. * Remove a specific limit velocity gradient
  14921. * @param gradient defines the gradient to remove
  14922. * @returns the current particle system
  14923. */
  14924. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14925. /**
  14926. * Adds a new drag gradient
  14927. * @param gradient defines the gradient to use (between 0 and 1)
  14928. * @param factor defines the drag value to affect to the specified gradient
  14929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14930. * @returns the current particle system
  14931. */
  14932. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14933. /**
  14934. * Remove a specific drag gradient
  14935. * @param gradient defines the gradient to remove
  14936. * @returns the current particle system
  14937. */
  14938. removeDragGradient(gradient: number): IParticleSystem;
  14939. /**
  14940. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14941. * @param gradient defines the gradient to use (between 0 and 1)
  14942. * @param factor defines the emit rate value to affect to the specified gradient
  14943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14944. * @returns the current particle system
  14945. */
  14946. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14947. /**
  14948. * Remove a specific emit rate gradient
  14949. * @param gradient defines the gradient to remove
  14950. * @returns the current particle system
  14951. */
  14952. removeEmitRateGradient(gradient: number): IParticleSystem;
  14953. /**
  14954. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14955. * @param gradient defines the gradient to use (between 0 and 1)
  14956. * @param factor defines the start size value to affect to the specified gradient
  14957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14958. * @returns the current particle system
  14959. */
  14960. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14961. /**
  14962. * Remove a specific start size gradient
  14963. * @param gradient defines the gradient to remove
  14964. * @returns the current particle system
  14965. */
  14966. removeStartSizeGradient(gradient: number): IParticleSystem;
  14967. private _createRampGradientTexture;
  14968. /**
  14969. * Gets the current list of ramp gradients.
  14970. * You must use addRampGradient and removeRampGradient to udpate this list
  14971. * @returns the list of ramp gradients
  14972. */
  14973. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14974. /**
  14975. * Adds a new ramp gradient used to remap particle colors
  14976. * @param gradient defines the gradient to use (between 0 and 1)
  14977. * @param color defines the color to affect to the specified gradient
  14978. * @returns the current particle system
  14979. */
  14980. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14981. /**
  14982. * Remove a specific ramp gradient
  14983. * @param gradient defines the gradient to remove
  14984. * @returns the current particle system
  14985. */
  14986. removeRampGradient(gradient: number): ParticleSystem;
  14987. /**
  14988. * Adds a new color gradient
  14989. * @param gradient defines the gradient to use (between 0 and 1)
  14990. * @param color1 defines the color to affect to the specified gradient
  14991. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14992. * @returns this particle system
  14993. */
  14994. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14995. /**
  14996. * Remove a specific color gradient
  14997. * @param gradient defines the gradient to remove
  14998. * @returns this particle system
  14999. */
  15000. removeColorGradient(gradient: number): IParticleSystem;
  15001. private _fetchR;
  15002. protected _reset(): void;
  15003. private _resetEffect;
  15004. private _createVertexBuffers;
  15005. private _createIndexBuffer;
  15006. /**
  15007. * Gets the maximum number of particles active at the same time.
  15008. * @returns The max number of active particles.
  15009. */
  15010. getCapacity(): number;
  15011. /**
  15012. * Gets whether there are still active particles in the system.
  15013. * @returns True if it is alive, otherwise false.
  15014. */
  15015. isAlive(): boolean;
  15016. /**
  15017. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15018. * @returns True if it has been started, otherwise false.
  15019. */
  15020. isStarted(): boolean;
  15021. private _prepareSubEmitterInternalArray;
  15022. /**
  15023. * Starts the particle system and begins to emit
  15024. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15025. */
  15026. start(delay?: number): void;
  15027. /**
  15028. * Stops the particle system.
  15029. * @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.
  15030. */
  15031. stop(stopSubEmitters?: boolean): void;
  15032. /**
  15033. * Remove all active particles
  15034. */
  15035. reset(): void;
  15036. /**
  15037. * @hidden (for internal use only)
  15038. */
  15039. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15040. /**
  15041. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15042. * Its lifetime will start back at 0.
  15043. */
  15044. recycleParticle: (particle: Particle) => void;
  15045. private _stopSubEmitters;
  15046. private _createParticle;
  15047. private _removeFromRoot;
  15048. private _emitFromParticle;
  15049. private _update;
  15050. /** @hidden */
  15051. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15052. /** @hidden */
  15053. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15054. /** @hidden */
  15055. private _getEffect;
  15056. /**
  15057. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15058. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15059. */
  15060. animate(preWarmOnly?: boolean): void;
  15061. private _appendParticleVertices;
  15062. /**
  15063. * Rebuilds the particle system.
  15064. */
  15065. rebuild(): void;
  15066. /**
  15067. * Is this system ready to be used/rendered
  15068. * @return true if the system is ready
  15069. */
  15070. isReady(): boolean;
  15071. private _render;
  15072. /**
  15073. * Renders the particle system in its current state.
  15074. * @returns the current number of particles
  15075. */
  15076. render(): number;
  15077. /**
  15078. * Disposes the particle system and free the associated resources
  15079. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15080. */
  15081. dispose(disposeTexture?: boolean): void;
  15082. /**
  15083. * Clones the particle system.
  15084. * @param name The name of the cloned object
  15085. * @param newEmitter The new emitter to use
  15086. * @returns the cloned particle system
  15087. */
  15088. clone(name: string, newEmitter: any): ParticleSystem;
  15089. /**
  15090. * Serializes the particle system to a JSON object.
  15091. * @returns the JSON object
  15092. */
  15093. serialize(): any;
  15094. /** @hidden */
  15095. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15096. /** @hidden */
  15097. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15098. /**
  15099. * Parses a JSON object to create a particle system.
  15100. * @param parsedParticleSystem The JSON object to parse
  15101. * @param scene The scene to create the particle system in
  15102. * @param rootUrl The root url to use to load external dependencies like texture
  15103. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15104. * @returns the Parsed particle system
  15105. */
  15106. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15107. }
  15108. }
  15109. declare module BABYLON {
  15110. /**
  15111. * A particle represents one of the element emitted by a particle system.
  15112. * This is mainly define by its coordinates, direction, velocity and age.
  15113. */
  15114. export class Particle {
  15115. /**
  15116. * The particle system the particle belongs to.
  15117. */
  15118. particleSystem: ParticleSystem;
  15119. private static _Count;
  15120. /**
  15121. * Unique ID of the particle
  15122. */
  15123. id: number;
  15124. /**
  15125. * The world position of the particle in the scene.
  15126. */
  15127. position: Vector3;
  15128. /**
  15129. * The world direction of the particle in the scene.
  15130. */
  15131. direction: Vector3;
  15132. /**
  15133. * The color of the particle.
  15134. */
  15135. color: Color4;
  15136. /**
  15137. * The color change of the particle per step.
  15138. */
  15139. colorStep: Color4;
  15140. /**
  15141. * Defines how long will the life of the particle be.
  15142. */
  15143. lifeTime: number;
  15144. /**
  15145. * The current age of the particle.
  15146. */
  15147. age: number;
  15148. /**
  15149. * The current size of the particle.
  15150. */
  15151. size: number;
  15152. /**
  15153. * The current scale of the particle.
  15154. */
  15155. scale: Vector2;
  15156. /**
  15157. * The current angle of the particle.
  15158. */
  15159. angle: number;
  15160. /**
  15161. * Defines how fast is the angle changing.
  15162. */
  15163. angularSpeed: number;
  15164. /**
  15165. * Defines the cell index used by the particle to be rendered from a sprite.
  15166. */
  15167. cellIndex: number;
  15168. /**
  15169. * The information required to support color remapping
  15170. */
  15171. remapData: Vector4;
  15172. /** @hidden */
  15173. _randomCellOffset?: number;
  15174. /** @hidden */
  15175. _initialDirection: Nullable<Vector3>;
  15176. /** @hidden */
  15177. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15178. /** @hidden */
  15179. _initialStartSpriteCellID: number;
  15180. /** @hidden */
  15181. _initialEndSpriteCellID: number;
  15182. /** @hidden */
  15183. _currentColorGradient: Nullable<ColorGradient>;
  15184. /** @hidden */
  15185. _currentColor1: Color4;
  15186. /** @hidden */
  15187. _currentColor2: Color4;
  15188. /** @hidden */
  15189. _currentSizeGradient: Nullable<FactorGradient>;
  15190. /** @hidden */
  15191. _currentSize1: number;
  15192. /** @hidden */
  15193. _currentSize2: number;
  15194. /** @hidden */
  15195. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15196. /** @hidden */
  15197. _currentAngularSpeed1: number;
  15198. /** @hidden */
  15199. _currentAngularSpeed2: number;
  15200. /** @hidden */
  15201. _currentVelocityGradient: Nullable<FactorGradient>;
  15202. /** @hidden */
  15203. _currentVelocity1: number;
  15204. /** @hidden */
  15205. _currentVelocity2: number;
  15206. /** @hidden */
  15207. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15208. /** @hidden */
  15209. _currentLimitVelocity1: number;
  15210. /** @hidden */
  15211. _currentLimitVelocity2: number;
  15212. /** @hidden */
  15213. _currentDragGradient: Nullable<FactorGradient>;
  15214. /** @hidden */
  15215. _currentDrag1: number;
  15216. /** @hidden */
  15217. _currentDrag2: number;
  15218. /** @hidden */
  15219. _randomNoiseCoordinates1: Vector3;
  15220. /** @hidden */
  15221. _randomNoiseCoordinates2: Vector3;
  15222. /**
  15223. * Creates a new instance Particle
  15224. * @param particleSystem the particle system the particle belongs to
  15225. */
  15226. constructor(
  15227. /**
  15228. * The particle system the particle belongs to.
  15229. */
  15230. particleSystem: ParticleSystem);
  15231. private updateCellInfoFromSystem;
  15232. /**
  15233. * Defines how the sprite cell index is updated for the particle
  15234. */
  15235. updateCellIndex(): void;
  15236. /** @hidden */
  15237. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15238. /** @hidden */
  15239. _inheritParticleInfoToSubEmitters(): void;
  15240. /** @hidden */
  15241. _reset(): void;
  15242. /**
  15243. * Copy the properties of particle to another one.
  15244. * @param other the particle to copy the information to.
  15245. */
  15246. copyTo(other: Particle): void;
  15247. }
  15248. }
  15249. declare module BABYLON {
  15250. /**
  15251. * Particle emitter represents a volume emitting particles.
  15252. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15253. */
  15254. export interface IParticleEmitterType {
  15255. /**
  15256. * Called by the particle System when the direction is computed for the created particle.
  15257. * @param worldMatrix is the world matrix of the particle system
  15258. * @param directionToUpdate is the direction vector to update with the result
  15259. * @param particle is the particle we are computed the direction for
  15260. */
  15261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15262. /**
  15263. * Called by the particle System when the position is computed for the created particle.
  15264. * @param worldMatrix is the world matrix of the particle system
  15265. * @param positionToUpdate is the position vector to update with the result
  15266. * @param particle is the particle we are computed the position for
  15267. */
  15268. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15269. /**
  15270. * Clones the current emitter and returns a copy of it
  15271. * @returns the new emitter
  15272. */
  15273. clone(): IParticleEmitterType;
  15274. /**
  15275. * Called by the GPUParticleSystem to setup the update shader
  15276. * @param effect defines the update shader
  15277. */
  15278. applyToShader(effect: Effect): void;
  15279. /**
  15280. * Returns a string to use to update the GPU particles update shader
  15281. * @returns the effect defines string
  15282. */
  15283. getEffectDefines(): string;
  15284. /**
  15285. * Returns a string representing the class name
  15286. * @returns a string containing the class name
  15287. */
  15288. getClassName(): string;
  15289. /**
  15290. * Serializes the particle system to a JSON object.
  15291. * @returns the JSON object
  15292. */
  15293. serialize(): any;
  15294. /**
  15295. * Parse properties from a JSON object
  15296. * @param serializationObject defines the JSON object
  15297. */
  15298. parse(serializationObject: any): void;
  15299. }
  15300. }
  15301. declare module BABYLON {
  15302. /**
  15303. * Particle emitter emitting particles from the inside of a box.
  15304. * It emits the particles randomly between 2 given directions.
  15305. */
  15306. export class BoxParticleEmitter implements IParticleEmitterType {
  15307. /**
  15308. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15309. */
  15310. direction1: Vector3;
  15311. /**
  15312. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15313. */
  15314. direction2: Vector3;
  15315. /**
  15316. * 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.
  15317. */
  15318. minEmitBox: Vector3;
  15319. /**
  15320. * 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.
  15321. */
  15322. maxEmitBox: Vector3;
  15323. /**
  15324. * Creates a new instance BoxParticleEmitter
  15325. */
  15326. constructor();
  15327. /**
  15328. * Called by the particle System when the direction is computed for the created particle.
  15329. * @param worldMatrix is the world matrix of the particle system
  15330. * @param directionToUpdate is the direction vector to update with the result
  15331. * @param particle is the particle we are computed the direction for
  15332. */
  15333. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15334. /**
  15335. * Called by the particle System when the position is computed for the created particle.
  15336. * @param worldMatrix is the world matrix of the particle system
  15337. * @param positionToUpdate is the position vector to update with the result
  15338. * @param particle is the particle we are computed the position for
  15339. */
  15340. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15341. /**
  15342. * Clones the current emitter and returns a copy of it
  15343. * @returns the new emitter
  15344. */
  15345. clone(): BoxParticleEmitter;
  15346. /**
  15347. * Called by the GPUParticleSystem to setup the update shader
  15348. * @param effect defines the update shader
  15349. */
  15350. applyToShader(effect: Effect): void;
  15351. /**
  15352. * Returns a string to use to update the GPU particles update shader
  15353. * @returns a string containng the defines string
  15354. */
  15355. getEffectDefines(): string;
  15356. /**
  15357. * Returns the string "BoxParticleEmitter"
  15358. * @returns a string containing the class name
  15359. */
  15360. getClassName(): string;
  15361. /**
  15362. * Serializes the particle system to a JSON object.
  15363. * @returns the JSON object
  15364. */
  15365. serialize(): any;
  15366. /**
  15367. * Parse properties from a JSON object
  15368. * @param serializationObject defines the JSON object
  15369. */
  15370. parse(serializationObject: any): void;
  15371. }
  15372. }
  15373. declare module BABYLON {
  15374. /**
  15375. * Particle emitter emitting particles from the inside of a cone.
  15376. * It emits the particles alongside the cone volume from the base to the particle.
  15377. * The emission direction might be randomized.
  15378. */
  15379. export class ConeParticleEmitter implements IParticleEmitterType {
  15380. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15381. directionRandomizer: number;
  15382. private _radius;
  15383. private _angle;
  15384. private _height;
  15385. /**
  15386. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15387. */
  15388. radiusRange: number;
  15389. /**
  15390. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15391. */
  15392. heightRange: number;
  15393. /**
  15394. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15395. */
  15396. emitFromSpawnPointOnly: boolean;
  15397. /**
  15398. * Gets or sets the radius of the emission cone
  15399. */
  15400. radius: number;
  15401. /**
  15402. * Gets or sets the angle of the emission cone
  15403. */
  15404. angle: number;
  15405. private _buildHeight;
  15406. /**
  15407. * Creates a new instance ConeParticleEmitter
  15408. * @param radius the radius of the emission cone (1 by default)
  15409. * @param angle the cone base angle (PI by default)
  15410. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15411. */
  15412. constructor(radius?: number, angle?: number,
  15413. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15414. directionRandomizer?: number);
  15415. /**
  15416. * Called by the particle System when the direction is computed for the created particle.
  15417. * @param worldMatrix is the world matrix of the particle system
  15418. * @param directionToUpdate is the direction vector to update with the result
  15419. * @param particle is the particle we are computed the direction for
  15420. */
  15421. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15422. /**
  15423. * Called by the particle System when the position is computed for the created particle.
  15424. * @param worldMatrix is the world matrix of the particle system
  15425. * @param positionToUpdate is the position vector to update with the result
  15426. * @param particle is the particle we are computed the position for
  15427. */
  15428. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15429. /**
  15430. * Clones the current emitter and returns a copy of it
  15431. * @returns the new emitter
  15432. */
  15433. clone(): ConeParticleEmitter;
  15434. /**
  15435. * Called by the GPUParticleSystem to setup the update shader
  15436. * @param effect defines the update shader
  15437. */
  15438. applyToShader(effect: Effect): void;
  15439. /**
  15440. * Returns a string to use to update the GPU particles update shader
  15441. * @returns a string containng the defines string
  15442. */
  15443. getEffectDefines(): string;
  15444. /**
  15445. * Returns the string "ConeParticleEmitter"
  15446. * @returns a string containing the class name
  15447. */
  15448. getClassName(): string;
  15449. /**
  15450. * Serializes the particle system to a JSON object.
  15451. * @returns the JSON object
  15452. */
  15453. serialize(): any;
  15454. /**
  15455. * Parse properties from a JSON object
  15456. * @param serializationObject defines the JSON object
  15457. */
  15458. parse(serializationObject: any): void;
  15459. }
  15460. }
  15461. declare module BABYLON {
  15462. /**
  15463. * Particle emitter emitting particles from the inside of a cylinder.
  15464. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15465. */
  15466. export class CylinderParticleEmitter implements IParticleEmitterType {
  15467. /**
  15468. * The radius of the emission cylinder.
  15469. */
  15470. radius: number;
  15471. /**
  15472. * The height of the emission cylinder.
  15473. */
  15474. height: number;
  15475. /**
  15476. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15477. */
  15478. radiusRange: number;
  15479. /**
  15480. * How much to randomize the particle direction [0-1].
  15481. */
  15482. directionRandomizer: number;
  15483. /**
  15484. * Creates a new instance CylinderParticleEmitter
  15485. * @param radius the radius of the emission cylinder (1 by default)
  15486. * @param height the height of the emission cylinder (1 by default)
  15487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15488. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15489. */
  15490. constructor(
  15491. /**
  15492. * The radius of the emission cylinder.
  15493. */
  15494. radius?: number,
  15495. /**
  15496. * The height of the emission cylinder.
  15497. */
  15498. height?: number,
  15499. /**
  15500. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15501. */
  15502. radiusRange?: number,
  15503. /**
  15504. * How much to randomize the particle direction [0-1].
  15505. */
  15506. directionRandomizer?: number);
  15507. /**
  15508. * Called by the particle System when the direction is computed for the created particle.
  15509. * @param worldMatrix is the world matrix of the particle system
  15510. * @param directionToUpdate is the direction vector to update with the result
  15511. * @param particle is the particle we are computed the direction for
  15512. */
  15513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15514. /**
  15515. * Called by the particle System when the position is computed for the created particle.
  15516. * @param worldMatrix is the world matrix of the particle system
  15517. * @param positionToUpdate is the position vector to update with the result
  15518. * @param particle is the particle we are computed the position for
  15519. */
  15520. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15521. /**
  15522. * Clones the current emitter and returns a copy of it
  15523. * @returns the new emitter
  15524. */
  15525. clone(): CylinderParticleEmitter;
  15526. /**
  15527. * Called by the GPUParticleSystem to setup the update shader
  15528. * @param effect defines the update shader
  15529. */
  15530. applyToShader(effect: Effect): void;
  15531. /**
  15532. * Returns a string to use to update the GPU particles update shader
  15533. * @returns a string containng the defines string
  15534. */
  15535. getEffectDefines(): string;
  15536. /**
  15537. * Returns the string "CylinderParticleEmitter"
  15538. * @returns a string containing the class name
  15539. */
  15540. getClassName(): string;
  15541. /**
  15542. * Serializes the particle system to a JSON object.
  15543. * @returns the JSON object
  15544. */
  15545. serialize(): any;
  15546. /**
  15547. * Parse properties from a JSON object
  15548. * @param serializationObject defines the JSON object
  15549. */
  15550. parse(serializationObject: any): void;
  15551. }
  15552. /**
  15553. * Particle emitter emitting particles from the inside of a cylinder.
  15554. * It emits the particles randomly between two vectors.
  15555. */
  15556. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15557. /**
  15558. * The min limit of the emission direction.
  15559. */
  15560. direction1: Vector3;
  15561. /**
  15562. * The max limit of the emission direction.
  15563. */
  15564. direction2: Vector3;
  15565. /**
  15566. * Creates a new instance CylinderDirectedParticleEmitter
  15567. * @param radius the radius of the emission cylinder (1 by default)
  15568. * @param height the height of the emission cylinder (1 by default)
  15569. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15570. * @param direction1 the min limit of the emission direction (up vector by default)
  15571. * @param direction2 the max limit of the emission direction (up vector by default)
  15572. */
  15573. constructor(radius?: number, height?: number, radiusRange?: number,
  15574. /**
  15575. * The min limit of the emission direction.
  15576. */
  15577. direction1?: Vector3,
  15578. /**
  15579. * The max limit of the emission direction.
  15580. */
  15581. direction2?: Vector3);
  15582. /**
  15583. * Called by the particle System when the direction is computed for the created particle.
  15584. * @param worldMatrix is the world matrix of the particle system
  15585. * @param directionToUpdate is the direction vector to update with the result
  15586. * @param particle is the particle we are computed the direction for
  15587. */
  15588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15589. /**
  15590. * Clones the current emitter and returns a copy of it
  15591. * @returns the new emitter
  15592. */
  15593. clone(): CylinderDirectedParticleEmitter;
  15594. /**
  15595. * Called by the GPUParticleSystem to setup the update shader
  15596. * @param effect defines the update shader
  15597. */
  15598. applyToShader(effect: Effect): void;
  15599. /**
  15600. * Returns a string to use to update the GPU particles update shader
  15601. * @returns a string containng the defines string
  15602. */
  15603. getEffectDefines(): string;
  15604. /**
  15605. * Returns the string "CylinderDirectedParticleEmitter"
  15606. * @returns a string containing the class name
  15607. */
  15608. getClassName(): string;
  15609. /**
  15610. * Serializes the particle system to a JSON object.
  15611. * @returns the JSON object
  15612. */
  15613. serialize(): any;
  15614. /**
  15615. * Parse properties from a JSON object
  15616. * @param serializationObject defines the JSON object
  15617. */
  15618. parse(serializationObject: any): void;
  15619. }
  15620. }
  15621. declare module BABYLON {
  15622. /**
  15623. * Particle emitter emitting particles from the inside of a hemisphere.
  15624. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15625. */
  15626. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15627. /**
  15628. * The radius of the emission hemisphere.
  15629. */
  15630. radius: number;
  15631. /**
  15632. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15633. */
  15634. radiusRange: number;
  15635. /**
  15636. * How much to randomize the particle direction [0-1].
  15637. */
  15638. directionRandomizer: number;
  15639. /**
  15640. * Creates a new instance HemisphericParticleEmitter
  15641. * @param radius the radius of the emission hemisphere (1 by default)
  15642. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15643. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15644. */
  15645. constructor(
  15646. /**
  15647. * The radius of the emission hemisphere.
  15648. */
  15649. radius?: number,
  15650. /**
  15651. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15652. */
  15653. radiusRange?: number,
  15654. /**
  15655. * How much to randomize the particle direction [0-1].
  15656. */
  15657. directionRandomizer?: number);
  15658. /**
  15659. * Called by the particle System when the direction is computed for the created particle.
  15660. * @param worldMatrix is the world matrix of the particle system
  15661. * @param directionToUpdate is the direction vector to update with the result
  15662. * @param particle is the particle we are computed the direction for
  15663. */
  15664. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15665. /**
  15666. * Called by the particle System when the position is computed for the created particle.
  15667. * @param worldMatrix is the world matrix of the particle system
  15668. * @param positionToUpdate is the position vector to update with the result
  15669. * @param particle is the particle we are computed the position for
  15670. */
  15671. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15672. /**
  15673. * Clones the current emitter and returns a copy of it
  15674. * @returns the new emitter
  15675. */
  15676. clone(): HemisphericParticleEmitter;
  15677. /**
  15678. * Called by the GPUParticleSystem to setup the update shader
  15679. * @param effect defines the update shader
  15680. */
  15681. applyToShader(effect: Effect): void;
  15682. /**
  15683. * Returns a string to use to update the GPU particles update shader
  15684. * @returns a string containng the defines string
  15685. */
  15686. getEffectDefines(): string;
  15687. /**
  15688. * Returns the string "HemisphericParticleEmitter"
  15689. * @returns a string containing the class name
  15690. */
  15691. getClassName(): string;
  15692. /**
  15693. * Serializes the particle system to a JSON object.
  15694. * @returns the JSON object
  15695. */
  15696. serialize(): any;
  15697. /**
  15698. * Parse properties from a JSON object
  15699. * @param serializationObject defines the JSON object
  15700. */
  15701. parse(serializationObject: any): void;
  15702. }
  15703. }
  15704. declare module BABYLON {
  15705. /**
  15706. * Particle emitter emitting particles from a point.
  15707. * It emits the particles randomly between 2 given directions.
  15708. */
  15709. export class PointParticleEmitter implements IParticleEmitterType {
  15710. /**
  15711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15712. */
  15713. direction1: Vector3;
  15714. /**
  15715. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15716. */
  15717. direction2: Vector3;
  15718. /**
  15719. * Creates a new instance PointParticleEmitter
  15720. */
  15721. constructor();
  15722. /**
  15723. * Called by the particle System when the direction is computed for the created particle.
  15724. * @param worldMatrix is the world matrix of the particle system
  15725. * @param directionToUpdate is the direction vector to update with the result
  15726. * @param particle is the particle we are computed the direction for
  15727. */
  15728. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15729. /**
  15730. * Called by the particle System when the position is computed for the created particle.
  15731. * @param worldMatrix is the world matrix of the particle system
  15732. * @param positionToUpdate is the position vector to update with the result
  15733. * @param particle is the particle we are computed the position for
  15734. */
  15735. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15736. /**
  15737. * Clones the current emitter and returns a copy of it
  15738. * @returns the new emitter
  15739. */
  15740. clone(): PointParticleEmitter;
  15741. /**
  15742. * Called by the GPUParticleSystem to setup the update shader
  15743. * @param effect defines the update shader
  15744. */
  15745. applyToShader(effect: Effect): void;
  15746. /**
  15747. * Returns a string to use to update the GPU particles update shader
  15748. * @returns a string containng the defines string
  15749. */
  15750. getEffectDefines(): string;
  15751. /**
  15752. * Returns the string "PointParticleEmitter"
  15753. * @returns a string containing the class name
  15754. */
  15755. getClassName(): string;
  15756. /**
  15757. * Serializes the particle system to a JSON object.
  15758. * @returns the JSON object
  15759. */
  15760. serialize(): any;
  15761. /**
  15762. * Parse properties from a JSON object
  15763. * @param serializationObject defines the JSON object
  15764. */
  15765. parse(serializationObject: any): void;
  15766. }
  15767. }
  15768. declare module BABYLON {
  15769. /**
  15770. * Particle emitter emitting particles from the inside of a sphere.
  15771. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15772. */
  15773. export class SphereParticleEmitter implements IParticleEmitterType {
  15774. /**
  15775. * The radius of the emission sphere.
  15776. */
  15777. radius: number;
  15778. /**
  15779. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15780. */
  15781. radiusRange: number;
  15782. /**
  15783. * How much to randomize the particle direction [0-1].
  15784. */
  15785. directionRandomizer: number;
  15786. /**
  15787. * Creates a new instance SphereParticleEmitter
  15788. * @param radius the radius of the emission sphere (1 by default)
  15789. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15790. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15791. */
  15792. constructor(
  15793. /**
  15794. * The radius of the emission sphere.
  15795. */
  15796. radius?: number,
  15797. /**
  15798. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15799. */
  15800. radiusRange?: number,
  15801. /**
  15802. * How much to randomize the particle direction [0-1].
  15803. */
  15804. directionRandomizer?: number);
  15805. /**
  15806. * Called by the particle System when the direction is computed for the created particle.
  15807. * @param worldMatrix is the world matrix of the particle system
  15808. * @param directionToUpdate is the direction vector to update with the result
  15809. * @param particle is the particle we are computed the direction for
  15810. */
  15811. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15812. /**
  15813. * Called by the particle System when the position is computed for the created particle.
  15814. * @param worldMatrix is the world matrix of the particle system
  15815. * @param positionToUpdate is the position vector to update with the result
  15816. * @param particle is the particle we are computed the position for
  15817. */
  15818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15819. /**
  15820. * Clones the current emitter and returns a copy of it
  15821. * @returns the new emitter
  15822. */
  15823. clone(): SphereParticleEmitter;
  15824. /**
  15825. * Called by the GPUParticleSystem to setup the update shader
  15826. * @param effect defines the update shader
  15827. */
  15828. applyToShader(effect: Effect): void;
  15829. /**
  15830. * Returns a string to use to update the GPU particles update shader
  15831. * @returns a string containng the defines string
  15832. */
  15833. getEffectDefines(): string;
  15834. /**
  15835. * Returns the string "SphereParticleEmitter"
  15836. * @returns a string containing the class name
  15837. */
  15838. getClassName(): string;
  15839. /**
  15840. * Serializes the particle system to a JSON object.
  15841. * @returns the JSON object
  15842. */
  15843. serialize(): any;
  15844. /**
  15845. * Parse properties from a JSON object
  15846. * @param serializationObject defines the JSON object
  15847. */
  15848. parse(serializationObject: any): void;
  15849. }
  15850. /**
  15851. * Particle emitter emitting particles from the inside of a sphere.
  15852. * It emits the particles randomly between two vectors.
  15853. */
  15854. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15855. /**
  15856. * The min limit of the emission direction.
  15857. */
  15858. direction1: Vector3;
  15859. /**
  15860. * The max limit of the emission direction.
  15861. */
  15862. direction2: Vector3;
  15863. /**
  15864. * Creates a new instance SphereDirectedParticleEmitter
  15865. * @param radius the radius of the emission sphere (1 by default)
  15866. * @param direction1 the min limit of the emission direction (up vector by default)
  15867. * @param direction2 the max limit of the emission direction (up vector by default)
  15868. */
  15869. constructor(radius?: number,
  15870. /**
  15871. * The min limit of the emission direction.
  15872. */
  15873. direction1?: Vector3,
  15874. /**
  15875. * The max limit of the emission direction.
  15876. */
  15877. direction2?: Vector3);
  15878. /**
  15879. * Called by the particle System when the direction is computed for the created particle.
  15880. * @param worldMatrix is the world matrix of the particle system
  15881. * @param directionToUpdate is the direction vector to update with the result
  15882. * @param particle is the particle we are computed the direction for
  15883. */
  15884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15885. /**
  15886. * Clones the current emitter and returns a copy of it
  15887. * @returns the new emitter
  15888. */
  15889. clone(): SphereDirectedParticleEmitter;
  15890. /**
  15891. * Called by the GPUParticleSystem to setup the update shader
  15892. * @param effect defines the update shader
  15893. */
  15894. applyToShader(effect: Effect): void;
  15895. /**
  15896. * Returns a string to use to update the GPU particles update shader
  15897. * @returns a string containng the defines string
  15898. */
  15899. getEffectDefines(): string;
  15900. /**
  15901. * Returns the string "SphereDirectedParticleEmitter"
  15902. * @returns a string containing the class name
  15903. */
  15904. getClassName(): string;
  15905. /**
  15906. * Serializes the particle system to a JSON object.
  15907. * @returns the JSON object
  15908. */
  15909. serialize(): any;
  15910. /**
  15911. * Parse properties from a JSON object
  15912. * @param serializationObject defines the JSON object
  15913. */
  15914. parse(serializationObject: any): void;
  15915. }
  15916. }
  15917. declare module BABYLON {
  15918. /**
  15919. * Interface representing a particle system in Babylon.js.
  15920. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15921. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15922. */
  15923. export interface IParticleSystem {
  15924. /**
  15925. * List of animations used by the particle system.
  15926. */
  15927. animations: Animation[];
  15928. /**
  15929. * The id of the Particle system.
  15930. */
  15931. id: string;
  15932. /**
  15933. * The name of the Particle system.
  15934. */
  15935. name: string;
  15936. /**
  15937. * The emitter represents the Mesh or position we are attaching the particle system to.
  15938. */
  15939. emitter: Nullable<AbstractMesh | Vector3>;
  15940. /**
  15941. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15942. */
  15943. isBillboardBased: boolean;
  15944. /**
  15945. * The rendering group used by the Particle system to chose when to render.
  15946. */
  15947. renderingGroupId: number;
  15948. /**
  15949. * The layer mask we are rendering the particles through.
  15950. */
  15951. layerMask: number;
  15952. /**
  15953. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15954. */
  15955. updateSpeed: number;
  15956. /**
  15957. * The amount of time the particle system is running (depends of the overall update speed).
  15958. */
  15959. targetStopDuration: number;
  15960. /**
  15961. * The texture used to render each particle. (this can be a spritesheet)
  15962. */
  15963. particleTexture: Nullable<Texture>;
  15964. /**
  15965. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15966. */
  15967. blendMode: number;
  15968. /**
  15969. * Minimum life time of emitting particles.
  15970. */
  15971. minLifeTime: number;
  15972. /**
  15973. * Maximum life time of emitting particles.
  15974. */
  15975. maxLifeTime: number;
  15976. /**
  15977. * Minimum Size of emitting particles.
  15978. */
  15979. minSize: number;
  15980. /**
  15981. * Maximum Size of emitting particles.
  15982. */
  15983. maxSize: number;
  15984. /**
  15985. * Minimum scale of emitting particles on X axis.
  15986. */
  15987. minScaleX: number;
  15988. /**
  15989. * Maximum scale of emitting particles on X axis.
  15990. */
  15991. maxScaleX: number;
  15992. /**
  15993. * Minimum scale of emitting particles on Y axis.
  15994. */
  15995. minScaleY: number;
  15996. /**
  15997. * Maximum scale of emitting particles on Y axis.
  15998. */
  15999. maxScaleY: number;
  16000. /**
  16001. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16002. */
  16003. color1: Color4;
  16004. /**
  16005. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16006. */
  16007. color2: Color4;
  16008. /**
  16009. * Color the particle will have at the end of its lifetime.
  16010. */
  16011. colorDead: Color4;
  16012. /**
  16013. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16014. */
  16015. emitRate: number;
  16016. /**
  16017. * You can use gravity if you want to give an orientation to your particles.
  16018. */
  16019. gravity: Vector3;
  16020. /**
  16021. * Minimum power of emitting particles.
  16022. */
  16023. minEmitPower: number;
  16024. /**
  16025. * Maximum power of emitting particles.
  16026. */
  16027. maxEmitPower: number;
  16028. /**
  16029. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16030. */
  16031. minAngularSpeed: number;
  16032. /**
  16033. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16034. */
  16035. maxAngularSpeed: number;
  16036. /**
  16037. * Gets or sets the minimal initial rotation in radians.
  16038. */
  16039. minInitialRotation: number;
  16040. /**
  16041. * Gets or sets the maximal initial rotation in radians.
  16042. */
  16043. maxInitialRotation: number;
  16044. /**
  16045. * The particle emitter type defines the emitter used by the particle system.
  16046. * It can be for example box, sphere, or cone...
  16047. */
  16048. particleEmitterType: Nullable<IParticleEmitterType>;
  16049. /**
  16050. * Defines the delay in milliseconds before starting the system (0 by default)
  16051. */
  16052. startDelay: number;
  16053. /**
  16054. * 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
  16055. */
  16056. preWarmCycles: number;
  16057. /**
  16058. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16059. */
  16060. preWarmStepOffset: number;
  16061. /**
  16062. * 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)
  16063. */
  16064. spriteCellChangeSpeed: number;
  16065. /**
  16066. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16067. */
  16068. startSpriteCellID: number;
  16069. /**
  16070. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16071. */
  16072. endSpriteCellID: number;
  16073. /**
  16074. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16075. */
  16076. spriteCellWidth: number;
  16077. /**
  16078. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16079. */
  16080. spriteCellHeight: number;
  16081. /**
  16082. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16083. */
  16084. spriteRandomStartCell: boolean;
  16085. /**
  16086. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16087. */
  16088. isAnimationSheetEnabled: boolean;
  16089. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16090. translationPivot: Vector2;
  16091. /**
  16092. * Gets or sets a texture used to add random noise to particle positions
  16093. */
  16094. noiseTexture: Nullable<BaseTexture>;
  16095. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16096. noiseStrength: Vector3;
  16097. /**
  16098. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16099. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16100. */
  16101. billboardMode: number;
  16102. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16103. limitVelocityDamping: number;
  16104. /**
  16105. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16106. */
  16107. beginAnimationOnStart: boolean;
  16108. /**
  16109. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16110. */
  16111. beginAnimationFrom: number;
  16112. /**
  16113. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16114. */
  16115. beginAnimationTo: number;
  16116. /**
  16117. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16118. */
  16119. beginAnimationLoop: boolean;
  16120. /**
  16121. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16122. */
  16123. disposeOnStop: boolean;
  16124. /**
  16125. * Gets the maximum number of particles active at the same time.
  16126. * @returns The max number of active particles.
  16127. */
  16128. getCapacity(): number;
  16129. /**
  16130. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16131. * @returns True if it has been started, otherwise false.
  16132. */
  16133. isStarted(): boolean;
  16134. /**
  16135. * Animates the particle system for this frame.
  16136. */
  16137. animate(): void;
  16138. /**
  16139. * Renders the particle system in its current state.
  16140. * @returns the current number of particles
  16141. */
  16142. render(): number;
  16143. /**
  16144. * Dispose the particle system and frees its associated resources.
  16145. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16146. */
  16147. dispose(disposeTexture?: boolean): void;
  16148. /**
  16149. * Clones the particle system.
  16150. * @param name The name of the cloned object
  16151. * @param newEmitter The new emitter to use
  16152. * @returns the cloned particle system
  16153. */
  16154. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16155. /**
  16156. * Serializes the particle system to a JSON object.
  16157. * @returns the JSON object
  16158. */
  16159. serialize(): any;
  16160. /**
  16161. * Rebuild the particle system
  16162. */
  16163. rebuild(): void;
  16164. /**
  16165. * Starts the particle system and begins to emit
  16166. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16167. */
  16168. start(delay?: number): void;
  16169. /**
  16170. * Stops the particle system.
  16171. */
  16172. stop(): void;
  16173. /**
  16174. * Remove all active particles
  16175. */
  16176. reset(): void;
  16177. /**
  16178. * Is this system ready to be used/rendered
  16179. * @return true if the system is ready
  16180. */
  16181. isReady(): boolean;
  16182. /**
  16183. * Adds a new color gradient
  16184. * @param gradient defines the gradient to use (between 0 and 1)
  16185. * @param color1 defines the color to affect to the specified gradient
  16186. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16187. * @returns the current particle system
  16188. */
  16189. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16190. /**
  16191. * Remove a specific color gradient
  16192. * @param gradient defines the gradient to remove
  16193. * @returns the current particle system
  16194. */
  16195. removeColorGradient(gradient: number): IParticleSystem;
  16196. /**
  16197. * Adds a new size gradient
  16198. * @param gradient defines the gradient to use (between 0 and 1)
  16199. * @param factor defines the size factor to affect to the specified gradient
  16200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16201. * @returns the current particle system
  16202. */
  16203. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16204. /**
  16205. * Remove a specific size gradient
  16206. * @param gradient defines the gradient to remove
  16207. * @returns the current particle system
  16208. */
  16209. removeSizeGradient(gradient: number): IParticleSystem;
  16210. /**
  16211. * Gets the current list of color gradients.
  16212. * You must use addColorGradient and removeColorGradient to udpate this list
  16213. * @returns the list of color gradients
  16214. */
  16215. getColorGradients(): Nullable<Array<ColorGradient>>;
  16216. /**
  16217. * Gets the current list of size gradients.
  16218. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16219. * @returns the list of size gradients
  16220. */
  16221. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16222. /**
  16223. * Gets the current list of angular speed gradients.
  16224. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16225. * @returns the list of angular speed gradients
  16226. */
  16227. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16228. /**
  16229. * Adds a new angular speed gradient
  16230. * @param gradient defines the gradient to use (between 0 and 1)
  16231. * @param factor defines the angular speed to affect to the specified gradient
  16232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16233. * @returns the current particle system
  16234. */
  16235. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16236. /**
  16237. * Remove a specific angular speed gradient
  16238. * @param gradient defines the gradient to remove
  16239. * @returns the current particle system
  16240. */
  16241. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16242. /**
  16243. * Gets the current list of velocity gradients.
  16244. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16245. * @returns the list of velocity gradients
  16246. */
  16247. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16248. /**
  16249. * Adds a new velocity gradient
  16250. * @param gradient defines the gradient to use (between 0 and 1)
  16251. * @param factor defines the velocity to affect to the specified gradient
  16252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16253. * @returns the current particle system
  16254. */
  16255. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16256. /**
  16257. * Remove a specific velocity gradient
  16258. * @param gradient defines the gradient to remove
  16259. * @returns the current particle system
  16260. */
  16261. removeVelocityGradient(gradient: number): IParticleSystem;
  16262. /**
  16263. * Gets the current list of limit velocity gradients.
  16264. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16265. * @returns the list of limit velocity gradients
  16266. */
  16267. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16268. /**
  16269. * Adds a new limit velocity gradient
  16270. * @param gradient defines the gradient to use (between 0 and 1)
  16271. * @param factor defines the limit velocity to affect to the specified gradient
  16272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16273. * @returns the current particle system
  16274. */
  16275. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16276. /**
  16277. * Remove a specific limit velocity gradient
  16278. * @param gradient defines the gradient to remove
  16279. * @returns the current particle system
  16280. */
  16281. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16282. /**
  16283. * Adds a new drag gradient
  16284. * @param gradient defines the gradient to use (between 0 and 1)
  16285. * @param factor defines the drag to affect to the specified gradient
  16286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16287. * @returns the current particle system
  16288. */
  16289. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16290. /**
  16291. * Remove a specific drag gradient
  16292. * @param gradient defines the gradient to remove
  16293. * @returns the current particle system
  16294. */
  16295. removeDragGradient(gradient: number): IParticleSystem;
  16296. /**
  16297. * Gets the current list of drag gradients.
  16298. * You must use addDragGradient and removeDragGradient to udpate this list
  16299. * @returns the list of drag gradients
  16300. */
  16301. getDragGradients(): Nullable<Array<FactorGradient>>;
  16302. /**
  16303. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16304. * @param gradient defines the gradient to use (between 0 and 1)
  16305. * @param factor defines the emit rate to affect to the specified gradient
  16306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16307. * @returns the current particle system
  16308. */
  16309. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16310. /**
  16311. * Remove a specific emit rate gradient
  16312. * @param gradient defines the gradient to remove
  16313. * @returns the current particle system
  16314. */
  16315. removeEmitRateGradient(gradient: number): IParticleSystem;
  16316. /**
  16317. * Gets the current list of emit rate gradients.
  16318. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16319. * @returns the list of emit rate gradients
  16320. */
  16321. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16322. /**
  16323. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16324. * @param gradient defines the gradient to use (between 0 and 1)
  16325. * @param factor defines the start size to affect to the specified gradient
  16326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16327. * @returns the current particle system
  16328. */
  16329. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16330. /**
  16331. * Remove a specific start size gradient
  16332. * @param gradient defines the gradient to remove
  16333. * @returns the current particle system
  16334. */
  16335. removeStartSizeGradient(gradient: number): IParticleSystem;
  16336. /**
  16337. * Gets the current list of start size gradients.
  16338. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16339. * @returns the list of start size gradients
  16340. */
  16341. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16342. /**
  16343. * Adds a new life time gradient
  16344. * @param gradient defines the gradient to use (between 0 and 1)
  16345. * @param factor defines the life time factor to affect to the specified gradient
  16346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16347. * @returns the current particle system
  16348. */
  16349. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16350. /**
  16351. * Remove a specific life time gradient
  16352. * @param gradient defines the gradient to remove
  16353. * @returns the current particle system
  16354. */
  16355. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16356. /**
  16357. * Gets the current list of life time gradients.
  16358. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16359. * @returns the list of life time gradients
  16360. */
  16361. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16362. /**
  16363. * Gets the current list of color gradients.
  16364. * You must use addColorGradient and removeColorGradient to udpate this list
  16365. * @returns the list of color gradients
  16366. */
  16367. getColorGradients(): Nullable<Array<ColorGradient>>;
  16368. /**
  16369. * Adds a new ramp gradient used to remap particle colors
  16370. * @param gradient defines the gradient to use (between 0 and 1)
  16371. * @param color defines the color to affect to the specified gradient
  16372. * @returns the current particle system
  16373. */
  16374. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16375. /**
  16376. * Gets the current list of ramp gradients.
  16377. * You must use addRampGradient and removeRampGradient to udpate this list
  16378. * @returns the list of ramp gradients
  16379. */
  16380. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16381. /** Gets or sets a boolean indicating that ramp gradients must be used
  16382. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16383. */
  16384. useRampGradients: boolean;
  16385. /**
  16386. * Adds a new color remap gradient
  16387. * @param gradient defines the gradient to use (between 0 and 1)
  16388. * @param min defines the color remap minimal range
  16389. * @param max defines the color remap maximal range
  16390. * @returns the current particle system
  16391. */
  16392. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16393. /**
  16394. * Gets the current list of color remap gradients.
  16395. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16396. * @returns the list of color remap gradients
  16397. */
  16398. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16399. /**
  16400. * Adds a new alpha remap gradient
  16401. * @param gradient defines the gradient to use (between 0 and 1)
  16402. * @param min defines the alpha remap minimal range
  16403. * @param max defines the alpha remap maximal range
  16404. * @returns the current particle system
  16405. */
  16406. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16407. /**
  16408. * Gets the current list of alpha remap gradients.
  16409. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16410. * @returns the list of alpha remap gradients
  16411. */
  16412. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16413. /**
  16414. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16415. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16416. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16417. * @returns the emitter
  16418. */
  16419. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16420. /**
  16421. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16422. * @param radius The radius of the hemisphere to emit from
  16423. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16424. * @returns the emitter
  16425. */
  16426. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16427. /**
  16428. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16429. * @param radius The radius of the sphere to emit from
  16430. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16431. * @returns the emitter
  16432. */
  16433. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16434. /**
  16435. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16436. * @param radius The radius of the sphere to emit from
  16437. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16438. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16439. * @returns the emitter
  16440. */
  16441. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16442. /**
  16443. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16444. * @param radius The radius of the emission cylinder
  16445. * @param height The height of the emission cylinder
  16446. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16447. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16448. * @returns the emitter
  16449. */
  16450. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16451. /**
  16452. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16453. * @param radius The radius of the cylinder to emit from
  16454. * @param height The height of the emission cylinder
  16455. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16456. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16457. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16458. * @returns the emitter
  16459. */
  16460. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16461. /**
  16462. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16463. * @param radius The radius of the cone to emit from
  16464. * @param angle The base angle of the cone
  16465. * @returns the emitter
  16466. */
  16467. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16468. /**
  16469. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16470. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16471. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16472. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16473. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16474. * @returns the emitter
  16475. */
  16476. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16477. /**
  16478. * Get hosting scene
  16479. * @returns the scene
  16480. */
  16481. getScene(): Scene;
  16482. }
  16483. }
  16484. declare module BABYLON {
  16485. /**
  16486. * Creates an instance based on a source mesh.
  16487. */
  16488. export class InstancedMesh extends AbstractMesh {
  16489. private _sourceMesh;
  16490. private _currentLOD;
  16491. /** @hidden */
  16492. _indexInSourceMeshInstanceArray: number;
  16493. constructor(name: string, source: Mesh);
  16494. /**
  16495. * Returns the string "InstancedMesh".
  16496. */
  16497. getClassName(): string;
  16498. /**
  16499. * If the source mesh receives shadows
  16500. */
  16501. readonly receiveShadows: boolean;
  16502. /**
  16503. * The material of the source mesh
  16504. */
  16505. readonly material: Nullable<Material>;
  16506. /**
  16507. * Visibility of the source mesh
  16508. */
  16509. readonly visibility: number;
  16510. /**
  16511. * Skeleton of the source mesh
  16512. */
  16513. readonly skeleton: Nullable<Skeleton>;
  16514. /**
  16515. * Rendering ground id of the source mesh
  16516. */
  16517. renderingGroupId: number;
  16518. /**
  16519. * Returns the total number of vertices (integer).
  16520. */
  16521. getTotalVertices(): number;
  16522. /**
  16523. * Returns a positive integer : the total number of indices in this mesh geometry.
  16524. * @returns the numner of indices or zero if the mesh has no geometry.
  16525. */
  16526. getTotalIndices(): number;
  16527. /**
  16528. * The source mesh of the instance
  16529. */
  16530. readonly sourceMesh: Mesh;
  16531. /**
  16532. * Is this node ready to be used/rendered
  16533. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16534. * @return {boolean} is it ready
  16535. */
  16536. isReady(completeCheck?: boolean): boolean;
  16537. /**
  16538. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16539. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16540. * @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.
  16541. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16542. */
  16543. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16544. /**
  16545. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16546. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16547. * The `data` are either a numeric array either a Float32Array.
  16548. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16549. * 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).
  16550. * Note that a new underlying VertexBuffer object is created each call.
  16551. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16552. *
  16553. * Possible `kind` values :
  16554. * - VertexBuffer.PositionKind
  16555. * - VertexBuffer.UVKind
  16556. * - VertexBuffer.UV2Kind
  16557. * - VertexBuffer.UV3Kind
  16558. * - VertexBuffer.UV4Kind
  16559. * - VertexBuffer.UV5Kind
  16560. * - VertexBuffer.UV6Kind
  16561. * - VertexBuffer.ColorKind
  16562. * - VertexBuffer.MatricesIndicesKind
  16563. * - VertexBuffer.MatricesIndicesExtraKind
  16564. * - VertexBuffer.MatricesWeightsKind
  16565. * - VertexBuffer.MatricesWeightsExtraKind
  16566. *
  16567. * Returns the Mesh.
  16568. */
  16569. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16570. /**
  16571. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16572. * If the mesh has no geometry, it is simply returned as it is.
  16573. * The `data` are either a numeric array either a Float32Array.
  16574. * No new underlying VertexBuffer object is created.
  16575. * 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.
  16576. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16577. *
  16578. * Possible `kind` values :
  16579. * - VertexBuffer.PositionKind
  16580. * - VertexBuffer.UVKind
  16581. * - VertexBuffer.UV2Kind
  16582. * - VertexBuffer.UV3Kind
  16583. * - VertexBuffer.UV4Kind
  16584. * - VertexBuffer.UV5Kind
  16585. * - VertexBuffer.UV6Kind
  16586. * - VertexBuffer.ColorKind
  16587. * - VertexBuffer.MatricesIndicesKind
  16588. * - VertexBuffer.MatricesIndicesExtraKind
  16589. * - VertexBuffer.MatricesWeightsKind
  16590. * - VertexBuffer.MatricesWeightsExtraKind
  16591. *
  16592. * Returns the Mesh.
  16593. */
  16594. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16595. /**
  16596. * Sets the mesh indices.
  16597. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16598. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16599. * This method creates a new index buffer each call.
  16600. * Returns the Mesh.
  16601. */
  16602. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16603. /**
  16604. * Boolean : True if the mesh owns the requested kind of data.
  16605. */
  16606. isVerticesDataPresent(kind: string): boolean;
  16607. /**
  16608. * Returns an array of indices (IndicesArray).
  16609. */
  16610. getIndices(): Nullable<IndicesArray>;
  16611. readonly _positions: Nullable<Vector3[]>;
  16612. /**
  16613. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16614. * This means the mesh underlying bounding box and sphere are recomputed.
  16615. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16616. * @returns the current mesh
  16617. */
  16618. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16619. /** @hidden */
  16620. _preActivate(): InstancedMesh;
  16621. /** @hidden */
  16622. _activate(renderId: number): InstancedMesh;
  16623. /**
  16624. * Returns the current associated LOD AbstractMesh.
  16625. */
  16626. getLOD(camera: Camera): AbstractMesh;
  16627. /** @hidden */
  16628. _syncSubMeshes(): InstancedMesh;
  16629. /** @hidden */
  16630. _generatePointsArray(): boolean;
  16631. /**
  16632. * Creates a new InstancedMesh from the current mesh.
  16633. * - name (string) : the cloned mesh name
  16634. * - newParent (optional Node) : the optional Node to parent the clone to.
  16635. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16636. *
  16637. * Returns the clone.
  16638. */
  16639. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16640. /**
  16641. * Disposes the InstancedMesh.
  16642. * Returns nothing.
  16643. */
  16644. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16645. }
  16646. }
  16647. declare module BABYLON {
  16648. /**
  16649. * Defines the options associated with the creation of a shader material.
  16650. */
  16651. export interface IShaderMaterialOptions {
  16652. /**
  16653. * Does the material work in alpha blend mode
  16654. */
  16655. needAlphaBlending: boolean;
  16656. /**
  16657. * Does the material work in alpha test mode
  16658. */
  16659. needAlphaTesting: boolean;
  16660. /**
  16661. * The list of attribute names used in the shader
  16662. */
  16663. attributes: string[];
  16664. /**
  16665. * The list of unifrom names used in the shader
  16666. */
  16667. uniforms: string[];
  16668. /**
  16669. * The list of UBO names used in the shader
  16670. */
  16671. uniformBuffers: string[];
  16672. /**
  16673. * The list of sampler names used in the shader
  16674. */
  16675. samplers: string[];
  16676. /**
  16677. * The list of defines used in the shader
  16678. */
  16679. defines: string[];
  16680. }
  16681. /**
  16682. * 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.
  16683. *
  16684. * This returned material effects how the mesh will look based on the code in the shaders.
  16685. *
  16686. * @see http://doc.babylonjs.com/how_to/shader_material
  16687. */
  16688. export class ShaderMaterial extends Material {
  16689. private _shaderPath;
  16690. private _options;
  16691. private _textures;
  16692. private _textureArrays;
  16693. private _floats;
  16694. private _ints;
  16695. private _floatsArrays;
  16696. private _colors3;
  16697. private _colors3Arrays;
  16698. private _colors4;
  16699. private _vectors2;
  16700. private _vectors3;
  16701. private _vectors4;
  16702. private _matrices;
  16703. private _matrices3x3;
  16704. private _matrices2x2;
  16705. private _vectors2Arrays;
  16706. private _vectors3Arrays;
  16707. private _cachedWorldViewMatrix;
  16708. private _renderId;
  16709. /**
  16710. * Instantiate a new shader material.
  16711. * 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.
  16712. * This returned material effects how the mesh will look based on the code in the shaders.
  16713. * @see http://doc.babylonjs.com/how_to/shader_material
  16714. * @param name Define the name of the material in the scene
  16715. * @param scene Define the scene the material belongs to
  16716. * @param shaderPath Defines the route to the shader code in one of three ways:
  16717. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16718. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16719. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16720. * @param options Define the options used to create the shader
  16721. */
  16722. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16723. /**
  16724. * Gets the options used to compile the shader.
  16725. * They can be modified to trigger a new compilation
  16726. */
  16727. readonly options: IShaderMaterialOptions;
  16728. /**
  16729. * Gets the current class name of the material e.g. "ShaderMaterial"
  16730. * Mainly use in serialization.
  16731. * @returns the class name
  16732. */
  16733. getClassName(): string;
  16734. /**
  16735. * Specifies if the material will require alpha blending
  16736. * @returns a boolean specifying if alpha blending is needed
  16737. */
  16738. needAlphaBlending(): boolean;
  16739. /**
  16740. * Specifies if this material should be rendered in alpha test mode
  16741. * @returns a boolean specifying if an alpha test is needed.
  16742. */
  16743. needAlphaTesting(): boolean;
  16744. private _checkUniform;
  16745. /**
  16746. * Set a texture in the shader.
  16747. * @param name Define the name of the uniform samplers as defined in the shader
  16748. * @param texture Define the texture to bind to this sampler
  16749. * @return the material itself allowing "fluent" like uniform updates
  16750. */
  16751. setTexture(name: string, texture: Texture): ShaderMaterial;
  16752. /**
  16753. * Set a texture array in the shader.
  16754. * @param name Define the name of the uniform sampler array as defined in the shader
  16755. * @param textures Define the list of textures to bind to this sampler
  16756. * @return the material itself allowing "fluent" like uniform updates
  16757. */
  16758. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16759. /**
  16760. * Set a float in the shader.
  16761. * @param name Define the name of the uniform as defined in the shader
  16762. * @param value Define the value to give to the uniform
  16763. * @return the material itself allowing "fluent" like uniform updates
  16764. */
  16765. setFloat(name: string, value: number): ShaderMaterial;
  16766. /**
  16767. * Set a int in the shader.
  16768. * @param name Define the name of the uniform as defined in the shader
  16769. * @param value Define the value to give to the uniform
  16770. * @return the material itself allowing "fluent" like uniform updates
  16771. */
  16772. setInt(name: string, value: number): ShaderMaterial;
  16773. /**
  16774. * Set an array of floats in the shader.
  16775. * @param name Define the name of the uniform as defined in the shader
  16776. * @param value Define the value to give to the uniform
  16777. * @return the material itself allowing "fluent" like uniform updates
  16778. */
  16779. setFloats(name: string, value: number[]): ShaderMaterial;
  16780. /**
  16781. * Set a vec3 in the shader from a Color3.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the material itself allowing "fluent" like uniform updates
  16785. */
  16786. setColor3(name: string, value: Color3): ShaderMaterial;
  16787. /**
  16788. * Set a vec3 array in the shader from a Color3 array.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the material itself allowing "fluent" like uniform updates
  16792. */
  16793. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16794. /**
  16795. * Set a vec4 in the shader from a Color4.
  16796. * @param name Define the name of the uniform as defined in the shader
  16797. * @param value Define the value to give to the uniform
  16798. * @return the material itself allowing "fluent" like uniform updates
  16799. */
  16800. setColor4(name: string, value: Color4): ShaderMaterial;
  16801. /**
  16802. * Set a vec2 in the shader from a Vector2.
  16803. * @param name Define the name of the uniform as defined in the shader
  16804. * @param value Define the value to give to the uniform
  16805. * @return the material itself allowing "fluent" like uniform updates
  16806. */
  16807. setVector2(name: string, value: Vector2): ShaderMaterial;
  16808. /**
  16809. * Set a vec3 in the shader from a Vector3.
  16810. * @param name Define the name of the uniform as defined in the shader
  16811. * @param value Define the value to give to the uniform
  16812. * @return the material itself allowing "fluent" like uniform updates
  16813. */
  16814. setVector3(name: string, value: Vector3): ShaderMaterial;
  16815. /**
  16816. * Set a vec4 in the shader from a Vector4.
  16817. * @param name Define the name of the uniform as defined in the shader
  16818. * @param value Define the value to give to the uniform
  16819. * @return the material itself allowing "fluent" like uniform updates
  16820. */
  16821. setVector4(name: string, value: Vector4): ShaderMaterial;
  16822. /**
  16823. * Set a mat4 in the shader from a Matrix.
  16824. * @param name Define the name of the uniform as defined in the shader
  16825. * @param value Define the value to give to the uniform
  16826. * @return the material itself allowing "fluent" like uniform updates
  16827. */
  16828. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16829. /**
  16830. * Set a mat3 in the shader from a Float32Array.
  16831. * @param name Define the name of the uniform as defined in the shader
  16832. * @param value Define the value to give to the uniform
  16833. * @return the material itself allowing "fluent" like uniform updates
  16834. */
  16835. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16836. /**
  16837. * Set a mat2 in the shader from a Float32Array.
  16838. * @param name Define the name of the uniform as defined in the shader
  16839. * @param value Define the value to give to the uniform
  16840. * @return the material itself allowing "fluent" like uniform updates
  16841. */
  16842. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16843. /**
  16844. * Set a vec2 array in the shader from a number array.
  16845. * @param name Define the name of the uniform as defined in the shader
  16846. * @param value Define the value to give to the uniform
  16847. * @return the material itself allowing "fluent" like uniform updates
  16848. */
  16849. setArray2(name: string, value: number[]): ShaderMaterial;
  16850. /**
  16851. * Set a vec3 array in the shader from a number array.
  16852. * @param name Define the name of the uniform as defined in the shader
  16853. * @param value Define the value to give to the uniform
  16854. * @return the material itself allowing "fluent" like uniform updates
  16855. */
  16856. setArray3(name: string, value: number[]): ShaderMaterial;
  16857. private _checkCache;
  16858. /**
  16859. * Specifies that the submesh is ready to be used
  16860. * @param mesh defines the mesh to check
  16861. * @param subMesh defines which submesh to check
  16862. * @param useInstances specifies that instances should be used
  16863. * @returns a boolean indicating that the submesh is ready or not
  16864. */
  16865. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16866. /**
  16867. * Checks if the material is ready to render the requested mesh
  16868. * @param mesh Define the mesh to render
  16869. * @param useInstances Define whether or not the material is used with instances
  16870. * @returns true if ready, otherwise false
  16871. */
  16872. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16873. /**
  16874. * Binds the world matrix to the material
  16875. * @param world defines the world transformation matrix
  16876. */
  16877. bindOnlyWorldMatrix(world: Matrix): void;
  16878. /**
  16879. * Binds the material to the mesh
  16880. * @param world defines the world transformation matrix
  16881. * @param mesh defines the mesh to bind the material to
  16882. */
  16883. bind(world: Matrix, mesh?: Mesh): void;
  16884. /**
  16885. * Gets the active textures from the material
  16886. * @returns an array of textures
  16887. */
  16888. getActiveTextures(): BaseTexture[];
  16889. /**
  16890. * Specifies if the material uses a texture
  16891. * @param texture defines the texture to check against the material
  16892. * @returns a boolean specifying if the material uses the texture
  16893. */
  16894. hasTexture(texture: BaseTexture): boolean;
  16895. /**
  16896. * Makes a duplicate of the material, and gives it a new name
  16897. * @param name defines the new name for the duplicated material
  16898. * @returns the cloned material
  16899. */
  16900. clone(name: string): ShaderMaterial;
  16901. /**
  16902. * Disposes the material
  16903. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16904. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16905. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16906. */
  16907. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16908. /**
  16909. * Serializes this material in a JSON representation
  16910. * @returns the serialized material object
  16911. */
  16912. serialize(): any;
  16913. /**
  16914. * Creates a shader material from parsed shader material data
  16915. * @param source defines the JSON represnetation of the material
  16916. * @param scene defines the hosting scene
  16917. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16918. * @returns a new material
  16919. */
  16920. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16921. }
  16922. }
  16923. declare module BABYLON {
  16924. /** @hidden */
  16925. export var colorPixelShader: {
  16926. name: string;
  16927. shader: string;
  16928. };
  16929. }
  16930. declare module BABYLON {
  16931. /** @hidden */
  16932. export var colorVertexShader: {
  16933. name: string;
  16934. shader: string;
  16935. };
  16936. }
  16937. declare module BABYLON {
  16938. /**
  16939. * Line mesh
  16940. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16941. */
  16942. export class LinesMesh extends Mesh {
  16943. /**
  16944. * If vertex color should be applied to the mesh
  16945. */
  16946. useVertexColor?: boolean | undefined;
  16947. /**
  16948. * If vertex alpha should be applied to the mesh
  16949. */
  16950. useVertexAlpha?: boolean | undefined;
  16951. /**
  16952. * Color of the line (Default: White)
  16953. */
  16954. color: Color3;
  16955. /**
  16956. * Alpha of the line (Default: 1)
  16957. */
  16958. alpha: number;
  16959. /**
  16960. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16961. * This margin is expressed in world space coordinates, so its value may vary.
  16962. * Default value is 0.1
  16963. */
  16964. intersectionThreshold: number;
  16965. private _colorShader;
  16966. /**
  16967. * Creates a new LinesMesh
  16968. * @param name defines the name
  16969. * @param scene defines the hosting scene
  16970. * @param parent defines the parent mesh if any
  16971. * @param source defines the optional source LinesMesh used to clone data from
  16972. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16973. * When false, achieved by calling a clone(), also passing False.
  16974. * This will make creation of children, recursive.
  16975. * @param useVertexColor defines if this LinesMesh supports vertex color
  16976. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16977. */
  16978. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16979. /**
  16980. * If vertex color should be applied to the mesh
  16981. */
  16982. useVertexColor?: boolean | undefined,
  16983. /**
  16984. * If vertex alpha should be applied to the mesh
  16985. */
  16986. useVertexAlpha?: boolean | undefined);
  16987. private _addClipPlaneDefine;
  16988. private _removeClipPlaneDefine;
  16989. isReady(): boolean;
  16990. /**
  16991. * Returns the string "LineMesh"
  16992. */
  16993. getClassName(): string;
  16994. /**
  16995. * @hidden
  16996. */
  16997. /**
  16998. * @hidden
  16999. */
  17000. material: Material;
  17001. /**
  17002. * @hidden
  17003. */
  17004. readonly checkCollisions: boolean;
  17005. /** @hidden */
  17006. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17007. /** @hidden */
  17008. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17009. /**
  17010. * Disposes of the line mesh
  17011. * @param doNotRecurse If children should be disposed
  17012. */
  17013. dispose(doNotRecurse?: boolean): void;
  17014. /**
  17015. * Returns a new LineMesh object cloned from the current one.
  17016. */
  17017. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17018. /**
  17019. * Creates a new InstancedLinesMesh object from the mesh model.
  17020. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17021. * @param name defines the name of the new instance
  17022. * @returns a new InstancedLinesMesh
  17023. */
  17024. createInstance(name: string): InstancedLinesMesh;
  17025. }
  17026. /**
  17027. * Creates an instance based on a source LinesMesh
  17028. */
  17029. export class InstancedLinesMesh extends InstancedMesh {
  17030. /**
  17031. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17032. * This margin is expressed in world space coordinates, so its value may vary.
  17033. * Initilized with the intersectionThreshold value of the source LinesMesh
  17034. */
  17035. intersectionThreshold: number;
  17036. constructor(name: string, source: LinesMesh);
  17037. /**
  17038. * Returns the string "InstancedLinesMesh".
  17039. */
  17040. getClassName(): string;
  17041. }
  17042. }
  17043. declare module BABYLON {
  17044. /** @hidden */
  17045. export var linePixelShader: {
  17046. name: string;
  17047. shader: string;
  17048. };
  17049. }
  17050. declare module BABYLON {
  17051. /** @hidden */
  17052. export var lineVertexShader: {
  17053. name: string;
  17054. shader: string;
  17055. };
  17056. }
  17057. declare module BABYLON {
  17058. interface AbstractMesh {
  17059. /**
  17060. * Disables the mesh edge rendering mode
  17061. * @returns the currentAbstractMesh
  17062. */
  17063. disableEdgesRendering(): AbstractMesh;
  17064. /**
  17065. * Enables the edge rendering mode on the mesh.
  17066. * This mode makes the mesh edges visible
  17067. * @param epsilon defines the maximal distance between two angles to detect a face
  17068. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17069. * @returns the currentAbstractMesh
  17070. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17071. */
  17072. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17073. /**
  17074. * Gets the edgesRenderer associated with the mesh
  17075. */
  17076. edgesRenderer: Nullable<EdgesRenderer>;
  17077. }
  17078. interface LinesMesh {
  17079. /**
  17080. * Enables the edge rendering mode on the mesh.
  17081. * This mode makes the mesh edges visible
  17082. * @param epsilon defines the maximal distance between two angles to detect a face
  17083. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17084. * @returns the currentAbstractMesh
  17085. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17086. */
  17087. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17088. }
  17089. interface InstancedLinesMesh {
  17090. /**
  17091. * Enables the edge rendering mode on the mesh.
  17092. * This mode makes the mesh edges visible
  17093. * @param epsilon defines the maximal distance between two angles to detect a face
  17094. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17095. * @returns the current InstancedLinesMesh
  17096. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17097. */
  17098. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17099. }
  17100. /**
  17101. * Defines the minimum contract an Edges renderer should follow.
  17102. */
  17103. export interface IEdgesRenderer extends IDisposable {
  17104. /**
  17105. * Gets or sets a boolean indicating if the edgesRenderer is active
  17106. */
  17107. isEnabled: boolean;
  17108. /**
  17109. * Renders the edges of the attached mesh,
  17110. */
  17111. render(): void;
  17112. /**
  17113. * Checks wether or not the edges renderer is ready to render.
  17114. * @return true if ready, otherwise false.
  17115. */
  17116. isReady(): boolean;
  17117. }
  17118. /**
  17119. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17120. */
  17121. export class EdgesRenderer implements IEdgesRenderer {
  17122. /**
  17123. * Define the size of the edges with an orthographic camera
  17124. */
  17125. edgesWidthScalerForOrthographic: number;
  17126. /**
  17127. * Define the size of the edges with a perspective camera
  17128. */
  17129. edgesWidthScalerForPerspective: number;
  17130. protected _source: AbstractMesh;
  17131. protected _linesPositions: number[];
  17132. protected _linesNormals: number[];
  17133. protected _linesIndices: number[];
  17134. protected _epsilon: number;
  17135. protected _indicesCount: number;
  17136. protected _lineShader: ShaderMaterial;
  17137. protected _ib: WebGLBuffer;
  17138. protected _buffers: {
  17139. [key: string]: Nullable<VertexBuffer>;
  17140. };
  17141. protected _checkVerticesInsteadOfIndices: boolean;
  17142. private _meshRebuildObserver;
  17143. private _meshDisposeObserver;
  17144. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17145. isEnabled: boolean;
  17146. /**
  17147. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17148. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17149. * @param source Mesh used to create edges
  17150. * @param epsilon sum of angles in adjacency to check for edge
  17151. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17152. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17153. */
  17154. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17155. protected _prepareRessources(): void;
  17156. /** @hidden */
  17157. _rebuild(): void;
  17158. /**
  17159. * Releases the required resources for the edges renderer
  17160. */
  17161. dispose(): void;
  17162. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17163. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17164. /**
  17165. * Checks if the pair of p0 and p1 is en edge
  17166. * @param faceIndex
  17167. * @param edge
  17168. * @param faceNormals
  17169. * @param p0
  17170. * @param p1
  17171. * @private
  17172. */
  17173. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17174. /**
  17175. * push line into the position, normal and index buffer
  17176. * @protected
  17177. */
  17178. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17179. /**
  17180. * Generates lines edges from adjacencjes
  17181. * @private
  17182. */
  17183. _generateEdgesLines(): void;
  17184. /**
  17185. * Checks wether or not the edges renderer is ready to render.
  17186. * @return true if ready, otherwise false.
  17187. */
  17188. isReady(): boolean;
  17189. /**
  17190. * Renders the edges of the attached mesh,
  17191. */
  17192. render(): void;
  17193. }
  17194. /**
  17195. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17196. */
  17197. export class LineEdgesRenderer extends EdgesRenderer {
  17198. /**
  17199. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17200. * @param source LineMesh used to generate edges
  17201. * @param epsilon not important (specified angle for edge detection)
  17202. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17203. */
  17204. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17205. /**
  17206. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17207. */
  17208. _generateEdgesLines(): void;
  17209. }
  17210. }
  17211. declare module BABYLON {
  17212. /**
  17213. * This represents the object necessary to create a rendering group.
  17214. * This is exclusively used and created by the rendering manager.
  17215. * To modify the behavior, you use the available helpers in your scene or meshes.
  17216. * @hidden
  17217. */
  17218. export class RenderingGroup {
  17219. index: number;
  17220. private _scene;
  17221. private _opaqueSubMeshes;
  17222. private _transparentSubMeshes;
  17223. private _alphaTestSubMeshes;
  17224. private _depthOnlySubMeshes;
  17225. private _particleSystems;
  17226. private _spriteManagers;
  17227. private _opaqueSortCompareFn;
  17228. private _alphaTestSortCompareFn;
  17229. private _transparentSortCompareFn;
  17230. private _renderOpaque;
  17231. private _renderAlphaTest;
  17232. private _renderTransparent;
  17233. private _edgesRenderers;
  17234. onBeforeTransparentRendering: () => void;
  17235. /**
  17236. * Set the opaque sort comparison function.
  17237. * If null the sub meshes will be render in the order they were created
  17238. */
  17239. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17240. /**
  17241. * Set the alpha test sort comparison function.
  17242. * If null the sub meshes will be render in the order they were created
  17243. */
  17244. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17245. /**
  17246. * Set the transparent sort comparison function.
  17247. * If null the sub meshes will be render in the order they were created
  17248. */
  17249. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17250. /**
  17251. * Creates a new rendering group.
  17252. * @param index The rendering group index
  17253. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17254. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17255. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17256. */
  17257. 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>);
  17258. /**
  17259. * Render all the sub meshes contained in the group.
  17260. * @param customRenderFunction Used to override the default render behaviour of the group.
  17261. * @returns true if rendered some submeshes.
  17262. */
  17263. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17264. /**
  17265. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17266. * @param subMeshes The submeshes to render
  17267. */
  17268. private renderOpaqueSorted;
  17269. /**
  17270. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17271. * @param subMeshes The submeshes to render
  17272. */
  17273. private renderAlphaTestSorted;
  17274. /**
  17275. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17276. * @param subMeshes The submeshes to render
  17277. */
  17278. private renderTransparentSorted;
  17279. /**
  17280. * Renders the submeshes in a specified order.
  17281. * @param subMeshes The submeshes to sort before render
  17282. * @param sortCompareFn The comparison function use to sort
  17283. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17284. * @param transparent Specifies to activate blending if true
  17285. */
  17286. private static renderSorted;
  17287. /**
  17288. * Renders the submeshes in the order they were dispatched (no sort applied).
  17289. * @param subMeshes The submeshes to render
  17290. */
  17291. private static renderUnsorted;
  17292. /**
  17293. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17294. * are rendered back to front if in the same alpha index.
  17295. *
  17296. * @param a The first submesh
  17297. * @param b The second submesh
  17298. * @returns The result of the comparison
  17299. */
  17300. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17301. /**
  17302. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17303. * are rendered back to front.
  17304. *
  17305. * @param a The first submesh
  17306. * @param b The second submesh
  17307. * @returns The result of the comparison
  17308. */
  17309. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17310. /**
  17311. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17312. * are rendered front to back (prevent overdraw).
  17313. *
  17314. * @param a The first submesh
  17315. * @param b The second submesh
  17316. * @returns The result of the comparison
  17317. */
  17318. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17319. /**
  17320. * Resets the different lists of submeshes to prepare a new frame.
  17321. */
  17322. prepare(): void;
  17323. dispose(): void;
  17324. /**
  17325. * Inserts the submesh in its correct queue depending on its material.
  17326. * @param subMesh The submesh to dispatch
  17327. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17328. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17329. */
  17330. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17331. dispatchSprites(spriteManager: ISpriteManager): void;
  17332. dispatchParticles(particleSystem: IParticleSystem): void;
  17333. private _renderParticles;
  17334. private _renderSprites;
  17335. }
  17336. }
  17337. declare module BABYLON {
  17338. /**
  17339. * Interface describing the different options available in the rendering manager
  17340. * regarding Auto Clear between groups.
  17341. */
  17342. export interface IRenderingManagerAutoClearSetup {
  17343. /**
  17344. * Defines whether or not autoclear is enable.
  17345. */
  17346. autoClear: boolean;
  17347. /**
  17348. * Defines whether or not to autoclear the depth buffer.
  17349. */
  17350. depth: boolean;
  17351. /**
  17352. * Defines whether or not to autoclear the stencil buffer.
  17353. */
  17354. stencil: boolean;
  17355. }
  17356. /**
  17357. * This class is used by the onRenderingGroupObservable
  17358. */
  17359. export class RenderingGroupInfo {
  17360. /**
  17361. * The Scene that being rendered
  17362. */
  17363. scene: Scene;
  17364. /**
  17365. * The camera currently used for the rendering pass
  17366. */
  17367. camera: Nullable<Camera>;
  17368. /**
  17369. * The ID of the renderingGroup being processed
  17370. */
  17371. renderingGroupId: number;
  17372. }
  17373. /**
  17374. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17375. * It is enable to manage the different groups as well as the different necessary sort functions.
  17376. * This should not be used directly aside of the few static configurations
  17377. */
  17378. export class RenderingManager {
  17379. /**
  17380. * The max id used for rendering groups (not included)
  17381. */
  17382. static MAX_RENDERINGGROUPS: number;
  17383. /**
  17384. * The min id used for rendering groups (included)
  17385. */
  17386. static MIN_RENDERINGGROUPS: number;
  17387. /**
  17388. * Used to globally prevent autoclearing scenes.
  17389. */
  17390. static AUTOCLEAR: boolean;
  17391. /**
  17392. * @hidden
  17393. */
  17394. _useSceneAutoClearSetup: boolean;
  17395. private _scene;
  17396. private _renderingGroups;
  17397. private _depthStencilBufferAlreadyCleaned;
  17398. private _autoClearDepthStencil;
  17399. private _customOpaqueSortCompareFn;
  17400. private _customAlphaTestSortCompareFn;
  17401. private _customTransparentSortCompareFn;
  17402. private _renderingGroupInfo;
  17403. /**
  17404. * Instantiates a new rendering group for a particular scene
  17405. * @param scene Defines the scene the groups belongs to
  17406. */
  17407. constructor(scene: Scene);
  17408. private _clearDepthStencilBuffer;
  17409. /**
  17410. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17411. * @hidden
  17412. */
  17413. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17414. /**
  17415. * Resets the different information of the group to prepare a new frame
  17416. * @hidden
  17417. */
  17418. reset(): void;
  17419. /**
  17420. * Dispose and release the group and its associated resources.
  17421. * @hidden
  17422. */
  17423. dispose(): void;
  17424. /**
  17425. * Clear the info related to rendering groups preventing retention points during dispose.
  17426. */
  17427. freeRenderingGroups(): void;
  17428. private _prepareRenderingGroup;
  17429. /**
  17430. * Add a sprite manager to the rendering manager in order to render it this frame.
  17431. * @param spriteManager Define the sprite manager to render
  17432. */
  17433. dispatchSprites(spriteManager: ISpriteManager): void;
  17434. /**
  17435. * Add a particle system to the rendering manager in order to render it this frame.
  17436. * @param particleSystem Define the particle system to render
  17437. */
  17438. dispatchParticles(particleSystem: IParticleSystem): void;
  17439. /**
  17440. * Add a submesh to the manager in order to render it this frame
  17441. * @param subMesh The submesh to dispatch
  17442. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17443. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17444. */
  17445. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17446. /**
  17447. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17448. * This allowed control for front to back rendering or reversly depending of the special needs.
  17449. *
  17450. * @param renderingGroupId The rendering group id corresponding to its index
  17451. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17452. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17453. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17454. */
  17455. 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;
  17456. /**
  17457. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17458. *
  17459. * @param renderingGroupId The rendering group id corresponding to its index
  17460. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17461. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17462. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17463. */
  17464. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17465. /**
  17466. * Gets the current auto clear configuration for one rendering group of the rendering
  17467. * manager.
  17468. * @param index the rendering group index to get the information for
  17469. * @returns The auto clear setup for the requested rendering group
  17470. */
  17471. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17472. }
  17473. }
  17474. declare module BABYLON {
  17475. /**
  17476. * This Helps creating a texture that will be created from a camera in your scene.
  17477. * It is basically a dynamic texture that could be used to create special effects for instance.
  17478. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17479. */
  17480. export class RenderTargetTexture extends Texture {
  17481. isCube: boolean;
  17482. /**
  17483. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17484. */
  17485. static readonly REFRESHRATE_RENDER_ONCE: number;
  17486. /**
  17487. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17488. */
  17489. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17490. /**
  17491. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17492. * the central point of your effect and can save a lot of performances.
  17493. */
  17494. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17495. /**
  17496. * Use this predicate to dynamically define the list of mesh you want to render.
  17497. * If set, the renderList property will be overwritten.
  17498. */
  17499. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17500. private _renderList;
  17501. /**
  17502. * Use this list to define the list of mesh you want to render.
  17503. */
  17504. renderList: Nullable<Array<AbstractMesh>>;
  17505. private _hookArray;
  17506. /**
  17507. * Define if particles should be rendered in your texture.
  17508. */
  17509. renderParticles: boolean;
  17510. /**
  17511. * Define if sprites should be rendered in your texture.
  17512. */
  17513. renderSprites: boolean;
  17514. /**
  17515. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17516. */
  17517. coordinatesMode: number;
  17518. /**
  17519. * Define the camera used to render the texture.
  17520. */
  17521. activeCamera: Nullable<Camera>;
  17522. /**
  17523. * Override the render function of the texture with your own one.
  17524. */
  17525. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17526. /**
  17527. * Define if camera post processes should be use while rendering the texture.
  17528. */
  17529. useCameraPostProcesses: boolean;
  17530. /**
  17531. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17532. */
  17533. ignoreCameraViewport: boolean;
  17534. private _postProcessManager;
  17535. private _postProcesses;
  17536. private _resizeObserver;
  17537. /**
  17538. * An event triggered when the texture is unbind.
  17539. */
  17540. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17541. /**
  17542. * An event triggered when the texture is unbind.
  17543. */
  17544. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17545. private _onAfterUnbindObserver;
  17546. /**
  17547. * Set a after unbind callback in the texture.
  17548. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17549. */
  17550. onAfterUnbind: () => void;
  17551. /**
  17552. * An event triggered before rendering the texture
  17553. */
  17554. onBeforeRenderObservable: Observable<number>;
  17555. private _onBeforeRenderObserver;
  17556. /**
  17557. * Set a before render callback in the texture.
  17558. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17559. */
  17560. onBeforeRender: (faceIndex: number) => void;
  17561. /**
  17562. * An event triggered after rendering the texture
  17563. */
  17564. onAfterRenderObservable: Observable<number>;
  17565. private _onAfterRenderObserver;
  17566. /**
  17567. * Set a after render callback in the texture.
  17568. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17569. */
  17570. onAfterRender: (faceIndex: number) => void;
  17571. /**
  17572. * An event triggered after the texture clear
  17573. */
  17574. onClearObservable: Observable<Engine>;
  17575. private _onClearObserver;
  17576. /**
  17577. * Set a clear callback in the texture.
  17578. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17579. */
  17580. onClear: (Engine: Engine) => void;
  17581. /**
  17582. * Define the clear color of the Render Target if it should be different from the scene.
  17583. */
  17584. clearColor: Color4;
  17585. protected _size: number | {
  17586. width: number;
  17587. height: number;
  17588. };
  17589. protected _initialSizeParameter: number | {
  17590. width: number;
  17591. height: number;
  17592. } | {
  17593. ratio: number;
  17594. };
  17595. protected _sizeRatio: Nullable<number>;
  17596. /** @hidden */
  17597. _generateMipMaps: boolean;
  17598. protected _renderingManager: RenderingManager;
  17599. /** @hidden */
  17600. _waitingRenderList: string[];
  17601. protected _doNotChangeAspectRatio: boolean;
  17602. protected _currentRefreshId: number;
  17603. protected _refreshRate: number;
  17604. protected _textureMatrix: Matrix;
  17605. protected _samples: number;
  17606. protected _renderTargetOptions: RenderTargetCreationOptions;
  17607. /**
  17608. * Gets render target creation options that were used.
  17609. */
  17610. readonly renderTargetOptions: RenderTargetCreationOptions;
  17611. protected _engine: Engine;
  17612. protected _onRatioRescale(): void;
  17613. /**
  17614. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17615. * It must define where the camera used to render the texture is set
  17616. */
  17617. boundingBoxPosition: Vector3;
  17618. private _boundingBoxSize;
  17619. /**
  17620. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17621. * When defined, the cubemap will switch to local mode
  17622. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17623. * @example https://www.babylonjs-playground.com/#RNASML
  17624. */
  17625. boundingBoxSize: Vector3;
  17626. /**
  17627. * In case the RTT has been created with a depth texture, get the associated
  17628. * depth texture.
  17629. * Otherwise, return null.
  17630. */
  17631. depthStencilTexture: Nullable<InternalTexture>;
  17632. /**
  17633. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17634. * or used a shadow, depth texture...
  17635. * @param name The friendly name of the texture
  17636. * @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)
  17637. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17638. * @param generateMipMaps True if mip maps need to be generated after render.
  17639. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17640. * @param type The type of the buffer in the RTT (int, half float, float...)
  17641. * @param isCube True if a cube texture needs to be created
  17642. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17643. * @param generateDepthBuffer True to generate a depth buffer
  17644. * @param generateStencilBuffer True to generate a stencil buffer
  17645. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17646. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17647. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17648. */
  17649. constructor(name: string, size: number | {
  17650. width: number;
  17651. height: number;
  17652. } | {
  17653. ratio: number;
  17654. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17655. /**
  17656. * Creates a depth stencil texture.
  17657. * This is only available in WebGL 2 or with the depth texture extension available.
  17658. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17659. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17660. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17661. */
  17662. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17663. private _processSizeParameter;
  17664. /**
  17665. * Define the number of samples to use in case of MSAA.
  17666. * It defaults to one meaning no MSAA has been enabled.
  17667. */
  17668. samples: number;
  17669. /**
  17670. * Resets the refresh counter of the texture and start bak from scratch.
  17671. * Could be useful to regenerate the texture if it is setup to render only once.
  17672. */
  17673. resetRefreshCounter(): void;
  17674. /**
  17675. * Define the refresh rate of the texture or the rendering frequency.
  17676. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17677. */
  17678. refreshRate: number;
  17679. /**
  17680. * Adds a post process to the render target rendering passes.
  17681. * @param postProcess define the post process to add
  17682. */
  17683. addPostProcess(postProcess: PostProcess): void;
  17684. /**
  17685. * Clear all the post processes attached to the render target
  17686. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17687. */
  17688. clearPostProcesses(dispose?: boolean): void;
  17689. /**
  17690. * Remove one of the post process from the list of attached post processes to the texture
  17691. * @param postProcess define the post process to remove from the list
  17692. */
  17693. removePostProcess(postProcess: PostProcess): void;
  17694. /** @hidden */
  17695. _shouldRender(): boolean;
  17696. /**
  17697. * Gets the actual render size of the texture.
  17698. * @returns the width of the render size
  17699. */
  17700. getRenderSize(): number;
  17701. /**
  17702. * Gets the actual render width of the texture.
  17703. * @returns the width of the render size
  17704. */
  17705. getRenderWidth(): number;
  17706. /**
  17707. * Gets the actual render height of the texture.
  17708. * @returns the height of the render size
  17709. */
  17710. getRenderHeight(): number;
  17711. /**
  17712. * Get if the texture can be rescaled or not.
  17713. */
  17714. readonly canRescale: boolean;
  17715. /**
  17716. * Resize the texture using a ratio.
  17717. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17718. */
  17719. scale(ratio: number): void;
  17720. /**
  17721. * Get the texture reflection matrix used to rotate/transform the reflection.
  17722. * @returns the reflection matrix
  17723. */
  17724. getReflectionTextureMatrix(): Matrix;
  17725. /**
  17726. * Resize the texture to a new desired size.
  17727. * Be carrefull as it will recreate all the data in the new texture.
  17728. * @param size Define the new size. It can be:
  17729. * - a number for squared texture,
  17730. * - an object containing { width: number, height: number }
  17731. * - or an object containing a ratio { ratio: number }
  17732. */
  17733. resize(size: number | {
  17734. width: number;
  17735. height: number;
  17736. } | {
  17737. ratio: number;
  17738. }): void;
  17739. /**
  17740. * Renders all the objects from the render list into the texture.
  17741. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17742. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17743. */
  17744. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17745. private _bestReflectionRenderTargetDimension;
  17746. /**
  17747. * @hidden
  17748. * @param faceIndex face index to bind to if this is a cubetexture
  17749. */
  17750. _bindFrameBuffer(faceIndex?: number): void;
  17751. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17752. private renderToTarget;
  17753. /**
  17754. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17755. * This allowed control for front to back rendering or reversly depending of the special needs.
  17756. *
  17757. * @param renderingGroupId The rendering group id corresponding to its index
  17758. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17759. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17760. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17761. */
  17762. 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;
  17763. /**
  17764. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17765. *
  17766. * @param renderingGroupId The rendering group id corresponding to its index
  17767. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17768. */
  17769. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17770. /**
  17771. * Clones the texture.
  17772. * @returns the cloned texture
  17773. */
  17774. clone(): RenderTargetTexture;
  17775. /**
  17776. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17777. * @returns The JSON representation of the texture
  17778. */
  17779. serialize(): any;
  17780. /**
  17781. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17782. */
  17783. disposeFramebufferObjects(): void;
  17784. /**
  17785. * Dispose the texture and release its associated resources.
  17786. */
  17787. dispose(): void;
  17788. /** @hidden */
  17789. _rebuild(): void;
  17790. /**
  17791. * Clear the info related to rendering groups preventing retention point in material dispose.
  17792. */
  17793. freeRenderingGroups(): void;
  17794. /**
  17795. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17796. * @returns the view count
  17797. */
  17798. getViewCount(): number;
  17799. }
  17800. }
  17801. declare module BABYLON {
  17802. /**
  17803. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17804. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17805. * You can then easily use it as a reflectionTexture on a flat surface.
  17806. * In case the surface is not a plane, please consider relying on reflection probes.
  17807. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17808. */
  17809. export class MirrorTexture extends RenderTargetTexture {
  17810. private scene;
  17811. /**
  17812. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17813. * 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.
  17814. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17815. */
  17816. mirrorPlane: Plane;
  17817. /**
  17818. * Define the blur ratio used to blur the reflection if needed.
  17819. */
  17820. blurRatio: number;
  17821. /**
  17822. * Define the adaptive blur kernel used to blur the reflection if needed.
  17823. * This will autocompute the closest best match for the `blurKernel`
  17824. */
  17825. adaptiveBlurKernel: number;
  17826. /**
  17827. * Define the blur kernel used to blur the reflection if needed.
  17828. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17829. */
  17830. blurKernel: number;
  17831. /**
  17832. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17833. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17834. */
  17835. blurKernelX: number;
  17836. /**
  17837. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17838. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17839. */
  17840. blurKernelY: number;
  17841. private _autoComputeBlurKernel;
  17842. protected _onRatioRescale(): void;
  17843. private _updateGammaSpace;
  17844. private _imageProcessingConfigChangeObserver;
  17845. private _transformMatrix;
  17846. private _mirrorMatrix;
  17847. private _savedViewMatrix;
  17848. private _blurX;
  17849. private _blurY;
  17850. private _adaptiveBlurKernel;
  17851. private _blurKernelX;
  17852. private _blurKernelY;
  17853. private _blurRatio;
  17854. /**
  17855. * Instantiates a Mirror Texture.
  17856. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17857. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17858. * You can then easily use it as a reflectionTexture on a flat surface.
  17859. * In case the surface is not a plane, please consider relying on reflection probes.
  17860. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17861. * @param name
  17862. * @param size
  17863. * @param scene
  17864. * @param generateMipMaps
  17865. * @param type
  17866. * @param samplingMode
  17867. * @param generateDepthBuffer
  17868. */
  17869. constructor(name: string, size: number | {
  17870. width: number;
  17871. height: number;
  17872. } | {
  17873. ratio: number;
  17874. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17875. private _preparePostProcesses;
  17876. /**
  17877. * Clone the mirror texture.
  17878. * @returns the cloned texture
  17879. */
  17880. clone(): MirrorTexture;
  17881. /**
  17882. * Serialize the texture to a JSON representation you could use in Parse later on
  17883. * @returns the serialized JSON representation
  17884. */
  17885. serialize(): any;
  17886. /**
  17887. * Dispose the texture and release its associated resources.
  17888. */
  17889. dispose(): void;
  17890. }
  17891. }
  17892. declare module BABYLON {
  17893. /**
  17894. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17895. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17896. */
  17897. export class Texture extends BaseTexture {
  17898. /** @hidden */
  17899. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17900. /** @hidden */
  17901. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17902. /** @hidden */
  17903. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17904. /** nearest is mag = nearest and min = nearest and mip = linear */
  17905. static readonly NEAREST_SAMPLINGMODE: number;
  17906. /** nearest is mag = nearest and min = nearest and mip = linear */
  17907. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17908. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17909. static readonly BILINEAR_SAMPLINGMODE: number;
  17910. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17911. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17912. /** Trilinear is mag = linear and min = linear and mip = linear */
  17913. static readonly TRILINEAR_SAMPLINGMODE: number;
  17914. /** Trilinear is mag = linear and min = linear and mip = linear */
  17915. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17916. /** mag = nearest and min = nearest and mip = nearest */
  17917. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17918. /** mag = nearest and min = linear and mip = nearest */
  17919. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17920. /** mag = nearest and min = linear and mip = linear */
  17921. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17922. /** mag = nearest and min = linear and mip = none */
  17923. static readonly NEAREST_LINEAR: number;
  17924. /** mag = nearest and min = nearest and mip = none */
  17925. static readonly NEAREST_NEAREST: number;
  17926. /** mag = linear and min = nearest and mip = nearest */
  17927. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17928. /** mag = linear and min = nearest and mip = linear */
  17929. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17930. /** mag = linear and min = linear and mip = none */
  17931. static readonly LINEAR_LINEAR: number;
  17932. /** mag = linear and min = nearest and mip = none */
  17933. static readonly LINEAR_NEAREST: number;
  17934. /** Explicit coordinates mode */
  17935. static readonly EXPLICIT_MODE: number;
  17936. /** Spherical coordinates mode */
  17937. static readonly SPHERICAL_MODE: number;
  17938. /** Planar coordinates mode */
  17939. static readonly PLANAR_MODE: number;
  17940. /** Cubic coordinates mode */
  17941. static readonly CUBIC_MODE: number;
  17942. /** Projection coordinates mode */
  17943. static readonly PROJECTION_MODE: number;
  17944. /** Inverse Cubic coordinates mode */
  17945. static readonly SKYBOX_MODE: number;
  17946. /** Inverse Cubic coordinates mode */
  17947. static readonly INVCUBIC_MODE: number;
  17948. /** Equirectangular coordinates mode */
  17949. static readonly EQUIRECTANGULAR_MODE: number;
  17950. /** Equirectangular Fixed coordinates mode */
  17951. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17952. /** Equirectangular Fixed Mirrored coordinates mode */
  17953. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17954. /** Texture is not repeating outside of 0..1 UVs */
  17955. static readonly CLAMP_ADDRESSMODE: number;
  17956. /** Texture is repeating outside of 0..1 UVs */
  17957. static readonly WRAP_ADDRESSMODE: number;
  17958. /** Texture is repeating and mirrored */
  17959. static readonly MIRROR_ADDRESSMODE: number;
  17960. /**
  17961. * 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
  17962. */
  17963. static UseSerializedUrlIfAny: boolean;
  17964. /**
  17965. * Define the url of the texture.
  17966. */
  17967. url: Nullable<string>;
  17968. /**
  17969. * Define an offset on the texture to offset the u coordinates of the UVs
  17970. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17971. */
  17972. uOffset: number;
  17973. /**
  17974. * Define an offset on the texture to offset the v coordinates of the UVs
  17975. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17976. */
  17977. vOffset: number;
  17978. /**
  17979. * Define an offset on the texture to scale the u coordinates of the UVs
  17980. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17981. */
  17982. uScale: number;
  17983. /**
  17984. * Define an offset on the texture to scale the v coordinates of the UVs
  17985. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17986. */
  17987. vScale: number;
  17988. /**
  17989. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17990. * @see http://doc.babylonjs.com/how_to/more_materials
  17991. */
  17992. uAng: number;
  17993. /**
  17994. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17995. * @see http://doc.babylonjs.com/how_to/more_materials
  17996. */
  17997. vAng: number;
  17998. /**
  17999. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18000. * @see http://doc.babylonjs.com/how_to/more_materials
  18001. */
  18002. wAng: number;
  18003. /**
  18004. * Defines the center of rotation (U)
  18005. */
  18006. uRotationCenter: number;
  18007. /**
  18008. * Defines the center of rotation (V)
  18009. */
  18010. vRotationCenter: number;
  18011. /**
  18012. * Defines the center of rotation (W)
  18013. */
  18014. wRotationCenter: number;
  18015. /**
  18016. * Are mip maps generated for this texture or not.
  18017. */
  18018. readonly noMipmap: boolean;
  18019. /**
  18020. * List of inspectable custom properties (used by the Inspector)
  18021. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18022. */
  18023. inspectableCustomProperties: IInspectable[];
  18024. private _noMipmap;
  18025. /** @hidden */
  18026. _invertY: boolean;
  18027. private _rowGenerationMatrix;
  18028. private _cachedTextureMatrix;
  18029. private _projectionModeMatrix;
  18030. private _t0;
  18031. private _t1;
  18032. private _t2;
  18033. private _cachedUOffset;
  18034. private _cachedVOffset;
  18035. private _cachedUScale;
  18036. private _cachedVScale;
  18037. private _cachedUAng;
  18038. private _cachedVAng;
  18039. private _cachedWAng;
  18040. private _cachedProjectionMatrixId;
  18041. private _cachedCoordinatesMode;
  18042. /** @hidden */
  18043. protected _initialSamplingMode: number;
  18044. /** @hidden */
  18045. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18046. private _deleteBuffer;
  18047. protected _format: Nullable<number>;
  18048. private _delayedOnLoad;
  18049. private _delayedOnError;
  18050. /**
  18051. * Observable triggered once the texture has been loaded.
  18052. */
  18053. onLoadObservable: Observable<Texture>;
  18054. protected _isBlocking: boolean;
  18055. /**
  18056. * Is the texture preventing material to render while loading.
  18057. * If false, a default texture will be used instead of the loading one during the preparation step.
  18058. */
  18059. isBlocking: boolean;
  18060. /**
  18061. * Get the current sampling mode associated with the texture.
  18062. */
  18063. readonly samplingMode: number;
  18064. /**
  18065. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18066. */
  18067. readonly invertY: boolean;
  18068. /**
  18069. * Instantiates a new texture.
  18070. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18071. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18072. * @param url define the url of the picture to load as a texture
  18073. * @param scene define the scene the texture will belong to
  18074. * @param noMipmap define if the texture will require mip maps or not
  18075. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18076. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18077. * @param onLoad define a callback triggered when the texture has been loaded
  18078. * @param onError define a callback triggered when an error occurred during the loading session
  18079. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18080. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18081. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18082. */
  18083. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18084. /**
  18085. * Update the url (and optional buffer) of this texture if url was null during construction.
  18086. * @param url the url of the texture
  18087. * @param buffer the buffer of the texture (defaults to null)
  18088. * @param onLoad callback called when the texture is loaded (defaults to null)
  18089. */
  18090. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18091. /**
  18092. * Finish the loading sequence of a texture flagged as delayed load.
  18093. * @hidden
  18094. */
  18095. delayLoad(): void;
  18096. private _prepareRowForTextureGeneration;
  18097. /**
  18098. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18099. * @returns the transform matrix of the texture.
  18100. */
  18101. getTextureMatrix(): Matrix;
  18102. /**
  18103. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18104. * @returns The reflection texture transform
  18105. */
  18106. getReflectionTextureMatrix(): Matrix;
  18107. /**
  18108. * Clones the texture.
  18109. * @returns the cloned texture
  18110. */
  18111. clone(): Texture;
  18112. /**
  18113. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18114. * @returns The JSON representation of the texture
  18115. */
  18116. serialize(): any;
  18117. /**
  18118. * Get the current class name of the texture useful for serialization or dynamic coding.
  18119. * @returns "Texture"
  18120. */
  18121. getClassName(): string;
  18122. /**
  18123. * Dispose the texture and release its associated resources.
  18124. */
  18125. dispose(): void;
  18126. /**
  18127. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18128. * @param parsedTexture Define the JSON representation of the texture
  18129. * @param scene Define the scene the parsed texture should be instantiated in
  18130. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18131. * @returns The parsed texture if successful
  18132. */
  18133. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18134. /**
  18135. * Creates a texture from its base 64 representation.
  18136. * @param data Define the base64 payload without the data: prefix
  18137. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18138. * @param scene Define the scene the texture should belong to
  18139. * @param noMipmap Forces the texture to not create mip map information if true
  18140. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18141. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18142. * @param onLoad define a callback triggered when the texture has been loaded
  18143. * @param onError define a callback triggered when an error occurred during the loading session
  18144. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18145. * @returns the created texture
  18146. */
  18147. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18148. /**
  18149. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18150. * @param data Define the base64 payload without the data: prefix
  18151. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18152. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18153. * @param scene Define the scene the texture should belong to
  18154. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18155. * @param noMipmap Forces the texture to not create mip map information if true
  18156. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18157. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18158. * @param onLoad define a callback triggered when the texture has been loaded
  18159. * @param onError define a callback triggered when an error occurred during the loading session
  18160. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18161. * @returns the created texture
  18162. */
  18163. 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;
  18164. }
  18165. }
  18166. declare module BABYLON {
  18167. /**
  18168. * Raw texture can help creating a texture directly from an array of data.
  18169. * This can be super useful if you either get the data from an uncompressed source or
  18170. * if you wish to create your texture pixel by pixel.
  18171. */
  18172. export class RawTexture extends Texture {
  18173. /**
  18174. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18175. */
  18176. format: number;
  18177. private _engine;
  18178. /**
  18179. * Instantiates a new RawTexture.
  18180. * Raw texture can help creating a texture directly from an array of data.
  18181. * This can be super useful if you either get the data from an uncompressed source or
  18182. * if you wish to create your texture pixel by pixel.
  18183. * @param data define the array of data to use to create the texture
  18184. * @param width define the width of the texture
  18185. * @param height define the height of the texture
  18186. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18187. * @param scene define the scene the texture belongs to
  18188. * @param generateMipMaps define whether mip maps should be generated or not
  18189. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18190. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18191. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18192. */
  18193. constructor(data: ArrayBufferView, width: number, height: number,
  18194. /**
  18195. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18196. */
  18197. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18198. /**
  18199. * Updates the texture underlying data.
  18200. * @param data Define the new data of the texture
  18201. */
  18202. update(data: ArrayBufferView): void;
  18203. /**
  18204. * Creates a luminance texture from some data.
  18205. * @param data Define the texture data
  18206. * @param width Define the width of the texture
  18207. * @param height Define the height of the texture
  18208. * @param scene Define the scene the texture belongs to
  18209. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18210. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18211. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18212. * @returns the luminance texture
  18213. */
  18214. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18215. /**
  18216. * Creates a luminance alpha texture from some data.
  18217. * @param data Define the texture data
  18218. * @param width Define the width of the texture
  18219. * @param height Define the height of the texture
  18220. * @param scene Define the scene the texture belongs to
  18221. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18222. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18223. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18224. * @returns the luminance alpha texture
  18225. */
  18226. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18227. /**
  18228. * Creates an alpha texture from some data.
  18229. * @param data Define the texture data
  18230. * @param width Define the width of the texture
  18231. * @param height Define the height of the texture
  18232. * @param scene Define the scene the texture belongs to
  18233. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18234. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18235. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18236. * @returns the alpha texture
  18237. */
  18238. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18239. /**
  18240. * Creates a RGB texture from some data.
  18241. * @param data Define the texture data
  18242. * @param width Define the width of the texture
  18243. * @param height Define the height of the texture
  18244. * @param scene Define the scene the texture belongs to
  18245. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18246. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18247. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18248. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18249. * @returns the RGB alpha texture
  18250. */
  18251. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18252. /**
  18253. * Creates a RGBA texture from some data.
  18254. * @param data Define the texture data
  18255. * @param width Define the width of the texture
  18256. * @param height Define the height of the texture
  18257. * @param scene Define the scene the texture belongs to
  18258. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18259. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18260. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18261. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18262. * @returns the RGBA texture
  18263. */
  18264. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18265. /**
  18266. * Creates a R texture from some data.
  18267. * @param data Define the texture data
  18268. * @param width Define the width of the texture
  18269. * @param height Define the height of the texture
  18270. * @param scene Define the scene the texture belongs to
  18271. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18272. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18273. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18274. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18275. * @returns the R texture
  18276. */
  18277. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18278. }
  18279. }
  18280. declare module BABYLON {
  18281. /**
  18282. * Defines a runtime animation
  18283. */
  18284. export class RuntimeAnimation {
  18285. private _events;
  18286. /**
  18287. * The current frame of the runtime animation
  18288. */
  18289. private _currentFrame;
  18290. /**
  18291. * The animation used by the runtime animation
  18292. */
  18293. private _animation;
  18294. /**
  18295. * The target of the runtime animation
  18296. */
  18297. private _target;
  18298. /**
  18299. * The initiating animatable
  18300. */
  18301. private _host;
  18302. /**
  18303. * The original value of the runtime animation
  18304. */
  18305. private _originalValue;
  18306. /**
  18307. * The original blend value of the runtime animation
  18308. */
  18309. private _originalBlendValue;
  18310. /**
  18311. * The offsets cache of the runtime animation
  18312. */
  18313. private _offsetsCache;
  18314. /**
  18315. * The high limits cache of the runtime animation
  18316. */
  18317. private _highLimitsCache;
  18318. /**
  18319. * Specifies if the runtime animation has been stopped
  18320. */
  18321. private _stopped;
  18322. /**
  18323. * The blending factor of the runtime animation
  18324. */
  18325. private _blendingFactor;
  18326. /**
  18327. * The BabylonJS scene
  18328. */
  18329. private _scene;
  18330. /**
  18331. * The current value of the runtime animation
  18332. */
  18333. private _currentValue;
  18334. /** @hidden */
  18335. _workValue: any;
  18336. /**
  18337. * The active target of the runtime animation
  18338. */
  18339. private _activeTarget;
  18340. /**
  18341. * The target path of the runtime animation
  18342. */
  18343. private _targetPath;
  18344. /**
  18345. * The weight of the runtime animation
  18346. */
  18347. private _weight;
  18348. /**
  18349. * The ratio offset of the runtime animation
  18350. */
  18351. private _ratioOffset;
  18352. /**
  18353. * The previous delay of the runtime animation
  18354. */
  18355. private _previousDelay;
  18356. /**
  18357. * The previous ratio of the runtime animation
  18358. */
  18359. private _previousRatio;
  18360. /**
  18361. * Gets the current frame of the runtime animation
  18362. */
  18363. readonly currentFrame: number;
  18364. /**
  18365. * Gets the weight of the runtime animation
  18366. */
  18367. readonly weight: number;
  18368. /**
  18369. * Gets the current value of the runtime animation
  18370. */
  18371. readonly currentValue: any;
  18372. /**
  18373. * Gets the target path of the runtime animation
  18374. */
  18375. readonly targetPath: string;
  18376. /**
  18377. * Gets the actual target of the runtime animation
  18378. */
  18379. readonly target: any;
  18380. /**
  18381. * Create a new RuntimeAnimation object
  18382. * @param target defines the target of the animation
  18383. * @param animation defines the source animation object
  18384. * @param scene defines the hosting scene
  18385. * @param host defines the initiating Animatable
  18386. */
  18387. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18388. /**
  18389. * Gets the animation from the runtime animation
  18390. */
  18391. readonly animation: Animation;
  18392. /**
  18393. * Resets the runtime animation to the beginning
  18394. * @param restoreOriginal defines whether to restore the target property to the original value
  18395. */
  18396. reset(restoreOriginal?: boolean): void;
  18397. /**
  18398. * Specifies if the runtime animation is stopped
  18399. * @returns Boolean specifying if the runtime animation is stopped
  18400. */
  18401. isStopped(): boolean;
  18402. /**
  18403. * Disposes of the runtime animation
  18404. */
  18405. dispose(): void;
  18406. /**
  18407. * Interpolates the animation from the current frame
  18408. * @param currentFrame The frame to interpolate the animation to
  18409. * @param repeatCount The number of times that the animation should loop
  18410. * @param loopMode The type of looping mode to use
  18411. * @param offsetValue Animation offset value
  18412. * @param highLimitValue The high limit value
  18413. * @returns The interpolated value
  18414. */
  18415. private _interpolate;
  18416. /**
  18417. * Apply the interpolated value to the target
  18418. * @param currentValue defines the value computed by the animation
  18419. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18420. */
  18421. setValue(currentValue: any, weight?: number): void;
  18422. private _setValue;
  18423. /**
  18424. * Gets the loop pmode of the runtime animation
  18425. * @returns Loop Mode
  18426. */
  18427. private _getCorrectLoopMode;
  18428. /**
  18429. * Move the current animation to a given frame
  18430. * @param frame defines the frame to move to
  18431. */
  18432. goToFrame(frame: number): void;
  18433. /**
  18434. * @hidden Internal use only
  18435. */
  18436. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18437. /**
  18438. * Execute the current animation
  18439. * @param delay defines the delay to add to the current frame
  18440. * @param from defines the lower bound of the animation range
  18441. * @param to defines the upper bound of the animation range
  18442. * @param loop defines if the current animation must loop
  18443. * @param speedRatio defines the current speed ratio
  18444. * @param weight defines the weight of the animation (default is -1 so no weight)
  18445. * @param onLoop optional callback called when animation loops
  18446. * @returns a boolean indicating if the animation is running
  18447. */
  18448. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18449. }
  18450. }
  18451. declare module BABYLON {
  18452. /**
  18453. * Class used to store an actual running animation
  18454. */
  18455. export class Animatable {
  18456. /** defines the target object */
  18457. target: any;
  18458. /** defines the starting frame number (default is 0) */
  18459. fromFrame: number;
  18460. /** defines the ending frame number (default is 100) */
  18461. toFrame: number;
  18462. /** defines if the animation must loop (default is false) */
  18463. loopAnimation: boolean;
  18464. /** defines a callback to call when animation ends if it is not looping */
  18465. onAnimationEnd?: (() => void) | null | undefined;
  18466. /** defines a callback to call when animation loops */
  18467. onAnimationLoop?: (() => void) | null | undefined;
  18468. private _localDelayOffset;
  18469. private _pausedDelay;
  18470. private _runtimeAnimations;
  18471. private _paused;
  18472. private _scene;
  18473. private _speedRatio;
  18474. private _weight;
  18475. private _syncRoot;
  18476. /**
  18477. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18478. * This will only apply for non looping animation (default is true)
  18479. */
  18480. disposeOnEnd: boolean;
  18481. /**
  18482. * Gets a boolean indicating if the animation has started
  18483. */
  18484. animationStarted: boolean;
  18485. /**
  18486. * Observer raised when the animation ends
  18487. */
  18488. onAnimationEndObservable: Observable<Animatable>;
  18489. /**
  18490. * Observer raised when the animation loops
  18491. */
  18492. onAnimationLoopObservable: Observable<Animatable>;
  18493. /**
  18494. * Gets the root Animatable used to synchronize and normalize animations
  18495. */
  18496. readonly syncRoot: Animatable;
  18497. /**
  18498. * Gets the current frame of the first RuntimeAnimation
  18499. * Used to synchronize Animatables
  18500. */
  18501. readonly masterFrame: number;
  18502. /**
  18503. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18504. */
  18505. weight: number;
  18506. /**
  18507. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18508. */
  18509. speedRatio: number;
  18510. /**
  18511. * Creates a new Animatable
  18512. * @param scene defines the hosting scene
  18513. * @param target defines the target object
  18514. * @param fromFrame defines the starting frame number (default is 0)
  18515. * @param toFrame defines the ending frame number (default is 100)
  18516. * @param loopAnimation defines if the animation must loop (default is false)
  18517. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18518. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18519. * @param animations defines a group of animation to add to the new Animatable
  18520. * @param onAnimationLoop defines a callback to call when animation loops
  18521. */
  18522. constructor(scene: Scene,
  18523. /** defines the target object */
  18524. target: any,
  18525. /** defines the starting frame number (default is 0) */
  18526. fromFrame?: number,
  18527. /** defines the ending frame number (default is 100) */
  18528. toFrame?: number,
  18529. /** defines if the animation must loop (default is false) */
  18530. loopAnimation?: boolean, speedRatio?: number,
  18531. /** defines a callback to call when animation ends if it is not looping */
  18532. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18533. /** defines a callback to call when animation loops */
  18534. onAnimationLoop?: (() => void) | null | undefined);
  18535. /**
  18536. * Synchronize and normalize current Animatable with a source Animatable
  18537. * This is useful when using animation weights and when animations are not of the same length
  18538. * @param root defines the root Animatable to synchronize with
  18539. * @returns the current Animatable
  18540. */
  18541. syncWith(root: Animatable): Animatable;
  18542. /**
  18543. * Gets the list of runtime animations
  18544. * @returns an array of RuntimeAnimation
  18545. */
  18546. getAnimations(): RuntimeAnimation[];
  18547. /**
  18548. * Adds more animations to the current animatable
  18549. * @param target defines the target of the animations
  18550. * @param animations defines the new animations to add
  18551. */
  18552. appendAnimations(target: any, animations: Animation[]): void;
  18553. /**
  18554. * Gets the source animation for a specific property
  18555. * @param property defines the propertyu to look for
  18556. * @returns null or the source animation for the given property
  18557. */
  18558. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18559. /**
  18560. * Gets the runtime animation for a specific property
  18561. * @param property defines the propertyu to look for
  18562. * @returns null or the runtime animation for the given property
  18563. */
  18564. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18565. /**
  18566. * Resets the animatable to its original state
  18567. */
  18568. reset(): void;
  18569. /**
  18570. * Allows the animatable to blend with current running animations
  18571. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18572. * @param blendingSpeed defines the blending speed to use
  18573. */
  18574. enableBlending(blendingSpeed: number): void;
  18575. /**
  18576. * Disable animation blending
  18577. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18578. */
  18579. disableBlending(): void;
  18580. /**
  18581. * Jump directly to a given frame
  18582. * @param frame defines the frame to jump to
  18583. */
  18584. goToFrame(frame: number): void;
  18585. /**
  18586. * Pause the animation
  18587. */
  18588. pause(): void;
  18589. /**
  18590. * Restart the animation
  18591. */
  18592. restart(): void;
  18593. private _raiseOnAnimationEnd;
  18594. /**
  18595. * Stop and delete the current animation
  18596. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18597. * @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)
  18598. */
  18599. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18600. /**
  18601. * Wait asynchronously for the animation to end
  18602. * @returns a promise which will be fullfilled when the animation ends
  18603. */
  18604. waitAsync(): Promise<Animatable>;
  18605. /** @hidden */
  18606. _animate(delay: number): boolean;
  18607. }
  18608. interface Scene {
  18609. /** @hidden */
  18610. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18611. /** @hidden */
  18612. _processLateAnimationBindingsForMatrices(holder: {
  18613. totalWeight: number;
  18614. animations: RuntimeAnimation[];
  18615. originalValue: Matrix;
  18616. }): any;
  18617. /** @hidden */
  18618. _processLateAnimationBindingsForQuaternions(holder: {
  18619. totalWeight: number;
  18620. animations: RuntimeAnimation[];
  18621. originalValue: Quaternion;
  18622. }, refQuaternion: Quaternion): Quaternion;
  18623. /** @hidden */
  18624. _processLateAnimationBindings(): void;
  18625. /**
  18626. * Will start the animation sequence of a given target
  18627. * @param target defines the target
  18628. * @param from defines from which frame should animation start
  18629. * @param to defines until which frame should animation run.
  18630. * @param weight defines the weight to apply to the animation (1.0 by default)
  18631. * @param loop defines if the animation loops
  18632. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18633. * @param onAnimationEnd defines the function to be executed when the animation ends
  18634. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18635. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18636. * @param onAnimationLoop defines the callback to call when an animation loops
  18637. * @returns the animatable object created for this animation
  18638. */
  18639. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18640. /**
  18641. * Will start the animation sequence of a given target
  18642. * @param target defines the target
  18643. * @param from defines from which frame should animation start
  18644. * @param to defines until which frame should animation run.
  18645. * @param loop defines if the animation loops
  18646. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18647. * @param onAnimationEnd defines the function to be executed when the animation ends
  18648. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18649. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18650. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18651. * @param onAnimationLoop defines the callback to call when an animation loops
  18652. * @returns the animatable object created for this animation
  18653. */
  18654. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18655. /**
  18656. * Will start the animation sequence of a given target and its hierarchy
  18657. * @param target defines the target
  18658. * @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.
  18659. * @param from defines from which frame should animation start
  18660. * @param to defines until which frame should animation run.
  18661. * @param loop defines if the animation loops
  18662. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18663. * @param onAnimationEnd defines the function to be executed when the animation ends
  18664. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18665. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18666. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18667. * @param onAnimationLoop defines the callback to call when an animation loops
  18668. * @returns the list of created animatables
  18669. */
  18670. 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[];
  18671. /**
  18672. * Begin a new animation on a given node
  18673. * @param target defines the target where the animation will take place
  18674. * @param animations defines the list of animations to start
  18675. * @param from defines the initial value
  18676. * @param to defines the final value
  18677. * @param loop defines if you want animation to loop (off by default)
  18678. * @param speedRatio defines the speed ratio to apply to all animations
  18679. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18680. * @param onAnimationLoop defines the callback to call when an animation loops
  18681. * @returns the list of created animatables
  18682. */
  18683. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18684. /**
  18685. * Begin a new animation on a given node and its hierarchy
  18686. * @param target defines the root node where the animation will take place
  18687. * @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.
  18688. * @param animations defines the list of animations to start
  18689. * @param from defines the initial value
  18690. * @param to defines the final value
  18691. * @param loop defines if you want animation to loop (off by default)
  18692. * @param speedRatio defines the speed ratio to apply to all animations
  18693. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18694. * @param onAnimationLoop defines the callback to call when an animation loops
  18695. * @returns the list of animatables created for all nodes
  18696. */
  18697. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18698. /**
  18699. * Gets the animatable associated with a specific target
  18700. * @param target defines the target of the animatable
  18701. * @returns the required animatable if found
  18702. */
  18703. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18704. /**
  18705. * Gets all animatables associated with a given target
  18706. * @param target defines the target to look animatables for
  18707. * @returns an array of Animatables
  18708. */
  18709. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18710. /**
  18711. * Will stop the animation of the given target
  18712. * @param target - the target
  18713. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18714. * @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)
  18715. */
  18716. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18717. /**
  18718. * Stops and removes all animations that have been applied to the scene
  18719. */
  18720. stopAllAnimations(): void;
  18721. }
  18722. interface Bone {
  18723. /**
  18724. * Copy an animation range from another bone
  18725. * @param source defines the source bone
  18726. * @param rangeName defines the range name to copy
  18727. * @param frameOffset defines the frame offset
  18728. * @param rescaleAsRequired defines if rescaling must be applied if required
  18729. * @param skelDimensionsRatio defines the scaling ratio
  18730. * @returns true if operation was successful
  18731. */
  18732. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18733. }
  18734. }
  18735. declare module BABYLON {
  18736. /**
  18737. * Class used to handle skinning animations
  18738. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18739. */
  18740. export class Skeleton implements IAnimatable {
  18741. /** defines the skeleton name */
  18742. name: string;
  18743. /** defines the skeleton Id */
  18744. id: string;
  18745. /**
  18746. * Defines the list of child bones
  18747. */
  18748. bones: Bone[];
  18749. /**
  18750. * Defines an estimate of the dimension of the skeleton at rest
  18751. */
  18752. dimensionsAtRest: Vector3;
  18753. /**
  18754. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18755. */
  18756. needInitialSkinMatrix: boolean;
  18757. /**
  18758. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18759. */
  18760. overrideMesh: Nullable<AbstractMesh>;
  18761. /**
  18762. * Gets the list of animations attached to this skeleton
  18763. */
  18764. animations: Array<Animation>;
  18765. private _scene;
  18766. private _isDirty;
  18767. private _transformMatrices;
  18768. private _transformMatrixTexture;
  18769. private _meshesWithPoseMatrix;
  18770. private _animatables;
  18771. private _identity;
  18772. private _synchronizedWithMesh;
  18773. private _ranges;
  18774. private _lastAbsoluteTransformsUpdateId;
  18775. private _canUseTextureForBones;
  18776. private _uniqueId;
  18777. /** @hidden */
  18778. _numBonesWithLinkedTransformNode: number;
  18779. /**
  18780. * Specifies if the skeleton should be serialized
  18781. */
  18782. doNotSerialize: boolean;
  18783. private _useTextureToStoreBoneMatrices;
  18784. /**
  18785. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18786. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18787. */
  18788. useTextureToStoreBoneMatrices: boolean;
  18789. private _animationPropertiesOverride;
  18790. /**
  18791. * Gets or sets the animation properties override
  18792. */
  18793. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18794. /**
  18795. * List of inspectable custom properties (used by the Inspector)
  18796. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18797. */
  18798. inspectableCustomProperties: IInspectable[];
  18799. /**
  18800. * An observable triggered before computing the skeleton's matrices
  18801. */
  18802. onBeforeComputeObservable: Observable<Skeleton>;
  18803. /**
  18804. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18805. */
  18806. readonly isUsingTextureForMatrices: boolean;
  18807. /**
  18808. * Gets the unique ID of this skeleton
  18809. */
  18810. readonly uniqueId: number;
  18811. /**
  18812. * Creates a new skeleton
  18813. * @param name defines the skeleton name
  18814. * @param id defines the skeleton Id
  18815. * @param scene defines the hosting scene
  18816. */
  18817. constructor(
  18818. /** defines the skeleton name */
  18819. name: string,
  18820. /** defines the skeleton Id */
  18821. id: string, scene: Scene);
  18822. /**
  18823. * Gets the current object class name.
  18824. * @return the class name
  18825. */
  18826. getClassName(): string;
  18827. /**
  18828. * Returns an array containing the root bones
  18829. * @returns an array containing the root bones
  18830. */
  18831. getChildren(): Array<Bone>;
  18832. /**
  18833. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18834. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18835. * @returns a Float32Array containing matrices data
  18836. */
  18837. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18838. /**
  18839. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18840. * @returns a raw texture containing the data
  18841. */
  18842. getTransformMatrixTexture(): Nullable<RawTexture>;
  18843. /**
  18844. * Gets the current hosting scene
  18845. * @returns a scene object
  18846. */
  18847. getScene(): Scene;
  18848. /**
  18849. * Gets a string representing the current skeleton data
  18850. * @param fullDetails defines a boolean indicating if we want a verbose version
  18851. * @returns a string representing the current skeleton data
  18852. */
  18853. toString(fullDetails?: boolean): string;
  18854. /**
  18855. * Get bone's index searching by name
  18856. * @param name defines bone's name to search for
  18857. * @return the indice of the bone. Returns -1 if not found
  18858. */
  18859. getBoneIndexByName(name: string): number;
  18860. /**
  18861. * Creater a new animation range
  18862. * @param name defines the name of the range
  18863. * @param from defines the start key
  18864. * @param to defines the end key
  18865. */
  18866. createAnimationRange(name: string, from: number, to: number): void;
  18867. /**
  18868. * Delete a specific animation range
  18869. * @param name defines the name of the range
  18870. * @param deleteFrames defines if frames must be removed as well
  18871. */
  18872. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18873. /**
  18874. * Gets a specific animation range
  18875. * @param name defines the name of the range to look for
  18876. * @returns the requested animation range or null if not found
  18877. */
  18878. getAnimationRange(name: string): Nullable<AnimationRange>;
  18879. /**
  18880. * Gets the list of all animation ranges defined on this skeleton
  18881. * @returns an array
  18882. */
  18883. getAnimationRanges(): Nullable<AnimationRange>[];
  18884. /**
  18885. * Copy animation range from a source skeleton.
  18886. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18887. * @param source defines the source skeleton
  18888. * @param name defines the name of the range to copy
  18889. * @param rescaleAsRequired defines if rescaling must be applied if required
  18890. * @returns true if operation was successful
  18891. */
  18892. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18893. /**
  18894. * Forces the skeleton to go to rest pose
  18895. */
  18896. returnToRest(): void;
  18897. private _getHighestAnimationFrame;
  18898. /**
  18899. * Begin a specific animation range
  18900. * @param name defines the name of the range to start
  18901. * @param loop defines if looping must be turned on (false by default)
  18902. * @param speedRatio defines the speed ratio to apply (1 by default)
  18903. * @param onAnimationEnd defines a callback which will be called when animation will end
  18904. * @returns a new animatable
  18905. */
  18906. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18907. /** @hidden */
  18908. _markAsDirty(): void;
  18909. /** @hidden */
  18910. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18911. /** @hidden */
  18912. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18913. private _computeTransformMatrices;
  18914. /**
  18915. * Build all resources required to render a skeleton
  18916. */
  18917. prepare(): void;
  18918. /**
  18919. * Gets the list of animatables currently running for this skeleton
  18920. * @returns an array of animatables
  18921. */
  18922. getAnimatables(): IAnimatable[];
  18923. /**
  18924. * Clone the current skeleton
  18925. * @param name defines the name of the new skeleton
  18926. * @param id defines the id of the enw skeleton
  18927. * @returns the new skeleton
  18928. */
  18929. clone(name: string, id: string): Skeleton;
  18930. /**
  18931. * Enable animation blending for this skeleton
  18932. * @param blendingSpeed defines the blending speed to apply
  18933. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18934. */
  18935. enableBlending(blendingSpeed?: number): void;
  18936. /**
  18937. * Releases all resources associated with the current skeleton
  18938. */
  18939. dispose(): void;
  18940. /**
  18941. * Serialize the skeleton in a JSON object
  18942. * @returns a JSON object
  18943. */
  18944. serialize(): any;
  18945. /**
  18946. * Creates a new skeleton from serialized data
  18947. * @param parsedSkeleton defines the serialized data
  18948. * @param scene defines the hosting scene
  18949. * @returns a new skeleton
  18950. */
  18951. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18952. /**
  18953. * Compute all node absolute transforms
  18954. * @param forceUpdate defines if computation must be done even if cache is up to date
  18955. */
  18956. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18957. /**
  18958. * Gets the root pose matrix
  18959. * @returns a matrix
  18960. */
  18961. getPoseMatrix(): Nullable<Matrix>;
  18962. /**
  18963. * Sorts bones per internal index
  18964. */
  18965. sortBones(): void;
  18966. private _sortBones;
  18967. }
  18968. }
  18969. declare module BABYLON {
  18970. /**
  18971. * Defines a target to use with MorphTargetManager
  18972. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18973. */
  18974. export class MorphTarget implements IAnimatable {
  18975. /** defines the name of the target */
  18976. name: string;
  18977. /**
  18978. * Gets or sets the list of animations
  18979. */
  18980. animations: Animation[];
  18981. private _scene;
  18982. private _positions;
  18983. private _normals;
  18984. private _tangents;
  18985. private _influence;
  18986. /**
  18987. * Observable raised when the influence changes
  18988. */
  18989. onInfluenceChanged: Observable<boolean>;
  18990. /** @hidden */
  18991. _onDataLayoutChanged: Observable<void>;
  18992. /**
  18993. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18994. */
  18995. influence: number;
  18996. /**
  18997. * Gets or sets the id of the morph Target
  18998. */
  18999. id: string;
  19000. private _animationPropertiesOverride;
  19001. /**
  19002. * Gets or sets the animation properties override
  19003. */
  19004. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19005. /**
  19006. * Creates a new MorphTarget
  19007. * @param name defines the name of the target
  19008. * @param influence defines the influence to use
  19009. * @param scene defines the scene the morphtarget belongs to
  19010. */
  19011. constructor(
  19012. /** defines the name of the target */
  19013. name: string, influence?: number, scene?: Nullable<Scene>);
  19014. /**
  19015. * Gets a boolean defining if the target contains position data
  19016. */
  19017. readonly hasPositions: boolean;
  19018. /**
  19019. * Gets a boolean defining if the target contains normal data
  19020. */
  19021. readonly hasNormals: boolean;
  19022. /**
  19023. * Gets a boolean defining if the target contains tangent data
  19024. */
  19025. readonly hasTangents: boolean;
  19026. /**
  19027. * Affects position data to this target
  19028. * @param data defines the position data to use
  19029. */
  19030. setPositions(data: Nullable<FloatArray>): void;
  19031. /**
  19032. * Gets the position data stored in this target
  19033. * @returns a FloatArray containing the position data (or null if not present)
  19034. */
  19035. getPositions(): Nullable<FloatArray>;
  19036. /**
  19037. * Affects normal data to this target
  19038. * @param data defines the normal data to use
  19039. */
  19040. setNormals(data: Nullable<FloatArray>): void;
  19041. /**
  19042. * Gets the normal data stored in this target
  19043. * @returns a FloatArray containing the normal data (or null if not present)
  19044. */
  19045. getNormals(): Nullable<FloatArray>;
  19046. /**
  19047. * Affects tangent data to this target
  19048. * @param data defines the tangent data to use
  19049. */
  19050. setTangents(data: Nullable<FloatArray>): void;
  19051. /**
  19052. * Gets the tangent data stored in this target
  19053. * @returns a FloatArray containing the tangent data (or null if not present)
  19054. */
  19055. getTangents(): Nullable<FloatArray>;
  19056. /**
  19057. * Serializes the current target into a Serialization object
  19058. * @returns the serialized object
  19059. */
  19060. serialize(): any;
  19061. /**
  19062. * Returns the string "MorphTarget"
  19063. * @returns "MorphTarget"
  19064. */
  19065. getClassName(): string;
  19066. /**
  19067. * Creates a new target from serialized data
  19068. * @param serializationObject defines the serialized data to use
  19069. * @returns a new MorphTarget
  19070. */
  19071. static Parse(serializationObject: any): MorphTarget;
  19072. /**
  19073. * Creates a MorphTarget from mesh data
  19074. * @param mesh defines the source mesh
  19075. * @param name defines the name to use for the new target
  19076. * @param influence defines the influence to attach to the target
  19077. * @returns a new MorphTarget
  19078. */
  19079. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19080. }
  19081. }
  19082. declare module BABYLON {
  19083. /**
  19084. * This class is used to deform meshes using morphing between different targets
  19085. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19086. */
  19087. export class MorphTargetManager {
  19088. private _targets;
  19089. private _targetInfluenceChangedObservers;
  19090. private _targetDataLayoutChangedObservers;
  19091. private _activeTargets;
  19092. private _scene;
  19093. private _influences;
  19094. private _supportsNormals;
  19095. private _supportsTangents;
  19096. private _vertexCount;
  19097. private _uniqueId;
  19098. private _tempInfluences;
  19099. /**
  19100. * Creates a new MorphTargetManager
  19101. * @param scene defines the current scene
  19102. */
  19103. constructor(scene?: Nullable<Scene>);
  19104. /**
  19105. * Gets the unique ID of this manager
  19106. */
  19107. readonly uniqueId: number;
  19108. /**
  19109. * Gets the number of vertices handled by this manager
  19110. */
  19111. readonly vertexCount: number;
  19112. /**
  19113. * Gets a boolean indicating if this manager supports morphing of normals
  19114. */
  19115. readonly supportsNormals: boolean;
  19116. /**
  19117. * Gets a boolean indicating if this manager supports morphing of tangents
  19118. */
  19119. readonly supportsTangents: boolean;
  19120. /**
  19121. * Gets the number of targets stored in this manager
  19122. */
  19123. readonly numTargets: number;
  19124. /**
  19125. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19126. */
  19127. readonly numInfluencers: number;
  19128. /**
  19129. * Gets the list of influences (one per target)
  19130. */
  19131. readonly influences: Float32Array;
  19132. /**
  19133. * Gets the active target at specified index. An active target is a target with an influence > 0
  19134. * @param index defines the index to check
  19135. * @returns the requested target
  19136. */
  19137. getActiveTarget(index: number): MorphTarget;
  19138. /**
  19139. * Gets the target at specified index
  19140. * @param index defines the index to check
  19141. * @returns the requested target
  19142. */
  19143. getTarget(index: number): MorphTarget;
  19144. /**
  19145. * Add a new target to this manager
  19146. * @param target defines the target to add
  19147. */
  19148. addTarget(target: MorphTarget): void;
  19149. /**
  19150. * Removes a target from the manager
  19151. * @param target defines the target to remove
  19152. */
  19153. removeTarget(target: MorphTarget): void;
  19154. /**
  19155. * Serializes the current manager into a Serialization object
  19156. * @returns the serialized object
  19157. */
  19158. serialize(): any;
  19159. private _syncActiveTargets;
  19160. /**
  19161. * Syncrhonize the targets with all the meshes using this morph target manager
  19162. */
  19163. synchronize(): void;
  19164. /**
  19165. * Creates a new MorphTargetManager from serialized data
  19166. * @param serializationObject defines the serialized data
  19167. * @param scene defines the hosting scene
  19168. * @returns the new MorphTargetManager
  19169. */
  19170. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19171. }
  19172. }
  19173. declare module BABYLON {
  19174. /**
  19175. * Mesh representing the gorund
  19176. */
  19177. export class GroundMesh extends Mesh {
  19178. /** If octree should be generated */
  19179. generateOctree: boolean;
  19180. private _heightQuads;
  19181. /** @hidden */
  19182. _subdivisionsX: number;
  19183. /** @hidden */
  19184. _subdivisionsY: number;
  19185. /** @hidden */
  19186. _width: number;
  19187. /** @hidden */
  19188. _height: number;
  19189. /** @hidden */
  19190. _minX: number;
  19191. /** @hidden */
  19192. _maxX: number;
  19193. /** @hidden */
  19194. _minZ: number;
  19195. /** @hidden */
  19196. _maxZ: number;
  19197. constructor(name: string, scene: Scene);
  19198. /**
  19199. * "GroundMesh"
  19200. * @returns "GroundMesh"
  19201. */
  19202. getClassName(): string;
  19203. /**
  19204. * The minimum of x and y subdivisions
  19205. */
  19206. readonly subdivisions: number;
  19207. /**
  19208. * X subdivisions
  19209. */
  19210. readonly subdivisionsX: number;
  19211. /**
  19212. * Y subdivisions
  19213. */
  19214. readonly subdivisionsY: number;
  19215. /**
  19216. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19217. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19218. * @param chunksCount the number of subdivisions for x and y
  19219. * @param octreeBlocksSize (Default: 32)
  19220. */
  19221. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19222. /**
  19223. * Returns a height (y) value in the Worl system :
  19224. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19225. * @param x x coordinate
  19226. * @param z z coordinate
  19227. * @returns the ground y position if (x, z) are outside the ground surface.
  19228. */
  19229. getHeightAtCoordinates(x: number, z: number): number;
  19230. /**
  19231. * Returns a normalized vector (Vector3) orthogonal to the ground
  19232. * at the ground coordinates (x, z) expressed in the World system.
  19233. * @param x x coordinate
  19234. * @param z z coordinate
  19235. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19236. */
  19237. getNormalAtCoordinates(x: number, z: number): Vector3;
  19238. /**
  19239. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19240. * at the ground coordinates (x, z) expressed in the World system.
  19241. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19242. * @param x x coordinate
  19243. * @param z z coordinate
  19244. * @param ref vector to store the result
  19245. * @returns the GroundMesh.
  19246. */
  19247. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19248. /**
  19249. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19250. * if the ground has been updated.
  19251. * This can be used in the render loop.
  19252. * @returns the GroundMesh.
  19253. */
  19254. updateCoordinateHeights(): GroundMesh;
  19255. private _getFacetAt;
  19256. private _initHeightQuads;
  19257. private _computeHeightQuads;
  19258. /**
  19259. * Serializes this ground mesh
  19260. * @param serializationObject object to write serialization to
  19261. */
  19262. serialize(serializationObject: any): void;
  19263. /**
  19264. * Parses a serialized ground mesh
  19265. * @param parsedMesh the serialized mesh
  19266. * @param scene the scene to create the ground mesh in
  19267. * @returns the created ground mesh
  19268. */
  19269. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19270. }
  19271. }
  19272. declare module BABYLON {
  19273. /**
  19274. * Interface for Physics-Joint data
  19275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19276. */
  19277. export interface PhysicsJointData {
  19278. /**
  19279. * The main pivot of the joint
  19280. */
  19281. mainPivot?: Vector3;
  19282. /**
  19283. * The connected pivot of the joint
  19284. */
  19285. connectedPivot?: Vector3;
  19286. /**
  19287. * The main axis of the joint
  19288. */
  19289. mainAxis?: Vector3;
  19290. /**
  19291. * The connected axis of the joint
  19292. */
  19293. connectedAxis?: Vector3;
  19294. /**
  19295. * The collision of the joint
  19296. */
  19297. collision?: boolean;
  19298. /**
  19299. * Native Oimo/Cannon/Energy data
  19300. */
  19301. nativeParams?: any;
  19302. }
  19303. /**
  19304. * This is a holder class for the physics joint created by the physics plugin
  19305. * It holds a set of functions to control the underlying joint
  19306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19307. */
  19308. export class PhysicsJoint {
  19309. /**
  19310. * The type of the physics joint
  19311. */
  19312. type: number;
  19313. /**
  19314. * The data for the physics joint
  19315. */
  19316. jointData: PhysicsJointData;
  19317. private _physicsJoint;
  19318. protected _physicsPlugin: IPhysicsEnginePlugin;
  19319. /**
  19320. * Initializes the physics joint
  19321. * @param type The type of the physics joint
  19322. * @param jointData The data for the physics joint
  19323. */
  19324. constructor(
  19325. /**
  19326. * The type of the physics joint
  19327. */
  19328. type: number,
  19329. /**
  19330. * The data for the physics joint
  19331. */
  19332. jointData: PhysicsJointData);
  19333. /**
  19334. * Gets the physics joint
  19335. */
  19336. /**
  19337. * Sets the physics joint
  19338. */
  19339. physicsJoint: any;
  19340. /**
  19341. * Sets the physics plugin
  19342. */
  19343. physicsPlugin: IPhysicsEnginePlugin;
  19344. /**
  19345. * Execute a function that is physics-plugin specific.
  19346. * @param {Function} func the function that will be executed.
  19347. * It accepts two parameters: the physics world and the physics joint
  19348. */
  19349. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19350. /**
  19351. * Distance-Joint type
  19352. */
  19353. static DistanceJoint: number;
  19354. /**
  19355. * Hinge-Joint type
  19356. */
  19357. static HingeJoint: number;
  19358. /**
  19359. * Ball-and-Socket joint type
  19360. */
  19361. static BallAndSocketJoint: number;
  19362. /**
  19363. * Wheel-Joint type
  19364. */
  19365. static WheelJoint: number;
  19366. /**
  19367. * Slider-Joint type
  19368. */
  19369. static SliderJoint: number;
  19370. /**
  19371. * Prismatic-Joint type
  19372. */
  19373. static PrismaticJoint: number;
  19374. /**
  19375. * Universal-Joint type
  19376. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19377. */
  19378. static UniversalJoint: number;
  19379. /**
  19380. * Hinge-Joint 2 type
  19381. */
  19382. static Hinge2Joint: number;
  19383. /**
  19384. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19385. */
  19386. static PointToPointJoint: number;
  19387. /**
  19388. * Spring-Joint type
  19389. */
  19390. static SpringJoint: number;
  19391. /**
  19392. * Lock-Joint type
  19393. */
  19394. static LockJoint: number;
  19395. }
  19396. /**
  19397. * A class representing a physics distance joint
  19398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19399. */
  19400. export class DistanceJoint extends PhysicsJoint {
  19401. /**
  19402. *
  19403. * @param jointData The data for the Distance-Joint
  19404. */
  19405. constructor(jointData: DistanceJointData);
  19406. /**
  19407. * Update the predefined distance.
  19408. * @param maxDistance The maximum preferred distance
  19409. * @param minDistance The minimum preferred distance
  19410. */
  19411. updateDistance(maxDistance: number, minDistance?: number): void;
  19412. }
  19413. /**
  19414. * Represents a Motor-Enabled Joint
  19415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19416. */
  19417. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19418. /**
  19419. * Initializes the Motor-Enabled Joint
  19420. * @param type The type of the joint
  19421. * @param jointData The physica joint data for the joint
  19422. */
  19423. constructor(type: number, jointData: PhysicsJointData);
  19424. /**
  19425. * Set the motor values.
  19426. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19427. * @param force the force to apply
  19428. * @param maxForce max force for this motor.
  19429. */
  19430. setMotor(force?: number, maxForce?: number): void;
  19431. /**
  19432. * Set the motor's limits.
  19433. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19434. * @param upperLimit The upper limit of the motor
  19435. * @param lowerLimit The lower limit of the motor
  19436. */
  19437. setLimit(upperLimit: number, lowerLimit?: number): void;
  19438. }
  19439. /**
  19440. * This class represents a single physics Hinge-Joint
  19441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19442. */
  19443. export class HingeJoint extends MotorEnabledJoint {
  19444. /**
  19445. * Initializes the Hinge-Joint
  19446. * @param jointData The joint data for the Hinge-Joint
  19447. */
  19448. constructor(jointData: PhysicsJointData);
  19449. /**
  19450. * Set the motor values.
  19451. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19452. * @param {number} force the force to apply
  19453. * @param {number} maxForce max force for this motor.
  19454. */
  19455. setMotor(force?: number, maxForce?: number): void;
  19456. /**
  19457. * Set the motor's limits.
  19458. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19459. * @param upperLimit The upper limit of the motor
  19460. * @param lowerLimit The lower limit of the motor
  19461. */
  19462. setLimit(upperLimit: number, lowerLimit?: number): void;
  19463. }
  19464. /**
  19465. * This class represents a dual hinge physics joint (same as wheel joint)
  19466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19467. */
  19468. export class Hinge2Joint extends MotorEnabledJoint {
  19469. /**
  19470. * Initializes the Hinge2-Joint
  19471. * @param jointData The joint data for the Hinge2-Joint
  19472. */
  19473. constructor(jointData: PhysicsJointData);
  19474. /**
  19475. * Set the motor values.
  19476. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19477. * @param {number} targetSpeed the speed the motor is to reach
  19478. * @param {number} maxForce max force for this motor.
  19479. * @param {motorIndex} the motor's index, 0 or 1.
  19480. */
  19481. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19482. /**
  19483. * Set the motor limits.
  19484. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19485. * @param {number} upperLimit the upper limit
  19486. * @param {number} lowerLimit lower limit
  19487. * @param {motorIndex} the motor's index, 0 or 1.
  19488. */
  19489. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19490. }
  19491. /**
  19492. * Interface for a motor enabled joint
  19493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19494. */
  19495. export interface IMotorEnabledJoint {
  19496. /**
  19497. * Physics joint
  19498. */
  19499. physicsJoint: any;
  19500. /**
  19501. * Sets the motor of the motor-enabled joint
  19502. * @param force The force of the motor
  19503. * @param maxForce The maximum force of the motor
  19504. * @param motorIndex The index of the motor
  19505. */
  19506. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19507. /**
  19508. * Sets the limit of the motor
  19509. * @param upperLimit The upper limit of the motor
  19510. * @param lowerLimit The lower limit of the motor
  19511. * @param motorIndex The index of the motor
  19512. */
  19513. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19514. }
  19515. /**
  19516. * Joint data for a Distance-Joint
  19517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19518. */
  19519. export interface DistanceJointData extends PhysicsJointData {
  19520. /**
  19521. * Max distance the 2 joint objects can be apart
  19522. */
  19523. maxDistance: number;
  19524. }
  19525. /**
  19526. * Joint data from a spring joint
  19527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19528. */
  19529. export interface SpringJointData extends PhysicsJointData {
  19530. /**
  19531. * Length of the spring
  19532. */
  19533. length: number;
  19534. /**
  19535. * Stiffness of the spring
  19536. */
  19537. stiffness: number;
  19538. /**
  19539. * Damping of the spring
  19540. */
  19541. damping: number;
  19542. /** this callback will be called when applying the force to the impostors. */
  19543. forceApplicationCallback: () => void;
  19544. }
  19545. }
  19546. declare module BABYLON {
  19547. /**
  19548. * Holds the data for the raycast result
  19549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19550. */
  19551. export class PhysicsRaycastResult {
  19552. private _hasHit;
  19553. private _hitDistance;
  19554. private _hitNormalWorld;
  19555. private _hitPointWorld;
  19556. private _rayFromWorld;
  19557. private _rayToWorld;
  19558. /**
  19559. * Gets if there was a hit
  19560. */
  19561. readonly hasHit: boolean;
  19562. /**
  19563. * Gets the distance from the hit
  19564. */
  19565. readonly hitDistance: number;
  19566. /**
  19567. * Gets the hit normal/direction in the world
  19568. */
  19569. readonly hitNormalWorld: Vector3;
  19570. /**
  19571. * Gets the hit point in the world
  19572. */
  19573. readonly hitPointWorld: Vector3;
  19574. /**
  19575. * Gets the ray "start point" of the ray in the world
  19576. */
  19577. readonly rayFromWorld: Vector3;
  19578. /**
  19579. * Gets the ray "end point" of the ray in the world
  19580. */
  19581. readonly rayToWorld: Vector3;
  19582. /**
  19583. * Sets the hit data (normal & point in world space)
  19584. * @param hitNormalWorld defines the normal in world space
  19585. * @param hitPointWorld defines the point in world space
  19586. */
  19587. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19588. /**
  19589. * Sets the distance from the start point to the hit point
  19590. * @param distance
  19591. */
  19592. setHitDistance(distance: number): void;
  19593. /**
  19594. * Calculates the distance manually
  19595. */
  19596. calculateHitDistance(): void;
  19597. /**
  19598. * Resets all the values to default
  19599. * @param from The from point on world space
  19600. * @param to The to point on world space
  19601. */
  19602. reset(from?: Vector3, to?: Vector3): void;
  19603. }
  19604. /**
  19605. * Interface for the size containing width and height
  19606. */
  19607. interface IXYZ {
  19608. /**
  19609. * X
  19610. */
  19611. x: number;
  19612. /**
  19613. * Y
  19614. */
  19615. y: number;
  19616. /**
  19617. * Z
  19618. */
  19619. z: number;
  19620. }
  19621. }
  19622. declare module BABYLON {
  19623. /**
  19624. * Interface used to describe a physics joint
  19625. */
  19626. export interface PhysicsImpostorJoint {
  19627. /** Defines the main impostor to which the joint is linked */
  19628. mainImpostor: PhysicsImpostor;
  19629. /** Defines the impostor that is connected to the main impostor using this joint */
  19630. connectedImpostor: PhysicsImpostor;
  19631. /** Defines the joint itself */
  19632. joint: PhysicsJoint;
  19633. }
  19634. /** @hidden */
  19635. export interface IPhysicsEnginePlugin {
  19636. world: any;
  19637. name: string;
  19638. setGravity(gravity: Vector3): void;
  19639. setTimeStep(timeStep: number): void;
  19640. getTimeStep(): number;
  19641. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19642. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19643. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19644. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19645. removePhysicsBody(impostor: PhysicsImpostor): void;
  19646. generateJoint(joint: PhysicsImpostorJoint): void;
  19647. removeJoint(joint: PhysicsImpostorJoint): void;
  19648. isSupported(): boolean;
  19649. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19650. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19651. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19652. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19653. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19654. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19655. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19656. getBodyMass(impostor: PhysicsImpostor): number;
  19657. getBodyFriction(impostor: PhysicsImpostor): number;
  19658. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19659. getBodyRestitution(impostor: PhysicsImpostor): number;
  19660. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19661. getBodyPressure?(impostor: PhysicsImpostor): number;
  19662. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19663. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19664. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19665. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19666. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19667. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19668. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19669. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19670. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19671. sleepBody(impostor: PhysicsImpostor): void;
  19672. wakeUpBody(impostor: PhysicsImpostor): void;
  19673. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19674. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19675. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19676. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19677. getRadius(impostor: PhysicsImpostor): number;
  19678. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19679. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19680. dispose(): void;
  19681. }
  19682. /**
  19683. * Interface used to define a physics engine
  19684. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19685. */
  19686. export interface IPhysicsEngine {
  19687. /**
  19688. * Gets the gravity vector used by the simulation
  19689. */
  19690. gravity: Vector3;
  19691. /**
  19692. * Sets the gravity vector used by the simulation
  19693. * @param gravity defines the gravity vector to use
  19694. */
  19695. setGravity(gravity: Vector3): void;
  19696. /**
  19697. * Set the time step of the physics engine.
  19698. * Default is 1/60.
  19699. * To slow it down, enter 1/600 for example.
  19700. * To speed it up, 1/30
  19701. * @param newTimeStep the new timestep to apply to this world.
  19702. */
  19703. setTimeStep(newTimeStep: number): void;
  19704. /**
  19705. * Get the time step of the physics engine.
  19706. * @returns the current time step
  19707. */
  19708. getTimeStep(): number;
  19709. /**
  19710. * Release all resources
  19711. */
  19712. dispose(): void;
  19713. /**
  19714. * Gets the name of the current physics plugin
  19715. * @returns the name of the plugin
  19716. */
  19717. getPhysicsPluginName(): string;
  19718. /**
  19719. * Adding a new impostor for the impostor tracking.
  19720. * This will be done by the impostor itself.
  19721. * @param impostor the impostor to add
  19722. */
  19723. addImpostor(impostor: PhysicsImpostor): void;
  19724. /**
  19725. * Remove an impostor from the engine.
  19726. * This impostor and its mesh will not longer be updated by the physics engine.
  19727. * @param impostor the impostor to remove
  19728. */
  19729. removeImpostor(impostor: PhysicsImpostor): void;
  19730. /**
  19731. * Add a joint to the physics engine
  19732. * @param mainImpostor defines the main impostor to which the joint is added.
  19733. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19734. * @param joint defines the joint that will connect both impostors.
  19735. */
  19736. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19737. /**
  19738. * Removes a joint from the simulation
  19739. * @param mainImpostor defines the impostor used with the joint
  19740. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19741. * @param joint defines the joint to remove
  19742. */
  19743. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19744. /**
  19745. * Gets the current plugin used to run the simulation
  19746. * @returns current plugin
  19747. */
  19748. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19749. /**
  19750. * Gets the list of physic impostors
  19751. * @returns an array of PhysicsImpostor
  19752. */
  19753. getImpostors(): Array<PhysicsImpostor>;
  19754. /**
  19755. * Gets the impostor for a physics enabled object
  19756. * @param object defines the object impersonated by the impostor
  19757. * @returns the PhysicsImpostor or null if not found
  19758. */
  19759. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19760. /**
  19761. * Gets the impostor for a physics body object
  19762. * @param body defines physics body used by the impostor
  19763. * @returns the PhysicsImpostor or null if not found
  19764. */
  19765. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19766. /**
  19767. * Does a raycast in the physics world
  19768. * @param from when should the ray start?
  19769. * @param to when should the ray end?
  19770. * @returns PhysicsRaycastResult
  19771. */
  19772. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19773. /**
  19774. * Called by the scene. No need to call it.
  19775. * @param delta defines the timespam between frames
  19776. */
  19777. _step(delta: number): void;
  19778. }
  19779. }
  19780. declare module BABYLON {
  19781. /**
  19782. * The interface for the physics imposter parameters
  19783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19784. */
  19785. export interface PhysicsImpostorParameters {
  19786. /**
  19787. * The mass of the physics imposter
  19788. */
  19789. mass: number;
  19790. /**
  19791. * The friction of the physics imposter
  19792. */
  19793. friction?: number;
  19794. /**
  19795. * The coefficient of restitution of the physics imposter
  19796. */
  19797. restitution?: number;
  19798. /**
  19799. * The native options of the physics imposter
  19800. */
  19801. nativeOptions?: any;
  19802. /**
  19803. * Specifies if the parent should be ignored
  19804. */
  19805. ignoreParent?: boolean;
  19806. /**
  19807. * Specifies if bi-directional transformations should be disabled
  19808. */
  19809. disableBidirectionalTransformation?: boolean;
  19810. /**
  19811. * The pressure inside the physics imposter, soft object only
  19812. */
  19813. pressure?: number;
  19814. /**
  19815. * The stiffness the physics imposter, soft object only
  19816. */
  19817. stiffness?: number;
  19818. /**
  19819. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19820. */
  19821. velocityIterations?: number;
  19822. /**
  19823. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19824. */
  19825. positionIterations?: number;
  19826. /**
  19827. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19828. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19829. * Add to fix multiple points
  19830. */
  19831. fixedPoints?: number;
  19832. /**
  19833. * The collision margin around a soft object
  19834. */
  19835. margin?: number;
  19836. /**
  19837. * The collision margin around a soft object
  19838. */
  19839. damping?: number;
  19840. /**
  19841. * The path for a rope based on an extrusion
  19842. */
  19843. path?: any;
  19844. /**
  19845. * The shape of an extrusion used for a rope based on an extrusion
  19846. */
  19847. shape?: any;
  19848. }
  19849. /**
  19850. * Interface for a physics-enabled object
  19851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19852. */
  19853. export interface IPhysicsEnabledObject {
  19854. /**
  19855. * The position of the physics-enabled object
  19856. */
  19857. position: Vector3;
  19858. /**
  19859. * The rotation of the physics-enabled object
  19860. */
  19861. rotationQuaternion: Nullable<Quaternion>;
  19862. /**
  19863. * The scale of the physics-enabled object
  19864. */
  19865. scaling: Vector3;
  19866. /**
  19867. * The rotation of the physics-enabled object
  19868. */
  19869. rotation?: Vector3;
  19870. /**
  19871. * The parent of the physics-enabled object
  19872. */
  19873. parent?: any;
  19874. /**
  19875. * The bounding info of the physics-enabled object
  19876. * @returns The bounding info of the physics-enabled object
  19877. */
  19878. getBoundingInfo(): BoundingInfo;
  19879. /**
  19880. * Computes the world matrix
  19881. * @param force Specifies if the world matrix should be computed by force
  19882. * @returns A world matrix
  19883. */
  19884. computeWorldMatrix(force: boolean): Matrix;
  19885. /**
  19886. * Gets the world matrix
  19887. * @returns A world matrix
  19888. */
  19889. getWorldMatrix?(): Matrix;
  19890. /**
  19891. * Gets the child meshes
  19892. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19893. * @returns An array of abstract meshes
  19894. */
  19895. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19896. /**
  19897. * Gets the vertex data
  19898. * @param kind The type of vertex data
  19899. * @returns A nullable array of numbers, or a float32 array
  19900. */
  19901. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19902. /**
  19903. * Gets the indices from the mesh
  19904. * @returns A nullable array of index arrays
  19905. */
  19906. getIndices?(): Nullable<IndicesArray>;
  19907. /**
  19908. * Gets the scene from the mesh
  19909. * @returns the indices array or null
  19910. */
  19911. getScene?(): Scene;
  19912. /**
  19913. * Gets the absolute position from the mesh
  19914. * @returns the absolute position
  19915. */
  19916. getAbsolutePosition(): Vector3;
  19917. /**
  19918. * Gets the absolute pivot point from the mesh
  19919. * @returns the absolute pivot point
  19920. */
  19921. getAbsolutePivotPoint(): Vector3;
  19922. /**
  19923. * Rotates the mesh
  19924. * @param axis The axis of rotation
  19925. * @param amount The amount of rotation
  19926. * @param space The space of the rotation
  19927. * @returns The rotation transform node
  19928. */
  19929. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19930. /**
  19931. * Translates the mesh
  19932. * @param axis The axis of translation
  19933. * @param distance The distance of translation
  19934. * @param space The space of the translation
  19935. * @returns The transform node
  19936. */
  19937. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19938. /**
  19939. * Sets the absolute position of the mesh
  19940. * @param absolutePosition The absolute position of the mesh
  19941. * @returns The transform node
  19942. */
  19943. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19944. /**
  19945. * Gets the class name of the mesh
  19946. * @returns The class name
  19947. */
  19948. getClassName(): string;
  19949. }
  19950. /**
  19951. * Represents a physics imposter
  19952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19953. */
  19954. export class PhysicsImpostor {
  19955. /**
  19956. * The physics-enabled object used as the physics imposter
  19957. */
  19958. object: IPhysicsEnabledObject;
  19959. /**
  19960. * The type of the physics imposter
  19961. */
  19962. type: number;
  19963. private _options;
  19964. private _scene?;
  19965. /**
  19966. * The default object size of the imposter
  19967. */
  19968. static DEFAULT_OBJECT_SIZE: Vector3;
  19969. /**
  19970. * The identity quaternion of the imposter
  19971. */
  19972. static IDENTITY_QUATERNION: Quaternion;
  19973. /** @hidden */
  19974. _pluginData: any;
  19975. private _physicsEngine;
  19976. private _physicsBody;
  19977. private _bodyUpdateRequired;
  19978. private _onBeforePhysicsStepCallbacks;
  19979. private _onAfterPhysicsStepCallbacks;
  19980. /** @hidden */
  19981. _onPhysicsCollideCallbacks: Array<{
  19982. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19983. otherImpostors: Array<PhysicsImpostor>;
  19984. }>;
  19985. private _deltaPosition;
  19986. private _deltaRotation;
  19987. private _deltaRotationConjugated;
  19988. /** hidden */
  19989. _isFromLine: boolean;
  19990. private _parent;
  19991. private _isDisposed;
  19992. private static _tmpVecs;
  19993. private static _tmpQuat;
  19994. /**
  19995. * Specifies if the physics imposter is disposed
  19996. */
  19997. readonly isDisposed: boolean;
  19998. /**
  19999. * Gets the mass of the physics imposter
  20000. */
  20001. mass: number;
  20002. /**
  20003. * Gets the coefficient of friction
  20004. */
  20005. /**
  20006. * Sets the coefficient of friction
  20007. */
  20008. friction: number;
  20009. /**
  20010. * Gets the coefficient of restitution
  20011. */
  20012. /**
  20013. * Sets the coefficient of restitution
  20014. */
  20015. restitution: number;
  20016. /**
  20017. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20018. */
  20019. /**
  20020. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20021. */
  20022. pressure: number;
  20023. /**
  20024. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20025. */
  20026. /**
  20027. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20028. */
  20029. stiffness: number;
  20030. /**
  20031. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20032. */
  20033. /**
  20034. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20035. */
  20036. velocityIterations: number;
  20037. /**
  20038. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20039. */
  20040. /**
  20041. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20042. */
  20043. positionIterations: number;
  20044. /**
  20045. * The unique id of the physics imposter
  20046. * set by the physics engine when adding this impostor to the array
  20047. */
  20048. uniqueId: number;
  20049. /**
  20050. * @hidden
  20051. */
  20052. soft: boolean;
  20053. /**
  20054. * @hidden
  20055. */
  20056. segments: number;
  20057. private _joints;
  20058. /**
  20059. * Initializes the physics imposter
  20060. * @param object The physics-enabled object used as the physics imposter
  20061. * @param type The type of the physics imposter
  20062. * @param _options The options for the physics imposter
  20063. * @param _scene The Babylon scene
  20064. */
  20065. constructor(
  20066. /**
  20067. * The physics-enabled object used as the physics imposter
  20068. */
  20069. object: IPhysicsEnabledObject,
  20070. /**
  20071. * The type of the physics imposter
  20072. */
  20073. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20074. /**
  20075. * This function will completly initialize this impostor.
  20076. * It will create a new body - but only if this mesh has no parent.
  20077. * If it has, this impostor will not be used other than to define the impostor
  20078. * of the child mesh.
  20079. * @hidden
  20080. */
  20081. _init(): void;
  20082. private _getPhysicsParent;
  20083. /**
  20084. * Should a new body be generated.
  20085. * @returns boolean specifying if body initialization is required
  20086. */
  20087. isBodyInitRequired(): boolean;
  20088. /**
  20089. * Sets the updated scaling
  20090. * @param updated Specifies if the scaling is updated
  20091. */
  20092. setScalingUpdated(): void;
  20093. /**
  20094. * Force a regeneration of this or the parent's impostor's body.
  20095. * Use under cautious - This will remove all joints already implemented.
  20096. */
  20097. forceUpdate(): void;
  20098. /**
  20099. * Gets the body that holds this impostor. Either its own, or its parent.
  20100. */
  20101. /**
  20102. * Set the physics body. Used mainly by the physics engine/plugin
  20103. */
  20104. physicsBody: any;
  20105. /**
  20106. * Get the parent of the physics imposter
  20107. * @returns Physics imposter or null
  20108. */
  20109. /**
  20110. * Sets the parent of the physics imposter
  20111. */
  20112. parent: Nullable<PhysicsImpostor>;
  20113. /**
  20114. * Resets the update flags
  20115. */
  20116. resetUpdateFlags(): void;
  20117. /**
  20118. * Gets the object extend size
  20119. * @returns the object extend size
  20120. */
  20121. getObjectExtendSize(): Vector3;
  20122. /**
  20123. * Gets the object center
  20124. * @returns The object center
  20125. */
  20126. getObjectCenter(): Vector3;
  20127. /**
  20128. * Get a specific parametes from the options parameter
  20129. * @param paramName The object parameter name
  20130. * @returns The object parameter
  20131. */
  20132. getParam(paramName: string): any;
  20133. /**
  20134. * Sets a specific parameter in the options given to the physics plugin
  20135. * @param paramName The parameter name
  20136. * @param value The value of the parameter
  20137. */
  20138. setParam(paramName: string, value: number): void;
  20139. /**
  20140. * Specifically change the body's mass option. Won't recreate the physics body object
  20141. * @param mass The mass of the physics imposter
  20142. */
  20143. setMass(mass: number): void;
  20144. /**
  20145. * Gets the linear velocity
  20146. * @returns linear velocity or null
  20147. */
  20148. getLinearVelocity(): Nullable<Vector3>;
  20149. /**
  20150. * Sets the linear velocity
  20151. * @param velocity linear velocity or null
  20152. */
  20153. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20154. /**
  20155. * Gets the angular velocity
  20156. * @returns angular velocity or null
  20157. */
  20158. getAngularVelocity(): Nullable<Vector3>;
  20159. /**
  20160. * Sets the angular velocity
  20161. * @param velocity The velocity or null
  20162. */
  20163. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20164. /**
  20165. * Execute a function with the physics plugin native code
  20166. * Provide a function the will have two variables - the world object and the physics body object
  20167. * @param func The function to execute with the physics plugin native code
  20168. */
  20169. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20170. /**
  20171. * Register a function that will be executed before the physics world is stepping forward
  20172. * @param func The function to execute before the physics world is stepped forward
  20173. */
  20174. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20175. /**
  20176. * Unregister a function that will be executed before the physics world is stepping forward
  20177. * @param func The function to execute before the physics world is stepped forward
  20178. */
  20179. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20180. /**
  20181. * Register a function that will be executed after the physics step
  20182. * @param func The function to execute after physics step
  20183. */
  20184. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20185. /**
  20186. * Unregisters a function that will be executed after the physics step
  20187. * @param func The function to execute after physics step
  20188. */
  20189. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20190. /**
  20191. * register a function that will be executed when this impostor collides against a different body
  20192. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20193. * @param func Callback that is executed on collision
  20194. */
  20195. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20196. /**
  20197. * Unregisters the physics imposter on contact
  20198. * @param collideAgainst The physics object to collide against
  20199. * @param func Callback to execute on collision
  20200. */
  20201. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20202. private _tmpQuat;
  20203. private _tmpQuat2;
  20204. /**
  20205. * Get the parent rotation
  20206. * @returns The parent rotation
  20207. */
  20208. getParentsRotation(): Quaternion;
  20209. /**
  20210. * this function is executed by the physics engine.
  20211. */
  20212. beforeStep: () => void;
  20213. /**
  20214. * this function is executed by the physics engine
  20215. */
  20216. afterStep: () => void;
  20217. /**
  20218. * Legacy collision detection event support
  20219. */
  20220. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20221. /**
  20222. * event and body object due to cannon's event-based architecture.
  20223. */
  20224. onCollide: (e: {
  20225. body: any;
  20226. }) => void;
  20227. /**
  20228. * Apply a force
  20229. * @param force The force to apply
  20230. * @param contactPoint The contact point for the force
  20231. * @returns The physics imposter
  20232. */
  20233. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20234. /**
  20235. * Apply an impulse
  20236. * @param force The impulse force
  20237. * @param contactPoint The contact point for the impulse force
  20238. * @returns The physics imposter
  20239. */
  20240. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20241. /**
  20242. * A help function to create a joint
  20243. * @param otherImpostor A physics imposter used to create a joint
  20244. * @param jointType The type of joint
  20245. * @param jointData The data for the joint
  20246. * @returns The physics imposter
  20247. */
  20248. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20249. /**
  20250. * Add a joint to this impostor with a different impostor
  20251. * @param otherImpostor A physics imposter used to add a joint
  20252. * @param joint The joint to add
  20253. * @returns The physics imposter
  20254. */
  20255. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20256. /**
  20257. * Add an anchor to a cloth impostor
  20258. * @param otherImpostor rigid impostor to anchor to
  20259. * @param width ratio across width from 0 to 1
  20260. * @param height ratio up height from 0 to 1
  20261. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20262. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20263. * @returns impostor the soft imposter
  20264. */
  20265. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20266. /**
  20267. * Add a hook to a rope impostor
  20268. * @param otherImpostor rigid impostor to anchor to
  20269. * @param length ratio across rope from 0 to 1
  20270. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20271. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20272. * @returns impostor the rope imposter
  20273. */
  20274. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20275. /**
  20276. * Will keep this body still, in a sleep mode.
  20277. * @returns the physics imposter
  20278. */
  20279. sleep(): PhysicsImpostor;
  20280. /**
  20281. * Wake the body up.
  20282. * @returns The physics imposter
  20283. */
  20284. wakeUp(): PhysicsImpostor;
  20285. /**
  20286. * Clones the physics imposter
  20287. * @param newObject The physics imposter clones to this physics-enabled object
  20288. * @returns A nullable physics imposter
  20289. */
  20290. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20291. /**
  20292. * Disposes the physics imposter
  20293. */
  20294. dispose(): void;
  20295. /**
  20296. * Sets the delta position
  20297. * @param position The delta position amount
  20298. */
  20299. setDeltaPosition(position: Vector3): void;
  20300. /**
  20301. * Sets the delta rotation
  20302. * @param rotation The delta rotation amount
  20303. */
  20304. setDeltaRotation(rotation: Quaternion): void;
  20305. /**
  20306. * Gets the box size of the physics imposter and stores the result in the input parameter
  20307. * @param result Stores the box size
  20308. * @returns The physics imposter
  20309. */
  20310. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20311. /**
  20312. * Gets the radius of the physics imposter
  20313. * @returns Radius of the physics imposter
  20314. */
  20315. getRadius(): number;
  20316. /**
  20317. * Sync a bone with this impostor
  20318. * @param bone The bone to sync to the impostor.
  20319. * @param boneMesh The mesh that the bone is influencing.
  20320. * @param jointPivot The pivot of the joint / bone in local space.
  20321. * @param distToJoint Optional distance from the impostor to the joint.
  20322. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20323. */
  20324. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20325. /**
  20326. * Sync impostor to a bone
  20327. * @param bone The bone that the impostor will be synced to.
  20328. * @param boneMesh The mesh that the bone is influencing.
  20329. * @param jointPivot The pivot of the joint / bone in local space.
  20330. * @param distToJoint Optional distance from the impostor to the joint.
  20331. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20332. * @param boneAxis Optional vector3 axis the bone is aligned with
  20333. */
  20334. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20335. /**
  20336. * No-Imposter type
  20337. */
  20338. static NoImpostor: number;
  20339. /**
  20340. * Sphere-Imposter type
  20341. */
  20342. static SphereImpostor: number;
  20343. /**
  20344. * Box-Imposter type
  20345. */
  20346. static BoxImpostor: number;
  20347. /**
  20348. * Plane-Imposter type
  20349. */
  20350. static PlaneImpostor: number;
  20351. /**
  20352. * Mesh-imposter type
  20353. */
  20354. static MeshImpostor: number;
  20355. /**
  20356. * Cylinder-Imposter type
  20357. */
  20358. static CylinderImpostor: number;
  20359. /**
  20360. * Particle-Imposter type
  20361. */
  20362. static ParticleImpostor: number;
  20363. /**
  20364. * Heightmap-Imposter type
  20365. */
  20366. static HeightmapImpostor: number;
  20367. /**
  20368. * ConvexHull-Impostor type (Ammo.js plugin only)
  20369. */
  20370. static ConvexHullImpostor: number;
  20371. /**
  20372. * Rope-Imposter type
  20373. */
  20374. static RopeImpostor: number;
  20375. /**
  20376. * Cloth-Imposter type
  20377. */
  20378. static ClothImpostor: number;
  20379. /**
  20380. * Softbody-Imposter type
  20381. */
  20382. static SoftbodyImpostor: number;
  20383. }
  20384. }
  20385. declare module BABYLON {
  20386. /**
  20387. * Class used to represent a specific level of detail of a mesh
  20388. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20389. */
  20390. export class MeshLODLevel {
  20391. /** Defines the distance where this level should star being displayed */
  20392. distance: number;
  20393. /** Defines the mesh to use to render this level */
  20394. mesh: Nullable<Mesh>;
  20395. /**
  20396. * Creates a new LOD level
  20397. * @param distance defines the distance where this level should star being displayed
  20398. * @param mesh defines the mesh to use to render this level
  20399. */
  20400. constructor(
  20401. /** Defines the distance where this level should star being displayed */
  20402. distance: number,
  20403. /** Defines the mesh to use to render this level */
  20404. mesh: Nullable<Mesh>);
  20405. }
  20406. /**
  20407. * @hidden
  20408. **/
  20409. export class _CreationDataStorage {
  20410. closePath?: boolean;
  20411. closeArray?: boolean;
  20412. idx: number[];
  20413. dashSize: number;
  20414. gapSize: number;
  20415. path3D: Path3D;
  20416. pathArray: Vector3[][];
  20417. arc: number;
  20418. radius: number;
  20419. cap: number;
  20420. tessellation: number;
  20421. }
  20422. /**
  20423. * @hidden
  20424. **/
  20425. class _InstanceDataStorage {
  20426. visibleInstances: any;
  20427. renderIdForInstances: number[];
  20428. batchCache: _InstancesBatch;
  20429. instancesBufferSize: number;
  20430. instancesBuffer: Nullable<Buffer>;
  20431. instancesData: Float32Array;
  20432. overridenInstanceCount: number;
  20433. }
  20434. /**
  20435. * @hidden
  20436. **/
  20437. export class _InstancesBatch {
  20438. mustReturn: boolean;
  20439. visibleInstances: Nullable<InstancedMesh[]>[];
  20440. renderSelf: boolean[];
  20441. }
  20442. /**
  20443. * Class used to represent renderable models
  20444. */
  20445. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20446. /**
  20447. * Mesh side orientation : usually the external or front surface
  20448. */
  20449. static readonly FRONTSIDE: number;
  20450. /**
  20451. * Mesh side orientation : usually the internal or back surface
  20452. */
  20453. static readonly BACKSIDE: number;
  20454. /**
  20455. * Mesh side orientation : both internal and external or front and back surfaces
  20456. */
  20457. static readonly DOUBLESIDE: number;
  20458. /**
  20459. * Mesh side orientation : by default, `FRONTSIDE`
  20460. */
  20461. static readonly DEFAULTSIDE: number;
  20462. /**
  20463. * Mesh cap setting : no cap
  20464. */
  20465. static readonly NO_CAP: number;
  20466. /**
  20467. * Mesh cap setting : one cap at the beginning of the mesh
  20468. */
  20469. static readonly CAP_START: number;
  20470. /**
  20471. * Mesh cap setting : one cap at the end of the mesh
  20472. */
  20473. static readonly CAP_END: number;
  20474. /**
  20475. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20476. */
  20477. static readonly CAP_ALL: number;
  20478. /**
  20479. * Gets the default side orientation.
  20480. * @param orientation the orientation to value to attempt to get
  20481. * @returns the default orientation
  20482. * @hidden
  20483. */
  20484. static _GetDefaultSideOrientation(orientation?: number): number;
  20485. private _onBeforeRenderObservable;
  20486. private _onBeforeBindObservable;
  20487. private _onAfterRenderObservable;
  20488. private _onBeforeDrawObservable;
  20489. /**
  20490. * An event triggered before rendering the mesh
  20491. */
  20492. readonly onBeforeRenderObservable: Observable<Mesh>;
  20493. /**
  20494. * An event triggered before binding the mesh
  20495. */
  20496. readonly onBeforeBindObservable: Observable<Mesh>;
  20497. /**
  20498. * An event triggered after rendering the mesh
  20499. */
  20500. readonly onAfterRenderObservable: Observable<Mesh>;
  20501. /**
  20502. * An event triggered before drawing the mesh
  20503. */
  20504. readonly onBeforeDrawObservable: Observable<Mesh>;
  20505. private _onBeforeDrawObserver;
  20506. /**
  20507. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20508. */
  20509. onBeforeDraw: () => void;
  20510. /**
  20511. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20512. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20513. */
  20514. delayLoadState: number;
  20515. /**
  20516. * Gets the list of instances created from this mesh
  20517. * it is not supposed to be modified manually.
  20518. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20519. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20520. */
  20521. instances: InstancedMesh[];
  20522. /**
  20523. * Gets the file containing delay loading data for this mesh
  20524. */
  20525. delayLoadingFile: string;
  20526. /** @hidden */
  20527. _binaryInfo: any;
  20528. private _LODLevels;
  20529. /**
  20530. * User defined function used to change how LOD level selection is done
  20531. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20532. */
  20533. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20534. private _morphTargetManager;
  20535. /**
  20536. * Gets or sets the morph target manager
  20537. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20538. */
  20539. morphTargetManager: Nullable<MorphTargetManager>;
  20540. /** @hidden */
  20541. _creationDataStorage: Nullable<_CreationDataStorage>;
  20542. /** @hidden */
  20543. _geometry: Nullable<Geometry>;
  20544. /** @hidden */
  20545. _delayInfo: Array<string>;
  20546. /** @hidden */
  20547. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20548. /** @hidden */
  20549. _instanceDataStorage: _InstanceDataStorage;
  20550. private _effectiveMaterial;
  20551. /** @hidden */
  20552. _shouldGenerateFlatShading: boolean;
  20553. private _preActivateId;
  20554. /** @hidden */
  20555. _originalBuilderSideOrientation: number;
  20556. /**
  20557. * Use this property to change the original side orientation defined at construction time
  20558. */
  20559. overrideMaterialSideOrientation: Nullable<number>;
  20560. private _areNormalsFrozen;
  20561. private _sourcePositions;
  20562. private _sourceNormals;
  20563. private _source;
  20564. private meshMap;
  20565. /**
  20566. * Gets the source mesh (the one used to clone this one from)
  20567. */
  20568. readonly source: Nullable<Mesh>;
  20569. /**
  20570. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20571. */
  20572. isUnIndexed: boolean;
  20573. /**
  20574. * @constructor
  20575. * @param name The value used by scene.getMeshByName() to do a lookup.
  20576. * @param scene The scene to add this mesh to.
  20577. * @param parent The parent of this mesh, if it has one
  20578. * @param source An optional Mesh from which geometry is shared, cloned.
  20579. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20580. * When false, achieved by calling a clone(), also passing False.
  20581. * This will make creation of children, recursive.
  20582. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20583. */
  20584. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20585. /**
  20586. * Gets the class name
  20587. * @returns the string "Mesh".
  20588. */
  20589. getClassName(): string;
  20590. /** @hidden */
  20591. readonly _isMesh: boolean;
  20592. /**
  20593. * Returns a description of this mesh
  20594. * @param fullDetails define if full details about this mesh must be used
  20595. * @returns a descriptive string representing this mesh
  20596. */
  20597. toString(fullDetails?: boolean): string;
  20598. /** @hidden */
  20599. _unBindEffect(): void;
  20600. /**
  20601. * Gets a boolean indicating if this mesh has LOD
  20602. */
  20603. readonly hasLODLevels: boolean;
  20604. /**
  20605. * Gets the list of MeshLODLevel associated with the current mesh
  20606. * @returns an array of MeshLODLevel
  20607. */
  20608. getLODLevels(): MeshLODLevel[];
  20609. private _sortLODLevels;
  20610. /**
  20611. * Add a mesh as LOD level triggered at the given distance.
  20612. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20613. * @param distance The distance from the center of the object to show this level
  20614. * @param mesh The mesh to be added as LOD level (can be null)
  20615. * @return This mesh (for chaining)
  20616. */
  20617. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20618. /**
  20619. * Returns the LOD level mesh at the passed distance or null if not found.
  20620. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20621. * @param distance The distance from the center of the object to show this level
  20622. * @returns a Mesh or `null`
  20623. */
  20624. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20625. /**
  20626. * Remove a mesh from the LOD array
  20627. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20628. * @param mesh defines the mesh to be removed
  20629. * @return This mesh (for chaining)
  20630. */
  20631. removeLODLevel(mesh: Mesh): Mesh;
  20632. /**
  20633. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20634. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20635. * @param camera defines the camera to use to compute distance
  20636. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20637. * @return This mesh (for chaining)
  20638. */
  20639. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20640. /**
  20641. * Gets the mesh internal Geometry object
  20642. */
  20643. readonly geometry: Nullable<Geometry>;
  20644. /**
  20645. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20646. * @returns the total number of vertices
  20647. */
  20648. getTotalVertices(): number;
  20649. /**
  20650. * Returns the content of an associated vertex buffer
  20651. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20652. * - VertexBuffer.PositionKind
  20653. * - VertexBuffer.UVKind
  20654. * - VertexBuffer.UV2Kind
  20655. * - VertexBuffer.UV3Kind
  20656. * - VertexBuffer.UV4Kind
  20657. * - VertexBuffer.UV5Kind
  20658. * - VertexBuffer.UV6Kind
  20659. * - VertexBuffer.ColorKind
  20660. * - VertexBuffer.MatricesIndicesKind
  20661. * - VertexBuffer.MatricesIndicesExtraKind
  20662. * - VertexBuffer.MatricesWeightsKind
  20663. * - VertexBuffer.MatricesWeightsExtraKind
  20664. * @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
  20665. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20666. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20667. */
  20668. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20669. /**
  20670. * Returns the mesh VertexBuffer object from the requested `kind`
  20671. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20672. * - VertexBuffer.PositionKind
  20673. * - VertexBuffer.UVKind
  20674. * - VertexBuffer.UV2Kind
  20675. * - VertexBuffer.UV3Kind
  20676. * - VertexBuffer.UV4Kind
  20677. * - VertexBuffer.UV5Kind
  20678. * - VertexBuffer.UV6Kind
  20679. * - VertexBuffer.ColorKind
  20680. * - VertexBuffer.MatricesIndicesKind
  20681. * - VertexBuffer.MatricesIndicesExtraKind
  20682. * - VertexBuffer.MatricesWeightsKind
  20683. * - VertexBuffer.MatricesWeightsExtraKind
  20684. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20685. */
  20686. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20687. /**
  20688. * Tests if a specific vertex buffer is associated with this mesh
  20689. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20690. * - VertexBuffer.PositionKind
  20691. * - VertexBuffer.UVKind
  20692. * - VertexBuffer.UV2Kind
  20693. * - VertexBuffer.UV3Kind
  20694. * - VertexBuffer.UV4Kind
  20695. * - VertexBuffer.UV5Kind
  20696. * - VertexBuffer.UV6Kind
  20697. * - VertexBuffer.ColorKind
  20698. * - VertexBuffer.MatricesIndicesKind
  20699. * - VertexBuffer.MatricesIndicesExtraKind
  20700. * - VertexBuffer.MatricesWeightsKind
  20701. * - VertexBuffer.MatricesWeightsExtraKind
  20702. * @returns a boolean
  20703. */
  20704. isVerticesDataPresent(kind: string): boolean;
  20705. /**
  20706. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20707. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20708. * - VertexBuffer.PositionKind
  20709. * - VertexBuffer.UVKind
  20710. * - VertexBuffer.UV2Kind
  20711. * - VertexBuffer.UV3Kind
  20712. * - VertexBuffer.UV4Kind
  20713. * - VertexBuffer.UV5Kind
  20714. * - VertexBuffer.UV6Kind
  20715. * - VertexBuffer.ColorKind
  20716. * - VertexBuffer.MatricesIndicesKind
  20717. * - VertexBuffer.MatricesIndicesExtraKind
  20718. * - VertexBuffer.MatricesWeightsKind
  20719. * - VertexBuffer.MatricesWeightsExtraKind
  20720. * @returns a boolean
  20721. */
  20722. isVertexBufferUpdatable(kind: string): boolean;
  20723. /**
  20724. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20725. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20726. * - VertexBuffer.PositionKind
  20727. * - VertexBuffer.UVKind
  20728. * - VertexBuffer.UV2Kind
  20729. * - VertexBuffer.UV3Kind
  20730. * - VertexBuffer.UV4Kind
  20731. * - VertexBuffer.UV5Kind
  20732. * - VertexBuffer.UV6Kind
  20733. * - VertexBuffer.ColorKind
  20734. * - VertexBuffer.MatricesIndicesKind
  20735. * - VertexBuffer.MatricesIndicesExtraKind
  20736. * - VertexBuffer.MatricesWeightsKind
  20737. * - VertexBuffer.MatricesWeightsExtraKind
  20738. * @returns an array of strings
  20739. */
  20740. getVerticesDataKinds(): string[];
  20741. /**
  20742. * Returns a positive integer : the total number of indices in this mesh geometry.
  20743. * @returns the numner of indices or zero if the mesh has no geometry.
  20744. */
  20745. getTotalIndices(): number;
  20746. /**
  20747. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20748. * @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.
  20749. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20750. * @returns the indices array or an empty array if the mesh has no geometry
  20751. */
  20752. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20753. readonly isBlocked: boolean;
  20754. /**
  20755. * Determine if the current mesh is ready to be rendered
  20756. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20757. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20758. * @returns true if all associated assets are ready (material, textures, shaders)
  20759. */
  20760. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20761. /**
  20762. * 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.
  20763. */
  20764. readonly areNormalsFrozen: boolean;
  20765. /**
  20766. * 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.
  20767. * @returns the current mesh
  20768. */
  20769. freezeNormals(): Mesh;
  20770. /**
  20771. * 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
  20772. * @returns the current mesh
  20773. */
  20774. unfreezeNormals(): Mesh;
  20775. /**
  20776. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20777. */
  20778. overridenInstanceCount: number;
  20779. /** @hidden */
  20780. _preActivate(): Mesh;
  20781. /** @hidden */
  20782. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20783. /** @hidden */
  20784. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20785. /**
  20786. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20787. * This means the mesh underlying bounding box and sphere are recomputed.
  20788. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20789. * @returns the current mesh
  20790. */
  20791. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20792. /** @hidden */
  20793. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20794. /**
  20795. * This function will subdivide the mesh into multiple submeshes
  20796. * @param count defines the expected number of submeshes
  20797. */
  20798. subdivide(count: number): void;
  20799. /**
  20800. * Copy a FloatArray into a specific associated vertex buffer
  20801. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20802. * - VertexBuffer.PositionKind
  20803. * - VertexBuffer.UVKind
  20804. * - VertexBuffer.UV2Kind
  20805. * - VertexBuffer.UV3Kind
  20806. * - VertexBuffer.UV4Kind
  20807. * - VertexBuffer.UV5Kind
  20808. * - VertexBuffer.UV6Kind
  20809. * - VertexBuffer.ColorKind
  20810. * - VertexBuffer.MatricesIndicesKind
  20811. * - VertexBuffer.MatricesIndicesExtraKind
  20812. * - VertexBuffer.MatricesWeightsKind
  20813. * - VertexBuffer.MatricesWeightsExtraKind
  20814. * @param data defines the data source
  20815. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20816. * @param stride defines the data stride size (can be null)
  20817. * @returns the current mesh
  20818. */
  20819. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20820. /**
  20821. * Flags an associated vertex buffer as updatable
  20822. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20823. * - VertexBuffer.PositionKind
  20824. * - VertexBuffer.UVKind
  20825. * - VertexBuffer.UV2Kind
  20826. * - VertexBuffer.UV3Kind
  20827. * - VertexBuffer.UV4Kind
  20828. * - VertexBuffer.UV5Kind
  20829. * - VertexBuffer.UV6Kind
  20830. * - VertexBuffer.ColorKind
  20831. * - VertexBuffer.MatricesIndicesKind
  20832. * - VertexBuffer.MatricesIndicesExtraKind
  20833. * - VertexBuffer.MatricesWeightsKind
  20834. * - VertexBuffer.MatricesWeightsExtraKind
  20835. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20836. */
  20837. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20838. /**
  20839. * Sets the mesh global Vertex Buffer
  20840. * @param buffer defines the buffer to use
  20841. * @returns the current mesh
  20842. */
  20843. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20844. /**
  20845. * Update a specific associated vertex buffer
  20846. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20847. * - VertexBuffer.PositionKind
  20848. * - VertexBuffer.UVKind
  20849. * - VertexBuffer.UV2Kind
  20850. * - VertexBuffer.UV3Kind
  20851. * - VertexBuffer.UV4Kind
  20852. * - VertexBuffer.UV5Kind
  20853. * - VertexBuffer.UV6Kind
  20854. * - VertexBuffer.ColorKind
  20855. * - VertexBuffer.MatricesIndicesKind
  20856. * - VertexBuffer.MatricesIndicesExtraKind
  20857. * - VertexBuffer.MatricesWeightsKind
  20858. * - VertexBuffer.MatricesWeightsExtraKind
  20859. * @param data defines the data source
  20860. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20861. * @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)
  20862. * @returns the current mesh
  20863. */
  20864. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20865. /**
  20866. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20867. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20868. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20869. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20870. * @returns the current mesh
  20871. */
  20872. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20873. /**
  20874. * Creates a un-shared specific occurence of the geometry for the mesh.
  20875. * @returns the current mesh
  20876. */
  20877. makeGeometryUnique(): Mesh;
  20878. /**
  20879. * Set the index buffer of this mesh
  20880. * @param indices defines the source data
  20881. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20882. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20883. * @returns the current mesh
  20884. */
  20885. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20886. /**
  20887. * Update the current index buffer
  20888. * @param indices defines the source data
  20889. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20890. * @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)
  20891. * @returns the current mesh
  20892. */
  20893. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20894. /**
  20895. * Invert the geometry to move from a right handed system to a left handed one.
  20896. * @returns the current mesh
  20897. */
  20898. toLeftHanded(): Mesh;
  20899. /** @hidden */
  20900. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20901. /** @hidden */
  20902. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20903. /**
  20904. * Registers for this mesh a javascript function called just before the rendering process
  20905. * @param func defines the function to call before rendering this mesh
  20906. * @returns the current mesh
  20907. */
  20908. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20909. /**
  20910. * Disposes a previously registered javascript function called before the rendering
  20911. * @param func defines the function to remove
  20912. * @returns the current mesh
  20913. */
  20914. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20915. /**
  20916. * Registers for this mesh a javascript function called just after the rendering is complete
  20917. * @param func defines the function to call after rendering this mesh
  20918. * @returns the current mesh
  20919. */
  20920. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20921. /**
  20922. * Disposes a previously registered javascript function called after the rendering.
  20923. * @param func defines the function to remove
  20924. * @returns the current mesh
  20925. */
  20926. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20927. /** @hidden */
  20928. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20929. /** @hidden */
  20930. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20931. /** @hidden */
  20932. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20933. /**
  20934. * 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
  20935. * @param subMesh defines the subMesh to render
  20936. * @param enableAlphaMode defines if alpha mode can be changed
  20937. * @returns the current mesh
  20938. */
  20939. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20940. private _onBeforeDraw;
  20941. /**
  20942. * Renormalize the mesh and patch it up if there are no weights
  20943. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20944. * However in the case of zero weights then we set just a single influence to 1.
  20945. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20946. */
  20947. cleanMatrixWeights(): void;
  20948. private normalizeSkinFourWeights;
  20949. private normalizeSkinWeightsAndExtra;
  20950. /**
  20951. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20952. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20953. * the user know there was an issue with importing the mesh
  20954. * @returns a validation object with skinned, valid and report string
  20955. */
  20956. validateSkinning(): {
  20957. skinned: boolean;
  20958. valid: boolean;
  20959. report: string;
  20960. };
  20961. /** @hidden */
  20962. _checkDelayState(): Mesh;
  20963. private _queueLoad;
  20964. /**
  20965. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20966. * A mesh is in the frustum if its bounding box intersects the frustum
  20967. * @param frustumPlanes defines the frustum to test
  20968. * @returns true if the mesh is in the frustum planes
  20969. */
  20970. isInFrustum(frustumPlanes: Plane[]): boolean;
  20971. /**
  20972. * Sets the mesh material by the material or multiMaterial `id` property
  20973. * @param id is a string identifying the material or the multiMaterial
  20974. * @returns the current mesh
  20975. */
  20976. setMaterialByID(id: string): Mesh;
  20977. /**
  20978. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20979. * @returns an array of IAnimatable
  20980. */
  20981. getAnimatables(): IAnimatable[];
  20982. /**
  20983. * Modifies the mesh geometry according to the passed transformation matrix.
  20984. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20985. * The mesh normals are modified using the same transformation.
  20986. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20987. * @param transform defines the transform matrix to use
  20988. * @see http://doc.babylonjs.com/resources/baking_transformations
  20989. * @returns the current mesh
  20990. */
  20991. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20992. /**
  20993. * Modifies the mesh geometry according to its own current World Matrix.
  20994. * The mesh World Matrix is then reset.
  20995. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20996. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20997. * @see http://doc.babylonjs.com/resources/baking_transformations
  20998. * @returns the current mesh
  20999. */
  21000. bakeCurrentTransformIntoVertices(): Mesh;
  21001. /** @hidden */
  21002. readonly _positions: Nullable<Vector3[]>;
  21003. /** @hidden */
  21004. _resetPointsArrayCache(): Mesh;
  21005. /** @hidden */
  21006. _generatePointsArray(): boolean;
  21007. /**
  21008. * Returns a new Mesh object generated from the current mesh properties.
  21009. * This method must not get confused with createInstance()
  21010. * @param name is a string, the name given to the new mesh
  21011. * @param newParent can be any Node object (default `null`)
  21012. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21013. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21014. * @returns a new mesh
  21015. */
  21016. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21017. /**
  21018. * Releases resources associated with this mesh.
  21019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21021. */
  21022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21023. /**
  21024. * Modifies the mesh geometry according to a displacement map.
  21025. * 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.
  21026. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21027. * @param url is a string, the URL from the image file is to be downloaded.
  21028. * @param minHeight is the lower limit of the displacement.
  21029. * @param maxHeight is the upper limit of the displacement.
  21030. * @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.
  21031. * @param uvOffset is an optional vector2 used to offset UV.
  21032. * @param uvScale is an optional vector2 used to scale UV.
  21033. * @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.
  21034. * @returns the Mesh.
  21035. */
  21036. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21037. /**
  21038. * Modifies the mesh geometry according to a displacementMap buffer.
  21039. * 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.
  21040. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21041. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21042. * @param heightMapWidth is the width of the buffer image.
  21043. * @param heightMapHeight is the height of the buffer image.
  21044. * @param minHeight is the lower limit of the displacement.
  21045. * @param maxHeight is the upper limit of the displacement.
  21046. * @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.
  21047. * @param uvOffset is an optional vector2 used to offset UV.
  21048. * @param uvScale is an optional vector2 used to scale UV.
  21049. * @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.
  21050. * @returns the Mesh.
  21051. */
  21052. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21053. /**
  21054. * Modify the mesh to get a flat shading rendering.
  21055. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21056. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21057. * @returns current mesh
  21058. */
  21059. convertToFlatShadedMesh(): Mesh;
  21060. /**
  21061. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21062. * In other words, more vertices, no more indices and a single bigger VBO.
  21063. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21064. * @returns current mesh
  21065. */
  21066. convertToUnIndexedMesh(): Mesh;
  21067. /**
  21068. * Inverses facet orientations.
  21069. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21070. * @param flipNormals will also inverts the normals
  21071. * @returns current mesh
  21072. */
  21073. flipFaces(flipNormals?: boolean): Mesh;
  21074. /**
  21075. * Increase the number of facets and hence vertices in a mesh
  21076. * Vertex normals are interpolated from existing vertex normals
  21077. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21078. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21079. */
  21080. increaseVertices(numberPerEdge: number): void;
  21081. /**
  21082. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21083. * This will undo any application of covertToFlatShadedMesh
  21084. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21085. */
  21086. forceSharedVertices(): void;
  21087. /** @hidden */
  21088. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21089. /** @hidden */
  21090. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21091. /**
  21092. * Creates a new InstancedMesh object from the mesh model.
  21093. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21094. * @param name defines the name of the new instance
  21095. * @returns a new InstancedMesh
  21096. */
  21097. createInstance(name: string): InstancedMesh;
  21098. /**
  21099. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21100. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21101. * @returns the current mesh
  21102. */
  21103. synchronizeInstances(): Mesh;
  21104. /**
  21105. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21106. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21107. * This should be used together with the simplification to avoid disappearing triangles.
  21108. * @param successCallback an optional success callback to be called after the optimization finished.
  21109. * @returns the current mesh
  21110. */
  21111. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21112. /**
  21113. * Serialize current mesh
  21114. * @param serializationObject defines the object which will receive the serialization data
  21115. */
  21116. serialize(serializationObject: any): void;
  21117. /** @hidden */
  21118. _syncGeometryWithMorphTargetManager(): void;
  21119. /** @hidden */
  21120. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21121. /**
  21122. * Returns a new Mesh object parsed from the source provided.
  21123. * @param parsedMesh is the source
  21124. * @param scene defines the hosting scene
  21125. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21126. * @returns a new Mesh
  21127. */
  21128. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21129. /**
  21130. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21131. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21132. * @param name defines the name of the mesh to create
  21133. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21134. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21135. * @param closePath creates a seam between the first and the last points of each path of the path array
  21136. * @param offset is taken in account only if the `pathArray` is containing a single path
  21137. * @param scene defines the hosting scene
  21138. * @param updatable defines if the mesh must be flagged as updatable
  21139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21140. * @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)
  21141. * @returns a new Mesh
  21142. */
  21143. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21144. /**
  21145. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21146. * @param name defines the name of the mesh to create
  21147. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21148. * @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
  21149. * @param scene defines the hosting scene
  21150. * @param updatable defines if the mesh must be flagged as updatable
  21151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21152. * @returns a new Mesh
  21153. */
  21154. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21155. /**
  21156. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21157. * @param name defines the name of the mesh to create
  21158. * @param size sets the size (float) of each box side (default 1)
  21159. * @param scene defines the hosting scene
  21160. * @param updatable defines if the mesh must be flagged as updatable
  21161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21162. * @returns a new Mesh
  21163. */
  21164. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21165. /**
  21166. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21167. * @param name defines the name of the mesh to create
  21168. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21169. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21170. * @param scene defines the hosting scene
  21171. * @param updatable defines if the mesh must be flagged as updatable
  21172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21173. * @returns a new Mesh
  21174. */
  21175. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21176. /**
  21177. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21178. * @param name defines the name of the mesh to create
  21179. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21180. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21181. * @param scene defines the hosting scene
  21182. * @returns a new Mesh
  21183. */
  21184. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21185. /**
  21186. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21187. * @param name defines the name of the mesh to create
  21188. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21189. * @param diameterTop set the top cap diameter (floats, default 1)
  21190. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21191. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21192. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21193. * @param scene defines the hosting scene
  21194. * @param updatable defines if the mesh must be flagged as updatable
  21195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21196. * @returns a new Mesh
  21197. */
  21198. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21199. /**
  21200. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21201. * @param name defines the name of the mesh to create
  21202. * @param diameter sets the diameter size (float) of the torus (default 1)
  21203. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21204. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21205. * @param scene defines the hosting scene
  21206. * @param updatable defines if the mesh must be flagged as updatable
  21207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21208. * @returns a new Mesh
  21209. */
  21210. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21211. /**
  21212. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21213. * @param name defines the name of the mesh to create
  21214. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21215. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21216. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21217. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21218. * @param p the number of windings on X axis (positive integers, default 2)
  21219. * @param q the number of windings on Y axis (positive integers, default 3)
  21220. * @param scene defines the hosting scene
  21221. * @param updatable defines if the mesh must be flagged as updatable
  21222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21223. * @returns a new Mesh
  21224. */
  21225. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21226. /**
  21227. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21228. * @param name defines the name of the mesh to create
  21229. * @param points is an array successive Vector3
  21230. * @param scene defines the hosting scene
  21231. * @param updatable defines if the mesh must be flagged as updatable
  21232. * @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).
  21233. * @returns a new Mesh
  21234. */
  21235. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21236. /**
  21237. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21238. * @param name defines the name of the mesh to create
  21239. * @param points is an array successive Vector3
  21240. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21241. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21242. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21243. * @param scene defines the hosting scene
  21244. * @param updatable defines if the mesh must be flagged as updatable
  21245. * @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)
  21246. * @returns a new Mesh
  21247. */
  21248. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21249. /**
  21250. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21251. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21252. * 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.
  21253. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21254. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21255. * Remember you can only change the shape positions, not their number when updating a polygon.
  21256. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21257. * @param name defines the name of the mesh to create
  21258. * @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
  21259. * @param scene defines the hosting scene
  21260. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21261. * @param updatable defines if the mesh must be flagged as updatable
  21262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21263. * @param earcutInjection can be used to inject your own earcut reference
  21264. * @returns a new Mesh
  21265. */
  21266. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21267. /**
  21268. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21269. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21270. * @param name defines the name of the mesh to create
  21271. * @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
  21272. * @param depth defines the height of extrusion
  21273. * @param scene defines the hosting scene
  21274. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21275. * @param updatable defines if the mesh must be flagged as updatable
  21276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21277. * @param earcutInjection can be used to inject your own earcut reference
  21278. * @returns a new Mesh
  21279. */
  21280. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21281. /**
  21282. * Creates an extruded shape mesh.
  21283. * 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
  21284. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21285. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21286. * @param name defines the name of the mesh to create
  21287. * @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
  21288. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21289. * @param scale is the value to scale the shape
  21290. * @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
  21291. * @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
  21292. * @param scene defines the hosting scene
  21293. * @param updatable defines if the mesh must be flagged as updatable
  21294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21295. * @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)
  21296. * @returns a new Mesh
  21297. */
  21298. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21299. /**
  21300. * Creates an custom extruded shape mesh.
  21301. * The custom extrusion is a parametric shape.
  21302. * It has no predefined shape. Its final shape will depend on the input parameters.
  21303. * Please consider using the same method from the MeshBuilder class instead
  21304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21305. * @param name defines the name of the mesh to create
  21306. * @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
  21307. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21308. * @param scaleFunction is a custom Javascript function called on each path point
  21309. * @param rotationFunction is a custom Javascript function called on each path point
  21310. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21311. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21312. * @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
  21313. * @param scene defines the hosting scene
  21314. * @param updatable defines if the mesh must be flagged as updatable
  21315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21316. * @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)
  21317. * @returns a new Mesh
  21318. */
  21319. 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;
  21320. /**
  21321. * Creates lathe mesh.
  21322. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21323. * Please consider using the same method from the MeshBuilder class instead
  21324. * @param name defines the name of the mesh to create
  21325. * @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
  21326. * @param radius is the radius value of the lathe
  21327. * @param tessellation is the side number of the lathe.
  21328. * @param scene defines the hosting scene
  21329. * @param updatable defines if the mesh must be flagged as updatable
  21330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21331. * @returns a new Mesh
  21332. */
  21333. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21334. /**
  21335. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21336. * @param name defines the name of the mesh to create
  21337. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21338. * @param scene defines the hosting scene
  21339. * @param updatable defines if the mesh must be flagged as updatable
  21340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21341. * @returns a new Mesh
  21342. */
  21343. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21344. /**
  21345. * Creates a ground mesh.
  21346. * Please consider using the same method from the MeshBuilder class instead
  21347. * @param name defines the name of the mesh to create
  21348. * @param width set the width of the ground
  21349. * @param height set the height of the ground
  21350. * @param subdivisions sets the number of subdivisions per side
  21351. * @param scene defines the hosting scene
  21352. * @param updatable defines if the mesh must be flagged as updatable
  21353. * @returns a new Mesh
  21354. */
  21355. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21356. /**
  21357. * Creates a tiled ground mesh.
  21358. * Please consider using the same method from the MeshBuilder class instead
  21359. * @param name defines the name of the mesh to create
  21360. * @param xmin set the ground minimum X coordinate
  21361. * @param zmin set the ground minimum Y coordinate
  21362. * @param xmax set the ground maximum X coordinate
  21363. * @param zmax set the ground maximum Z coordinate
  21364. * @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
  21365. * @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
  21366. * @param scene defines the hosting scene
  21367. * @param updatable defines if the mesh must be flagged as updatable
  21368. * @returns a new Mesh
  21369. */
  21370. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21371. w: number;
  21372. h: number;
  21373. }, precision: {
  21374. w: number;
  21375. h: number;
  21376. }, scene: Scene, updatable?: boolean): Mesh;
  21377. /**
  21378. * Creates a ground mesh from a height map.
  21379. * Please consider using the same method from the MeshBuilder class instead
  21380. * @see http://doc.babylonjs.com/babylon101/height_map
  21381. * @param name defines the name of the mesh to create
  21382. * @param url sets the URL of the height map image resource
  21383. * @param width set the ground width size
  21384. * @param height set the ground height size
  21385. * @param subdivisions sets the number of subdivision per side
  21386. * @param minHeight is the minimum altitude on the ground
  21387. * @param maxHeight is the maximum altitude on the ground
  21388. * @param scene defines the hosting scene
  21389. * @param updatable defines if the mesh must be flagged as updatable
  21390. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21391. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21392. * @returns a new Mesh
  21393. */
  21394. 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;
  21395. /**
  21396. * Creates a tube mesh.
  21397. * The tube is a parametric shape.
  21398. * It has no predefined shape. Its final shape will depend on the input parameters.
  21399. * Please consider using the same method from the MeshBuilder class instead
  21400. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21401. * @param name defines the name of the mesh to create
  21402. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21403. * @param radius sets the tube radius size
  21404. * @param tessellation is the number of sides on the tubular surface
  21405. * @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
  21406. * @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
  21407. * @param scene defines the hosting scene
  21408. * @param updatable defines if the mesh must be flagged as updatable
  21409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21410. * @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)
  21411. * @returns a new Mesh
  21412. */
  21413. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21414. (i: number, distance: number): number;
  21415. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21416. /**
  21417. * Creates a polyhedron mesh.
  21418. * Please consider using the same method from the MeshBuilder class instead.
  21419. * * 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
  21420. * * The parameter `size` (positive float, default 1) sets the polygon size
  21421. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21422. * * 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`
  21423. * * 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
  21424. * * 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)`)
  21425. * * 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
  21426. * * 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
  21427. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21428. * * 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
  21429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21430. * @param name defines the name of the mesh to create
  21431. * @param options defines the options used to create the mesh
  21432. * @param scene defines the hosting scene
  21433. * @returns a new Mesh
  21434. */
  21435. static CreatePolyhedron(name: string, options: {
  21436. type?: number;
  21437. size?: number;
  21438. sizeX?: number;
  21439. sizeY?: number;
  21440. sizeZ?: number;
  21441. custom?: any;
  21442. faceUV?: Vector4[];
  21443. faceColors?: Color4[];
  21444. updatable?: boolean;
  21445. sideOrientation?: number;
  21446. }, scene: Scene): Mesh;
  21447. /**
  21448. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21449. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21450. * * 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`)
  21451. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21452. * * 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
  21453. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21454. * * 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
  21455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21456. * @param name defines the name of the mesh
  21457. * @param options defines the options used to create the mesh
  21458. * @param scene defines the hosting scene
  21459. * @returns a new Mesh
  21460. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21461. */
  21462. static CreateIcoSphere(name: string, options: {
  21463. radius?: number;
  21464. flat?: boolean;
  21465. subdivisions?: number;
  21466. sideOrientation?: number;
  21467. updatable?: boolean;
  21468. }, scene: Scene): Mesh;
  21469. /**
  21470. * Creates a decal mesh.
  21471. * Please consider using the same method from the MeshBuilder class instead.
  21472. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21473. * @param name defines the name of the mesh
  21474. * @param sourceMesh defines the mesh receiving the decal
  21475. * @param position sets the position of the decal in world coordinates
  21476. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21477. * @param size sets the decal scaling
  21478. * @param angle sets the angle to rotate the decal
  21479. * @returns a new Mesh
  21480. */
  21481. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21482. /**
  21483. * Prepare internal position array for software CPU skinning
  21484. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21485. */
  21486. setPositionsForCPUSkinning(): Float32Array;
  21487. /**
  21488. * Prepare internal normal array for software CPU skinning
  21489. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21490. */
  21491. setNormalsForCPUSkinning(): Float32Array;
  21492. /**
  21493. * Updates the vertex buffer by applying transformation from the bones
  21494. * @param skeleton defines the skeleton to apply to current mesh
  21495. * @returns the current mesh
  21496. */
  21497. applySkeleton(skeleton: Skeleton): Mesh;
  21498. /**
  21499. * 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
  21500. * @param meshes defines the list of meshes to scan
  21501. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21502. */
  21503. static MinMax(meshes: AbstractMesh[]): {
  21504. min: Vector3;
  21505. max: Vector3;
  21506. };
  21507. /**
  21508. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21509. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21510. * @returns a vector3
  21511. */
  21512. static Center(meshesOrMinMaxVector: {
  21513. min: Vector3;
  21514. max: Vector3;
  21515. } | AbstractMesh[]): Vector3;
  21516. /**
  21517. * Merge the array of meshes into a single mesh for performance reasons.
  21518. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21519. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21520. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21521. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21522. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21523. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21524. * @returns a new mesh
  21525. */
  21526. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21527. /** @hidden */
  21528. addInstance(instance: InstancedMesh): void;
  21529. /** @hidden */
  21530. removeInstance(instance: InstancedMesh): void;
  21531. }
  21532. }
  21533. declare module BABYLON {
  21534. /**
  21535. * Base class for the main features of a material in Babylon.js
  21536. */
  21537. export class Material implements IAnimatable {
  21538. /**
  21539. * Returns the triangle fill mode
  21540. */
  21541. static readonly TriangleFillMode: number;
  21542. /**
  21543. * Returns the wireframe mode
  21544. */
  21545. static readonly WireFrameFillMode: number;
  21546. /**
  21547. * Returns the point fill mode
  21548. */
  21549. static readonly PointFillMode: number;
  21550. /**
  21551. * Returns the point list draw mode
  21552. */
  21553. static readonly PointListDrawMode: number;
  21554. /**
  21555. * Returns the line list draw mode
  21556. */
  21557. static readonly LineListDrawMode: number;
  21558. /**
  21559. * Returns the line loop draw mode
  21560. */
  21561. static readonly LineLoopDrawMode: number;
  21562. /**
  21563. * Returns the line strip draw mode
  21564. */
  21565. static readonly LineStripDrawMode: number;
  21566. /**
  21567. * Returns the triangle strip draw mode
  21568. */
  21569. static readonly TriangleStripDrawMode: number;
  21570. /**
  21571. * Returns the triangle fan draw mode
  21572. */
  21573. static readonly TriangleFanDrawMode: number;
  21574. /**
  21575. * Stores the clock-wise side orientation
  21576. */
  21577. static readonly ClockWiseSideOrientation: number;
  21578. /**
  21579. * Stores the counter clock-wise side orientation
  21580. */
  21581. static readonly CounterClockWiseSideOrientation: number;
  21582. /**
  21583. * The dirty texture flag value
  21584. */
  21585. static readonly TextureDirtyFlag: number;
  21586. /**
  21587. * The dirty light flag value
  21588. */
  21589. static readonly LightDirtyFlag: number;
  21590. /**
  21591. * The dirty fresnel flag value
  21592. */
  21593. static readonly FresnelDirtyFlag: number;
  21594. /**
  21595. * The dirty attribute flag value
  21596. */
  21597. static readonly AttributesDirtyFlag: number;
  21598. /**
  21599. * The dirty misc flag value
  21600. */
  21601. static readonly MiscDirtyFlag: number;
  21602. /**
  21603. * The all dirty flag value
  21604. */
  21605. static readonly AllDirtyFlag: number;
  21606. /**
  21607. * The ID of the material
  21608. */
  21609. id: string;
  21610. /**
  21611. * Gets or sets the unique id of the material
  21612. */
  21613. uniqueId: number;
  21614. /**
  21615. * The name of the material
  21616. */
  21617. name: string;
  21618. /**
  21619. * Gets or sets user defined metadata
  21620. */
  21621. metadata: any;
  21622. /**
  21623. * For internal use only. Please do not use.
  21624. */
  21625. reservedDataStore: any;
  21626. /**
  21627. * Specifies if the ready state should be checked on each call
  21628. */
  21629. checkReadyOnEveryCall: boolean;
  21630. /**
  21631. * Specifies if the ready state should be checked once
  21632. */
  21633. checkReadyOnlyOnce: boolean;
  21634. /**
  21635. * The state of the material
  21636. */
  21637. state: string;
  21638. /**
  21639. * The alpha value of the material
  21640. */
  21641. protected _alpha: number;
  21642. /**
  21643. * List of inspectable custom properties (used by the Inspector)
  21644. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21645. */
  21646. inspectableCustomProperties: IInspectable[];
  21647. /**
  21648. * Sets the alpha value of the material
  21649. */
  21650. /**
  21651. * Gets the alpha value of the material
  21652. */
  21653. alpha: number;
  21654. /**
  21655. * Specifies if back face culling is enabled
  21656. */
  21657. protected _backFaceCulling: boolean;
  21658. /**
  21659. * Sets the back-face culling state
  21660. */
  21661. /**
  21662. * Gets the back-face culling state
  21663. */
  21664. backFaceCulling: boolean;
  21665. /**
  21666. * Stores the value for side orientation
  21667. */
  21668. sideOrientation: number;
  21669. /**
  21670. * Callback triggered when the material is compiled
  21671. */
  21672. onCompiled: (effect: Effect) => void;
  21673. /**
  21674. * Callback triggered when an error occurs
  21675. */
  21676. onError: (effect: Effect, errors: string) => void;
  21677. /**
  21678. * Callback triggered to get the render target textures
  21679. */
  21680. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21681. /**
  21682. * Gets a boolean indicating that current material needs to register RTT
  21683. */
  21684. readonly hasRenderTargetTextures: boolean;
  21685. /**
  21686. * Specifies if the material should be serialized
  21687. */
  21688. doNotSerialize: boolean;
  21689. /**
  21690. * @hidden
  21691. */
  21692. _storeEffectOnSubMeshes: boolean;
  21693. /**
  21694. * Stores the animations for the material
  21695. */
  21696. animations: Array<Animation>;
  21697. /**
  21698. * An event triggered when the material is disposed
  21699. */
  21700. onDisposeObservable: Observable<Material>;
  21701. /**
  21702. * An observer which watches for dispose events
  21703. */
  21704. private _onDisposeObserver;
  21705. private _onUnBindObservable;
  21706. /**
  21707. * Called during a dispose event
  21708. */
  21709. onDispose: () => void;
  21710. private _onBindObservable;
  21711. /**
  21712. * An event triggered when the material is bound
  21713. */
  21714. readonly onBindObservable: Observable<AbstractMesh>;
  21715. /**
  21716. * An observer which watches for bind events
  21717. */
  21718. private _onBindObserver;
  21719. /**
  21720. * Called during a bind event
  21721. */
  21722. onBind: (Mesh: AbstractMesh) => void;
  21723. /**
  21724. * An event triggered when the material is unbound
  21725. */
  21726. readonly onUnBindObservable: Observable<Material>;
  21727. /**
  21728. * Stores the value of the alpha mode
  21729. */
  21730. private _alphaMode;
  21731. /**
  21732. * Sets the value of the alpha mode.
  21733. *
  21734. * | Value | Type | Description |
  21735. * | --- | --- | --- |
  21736. * | 0 | ALPHA_DISABLE | |
  21737. * | 1 | ALPHA_ADD | |
  21738. * | 2 | ALPHA_COMBINE | |
  21739. * | 3 | ALPHA_SUBTRACT | |
  21740. * | 4 | ALPHA_MULTIPLY | |
  21741. * | 5 | ALPHA_MAXIMIZED | |
  21742. * | 6 | ALPHA_ONEONE | |
  21743. * | 7 | ALPHA_PREMULTIPLIED | |
  21744. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21745. * | 9 | ALPHA_INTERPOLATE | |
  21746. * | 10 | ALPHA_SCREENMODE | |
  21747. *
  21748. */
  21749. /**
  21750. * Gets the value of the alpha mode
  21751. */
  21752. alphaMode: number;
  21753. /**
  21754. * Stores the state of the need depth pre-pass value
  21755. */
  21756. private _needDepthPrePass;
  21757. /**
  21758. * Sets the need depth pre-pass value
  21759. */
  21760. /**
  21761. * Gets the depth pre-pass value
  21762. */
  21763. needDepthPrePass: boolean;
  21764. /**
  21765. * Specifies if depth writing should be disabled
  21766. */
  21767. disableDepthWrite: boolean;
  21768. /**
  21769. * Specifies if depth writing should be forced
  21770. */
  21771. forceDepthWrite: boolean;
  21772. /**
  21773. * Specifies if there should be a separate pass for culling
  21774. */
  21775. separateCullingPass: boolean;
  21776. /**
  21777. * Stores the state specifing if fog should be enabled
  21778. */
  21779. private _fogEnabled;
  21780. /**
  21781. * Sets the state for enabling fog
  21782. */
  21783. /**
  21784. * Gets the value of the fog enabled state
  21785. */
  21786. fogEnabled: boolean;
  21787. /**
  21788. * Stores the size of points
  21789. */
  21790. pointSize: number;
  21791. /**
  21792. * Stores the z offset value
  21793. */
  21794. zOffset: number;
  21795. /**
  21796. * Gets a value specifying if wireframe mode is enabled
  21797. */
  21798. /**
  21799. * Sets the state of wireframe mode
  21800. */
  21801. wireframe: boolean;
  21802. /**
  21803. * Gets the value specifying if point clouds are enabled
  21804. */
  21805. /**
  21806. * Sets the state of point cloud mode
  21807. */
  21808. pointsCloud: boolean;
  21809. /**
  21810. * Gets the material fill mode
  21811. */
  21812. /**
  21813. * Sets the material fill mode
  21814. */
  21815. fillMode: number;
  21816. /**
  21817. * @hidden
  21818. * Stores the effects for the material
  21819. */
  21820. _effect: Nullable<Effect>;
  21821. /**
  21822. * @hidden
  21823. * Specifies if the material was previously ready
  21824. */
  21825. _wasPreviouslyReady: boolean;
  21826. /**
  21827. * Specifies if uniform buffers should be used
  21828. */
  21829. private _useUBO;
  21830. /**
  21831. * Stores a reference to the scene
  21832. */
  21833. private _scene;
  21834. /**
  21835. * Stores the fill mode state
  21836. */
  21837. private _fillMode;
  21838. /**
  21839. * Specifies if the depth write state should be cached
  21840. */
  21841. private _cachedDepthWriteState;
  21842. /**
  21843. * Stores the uniform buffer
  21844. */
  21845. protected _uniformBuffer: UniformBuffer;
  21846. /** @hidden */
  21847. _indexInSceneMaterialArray: number;
  21848. /** @hidden */
  21849. meshMap: Nullable<{
  21850. [id: string]: AbstractMesh | undefined;
  21851. }>;
  21852. /**
  21853. * Creates a material instance
  21854. * @param name defines the name of the material
  21855. * @param scene defines the scene to reference
  21856. * @param doNotAdd specifies if the material should be added to the scene
  21857. */
  21858. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21859. /**
  21860. * Returns a string representation of the current material
  21861. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21862. * @returns a string with material information
  21863. */
  21864. toString(fullDetails?: boolean): string;
  21865. /**
  21866. * Gets the class name of the material
  21867. * @returns a string with the class name of the material
  21868. */
  21869. getClassName(): string;
  21870. /**
  21871. * Specifies if updates for the material been locked
  21872. */
  21873. readonly isFrozen: boolean;
  21874. /**
  21875. * Locks updates for the material
  21876. */
  21877. freeze(): void;
  21878. /**
  21879. * Unlocks updates for the material
  21880. */
  21881. unfreeze(): void;
  21882. /**
  21883. * Specifies if the material is ready to be used
  21884. * @param mesh defines the mesh to check
  21885. * @param useInstances specifies if instances should be used
  21886. * @returns a boolean indicating if the material is ready to be used
  21887. */
  21888. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21889. /**
  21890. * Specifies that the submesh is ready to be used
  21891. * @param mesh defines the mesh to check
  21892. * @param subMesh defines which submesh to check
  21893. * @param useInstances specifies that instances should be used
  21894. * @returns a boolean indicating that the submesh is ready or not
  21895. */
  21896. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21897. /**
  21898. * Returns the material effect
  21899. * @returns the effect associated with the material
  21900. */
  21901. getEffect(): Nullable<Effect>;
  21902. /**
  21903. * Returns the current scene
  21904. * @returns a Scene
  21905. */
  21906. getScene(): Scene;
  21907. /**
  21908. * Specifies if the material will require alpha blending
  21909. * @returns a boolean specifying if alpha blending is needed
  21910. */
  21911. needAlphaBlending(): boolean;
  21912. /**
  21913. * Specifies if the mesh will require alpha blending
  21914. * @param mesh defines the mesh to check
  21915. * @returns a boolean specifying if alpha blending is needed for the mesh
  21916. */
  21917. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21918. /**
  21919. * Specifies if this material should be rendered in alpha test mode
  21920. * @returns a boolean specifying if an alpha test is needed.
  21921. */
  21922. needAlphaTesting(): boolean;
  21923. /**
  21924. * Gets the texture used for the alpha test
  21925. * @returns the texture to use for alpha testing
  21926. */
  21927. getAlphaTestTexture(): Nullable<BaseTexture>;
  21928. /**
  21929. * Marks the material to indicate that it needs to be re-calculated
  21930. */
  21931. markDirty(): void;
  21932. /** @hidden */
  21933. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21934. /**
  21935. * Binds the material to the mesh
  21936. * @param world defines the world transformation matrix
  21937. * @param mesh defines the mesh to bind the material to
  21938. */
  21939. bind(world: Matrix, mesh?: Mesh): void;
  21940. /**
  21941. * Binds the submesh to the material
  21942. * @param world defines the world transformation matrix
  21943. * @param mesh defines the mesh containing the submesh
  21944. * @param subMesh defines the submesh to bind the material to
  21945. */
  21946. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21947. /**
  21948. * Binds the world matrix to the material
  21949. * @param world defines the world transformation matrix
  21950. */
  21951. bindOnlyWorldMatrix(world: Matrix): void;
  21952. /**
  21953. * Binds the scene's uniform buffer to the effect.
  21954. * @param effect defines the effect to bind to the scene uniform buffer
  21955. * @param sceneUbo defines the uniform buffer storing scene data
  21956. */
  21957. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21958. /**
  21959. * Binds the view matrix to the effect
  21960. * @param effect defines the effect to bind the view matrix to
  21961. */
  21962. bindView(effect: Effect): void;
  21963. /**
  21964. * Binds the view projection matrix to the effect
  21965. * @param effect defines the effect to bind the view projection matrix to
  21966. */
  21967. bindViewProjection(effect: Effect): void;
  21968. /**
  21969. * Specifies if material alpha testing should be turned on for the mesh
  21970. * @param mesh defines the mesh to check
  21971. */
  21972. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21973. /**
  21974. * Processes to execute after binding the material to a mesh
  21975. * @param mesh defines the rendered mesh
  21976. */
  21977. protected _afterBind(mesh?: Mesh): void;
  21978. /**
  21979. * Unbinds the material from the mesh
  21980. */
  21981. unbind(): void;
  21982. /**
  21983. * Gets the active textures from the material
  21984. * @returns an array of textures
  21985. */
  21986. getActiveTextures(): BaseTexture[];
  21987. /**
  21988. * Specifies if the material uses a texture
  21989. * @param texture defines the texture to check against the material
  21990. * @returns a boolean specifying if the material uses the texture
  21991. */
  21992. hasTexture(texture: BaseTexture): boolean;
  21993. /**
  21994. * Makes a duplicate of the material, and gives it a new name
  21995. * @param name defines the new name for the duplicated material
  21996. * @returns the cloned material
  21997. */
  21998. clone(name: string): Nullable<Material>;
  21999. /**
  22000. * Gets the meshes bound to the material
  22001. * @returns an array of meshes bound to the material
  22002. */
  22003. getBindedMeshes(): AbstractMesh[];
  22004. /**
  22005. * Force shader compilation
  22006. * @param mesh defines the mesh associated with this material
  22007. * @param onCompiled defines a function to execute once the material is compiled
  22008. * @param options defines the options to configure the compilation
  22009. */
  22010. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22011. clipPlane: boolean;
  22012. }>): void;
  22013. /**
  22014. * Force shader compilation
  22015. * @param mesh defines the mesh that will use this material
  22016. * @param options defines additional options for compiling the shaders
  22017. * @returns a promise that resolves when the compilation completes
  22018. */
  22019. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22020. clipPlane: boolean;
  22021. }>): Promise<void>;
  22022. private static readonly _ImageProcessingDirtyCallBack;
  22023. private static readonly _TextureDirtyCallBack;
  22024. private static readonly _FresnelDirtyCallBack;
  22025. private static readonly _MiscDirtyCallBack;
  22026. private static readonly _LightsDirtyCallBack;
  22027. private static readonly _AttributeDirtyCallBack;
  22028. private static _FresnelAndMiscDirtyCallBack;
  22029. private static _TextureAndMiscDirtyCallBack;
  22030. private static readonly _DirtyCallbackArray;
  22031. private static readonly _RunDirtyCallBacks;
  22032. /**
  22033. * Marks a define in the material to indicate that it needs to be re-computed
  22034. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22035. */
  22036. markAsDirty(flag: number): void;
  22037. /**
  22038. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22039. * @param func defines a function which checks material defines against the submeshes
  22040. */
  22041. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22042. /**
  22043. * Indicates that image processing needs to be re-calculated for all submeshes
  22044. */
  22045. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22046. /**
  22047. * Indicates that textures need to be re-calculated for all submeshes
  22048. */
  22049. protected _markAllSubMeshesAsTexturesDirty(): void;
  22050. /**
  22051. * Indicates that fresnel needs to be re-calculated for all submeshes
  22052. */
  22053. protected _markAllSubMeshesAsFresnelDirty(): void;
  22054. /**
  22055. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22056. */
  22057. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22058. /**
  22059. * Indicates that lights need to be re-calculated for all submeshes
  22060. */
  22061. protected _markAllSubMeshesAsLightsDirty(): void;
  22062. /**
  22063. * Indicates that attributes need to be re-calculated for all submeshes
  22064. */
  22065. protected _markAllSubMeshesAsAttributesDirty(): void;
  22066. /**
  22067. * Indicates that misc needs to be re-calculated for all submeshes
  22068. */
  22069. protected _markAllSubMeshesAsMiscDirty(): void;
  22070. /**
  22071. * Indicates that textures and misc need to be re-calculated for all submeshes
  22072. */
  22073. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22074. /**
  22075. * Disposes the material
  22076. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22077. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22078. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22079. */
  22080. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22081. /** @hidden */
  22082. private releaseVertexArrayObject;
  22083. /**
  22084. * Serializes this material
  22085. * @returns the serialized material object
  22086. */
  22087. serialize(): any;
  22088. /**
  22089. * Creates a material from parsed material data
  22090. * @param parsedMaterial defines parsed material data
  22091. * @param scene defines the hosting scene
  22092. * @param rootUrl defines the root URL to use to load textures
  22093. * @returns a new material
  22094. */
  22095. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22096. }
  22097. }
  22098. declare module BABYLON {
  22099. /**
  22100. * Base class for submeshes
  22101. */
  22102. export class BaseSubMesh {
  22103. /** @hidden */
  22104. _materialDefines: Nullable<MaterialDefines>;
  22105. /** @hidden */
  22106. _materialEffect: Nullable<Effect>;
  22107. /**
  22108. * Gets associated effect
  22109. */
  22110. readonly effect: Nullable<Effect>;
  22111. /**
  22112. * Sets associated effect (effect used to render this submesh)
  22113. * @param effect defines the effect to associate with
  22114. * @param defines defines the set of defines used to compile this effect
  22115. */
  22116. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22117. }
  22118. /**
  22119. * Defines a subdivision inside a mesh
  22120. */
  22121. export class SubMesh extends BaseSubMesh implements ICullable {
  22122. /** the material index to use */
  22123. materialIndex: number;
  22124. /** vertex index start */
  22125. verticesStart: number;
  22126. /** vertices count */
  22127. verticesCount: number;
  22128. /** index start */
  22129. indexStart: number;
  22130. /** indices count */
  22131. indexCount: number;
  22132. /** @hidden */
  22133. _linesIndexCount: number;
  22134. private _mesh;
  22135. private _renderingMesh;
  22136. private _boundingInfo;
  22137. private _linesIndexBuffer;
  22138. /** @hidden */
  22139. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22140. /** @hidden */
  22141. _trianglePlanes: Plane[];
  22142. /** @hidden */
  22143. _lastColliderTransformMatrix: Matrix;
  22144. /** @hidden */
  22145. _renderId: number;
  22146. /** @hidden */
  22147. _alphaIndex: number;
  22148. /** @hidden */
  22149. _distanceToCamera: number;
  22150. /** @hidden */
  22151. _id: number;
  22152. private _currentMaterial;
  22153. /**
  22154. * Add a new submesh to a mesh
  22155. * @param materialIndex defines the material index to use
  22156. * @param verticesStart defines vertex index start
  22157. * @param verticesCount defines vertices count
  22158. * @param indexStart defines index start
  22159. * @param indexCount defines indices count
  22160. * @param mesh defines the parent mesh
  22161. * @param renderingMesh defines an optional rendering mesh
  22162. * @param createBoundingBox defines if bounding box should be created for this submesh
  22163. * @returns the new submesh
  22164. */
  22165. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22166. /**
  22167. * Creates a new submesh
  22168. * @param materialIndex defines the material index to use
  22169. * @param verticesStart defines vertex index start
  22170. * @param verticesCount defines vertices count
  22171. * @param indexStart defines index start
  22172. * @param indexCount defines indices count
  22173. * @param mesh defines the parent mesh
  22174. * @param renderingMesh defines an optional rendering mesh
  22175. * @param createBoundingBox defines if bounding box should be created for this submesh
  22176. */
  22177. constructor(
  22178. /** the material index to use */
  22179. materialIndex: number,
  22180. /** vertex index start */
  22181. verticesStart: number,
  22182. /** vertices count */
  22183. verticesCount: number,
  22184. /** index start */
  22185. indexStart: number,
  22186. /** indices count */
  22187. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22188. /**
  22189. * Returns true if this submesh covers the entire parent mesh
  22190. * @ignorenaming
  22191. */
  22192. readonly IsGlobal: boolean;
  22193. /**
  22194. * Returns the submesh BoudingInfo object
  22195. * @returns current bounding info (or mesh's one if the submesh is global)
  22196. */
  22197. getBoundingInfo(): BoundingInfo;
  22198. /**
  22199. * Sets the submesh BoundingInfo
  22200. * @param boundingInfo defines the new bounding info to use
  22201. * @returns the SubMesh
  22202. */
  22203. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22204. /**
  22205. * Returns the mesh of the current submesh
  22206. * @return the parent mesh
  22207. */
  22208. getMesh(): AbstractMesh;
  22209. /**
  22210. * Returns the rendering mesh of the submesh
  22211. * @returns the rendering mesh (could be different from parent mesh)
  22212. */
  22213. getRenderingMesh(): Mesh;
  22214. /**
  22215. * Returns the submesh material
  22216. * @returns null or the current material
  22217. */
  22218. getMaterial(): Nullable<Material>;
  22219. /**
  22220. * Sets a new updated BoundingInfo object to the submesh
  22221. * @returns the SubMesh
  22222. */
  22223. refreshBoundingInfo(): SubMesh;
  22224. /** @hidden */
  22225. _checkCollision(collider: Collider): boolean;
  22226. /**
  22227. * Updates the submesh BoundingInfo
  22228. * @param world defines the world matrix to use to update the bounding info
  22229. * @returns the submesh
  22230. */
  22231. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22232. /**
  22233. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22234. * @param frustumPlanes defines the frustum planes
  22235. * @returns true if the submesh is intersecting with the frustum
  22236. */
  22237. isInFrustum(frustumPlanes: Plane[]): boolean;
  22238. /**
  22239. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22240. * @param frustumPlanes defines the frustum planes
  22241. * @returns true if the submesh is inside the frustum
  22242. */
  22243. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22244. /**
  22245. * Renders the submesh
  22246. * @param enableAlphaMode defines if alpha needs to be used
  22247. * @returns the submesh
  22248. */
  22249. render(enableAlphaMode: boolean): SubMesh;
  22250. /**
  22251. * @hidden
  22252. */
  22253. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22254. /**
  22255. * Checks if the submesh intersects with a ray
  22256. * @param ray defines the ray to test
  22257. * @returns true is the passed ray intersects the submesh bounding box
  22258. */
  22259. canIntersects(ray: Ray): boolean;
  22260. /**
  22261. * Intersects current submesh with a ray
  22262. * @param ray defines the ray to test
  22263. * @param positions defines mesh's positions array
  22264. * @param indices defines mesh's indices array
  22265. * @param fastCheck defines if only bounding info should be used
  22266. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22267. * @returns intersection info or null if no intersection
  22268. */
  22269. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22270. /** @hidden */
  22271. private _intersectLines;
  22272. /** @hidden */
  22273. private _intersectTriangles;
  22274. /** @hidden */
  22275. _rebuild(): void;
  22276. /**
  22277. * Creates a new submesh from the passed mesh
  22278. * @param newMesh defines the new hosting mesh
  22279. * @param newRenderingMesh defines an optional rendering mesh
  22280. * @returns the new submesh
  22281. */
  22282. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22283. /**
  22284. * Release associated resources
  22285. */
  22286. dispose(): void;
  22287. /**
  22288. * Gets the class name
  22289. * @returns the string "SubMesh".
  22290. */
  22291. getClassName(): string;
  22292. /**
  22293. * Creates a new submesh from indices data
  22294. * @param materialIndex the index of the main mesh material
  22295. * @param startIndex the index where to start the copy in the mesh indices array
  22296. * @param indexCount the number of indices to copy then from the startIndex
  22297. * @param mesh the main mesh to create the submesh from
  22298. * @param renderingMesh the optional rendering mesh
  22299. * @returns a new submesh
  22300. */
  22301. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22302. }
  22303. }
  22304. declare module BABYLON {
  22305. /**
  22306. * Class used to store geometry data (vertex buffers + index buffer)
  22307. */
  22308. export class Geometry implements IGetSetVerticesData {
  22309. /**
  22310. * Gets or sets the ID of the geometry
  22311. */
  22312. id: string;
  22313. /**
  22314. * Gets or sets the unique ID of the geometry
  22315. */
  22316. uniqueId: number;
  22317. /**
  22318. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22319. */
  22320. delayLoadState: number;
  22321. /**
  22322. * Gets the file containing the data to load when running in delay load state
  22323. */
  22324. delayLoadingFile: Nullable<string>;
  22325. /**
  22326. * Callback called when the geometry is updated
  22327. */
  22328. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22329. private _scene;
  22330. private _engine;
  22331. private _meshes;
  22332. private _totalVertices;
  22333. /** @hidden */
  22334. _indices: IndicesArray;
  22335. /** @hidden */
  22336. _vertexBuffers: {
  22337. [key: string]: VertexBuffer;
  22338. };
  22339. private _isDisposed;
  22340. private _extend;
  22341. private _boundingBias;
  22342. /** @hidden */
  22343. _delayInfo: Array<string>;
  22344. private _indexBuffer;
  22345. private _indexBufferIsUpdatable;
  22346. /** @hidden */
  22347. _boundingInfo: Nullable<BoundingInfo>;
  22348. /** @hidden */
  22349. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22350. /** @hidden */
  22351. _softwareSkinningFrameId: number;
  22352. private _vertexArrayObjects;
  22353. private _updatable;
  22354. /** @hidden */
  22355. _positions: Nullable<Vector3[]>;
  22356. /**
  22357. * 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
  22358. */
  22359. /**
  22360. * 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
  22361. */
  22362. boundingBias: Vector2;
  22363. /**
  22364. * Static function used to attach a new empty geometry to a mesh
  22365. * @param mesh defines the mesh to attach the geometry to
  22366. * @returns the new Geometry
  22367. */
  22368. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22369. /**
  22370. * Creates a new geometry
  22371. * @param id defines the unique ID
  22372. * @param scene defines the hosting scene
  22373. * @param vertexData defines the VertexData used to get geometry data
  22374. * @param updatable defines if geometry must be updatable (false by default)
  22375. * @param mesh defines the mesh that will be associated with the geometry
  22376. */
  22377. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22378. /**
  22379. * Gets the current extend of the geometry
  22380. */
  22381. readonly extend: {
  22382. minimum: Vector3;
  22383. maximum: Vector3;
  22384. };
  22385. /**
  22386. * Gets the hosting scene
  22387. * @returns the hosting Scene
  22388. */
  22389. getScene(): Scene;
  22390. /**
  22391. * Gets the hosting engine
  22392. * @returns the hosting Engine
  22393. */
  22394. getEngine(): Engine;
  22395. /**
  22396. * Defines if the geometry is ready to use
  22397. * @returns true if the geometry is ready to be used
  22398. */
  22399. isReady(): boolean;
  22400. /**
  22401. * Gets a value indicating that the geometry should not be serialized
  22402. */
  22403. readonly doNotSerialize: boolean;
  22404. /** @hidden */
  22405. _rebuild(): void;
  22406. /**
  22407. * Affects all geometry data in one call
  22408. * @param vertexData defines the geometry data
  22409. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22410. */
  22411. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22412. /**
  22413. * Set specific vertex data
  22414. * @param kind defines the data kind (Position, normal, etc...)
  22415. * @param data defines the vertex data to use
  22416. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22417. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22418. */
  22419. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22420. /**
  22421. * Removes a specific vertex data
  22422. * @param kind defines the data kind (Position, normal, etc...)
  22423. */
  22424. removeVerticesData(kind: string): void;
  22425. /**
  22426. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22427. * @param buffer defines the vertex buffer to use
  22428. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22429. */
  22430. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22431. /**
  22432. * Update a specific vertex buffer
  22433. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22434. * It will do nothing if the buffer is not updatable
  22435. * @param kind defines the data kind (Position, normal, etc...)
  22436. * @param data defines the data to use
  22437. * @param offset defines the offset in the target buffer where to store the data
  22438. * @param useBytes set to true if the offset is in bytes
  22439. */
  22440. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22441. /**
  22442. * Update a specific vertex buffer
  22443. * This function will create a new buffer if the current one is not updatable
  22444. * @param kind defines the data kind (Position, normal, etc...)
  22445. * @param data defines the data to use
  22446. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22447. */
  22448. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22449. private _updateBoundingInfo;
  22450. /** @hidden */
  22451. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22452. /**
  22453. * Gets total number of vertices
  22454. * @returns the total number of vertices
  22455. */
  22456. getTotalVertices(): number;
  22457. /**
  22458. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22459. * @param kind defines the data kind (Position, normal, etc...)
  22460. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22461. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22462. * @returns a float array containing vertex data
  22463. */
  22464. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22465. /**
  22466. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22467. * @param kind defines the data kind (Position, normal, etc...)
  22468. * @returns true if the vertex buffer with the specified kind is updatable
  22469. */
  22470. isVertexBufferUpdatable(kind: string): boolean;
  22471. /**
  22472. * Gets a specific vertex buffer
  22473. * @param kind defines the data kind (Position, normal, etc...)
  22474. * @returns a VertexBuffer
  22475. */
  22476. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22477. /**
  22478. * Returns all vertex buffers
  22479. * @return an object holding all vertex buffers indexed by kind
  22480. */
  22481. getVertexBuffers(): Nullable<{
  22482. [key: string]: VertexBuffer;
  22483. }>;
  22484. /**
  22485. * Gets a boolean indicating if specific vertex buffer is present
  22486. * @param kind defines the data kind (Position, normal, etc...)
  22487. * @returns true if data is present
  22488. */
  22489. isVerticesDataPresent(kind: string): boolean;
  22490. /**
  22491. * Gets a list of all attached data kinds (Position, normal, etc...)
  22492. * @returns a list of string containing all kinds
  22493. */
  22494. getVerticesDataKinds(): string[];
  22495. /**
  22496. * Update index buffer
  22497. * @param indices defines the indices to store in the index buffer
  22498. * @param offset defines the offset in the target buffer where to store the data
  22499. * @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)
  22500. */
  22501. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22502. /**
  22503. * Creates a new index buffer
  22504. * @param indices defines the indices to store in the index buffer
  22505. * @param totalVertices defines the total number of vertices (could be null)
  22506. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22507. */
  22508. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22509. /**
  22510. * Return the total number of indices
  22511. * @returns the total number of indices
  22512. */
  22513. getTotalIndices(): number;
  22514. /**
  22515. * Gets the index buffer array
  22516. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22517. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22518. * @returns the index buffer array
  22519. */
  22520. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22521. /**
  22522. * Gets the index buffer
  22523. * @return the index buffer
  22524. */
  22525. getIndexBuffer(): Nullable<WebGLBuffer>;
  22526. /** @hidden */
  22527. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22528. /**
  22529. * Release the associated resources for a specific mesh
  22530. * @param mesh defines the source mesh
  22531. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22532. */
  22533. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22534. /**
  22535. * Apply current geometry to a given mesh
  22536. * @param mesh defines the mesh to apply geometry to
  22537. */
  22538. applyToMesh(mesh: Mesh): void;
  22539. private _updateExtend;
  22540. private _applyToMesh;
  22541. private notifyUpdate;
  22542. /**
  22543. * Load the geometry if it was flagged as delay loaded
  22544. * @param scene defines the hosting scene
  22545. * @param onLoaded defines a callback called when the geometry is loaded
  22546. */
  22547. load(scene: Scene, onLoaded?: () => void): void;
  22548. private _queueLoad;
  22549. /**
  22550. * Invert the geometry to move from a right handed system to a left handed one.
  22551. */
  22552. toLeftHanded(): void;
  22553. /** @hidden */
  22554. _resetPointsArrayCache(): void;
  22555. /** @hidden */
  22556. _generatePointsArray(): boolean;
  22557. /**
  22558. * Gets a value indicating if the geometry is disposed
  22559. * @returns true if the geometry was disposed
  22560. */
  22561. isDisposed(): boolean;
  22562. private _disposeVertexArrayObjects;
  22563. /**
  22564. * Free all associated resources
  22565. */
  22566. dispose(): void;
  22567. /**
  22568. * Clone the current geometry into a new geometry
  22569. * @param id defines the unique ID of the new geometry
  22570. * @returns a new geometry object
  22571. */
  22572. copy(id: string): Geometry;
  22573. /**
  22574. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22575. * @return a JSON representation of the current geometry data (without the vertices data)
  22576. */
  22577. serialize(): any;
  22578. private toNumberArray;
  22579. /**
  22580. * Serialize all vertices data into a JSON oject
  22581. * @returns a JSON representation of the current geometry data
  22582. */
  22583. serializeVerticeData(): any;
  22584. /**
  22585. * Extracts a clone of a mesh geometry
  22586. * @param mesh defines the source mesh
  22587. * @param id defines the unique ID of the new geometry object
  22588. * @returns the new geometry object
  22589. */
  22590. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22591. /**
  22592. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22593. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22594. * Be aware Math.random() could cause collisions, but:
  22595. * "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"
  22596. * @returns a string containing a new GUID
  22597. */
  22598. static RandomId(): string;
  22599. /** @hidden */
  22600. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22601. private static _CleanMatricesWeights;
  22602. /**
  22603. * Create a new geometry from persisted data (Using .babylon file format)
  22604. * @param parsedVertexData defines the persisted data
  22605. * @param scene defines the hosting scene
  22606. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22607. * @returns the new geometry object
  22608. */
  22609. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22610. }
  22611. }
  22612. declare module BABYLON {
  22613. /**
  22614. * Define an interface for all classes that will get and set the data on vertices
  22615. */
  22616. export interface IGetSetVerticesData {
  22617. /**
  22618. * Gets a boolean indicating if specific vertex data is present
  22619. * @param kind defines the vertex data kind to use
  22620. * @returns true is data kind is present
  22621. */
  22622. isVerticesDataPresent(kind: string): boolean;
  22623. /**
  22624. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22625. * @param kind defines the data kind (Position, normal, etc...)
  22626. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22628. * @returns a float array containing vertex data
  22629. */
  22630. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22631. /**
  22632. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22633. * @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.
  22634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22635. * @returns the indices array or an empty array if the mesh has no geometry
  22636. */
  22637. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22638. /**
  22639. * Set specific vertex data
  22640. * @param kind defines the data kind (Position, normal, etc...)
  22641. * @param data defines the vertex data to use
  22642. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22643. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22644. */
  22645. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22646. /**
  22647. * Update a specific associated vertex buffer
  22648. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22649. * - VertexBuffer.PositionKind
  22650. * - VertexBuffer.UVKind
  22651. * - VertexBuffer.UV2Kind
  22652. * - VertexBuffer.UV3Kind
  22653. * - VertexBuffer.UV4Kind
  22654. * - VertexBuffer.UV5Kind
  22655. * - VertexBuffer.UV6Kind
  22656. * - VertexBuffer.ColorKind
  22657. * - VertexBuffer.MatricesIndicesKind
  22658. * - VertexBuffer.MatricesIndicesExtraKind
  22659. * - VertexBuffer.MatricesWeightsKind
  22660. * - VertexBuffer.MatricesWeightsExtraKind
  22661. * @param data defines the data source
  22662. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22663. * @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)
  22664. */
  22665. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22666. /**
  22667. * Creates a new index buffer
  22668. * @param indices defines the indices to store in the index buffer
  22669. * @param totalVertices defines the total number of vertices (could be null)
  22670. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22671. */
  22672. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22673. }
  22674. /**
  22675. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22676. */
  22677. export class VertexData {
  22678. /**
  22679. * Mesh side orientation : usually the external or front surface
  22680. */
  22681. static readonly FRONTSIDE: number;
  22682. /**
  22683. * Mesh side orientation : usually the internal or back surface
  22684. */
  22685. static readonly BACKSIDE: number;
  22686. /**
  22687. * Mesh side orientation : both internal and external or front and back surfaces
  22688. */
  22689. static readonly DOUBLESIDE: number;
  22690. /**
  22691. * Mesh side orientation : by default, `FRONTSIDE`
  22692. */
  22693. static readonly DEFAULTSIDE: number;
  22694. /**
  22695. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22696. */
  22697. positions: Nullable<FloatArray>;
  22698. /**
  22699. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22700. */
  22701. normals: Nullable<FloatArray>;
  22702. /**
  22703. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22704. */
  22705. tangents: Nullable<FloatArray>;
  22706. /**
  22707. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22708. */
  22709. uvs: Nullable<FloatArray>;
  22710. /**
  22711. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22712. */
  22713. uvs2: Nullable<FloatArray>;
  22714. /**
  22715. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22716. */
  22717. uvs3: Nullable<FloatArray>;
  22718. /**
  22719. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22720. */
  22721. uvs4: Nullable<FloatArray>;
  22722. /**
  22723. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22724. */
  22725. uvs5: Nullable<FloatArray>;
  22726. /**
  22727. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22728. */
  22729. uvs6: Nullable<FloatArray>;
  22730. /**
  22731. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22732. */
  22733. colors: Nullable<FloatArray>;
  22734. /**
  22735. * 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).
  22736. */
  22737. matricesIndices: Nullable<FloatArray>;
  22738. /**
  22739. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22740. */
  22741. matricesWeights: Nullable<FloatArray>;
  22742. /**
  22743. * An array extending the number of possible indices
  22744. */
  22745. matricesIndicesExtra: Nullable<FloatArray>;
  22746. /**
  22747. * An array extending the number of possible weights when the number of indices is extended
  22748. */
  22749. matricesWeightsExtra: Nullable<FloatArray>;
  22750. /**
  22751. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22752. */
  22753. indices: Nullable<IndicesArray>;
  22754. /**
  22755. * Uses the passed data array to set the set the values for the specified kind of data
  22756. * @param data a linear array of floating numbers
  22757. * @param kind the type of data that is being set, eg positions, colors etc
  22758. */
  22759. set(data: FloatArray, kind: string): void;
  22760. /**
  22761. * Associates the vertexData to the passed Mesh.
  22762. * Sets it as updatable or not (default `false`)
  22763. * @param mesh the mesh the vertexData is applied to
  22764. * @param updatable when used and having the value true allows new data to update the vertexData
  22765. * @returns the VertexData
  22766. */
  22767. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22768. /**
  22769. * Associates the vertexData to the passed Geometry.
  22770. * Sets it as updatable or not (default `false`)
  22771. * @param geometry the geometry the vertexData is applied to
  22772. * @param updatable when used and having the value true allows new data to update the vertexData
  22773. * @returns VertexData
  22774. */
  22775. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22776. /**
  22777. * Updates the associated mesh
  22778. * @param mesh the mesh to be updated
  22779. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22780. * @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
  22781. * @returns VertexData
  22782. */
  22783. updateMesh(mesh: Mesh): VertexData;
  22784. /**
  22785. * Updates the associated geometry
  22786. * @param geometry the geometry to be updated
  22787. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22788. * @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
  22789. * @returns VertexData.
  22790. */
  22791. updateGeometry(geometry: Geometry): VertexData;
  22792. private _applyTo;
  22793. private _update;
  22794. /**
  22795. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22796. * @param matrix the transforming matrix
  22797. * @returns the VertexData
  22798. */
  22799. transform(matrix: Matrix): VertexData;
  22800. /**
  22801. * Merges the passed VertexData into the current one
  22802. * @param other the VertexData to be merged into the current one
  22803. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22804. * @returns the modified VertexData
  22805. */
  22806. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22807. private _mergeElement;
  22808. private _validate;
  22809. /**
  22810. * Serializes the VertexData
  22811. * @returns a serialized object
  22812. */
  22813. serialize(): any;
  22814. /**
  22815. * Extracts the vertexData from a mesh
  22816. * @param mesh the mesh from which to extract the VertexData
  22817. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22818. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22819. * @returns the object VertexData associated to the passed mesh
  22820. */
  22821. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22822. /**
  22823. * Extracts the vertexData from the geometry
  22824. * @param geometry the geometry from which to extract the VertexData
  22825. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22826. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22827. * @returns the object VertexData associated to the passed mesh
  22828. */
  22829. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22830. private static _ExtractFrom;
  22831. /**
  22832. * Creates the VertexData for a Ribbon
  22833. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22834. * * pathArray array of paths, each of which an array of successive Vector3
  22835. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22836. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22837. * * 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
  22838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22839. * * 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)
  22840. * * 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)
  22841. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22842. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22843. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22844. * @returns the VertexData of the ribbon
  22845. */
  22846. static CreateRibbon(options: {
  22847. pathArray: Vector3[][];
  22848. closeArray?: boolean;
  22849. closePath?: boolean;
  22850. offset?: number;
  22851. sideOrientation?: number;
  22852. frontUVs?: Vector4;
  22853. backUVs?: Vector4;
  22854. invertUV?: boolean;
  22855. uvs?: Vector2[];
  22856. colors?: Color4[];
  22857. }): VertexData;
  22858. /**
  22859. * Creates the VertexData for a box
  22860. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22861. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22862. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22863. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22864. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22865. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22866. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22868. * * 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)
  22869. * * 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)
  22870. * @returns the VertexData of the box
  22871. */
  22872. static CreateBox(options: {
  22873. size?: number;
  22874. width?: number;
  22875. height?: number;
  22876. depth?: number;
  22877. faceUV?: Vector4[];
  22878. faceColors?: Color4[];
  22879. sideOrientation?: number;
  22880. frontUVs?: Vector4;
  22881. backUVs?: Vector4;
  22882. }): VertexData;
  22883. /**
  22884. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22885. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22886. * * segments sets the number of horizontal strips optional, default 32
  22887. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22888. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22889. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22890. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22891. * * 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
  22892. * * 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
  22893. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22894. * * 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)
  22895. * * 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)
  22896. * @returns the VertexData of the ellipsoid
  22897. */
  22898. static CreateSphere(options: {
  22899. segments?: number;
  22900. diameter?: number;
  22901. diameterX?: number;
  22902. diameterY?: number;
  22903. diameterZ?: number;
  22904. arc?: number;
  22905. slice?: number;
  22906. sideOrientation?: number;
  22907. frontUVs?: Vector4;
  22908. backUVs?: Vector4;
  22909. }): VertexData;
  22910. /**
  22911. * Creates the VertexData for a cylinder, cone or prism
  22912. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22913. * * height sets the height (y direction) of the cylinder, optional, default 2
  22914. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22915. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22916. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22917. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22918. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22919. * * 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
  22920. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22921. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22922. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22923. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22925. * * 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)
  22926. * * 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)
  22927. * @returns the VertexData of the cylinder, cone or prism
  22928. */
  22929. static CreateCylinder(options: {
  22930. height?: number;
  22931. diameterTop?: number;
  22932. diameterBottom?: number;
  22933. diameter?: number;
  22934. tessellation?: number;
  22935. subdivisions?: number;
  22936. arc?: number;
  22937. faceColors?: Color4[];
  22938. faceUV?: Vector4[];
  22939. hasRings?: boolean;
  22940. enclose?: boolean;
  22941. sideOrientation?: number;
  22942. frontUVs?: Vector4;
  22943. backUVs?: Vector4;
  22944. }): VertexData;
  22945. /**
  22946. * Creates the VertexData for a torus
  22947. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22948. * * diameter the diameter of the torus, optional default 1
  22949. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22950. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22952. * * 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)
  22953. * * 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)
  22954. * @returns the VertexData of the torus
  22955. */
  22956. static CreateTorus(options: {
  22957. diameter?: number;
  22958. thickness?: number;
  22959. tessellation?: number;
  22960. sideOrientation?: number;
  22961. frontUVs?: Vector4;
  22962. backUVs?: Vector4;
  22963. }): VertexData;
  22964. /**
  22965. * Creates the VertexData of the LineSystem
  22966. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22967. * - lines an array of lines, each line being an array of successive Vector3
  22968. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22969. * @returns the VertexData of the LineSystem
  22970. */
  22971. static CreateLineSystem(options: {
  22972. lines: Vector3[][];
  22973. colors?: Nullable<Color4[][]>;
  22974. }): VertexData;
  22975. /**
  22976. * Create the VertexData for a DashedLines
  22977. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22978. * - points an array successive Vector3
  22979. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22980. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22981. * - dashNb the intended total number of dashes, optional, default 200
  22982. * @returns the VertexData for the DashedLines
  22983. */
  22984. static CreateDashedLines(options: {
  22985. points: Vector3[];
  22986. dashSize?: number;
  22987. gapSize?: number;
  22988. dashNb?: number;
  22989. }): VertexData;
  22990. /**
  22991. * Creates the VertexData for a Ground
  22992. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22993. * - width the width (x direction) of the ground, optional, default 1
  22994. * - height the height (z direction) of the ground, optional, default 1
  22995. * - subdivisions the number of subdivisions per side, optional, default 1
  22996. * @returns the VertexData of the Ground
  22997. */
  22998. static CreateGround(options: {
  22999. width?: number;
  23000. height?: number;
  23001. subdivisions?: number;
  23002. subdivisionsX?: number;
  23003. subdivisionsY?: number;
  23004. }): VertexData;
  23005. /**
  23006. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23007. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23008. * * xmin the ground minimum X coordinate, optional, default -1
  23009. * * zmin the ground minimum Z coordinate, optional, default -1
  23010. * * xmax the ground maximum X coordinate, optional, default 1
  23011. * * zmax the ground maximum Z coordinate, optional, default 1
  23012. * * 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}
  23013. * * 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}
  23014. * @returns the VertexData of the TiledGround
  23015. */
  23016. static CreateTiledGround(options: {
  23017. xmin: number;
  23018. zmin: number;
  23019. xmax: number;
  23020. zmax: number;
  23021. subdivisions?: {
  23022. w: number;
  23023. h: number;
  23024. };
  23025. precision?: {
  23026. w: number;
  23027. h: number;
  23028. };
  23029. }): VertexData;
  23030. /**
  23031. * Creates the VertexData of the Ground designed from a heightmap
  23032. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23033. * * width the width (x direction) of the ground
  23034. * * height the height (z direction) of the ground
  23035. * * subdivisions the number of subdivisions per side
  23036. * * minHeight the minimum altitude on the ground, optional, default 0
  23037. * * maxHeight the maximum altitude on the ground, optional default 1
  23038. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23039. * * buffer the array holding the image color data
  23040. * * bufferWidth the width of image
  23041. * * bufferHeight the height of image
  23042. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23043. * @returns the VertexData of the Ground designed from a heightmap
  23044. */
  23045. static CreateGroundFromHeightMap(options: {
  23046. width: number;
  23047. height: number;
  23048. subdivisions: number;
  23049. minHeight: number;
  23050. maxHeight: number;
  23051. colorFilter: Color3;
  23052. buffer: Uint8Array;
  23053. bufferWidth: number;
  23054. bufferHeight: number;
  23055. alphaFilter: number;
  23056. }): VertexData;
  23057. /**
  23058. * Creates the VertexData for a Plane
  23059. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23060. * * size sets the width and height of the plane to the value of size, optional default 1
  23061. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23062. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23063. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23064. * * 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)
  23065. * * 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)
  23066. * @returns the VertexData of the box
  23067. */
  23068. static CreatePlane(options: {
  23069. size?: number;
  23070. width?: number;
  23071. height?: number;
  23072. sideOrientation?: number;
  23073. frontUVs?: Vector4;
  23074. backUVs?: Vector4;
  23075. }): VertexData;
  23076. /**
  23077. * Creates the VertexData of the Disc or regular Polygon
  23078. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23079. * * radius the radius of the disc, optional default 0.5
  23080. * * tessellation the number of polygon sides, optional, default 64
  23081. * * 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
  23082. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23083. * * 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)
  23084. * * 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)
  23085. * @returns the VertexData of the box
  23086. */
  23087. static CreateDisc(options: {
  23088. radius?: number;
  23089. tessellation?: number;
  23090. arc?: number;
  23091. sideOrientation?: number;
  23092. frontUVs?: Vector4;
  23093. backUVs?: Vector4;
  23094. }): VertexData;
  23095. /**
  23096. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23097. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23098. * @param polygon a mesh built from polygonTriangulation.build()
  23099. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23100. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23101. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23102. * @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)
  23103. * @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)
  23104. * @returns the VertexData of the Polygon
  23105. */
  23106. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23107. /**
  23108. * Creates the VertexData of the IcoSphere
  23109. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23110. * * radius the radius of the IcoSphere, optional default 1
  23111. * * radiusX allows stretching in the x direction, optional, default radius
  23112. * * radiusY allows stretching in the y direction, optional, default radius
  23113. * * radiusZ allows stretching in the z direction, optional, default radius
  23114. * * flat when true creates a flat shaded mesh, optional, default true
  23115. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23117. * * 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)
  23118. * * 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)
  23119. * @returns the VertexData of the IcoSphere
  23120. */
  23121. static CreateIcoSphere(options: {
  23122. radius?: number;
  23123. radiusX?: number;
  23124. radiusY?: number;
  23125. radiusZ?: number;
  23126. flat?: boolean;
  23127. subdivisions?: number;
  23128. sideOrientation?: number;
  23129. frontUVs?: Vector4;
  23130. backUVs?: Vector4;
  23131. }): VertexData;
  23132. /**
  23133. * Creates the VertexData for a Polyhedron
  23134. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23135. * * type provided types are:
  23136. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23137. * * 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)
  23138. * * size the size of the IcoSphere, optional default 1
  23139. * * sizeX allows stretching in the x direction, optional, default size
  23140. * * sizeY allows stretching in the y direction, optional, default size
  23141. * * sizeZ allows stretching in the z direction, optional, default size
  23142. * * 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
  23143. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23144. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23145. * * flat when true creates a flat shaded mesh, optional, default true
  23146. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23148. * * 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)
  23149. * * 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)
  23150. * @returns the VertexData of the Polyhedron
  23151. */
  23152. static CreatePolyhedron(options: {
  23153. type?: number;
  23154. size?: number;
  23155. sizeX?: number;
  23156. sizeY?: number;
  23157. sizeZ?: number;
  23158. custom?: any;
  23159. faceUV?: Vector4[];
  23160. faceColors?: Color4[];
  23161. flat?: boolean;
  23162. sideOrientation?: number;
  23163. frontUVs?: Vector4;
  23164. backUVs?: Vector4;
  23165. }): VertexData;
  23166. /**
  23167. * Creates the VertexData for a TorusKnot
  23168. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23169. * * radius the radius of the torus knot, optional, default 2
  23170. * * tube the thickness of the tube, optional, default 0.5
  23171. * * radialSegments the number of sides on each tube segments, optional, default 32
  23172. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23173. * * p the number of windings around the z axis, optional, default 2
  23174. * * q the number of windings around the x axis, optional, default 3
  23175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23176. * * 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)
  23177. * * 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)
  23178. * @returns the VertexData of the Torus Knot
  23179. */
  23180. static CreateTorusKnot(options: {
  23181. radius?: number;
  23182. tube?: number;
  23183. radialSegments?: number;
  23184. tubularSegments?: number;
  23185. p?: number;
  23186. q?: number;
  23187. sideOrientation?: number;
  23188. frontUVs?: Vector4;
  23189. backUVs?: Vector4;
  23190. }): VertexData;
  23191. /**
  23192. * Compute normals for given positions and indices
  23193. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23194. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23195. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23196. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23197. * * facetNormals : optional array of facet normals (vector3)
  23198. * * facetPositions : optional array of facet positions (vector3)
  23199. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23200. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23201. * * bInfo : optional bounding info, required for facetPartitioning computation
  23202. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23203. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23204. * * useRightHandedSystem: optional boolean to for right handed system computation
  23205. * * depthSort : optional boolean to enable the facet depth sort computation
  23206. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23207. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23208. */
  23209. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23210. facetNormals?: any;
  23211. facetPositions?: any;
  23212. facetPartitioning?: any;
  23213. ratio?: number;
  23214. bInfo?: any;
  23215. bbSize?: Vector3;
  23216. subDiv?: any;
  23217. useRightHandedSystem?: boolean;
  23218. depthSort?: boolean;
  23219. distanceTo?: Vector3;
  23220. depthSortedFacets?: any;
  23221. }): void;
  23222. /** @hidden */
  23223. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23224. /**
  23225. * Applies VertexData created from the imported parameters to the geometry
  23226. * @param parsedVertexData the parsed data from an imported file
  23227. * @param geometry the geometry to apply the VertexData to
  23228. */
  23229. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23230. }
  23231. }
  23232. declare module BABYLON {
  23233. /**
  23234. * Class containing static functions to help procedurally build meshes
  23235. */
  23236. export class DiscBuilder {
  23237. /**
  23238. * Creates a plane polygonal mesh. By default, this is a disc
  23239. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23240. * * 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
  23241. * * 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
  23242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23243. * * 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
  23244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23245. * @param name defines the name of the mesh
  23246. * @param options defines the options used to create the mesh
  23247. * @param scene defines the hosting scene
  23248. * @returns the plane polygonal mesh
  23249. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23250. */
  23251. static CreateDisc(name: string, options: {
  23252. radius?: number;
  23253. tessellation?: number;
  23254. arc?: number;
  23255. updatable?: boolean;
  23256. sideOrientation?: number;
  23257. frontUVs?: Vector4;
  23258. backUVs?: Vector4;
  23259. }, scene?: Nullable<Scene>): Mesh;
  23260. }
  23261. }
  23262. declare module BABYLON {
  23263. /**
  23264. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23265. *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.
  23266. * The SPS is also a particle system. It provides some methods to manage the particles.
  23267. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23268. *
  23269. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23270. */
  23271. export class SolidParticleSystem implements IDisposable {
  23272. /**
  23273. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23274. * Example : var p = SPS.particles[i];
  23275. */
  23276. particles: SolidParticle[];
  23277. /**
  23278. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23279. */
  23280. nbParticles: number;
  23281. /**
  23282. * If the particles must ever face the camera (default false). Useful for planar particles.
  23283. */
  23284. billboard: boolean;
  23285. /**
  23286. * Recompute normals when adding a shape
  23287. */
  23288. recomputeNormals: boolean;
  23289. /**
  23290. * This a counter ofr your own usage. It's not set by any SPS functions.
  23291. */
  23292. counter: number;
  23293. /**
  23294. * The SPS name. This name is also given to the underlying mesh.
  23295. */
  23296. name: string;
  23297. /**
  23298. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23299. */
  23300. mesh: Mesh;
  23301. /**
  23302. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23303. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23304. */
  23305. vars: any;
  23306. /**
  23307. * This array is populated when the SPS is set as 'pickable'.
  23308. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23309. * Each element of this array is an object `{idx: int, faceId: int}`.
  23310. * `idx` is the picked particle index in the `SPS.particles` array
  23311. * `faceId` is the picked face index counted within this particle.
  23312. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23313. */
  23314. pickedParticles: {
  23315. idx: number;
  23316. faceId: number;
  23317. }[];
  23318. /**
  23319. * This array is populated when `enableDepthSort` is set to true.
  23320. * Each element of this array is an instance of the class DepthSortedParticle.
  23321. */
  23322. depthSortedParticles: DepthSortedParticle[];
  23323. /**
  23324. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23325. * @hidden
  23326. */
  23327. _bSphereOnly: boolean;
  23328. /**
  23329. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23330. * @hidden
  23331. */
  23332. _bSphereRadiusFactor: number;
  23333. private _scene;
  23334. private _positions;
  23335. private _indices;
  23336. private _normals;
  23337. private _colors;
  23338. private _uvs;
  23339. private _indices32;
  23340. private _positions32;
  23341. private _normals32;
  23342. private _fixedNormal32;
  23343. private _colors32;
  23344. private _uvs32;
  23345. private _index;
  23346. private _updatable;
  23347. private _pickable;
  23348. private _isVisibilityBoxLocked;
  23349. private _alwaysVisible;
  23350. private _depthSort;
  23351. private _shapeCounter;
  23352. private _copy;
  23353. private _color;
  23354. private _computeParticleColor;
  23355. private _computeParticleTexture;
  23356. private _computeParticleRotation;
  23357. private _computeParticleVertex;
  23358. private _computeBoundingBox;
  23359. private _depthSortParticles;
  23360. private _camera;
  23361. private _mustUnrotateFixedNormals;
  23362. private _particlesIntersect;
  23363. private _needs32Bits;
  23364. /**
  23365. * Creates a SPS (Solid Particle System) object.
  23366. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23367. * @param scene (Scene) is the scene in which the SPS is added.
  23368. * @param options defines the options of the sps e.g.
  23369. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23370. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23371. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23372. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23373. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23374. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23375. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23376. */
  23377. constructor(name: string, scene: Scene, options?: {
  23378. updatable?: boolean;
  23379. isPickable?: boolean;
  23380. enableDepthSort?: boolean;
  23381. particleIntersection?: boolean;
  23382. boundingSphereOnly?: boolean;
  23383. bSphereRadiusFactor?: number;
  23384. });
  23385. /**
  23386. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23387. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23388. * @returns the created mesh
  23389. */
  23390. buildMesh(): Mesh;
  23391. /**
  23392. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23393. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23394. * Thus the particles generated from `digest()` have their property `position` set yet.
  23395. * @param mesh ( Mesh ) is the mesh to be digested
  23396. * @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
  23397. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23398. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23399. * @returns the current SPS
  23400. */
  23401. digest(mesh: Mesh, options?: {
  23402. facetNb?: number;
  23403. number?: number;
  23404. delta?: number;
  23405. }): SolidParticleSystem;
  23406. private _unrotateFixedNormals;
  23407. private _resetCopy;
  23408. private _meshBuilder;
  23409. private _posToShape;
  23410. private _uvsToShapeUV;
  23411. private _addParticle;
  23412. /**
  23413. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23414. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23415. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23416. * @param nb (positive integer) the number of particles to be created from this model
  23417. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23418. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23419. * @returns the number of shapes in the system
  23420. */
  23421. addShape(mesh: Mesh, nb: number, options?: {
  23422. positionFunction?: any;
  23423. vertexFunction?: any;
  23424. }): number;
  23425. private _rebuildParticle;
  23426. /**
  23427. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23428. * @returns the SPS.
  23429. */
  23430. rebuildMesh(): SolidParticleSystem;
  23431. /**
  23432. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23433. * This method calls `updateParticle()` for each particle of the SPS.
  23434. * For an animated SPS, it is usually called within the render loop.
  23435. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23436. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23437. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23438. * @returns the SPS.
  23439. */
  23440. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23441. /**
  23442. * Disposes the SPS.
  23443. */
  23444. dispose(): void;
  23445. /**
  23446. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23447. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23448. * @returns the SPS.
  23449. */
  23450. refreshVisibleSize(): SolidParticleSystem;
  23451. /**
  23452. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23453. * @param size the size (float) of the visibility box
  23454. * note : this doesn't lock the SPS mesh bounding box.
  23455. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23456. */
  23457. setVisibilityBox(size: number): void;
  23458. /**
  23459. * Gets whether the SPS as always visible or not
  23460. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23461. */
  23462. /**
  23463. * Sets the SPS as always visible or not
  23464. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23465. */
  23466. isAlwaysVisible: boolean;
  23467. /**
  23468. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23469. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23470. */
  23471. /**
  23472. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23473. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23474. */
  23475. isVisibilityBoxLocked: boolean;
  23476. /**
  23477. * Tells to `setParticles()` to compute the particle rotations or not.
  23478. * Default value : true. The SPS is faster when it's set to false.
  23479. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23480. */
  23481. /**
  23482. * Gets if `setParticles()` computes the particle rotations or not.
  23483. * Default value : true. The SPS is faster when it's set to false.
  23484. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23485. */
  23486. computeParticleRotation: boolean;
  23487. /**
  23488. * Tells to `setParticles()` to compute the particle colors or not.
  23489. * Default value : true. The SPS is faster when it's set to false.
  23490. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23491. */
  23492. /**
  23493. * Gets if `setParticles()` computes the particle colors or not.
  23494. * Default value : true. The SPS is faster when it's set to false.
  23495. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23496. */
  23497. computeParticleColor: boolean;
  23498. /**
  23499. * Gets if `setParticles()` computes the particle textures or not.
  23500. * Default value : true. The SPS is faster when it's set to false.
  23501. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23502. */
  23503. computeParticleTexture: boolean;
  23504. /**
  23505. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23506. * Default value : false. The SPS is faster when it's set to false.
  23507. * Note : the particle custom vertex positions aren't stored values.
  23508. */
  23509. /**
  23510. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23511. * Default value : false. The SPS is faster when it's set to false.
  23512. * Note : the particle custom vertex positions aren't stored values.
  23513. */
  23514. computeParticleVertex: boolean;
  23515. /**
  23516. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23517. */
  23518. /**
  23519. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23520. */
  23521. computeBoundingBox: boolean;
  23522. /**
  23523. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23524. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23525. * Default : `true`
  23526. */
  23527. /**
  23528. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23529. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23530. * Default : `true`
  23531. */
  23532. depthSortParticles: boolean;
  23533. /**
  23534. * This function does nothing. It may be overwritten to set all the particle first values.
  23535. * The SPS doesn't call this function, you may have to call it by your own.
  23536. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23537. */
  23538. initParticles(): void;
  23539. /**
  23540. * This function does nothing. It may be overwritten to recycle a particle.
  23541. * The SPS doesn't call this function, you may have to call it by your own.
  23542. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23543. * @param particle The particle to recycle
  23544. * @returns the recycled particle
  23545. */
  23546. recycleParticle(particle: SolidParticle): SolidParticle;
  23547. /**
  23548. * Updates a particle : this function should be overwritten by the user.
  23549. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23550. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23551. * @example : just set a particle position or velocity and recycle conditions
  23552. * @param particle The particle to update
  23553. * @returns the updated particle
  23554. */
  23555. updateParticle(particle: SolidParticle): SolidParticle;
  23556. /**
  23557. * Updates a vertex of a particle : it can be overwritten by the user.
  23558. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23559. * @param particle the current particle
  23560. * @param vertex the current index of the current particle
  23561. * @param pt the index of the current vertex in the particle shape
  23562. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23563. * @example : just set a vertex particle position
  23564. * @returns the updated vertex
  23565. */
  23566. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23567. /**
  23568. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23569. * This does nothing and may be overwritten by the user.
  23570. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23571. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23572. * @param update the boolean update value actually passed to setParticles()
  23573. */
  23574. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23575. /**
  23576. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23577. * This will be passed three parameters.
  23578. * This does nothing and may be overwritten by the user.
  23579. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23580. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23581. * @param update the boolean update value actually passed to setParticles()
  23582. */
  23583. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23584. }
  23585. }
  23586. declare module BABYLON {
  23587. /**
  23588. * Represents one particle of a solid particle system.
  23589. */
  23590. export class SolidParticle {
  23591. /**
  23592. * particle global index
  23593. */
  23594. idx: number;
  23595. /**
  23596. * The color of the particle
  23597. */
  23598. color: Nullable<Color4>;
  23599. /**
  23600. * The world space position of the particle.
  23601. */
  23602. position: Vector3;
  23603. /**
  23604. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23605. */
  23606. rotation: Vector3;
  23607. /**
  23608. * The world space rotation quaternion of the particle.
  23609. */
  23610. rotationQuaternion: Nullable<Quaternion>;
  23611. /**
  23612. * The scaling of the particle.
  23613. */
  23614. scaling: Vector3;
  23615. /**
  23616. * The uvs of the particle.
  23617. */
  23618. uvs: Vector4;
  23619. /**
  23620. * The current speed of the particle.
  23621. */
  23622. velocity: Vector3;
  23623. /**
  23624. * The pivot point in the particle local space.
  23625. */
  23626. pivot: Vector3;
  23627. /**
  23628. * Must the particle be translated from its pivot point in its local space ?
  23629. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23630. * Default : false
  23631. */
  23632. translateFromPivot: boolean;
  23633. /**
  23634. * Is the particle active or not ?
  23635. */
  23636. alive: boolean;
  23637. /**
  23638. * Is the particle visible or not ?
  23639. */
  23640. isVisible: boolean;
  23641. /**
  23642. * Index of this particle in the global "positions" array (Internal use)
  23643. * @hidden
  23644. */
  23645. _pos: number;
  23646. /**
  23647. * @hidden Index of this particle in the global "indices" array (Internal use)
  23648. */
  23649. _ind: number;
  23650. /**
  23651. * @hidden ModelShape of this particle (Internal use)
  23652. */
  23653. _model: ModelShape;
  23654. /**
  23655. * ModelShape id of this particle
  23656. */
  23657. shapeId: number;
  23658. /**
  23659. * Index of the particle in its shape id (Internal use)
  23660. */
  23661. idxInShape: number;
  23662. /**
  23663. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23664. */
  23665. _modelBoundingInfo: BoundingInfo;
  23666. /**
  23667. * @hidden Particle BoundingInfo object (Internal use)
  23668. */
  23669. _boundingInfo: BoundingInfo;
  23670. /**
  23671. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23672. */
  23673. _sps: SolidParticleSystem;
  23674. /**
  23675. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23676. */
  23677. _stillInvisible: boolean;
  23678. /**
  23679. * @hidden Last computed particle rotation matrix
  23680. */
  23681. _rotationMatrix: number[];
  23682. /**
  23683. * Parent particle Id, if any.
  23684. * Default null.
  23685. */
  23686. parentId: Nullable<number>;
  23687. /**
  23688. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23689. * The possible values are :
  23690. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23691. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23692. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23693. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23694. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23695. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23696. * */
  23697. cullingStrategy: number;
  23698. /**
  23699. * @hidden Internal global position in the SPS.
  23700. */
  23701. _globalPosition: Vector3;
  23702. /**
  23703. * Creates a Solid Particle object.
  23704. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23705. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23706. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23707. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23708. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23709. * @param shapeId (integer) is the model shape identifier in the SPS.
  23710. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23711. * @param sps defines the sps it is associated to
  23712. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23713. */
  23714. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23715. /**
  23716. * Legacy support, changed scale to scaling
  23717. */
  23718. /**
  23719. * Legacy support, changed scale to scaling
  23720. */
  23721. scale: Vector3;
  23722. /**
  23723. * Legacy support, changed quaternion to rotationQuaternion
  23724. */
  23725. /**
  23726. * Legacy support, changed quaternion to rotationQuaternion
  23727. */
  23728. quaternion: Nullable<Quaternion>;
  23729. /**
  23730. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23731. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23732. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23733. * @returns true if it intersects
  23734. */
  23735. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23736. /**
  23737. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23738. * A particle is in the frustum if its bounding box intersects the frustum
  23739. * @param frustumPlanes defines the frustum to test
  23740. * @returns true if the particle is in the frustum planes
  23741. */
  23742. isInFrustum(frustumPlanes: Plane[]): boolean;
  23743. /**
  23744. * get the rotation matrix of the particle
  23745. * @hidden
  23746. */
  23747. getRotationMatrix(m: Matrix): void;
  23748. }
  23749. /**
  23750. * Represents the shape of the model used by one particle of a solid particle system.
  23751. * SPS internal tool, don't use it manually.
  23752. */
  23753. export class ModelShape {
  23754. /**
  23755. * The shape id
  23756. * @hidden
  23757. */
  23758. shapeID: number;
  23759. /**
  23760. * flat array of model positions (internal use)
  23761. * @hidden
  23762. */
  23763. _shape: Vector3[];
  23764. /**
  23765. * flat array of model UVs (internal use)
  23766. * @hidden
  23767. */
  23768. _shapeUV: number[];
  23769. /**
  23770. * length of the shape in the model indices array (internal use)
  23771. * @hidden
  23772. */
  23773. _indicesLength: number;
  23774. /**
  23775. * Custom position function (internal use)
  23776. * @hidden
  23777. */
  23778. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23779. /**
  23780. * Custom vertex function (internal use)
  23781. * @hidden
  23782. */
  23783. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23784. /**
  23785. * 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.
  23786. * SPS internal tool, don't use it manually.
  23787. * @hidden
  23788. */
  23789. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  23790. }
  23791. /**
  23792. * Represents a Depth Sorted Particle in the solid particle system.
  23793. */
  23794. export class DepthSortedParticle {
  23795. /**
  23796. * Index of the particle in the "indices" array
  23797. */
  23798. ind: number;
  23799. /**
  23800. * Length of the particle shape in the "indices" array
  23801. */
  23802. indicesLength: number;
  23803. /**
  23804. * Squared distance from the particle to the camera
  23805. */
  23806. sqDistance: number;
  23807. }
  23808. }
  23809. declare module BABYLON {
  23810. /**
  23811. * Class used to store all common mesh properties
  23812. */
  23813. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23814. /** No occlusion */
  23815. static OCCLUSION_TYPE_NONE: number;
  23816. /** Occlusion set to optimisitic */
  23817. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23818. /** Occlusion set to strict */
  23819. static OCCLUSION_TYPE_STRICT: number;
  23820. /** Use an accurante occlusion algorithm */
  23821. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23822. /** Use a conservative occlusion algorithm */
  23823. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23824. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23825. * Test order :
  23826. * Is the bounding sphere outside the frustum ?
  23827. * If not, are the bounding box vertices outside the frustum ?
  23828. * It not, then the cullable object is in the frustum.
  23829. */
  23830. static readonly CULLINGSTRATEGY_STANDARD: number;
  23831. /** Culling strategy : Bounding Sphere Only.
  23832. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23833. * It's also less accurate than the standard because some not visible objects can still be selected.
  23834. * Test : is the bounding sphere outside the frustum ?
  23835. * If not, then the cullable object is in the frustum.
  23836. */
  23837. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23838. /** Culling strategy : Optimistic Inclusion.
  23839. * This in an inclusion test first, then the standard exclusion test.
  23840. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23841. * 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.
  23842. * Anyway, it's as accurate as the standard strategy.
  23843. * Test :
  23844. * Is the cullable object bounding sphere center in the frustum ?
  23845. * If not, apply the default culling strategy.
  23846. */
  23847. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23848. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23849. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23850. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23851. * 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.
  23852. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23853. * Test :
  23854. * Is the cullable object bounding sphere center in the frustum ?
  23855. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23856. */
  23857. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23858. /**
  23859. * No billboard
  23860. */
  23861. static readonly BILLBOARDMODE_NONE: number;
  23862. /** Billboard on X axis */
  23863. static readonly BILLBOARDMODE_X: number;
  23864. /** Billboard on Y axis */
  23865. static readonly BILLBOARDMODE_Y: number;
  23866. /** Billboard on Z axis */
  23867. static readonly BILLBOARDMODE_Z: number;
  23868. /** Billboard on all axes */
  23869. static readonly BILLBOARDMODE_ALL: number;
  23870. private _facetData;
  23871. /**
  23872. * The culling strategy to use to check whether the mesh must be rendered or not.
  23873. * This value can be changed at any time and will be used on the next render mesh selection.
  23874. * The possible values are :
  23875. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23876. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23877. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23878. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23879. * Please read each static variable documentation to get details about the culling process.
  23880. * */
  23881. cullingStrategy: number;
  23882. /**
  23883. * Gets the number of facets in the mesh
  23884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23885. */
  23886. readonly facetNb: number;
  23887. /**
  23888. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23890. */
  23891. partitioningSubdivisions: number;
  23892. /**
  23893. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23894. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23896. */
  23897. partitioningBBoxRatio: number;
  23898. /**
  23899. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23900. * Works only for updatable meshes.
  23901. * Doesn't work with multi-materials
  23902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23903. */
  23904. mustDepthSortFacets: boolean;
  23905. /**
  23906. * The location (Vector3) where the facet depth sort must be computed from.
  23907. * By default, the active camera position.
  23908. * Used only when facet depth sort is enabled
  23909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23910. */
  23911. facetDepthSortFrom: Vector3;
  23912. /**
  23913. * gets a boolean indicating if facetData is enabled
  23914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23915. */
  23916. readonly isFacetDataEnabled: boolean;
  23917. /** @hidden */
  23918. _updateNonUniformScalingState(value: boolean): boolean;
  23919. /**
  23920. * An event triggered when this mesh collides with another one
  23921. */
  23922. onCollideObservable: Observable<AbstractMesh>;
  23923. private _onCollideObserver;
  23924. /** Set a function to call when this mesh collides with another one */
  23925. onCollide: () => void;
  23926. /**
  23927. * An event triggered when the collision's position changes
  23928. */
  23929. onCollisionPositionChangeObservable: Observable<Vector3>;
  23930. private _onCollisionPositionChangeObserver;
  23931. /** Set a function to call when the collision's position changes */
  23932. onCollisionPositionChange: () => void;
  23933. /**
  23934. * An event triggered when material is changed
  23935. */
  23936. onMaterialChangedObservable: Observable<AbstractMesh>;
  23937. /**
  23938. * Gets or sets the orientation for POV movement & rotation
  23939. */
  23940. definedFacingForward: boolean;
  23941. /** @hidden */
  23942. _occlusionQuery: Nullable<WebGLQuery>;
  23943. private _visibility;
  23944. /**
  23945. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23946. */
  23947. /**
  23948. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23949. */
  23950. visibility: number;
  23951. /** Gets or sets the alpha index used to sort transparent meshes
  23952. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23953. */
  23954. alphaIndex: number;
  23955. /**
  23956. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23957. */
  23958. isVisible: boolean;
  23959. /**
  23960. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23961. */
  23962. isPickable: boolean;
  23963. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23964. showSubMeshesBoundingBox: boolean;
  23965. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23966. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23967. */
  23968. isBlocker: boolean;
  23969. /**
  23970. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23971. */
  23972. enablePointerMoveEvents: boolean;
  23973. /**
  23974. * Specifies the rendering group id for this mesh (0 by default)
  23975. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23976. */
  23977. renderingGroupId: number;
  23978. private _material;
  23979. /** Gets or sets current material */
  23980. material: Nullable<Material>;
  23981. private _receiveShadows;
  23982. /**
  23983. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23984. * @see http://doc.babylonjs.com/babylon101/shadows
  23985. */
  23986. receiveShadows: boolean;
  23987. /** Defines color to use when rendering outline */
  23988. outlineColor: Color3;
  23989. /** Define width to use when rendering outline */
  23990. outlineWidth: number;
  23991. /** Defines color to use when rendering overlay */
  23992. overlayColor: Color3;
  23993. /** Defines alpha to use when rendering overlay */
  23994. overlayAlpha: number;
  23995. private _hasVertexAlpha;
  23996. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23997. hasVertexAlpha: boolean;
  23998. private _useVertexColors;
  23999. /** 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) */
  24000. useVertexColors: boolean;
  24001. private _computeBonesUsingShaders;
  24002. /**
  24003. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24004. */
  24005. computeBonesUsingShaders: boolean;
  24006. private _numBoneInfluencers;
  24007. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24008. numBoneInfluencers: number;
  24009. private _applyFog;
  24010. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24011. applyFog: boolean;
  24012. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24013. useOctreeForRenderingSelection: boolean;
  24014. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24015. useOctreeForPicking: boolean;
  24016. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24017. useOctreeForCollisions: boolean;
  24018. private _layerMask;
  24019. /**
  24020. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24021. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24022. */
  24023. layerMask: number;
  24024. /**
  24025. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24026. */
  24027. alwaysSelectAsActiveMesh: boolean;
  24028. /**
  24029. * Gets or sets the current action manager
  24030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24031. */
  24032. actionManager: Nullable<AbstractActionManager>;
  24033. private _checkCollisions;
  24034. private _collisionMask;
  24035. private _collisionGroup;
  24036. /**
  24037. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24038. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24039. */
  24040. ellipsoid: Vector3;
  24041. /**
  24042. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24043. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24044. */
  24045. ellipsoidOffset: Vector3;
  24046. private _collider;
  24047. private _oldPositionForCollisions;
  24048. private _diffPositionForCollisions;
  24049. /**
  24050. * Gets or sets a collision mask used to mask collisions (default is -1).
  24051. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24052. */
  24053. collisionMask: number;
  24054. /**
  24055. * Gets or sets the current collision group mask (-1 by default).
  24056. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24057. */
  24058. collisionGroup: number;
  24059. /**
  24060. * Defines edge width used when edgesRenderer is enabled
  24061. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24062. */
  24063. edgesWidth: number;
  24064. /**
  24065. * Defines edge color used when edgesRenderer is enabled
  24066. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24067. */
  24068. edgesColor: Color4;
  24069. /** @hidden */
  24070. _edgesRenderer: Nullable<IEdgesRenderer>;
  24071. /** @hidden */
  24072. _masterMesh: Nullable<AbstractMesh>;
  24073. /** @hidden */
  24074. _boundingInfo: Nullable<BoundingInfo>;
  24075. /** @hidden */
  24076. _renderId: number;
  24077. /**
  24078. * Gets or sets the list of subMeshes
  24079. * @see http://doc.babylonjs.com/how_to/multi_materials
  24080. */
  24081. subMeshes: SubMesh[];
  24082. /** @hidden */
  24083. _intersectionsInProgress: AbstractMesh[];
  24084. /** @hidden */
  24085. _unIndexed: boolean;
  24086. /** @hidden */
  24087. _lightSources: Light[];
  24088. /** @hidden */
  24089. readonly _positions: Nullable<Vector3[]>;
  24090. /** @hidden */
  24091. _waitingActions: any;
  24092. /** @hidden */
  24093. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24094. private _skeleton;
  24095. /** @hidden */
  24096. _bonesTransformMatrices: Nullable<Float32Array>;
  24097. /**
  24098. * Gets or sets a skeleton to apply skining transformations
  24099. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24100. */
  24101. skeleton: Nullable<Skeleton>;
  24102. /**
  24103. * An event triggered when the mesh is rebuilt.
  24104. */
  24105. onRebuildObservable: Observable<AbstractMesh>;
  24106. /**
  24107. * Creates a new AbstractMesh
  24108. * @param name defines the name of the mesh
  24109. * @param scene defines the hosting scene
  24110. */
  24111. constructor(name: string, scene?: Nullable<Scene>);
  24112. /**
  24113. * Returns the string "AbstractMesh"
  24114. * @returns "AbstractMesh"
  24115. */
  24116. getClassName(): string;
  24117. /**
  24118. * Gets a string representation of the current mesh
  24119. * @param fullDetails defines a boolean indicating if full details must be included
  24120. * @returns a string representation of the current mesh
  24121. */
  24122. toString(fullDetails?: boolean): string;
  24123. /**
  24124. * @hidden
  24125. */
  24126. protected _getEffectiveParent(): Nullable<Node>;
  24127. /** @hidden */
  24128. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24129. /** @hidden */
  24130. _rebuild(): void;
  24131. /** @hidden */
  24132. _resyncLightSources(): void;
  24133. /** @hidden */
  24134. _resyncLighSource(light: Light): void;
  24135. /** @hidden */
  24136. _unBindEffect(): void;
  24137. /** @hidden */
  24138. _removeLightSource(light: Light): void;
  24139. private _markSubMeshesAsDirty;
  24140. /** @hidden */
  24141. _markSubMeshesAsLightDirty(): void;
  24142. /** @hidden */
  24143. _markSubMeshesAsAttributesDirty(): void;
  24144. /** @hidden */
  24145. _markSubMeshesAsMiscDirty(): void;
  24146. /**
  24147. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24148. */
  24149. scaling: Vector3;
  24150. /**
  24151. * Returns true if the mesh is blocked. Implemented by child classes
  24152. */
  24153. readonly isBlocked: boolean;
  24154. /**
  24155. * Returns the mesh itself by default. Implemented by child classes
  24156. * @param camera defines the camera to use to pick the right LOD level
  24157. * @returns the currentAbstractMesh
  24158. */
  24159. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24160. /**
  24161. * Returns 0 by default. Implemented by child classes
  24162. * @returns an integer
  24163. */
  24164. getTotalVertices(): number;
  24165. /**
  24166. * Returns a positive integer : the total number of indices in this mesh geometry.
  24167. * @returns the numner of indices or zero if the mesh has no geometry.
  24168. */
  24169. getTotalIndices(): number;
  24170. /**
  24171. * Returns null by default. Implemented by child classes
  24172. * @returns null
  24173. */
  24174. getIndices(): Nullable<IndicesArray>;
  24175. /**
  24176. * Returns the array of the requested vertex data kind. Implemented by child classes
  24177. * @param kind defines the vertex data kind to use
  24178. * @returns null
  24179. */
  24180. getVerticesData(kind: string): Nullable<FloatArray>;
  24181. /**
  24182. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24183. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24184. * Note that a new underlying VertexBuffer object is created each call.
  24185. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24186. * @param kind defines vertex data kind:
  24187. * * VertexBuffer.PositionKind
  24188. * * VertexBuffer.UVKind
  24189. * * VertexBuffer.UV2Kind
  24190. * * VertexBuffer.UV3Kind
  24191. * * VertexBuffer.UV4Kind
  24192. * * VertexBuffer.UV5Kind
  24193. * * VertexBuffer.UV6Kind
  24194. * * VertexBuffer.ColorKind
  24195. * * VertexBuffer.MatricesIndicesKind
  24196. * * VertexBuffer.MatricesIndicesExtraKind
  24197. * * VertexBuffer.MatricesWeightsKind
  24198. * * VertexBuffer.MatricesWeightsExtraKind
  24199. * @param data defines the data source
  24200. * @param updatable defines if the data must be flagged as updatable (or static)
  24201. * @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
  24202. * @returns the current mesh
  24203. */
  24204. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24205. /**
  24206. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24207. * If the mesh has no geometry, it is simply returned as it is.
  24208. * @param kind defines vertex data kind:
  24209. * * VertexBuffer.PositionKind
  24210. * * VertexBuffer.UVKind
  24211. * * VertexBuffer.UV2Kind
  24212. * * VertexBuffer.UV3Kind
  24213. * * VertexBuffer.UV4Kind
  24214. * * VertexBuffer.UV5Kind
  24215. * * VertexBuffer.UV6Kind
  24216. * * VertexBuffer.ColorKind
  24217. * * VertexBuffer.MatricesIndicesKind
  24218. * * VertexBuffer.MatricesIndicesExtraKind
  24219. * * VertexBuffer.MatricesWeightsKind
  24220. * * VertexBuffer.MatricesWeightsExtraKind
  24221. * @param data defines the data source
  24222. * @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
  24223. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24224. * @returns the current mesh
  24225. */
  24226. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24227. /**
  24228. * Sets the mesh indices,
  24229. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24230. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24231. * @param totalVertices Defines the total number of vertices
  24232. * @returns the current mesh
  24233. */
  24234. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24235. /**
  24236. * Gets a boolean indicating if specific vertex data is present
  24237. * @param kind defines the vertex data kind to use
  24238. * @returns true is data kind is present
  24239. */
  24240. isVerticesDataPresent(kind: string): boolean;
  24241. /**
  24242. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24243. * @returns a BoundingInfo
  24244. */
  24245. getBoundingInfo(): BoundingInfo;
  24246. /**
  24247. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24248. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24249. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24250. * @returns the current mesh
  24251. */
  24252. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24253. /**
  24254. * Overwrite the current bounding info
  24255. * @param boundingInfo defines the new bounding info
  24256. * @returns the current mesh
  24257. */
  24258. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24259. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24260. readonly useBones: boolean;
  24261. /** @hidden */
  24262. _preActivate(): void;
  24263. /** @hidden */
  24264. _preActivateForIntermediateRendering(renderId: number): void;
  24265. /** @hidden */
  24266. _activate(renderId: number): void;
  24267. /**
  24268. * Gets the current world matrix
  24269. * @returns a Matrix
  24270. */
  24271. getWorldMatrix(): Matrix;
  24272. /** @hidden */
  24273. _getWorldMatrixDeterminant(): number;
  24274. /**
  24275. * Perform relative position change from the point of view of behind the front of the mesh.
  24276. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24277. * Supports definition of mesh facing forward or backward
  24278. * @param amountRight defines the distance on the right axis
  24279. * @param amountUp defines the distance on the up axis
  24280. * @param amountForward defines the distance on the forward axis
  24281. * @returns the current mesh
  24282. */
  24283. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24284. /**
  24285. * Calculate relative position change from the point of view of behind the front of the mesh.
  24286. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24287. * Supports definition of mesh facing forward or backward
  24288. * @param amountRight defines the distance on the right axis
  24289. * @param amountUp defines the distance on the up axis
  24290. * @param amountForward defines the distance on the forward axis
  24291. * @returns the new displacement vector
  24292. */
  24293. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24294. /**
  24295. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24296. * Supports definition of mesh facing forward or backward
  24297. * @param flipBack defines the flip
  24298. * @param twirlClockwise defines the twirl
  24299. * @param tiltRight defines the tilt
  24300. * @returns the current mesh
  24301. */
  24302. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24303. /**
  24304. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24305. * Supports definition of mesh facing forward or backward.
  24306. * @param flipBack defines the flip
  24307. * @param twirlClockwise defines the twirl
  24308. * @param tiltRight defines the tilt
  24309. * @returns the new rotation vector
  24310. */
  24311. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24312. /**
  24313. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24314. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24315. * @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
  24316. * @returns the new bounding vectors
  24317. */
  24318. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24319. min: Vector3;
  24320. max: Vector3;
  24321. };
  24322. /**
  24323. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24324. * This means the mesh underlying bounding box and sphere are recomputed.
  24325. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24326. * @returns the current mesh
  24327. */
  24328. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24329. /** @hidden */
  24330. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24331. /** @hidden */
  24332. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24333. /** @hidden */
  24334. _updateBoundingInfo(): AbstractMesh;
  24335. /** @hidden */
  24336. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24337. /** @hidden */
  24338. protected _afterComputeWorldMatrix(): void;
  24339. /** @hidden */
  24340. readonly _effectiveMesh: AbstractMesh;
  24341. /**
  24342. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24343. * A mesh is in the frustum if its bounding box intersects the frustum
  24344. * @param frustumPlanes defines the frustum to test
  24345. * @returns true if the mesh is in the frustum planes
  24346. */
  24347. isInFrustum(frustumPlanes: Plane[]): boolean;
  24348. /**
  24349. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24350. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24351. * @param frustumPlanes defines the frustum to test
  24352. * @returns true if the mesh is completely in the frustum planes
  24353. */
  24354. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24355. /**
  24356. * True if the mesh intersects another mesh or a SolidParticle object
  24357. * @param mesh defines a target mesh or SolidParticle to test
  24358. * @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)
  24359. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24360. * @returns true if there is an intersection
  24361. */
  24362. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24363. /**
  24364. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24365. * @param point defines the point to test
  24366. * @returns true if there is an intersection
  24367. */
  24368. intersectsPoint(point: Vector3): boolean;
  24369. /**
  24370. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24371. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24372. */
  24373. checkCollisions: boolean;
  24374. /**
  24375. * Gets Collider object used to compute collisions (not physics)
  24376. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24377. */
  24378. readonly collider: Collider;
  24379. /**
  24380. * Move the mesh using collision engine
  24381. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24382. * @param displacement defines the requested displacement vector
  24383. * @returns the current mesh
  24384. */
  24385. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24386. private _onCollisionPositionChange;
  24387. /** @hidden */
  24388. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24389. /** @hidden */
  24390. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24391. /** @hidden */
  24392. _checkCollision(collider: Collider): AbstractMesh;
  24393. /** @hidden */
  24394. _generatePointsArray(): boolean;
  24395. /**
  24396. * Checks if the passed Ray intersects with the mesh
  24397. * @param ray defines the ray to use
  24398. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24399. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24400. * @returns the picking info
  24401. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24402. */
  24403. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24404. /**
  24405. * Clones the current mesh
  24406. * @param name defines the mesh name
  24407. * @param newParent defines the new mesh parent
  24408. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24409. * @returns the new mesh
  24410. */
  24411. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24412. /**
  24413. * Disposes all the submeshes of the current meshnp
  24414. * @returns the current mesh
  24415. */
  24416. releaseSubMeshes(): AbstractMesh;
  24417. /**
  24418. * Releases resources associated with this abstract mesh.
  24419. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24420. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24421. */
  24422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24423. /**
  24424. * Adds the passed mesh as a child to the current mesh
  24425. * @param mesh defines the child mesh
  24426. * @returns the current mesh
  24427. */
  24428. addChild(mesh: AbstractMesh): AbstractMesh;
  24429. /**
  24430. * Removes the passed mesh from the current mesh children list
  24431. * @param mesh defines the child mesh
  24432. * @returns the current mesh
  24433. */
  24434. removeChild(mesh: AbstractMesh): AbstractMesh;
  24435. /** @hidden */
  24436. private _initFacetData;
  24437. /**
  24438. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24439. * This method can be called within the render loop.
  24440. * 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
  24441. * @returns the current mesh
  24442. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24443. */
  24444. updateFacetData(): AbstractMesh;
  24445. /**
  24446. * Returns the facetLocalNormals array.
  24447. * The normals are expressed in the mesh local spac
  24448. * @returns an array of Vector3
  24449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24450. */
  24451. getFacetLocalNormals(): Vector3[];
  24452. /**
  24453. * Returns the facetLocalPositions array.
  24454. * The facet positions are expressed in the mesh local space
  24455. * @returns an array of Vector3
  24456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24457. */
  24458. getFacetLocalPositions(): Vector3[];
  24459. /**
  24460. * Returns the facetLocalPartioning array
  24461. * @returns an array of array of numbers
  24462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24463. */
  24464. getFacetLocalPartitioning(): number[][];
  24465. /**
  24466. * Returns the i-th facet position in the world system.
  24467. * This method allocates a new Vector3 per call
  24468. * @param i defines the facet index
  24469. * @returns a new Vector3
  24470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24471. */
  24472. getFacetPosition(i: number): Vector3;
  24473. /**
  24474. * Sets the reference Vector3 with the i-th facet position in the world system
  24475. * @param i defines the facet index
  24476. * @param ref defines the target vector
  24477. * @returns the current mesh
  24478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24479. */
  24480. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24481. /**
  24482. * Returns the i-th facet normal in the world system.
  24483. * This method allocates a new Vector3 per call
  24484. * @param i defines the facet index
  24485. * @returns a new Vector3
  24486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24487. */
  24488. getFacetNormal(i: number): Vector3;
  24489. /**
  24490. * Sets the reference Vector3 with the i-th facet normal in the world system
  24491. * @param i defines the facet index
  24492. * @param ref defines the target vector
  24493. * @returns the current mesh
  24494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24495. */
  24496. getFacetNormalToRef(i: number, ref: Vector3): this;
  24497. /**
  24498. * 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)
  24499. * @param x defines x coordinate
  24500. * @param y defines y coordinate
  24501. * @param z defines z coordinate
  24502. * @returns the array of facet indexes
  24503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24504. */
  24505. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24506. /**
  24507. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24508. * @param projected sets as the (x,y,z) world projection on the facet
  24509. * @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
  24510. * @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
  24511. * @param x defines x coordinate
  24512. * @param y defines y coordinate
  24513. * @param z defines z coordinate
  24514. * @returns the face index if found (or null instead)
  24515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24516. */
  24517. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24518. /**
  24519. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24520. * @param projected sets as the (x,y,z) local projection on the facet
  24521. * @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
  24522. * @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
  24523. * @param x defines x coordinate
  24524. * @param y defines y coordinate
  24525. * @param z defines z coordinate
  24526. * @returns the face index if found (or null instead)
  24527. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24528. */
  24529. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24530. /**
  24531. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24532. * @returns the parameters
  24533. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24534. */
  24535. getFacetDataParameters(): any;
  24536. /**
  24537. * Disables the feature FacetData and frees the related memory
  24538. * @returns the current mesh
  24539. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24540. */
  24541. disableFacetData(): AbstractMesh;
  24542. /**
  24543. * Updates the AbstractMesh indices array
  24544. * @param indices defines the data source
  24545. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24546. * @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)
  24547. * @returns the current mesh
  24548. */
  24549. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24550. /**
  24551. * Creates new normals data for the mesh
  24552. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24553. * @returns the current mesh
  24554. */
  24555. createNormals(updatable: boolean): AbstractMesh;
  24556. /**
  24557. * Align the mesh with a normal
  24558. * @param normal defines the normal to use
  24559. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24560. * @returns the current mesh
  24561. */
  24562. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24563. /** @hidden */
  24564. _checkOcclusionQuery(): boolean;
  24565. }
  24566. }
  24567. declare module BABYLON {
  24568. /**
  24569. * Interface used to define ActionEvent
  24570. */
  24571. export interface IActionEvent {
  24572. /** The mesh or sprite that triggered the action */
  24573. source: any;
  24574. /** The X mouse cursor position at the time of the event */
  24575. pointerX: number;
  24576. /** The Y mouse cursor position at the time of the event */
  24577. pointerY: number;
  24578. /** The mesh that is currently pointed at (can be null) */
  24579. meshUnderPointer: Nullable<AbstractMesh>;
  24580. /** the original (browser) event that triggered the ActionEvent */
  24581. sourceEvent?: any;
  24582. /** additional data for the event */
  24583. additionalData?: any;
  24584. }
  24585. /**
  24586. * ActionEvent is the event being sent when an action is triggered.
  24587. */
  24588. export class ActionEvent implements IActionEvent {
  24589. /** The mesh or sprite that triggered the action */
  24590. source: any;
  24591. /** The X mouse cursor position at the time of the event */
  24592. pointerX: number;
  24593. /** The Y mouse cursor position at the time of the event */
  24594. pointerY: number;
  24595. /** The mesh that is currently pointed at (can be null) */
  24596. meshUnderPointer: Nullable<AbstractMesh>;
  24597. /** the original (browser) event that triggered the ActionEvent */
  24598. sourceEvent?: any;
  24599. /** additional data for the event */
  24600. additionalData?: any;
  24601. /**
  24602. * Creates a new ActionEvent
  24603. * @param source The mesh or sprite that triggered the action
  24604. * @param pointerX The X mouse cursor position at the time of the event
  24605. * @param pointerY The Y mouse cursor position at the time of the event
  24606. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24607. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24608. * @param additionalData additional data for the event
  24609. */
  24610. constructor(
  24611. /** The mesh or sprite that triggered the action */
  24612. source: any,
  24613. /** The X mouse cursor position at the time of the event */
  24614. pointerX: number,
  24615. /** The Y mouse cursor position at the time of the event */
  24616. pointerY: number,
  24617. /** The mesh that is currently pointed at (can be null) */
  24618. meshUnderPointer: Nullable<AbstractMesh>,
  24619. /** the original (browser) event that triggered the ActionEvent */
  24620. sourceEvent?: any,
  24621. /** additional data for the event */
  24622. additionalData?: any);
  24623. /**
  24624. * Helper function to auto-create an ActionEvent from a source mesh.
  24625. * @param source The source mesh that triggered the event
  24626. * @param evt The original (browser) event
  24627. * @param additionalData additional data for the event
  24628. * @returns the new ActionEvent
  24629. */
  24630. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24631. /**
  24632. * Helper function to auto-create an ActionEvent from a source sprite
  24633. * @param source The source sprite that triggered the event
  24634. * @param scene Scene associated with the sprite
  24635. * @param evt The original (browser) event
  24636. * @param additionalData additional data for the event
  24637. * @returns the new ActionEvent
  24638. */
  24639. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24640. /**
  24641. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24642. * @param scene the scene where the event occurred
  24643. * @param evt The original (browser) event
  24644. * @returns the new ActionEvent
  24645. */
  24646. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24647. /**
  24648. * Helper function to auto-create an ActionEvent from a primitive
  24649. * @param prim defines the target primitive
  24650. * @param pointerPos defines the pointer position
  24651. * @param evt The original (browser) event
  24652. * @param additionalData additional data for the event
  24653. * @returns the new ActionEvent
  24654. */
  24655. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24656. }
  24657. }
  24658. declare module BABYLON {
  24659. /**
  24660. * Abstract class used to decouple action Manager from scene and meshes.
  24661. * Do not instantiate.
  24662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24663. */
  24664. export abstract class AbstractActionManager implements IDisposable {
  24665. /** Gets the list of active triggers */
  24666. static Triggers: {
  24667. [key: string]: number;
  24668. };
  24669. /** Gets the cursor to use when hovering items */
  24670. hoverCursor: string;
  24671. /** Gets the list of actions */
  24672. actions: IAction[];
  24673. /**
  24674. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24675. */
  24676. isRecursive: boolean;
  24677. /**
  24678. * Releases all associated resources
  24679. */
  24680. abstract dispose(): void;
  24681. /**
  24682. * Does this action manager has pointer triggers
  24683. */
  24684. abstract readonly hasPointerTriggers: boolean;
  24685. /**
  24686. * Does this action manager has pick triggers
  24687. */
  24688. abstract readonly hasPickTriggers: boolean;
  24689. /**
  24690. * Process a specific trigger
  24691. * @param trigger defines the trigger to process
  24692. * @param evt defines the event details to be processed
  24693. */
  24694. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24695. /**
  24696. * Does this action manager handles actions of any of the given triggers
  24697. * @param triggers defines the triggers to be tested
  24698. * @return a boolean indicating whether one (or more) of the triggers is handled
  24699. */
  24700. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24701. /**
  24702. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24703. * speed.
  24704. * @param triggerA defines the trigger to be tested
  24705. * @param triggerB defines the trigger to be tested
  24706. * @return a boolean indicating whether one (or more) of the triggers is handled
  24707. */
  24708. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24709. /**
  24710. * Does this action manager handles actions of a given trigger
  24711. * @param trigger defines the trigger to be tested
  24712. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24713. * @return whether the trigger is handled
  24714. */
  24715. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24716. /**
  24717. * Serialize this manager to a JSON object
  24718. * @param name defines the property name to store this manager
  24719. * @returns a JSON representation of this manager
  24720. */
  24721. abstract serialize(name: string): any;
  24722. /**
  24723. * Registers an action to this action manager
  24724. * @param action defines the action to be registered
  24725. * @return the action amended (prepared) after registration
  24726. */
  24727. abstract registerAction(action: IAction): Nullable<IAction>;
  24728. /**
  24729. * Unregisters an action to this action manager
  24730. * @param action defines the action to be unregistered
  24731. * @return a boolean indicating whether the action has been unregistered
  24732. */
  24733. abstract unregisterAction(action: IAction): Boolean;
  24734. /**
  24735. * Does exist one action manager with at least one trigger
  24736. **/
  24737. static readonly HasTriggers: boolean;
  24738. /**
  24739. * Does exist one action manager with at least one pick trigger
  24740. **/
  24741. static readonly HasPickTriggers: boolean;
  24742. /**
  24743. * Does exist one action manager that handles actions of a given trigger
  24744. * @param trigger defines the trigger to be tested
  24745. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24746. **/
  24747. static HasSpecificTrigger(trigger: number): boolean;
  24748. }
  24749. }
  24750. declare module BABYLON {
  24751. /**
  24752. * Defines how a node can be built from a string name.
  24753. */
  24754. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24755. /**
  24756. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24757. */
  24758. export class Node implements IBehaviorAware<Node> {
  24759. /** @hidden */
  24760. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24761. private static _NodeConstructors;
  24762. /**
  24763. * Add a new node constructor
  24764. * @param type defines the type name of the node to construct
  24765. * @param constructorFunc defines the constructor function
  24766. */
  24767. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24768. /**
  24769. * Returns a node constructor based on type name
  24770. * @param type defines the type name
  24771. * @param name defines the new node name
  24772. * @param scene defines the hosting scene
  24773. * @param options defines optional options to transmit to constructors
  24774. * @returns the new constructor or null
  24775. */
  24776. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24777. /**
  24778. * Gets or sets the name of the node
  24779. */
  24780. name: string;
  24781. /**
  24782. * Gets or sets the id of the node
  24783. */
  24784. id: string;
  24785. /**
  24786. * Gets or sets the unique id of the node
  24787. */
  24788. uniqueId: number;
  24789. /**
  24790. * Gets or sets a string used to store user defined state for the node
  24791. */
  24792. state: string;
  24793. /**
  24794. * Gets or sets an object used to store user defined information for the node
  24795. */
  24796. metadata: any;
  24797. /**
  24798. * For internal use only. Please do not use.
  24799. */
  24800. reservedDataStore: any;
  24801. /**
  24802. * List of inspectable custom properties (used by the Inspector)
  24803. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24804. */
  24805. inspectableCustomProperties: IInspectable[];
  24806. /**
  24807. * Gets or sets a boolean used to define if the node must be serialized
  24808. */
  24809. doNotSerialize: boolean;
  24810. /** @hidden */
  24811. _isDisposed: boolean;
  24812. /**
  24813. * Gets a list of Animations associated with the node
  24814. */
  24815. animations: Animation[];
  24816. protected _ranges: {
  24817. [name: string]: Nullable<AnimationRange>;
  24818. };
  24819. /**
  24820. * Callback raised when the node is ready to be used
  24821. */
  24822. onReady: (node: Node) => void;
  24823. private _isEnabled;
  24824. private _isParentEnabled;
  24825. private _isReady;
  24826. /** @hidden */
  24827. _currentRenderId: number;
  24828. private _parentUpdateId;
  24829. protected _childUpdateId: number;
  24830. /** @hidden */
  24831. _waitingParentId: Nullable<string>;
  24832. /** @hidden */
  24833. _scene: Scene;
  24834. /** @hidden */
  24835. _cache: any;
  24836. private _parentNode;
  24837. private _children;
  24838. /** @hidden */
  24839. _worldMatrix: Matrix;
  24840. /** @hidden */
  24841. _worldMatrixDeterminant: number;
  24842. /** @hidden */
  24843. private _sceneRootNodesIndex;
  24844. /**
  24845. * Gets a boolean indicating if the node has been disposed
  24846. * @returns true if the node was disposed
  24847. */
  24848. isDisposed(): boolean;
  24849. /**
  24850. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24851. * @see https://doc.babylonjs.com/how_to/parenting
  24852. */
  24853. parent: Nullable<Node>;
  24854. private addToSceneRootNodes;
  24855. private removeFromSceneRootNodes;
  24856. private _animationPropertiesOverride;
  24857. /**
  24858. * Gets or sets the animation properties override
  24859. */
  24860. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24861. /**
  24862. * Gets a string idenfifying the name of the class
  24863. * @returns "Node" string
  24864. */
  24865. getClassName(): string;
  24866. /** @hidden */
  24867. readonly _isNode: boolean;
  24868. /**
  24869. * An event triggered when the mesh is disposed
  24870. */
  24871. onDisposeObservable: Observable<Node>;
  24872. private _onDisposeObserver;
  24873. /**
  24874. * Sets a callback that will be raised when the node will be disposed
  24875. */
  24876. onDispose: () => void;
  24877. /**
  24878. * Creates a new Node
  24879. * @param name the name and id to be given to this node
  24880. * @param scene the scene this node will be added to
  24881. * @param addToRootNodes the node will be added to scene.rootNodes
  24882. */
  24883. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24884. /**
  24885. * Gets the scene of the node
  24886. * @returns a scene
  24887. */
  24888. getScene(): Scene;
  24889. /**
  24890. * Gets the engine of the node
  24891. * @returns a Engine
  24892. */
  24893. getEngine(): Engine;
  24894. private _behaviors;
  24895. /**
  24896. * Attach a behavior to the node
  24897. * @see http://doc.babylonjs.com/features/behaviour
  24898. * @param behavior defines the behavior to attach
  24899. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24900. * @returns the current Node
  24901. */
  24902. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24903. /**
  24904. * Remove an attached behavior
  24905. * @see http://doc.babylonjs.com/features/behaviour
  24906. * @param behavior defines the behavior to attach
  24907. * @returns the current Node
  24908. */
  24909. removeBehavior(behavior: Behavior<Node>): Node;
  24910. /**
  24911. * Gets the list of attached behaviors
  24912. * @see http://doc.babylonjs.com/features/behaviour
  24913. */
  24914. readonly behaviors: Behavior<Node>[];
  24915. /**
  24916. * Gets an attached behavior by name
  24917. * @param name defines the name of the behavior to look for
  24918. * @see http://doc.babylonjs.com/features/behaviour
  24919. * @returns null if behavior was not found else the requested behavior
  24920. */
  24921. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24922. /**
  24923. * Returns the latest update of the World matrix
  24924. * @returns a Matrix
  24925. */
  24926. getWorldMatrix(): Matrix;
  24927. /** @hidden */
  24928. _getWorldMatrixDeterminant(): number;
  24929. /**
  24930. * Returns directly the latest state of the mesh World matrix.
  24931. * A Matrix is returned.
  24932. */
  24933. readonly worldMatrixFromCache: Matrix;
  24934. /** @hidden */
  24935. _initCache(): void;
  24936. /** @hidden */
  24937. updateCache(force?: boolean): void;
  24938. /** @hidden */
  24939. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24940. /** @hidden */
  24941. _updateCache(ignoreParentClass?: boolean): void;
  24942. /** @hidden */
  24943. _isSynchronized(): boolean;
  24944. /** @hidden */
  24945. _markSyncedWithParent(): void;
  24946. /** @hidden */
  24947. isSynchronizedWithParent(): boolean;
  24948. /** @hidden */
  24949. isSynchronized(): boolean;
  24950. /**
  24951. * Is this node ready to be used/rendered
  24952. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24953. * @return true if the node is ready
  24954. */
  24955. isReady(completeCheck?: boolean): boolean;
  24956. /**
  24957. * Is this node enabled?
  24958. * 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
  24959. * @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
  24960. * @return whether this node (and its parent) is enabled
  24961. */
  24962. isEnabled(checkAncestors?: boolean): boolean;
  24963. /** @hidden */
  24964. protected _syncParentEnabledState(): void;
  24965. /**
  24966. * Set the enabled state of this node
  24967. * @param value defines the new enabled state
  24968. */
  24969. setEnabled(value: boolean): void;
  24970. /**
  24971. * Is this node a descendant of the given node?
  24972. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24973. * @param ancestor defines the parent node to inspect
  24974. * @returns a boolean indicating if this node is a descendant of the given node
  24975. */
  24976. isDescendantOf(ancestor: Node): boolean;
  24977. /** @hidden */
  24978. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24979. /**
  24980. * Will return all nodes that have this node as ascendant
  24981. * @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
  24982. * @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
  24983. * @return all children nodes of all types
  24984. */
  24985. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24986. /**
  24987. * Get all child-meshes of this node
  24988. * @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)
  24989. * @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
  24990. * @returns an array of AbstractMesh
  24991. */
  24992. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24993. /**
  24994. * Get all direct children of this node
  24995. * @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
  24996. * @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)
  24997. * @returns an array of Node
  24998. */
  24999. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25000. /** @hidden */
  25001. _setReady(state: boolean): void;
  25002. /**
  25003. * Get an animation by name
  25004. * @param name defines the name of the animation to look for
  25005. * @returns null if not found else the requested animation
  25006. */
  25007. getAnimationByName(name: string): Nullable<Animation>;
  25008. /**
  25009. * Creates an animation range for this node
  25010. * @param name defines the name of the range
  25011. * @param from defines the starting key
  25012. * @param to defines the end key
  25013. */
  25014. createAnimationRange(name: string, from: number, to: number): void;
  25015. /**
  25016. * Delete a specific animation range
  25017. * @param name defines the name of the range to delete
  25018. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25019. */
  25020. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25021. /**
  25022. * Get an animation range by name
  25023. * @param name defines the name of the animation range to look for
  25024. * @returns null if not found else the requested animation range
  25025. */
  25026. getAnimationRange(name: string): Nullable<AnimationRange>;
  25027. /**
  25028. * Gets the list of all animation ranges defined on this node
  25029. * @returns an array
  25030. */
  25031. getAnimationRanges(): Nullable<AnimationRange>[];
  25032. /**
  25033. * Will start the animation sequence
  25034. * @param name defines the range frames for animation sequence
  25035. * @param loop defines if the animation should loop (false by default)
  25036. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25037. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25038. * @returns the object created for this animation. If range does not exist, it will return null
  25039. */
  25040. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25041. /**
  25042. * Serialize animation ranges into a JSON compatible object
  25043. * @returns serialization object
  25044. */
  25045. serializeAnimationRanges(): any;
  25046. /**
  25047. * Computes the world matrix of the node
  25048. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25049. * @returns the world matrix
  25050. */
  25051. computeWorldMatrix(force?: boolean): Matrix;
  25052. /**
  25053. * Releases resources associated with this node.
  25054. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25055. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25056. */
  25057. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25058. /**
  25059. * Parse animation range data from a serialization object and store them into a given node
  25060. * @param node defines where to store the animation ranges
  25061. * @param parsedNode defines the serialization object to read data from
  25062. * @param scene defines the hosting scene
  25063. */
  25064. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25065. }
  25066. }
  25067. declare module BABYLON {
  25068. /**
  25069. * Class used to store any kind of animation
  25070. */
  25071. export class Animation {
  25072. /**Name of the animation */
  25073. name: string;
  25074. /**Property to animate */
  25075. targetProperty: string;
  25076. /**The frames per second of the animation */
  25077. framePerSecond: number;
  25078. /**The data type of the animation */
  25079. dataType: number;
  25080. /**The loop mode of the animation */
  25081. loopMode?: number | undefined;
  25082. /**Specifies if blending should be enabled */
  25083. enableBlending?: boolean | undefined;
  25084. /**
  25085. * Use matrix interpolation instead of using direct key value when animating matrices
  25086. */
  25087. static AllowMatricesInterpolation: boolean;
  25088. /**
  25089. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25090. */
  25091. static AllowMatrixDecomposeForInterpolation: boolean;
  25092. /**
  25093. * Stores the key frames of the animation
  25094. */
  25095. private _keys;
  25096. /**
  25097. * Stores the easing function of the animation
  25098. */
  25099. private _easingFunction;
  25100. /**
  25101. * @hidden Internal use only
  25102. */
  25103. _runtimeAnimations: RuntimeAnimation[];
  25104. /**
  25105. * The set of event that will be linked to this animation
  25106. */
  25107. private _events;
  25108. /**
  25109. * Stores an array of target property paths
  25110. */
  25111. targetPropertyPath: string[];
  25112. /**
  25113. * Stores the blending speed of the animation
  25114. */
  25115. blendingSpeed: number;
  25116. /**
  25117. * Stores the animation ranges for the animation
  25118. */
  25119. private _ranges;
  25120. /**
  25121. * @hidden Internal use
  25122. */
  25123. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25124. /**
  25125. * Sets up an animation
  25126. * @param property The property to animate
  25127. * @param animationType The animation type to apply
  25128. * @param framePerSecond The frames per second of the animation
  25129. * @param easingFunction The easing function used in the animation
  25130. * @returns The created animation
  25131. */
  25132. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25133. /**
  25134. * Create and start an animation on a node
  25135. * @param name defines the name of the global animation that will be run on all nodes
  25136. * @param node defines the root node where the animation will take place
  25137. * @param targetProperty defines property to animate
  25138. * @param framePerSecond defines the number of frame per second yo use
  25139. * @param totalFrame defines the number of frames in total
  25140. * @param from defines the initial value
  25141. * @param to defines the final value
  25142. * @param loopMode defines which loop mode you want to use (off by default)
  25143. * @param easingFunction defines the easing function to use (linear by default)
  25144. * @param onAnimationEnd defines the callback to call when animation end
  25145. * @returns the animatable created for this animation
  25146. */
  25147. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25148. /**
  25149. * Create and start an animation on a node and its descendants
  25150. * @param name defines the name of the global animation that will be run on all nodes
  25151. * @param node defines the root node where the animation will take place
  25152. * @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
  25153. * @param targetProperty defines property to animate
  25154. * @param framePerSecond defines the number of frame per second to use
  25155. * @param totalFrame defines the number of frames in total
  25156. * @param from defines the initial value
  25157. * @param to defines the final value
  25158. * @param loopMode defines which loop mode you want to use (off by default)
  25159. * @param easingFunction defines the easing function to use (linear by default)
  25160. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25161. * @returns the list of animatables created for all nodes
  25162. * @example https://www.babylonjs-playground.com/#MH0VLI
  25163. */
  25164. 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[]>;
  25165. /**
  25166. * Creates a new animation, merges it with the existing animations and starts it
  25167. * @param name Name of the animation
  25168. * @param node Node which contains the scene that begins the animations
  25169. * @param targetProperty Specifies which property to animate
  25170. * @param framePerSecond The frames per second of the animation
  25171. * @param totalFrame The total number of frames
  25172. * @param from The frame at the beginning of the animation
  25173. * @param to The frame at the end of the animation
  25174. * @param loopMode Specifies the loop mode of the animation
  25175. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25176. * @param onAnimationEnd Callback to run once the animation is complete
  25177. * @returns Nullable animation
  25178. */
  25179. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25180. /**
  25181. * Transition property of an host to the target Value
  25182. * @param property The property to transition
  25183. * @param targetValue The target Value of the property
  25184. * @param host The object where the property to animate belongs
  25185. * @param scene Scene used to run the animation
  25186. * @param frameRate Framerate (in frame/s) to use
  25187. * @param transition The transition type we want to use
  25188. * @param duration The duration of the animation, in milliseconds
  25189. * @param onAnimationEnd Callback trigger at the end of the animation
  25190. * @returns Nullable animation
  25191. */
  25192. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25193. /**
  25194. * Return the array of runtime animations currently using this animation
  25195. */
  25196. readonly runtimeAnimations: RuntimeAnimation[];
  25197. /**
  25198. * Specifies if any of the runtime animations are currently running
  25199. */
  25200. readonly hasRunningRuntimeAnimations: boolean;
  25201. /**
  25202. * Initializes the animation
  25203. * @param name Name of the animation
  25204. * @param targetProperty Property to animate
  25205. * @param framePerSecond The frames per second of the animation
  25206. * @param dataType The data type of the animation
  25207. * @param loopMode The loop mode of the animation
  25208. * @param enableBlending Specifies if blending should be enabled
  25209. */
  25210. constructor(
  25211. /**Name of the animation */
  25212. name: string,
  25213. /**Property to animate */
  25214. targetProperty: string,
  25215. /**The frames per second of the animation */
  25216. framePerSecond: number,
  25217. /**The data type of the animation */
  25218. dataType: number,
  25219. /**The loop mode of the animation */
  25220. loopMode?: number | undefined,
  25221. /**Specifies if blending should be enabled */
  25222. enableBlending?: boolean | undefined);
  25223. /**
  25224. * Converts the animation to a string
  25225. * @param fullDetails support for multiple levels of logging within scene loading
  25226. * @returns String form of the animation
  25227. */
  25228. toString(fullDetails?: boolean): string;
  25229. /**
  25230. * Add an event to this animation
  25231. * @param event Event to add
  25232. */
  25233. addEvent(event: AnimationEvent): void;
  25234. /**
  25235. * Remove all events found at the given frame
  25236. * @param frame The frame to remove events from
  25237. */
  25238. removeEvents(frame: number): void;
  25239. /**
  25240. * Retrieves all the events from the animation
  25241. * @returns Events from the animation
  25242. */
  25243. getEvents(): AnimationEvent[];
  25244. /**
  25245. * Creates an animation range
  25246. * @param name Name of the animation range
  25247. * @param from Starting frame of the animation range
  25248. * @param to Ending frame of the animation
  25249. */
  25250. createRange(name: string, from: number, to: number): void;
  25251. /**
  25252. * Deletes an animation range by name
  25253. * @param name Name of the animation range to delete
  25254. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25255. */
  25256. deleteRange(name: string, deleteFrames?: boolean): void;
  25257. /**
  25258. * Gets the animation range by name, or null if not defined
  25259. * @param name Name of the animation range
  25260. * @returns Nullable animation range
  25261. */
  25262. getRange(name: string): Nullable<AnimationRange>;
  25263. /**
  25264. * Gets the key frames from the animation
  25265. * @returns The key frames of the animation
  25266. */
  25267. getKeys(): Array<IAnimationKey>;
  25268. /**
  25269. * Gets the highest frame rate of the animation
  25270. * @returns Highest frame rate of the animation
  25271. */
  25272. getHighestFrame(): number;
  25273. /**
  25274. * Gets the easing function of the animation
  25275. * @returns Easing function of the animation
  25276. */
  25277. getEasingFunction(): IEasingFunction;
  25278. /**
  25279. * Sets the easing function of the animation
  25280. * @param easingFunction A custom mathematical formula for animation
  25281. */
  25282. setEasingFunction(easingFunction: EasingFunction): void;
  25283. /**
  25284. * Interpolates a scalar linearly
  25285. * @param startValue Start value of the animation curve
  25286. * @param endValue End value of the animation curve
  25287. * @param gradient Scalar amount to interpolate
  25288. * @returns Interpolated scalar value
  25289. */
  25290. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25291. /**
  25292. * Interpolates a scalar cubically
  25293. * @param startValue Start value of the animation curve
  25294. * @param outTangent End tangent of the animation
  25295. * @param endValue End value of the animation curve
  25296. * @param inTangent Start tangent of the animation curve
  25297. * @param gradient Scalar amount to interpolate
  25298. * @returns Interpolated scalar value
  25299. */
  25300. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25301. /**
  25302. * Interpolates a quaternion using a spherical linear interpolation
  25303. * @param startValue Start value of the animation curve
  25304. * @param endValue End value of the animation curve
  25305. * @param gradient Scalar amount to interpolate
  25306. * @returns Interpolated quaternion value
  25307. */
  25308. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25309. /**
  25310. * Interpolates a quaternion cubically
  25311. * @param startValue Start value of the animation curve
  25312. * @param outTangent End tangent of the animation curve
  25313. * @param endValue End value of the animation curve
  25314. * @param inTangent Start tangent of the animation curve
  25315. * @param gradient Scalar amount to interpolate
  25316. * @returns Interpolated quaternion value
  25317. */
  25318. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25319. /**
  25320. * Interpolates a Vector3 linearl
  25321. * @param startValue Start value of the animation curve
  25322. * @param endValue End value of the animation curve
  25323. * @param gradient Scalar amount to interpolate
  25324. * @returns Interpolated scalar value
  25325. */
  25326. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25327. /**
  25328. * Interpolates a Vector3 cubically
  25329. * @param startValue Start value of the animation curve
  25330. * @param outTangent End tangent of the animation
  25331. * @param endValue End value of the animation curve
  25332. * @param inTangent Start tangent of the animation curve
  25333. * @param gradient Scalar amount to interpolate
  25334. * @returns InterpolatedVector3 value
  25335. */
  25336. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25337. /**
  25338. * Interpolates a Vector2 linearly
  25339. * @param startValue Start value of the animation curve
  25340. * @param endValue End value of the animation curve
  25341. * @param gradient Scalar amount to interpolate
  25342. * @returns Interpolated Vector2 value
  25343. */
  25344. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25345. /**
  25346. * Interpolates a Vector2 cubically
  25347. * @param startValue Start value of the animation curve
  25348. * @param outTangent End tangent of the animation
  25349. * @param endValue End value of the animation curve
  25350. * @param inTangent Start tangent of the animation curve
  25351. * @param gradient Scalar amount to interpolate
  25352. * @returns Interpolated Vector2 value
  25353. */
  25354. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25355. /**
  25356. * Interpolates a size linearly
  25357. * @param startValue Start value of the animation curve
  25358. * @param endValue End value of the animation curve
  25359. * @param gradient Scalar amount to interpolate
  25360. * @returns Interpolated Size value
  25361. */
  25362. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25363. /**
  25364. * Interpolates a Color3 linearly
  25365. * @param startValue Start value of the animation curve
  25366. * @param endValue End value of the animation curve
  25367. * @param gradient Scalar amount to interpolate
  25368. * @returns Interpolated Color3 value
  25369. */
  25370. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25371. /**
  25372. * @hidden Internal use only
  25373. */
  25374. _getKeyValue(value: any): any;
  25375. /**
  25376. * @hidden Internal use only
  25377. */
  25378. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25379. /**
  25380. * Defines the function to use to interpolate matrices
  25381. * @param startValue defines the start matrix
  25382. * @param endValue defines the end matrix
  25383. * @param gradient defines the gradient between both matrices
  25384. * @param result defines an optional target matrix where to store the interpolation
  25385. * @returns the interpolated matrix
  25386. */
  25387. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25388. /**
  25389. * Makes a copy of the animation
  25390. * @returns Cloned animation
  25391. */
  25392. clone(): Animation;
  25393. /**
  25394. * Sets the key frames of the animation
  25395. * @param values The animation key frames to set
  25396. */
  25397. setKeys(values: Array<IAnimationKey>): void;
  25398. /**
  25399. * Serializes the animation to an object
  25400. * @returns Serialized object
  25401. */
  25402. serialize(): any;
  25403. /**
  25404. * Float animation type
  25405. */
  25406. private static _ANIMATIONTYPE_FLOAT;
  25407. /**
  25408. * Vector3 animation type
  25409. */
  25410. private static _ANIMATIONTYPE_VECTOR3;
  25411. /**
  25412. * Quaternion animation type
  25413. */
  25414. private static _ANIMATIONTYPE_QUATERNION;
  25415. /**
  25416. * Matrix animation type
  25417. */
  25418. private static _ANIMATIONTYPE_MATRIX;
  25419. /**
  25420. * Color3 animation type
  25421. */
  25422. private static _ANIMATIONTYPE_COLOR3;
  25423. /**
  25424. * Vector2 animation type
  25425. */
  25426. private static _ANIMATIONTYPE_VECTOR2;
  25427. /**
  25428. * Size animation type
  25429. */
  25430. private static _ANIMATIONTYPE_SIZE;
  25431. /**
  25432. * Relative Loop Mode
  25433. */
  25434. private static _ANIMATIONLOOPMODE_RELATIVE;
  25435. /**
  25436. * Cycle Loop Mode
  25437. */
  25438. private static _ANIMATIONLOOPMODE_CYCLE;
  25439. /**
  25440. * Constant Loop Mode
  25441. */
  25442. private static _ANIMATIONLOOPMODE_CONSTANT;
  25443. /**
  25444. * Get the float animation type
  25445. */
  25446. static readonly ANIMATIONTYPE_FLOAT: number;
  25447. /**
  25448. * Get the Vector3 animation type
  25449. */
  25450. static readonly ANIMATIONTYPE_VECTOR3: number;
  25451. /**
  25452. * Get the Vector2 animation type
  25453. */
  25454. static readonly ANIMATIONTYPE_VECTOR2: number;
  25455. /**
  25456. * Get the Size animation type
  25457. */
  25458. static readonly ANIMATIONTYPE_SIZE: number;
  25459. /**
  25460. * Get the Quaternion animation type
  25461. */
  25462. static readonly ANIMATIONTYPE_QUATERNION: number;
  25463. /**
  25464. * Get the Matrix animation type
  25465. */
  25466. static readonly ANIMATIONTYPE_MATRIX: number;
  25467. /**
  25468. * Get the Color3 animation type
  25469. */
  25470. static readonly ANIMATIONTYPE_COLOR3: number;
  25471. /**
  25472. * Get the Relative Loop Mode
  25473. */
  25474. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25475. /**
  25476. * Get the Cycle Loop Mode
  25477. */
  25478. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25479. /**
  25480. * Get the Constant Loop Mode
  25481. */
  25482. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25483. /** @hidden */
  25484. static _UniversalLerp(left: any, right: any, amount: number): any;
  25485. /**
  25486. * Parses an animation object and creates an animation
  25487. * @param parsedAnimation Parsed animation object
  25488. * @returns Animation object
  25489. */
  25490. static Parse(parsedAnimation: any): Animation;
  25491. /**
  25492. * Appends the serialized animations from the source animations
  25493. * @param source Source containing the animations
  25494. * @param destination Target to store the animations
  25495. */
  25496. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25497. }
  25498. }
  25499. declare module BABYLON {
  25500. /**
  25501. * Base class of all the textures in babylon.
  25502. * It groups all the common properties the materials, post process, lights... might need
  25503. * in order to make a correct use of the texture.
  25504. */
  25505. export class BaseTexture implements IAnimatable {
  25506. /**
  25507. * Default anisotropic filtering level for the application.
  25508. * It is set to 4 as a good tradeoff between perf and quality.
  25509. */
  25510. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25511. /**
  25512. * Gets or sets the unique id of the texture
  25513. */
  25514. uniqueId: number;
  25515. /**
  25516. * Define the name of the texture.
  25517. */
  25518. name: string;
  25519. /**
  25520. * Gets or sets an object used to store user defined information.
  25521. */
  25522. metadata: any;
  25523. /**
  25524. * For internal use only. Please do not use.
  25525. */
  25526. reservedDataStore: any;
  25527. private _hasAlpha;
  25528. /**
  25529. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25530. */
  25531. hasAlpha: boolean;
  25532. /**
  25533. * Defines if the alpha value should be determined via the rgb values.
  25534. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25535. */
  25536. getAlphaFromRGB: boolean;
  25537. /**
  25538. * Intensity or strength of the texture.
  25539. * It is commonly used by materials to fine tune the intensity of the texture
  25540. */
  25541. level: number;
  25542. /**
  25543. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25544. * This is part of the texture as textures usually maps to one uv set.
  25545. */
  25546. coordinatesIndex: number;
  25547. private _coordinatesMode;
  25548. /**
  25549. * How a texture is mapped.
  25550. *
  25551. * | Value | Type | Description |
  25552. * | ----- | ----------------------------------- | ----------- |
  25553. * | 0 | EXPLICIT_MODE | |
  25554. * | 1 | SPHERICAL_MODE | |
  25555. * | 2 | PLANAR_MODE | |
  25556. * | 3 | CUBIC_MODE | |
  25557. * | 4 | PROJECTION_MODE | |
  25558. * | 5 | SKYBOX_MODE | |
  25559. * | 6 | INVCUBIC_MODE | |
  25560. * | 7 | EQUIRECTANGULAR_MODE | |
  25561. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25562. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25563. */
  25564. coordinatesMode: number;
  25565. /**
  25566. * | Value | Type | Description |
  25567. * | ----- | ------------------ | ----------- |
  25568. * | 0 | CLAMP_ADDRESSMODE | |
  25569. * | 1 | WRAP_ADDRESSMODE | |
  25570. * | 2 | MIRROR_ADDRESSMODE | |
  25571. */
  25572. wrapU: number;
  25573. /**
  25574. * | Value | Type | Description |
  25575. * | ----- | ------------------ | ----------- |
  25576. * | 0 | CLAMP_ADDRESSMODE | |
  25577. * | 1 | WRAP_ADDRESSMODE | |
  25578. * | 2 | MIRROR_ADDRESSMODE | |
  25579. */
  25580. wrapV: number;
  25581. /**
  25582. * | Value | Type | Description |
  25583. * | ----- | ------------------ | ----------- |
  25584. * | 0 | CLAMP_ADDRESSMODE | |
  25585. * | 1 | WRAP_ADDRESSMODE | |
  25586. * | 2 | MIRROR_ADDRESSMODE | |
  25587. */
  25588. wrapR: number;
  25589. /**
  25590. * With compliant hardware and browser (supporting anisotropic filtering)
  25591. * this defines the level of anisotropic filtering in the texture.
  25592. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25593. */
  25594. anisotropicFilteringLevel: number;
  25595. /**
  25596. * Define if the texture is a cube texture or if false a 2d texture.
  25597. */
  25598. isCube: boolean;
  25599. /**
  25600. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25601. */
  25602. is3D: boolean;
  25603. /**
  25604. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25605. * HDR texture are usually stored in linear space.
  25606. * This only impacts the PBR and Background materials
  25607. */
  25608. gammaSpace: boolean;
  25609. /**
  25610. * Gets whether or not the texture contains RGBD data.
  25611. */
  25612. readonly isRGBD: boolean;
  25613. /**
  25614. * Is Z inverted in the texture (useful in a cube texture).
  25615. */
  25616. invertZ: boolean;
  25617. /**
  25618. * Are mip maps generated for this texture or not.
  25619. */
  25620. readonly noMipmap: boolean;
  25621. /**
  25622. * @hidden
  25623. */
  25624. lodLevelInAlpha: boolean;
  25625. /**
  25626. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25627. */
  25628. lodGenerationOffset: number;
  25629. /**
  25630. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25631. */
  25632. lodGenerationScale: number;
  25633. /**
  25634. * Define if the texture is a render target.
  25635. */
  25636. isRenderTarget: boolean;
  25637. /**
  25638. * Define the unique id of the texture in the scene.
  25639. */
  25640. readonly uid: string;
  25641. /**
  25642. * Return a string representation of the texture.
  25643. * @returns the texture as a string
  25644. */
  25645. toString(): string;
  25646. /**
  25647. * Get the class name of the texture.
  25648. * @returns "BaseTexture"
  25649. */
  25650. getClassName(): string;
  25651. /**
  25652. * Define the list of animation attached to the texture.
  25653. */
  25654. animations: Animation[];
  25655. /**
  25656. * An event triggered when the texture is disposed.
  25657. */
  25658. onDisposeObservable: Observable<BaseTexture>;
  25659. private _onDisposeObserver;
  25660. /**
  25661. * Callback triggered when the texture has been disposed.
  25662. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25663. */
  25664. onDispose: () => void;
  25665. /**
  25666. * Define the current state of the loading sequence when in delayed load mode.
  25667. */
  25668. delayLoadState: number;
  25669. private _scene;
  25670. /** @hidden */
  25671. _texture: Nullable<InternalTexture>;
  25672. private _uid;
  25673. /**
  25674. * Define if the texture is preventinga material to render or not.
  25675. * If not and the texture is not ready, the engine will use a default black texture instead.
  25676. */
  25677. readonly isBlocking: boolean;
  25678. /**
  25679. * Instantiates a new BaseTexture.
  25680. * Base class of all the textures in babylon.
  25681. * It groups all the common properties the materials, post process, lights... might need
  25682. * in order to make a correct use of the texture.
  25683. * @param scene Define the scene the texture blongs to
  25684. */
  25685. constructor(scene: Nullable<Scene>);
  25686. /**
  25687. * Get the scene the texture belongs to.
  25688. * @returns the scene or null if undefined
  25689. */
  25690. getScene(): Nullable<Scene>;
  25691. /**
  25692. * Get the texture transform matrix used to offset tile the texture for istance.
  25693. * @returns the transformation matrix
  25694. */
  25695. getTextureMatrix(): Matrix;
  25696. /**
  25697. * Get the texture reflection matrix used to rotate/transform the reflection.
  25698. * @returns the reflection matrix
  25699. */
  25700. getReflectionTextureMatrix(): Matrix;
  25701. /**
  25702. * Get the underlying lower level texture from Babylon.
  25703. * @returns the insternal texture
  25704. */
  25705. getInternalTexture(): Nullable<InternalTexture>;
  25706. /**
  25707. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25708. * @returns true if ready or not blocking
  25709. */
  25710. isReadyOrNotBlocking(): boolean;
  25711. /**
  25712. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25713. * @returns true if fully ready
  25714. */
  25715. isReady(): boolean;
  25716. private _cachedSize;
  25717. /**
  25718. * Get the size of the texture.
  25719. * @returns the texture size.
  25720. */
  25721. getSize(): ISize;
  25722. /**
  25723. * Get the base size of the texture.
  25724. * It can be different from the size if the texture has been resized for POT for instance
  25725. * @returns the base size
  25726. */
  25727. getBaseSize(): ISize;
  25728. /**
  25729. * Update the sampling mode of the texture.
  25730. * Default is Trilinear mode.
  25731. *
  25732. * | Value | Type | Description |
  25733. * | ----- | ------------------ | ----------- |
  25734. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25735. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25736. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25737. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25738. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25739. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25740. * | 7 | NEAREST_LINEAR | |
  25741. * | 8 | NEAREST_NEAREST | |
  25742. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25743. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25744. * | 11 | LINEAR_LINEAR | |
  25745. * | 12 | LINEAR_NEAREST | |
  25746. *
  25747. * > _mag_: magnification filter (close to the viewer)
  25748. * > _min_: minification filter (far from the viewer)
  25749. * > _mip_: filter used between mip map levels
  25750. *@param samplingMode Define the new sampling mode of the texture
  25751. */
  25752. updateSamplingMode(samplingMode: number): void;
  25753. /**
  25754. * Scales the texture if is `canRescale()`
  25755. * @param ratio the resize factor we want to use to rescale
  25756. */
  25757. scale(ratio: number): void;
  25758. /**
  25759. * Get if the texture can rescale.
  25760. */
  25761. readonly canRescale: boolean;
  25762. /** @hidden */
  25763. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25764. /** @hidden */
  25765. _rebuild(): void;
  25766. /**
  25767. * Triggers the load sequence in delayed load mode.
  25768. */
  25769. delayLoad(): void;
  25770. /**
  25771. * Clones the texture.
  25772. * @returns the cloned texture
  25773. */
  25774. clone(): Nullable<BaseTexture>;
  25775. /**
  25776. * Get the texture underlying type (INT, FLOAT...)
  25777. */
  25778. readonly textureType: number;
  25779. /**
  25780. * Get the texture underlying format (RGB, RGBA...)
  25781. */
  25782. readonly textureFormat: number;
  25783. /**
  25784. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25785. * This will returns an RGBA array buffer containing either in values (0-255) or
  25786. * float values (0-1) depending of the underlying buffer type.
  25787. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25788. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25789. * @param buffer defines a user defined buffer to fill with data (can be null)
  25790. * @returns The Array buffer containing the pixels data.
  25791. */
  25792. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25793. /**
  25794. * Release and destroy the underlying lower level texture aka internalTexture.
  25795. */
  25796. releaseInternalTexture(): void;
  25797. /**
  25798. * Get the polynomial representation of the texture data.
  25799. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25800. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25801. */
  25802. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25803. /** @hidden */
  25804. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25805. /** @hidden */
  25806. readonly _lodTextureMid: Nullable<BaseTexture>;
  25807. /** @hidden */
  25808. readonly _lodTextureLow: Nullable<BaseTexture>;
  25809. /**
  25810. * Dispose the texture and release its associated resources.
  25811. */
  25812. dispose(): void;
  25813. /**
  25814. * Serialize the texture into a JSON representation that can be parsed later on.
  25815. * @returns the JSON representation of the texture
  25816. */
  25817. serialize(): any;
  25818. /**
  25819. * Helper function to be called back once a list of texture contains only ready textures.
  25820. * @param textures Define the list of textures to wait for
  25821. * @param callback Define the callback triggered once the entire list will be ready
  25822. */
  25823. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25824. }
  25825. }
  25826. declare module BABYLON {
  25827. /**
  25828. * Uniform buffer objects.
  25829. *
  25830. * Handles blocks of uniform on the GPU.
  25831. *
  25832. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25833. *
  25834. * For more information, please refer to :
  25835. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25836. */
  25837. export class UniformBuffer {
  25838. private _engine;
  25839. private _buffer;
  25840. private _data;
  25841. private _bufferData;
  25842. private _dynamic?;
  25843. private _uniformLocations;
  25844. private _uniformSizes;
  25845. private _uniformLocationPointer;
  25846. private _needSync;
  25847. private _noUBO;
  25848. private _currentEffect;
  25849. private static _MAX_UNIFORM_SIZE;
  25850. private static _tempBuffer;
  25851. /**
  25852. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25853. * This is dynamic to allow compat with webgl 1 and 2.
  25854. * You will need to pass the name of the uniform as well as the value.
  25855. */
  25856. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25857. /**
  25858. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25859. * This is dynamic to allow compat with webgl 1 and 2.
  25860. * You will need to pass the name of the uniform as well as the value.
  25861. */
  25862. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25863. /**
  25864. * Lambda to Update a single float in a uniform buffer.
  25865. * This is dynamic to allow compat with webgl 1 and 2.
  25866. * You will need to pass the name of the uniform as well as the value.
  25867. */
  25868. updateFloat: (name: string, x: number) => void;
  25869. /**
  25870. * Lambda to Update a vec2 of float in a uniform buffer.
  25871. * This is dynamic to allow compat with webgl 1 and 2.
  25872. * You will need to pass the name of the uniform as well as the value.
  25873. */
  25874. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25875. /**
  25876. * Lambda to Update a vec3 of float in a uniform buffer.
  25877. * This is dynamic to allow compat with webgl 1 and 2.
  25878. * You will need to pass the name of the uniform as well as the value.
  25879. */
  25880. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25881. /**
  25882. * Lambda to Update a vec4 of float in a uniform buffer.
  25883. * This is dynamic to allow compat with webgl 1 and 2.
  25884. * You will need to pass the name of the uniform as well as the value.
  25885. */
  25886. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25887. /**
  25888. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25889. * This is dynamic to allow compat with webgl 1 and 2.
  25890. * You will need to pass the name of the uniform as well as the value.
  25891. */
  25892. updateMatrix: (name: string, mat: Matrix) => void;
  25893. /**
  25894. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25895. * This is dynamic to allow compat with webgl 1 and 2.
  25896. * You will need to pass the name of the uniform as well as the value.
  25897. */
  25898. updateVector3: (name: string, vector: Vector3) => void;
  25899. /**
  25900. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25901. * This is dynamic to allow compat with webgl 1 and 2.
  25902. * You will need to pass the name of the uniform as well as the value.
  25903. */
  25904. updateVector4: (name: string, vector: Vector4) => void;
  25905. /**
  25906. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25907. * This is dynamic to allow compat with webgl 1 and 2.
  25908. * You will need to pass the name of the uniform as well as the value.
  25909. */
  25910. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25911. /**
  25912. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25913. * This is dynamic to allow compat with webgl 1 and 2.
  25914. * You will need to pass the name of the uniform as well as the value.
  25915. */
  25916. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25917. /**
  25918. * Instantiates a new Uniform buffer objects.
  25919. *
  25920. * Handles blocks of uniform on the GPU.
  25921. *
  25922. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25923. *
  25924. * For more information, please refer to :
  25925. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25926. * @param engine Define the engine the buffer is associated with
  25927. * @param data Define the data contained in the buffer
  25928. * @param dynamic Define if the buffer is updatable
  25929. */
  25930. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25931. /**
  25932. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25933. * or just falling back on setUniformXXX calls.
  25934. */
  25935. readonly useUbo: boolean;
  25936. /**
  25937. * Indicates if the WebGL underlying uniform buffer is in sync
  25938. * with the javascript cache data.
  25939. */
  25940. readonly isSync: boolean;
  25941. /**
  25942. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25943. * Also, a dynamic UniformBuffer will disable cache verification and always
  25944. * update the underlying WebGL uniform buffer to the GPU.
  25945. * @returns if Dynamic, otherwise false
  25946. */
  25947. isDynamic(): boolean;
  25948. /**
  25949. * The data cache on JS side.
  25950. * @returns the underlying data as a float array
  25951. */
  25952. getData(): Float32Array;
  25953. /**
  25954. * The underlying WebGL Uniform buffer.
  25955. * @returns the webgl buffer
  25956. */
  25957. getBuffer(): Nullable<WebGLBuffer>;
  25958. /**
  25959. * std140 layout specifies how to align data within an UBO structure.
  25960. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25961. * for specs.
  25962. */
  25963. private _fillAlignment;
  25964. /**
  25965. * Adds an uniform in the buffer.
  25966. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25967. * for the layout to be correct !
  25968. * @param name Name of the uniform, as used in the uniform block in the shader.
  25969. * @param size Data size, or data directly.
  25970. */
  25971. addUniform(name: string, size: number | number[]): void;
  25972. /**
  25973. * Adds a Matrix 4x4 to the uniform buffer.
  25974. * @param name Name of the uniform, as used in the uniform block in the shader.
  25975. * @param mat A 4x4 matrix.
  25976. */
  25977. addMatrix(name: string, mat: Matrix): void;
  25978. /**
  25979. * Adds a vec2 to the uniform buffer.
  25980. * @param name Name of the uniform, as used in the uniform block in the shader.
  25981. * @param x Define the x component value of the vec2
  25982. * @param y Define the y component value of the vec2
  25983. */
  25984. addFloat2(name: string, x: number, y: number): void;
  25985. /**
  25986. * Adds a vec3 to the uniform buffer.
  25987. * @param name Name of the uniform, as used in the uniform block in the shader.
  25988. * @param x Define the x component value of the vec3
  25989. * @param y Define the y component value of the vec3
  25990. * @param z Define the z component value of the vec3
  25991. */
  25992. addFloat3(name: string, x: number, y: number, z: number): void;
  25993. /**
  25994. * Adds a vec3 to the uniform buffer.
  25995. * @param name Name of the uniform, as used in the uniform block in the shader.
  25996. * @param color Define the vec3 from a Color
  25997. */
  25998. addColor3(name: string, color: Color3): void;
  25999. /**
  26000. * Adds a vec4 to the uniform buffer.
  26001. * @param name Name of the uniform, as used in the uniform block in the shader.
  26002. * @param color Define the rgb components from a Color
  26003. * @param alpha Define the a component of the vec4
  26004. */
  26005. addColor4(name: string, color: Color3, alpha: number): void;
  26006. /**
  26007. * Adds a vec3 to the uniform buffer.
  26008. * @param name Name of the uniform, as used in the uniform block in the shader.
  26009. * @param vector Define the vec3 components from a Vector
  26010. */
  26011. addVector3(name: string, vector: Vector3): void;
  26012. /**
  26013. * Adds a Matrix 3x3 to the uniform buffer.
  26014. * @param name Name of the uniform, as used in the uniform block in the shader.
  26015. */
  26016. addMatrix3x3(name: string): void;
  26017. /**
  26018. * Adds a Matrix 2x2 to the uniform buffer.
  26019. * @param name Name of the uniform, as used in the uniform block in the shader.
  26020. */
  26021. addMatrix2x2(name: string): void;
  26022. /**
  26023. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26024. */
  26025. create(): void;
  26026. /** @hidden */
  26027. _rebuild(): void;
  26028. /**
  26029. * Updates the WebGL Uniform Buffer on the GPU.
  26030. * If the `dynamic` flag is set to true, no cache comparison is done.
  26031. * Otherwise, the buffer will be updated only if the cache differs.
  26032. */
  26033. update(): void;
  26034. /**
  26035. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26036. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26037. * @param data Define the flattened data
  26038. * @param size Define the size of the data.
  26039. */
  26040. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26041. private _updateMatrix3x3ForUniform;
  26042. private _updateMatrix3x3ForEffect;
  26043. private _updateMatrix2x2ForEffect;
  26044. private _updateMatrix2x2ForUniform;
  26045. private _updateFloatForEffect;
  26046. private _updateFloatForUniform;
  26047. private _updateFloat2ForEffect;
  26048. private _updateFloat2ForUniform;
  26049. private _updateFloat3ForEffect;
  26050. private _updateFloat3ForUniform;
  26051. private _updateFloat4ForEffect;
  26052. private _updateFloat4ForUniform;
  26053. private _updateMatrixForEffect;
  26054. private _updateMatrixForUniform;
  26055. private _updateVector3ForEffect;
  26056. private _updateVector3ForUniform;
  26057. private _updateVector4ForEffect;
  26058. private _updateVector4ForUniform;
  26059. private _updateColor3ForEffect;
  26060. private _updateColor3ForUniform;
  26061. private _updateColor4ForEffect;
  26062. private _updateColor4ForUniform;
  26063. /**
  26064. * Sets a sampler uniform on the effect.
  26065. * @param name Define the name of the sampler.
  26066. * @param texture Define the texture to set in the sampler
  26067. */
  26068. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26069. /**
  26070. * Directly updates the value of the uniform in the cache AND on the GPU.
  26071. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26072. * @param data Define the flattened data
  26073. */
  26074. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26075. /**
  26076. * Binds this uniform buffer to an effect.
  26077. * @param effect Define the effect to bind the buffer to
  26078. * @param name Name of the uniform block in the shader.
  26079. */
  26080. bindToEffect(effect: Effect, name: string): void;
  26081. /**
  26082. * Disposes the uniform buffer.
  26083. */
  26084. dispose(): void;
  26085. }
  26086. }
  26087. declare module BABYLON {
  26088. /**
  26089. * This represents the required contract to create a new type of texture loader.
  26090. */
  26091. export interface IInternalTextureLoader {
  26092. /**
  26093. * Defines wether the loader supports cascade loading the different faces.
  26094. */
  26095. supportCascades: boolean;
  26096. /**
  26097. * This returns if the loader support the current file information.
  26098. * @param extension defines the file extension of the file being loaded
  26099. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26100. * @param fallback defines the fallback internal texture if any
  26101. * @param isBase64 defines whether the texture is encoded as a base64
  26102. * @param isBuffer defines whether the texture data are stored as a buffer
  26103. * @returns true if the loader can load the specified file
  26104. */
  26105. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26106. /**
  26107. * Transform the url before loading if required.
  26108. * @param rootUrl the url of the texture
  26109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26110. * @returns the transformed texture
  26111. */
  26112. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26113. /**
  26114. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26115. * @param rootUrl the url of the texture
  26116. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26117. * @returns the fallback texture
  26118. */
  26119. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26120. /**
  26121. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26122. * @param data contains the texture data
  26123. * @param texture defines the BabylonJS internal texture
  26124. * @param createPolynomials will be true if polynomials have been requested
  26125. * @param onLoad defines the callback to trigger once the texture is ready
  26126. * @param onError defines the callback to trigger in case of error
  26127. */
  26128. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26129. /**
  26130. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26131. * @param data contains the texture data
  26132. * @param texture defines the BabylonJS internal texture
  26133. * @param callback defines the method to call once ready to upload
  26134. */
  26135. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26136. }
  26137. }
  26138. declare module BABYLON {
  26139. /**
  26140. * Creation options of the multi render target texture.
  26141. */
  26142. export interface IMultiRenderTargetOptions {
  26143. /**
  26144. * Define if the texture needs to create mip maps after render.
  26145. */
  26146. generateMipMaps?: boolean;
  26147. /**
  26148. * Define the types of all the draw buffers we want to create
  26149. */
  26150. types?: number[];
  26151. /**
  26152. * Define the sampling modes of all the draw buffers we want to create
  26153. */
  26154. samplingModes?: number[];
  26155. /**
  26156. * Define if a depth buffer is required
  26157. */
  26158. generateDepthBuffer?: boolean;
  26159. /**
  26160. * Define if a stencil buffer is required
  26161. */
  26162. generateStencilBuffer?: boolean;
  26163. /**
  26164. * Define if a depth texture is required instead of a depth buffer
  26165. */
  26166. generateDepthTexture?: boolean;
  26167. /**
  26168. * Define the number of desired draw buffers
  26169. */
  26170. textureCount?: number;
  26171. /**
  26172. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26173. */
  26174. doNotChangeAspectRatio?: boolean;
  26175. /**
  26176. * Define the default type of the buffers we are creating
  26177. */
  26178. defaultType?: number;
  26179. }
  26180. /**
  26181. * A multi render target, like a render target provides the ability to render to a texture.
  26182. * Unlike the render target, it can render to several draw buffers in one draw.
  26183. * This is specially interesting in deferred rendering or for any effects requiring more than
  26184. * just one color from a single pass.
  26185. */
  26186. export class MultiRenderTarget extends RenderTargetTexture {
  26187. private _internalTextures;
  26188. private _textures;
  26189. private _multiRenderTargetOptions;
  26190. /**
  26191. * Get if draw buffers are currently supported by the used hardware and browser.
  26192. */
  26193. readonly isSupported: boolean;
  26194. /**
  26195. * Get the list of textures generated by the multi render target.
  26196. */
  26197. readonly textures: Texture[];
  26198. /**
  26199. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26200. */
  26201. readonly depthTexture: Texture;
  26202. /**
  26203. * Set the wrapping mode on U of all the textures we are rendering to.
  26204. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26205. */
  26206. wrapU: number;
  26207. /**
  26208. * Set the wrapping mode on V of all the textures we are rendering to.
  26209. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26210. */
  26211. wrapV: number;
  26212. /**
  26213. * Instantiate a new multi render target texture.
  26214. * A multi render target, like a render target provides the ability to render to a texture.
  26215. * Unlike the render target, it can render to several draw buffers in one draw.
  26216. * This is specially interesting in deferred rendering or for any effects requiring more than
  26217. * just one color from a single pass.
  26218. * @param name Define the name of the texture
  26219. * @param size Define the size of the buffers to render to
  26220. * @param count Define the number of target we are rendering into
  26221. * @param scene Define the scene the texture belongs to
  26222. * @param options Define the options used to create the multi render target
  26223. */
  26224. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26225. /** @hidden */
  26226. _rebuild(): void;
  26227. private _createInternalTextures;
  26228. private _createTextures;
  26229. /**
  26230. * Define the number of samples used if MSAA is enabled.
  26231. */
  26232. samples: number;
  26233. /**
  26234. * Resize all the textures in the multi render target.
  26235. * Be carrefull as it will recreate all the data in the new texture.
  26236. * @param size Define the new size
  26237. */
  26238. resize(size: any): void;
  26239. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26240. /**
  26241. * Dispose the render targets and their associated resources
  26242. */
  26243. dispose(): void;
  26244. /**
  26245. * Release all the underlying texture used as draw buffers.
  26246. */
  26247. releaseInternalTextures(): void;
  26248. }
  26249. }
  26250. declare module BABYLON {
  26251. /**
  26252. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26254. */
  26255. export class Analyser {
  26256. /**
  26257. * Gets or sets the smoothing
  26258. * @ignorenaming
  26259. */
  26260. SMOOTHING: number;
  26261. /**
  26262. * Gets or sets the FFT table size
  26263. * @ignorenaming
  26264. */
  26265. FFT_SIZE: number;
  26266. /**
  26267. * Gets or sets the bar graph amplitude
  26268. * @ignorenaming
  26269. */
  26270. BARGRAPHAMPLITUDE: number;
  26271. /**
  26272. * Gets or sets the position of the debug canvas
  26273. * @ignorenaming
  26274. */
  26275. DEBUGCANVASPOS: {
  26276. x: number;
  26277. y: number;
  26278. };
  26279. /**
  26280. * Gets or sets the debug canvas size
  26281. * @ignorenaming
  26282. */
  26283. DEBUGCANVASSIZE: {
  26284. width: number;
  26285. height: number;
  26286. };
  26287. private _byteFreqs;
  26288. private _byteTime;
  26289. private _floatFreqs;
  26290. private _webAudioAnalyser;
  26291. private _debugCanvas;
  26292. private _debugCanvasContext;
  26293. private _scene;
  26294. private _registerFunc;
  26295. private _audioEngine;
  26296. /**
  26297. * Creates a new analyser
  26298. * @param scene defines hosting scene
  26299. */
  26300. constructor(scene: Scene);
  26301. /**
  26302. * Get the number of data values you will have to play with for the visualization
  26303. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26304. * @returns a number
  26305. */
  26306. getFrequencyBinCount(): number;
  26307. /**
  26308. * Gets the current frequency data as a byte array
  26309. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26310. * @returns a Uint8Array
  26311. */
  26312. getByteFrequencyData(): Uint8Array;
  26313. /**
  26314. * Gets the current waveform as a byte array
  26315. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26316. * @returns a Uint8Array
  26317. */
  26318. getByteTimeDomainData(): Uint8Array;
  26319. /**
  26320. * Gets the current frequency data as a float array
  26321. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26322. * @returns a Float32Array
  26323. */
  26324. getFloatFrequencyData(): Float32Array;
  26325. /**
  26326. * Renders the debug canvas
  26327. */
  26328. drawDebugCanvas(): void;
  26329. /**
  26330. * Stops rendering the debug canvas and removes it
  26331. */
  26332. stopDebugCanvas(): void;
  26333. /**
  26334. * Connects two audio nodes
  26335. * @param inputAudioNode defines first node to connect
  26336. * @param outputAudioNode defines second node to connect
  26337. */
  26338. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26339. /**
  26340. * Releases all associated resources
  26341. */
  26342. dispose(): void;
  26343. }
  26344. }
  26345. declare module BABYLON {
  26346. /**
  26347. * This represents an audio engine and it is responsible
  26348. * to play, synchronize and analyse sounds throughout the application.
  26349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26350. */
  26351. export interface IAudioEngine extends IDisposable {
  26352. /**
  26353. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26354. */
  26355. readonly canUseWebAudio: boolean;
  26356. /**
  26357. * Gets the current AudioContext if available.
  26358. */
  26359. readonly audioContext: Nullable<AudioContext>;
  26360. /**
  26361. * The master gain node defines the global audio volume of your audio engine.
  26362. */
  26363. readonly masterGain: GainNode;
  26364. /**
  26365. * Gets whether or not mp3 are supported by your browser.
  26366. */
  26367. readonly isMP3supported: boolean;
  26368. /**
  26369. * Gets whether or not ogg are supported by your browser.
  26370. */
  26371. readonly isOGGsupported: boolean;
  26372. /**
  26373. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26374. * @ignoreNaming
  26375. */
  26376. WarnedWebAudioUnsupported: boolean;
  26377. /**
  26378. * Defines if the audio engine relies on a custom unlocked button.
  26379. * In this case, the embedded button will not be displayed.
  26380. */
  26381. useCustomUnlockedButton: boolean;
  26382. /**
  26383. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26384. */
  26385. readonly unlocked: boolean;
  26386. /**
  26387. * Event raised when audio has been unlocked on the browser.
  26388. */
  26389. onAudioUnlockedObservable: Observable<AudioEngine>;
  26390. /**
  26391. * Event raised when audio has been locked on the browser.
  26392. */
  26393. onAudioLockedObservable: Observable<AudioEngine>;
  26394. /**
  26395. * Flags the audio engine in Locked state.
  26396. * This happens due to new browser policies preventing audio to autoplay.
  26397. */
  26398. lock(): void;
  26399. /**
  26400. * Unlocks the audio engine once a user action has been done on the dom.
  26401. * This is helpful to resume play once browser policies have been satisfied.
  26402. */
  26403. unlock(): void;
  26404. }
  26405. /**
  26406. * This represents the default audio engine used in babylon.
  26407. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26409. */
  26410. export class AudioEngine implements IAudioEngine {
  26411. private _audioContext;
  26412. private _audioContextInitialized;
  26413. private _muteButton;
  26414. private _hostElement;
  26415. /**
  26416. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26417. */
  26418. canUseWebAudio: boolean;
  26419. /**
  26420. * The master gain node defines the global audio volume of your audio engine.
  26421. */
  26422. masterGain: GainNode;
  26423. /**
  26424. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26425. * @ignoreNaming
  26426. */
  26427. WarnedWebAudioUnsupported: boolean;
  26428. /**
  26429. * Gets whether or not mp3 are supported by your browser.
  26430. */
  26431. isMP3supported: boolean;
  26432. /**
  26433. * Gets whether or not ogg are supported by your browser.
  26434. */
  26435. isOGGsupported: boolean;
  26436. /**
  26437. * Gets whether audio has been unlocked on the device.
  26438. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26439. * a user interaction has happened.
  26440. */
  26441. unlocked: boolean;
  26442. /**
  26443. * Defines if the audio engine relies on a custom unlocked button.
  26444. * In this case, the embedded button will not be displayed.
  26445. */
  26446. useCustomUnlockedButton: boolean;
  26447. /**
  26448. * Event raised when audio has been unlocked on the browser.
  26449. */
  26450. onAudioUnlockedObservable: Observable<AudioEngine>;
  26451. /**
  26452. * Event raised when audio has been locked on the browser.
  26453. */
  26454. onAudioLockedObservable: Observable<AudioEngine>;
  26455. /**
  26456. * Gets the current AudioContext if available.
  26457. */
  26458. readonly audioContext: Nullable<AudioContext>;
  26459. private _connectedAnalyser;
  26460. /**
  26461. * Instantiates a new audio engine.
  26462. *
  26463. * There should be only one per page as some browsers restrict the number
  26464. * of audio contexts you can create.
  26465. * @param hostElement defines the host element where to display the mute icon if necessary
  26466. */
  26467. constructor(hostElement?: Nullable<HTMLElement>);
  26468. /**
  26469. * Flags the audio engine in Locked state.
  26470. * This happens due to new browser policies preventing audio to autoplay.
  26471. */
  26472. lock(): void;
  26473. /**
  26474. * Unlocks the audio engine once a user action has been done on the dom.
  26475. * This is helpful to resume play once browser policies have been satisfied.
  26476. */
  26477. unlock(): void;
  26478. private _resumeAudioContext;
  26479. private _initializeAudioContext;
  26480. private _tryToRun;
  26481. private _triggerRunningState;
  26482. private _triggerSuspendedState;
  26483. private _displayMuteButton;
  26484. private _moveButtonToTopLeft;
  26485. private _onResize;
  26486. private _hideMuteButton;
  26487. /**
  26488. * Destroy and release the resources associated with the audio ccontext.
  26489. */
  26490. dispose(): void;
  26491. /**
  26492. * Gets the global volume sets on the master gain.
  26493. * @returns the global volume if set or -1 otherwise
  26494. */
  26495. getGlobalVolume(): number;
  26496. /**
  26497. * Sets the global volume of your experience (sets on the master gain).
  26498. * @param newVolume Defines the new global volume of the application
  26499. */
  26500. setGlobalVolume(newVolume: number): void;
  26501. /**
  26502. * Connect the audio engine to an audio analyser allowing some amazing
  26503. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26505. * @param analyser The analyser to connect to the engine
  26506. */
  26507. connectToAnalyser(analyser: Analyser): void;
  26508. }
  26509. }
  26510. declare module BABYLON {
  26511. /**
  26512. * Interface used to present a loading screen while loading a scene
  26513. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26514. */
  26515. export interface ILoadingScreen {
  26516. /**
  26517. * Function called to display the loading screen
  26518. */
  26519. displayLoadingUI: () => void;
  26520. /**
  26521. * Function called to hide the loading screen
  26522. */
  26523. hideLoadingUI: () => void;
  26524. /**
  26525. * Gets or sets the color to use for the background
  26526. */
  26527. loadingUIBackgroundColor: string;
  26528. /**
  26529. * Gets or sets the text to display while loading
  26530. */
  26531. loadingUIText: string;
  26532. }
  26533. /**
  26534. * Class used for the default loading screen
  26535. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26536. */
  26537. export class DefaultLoadingScreen implements ILoadingScreen {
  26538. private _renderingCanvas;
  26539. private _loadingText;
  26540. private _loadingDivBackgroundColor;
  26541. private _loadingDiv;
  26542. private _loadingTextDiv;
  26543. /**
  26544. * Creates a new default loading screen
  26545. * @param _renderingCanvas defines the canvas used to render the scene
  26546. * @param _loadingText defines the default text to display
  26547. * @param _loadingDivBackgroundColor defines the default background color
  26548. */
  26549. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26550. /**
  26551. * Function called to display the loading screen
  26552. */
  26553. displayLoadingUI(): void;
  26554. /**
  26555. * Function called to hide the loading screen
  26556. */
  26557. hideLoadingUI(): void;
  26558. /**
  26559. * Gets or sets the text to display while loading
  26560. */
  26561. loadingUIText: string;
  26562. /**
  26563. * Gets or sets the color to use for the background
  26564. */
  26565. loadingUIBackgroundColor: string;
  26566. private _resizeLoadingUI;
  26567. }
  26568. }
  26569. declare module BABYLON {
  26570. /**
  26571. * Settings for finer control over video usage
  26572. */
  26573. export interface VideoTextureSettings {
  26574. /**
  26575. * Applies `autoplay` to video, if specified
  26576. */
  26577. autoPlay?: boolean;
  26578. /**
  26579. * Applies `loop` to video, if specified
  26580. */
  26581. loop?: boolean;
  26582. /**
  26583. * Automatically updates internal texture from video at every frame in the render loop
  26584. */
  26585. autoUpdateTexture: boolean;
  26586. /**
  26587. * Image src displayed during the video loading or until the user interacts with the video.
  26588. */
  26589. poster?: string;
  26590. }
  26591. /**
  26592. * If you want to display a video in your scene, this is the special texture for that.
  26593. * This special texture works similar to other textures, with the exception of a few parameters.
  26594. * @see https://doc.babylonjs.com/how_to/video_texture
  26595. */
  26596. export class VideoTexture extends Texture {
  26597. /**
  26598. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26599. */
  26600. readonly autoUpdateTexture: boolean;
  26601. /**
  26602. * The video instance used by the texture internally
  26603. */
  26604. readonly video: HTMLVideoElement;
  26605. private _onUserActionRequestedObservable;
  26606. /**
  26607. * Event triggerd when a dom action is required by the user to play the video.
  26608. * This happens due to recent changes in browser policies preventing video to auto start.
  26609. */
  26610. readonly onUserActionRequestedObservable: Observable<Texture>;
  26611. private _generateMipMaps;
  26612. private _engine;
  26613. private _stillImageCaptured;
  26614. private _displayingPosterTexture;
  26615. private _settings;
  26616. private _createInternalTextureOnEvent;
  26617. /**
  26618. * Creates a video texture.
  26619. * If you want to display a video in your scene, this is the special texture for that.
  26620. * This special texture works similar to other textures, with the exception of a few parameters.
  26621. * @see https://doc.babylonjs.com/how_to/video_texture
  26622. * @param name optional name, will detect from video source, if not defined
  26623. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26624. * @param scene is obviously the current scene.
  26625. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26626. * @param invertY is false by default but can be used to invert video on Y axis
  26627. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26628. * @param settings allows finer control over video usage
  26629. */
  26630. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26631. private _getName;
  26632. private _getVideo;
  26633. private _createInternalTexture;
  26634. private reset;
  26635. /**
  26636. * @hidden Internal method to initiate `update`.
  26637. */
  26638. _rebuild(): void;
  26639. /**
  26640. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26641. */
  26642. update(): void;
  26643. /**
  26644. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26645. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26646. */
  26647. updateTexture(isVisible: boolean): void;
  26648. protected _updateInternalTexture: () => void;
  26649. /**
  26650. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26651. * @param url New url.
  26652. */
  26653. updateURL(url: string): void;
  26654. /**
  26655. * Dispose the texture and release its associated resources.
  26656. */
  26657. dispose(): void;
  26658. /**
  26659. * Creates a video texture straight from a stream.
  26660. * @param scene Define the scene the texture should be created in
  26661. * @param stream Define the stream the texture should be created from
  26662. * @returns The created video texture as a promise
  26663. */
  26664. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26665. /**
  26666. * Creates a video texture straight from your WebCam video feed.
  26667. * @param scene Define the scene the texture should be created in
  26668. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26669. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26670. * @returns The created video texture as a promise
  26671. */
  26672. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26673. minWidth: number;
  26674. maxWidth: number;
  26675. minHeight: number;
  26676. maxHeight: number;
  26677. deviceId: string;
  26678. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26679. /**
  26680. * Creates a video texture straight from your WebCam video feed.
  26681. * @param scene Define the scene the texture should be created in
  26682. * @param onReady Define a callback to triggered once the texture will be ready
  26683. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26684. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26685. */
  26686. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26687. minWidth: number;
  26688. maxWidth: number;
  26689. minHeight: number;
  26690. maxHeight: number;
  26691. deviceId: string;
  26692. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26693. }
  26694. }
  26695. declare module BABYLON {
  26696. /**
  26697. * Interface for attribute information associated with buffer instanciation
  26698. */
  26699. export class InstancingAttributeInfo {
  26700. /**
  26701. * Index/offset of the attribute in the vertex shader
  26702. */
  26703. index: number;
  26704. /**
  26705. * size of the attribute, 1, 2, 3 or 4
  26706. */
  26707. attributeSize: number;
  26708. /**
  26709. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26710. * default is FLOAT
  26711. */
  26712. attribyteType: number;
  26713. /**
  26714. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26715. */
  26716. normalized: boolean;
  26717. /**
  26718. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26719. */
  26720. offset: number;
  26721. /**
  26722. * Name of the GLSL attribute, for debugging purpose only
  26723. */
  26724. attributeName: string;
  26725. }
  26726. /**
  26727. * Define options used to create a depth texture
  26728. */
  26729. export class DepthTextureCreationOptions {
  26730. /** Specifies whether or not a stencil should be allocated in the texture */
  26731. generateStencil?: boolean;
  26732. /** Specifies whether or not bilinear filtering is enable on the texture */
  26733. bilinearFiltering?: boolean;
  26734. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26735. comparisonFunction?: number;
  26736. /** Specifies if the created texture is a cube texture */
  26737. isCube?: boolean;
  26738. }
  26739. /**
  26740. * Class used to describe the capabilities of the engine relatively to the current browser
  26741. */
  26742. export class EngineCapabilities {
  26743. /** Maximum textures units per fragment shader */
  26744. maxTexturesImageUnits: number;
  26745. /** Maximum texture units per vertex shader */
  26746. maxVertexTextureImageUnits: number;
  26747. /** Maximum textures units in the entire pipeline */
  26748. maxCombinedTexturesImageUnits: number;
  26749. /** Maximum texture size */
  26750. maxTextureSize: number;
  26751. /** Maximum cube texture size */
  26752. maxCubemapTextureSize: number;
  26753. /** Maximum render texture size */
  26754. maxRenderTextureSize: number;
  26755. /** Maximum number of vertex attributes */
  26756. maxVertexAttribs: number;
  26757. /** Maximum number of varyings */
  26758. maxVaryingVectors: number;
  26759. /** Maximum number of uniforms per vertex shader */
  26760. maxVertexUniformVectors: number;
  26761. /** Maximum number of uniforms per fragment shader */
  26762. maxFragmentUniformVectors: number;
  26763. /** Defines if standard derivates (dx/dy) are supported */
  26764. standardDerivatives: boolean;
  26765. /** Defines if s3tc texture compression is supported */
  26766. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26767. /** Defines if pvrtc texture compression is supported */
  26768. pvrtc: any;
  26769. /** Defines if etc1 texture compression is supported */
  26770. etc1: any;
  26771. /** Defines if etc2 texture compression is supported */
  26772. etc2: any;
  26773. /** Defines if astc texture compression is supported */
  26774. astc: any;
  26775. /** Defines if float textures are supported */
  26776. textureFloat: boolean;
  26777. /** Defines if vertex array objects are supported */
  26778. vertexArrayObject: boolean;
  26779. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26780. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26781. /** Gets the maximum level of anisotropy supported */
  26782. maxAnisotropy: number;
  26783. /** Defines if instancing is supported */
  26784. instancedArrays: boolean;
  26785. /** Defines if 32 bits indices are supported */
  26786. uintIndices: boolean;
  26787. /** Defines if high precision shaders are supported */
  26788. highPrecisionShaderSupported: boolean;
  26789. /** Defines if depth reading in the fragment shader is supported */
  26790. fragmentDepthSupported: boolean;
  26791. /** Defines if float texture linear filtering is supported*/
  26792. textureFloatLinearFiltering: boolean;
  26793. /** Defines if rendering to float textures is supported */
  26794. textureFloatRender: boolean;
  26795. /** Defines if half float textures are supported*/
  26796. textureHalfFloat: boolean;
  26797. /** Defines if half float texture linear filtering is supported*/
  26798. textureHalfFloatLinearFiltering: boolean;
  26799. /** Defines if rendering to half float textures is supported */
  26800. textureHalfFloatRender: boolean;
  26801. /** Defines if textureLOD shader command is supported */
  26802. textureLOD: boolean;
  26803. /** Defines if draw buffers extension is supported */
  26804. drawBuffersExtension: boolean;
  26805. /** Defines if depth textures are supported */
  26806. depthTextureExtension: boolean;
  26807. /** Defines if float color buffer are supported */
  26808. colorBufferFloat: boolean;
  26809. /** Gets disjoint timer query extension (null if not supported) */
  26810. timerQuery: EXT_disjoint_timer_query;
  26811. /** Defines if timestamp can be used with timer query */
  26812. canUseTimestampForTimerQuery: boolean;
  26813. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26814. multiview: any;
  26815. /** Function used to let the system compiles shaders in background */
  26816. parallelShaderCompile: {
  26817. COMPLETION_STATUS_KHR: number;
  26818. };
  26819. }
  26820. /** Interface defining initialization parameters for Engine class */
  26821. export interface EngineOptions extends WebGLContextAttributes {
  26822. /**
  26823. * Defines if the engine should no exceed a specified device ratio
  26824. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26825. */
  26826. limitDeviceRatio?: number;
  26827. /**
  26828. * Defines if webvr should be enabled automatically
  26829. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26830. */
  26831. autoEnableWebVR?: boolean;
  26832. /**
  26833. * Defines if webgl2 should be turned off even if supported
  26834. * @see http://doc.babylonjs.com/features/webgl2
  26835. */
  26836. disableWebGL2Support?: boolean;
  26837. /**
  26838. * Defines if webaudio should be initialized as well
  26839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26840. */
  26841. audioEngine?: boolean;
  26842. /**
  26843. * Defines if animations should run using a deterministic lock step
  26844. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26845. */
  26846. deterministicLockstep?: boolean;
  26847. /** Defines the maximum steps to use with deterministic lock step mode */
  26848. lockstepMaxSteps?: number;
  26849. /**
  26850. * Defines that engine should ignore context lost events
  26851. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26852. */
  26853. doNotHandleContextLost?: boolean;
  26854. /**
  26855. * Defines that engine should ignore modifying touch action attribute and style
  26856. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26857. */
  26858. doNotHandleTouchAction?: boolean;
  26859. /**
  26860. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26861. */
  26862. useHighPrecisionFloats?: boolean;
  26863. }
  26864. /**
  26865. * Defines the interface used by display changed events
  26866. */
  26867. export interface IDisplayChangedEventArgs {
  26868. /** Gets the vrDisplay object (if any) */
  26869. vrDisplay: Nullable<any>;
  26870. /** Gets a boolean indicating if webVR is supported */
  26871. vrSupported: boolean;
  26872. }
  26873. /**
  26874. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26875. */
  26876. export class Engine {
  26877. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26878. static ExceptionList: ({
  26879. key: string;
  26880. capture: string;
  26881. captureConstraint: number;
  26882. targets: string[];
  26883. } | {
  26884. key: string;
  26885. capture: null;
  26886. captureConstraint: null;
  26887. targets: string[];
  26888. })[];
  26889. /** Gets the list of created engines */
  26890. static readonly Instances: Engine[];
  26891. /**
  26892. * Gets the latest created engine
  26893. */
  26894. static readonly LastCreatedEngine: Nullable<Engine>;
  26895. /**
  26896. * Gets the latest created scene
  26897. */
  26898. static readonly LastCreatedScene: Nullable<Scene>;
  26899. /**
  26900. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26901. * @param flag defines which part of the materials must be marked as dirty
  26902. * @param predicate defines a predicate used to filter which materials should be affected
  26903. */
  26904. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26905. /**
  26906. * Hidden
  26907. */
  26908. static _TextureLoaders: IInternalTextureLoader[];
  26909. /** Defines that alpha blending is disabled */
  26910. static readonly ALPHA_DISABLE: number;
  26911. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26912. static readonly ALPHA_ADD: number;
  26913. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26914. static readonly ALPHA_COMBINE: number;
  26915. /** Defines that alpha blending to DEST - SRC * DEST */
  26916. static readonly ALPHA_SUBTRACT: number;
  26917. /** Defines that alpha blending to SRC * DEST */
  26918. static readonly ALPHA_MULTIPLY: number;
  26919. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26920. static readonly ALPHA_MAXIMIZED: number;
  26921. /** Defines that alpha blending to SRC + DEST */
  26922. static readonly ALPHA_ONEONE: number;
  26923. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26924. static readonly ALPHA_PREMULTIPLIED: number;
  26925. /**
  26926. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26927. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26928. */
  26929. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26930. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26931. static readonly ALPHA_INTERPOLATE: number;
  26932. /**
  26933. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26934. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26935. */
  26936. static readonly ALPHA_SCREENMODE: number;
  26937. /** Defines that the ressource is not delayed*/
  26938. static readonly DELAYLOADSTATE_NONE: number;
  26939. /** Defines that the ressource was successfully delay loaded */
  26940. static readonly DELAYLOADSTATE_LOADED: number;
  26941. /** Defines that the ressource is currently delay loading */
  26942. static readonly DELAYLOADSTATE_LOADING: number;
  26943. /** Defines that the ressource is delayed and has not started loading */
  26944. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26945. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26946. static readonly NEVER: number;
  26947. /** 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 */
  26948. static readonly ALWAYS: number;
  26949. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26950. static readonly LESS: number;
  26951. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26952. static readonly EQUAL: number;
  26953. /** 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 */
  26954. static readonly LEQUAL: number;
  26955. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26956. static readonly GREATER: number;
  26957. /** 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 */
  26958. static readonly GEQUAL: number;
  26959. /** 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 */
  26960. static readonly NOTEQUAL: number;
  26961. /** Passed to stencilOperation to specify that stencil value must be kept */
  26962. static readonly KEEP: number;
  26963. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26964. static readonly REPLACE: number;
  26965. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26966. static readonly INCR: number;
  26967. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26968. static readonly DECR: number;
  26969. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26970. static readonly INVERT: number;
  26971. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26972. static readonly INCR_WRAP: number;
  26973. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26974. static readonly DECR_WRAP: number;
  26975. /** Texture is not repeating outside of 0..1 UVs */
  26976. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26977. /** Texture is repeating outside of 0..1 UVs */
  26978. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26979. /** Texture is repeating and mirrored */
  26980. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26981. /** ALPHA */
  26982. static readonly TEXTUREFORMAT_ALPHA: number;
  26983. /** LUMINANCE */
  26984. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26985. /** LUMINANCE_ALPHA */
  26986. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26987. /** RGB */
  26988. static readonly TEXTUREFORMAT_RGB: number;
  26989. /** RGBA */
  26990. static readonly TEXTUREFORMAT_RGBA: number;
  26991. /** RED */
  26992. static readonly TEXTUREFORMAT_RED: number;
  26993. /** RED (2nd reference) */
  26994. static readonly TEXTUREFORMAT_R: number;
  26995. /** RG */
  26996. static readonly TEXTUREFORMAT_RG: number;
  26997. /** RED_INTEGER */
  26998. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26999. /** RED_INTEGER (2nd reference) */
  27000. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27001. /** RG_INTEGER */
  27002. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27003. /** RGB_INTEGER */
  27004. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27005. /** RGBA_INTEGER */
  27006. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27007. /** UNSIGNED_BYTE */
  27008. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27009. /** UNSIGNED_BYTE (2nd reference) */
  27010. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27011. /** FLOAT */
  27012. static readonly TEXTURETYPE_FLOAT: number;
  27013. /** HALF_FLOAT */
  27014. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27015. /** BYTE */
  27016. static readonly TEXTURETYPE_BYTE: number;
  27017. /** SHORT */
  27018. static readonly TEXTURETYPE_SHORT: number;
  27019. /** UNSIGNED_SHORT */
  27020. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27021. /** INT */
  27022. static readonly TEXTURETYPE_INT: number;
  27023. /** UNSIGNED_INT */
  27024. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27025. /** UNSIGNED_SHORT_4_4_4_4 */
  27026. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27027. /** UNSIGNED_SHORT_5_5_5_1 */
  27028. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27029. /** UNSIGNED_SHORT_5_6_5 */
  27030. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27031. /** UNSIGNED_INT_2_10_10_10_REV */
  27032. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27033. /** UNSIGNED_INT_24_8 */
  27034. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27035. /** UNSIGNED_INT_10F_11F_11F_REV */
  27036. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27037. /** UNSIGNED_INT_5_9_9_9_REV */
  27038. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27039. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27040. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27041. /** nearest is mag = nearest and min = nearest and mip = linear */
  27042. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27043. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27044. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27045. /** Trilinear is mag = linear and min = linear and mip = linear */
  27046. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27047. /** nearest is mag = nearest and min = nearest and mip = linear */
  27048. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27049. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27050. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27051. /** Trilinear is mag = linear and min = linear and mip = linear */
  27052. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27053. /** mag = nearest and min = nearest and mip = nearest */
  27054. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27055. /** mag = nearest and min = linear and mip = nearest */
  27056. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27057. /** mag = nearest and min = linear and mip = linear */
  27058. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27059. /** mag = nearest and min = linear and mip = none */
  27060. static readonly TEXTURE_NEAREST_LINEAR: number;
  27061. /** mag = nearest and min = nearest and mip = none */
  27062. static readonly TEXTURE_NEAREST_NEAREST: number;
  27063. /** mag = linear and min = nearest and mip = nearest */
  27064. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27065. /** mag = linear and min = nearest and mip = linear */
  27066. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27067. /** mag = linear and min = linear and mip = none */
  27068. static readonly TEXTURE_LINEAR_LINEAR: number;
  27069. /** mag = linear and min = nearest and mip = none */
  27070. static readonly TEXTURE_LINEAR_NEAREST: number;
  27071. /** Explicit coordinates mode */
  27072. static readonly TEXTURE_EXPLICIT_MODE: number;
  27073. /** Spherical coordinates mode */
  27074. static readonly TEXTURE_SPHERICAL_MODE: number;
  27075. /** Planar coordinates mode */
  27076. static readonly TEXTURE_PLANAR_MODE: number;
  27077. /** Cubic coordinates mode */
  27078. static readonly TEXTURE_CUBIC_MODE: number;
  27079. /** Projection coordinates mode */
  27080. static readonly TEXTURE_PROJECTION_MODE: number;
  27081. /** Skybox coordinates mode */
  27082. static readonly TEXTURE_SKYBOX_MODE: number;
  27083. /** Inverse Cubic coordinates mode */
  27084. static readonly TEXTURE_INVCUBIC_MODE: number;
  27085. /** Equirectangular coordinates mode */
  27086. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27087. /** Equirectangular Fixed coordinates mode */
  27088. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27089. /** Equirectangular Fixed Mirrored coordinates mode */
  27090. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27091. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27092. static readonly SCALEMODE_FLOOR: number;
  27093. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27094. static readonly SCALEMODE_NEAREST: number;
  27095. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27096. static readonly SCALEMODE_CEILING: number;
  27097. /**
  27098. * Returns the current npm package of the sdk
  27099. */
  27100. static readonly NpmPackage: string;
  27101. /**
  27102. * Returns the current version of the framework
  27103. */
  27104. static readonly Version: string;
  27105. /**
  27106. * Returns a string describing the current engine
  27107. */
  27108. readonly description: string;
  27109. /**
  27110. * Gets or sets the epsilon value used by collision engine
  27111. */
  27112. static CollisionsEpsilon: number;
  27113. /**
  27114. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27115. */
  27116. static ShadersRepository: string;
  27117. /**
  27118. * Method called to create the default loading screen.
  27119. * This can be overriden in your own app.
  27120. * @param canvas The rendering canvas element
  27121. * @returns The loading screen
  27122. */
  27123. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27124. /**
  27125. * Method called to create the default rescale post process on each engine.
  27126. */
  27127. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27128. /**
  27129. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27130. */
  27131. forcePOTTextures: boolean;
  27132. /**
  27133. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27134. */
  27135. isFullscreen: boolean;
  27136. /**
  27137. * Gets a boolean indicating if the pointer is currently locked
  27138. */
  27139. isPointerLock: boolean;
  27140. /**
  27141. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27142. */
  27143. cullBackFaces: boolean;
  27144. /**
  27145. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27146. */
  27147. renderEvenInBackground: boolean;
  27148. /**
  27149. * Gets or sets a boolean indicating that cache can be kept between frames
  27150. */
  27151. preventCacheWipeBetweenFrames: boolean;
  27152. /**
  27153. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27154. **/
  27155. enableOfflineSupport: boolean;
  27156. /**
  27157. * 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)
  27158. **/
  27159. disableManifestCheck: boolean;
  27160. /**
  27161. * Gets the list of created scenes
  27162. */
  27163. scenes: Scene[];
  27164. /**
  27165. * Event raised when a new scene is created
  27166. */
  27167. onNewSceneAddedObservable: Observable<Scene>;
  27168. /**
  27169. * Gets the list of created postprocesses
  27170. */
  27171. postProcesses: PostProcess[];
  27172. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27173. validateShaderPrograms: boolean;
  27174. /**
  27175. * Observable event triggered each time the rendering canvas is resized
  27176. */
  27177. onResizeObservable: Observable<Engine>;
  27178. /**
  27179. * Observable event triggered each time the canvas loses focus
  27180. */
  27181. onCanvasBlurObservable: Observable<Engine>;
  27182. /**
  27183. * Observable event triggered each time the canvas gains focus
  27184. */
  27185. onCanvasFocusObservable: Observable<Engine>;
  27186. /**
  27187. * Observable event triggered each time the canvas receives pointerout event
  27188. */
  27189. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27190. /**
  27191. * Observable event triggered before each texture is initialized
  27192. */
  27193. onBeforeTextureInitObservable: Observable<Texture>;
  27194. private _vrDisplay;
  27195. private _vrSupported;
  27196. private _oldSize;
  27197. private _oldHardwareScaleFactor;
  27198. private _vrExclusivePointerMode;
  27199. private _webVRInitPromise;
  27200. /**
  27201. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27202. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27203. */
  27204. readonly isInVRExclusivePointerMode: boolean;
  27205. /**
  27206. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27207. */
  27208. disableUniformBuffers: boolean;
  27209. /** @hidden */
  27210. _uniformBuffers: UniformBuffer[];
  27211. /**
  27212. * Gets a boolean indicating that the engine supports uniform buffers
  27213. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27214. */
  27215. readonly supportsUniformBuffers: boolean;
  27216. /**
  27217. * Observable raised when the engine begins a new frame
  27218. */
  27219. onBeginFrameObservable: Observable<Engine>;
  27220. /**
  27221. * If set, will be used to request the next animation frame for the render loop
  27222. */
  27223. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27224. /**
  27225. * Observable raised when the engine ends the current frame
  27226. */
  27227. onEndFrameObservable: Observable<Engine>;
  27228. /**
  27229. * Observable raised when the engine is about to compile a shader
  27230. */
  27231. onBeforeShaderCompilationObservable: Observable<Engine>;
  27232. /**
  27233. * Observable raised when the engine has jsut compiled a shader
  27234. */
  27235. onAfterShaderCompilationObservable: Observable<Engine>;
  27236. /** @hidden */
  27237. _gl: WebGLRenderingContext;
  27238. private _renderingCanvas;
  27239. private _windowIsBackground;
  27240. private _webGLVersion;
  27241. protected _highPrecisionShadersAllowed: boolean;
  27242. /** @hidden */
  27243. readonly _shouldUseHighPrecisionShader: boolean;
  27244. /**
  27245. * Gets a boolean indicating that only power of 2 textures are supported
  27246. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27247. */
  27248. readonly needPOTTextures: boolean;
  27249. /** @hidden */
  27250. _badOS: boolean;
  27251. /** @hidden */
  27252. _badDesktopOS: boolean;
  27253. /**
  27254. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27255. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27256. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27257. */
  27258. disableTextureBindingOptimization: boolean;
  27259. /**
  27260. * Gets the audio engine
  27261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27262. * @ignorenaming
  27263. */
  27264. static audioEngine: IAudioEngine;
  27265. /**
  27266. * Default AudioEngine factory responsible of creating the Audio Engine.
  27267. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27268. */
  27269. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27270. /**
  27271. * Default offline support factory responsible of creating a tool used to store data locally.
  27272. * By default, this will create a Database object if the workload has been embedded.
  27273. */
  27274. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27275. private _onFocus;
  27276. private _onBlur;
  27277. private _onCanvasPointerOut;
  27278. private _onCanvasBlur;
  27279. private _onCanvasFocus;
  27280. private _onFullscreenChange;
  27281. private _onPointerLockChange;
  27282. private _onVRDisplayPointerRestricted;
  27283. private _onVRDisplayPointerUnrestricted;
  27284. private _onVrDisplayConnect;
  27285. private _onVrDisplayDisconnect;
  27286. private _onVrDisplayPresentChange;
  27287. /**
  27288. * Observable signaled when VR display mode changes
  27289. */
  27290. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27291. /**
  27292. * Observable signaled when VR request present is complete
  27293. */
  27294. onVRRequestPresentComplete: Observable<boolean>;
  27295. /**
  27296. * Observable signaled when VR request present starts
  27297. */
  27298. onVRRequestPresentStart: Observable<Engine>;
  27299. private _hardwareScalingLevel;
  27300. /** @hidden */
  27301. protected _caps: EngineCapabilities;
  27302. private _pointerLockRequested;
  27303. private _isStencilEnable;
  27304. private _colorWrite;
  27305. private _loadingScreen;
  27306. /** @hidden */
  27307. _drawCalls: PerfCounter;
  27308. /** @hidden */
  27309. _textureCollisions: PerfCounter;
  27310. private _glVersion;
  27311. private _glRenderer;
  27312. private _glVendor;
  27313. private _videoTextureSupported;
  27314. private _renderingQueueLaunched;
  27315. private _activeRenderLoops;
  27316. private _deterministicLockstep;
  27317. private _lockstepMaxSteps;
  27318. /**
  27319. * Observable signaled when a context lost event is raised
  27320. */
  27321. onContextLostObservable: Observable<Engine>;
  27322. /**
  27323. * Observable signaled when a context restored event is raised
  27324. */
  27325. onContextRestoredObservable: Observable<Engine>;
  27326. private _onContextLost;
  27327. private _onContextRestored;
  27328. private _contextWasLost;
  27329. private _doNotHandleContextLost;
  27330. /**
  27331. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27333. */
  27334. doNotHandleContextLost: boolean;
  27335. private _performanceMonitor;
  27336. private _fps;
  27337. private _deltaTime;
  27338. /**
  27339. * Turn this value on if you want to pause FPS computation when in background
  27340. */
  27341. disablePerformanceMonitorInBackground: boolean;
  27342. /**
  27343. * Gets the performance monitor attached to this engine
  27344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27345. */
  27346. readonly performanceMonitor: PerformanceMonitor;
  27347. /**
  27348. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27349. */
  27350. disableVertexArrayObjects: boolean;
  27351. /** @hidden */
  27352. protected _depthCullingState: _DepthCullingState;
  27353. /** @hidden */
  27354. protected _stencilState: _StencilState;
  27355. /** @hidden */
  27356. protected _alphaState: _AlphaState;
  27357. /** @hidden */
  27358. protected _alphaMode: number;
  27359. protected _internalTexturesCache: InternalTexture[];
  27360. /** @hidden */
  27361. protected _activeChannel: number;
  27362. private _currentTextureChannel;
  27363. /** @hidden */
  27364. protected _boundTexturesCache: {
  27365. [key: string]: Nullable<InternalTexture>;
  27366. };
  27367. /** @hidden */
  27368. protected _currentEffect: Nullable<Effect>;
  27369. /** @hidden */
  27370. protected _currentProgram: Nullable<WebGLProgram>;
  27371. private _compiledEffects;
  27372. private _vertexAttribArraysEnabled;
  27373. /** @hidden */
  27374. protected _cachedViewport: Nullable<Viewport>;
  27375. private _cachedVertexArrayObject;
  27376. /** @hidden */
  27377. protected _cachedVertexBuffers: any;
  27378. /** @hidden */
  27379. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27380. /** @hidden */
  27381. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27382. /** @hidden */
  27383. protected _currentRenderTarget: Nullable<InternalTexture>;
  27384. private _uintIndicesCurrentlySet;
  27385. private _currentBoundBuffer;
  27386. /** @hidden */
  27387. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27388. private _currentBufferPointers;
  27389. private _currentInstanceLocations;
  27390. private _currentInstanceBuffers;
  27391. private _textureUnits;
  27392. private _firstBoundInternalTextureTracker;
  27393. private _lastBoundInternalTextureTracker;
  27394. private _workingCanvas;
  27395. private _workingContext;
  27396. private _rescalePostProcess;
  27397. private _dummyFramebuffer;
  27398. private _externalData;
  27399. private _bindedRenderFunction;
  27400. private _vaoRecordInProgress;
  27401. private _mustWipeVertexAttributes;
  27402. private _emptyTexture;
  27403. private _emptyCubeTexture;
  27404. private _emptyTexture3D;
  27405. /** @hidden */
  27406. _frameHandler: number;
  27407. private _nextFreeTextureSlots;
  27408. private _maxSimultaneousTextures;
  27409. private _activeRequests;
  27410. private _texturesSupported;
  27411. private _textureFormatInUse;
  27412. /**
  27413. * Gets the list of texture formats supported
  27414. */
  27415. readonly texturesSupported: Array<string>;
  27416. /**
  27417. * Gets the list of texture formats in use
  27418. */
  27419. readonly textureFormatInUse: Nullable<string>;
  27420. /**
  27421. * Gets the current viewport
  27422. */
  27423. readonly currentViewport: Nullable<Viewport>;
  27424. /**
  27425. * Gets the default empty texture
  27426. */
  27427. readonly emptyTexture: InternalTexture;
  27428. /**
  27429. * Gets the default empty 3D texture
  27430. */
  27431. readonly emptyTexture3D: InternalTexture;
  27432. /**
  27433. * Gets the default empty cube texture
  27434. */
  27435. readonly emptyCubeTexture: InternalTexture;
  27436. /**
  27437. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27438. */
  27439. readonly premultipliedAlpha: boolean;
  27440. /**
  27441. * Creates a new engine
  27442. * @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
  27443. * @param antialias defines enable antialiasing (default: false)
  27444. * @param options defines further options to be sent to the getContext() function
  27445. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27446. */
  27447. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27448. private _disableTouchAction;
  27449. private _rebuildInternalTextures;
  27450. private _rebuildEffects;
  27451. /**
  27452. * Gets a boolean indicating if all created effects are ready
  27453. * @returns true if all effects are ready
  27454. */
  27455. areAllEffectsReady(): boolean;
  27456. private _rebuildBuffers;
  27457. private _initGLContext;
  27458. /**
  27459. * Gets version of the current webGL context
  27460. */
  27461. readonly webGLVersion: number;
  27462. /**
  27463. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27464. */
  27465. readonly isStencilEnable: boolean;
  27466. private _prepareWorkingCanvas;
  27467. /**
  27468. * Reset the texture cache to empty state
  27469. */
  27470. resetTextureCache(): void;
  27471. /**
  27472. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27473. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27474. * @returns true if engine is in deterministic lock step mode
  27475. */
  27476. isDeterministicLockStep(): boolean;
  27477. /**
  27478. * Gets the max steps when engine is running in deterministic lock step
  27479. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27480. * @returns the max steps
  27481. */
  27482. getLockstepMaxSteps(): number;
  27483. /**
  27484. * Gets an object containing information about the current webGL context
  27485. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27486. */
  27487. getGlInfo(): {
  27488. vendor: string;
  27489. renderer: string;
  27490. version: string;
  27491. };
  27492. /**
  27493. * Gets current aspect ratio
  27494. * @param camera defines the camera to use to get the aspect ratio
  27495. * @param useScreen defines if screen size must be used (or the current render target if any)
  27496. * @returns a number defining the aspect ratio
  27497. */
  27498. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27499. /**
  27500. * Gets current screen aspect ratio
  27501. * @returns a number defining the aspect ratio
  27502. */
  27503. getScreenAspectRatio(): number;
  27504. /**
  27505. * Gets the current render width
  27506. * @param useScreen defines if screen size must be used (or the current render target if any)
  27507. * @returns a number defining the current render width
  27508. */
  27509. getRenderWidth(useScreen?: boolean): number;
  27510. /**
  27511. * Gets the current render height
  27512. * @param useScreen defines if screen size must be used (or the current render target if any)
  27513. * @returns a number defining the current render height
  27514. */
  27515. getRenderHeight(useScreen?: boolean): number;
  27516. /**
  27517. * Gets the HTML canvas attached with the current webGL context
  27518. * @returns a HTML canvas
  27519. */
  27520. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27521. /**
  27522. * Gets the client rect of the HTML canvas attached with the current webGL context
  27523. * @returns a client rectanglee
  27524. */
  27525. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27526. /**
  27527. * Defines the hardware scaling level.
  27528. * By default the hardware scaling level is computed from the window device ratio.
  27529. * 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.
  27530. * @param level defines the level to use
  27531. */
  27532. setHardwareScalingLevel(level: number): void;
  27533. /**
  27534. * Gets the current hardware scaling level.
  27535. * By default the hardware scaling level is computed from the window device ratio.
  27536. * 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.
  27537. * @returns a number indicating the current hardware scaling level
  27538. */
  27539. getHardwareScalingLevel(): number;
  27540. /**
  27541. * Gets the list of loaded textures
  27542. * @returns an array containing all loaded textures
  27543. */
  27544. getLoadedTexturesCache(): InternalTexture[];
  27545. /**
  27546. * Gets the object containing all engine capabilities
  27547. * @returns the EngineCapabilities object
  27548. */
  27549. getCaps(): EngineCapabilities;
  27550. /**
  27551. * Gets the current depth function
  27552. * @returns a number defining the depth function
  27553. */
  27554. getDepthFunction(): Nullable<number>;
  27555. /**
  27556. * Sets the current depth function
  27557. * @param depthFunc defines the function to use
  27558. */
  27559. setDepthFunction(depthFunc: number): void;
  27560. /**
  27561. * Sets the current depth function to GREATER
  27562. */
  27563. setDepthFunctionToGreater(): void;
  27564. /**
  27565. * Sets the current depth function to GEQUAL
  27566. */
  27567. setDepthFunctionToGreaterOrEqual(): void;
  27568. /**
  27569. * Sets the current depth function to LESS
  27570. */
  27571. setDepthFunctionToLess(): void;
  27572. private _cachedStencilBuffer;
  27573. private _cachedStencilFunction;
  27574. private _cachedStencilMask;
  27575. private _cachedStencilOperationPass;
  27576. private _cachedStencilOperationFail;
  27577. private _cachedStencilOperationDepthFail;
  27578. private _cachedStencilReference;
  27579. /**
  27580. * Caches the the state of the stencil buffer
  27581. */
  27582. cacheStencilState(): void;
  27583. /**
  27584. * Restores the state of the stencil buffer
  27585. */
  27586. restoreStencilState(): void;
  27587. /**
  27588. * Sets the current depth function to LEQUAL
  27589. */
  27590. setDepthFunctionToLessOrEqual(): void;
  27591. /**
  27592. * Gets a boolean indicating if stencil buffer is enabled
  27593. * @returns the current stencil buffer state
  27594. */
  27595. getStencilBuffer(): boolean;
  27596. /**
  27597. * Enable or disable the stencil buffer
  27598. * @param enable defines if the stencil buffer must be enabled or disabled
  27599. */
  27600. setStencilBuffer(enable: boolean): void;
  27601. /**
  27602. * Gets the current stencil mask
  27603. * @returns a number defining the new stencil mask to use
  27604. */
  27605. getStencilMask(): number;
  27606. /**
  27607. * Sets the current stencil mask
  27608. * @param mask defines the new stencil mask to use
  27609. */
  27610. setStencilMask(mask: number): void;
  27611. /**
  27612. * Gets the current stencil function
  27613. * @returns a number defining the stencil function to use
  27614. */
  27615. getStencilFunction(): number;
  27616. /**
  27617. * Gets the current stencil reference value
  27618. * @returns a number defining the stencil reference value to use
  27619. */
  27620. getStencilFunctionReference(): number;
  27621. /**
  27622. * Gets the current stencil mask
  27623. * @returns a number defining the stencil mask to use
  27624. */
  27625. getStencilFunctionMask(): number;
  27626. /**
  27627. * Sets the current stencil function
  27628. * @param stencilFunc defines the new stencil function to use
  27629. */
  27630. setStencilFunction(stencilFunc: number): void;
  27631. /**
  27632. * Sets the current stencil reference
  27633. * @param reference defines the new stencil reference to use
  27634. */
  27635. setStencilFunctionReference(reference: number): void;
  27636. /**
  27637. * Sets the current stencil mask
  27638. * @param mask defines the new stencil mask to use
  27639. */
  27640. setStencilFunctionMask(mask: number): void;
  27641. /**
  27642. * Gets the current stencil operation when stencil fails
  27643. * @returns a number defining stencil operation to use when stencil fails
  27644. */
  27645. getStencilOperationFail(): number;
  27646. /**
  27647. * Gets the current stencil operation when depth fails
  27648. * @returns a number defining stencil operation to use when depth fails
  27649. */
  27650. getStencilOperationDepthFail(): number;
  27651. /**
  27652. * Gets the current stencil operation when stencil passes
  27653. * @returns a number defining stencil operation to use when stencil passes
  27654. */
  27655. getStencilOperationPass(): number;
  27656. /**
  27657. * Sets the stencil operation to use when stencil fails
  27658. * @param operation defines the stencil operation to use when stencil fails
  27659. */
  27660. setStencilOperationFail(operation: number): void;
  27661. /**
  27662. * Sets the stencil operation to use when depth fails
  27663. * @param operation defines the stencil operation to use when depth fails
  27664. */
  27665. setStencilOperationDepthFail(operation: number): void;
  27666. /**
  27667. * Sets the stencil operation to use when stencil passes
  27668. * @param operation defines the stencil operation to use when stencil passes
  27669. */
  27670. setStencilOperationPass(operation: number): void;
  27671. /**
  27672. * Sets a boolean indicating if the dithering state is enabled or disabled
  27673. * @param value defines the dithering state
  27674. */
  27675. setDitheringState(value: boolean): void;
  27676. /**
  27677. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27678. * @param value defines the rasterizer state
  27679. */
  27680. setRasterizerState(value: boolean): void;
  27681. /**
  27682. * stop executing a render loop function and remove it from the execution array
  27683. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27684. */
  27685. stopRenderLoop(renderFunction?: () => void): void;
  27686. /** @hidden */
  27687. _renderLoop(): void;
  27688. /**
  27689. * Register and execute a render loop. The engine can have more than one render function
  27690. * @param renderFunction defines the function to continuously execute
  27691. */
  27692. runRenderLoop(renderFunction: () => void): void;
  27693. /**
  27694. * Toggle full screen mode
  27695. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27696. */
  27697. switchFullscreen(requestPointerLock: boolean): void;
  27698. /**
  27699. * Enters full screen mode
  27700. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27701. */
  27702. enterFullscreen(requestPointerLock: boolean): void;
  27703. /**
  27704. * Exits full screen mode
  27705. */
  27706. exitFullscreen(): void;
  27707. /**
  27708. * Clear the current render buffer or the current render target (if any is set up)
  27709. * @param color defines the color to use
  27710. * @param backBuffer defines if the back buffer must be cleared
  27711. * @param depth defines if the depth buffer must be cleared
  27712. * @param stencil defines if the stencil buffer must be cleared
  27713. */
  27714. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27715. /**
  27716. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27717. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27718. * @param y defines the y-coordinate of the corner of the clear rectangle
  27719. * @param width defines the width of the clear rectangle
  27720. * @param height defines the height of the clear rectangle
  27721. * @param clearColor defines the clear color
  27722. */
  27723. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27724. /**
  27725. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27726. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27727. * @param y defines the y-coordinate of the corner of the clear rectangle
  27728. * @param width defines the width of the clear rectangle
  27729. * @param height defines the height of the clear rectangle
  27730. */
  27731. enableScissor(x: number, y: number, width: number, height: number): void;
  27732. /**
  27733. * Disable previously set scissor test rectangle
  27734. */
  27735. disableScissor(): void;
  27736. private _viewportCached;
  27737. /** @hidden */
  27738. _viewport(x: number, y: number, width: number, height: number): void;
  27739. /**
  27740. * Set the WebGL's viewport
  27741. * @param viewport defines the viewport element to be used
  27742. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27743. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27744. */
  27745. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27746. /**
  27747. * Directly set the WebGL Viewport
  27748. * @param x defines the x coordinate of the viewport (in screen space)
  27749. * @param y defines the y coordinate of the viewport (in screen space)
  27750. * @param width defines the width of the viewport (in screen space)
  27751. * @param height defines the height of the viewport (in screen space)
  27752. * @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
  27753. */
  27754. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27755. /**
  27756. * Begin a new frame
  27757. */
  27758. beginFrame(): void;
  27759. /**
  27760. * Enf the current frame
  27761. */
  27762. endFrame(): void;
  27763. /**
  27764. * Resize the view according to the canvas' size
  27765. */
  27766. resize(): void;
  27767. /**
  27768. * Force a specific size of the canvas
  27769. * @param width defines the new canvas' width
  27770. * @param height defines the new canvas' height
  27771. */
  27772. setSize(width: number, height: number): void;
  27773. /**
  27774. * Gets a boolean indicating if a webVR device was detected
  27775. * @returns true if a webVR device was detected
  27776. */
  27777. isVRDevicePresent(): boolean;
  27778. /**
  27779. * Gets the current webVR device
  27780. * @returns the current webVR device (or null)
  27781. */
  27782. getVRDevice(): any;
  27783. /**
  27784. * Initializes a webVR display and starts listening to display change events
  27785. * The onVRDisplayChangedObservable will be notified upon these changes
  27786. * @returns The onVRDisplayChangedObservable
  27787. */
  27788. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27789. /**
  27790. * Initializes a webVR display and starts listening to display change events
  27791. * The onVRDisplayChangedObservable will be notified upon these changes
  27792. * @returns A promise containing a VRDisplay and if vr is supported
  27793. */
  27794. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27795. /**
  27796. * Call this function to switch to webVR mode
  27797. * Will do nothing if webVR is not supported or if there is no webVR device
  27798. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27799. */
  27800. enableVR(): void;
  27801. /**
  27802. * Call this function to leave webVR mode
  27803. * Will do nothing if webVR is not supported or if there is no webVR device
  27804. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27805. */
  27806. disableVR(): void;
  27807. private _onVRFullScreenTriggered;
  27808. private _getVRDisplaysAsync;
  27809. /**
  27810. * Binds the frame buffer to the specified texture.
  27811. * @param texture The texture to render to or null for the default canvas
  27812. * @param faceIndex The face of the texture to render to in case of cube texture
  27813. * @param requiredWidth The width of the target to render to
  27814. * @param requiredHeight The height of the target to render to
  27815. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27816. * @param depthStencilTexture The depth stencil texture to use to render
  27817. * @param lodLevel defines le lod level to bind to the frame buffer
  27818. */
  27819. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27820. private bindUnboundFramebuffer;
  27821. /**
  27822. * Unbind the current render target texture from the webGL context
  27823. * @param texture defines the render target texture to unbind
  27824. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27825. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27826. */
  27827. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27828. /**
  27829. * Unbind a list of render target textures from the webGL context
  27830. * This is used only when drawBuffer extension or webGL2 are active
  27831. * @param textures defines the render target textures to unbind
  27832. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27833. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27834. */
  27835. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27836. /**
  27837. * Force the mipmap generation for the given render target texture
  27838. * @param texture defines the render target texture to use
  27839. */
  27840. generateMipMapsForCubemap(texture: InternalTexture): void;
  27841. /**
  27842. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27843. */
  27844. flushFramebuffer(): void;
  27845. /**
  27846. * Unbind the current render target and bind the default framebuffer
  27847. */
  27848. restoreDefaultFramebuffer(): void;
  27849. /**
  27850. * Create an uniform buffer
  27851. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27852. * @param elements defines the content of the uniform buffer
  27853. * @returns the webGL uniform buffer
  27854. */
  27855. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27856. /**
  27857. * Create a dynamic uniform buffer
  27858. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27859. * @param elements defines the content of the uniform buffer
  27860. * @returns the webGL uniform buffer
  27861. */
  27862. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27863. /**
  27864. * Update an existing uniform buffer
  27865. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27866. * @param uniformBuffer defines the target uniform buffer
  27867. * @param elements defines the content to update
  27868. * @param offset defines the offset in the uniform buffer where update should start
  27869. * @param count defines the size of the data to update
  27870. */
  27871. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27872. private _resetVertexBufferBinding;
  27873. /**
  27874. * Creates a vertex buffer
  27875. * @param data the data for the vertex buffer
  27876. * @returns the new WebGL static buffer
  27877. */
  27878. createVertexBuffer(data: DataArray): WebGLBuffer;
  27879. /**
  27880. * Creates a dynamic vertex buffer
  27881. * @param data the data for the dynamic vertex buffer
  27882. * @returns the new WebGL dynamic buffer
  27883. */
  27884. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27885. /**
  27886. * Update a dynamic index buffer
  27887. * @param indexBuffer defines the target index buffer
  27888. * @param indices defines the data to update
  27889. * @param offset defines the offset in the target index buffer where update should start
  27890. */
  27891. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27892. /**
  27893. * Updates a dynamic vertex buffer.
  27894. * @param vertexBuffer the vertex buffer to update
  27895. * @param data the data used to update the vertex buffer
  27896. * @param byteOffset the byte offset of the data
  27897. * @param byteLength the byte length of the data
  27898. */
  27899. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27900. private _resetIndexBufferBinding;
  27901. /**
  27902. * Creates a new index buffer
  27903. * @param indices defines the content of the index buffer
  27904. * @param updatable defines if the index buffer must be updatable
  27905. * @returns a new webGL buffer
  27906. */
  27907. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27908. /**
  27909. * Bind a webGL buffer to the webGL context
  27910. * @param buffer defines the buffer to bind
  27911. */
  27912. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27913. /**
  27914. * Bind an uniform buffer to the current webGL context
  27915. * @param buffer defines the buffer to bind
  27916. */
  27917. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27918. /**
  27919. * Bind a buffer to the current webGL context at a given location
  27920. * @param buffer defines the buffer to bind
  27921. * @param location defines the index where to bind the buffer
  27922. */
  27923. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27924. /**
  27925. * Bind a specific block at a given index in a specific shader program
  27926. * @param shaderProgram defines the shader program
  27927. * @param blockName defines the block name
  27928. * @param index defines the index where to bind the block
  27929. */
  27930. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27931. private bindIndexBuffer;
  27932. private bindBuffer;
  27933. /**
  27934. * update the bound buffer with the given data
  27935. * @param data defines the data to update
  27936. */
  27937. updateArrayBuffer(data: Float32Array): void;
  27938. private _vertexAttribPointer;
  27939. private _bindIndexBufferWithCache;
  27940. private _bindVertexBuffersAttributes;
  27941. /**
  27942. * Records a vertex array object
  27943. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27944. * @param vertexBuffers defines the list of vertex buffers to store
  27945. * @param indexBuffer defines the index buffer to store
  27946. * @param effect defines the effect to store
  27947. * @returns the new vertex array object
  27948. */
  27949. recordVertexArrayObject(vertexBuffers: {
  27950. [key: string]: VertexBuffer;
  27951. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27952. /**
  27953. * Bind a specific vertex array object
  27954. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27955. * @param vertexArrayObject defines the vertex array object to bind
  27956. * @param indexBuffer defines the index buffer to bind
  27957. */
  27958. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27959. /**
  27960. * Bind webGl buffers directly to the webGL context
  27961. * @param vertexBuffer defines the vertex buffer to bind
  27962. * @param indexBuffer defines the index buffer to bind
  27963. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27964. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27965. * @param effect defines the effect associated with the vertex buffer
  27966. */
  27967. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27968. private _unbindVertexArrayObject;
  27969. /**
  27970. * Bind a list of vertex buffers to the webGL context
  27971. * @param vertexBuffers defines the list of vertex buffers to bind
  27972. * @param indexBuffer defines the index buffer to bind
  27973. * @param effect defines the effect associated with the vertex buffers
  27974. */
  27975. bindBuffers(vertexBuffers: {
  27976. [key: string]: Nullable<VertexBuffer>;
  27977. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27978. /**
  27979. * Unbind all instance attributes
  27980. */
  27981. unbindInstanceAttributes(): void;
  27982. /**
  27983. * Release and free the memory of a vertex array object
  27984. * @param vao defines the vertex array object to delete
  27985. */
  27986. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27987. /** @hidden */
  27988. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27989. /**
  27990. * Creates a webGL buffer to use with instanciation
  27991. * @param capacity defines the size of the buffer
  27992. * @returns the webGL buffer
  27993. */
  27994. createInstancesBuffer(capacity: number): WebGLBuffer;
  27995. /**
  27996. * Delete a webGL buffer used with instanciation
  27997. * @param buffer defines the webGL buffer to delete
  27998. */
  27999. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28000. /**
  28001. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28002. * @param instancesBuffer defines the webGL buffer to update and bind
  28003. * @param data defines the data to store in the buffer
  28004. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28005. */
  28006. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28007. /**
  28008. * Apply all cached states (depth, culling, stencil and alpha)
  28009. */
  28010. applyStates(): void;
  28011. /**
  28012. * Send a draw order
  28013. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28014. * @param indexStart defines the starting index
  28015. * @param indexCount defines the number of index to draw
  28016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28017. */
  28018. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28019. /**
  28020. * Draw a list of points
  28021. * @param verticesStart defines the index of first vertex to draw
  28022. * @param verticesCount defines the count of vertices to draw
  28023. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28024. */
  28025. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28026. /**
  28027. * Draw a list of unindexed primitives
  28028. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28029. * @param verticesStart defines the index of first vertex to draw
  28030. * @param verticesCount defines the count of vertices to draw
  28031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28032. */
  28033. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28034. /**
  28035. * Draw a list of indexed primitives
  28036. * @param fillMode defines the primitive to use
  28037. * @param indexStart defines the starting index
  28038. * @param indexCount defines the number of index to draw
  28039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28040. */
  28041. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28042. /**
  28043. * Draw a list of unindexed primitives
  28044. * @param fillMode defines the primitive to use
  28045. * @param verticesStart defines the index of first vertex to draw
  28046. * @param verticesCount defines the count of vertices to draw
  28047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28048. */
  28049. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28050. private _drawMode;
  28051. /** @hidden */
  28052. _releaseEffect(effect: Effect): void;
  28053. /** @hidden */
  28054. _deleteProgram(program: WebGLProgram): void;
  28055. /**
  28056. * Create a new effect (used to store vertex/fragment shaders)
  28057. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28058. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28059. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28060. * @param samplers defines an array of string used to represent textures
  28061. * @param defines defines the string containing the defines to use to compile the shaders
  28062. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28063. * @param onCompiled defines a function to call when the effect creation is successful
  28064. * @param onError defines a function to call when the effect creation has failed
  28065. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28066. * @returns the new Effect
  28067. */
  28068. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28069. private _compileShader;
  28070. private _compileRawShader;
  28071. /**
  28072. * Directly creates a webGL program
  28073. * @param vertexCode defines the vertex shader code to use
  28074. * @param fragmentCode defines the fragment shader code to use
  28075. * @param context defines the webGL context to use (if not set, the current one will be used)
  28076. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28077. * @returns the new webGL program
  28078. */
  28079. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28080. /**
  28081. * Creates a webGL program
  28082. * @param vertexCode defines the vertex shader code to use
  28083. * @param fragmentCode defines the fragment shader code to use
  28084. * @param defines defines the string containing the defines to use to compile the shaders
  28085. * @param context defines the webGL context to use (if not set, the current one will be used)
  28086. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28087. * @returns the new webGL program
  28088. */
  28089. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28090. private _createShaderProgram;
  28091. private _finalizeProgram;
  28092. /** @hidden */
  28093. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28094. /** @hidden */
  28095. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28096. /**
  28097. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28098. * @param shaderProgram defines the webGL program to use
  28099. * @param uniformsNames defines the list of uniform names
  28100. * @returns an array of webGL uniform locations
  28101. */
  28102. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28103. /**
  28104. * Gets the lsit of active attributes for a given webGL program
  28105. * @param shaderProgram defines the webGL program to use
  28106. * @param attributesNames defines the list of attribute names to get
  28107. * @returns an array of indices indicating the offset of each attribute
  28108. */
  28109. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28110. /**
  28111. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28112. * @param effect defines the effect to activate
  28113. */
  28114. enableEffect(effect: Nullable<Effect>): void;
  28115. /**
  28116. * Set the value of an uniform to an array of int32
  28117. * @param uniform defines the webGL uniform location where to store the value
  28118. * @param array defines the array of int32 to store
  28119. */
  28120. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28121. /**
  28122. * Set the value of an uniform to an array of int32 (stored as vec2)
  28123. * @param uniform defines the webGL uniform location where to store the value
  28124. * @param array defines the array of int32 to store
  28125. */
  28126. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28127. /**
  28128. * Set the value of an uniform to an array of int32 (stored as vec3)
  28129. * @param uniform defines the webGL uniform location where to store the value
  28130. * @param array defines the array of int32 to store
  28131. */
  28132. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28133. /**
  28134. * Set the value of an uniform to an array of int32 (stored as vec4)
  28135. * @param uniform defines the webGL uniform location where to store the value
  28136. * @param array defines the array of int32 to store
  28137. */
  28138. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28139. /**
  28140. * Set the value of an uniform to an array of float32
  28141. * @param uniform defines the webGL uniform location where to store the value
  28142. * @param array defines the array of float32 to store
  28143. */
  28144. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28145. /**
  28146. * Set the value of an uniform to an array of float32 (stored as vec2)
  28147. * @param uniform defines the webGL uniform location where to store the value
  28148. * @param array defines the array of float32 to store
  28149. */
  28150. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28151. /**
  28152. * Set the value of an uniform to an array of float32 (stored as vec3)
  28153. * @param uniform defines the webGL uniform location where to store the value
  28154. * @param array defines the array of float32 to store
  28155. */
  28156. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28157. /**
  28158. * Set the value of an uniform to an array of float32 (stored as vec4)
  28159. * @param uniform defines the webGL uniform location where to store the value
  28160. * @param array defines the array of float32 to store
  28161. */
  28162. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28163. /**
  28164. * Set the value of an uniform to an array of number
  28165. * @param uniform defines the webGL uniform location where to store the value
  28166. * @param array defines the array of number to store
  28167. */
  28168. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28169. /**
  28170. * Set the value of an uniform to an array of number (stored as vec2)
  28171. * @param uniform defines the webGL uniform location where to store the value
  28172. * @param array defines the array of number to store
  28173. */
  28174. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28175. /**
  28176. * Set the value of an uniform to an array of number (stored as vec3)
  28177. * @param uniform defines the webGL uniform location where to store the value
  28178. * @param array defines the array of number to store
  28179. */
  28180. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28181. /**
  28182. * Set the value of an uniform to an array of number (stored as vec4)
  28183. * @param uniform defines the webGL uniform location where to store the value
  28184. * @param array defines the array of number to store
  28185. */
  28186. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28187. /**
  28188. * Set the value of an uniform to an array of float32 (stored as matrices)
  28189. * @param uniform defines the webGL uniform location where to store the value
  28190. * @param matrices defines the array of float32 to store
  28191. */
  28192. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28193. /**
  28194. * Set the value of an uniform to a matrix
  28195. * @param uniform defines the webGL uniform location where to store the value
  28196. * @param matrix defines the matrix to store
  28197. */
  28198. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28199. /**
  28200. * Set the value of an uniform to a matrix (3x3)
  28201. * @param uniform defines the webGL uniform location where to store the value
  28202. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28203. */
  28204. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28205. /**
  28206. * Set the value of an uniform to a matrix (2x2)
  28207. * @param uniform defines the webGL uniform location where to store the value
  28208. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28209. */
  28210. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28211. /**
  28212. * Set the value of an uniform to a number (int)
  28213. * @param uniform defines the webGL uniform location where to store the value
  28214. * @param value defines the int number to store
  28215. */
  28216. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28217. /**
  28218. * Set the value of an uniform to a number (float)
  28219. * @param uniform defines the webGL uniform location where to store the value
  28220. * @param value defines the float number to store
  28221. */
  28222. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28223. /**
  28224. * Set the value of an uniform to a vec2
  28225. * @param uniform defines the webGL uniform location where to store the value
  28226. * @param x defines the 1st component of the value
  28227. * @param y defines the 2nd component of the value
  28228. */
  28229. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28230. /**
  28231. * Set the value of an uniform to a vec3
  28232. * @param uniform defines the webGL uniform location where to store the value
  28233. * @param x defines the 1st component of the value
  28234. * @param y defines the 2nd component of the value
  28235. * @param z defines the 3rd component of the value
  28236. */
  28237. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28238. /**
  28239. * Set the value of an uniform to a boolean
  28240. * @param uniform defines the webGL uniform location where to store the value
  28241. * @param bool defines the boolean to store
  28242. */
  28243. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28244. /**
  28245. * Set the value of an uniform to a vec4
  28246. * @param uniform defines the webGL uniform location where to store the value
  28247. * @param x defines the 1st component of the value
  28248. * @param y defines the 2nd component of the value
  28249. * @param z defines the 3rd component of the value
  28250. * @param w defines the 4th component of the value
  28251. */
  28252. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28253. /**
  28254. * Set the value of an uniform to a Color3
  28255. * @param uniform defines the webGL uniform location where to store the value
  28256. * @param color3 defines the color to store
  28257. */
  28258. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28259. /**
  28260. * Set the value of an uniform to a Color3 and an alpha value
  28261. * @param uniform defines the webGL uniform location where to store the value
  28262. * @param color3 defines the color to store
  28263. * @param alpha defines the alpha component to store
  28264. */
  28265. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28266. /**
  28267. * Sets a Color4 on a uniform variable
  28268. * @param uniform defines the uniform location
  28269. * @param color4 defines the value to be set
  28270. */
  28271. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28272. /**
  28273. * Set various states to the webGL context
  28274. * @param culling defines backface culling state
  28275. * @param zOffset defines the value to apply to zOffset (0 by default)
  28276. * @param force defines if states must be applied even if cache is up to date
  28277. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28278. */
  28279. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28280. /**
  28281. * Set the z offset to apply to current rendering
  28282. * @param value defines the offset to apply
  28283. */
  28284. setZOffset(value: number): void;
  28285. /**
  28286. * Gets the current value of the zOffset
  28287. * @returns the current zOffset state
  28288. */
  28289. getZOffset(): number;
  28290. /**
  28291. * Enable or disable depth buffering
  28292. * @param enable defines the state to set
  28293. */
  28294. setDepthBuffer(enable: boolean): void;
  28295. /**
  28296. * Gets a boolean indicating if depth writing is enabled
  28297. * @returns the current depth writing state
  28298. */
  28299. getDepthWrite(): boolean;
  28300. /**
  28301. * Enable or disable depth writing
  28302. * @param enable defines the state to set
  28303. */
  28304. setDepthWrite(enable: boolean): void;
  28305. /**
  28306. * Enable or disable color writing
  28307. * @param enable defines the state to set
  28308. */
  28309. setColorWrite(enable: boolean): void;
  28310. /**
  28311. * Gets a boolean indicating if color writing is enabled
  28312. * @returns the current color writing state
  28313. */
  28314. getColorWrite(): boolean;
  28315. /**
  28316. * Sets alpha constants used by some alpha blending modes
  28317. * @param r defines the red component
  28318. * @param g defines the green component
  28319. * @param b defines the blue component
  28320. * @param a defines the alpha component
  28321. */
  28322. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28323. /**
  28324. * Sets the current alpha mode
  28325. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28326. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28327. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28328. */
  28329. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28330. /**
  28331. * Gets the current alpha mode
  28332. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28333. * @returns the current alpha mode
  28334. */
  28335. getAlphaMode(): number;
  28336. /**
  28337. * Clears the list of texture accessible through engine.
  28338. * This can help preventing texture load conflict due to name collision.
  28339. */
  28340. clearInternalTexturesCache(): void;
  28341. /**
  28342. * Force the entire cache to be cleared
  28343. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28344. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28345. */
  28346. wipeCaches(bruteForce?: boolean): void;
  28347. /**
  28348. * Set the compressed texture format to use, based on the formats you have, and the formats
  28349. * supported by the hardware / browser.
  28350. *
  28351. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28352. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28353. * to API arguments needed to compressed textures. This puts the burden on the container
  28354. * generator to house the arcane code for determining these for current & future formats.
  28355. *
  28356. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28357. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28358. *
  28359. * Note: The result of this call is not taken into account when a texture is base64.
  28360. *
  28361. * @param formatsAvailable defines the list of those format families you have created
  28362. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28363. *
  28364. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28365. * @returns The extension selected.
  28366. */
  28367. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28368. private _getSamplingParameters;
  28369. private _partialLoadImg;
  28370. private _cascadeLoadImgs;
  28371. /** @hidden */
  28372. _createTexture(): WebGLTexture;
  28373. /**
  28374. * Usually called from Texture.ts.
  28375. * Passed information to create a WebGLTexture
  28376. * @param urlArg defines a value which contains one of the following:
  28377. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28378. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28379. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28380. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28381. * @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)
  28382. * @param scene needed for loading to the correct scene
  28383. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28384. * @param onLoad optional callback to be called upon successful completion
  28385. * @param onError optional callback to be called upon failure
  28386. * @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
  28387. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28388. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28389. * @param forcedExtension defines the extension to use to pick the right loader
  28390. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28391. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28392. */
  28393. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28394. private _rescaleTexture;
  28395. /**
  28396. * Update a raw texture
  28397. * @param texture defines the texture to update
  28398. * @param data defines the data to store in the texture
  28399. * @param format defines the format of the data
  28400. * @param invertY defines if data must be stored with Y axis inverted
  28401. * @param compression defines the compression used (null by default)
  28402. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28403. */
  28404. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28405. /**
  28406. * Creates a raw texture
  28407. * @param data defines the data to store in the texture
  28408. * @param width defines the width of the texture
  28409. * @param height defines the height of the texture
  28410. * @param format defines the format of the data
  28411. * @param generateMipMaps defines if the engine should generate the mip levels
  28412. * @param invertY defines if data must be stored with Y axis inverted
  28413. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28414. * @param compression defines the compression used (null by default)
  28415. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28416. * @returns the raw texture inside an InternalTexture
  28417. */
  28418. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28419. private _unpackFlipYCached;
  28420. /**
  28421. * In case you are sharing the context with other applications, it might
  28422. * be interested to not cache the unpack flip y state to ensure a consistent
  28423. * value would be set.
  28424. */
  28425. enableUnpackFlipYCached: boolean;
  28426. /** @hidden */
  28427. _unpackFlipY(value: boolean): void;
  28428. /** @hidden */
  28429. _getUnpackAlignement(): number;
  28430. /**
  28431. * Creates a dynamic texture
  28432. * @param width defines the width of the texture
  28433. * @param height defines the height of the texture
  28434. * @param generateMipMaps defines if the engine should generate the mip levels
  28435. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28436. * @returns the dynamic texture inside an InternalTexture
  28437. */
  28438. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28439. /**
  28440. * Update the sampling mode of a given texture
  28441. * @param samplingMode defines the required sampling mode
  28442. * @param texture defines the texture to update
  28443. */
  28444. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28445. /**
  28446. * Update the content of a dynamic texture
  28447. * @param texture defines the texture to update
  28448. * @param canvas defines the canvas containing the source
  28449. * @param invertY defines if data must be stored with Y axis inverted
  28450. * @param premulAlpha defines if alpha is stored as premultiplied
  28451. * @param format defines the format of the data
  28452. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28453. */
  28454. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28455. /**
  28456. * Update a video texture
  28457. * @param texture defines the texture to update
  28458. * @param video defines the video element to use
  28459. * @param invertY defines if data must be stored with Y axis inverted
  28460. */
  28461. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28462. /**
  28463. * Updates a depth texture Comparison Mode and Function.
  28464. * If the comparison Function is equal to 0, the mode will be set to none.
  28465. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28466. * @param texture The texture to set the comparison function for
  28467. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28468. */
  28469. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28470. private _setupDepthStencilTexture;
  28471. /**
  28472. * Creates a depth stencil texture.
  28473. * This is only available in WebGL 2 or with the depth texture extension available.
  28474. * @param size The size of face edge in the texture.
  28475. * @param options The options defining the texture.
  28476. * @returns The texture
  28477. */
  28478. createDepthStencilTexture(size: number | {
  28479. width: number;
  28480. height: number;
  28481. }, options: DepthTextureCreationOptions): InternalTexture;
  28482. /**
  28483. * Creates a depth stencil texture.
  28484. * This is only available in WebGL 2 or with the depth texture extension available.
  28485. * @param size The size of face edge in the texture.
  28486. * @param options The options defining the texture.
  28487. * @returns The texture
  28488. */
  28489. private _createDepthStencilTexture;
  28490. /**
  28491. * Creates a depth stencil cube texture.
  28492. * This is only available in WebGL 2.
  28493. * @param size The size of face edge in the cube texture.
  28494. * @param options The options defining the cube texture.
  28495. * @returns The cube texture
  28496. */
  28497. private _createDepthStencilCubeTexture;
  28498. /**
  28499. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28500. * @param renderTarget The render target to set the frame buffer for
  28501. */
  28502. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28503. /**
  28504. * Creates a new render target texture
  28505. * @param size defines the size of the texture
  28506. * @param options defines the options used to create the texture
  28507. * @returns a new render target texture stored in an InternalTexture
  28508. */
  28509. createRenderTargetTexture(size: number | {
  28510. width: number;
  28511. height: number;
  28512. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28513. /**
  28514. * Create a multi render target texture
  28515. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28516. * @param size defines the size of the texture
  28517. * @param options defines the creation options
  28518. * @returns the cube texture as an InternalTexture
  28519. */
  28520. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28521. private _setupFramebufferDepthAttachments;
  28522. /**
  28523. * Updates the sample count of a render target texture
  28524. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28525. * @param texture defines the texture to update
  28526. * @param samples defines the sample count to set
  28527. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28528. */
  28529. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28530. /**
  28531. * Update the sample count for a given multiple render target texture
  28532. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28533. * @param textures defines the textures to update
  28534. * @param samples defines the sample count to set
  28535. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28536. */
  28537. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28538. /** @hidden */
  28539. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28540. /** @hidden */
  28541. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28542. /** @hidden */
  28543. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28544. /** @hidden */
  28545. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28546. /**
  28547. * Creates a new render target cube texture
  28548. * @param size defines the size of the texture
  28549. * @param options defines the options used to create the texture
  28550. * @returns a new render target cube texture stored in an InternalTexture
  28551. */
  28552. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28553. /**
  28554. * Creates a cube texture
  28555. * @param rootUrl defines the url where the files to load is located
  28556. * @param scene defines the current scene
  28557. * @param files defines the list of files to load (1 per face)
  28558. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28559. * @param onLoad defines an optional callback raised when the texture is loaded
  28560. * @param onError defines an optional callback raised if there is an issue to load the texture
  28561. * @param format defines the format of the data
  28562. * @param forcedExtension defines the extension to use to pick the right loader
  28563. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28564. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28565. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28566. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28567. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28568. * @returns the cube texture as an InternalTexture
  28569. */
  28570. 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>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28571. /**
  28572. * @hidden
  28573. */
  28574. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28575. /**
  28576. * Update a raw cube texture
  28577. * @param texture defines the texture to udpdate
  28578. * @param data defines the data to store
  28579. * @param format defines the data format
  28580. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28581. * @param invertY defines if data must be stored with Y axis inverted
  28582. * @param compression defines the compression used (null by default)
  28583. * @param level defines which level of the texture to update
  28584. */
  28585. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28586. /**
  28587. * Creates a new raw cube texture
  28588. * @param data defines the array of data to use to create each face
  28589. * @param size defines the size of the textures
  28590. * @param format defines the format of the data
  28591. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28592. * @param generateMipMaps defines if the engine should generate the mip levels
  28593. * @param invertY defines if data must be stored with Y axis inverted
  28594. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28595. * @param compression defines the compression used (null by default)
  28596. * @returns the cube texture as an InternalTexture
  28597. */
  28598. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28599. /**
  28600. * Creates a new raw cube texture from a specified url
  28601. * @param url defines the url where the data is located
  28602. * @param scene defines the current scene
  28603. * @param size defines the size of the textures
  28604. * @param format defines the format of the data
  28605. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28606. * @param noMipmap defines if the engine should avoid generating the mip levels
  28607. * @param callback defines a callback used to extract texture data from loaded data
  28608. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28609. * @param onLoad defines a callback called when texture is loaded
  28610. * @param onError defines a callback called if there is an error
  28611. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28612. * @param invertY defines if data must be stored with Y axis inverted
  28613. * @returns the cube texture as an InternalTexture
  28614. */
  28615. 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;
  28616. /**
  28617. * Update a raw 3D texture
  28618. * @param texture defines the texture to update
  28619. * @param data defines the data to store
  28620. * @param format defines the data format
  28621. * @param invertY defines if data must be stored with Y axis inverted
  28622. * @param compression defines the used compression (can be null)
  28623. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28624. */
  28625. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28626. /**
  28627. * Creates a new raw 3D texture
  28628. * @param data defines the data used to create the texture
  28629. * @param width defines the width of the texture
  28630. * @param height defines the height of the texture
  28631. * @param depth defines the depth of the texture
  28632. * @param format defines the format of the texture
  28633. * @param generateMipMaps defines if the engine must generate mip levels
  28634. * @param invertY defines if data must be stored with Y axis inverted
  28635. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28636. * @param compression defines the compressed used (can be null)
  28637. * @param textureType defines the compressed used (can be null)
  28638. * @returns a new raw 3D texture (stored in an InternalTexture)
  28639. */
  28640. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28641. private _prepareWebGLTextureContinuation;
  28642. private _prepareWebGLTexture;
  28643. private _convertRGBtoRGBATextureData;
  28644. /** @hidden */
  28645. _releaseFramebufferObjects(texture: InternalTexture): void;
  28646. /** @hidden */
  28647. _releaseTexture(texture: InternalTexture): void;
  28648. private setProgram;
  28649. private _boundUniforms;
  28650. /**
  28651. * Binds an effect to the webGL context
  28652. * @param effect defines the effect to bind
  28653. */
  28654. bindSamplers(effect: Effect): void;
  28655. private _moveBoundTextureOnTop;
  28656. private _getCorrectTextureChannel;
  28657. private _linkTrackers;
  28658. private _removeDesignatedSlot;
  28659. private _activateCurrentTexture;
  28660. /** @hidden */
  28661. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28662. /** @hidden */
  28663. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28664. /**
  28665. * Sets a texture to the webGL context from a postprocess
  28666. * @param channel defines the channel to use
  28667. * @param postProcess defines the source postprocess
  28668. */
  28669. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28670. /**
  28671. * Binds the output of the passed in post process to the texture channel specified
  28672. * @param channel The channel the texture should be bound to
  28673. * @param postProcess The post process which's output should be bound
  28674. */
  28675. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28676. /**
  28677. * Unbind all textures from the webGL context
  28678. */
  28679. unbindAllTextures(): void;
  28680. /**
  28681. * Sets a texture to the according uniform.
  28682. * @param channel The texture channel
  28683. * @param uniform The uniform to set
  28684. * @param texture The texture to apply
  28685. */
  28686. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28687. /**
  28688. * Sets a depth stencil texture from a render target to the according uniform.
  28689. * @param channel The texture channel
  28690. * @param uniform The uniform to set
  28691. * @param texture The render target texture containing the depth stencil texture to apply
  28692. */
  28693. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28694. private _bindSamplerUniformToChannel;
  28695. private _getTextureWrapMode;
  28696. private _setTexture;
  28697. /**
  28698. * Sets an array of texture to the webGL context
  28699. * @param channel defines the channel where the texture array must be set
  28700. * @param uniform defines the associated uniform location
  28701. * @param textures defines the array of textures to bind
  28702. */
  28703. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28704. /** @hidden */
  28705. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28706. private _setTextureParameterFloat;
  28707. private _setTextureParameterInteger;
  28708. /**
  28709. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28710. * @param x defines the x coordinate of the rectangle where pixels must be read
  28711. * @param y defines the y coordinate of the rectangle where pixels must be read
  28712. * @param width defines the width of the rectangle where pixels must be read
  28713. * @param height defines the height of the rectangle where pixels must be read
  28714. * @returns a Uint8Array containing RGBA colors
  28715. */
  28716. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28717. /**
  28718. * Add an externaly attached data from its key.
  28719. * This method call will fail and return false, if such key already exists.
  28720. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28721. * @param key the unique key that identifies the data
  28722. * @param data the data object to associate to the key for this Engine instance
  28723. * @return true if no such key were already present and the data was added successfully, false otherwise
  28724. */
  28725. addExternalData<T>(key: string, data: T): boolean;
  28726. /**
  28727. * Get an externaly attached data from its key
  28728. * @param key the unique key that identifies the data
  28729. * @return the associated data, if present (can be null), or undefined if not present
  28730. */
  28731. getExternalData<T>(key: string): T;
  28732. /**
  28733. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28734. * @param key the unique key that identifies the data
  28735. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28736. * @return the associated data, can be null if the factory returned null.
  28737. */
  28738. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28739. /**
  28740. * Remove an externaly attached data from the Engine instance
  28741. * @param key the unique key that identifies the data
  28742. * @return true if the data was successfully removed, false if it doesn't exist
  28743. */
  28744. removeExternalData(key: string): boolean;
  28745. /**
  28746. * Unbind all vertex attributes from the webGL context
  28747. */
  28748. unbindAllAttributes(): void;
  28749. /**
  28750. * 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
  28751. */
  28752. releaseEffects(): void;
  28753. /**
  28754. * Dispose and release all associated resources
  28755. */
  28756. dispose(): void;
  28757. /**
  28758. * Display the loading screen
  28759. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28760. */
  28761. displayLoadingUI(): void;
  28762. /**
  28763. * Hide the loading screen
  28764. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28765. */
  28766. hideLoadingUI(): void;
  28767. /**
  28768. * Gets the current loading screen object
  28769. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28770. */
  28771. /**
  28772. * Sets the current loading screen object
  28773. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28774. */
  28775. loadingScreen: ILoadingScreen;
  28776. /**
  28777. * Sets the current loading screen text
  28778. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28779. */
  28780. loadingUIText: string;
  28781. /**
  28782. * Sets the current loading screen background color
  28783. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28784. */
  28785. loadingUIBackgroundColor: string;
  28786. /**
  28787. * Attach a new callback raised when context lost event is fired
  28788. * @param callback defines the callback to call
  28789. */
  28790. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28791. /**
  28792. * Attach a new callback raised when context restored event is fired
  28793. * @param callback defines the callback to call
  28794. */
  28795. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28796. /**
  28797. * Gets the source code of the vertex shader associated with a specific webGL program
  28798. * @param program defines the program to use
  28799. * @returns a string containing the source code of the vertex shader associated with the program
  28800. */
  28801. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28802. /**
  28803. * Gets the source code of the fragment shader associated with a specific webGL program
  28804. * @param program defines the program to use
  28805. * @returns a string containing the source code of the fragment shader associated with the program
  28806. */
  28807. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28808. /**
  28809. * Get the current error code of the webGL context
  28810. * @returns the error code
  28811. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28812. */
  28813. getError(): number;
  28814. /**
  28815. * Gets the current framerate
  28816. * @returns a number representing the framerate
  28817. */
  28818. getFps(): number;
  28819. /**
  28820. * Gets the time spent between current and previous frame
  28821. * @returns a number representing the delta time in ms
  28822. */
  28823. getDeltaTime(): number;
  28824. private _measureFps;
  28825. /** @hidden */
  28826. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28827. private _canRenderToFloatFramebuffer;
  28828. private _canRenderToHalfFloatFramebuffer;
  28829. private _canRenderToFramebuffer;
  28830. /** @hidden */
  28831. _getWebGLTextureType(type: number): number;
  28832. private _getInternalFormat;
  28833. /** @hidden */
  28834. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28835. /** @hidden */
  28836. _getRGBAMultiSampleBufferFormat(type: number): number;
  28837. /** @hidden */
  28838. _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;
  28839. /** @hidden */
  28840. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28841. private _partialLoadFile;
  28842. private _cascadeLoadFiles;
  28843. /**
  28844. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28845. * @returns true if the engine can be created
  28846. * @ignorenaming
  28847. */
  28848. static isSupported(): boolean;
  28849. }
  28850. }
  28851. declare module BABYLON {
  28852. /**
  28853. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28854. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28855. */
  28856. export class EffectFallbacks {
  28857. private _defines;
  28858. private _currentRank;
  28859. private _maxRank;
  28860. private _mesh;
  28861. /**
  28862. * Removes the fallback from the bound mesh.
  28863. */
  28864. unBindMesh(): void;
  28865. /**
  28866. * Adds a fallback on the specified property.
  28867. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28868. * @param define The name of the define in the shader
  28869. */
  28870. addFallback(rank: number, define: string): void;
  28871. /**
  28872. * Sets the mesh to use CPU skinning when needing to fallback.
  28873. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28874. * @param mesh The mesh to use the fallbacks.
  28875. */
  28876. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28877. /**
  28878. * Checks to see if more fallbacks are still availible.
  28879. */
  28880. readonly isMoreFallbacks: boolean;
  28881. /**
  28882. * Removes the defines that shoould be removed when falling back.
  28883. * @param currentDefines defines the current define statements for the shader.
  28884. * @param effect defines the current effect we try to compile
  28885. * @returns The resulting defines with defines of the current rank removed.
  28886. */
  28887. reduce(currentDefines: string, effect: Effect): string;
  28888. }
  28889. /**
  28890. * Options to be used when creating an effect.
  28891. */
  28892. export class EffectCreationOptions {
  28893. /**
  28894. * Atrributes that will be used in the shader.
  28895. */
  28896. attributes: string[];
  28897. /**
  28898. * Uniform varible names that will be set in the shader.
  28899. */
  28900. uniformsNames: string[];
  28901. /**
  28902. * Uniform buffer varible names that will be set in the shader.
  28903. */
  28904. uniformBuffersNames: string[];
  28905. /**
  28906. * Sampler texture variable names that will be set in the shader.
  28907. */
  28908. samplers: string[];
  28909. /**
  28910. * Define statements that will be set in the shader.
  28911. */
  28912. defines: any;
  28913. /**
  28914. * Possible fallbacks for this effect to improve performance when needed.
  28915. */
  28916. fallbacks: Nullable<EffectFallbacks>;
  28917. /**
  28918. * Callback that will be called when the shader is compiled.
  28919. */
  28920. onCompiled: Nullable<(effect: Effect) => void>;
  28921. /**
  28922. * Callback that will be called if an error occurs during shader compilation.
  28923. */
  28924. onError: Nullable<(effect: Effect, errors: string) => void>;
  28925. /**
  28926. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28927. */
  28928. indexParameters: any;
  28929. /**
  28930. * Max number of lights that can be used in the shader.
  28931. */
  28932. maxSimultaneousLights: number;
  28933. /**
  28934. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28935. */
  28936. transformFeedbackVaryings: Nullable<string[]>;
  28937. }
  28938. /**
  28939. * Effect containing vertex and fragment shader that can be executed on an object.
  28940. */
  28941. export class Effect {
  28942. /**
  28943. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28944. */
  28945. static ShadersRepository: string;
  28946. /**
  28947. * Name of the effect.
  28948. */
  28949. name: any;
  28950. /**
  28951. * String container all the define statements that should be set on the shader.
  28952. */
  28953. defines: string;
  28954. /**
  28955. * Callback that will be called when the shader is compiled.
  28956. */
  28957. onCompiled: Nullable<(effect: Effect) => void>;
  28958. /**
  28959. * Callback that will be called if an error occurs during shader compilation.
  28960. */
  28961. onError: Nullable<(effect: Effect, errors: string) => void>;
  28962. /**
  28963. * Callback that will be called when effect is bound.
  28964. */
  28965. onBind: Nullable<(effect: Effect) => void>;
  28966. /**
  28967. * Unique ID of the effect.
  28968. */
  28969. uniqueId: number;
  28970. /**
  28971. * Observable that will be called when the shader is compiled.
  28972. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28973. */
  28974. onCompileObservable: Observable<Effect>;
  28975. /**
  28976. * Observable that will be called if an error occurs during shader compilation.
  28977. */
  28978. onErrorObservable: Observable<Effect>;
  28979. /** @hidden */
  28980. _onBindObservable: Nullable<Observable<Effect>>;
  28981. /**
  28982. * Observable that will be called when effect is bound.
  28983. */
  28984. readonly onBindObservable: Observable<Effect>;
  28985. /** @hidden */
  28986. _bonesComputationForcedToCPU: boolean;
  28987. private static _uniqueIdSeed;
  28988. private _engine;
  28989. private _uniformBuffersNames;
  28990. private _uniformsNames;
  28991. private _samplers;
  28992. private _isReady;
  28993. private _compilationError;
  28994. private _attributesNames;
  28995. private _attributes;
  28996. private _uniforms;
  28997. /**
  28998. * Key for the effect.
  28999. * @hidden
  29000. */
  29001. _key: string;
  29002. private _indexParameters;
  29003. private _fallbacks;
  29004. private _vertexSourceCode;
  29005. private _fragmentSourceCode;
  29006. private _vertexSourceCodeOverride;
  29007. private _fragmentSourceCodeOverride;
  29008. private _transformFeedbackVaryings;
  29009. /**
  29010. * Compiled shader to webGL program.
  29011. * @hidden
  29012. */
  29013. _program: WebGLProgram;
  29014. private _valueCache;
  29015. private static _baseCache;
  29016. /**
  29017. * Instantiates an effect.
  29018. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29019. * @param baseName Name of the effect.
  29020. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29021. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29022. * @param samplers List of sampler variables that will be passed to the shader.
  29023. * @param engine Engine to be used to render the effect
  29024. * @param defines Define statements to be added to the shader.
  29025. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29026. * @param onCompiled Callback that will be called when the shader is compiled.
  29027. * @param onError Callback that will be called if an error occurs during shader compilation.
  29028. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29029. */
  29030. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29031. /**
  29032. * Unique key for this effect
  29033. */
  29034. readonly key: string;
  29035. /**
  29036. * If the effect has been compiled and prepared.
  29037. * @returns if the effect is compiled and prepared.
  29038. */
  29039. isReady(): boolean;
  29040. /**
  29041. * The engine the effect was initialized with.
  29042. * @returns the engine.
  29043. */
  29044. getEngine(): Engine;
  29045. /**
  29046. * The compiled webGL program for the effect
  29047. * @returns the webGL program.
  29048. */
  29049. getProgram(): WebGLProgram;
  29050. /**
  29051. * The set of names of attribute variables for the shader.
  29052. * @returns An array of attribute names.
  29053. */
  29054. getAttributesNames(): string[];
  29055. /**
  29056. * Returns the attribute at the given index.
  29057. * @param index The index of the attribute.
  29058. * @returns The location of the attribute.
  29059. */
  29060. getAttributeLocation(index: number): number;
  29061. /**
  29062. * Returns the attribute based on the name of the variable.
  29063. * @param name of the attribute to look up.
  29064. * @returns the attribute location.
  29065. */
  29066. getAttributeLocationByName(name: string): number;
  29067. /**
  29068. * The number of attributes.
  29069. * @returns the numnber of attributes.
  29070. */
  29071. getAttributesCount(): number;
  29072. /**
  29073. * Gets the index of a uniform variable.
  29074. * @param uniformName of the uniform to look up.
  29075. * @returns the index.
  29076. */
  29077. getUniformIndex(uniformName: string): number;
  29078. /**
  29079. * Returns the attribute based on the name of the variable.
  29080. * @param uniformName of the uniform to look up.
  29081. * @returns the location of the uniform.
  29082. */
  29083. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29084. /**
  29085. * Returns an array of sampler variable names
  29086. * @returns The array of sampler variable neames.
  29087. */
  29088. getSamplers(): string[];
  29089. /**
  29090. * The error from the last compilation.
  29091. * @returns the error string.
  29092. */
  29093. getCompilationError(): string;
  29094. /**
  29095. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29096. * @param func The callback to be used.
  29097. */
  29098. executeWhenCompiled(func: (effect: Effect) => void): void;
  29099. private _checkIsReady;
  29100. /** @hidden */
  29101. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29102. /** @hidden */
  29103. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29104. /** @hidden */
  29105. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29106. private _processShaderConversion;
  29107. private _processIncludes;
  29108. private _processPrecision;
  29109. /**
  29110. * Recompiles the webGL program
  29111. * @param vertexSourceCode The source code for the vertex shader.
  29112. * @param fragmentSourceCode The source code for the fragment shader.
  29113. * @param onCompiled Callback called when completed.
  29114. * @param onError Callback called on error.
  29115. * @hidden
  29116. */
  29117. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29118. /**
  29119. * Gets the uniform locations of the the specified variable names
  29120. * @param names THe names of the variables to lookup.
  29121. * @returns Array of locations in the same order as variable names.
  29122. */
  29123. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29124. /**
  29125. * Prepares the effect
  29126. * @hidden
  29127. */
  29128. _prepareEffect(): void;
  29129. /**
  29130. * Checks if the effect is supported. (Must be called after compilation)
  29131. */
  29132. readonly isSupported: boolean;
  29133. /**
  29134. * Binds a texture to the engine to be used as output of the shader.
  29135. * @param channel Name of the output variable.
  29136. * @param texture Texture to bind.
  29137. * @hidden
  29138. */
  29139. _bindTexture(channel: string, texture: InternalTexture): void;
  29140. /**
  29141. * Sets a texture on the engine to be used in the shader.
  29142. * @param channel Name of the sampler variable.
  29143. * @param texture Texture to set.
  29144. */
  29145. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29146. /**
  29147. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29148. * @param channel Name of the sampler variable.
  29149. * @param texture Texture to set.
  29150. */
  29151. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29152. /**
  29153. * Sets an array of textures on the engine to be used in the shader.
  29154. * @param channel Name of the variable.
  29155. * @param textures Textures to set.
  29156. */
  29157. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29158. /**
  29159. * 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)
  29160. * @param channel Name of the sampler variable.
  29161. * @param postProcess Post process to get the input texture from.
  29162. */
  29163. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29164. /**
  29165. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29166. * 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)
  29167. * @param channel Name of the sampler variable.
  29168. * @param postProcess Post process to get the output texture from.
  29169. */
  29170. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29171. /** @hidden */
  29172. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29173. /** @hidden */
  29174. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29175. /** @hidden */
  29176. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29177. /** @hidden */
  29178. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29179. /**
  29180. * Binds a buffer to a uniform.
  29181. * @param buffer Buffer to bind.
  29182. * @param name Name of the uniform variable to bind to.
  29183. */
  29184. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29185. /**
  29186. * Binds block to a uniform.
  29187. * @param blockName Name of the block to bind.
  29188. * @param index Index to bind.
  29189. */
  29190. bindUniformBlock(blockName: string, index: number): void;
  29191. /**
  29192. * Sets an interger value on a uniform variable.
  29193. * @param uniformName Name of the variable.
  29194. * @param value Value to be set.
  29195. * @returns this effect.
  29196. */
  29197. setInt(uniformName: string, value: number): Effect;
  29198. /**
  29199. * Sets an int array on a uniform variable.
  29200. * @param uniformName Name of the variable.
  29201. * @param array array to be set.
  29202. * @returns this effect.
  29203. */
  29204. setIntArray(uniformName: string, array: Int32Array): Effect;
  29205. /**
  29206. * 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)
  29207. * @param uniformName Name of the variable.
  29208. * @param array array to be set.
  29209. * @returns this effect.
  29210. */
  29211. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29212. /**
  29213. * 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)
  29214. * @param uniformName Name of the variable.
  29215. * @param array array to be set.
  29216. * @returns this effect.
  29217. */
  29218. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29219. /**
  29220. * 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)
  29221. * @param uniformName Name of the variable.
  29222. * @param array array to be set.
  29223. * @returns this effect.
  29224. */
  29225. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29226. /**
  29227. * Sets an float array on a uniform variable.
  29228. * @param uniformName Name of the variable.
  29229. * @param array array to be set.
  29230. * @returns this effect.
  29231. */
  29232. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29233. /**
  29234. * 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)
  29235. * @param uniformName Name of the variable.
  29236. * @param array array to be set.
  29237. * @returns this effect.
  29238. */
  29239. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29240. /**
  29241. * 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)
  29242. * @param uniformName Name of the variable.
  29243. * @param array array to be set.
  29244. * @returns this effect.
  29245. */
  29246. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29247. /**
  29248. * 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)
  29249. * @param uniformName Name of the variable.
  29250. * @param array array to be set.
  29251. * @returns this effect.
  29252. */
  29253. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29254. /**
  29255. * Sets an array on a uniform variable.
  29256. * @param uniformName Name of the variable.
  29257. * @param array array to be set.
  29258. * @returns this effect.
  29259. */
  29260. setArray(uniformName: string, array: number[]): Effect;
  29261. /**
  29262. * 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)
  29263. * @param uniformName Name of the variable.
  29264. * @param array array to be set.
  29265. * @returns this effect.
  29266. */
  29267. setArray2(uniformName: string, array: number[]): Effect;
  29268. /**
  29269. * 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)
  29270. * @param uniformName Name of the variable.
  29271. * @param array array to be set.
  29272. * @returns this effect.
  29273. */
  29274. setArray3(uniformName: string, array: number[]): Effect;
  29275. /**
  29276. * 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)
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setArray4(uniformName: string, array: number[]): Effect;
  29282. /**
  29283. * Sets matrices on a uniform variable.
  29284. * @param uniformName Name of the variable.
  29285. * @param matrices matrices to be set.
  29286. * @returns this effect.
  29287. */
  29288. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29289. /**
  29290. * Sets matrix on a uniform variable.
  29291. * @param uniformName Name of the variable.
  29292. * @param matrix matrix to be set.
  29293. * @returns this effect.
  29294. */
  29295. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29296. /**
  29297. * 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)
  29298. * @param uniformName Name of the variable.
  29299. * @param matrix matrix to be set.
  29300. * @returns this effect.
  29301. */
  29302. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29303. /**
  29304. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29305. * @param uniformName Name of the variable.
  29306. * @param matrix matrix to be set.
  29307. * @returns this effect.
  29308. */
  29309. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29310. /**
  29311. * Sets a float on a uniform variable.
  29312. * @param uniformName Name of the variable.
  29313. * @param value value to be set.
  29314. * @returns this effect.
  29315. */
  29316. setFloat(uniformName: string, value: number): Effect;
  29317. /**
  29318. * Sets a boolean on a uniform variable.
  29319. * @param uniformName Name of the variable.
  29320. * @param bool value to be set.
  29321. * @returns this effect.
  29322. */
  29323. setBool(uniformName: string, bool: boolean): Effect;
  29324. /**
  29325. * Sets a Vector2 on a uniform variable.
  29326. * @param uniformName Name of the variable.
  29327. * @param vector2 vector2 to be set.
  29328. * @returns this effect.
  29329. */
  29330. setVector2(uniformName: string, vector2: Vector2): Effect;
  29331. /**
  29332. * Sets a float2 on a uniform variable.
  29333. * @param uniformName Name of the variable.
  29334. * @param x First float in float2.
  29335. * @param y Second float in float2.
  29336. * @returns this effect.
  29337. */
  29338. setFloat2(uniformName: string, x: number, y: number): Effect;
  29339. /**
  29340. * Sets a Vector3 on a uniform variable.
  29341. * @param uniformName Name of the variable.
  29342. * @param vector3 Value to be set.
  29343. * @returns this effect.
  29344. */
  29345. setVector3(uniformName: string, vector3: Vector3): Effect;
  29346. /**
  29347. * Sets a float3 on a uniform variable.
  29348. * @param uniformName Name of the variable.
  29349. * @param x First float in float3.
  29350. * @param y Second float in float3.
  29351. * @param z Third float in float3.
  29352. * @returns this effect.
  29353. */
  29354. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29355. /**
  29356. * Sets a Vector4 on a uniform variable.
  29357. * @param uniformName Name of the variable.
  29358. * @param vector4 Value to be set.
  29359. * @returns this effect.
  29360. */
  29361. setVector4(uniformName: string, vector4: Vector4): Effect;
  29362. /**
  29363. * Sets a float4 on a uniform variable.
  29364. * @param uniformName Name of the variable.
  29365. * @param x First float in float4.
  29366. * @param y Second float in float4.
  29367. * @param z Third float in float4.
  29368. * @param w Fourth float in float4.
  29369. * @returns this effect.
  29370. */
  29371. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29372. /**
  29373. * Sets a Color3 on a uniform variable.
  29374. * @param uniformName Name of the variable.
  29375. * @param color3 Value to be set.
  29376. * @returns this effect.
  29377. */
  29378. setColor3(uniformName: string, color3: Color3): Effect;
  29379. /**
  29380. * Sets a Color4 on a uniform variable.
  29381. * @param uniformName Name of the variable.
  29382. * @param color3 Value to be set.
  29383. * @param alpha Alpha value to be set.
  29384. * @returns this effect.
  29385. */
  29386. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29387. /**
  29388. * Sets a Color4 on a uniform variable
  29389. * @param uniformName defines the name of the variable
  29390. * @param color4 defines the value to be set
  29391. * @returns this effect.
  29392. */
  29393. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29394. /**
  29395. * This function will add a new shader to the shader store
  29396. * @param name the name of the shader
  29397. * @param pixelShader optional pixel shader content
  29398. * @param vertexShader optional vertex shader content
  29399. */
  29400. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29401. /**
  29402. * Store of each shader (The can be looked up using effect.key)
  29403. */
  29404. static ShadersStore: {
  29405. [key: string]: string;
  29406. };
  29407. /**
  29408. * Store of each included file for a shader (The can be looked up using effect.key)
  29409. */
  29410. static IncludesShadersStore: {
  29411. [key: string]: string;
  29412. };
  29413. /**
  29414. * Resets the cache of effects.
  29415. */
  29416. static ResetCache(): void;
  29417. }
  29418. }
  29419. declare module BABYLON {
  29420. /**
  29421. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29422. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29423. * 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;
  29424. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29425. */
  29426. export class ColorCurves {
  29427. private _dirty;
  29428. private _tempColor;
  29429. private _globalCurve;
  29430. private _highlightsCurve;
  29431. private _midtonesCurve;
  29432. private _shadowsCurve;
  29433. private _positiveCurve;
  29434. private _negativeCurve;
  29435. private _globalHue;
  29436. private _globalDensity;
  29437. private _globalSaturation;
  29438. private _globalExposure;
  29439. /**
  29440. * Gets the global Hue value.
  29441. * 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).
  29442. */
  29443. /**
  29444. * Sets the global Hue value.
  29445. * 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).
  29446. */
  29447. globalHue: number;
  29448. /**
  29449. * Gets the global Density value.
  29450. * 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.
  29451. * Values less than zero provide a filter of opposite hue.
  29452. */
  29453. /**
  29454. * Sets the global Density value.
  29455. * 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.
  29456. * Values less than zero provide a filter of opposite hue.
  29457. */
  29458. globalDensity: number;
  29459. /**
  29460. * Gets the global Saturation value.
  29461. * 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.
  29462. */
  29463. /**
  29464. * Sets the global Saturation value.
  29465. * 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.
  29466. */
  29467. globalSaturation: number;
  29468. /**
  29469. * Gets the global Exposure value.
  29470. * 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.
  29471. */
  29472. /**
  29473. * Sets the global Exposure value.
  29474. * 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.
  29475. */
  29476. globalExposure: number;
  29477. private _highlightsHue;
  29478. private _highlightsDensity;
  29479. private _highlightsSaturation;
  29480. private _highlightsExposure;
  29481. /**
  29482. * Gets the highlights Hue value.
  29483. * 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).
  29484. */
  29485. /**
  29486. * Sets the highlights Hue value.
  29487. * 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).
  29488. */
  29489. highlightsHue: number;
  29490. /**
  29491. * Gets the highlights Density value.
  29492. * 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.
  29493. * Values less than zero provide a filter of opposite hue.
  29494. */
  29495. /**
  29496. * Sets the highlights Density value.
  29497. * 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.
  29498. * Values less than zero provide a filter of opposite hue.
  29499. */
  29500. highlightsDensity: number;
  29501. /**
  29502. * Gets the highlights Saturation value.
  29503. * 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.
  29504. */
  29505. /**
  29506. * Sets the highlights Saturation value.
  29507. * 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.
  29508. */
  29509. highlightsSaturation: number;
  29510. /**
  29511. * Gets the highlights Exposure value.
  29512. * 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.
  29513. */
  29514. /**
  29515. * Sets the highlights Exposure value.
  29516. * 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.
  29517. */
  29518. highlightsExposure: number;
  29519. private _midtonesHue;
  29520. private _midtonesDensity;
  29521. private _midtonesSaturation;
  29522. private _midtonesExposure;
  29523. /**
  29524. * Gets the midtones Hue value.
  29525. * 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).
  29526. */
  29527. /**
  29528. * Sets the midtones Hue value.
  29529. * 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).
  29530. */
  29531. midtonesHue: number;
  29532. /**
  29533. * Gets the midtones Density value.
  29534. * 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.
  29535. * Values less than zero provide a filter of opposite hue.
  29536. */
  29537. /**
  29538. * Sets the midtones Density value.
  29539. * 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.
  29540. * Values less than zero provide a filter of opposite hue.
  29541. */
  29542. midtonesDensity: number;
  29543. /**
  29544. * Gets the midtones Saturation value.
  29545. * 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.
  29546. */
  29547. /**
  29548. * Sets the midtones Saturation value.
  29549. * 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.
  29550. */
  29551. midtonesSaturation: number;
  29552. /**
  29553. * Gets the midtones Exposure value.
  29554. * 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.
  29555. */
  29556. /**
  29557. * Sets the midtones Exposure value.
  29558. * 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.
  29559. */
  29560. midtonesExposure: number;
  29561. private _shadowsHue;
  29562. private _shadowsDensity;
  29563. private _shadowsSaturation;
  29564. private _shadowsExposure;
  29565. /**
  29566. * Gets the shadows Hue value.
  29567. * 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).
  29568. */
  29569. /**
  29570. * Sets the shadows Hue value.
  29571. * 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).
  29572. */
  29573. shadowsHue: number;
  29574. /**
  29575. * Gets the shadows Density value.
  29576. * 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.
  29577. * Values less than zero provide a filter of opposite hue.
  29578. */
  29579. /**
  29580. * Sets the shadows Density value.
  29581. * 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.
  29582. * Values less than zero provide a filter of opposite hue.
  29583. */
  29584. shadowsDensity: number;
  29585. /**
  29586. * Gets the shadows Saturation value.
  29587. * 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.
  29588. */
  29589. /**
  29590. * Sets the shadows Saturation value.
  29591. * 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.
  29592. */
  29593. shadowsSaturation: number;
  29594. /**
  29595. * Gets the shadows Exposure value.
  29596. * 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.
  29597. */
  29598. /**
  29599. * Sets the shadows Exposure value.
  29600. * 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.
  29601. */
  29602. shadowsExposure: number;
  29603. /**
  29604. * Returns the class name
  29605. * @returns The class name
  29606. */
  29607. getClassName(): string;
  29608. /**
  29609. * Binds the color curves to the shader.
  29610. * @param colorCurves The color curve to bind
  29611. * @param effect The effect to bind to
  29612. * @param positiveUniform The positive uniform shader parameter
  29613. * @param neutralUniform The neutral uniform shader parameter
  29614. * @param negativeUniform The negative uniform shader parameter
  29615. */
  29616. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29617. /**
  29618. * Prepare the list of uniforms associated with the ColorCurves effects.
  29619. * @param uniformsList The list of uniforms used in the effect
  29620. */
  29621. static PrepareUniforms(uniformsList: string[]): void;
  29622. /**
  29623. * Returns color grading data based on a hue, density, saturation and exposure value.
  29624. * @param filterHue The hue of the color filter.
  29625. * @param filterDensity The density of the color filter.
  29626. * @param saturation The saturation.
  29627. * @param exposure The exposure.
  29628. * @param result The result data container.
  29629. */
  29630. private getColorGradingDataToRef;
  29631. /**
  29632. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29633. * @param value The input slider value in range [-100,100].
  29634. * @returns Adjusted value.
  29635. */
  29636. private static applyColorGradingSliderNonlinear;
  29637. /**
  29638. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29639. * @param hue The hue (H) input.
  29640. * @param saturation The saturation (S) input.
  29641. * @param brightness The brightness (B) input.
  29642. * @result An RGBA color represented as Vector4.
  29643. */
  29644. private static fromHSBToRef;
  29645. /**
  29646. * Returns a value clamped between min and max
  29647. * @param value The value to clamp
  29648. * @param min The minimum of value
  29649. * @param max The maximum of value
  29650. * @returns The clamped value.
  29651. */
  29652. private static clamp;
  29653. /**
  29654. * Clones the current color curve instance.
  29655. * @return The cloned curves
  29656. */
  29657. clone(): ColorCurves;
  29658. /**
  29659. * Serializes the current color curve instance to a json representation.
  29660. * @return a JSON representation
  29661. */
  29662. serialize(): any;
  29663. /**
  29664. * Parses the color curve from a json representation.
  29665. * @param source the JSON source to parse
  29666. * @return The parsed curves
  29667. */
  29668. static Parse(source: any): ColorCurves;
  29669. }
  29670. }
  29671. declare module BABYLON {
  29672. /**
  29673. * Interface to follow in your material defines to integrate easily the
  29674. * Image proccessing functions.
  29675. * @hidden
  29676. */
  29677. export interface IImageProcessingConfigurationDefines {
  29678. IMAGEPROCESSING: boolean;
  29679. VIGNETTE: boolean;
  29680. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29681. VIGNETTEBLENDMODEOPAQUE: boolean;
  29682. TONEMAPPING: boolean;
  29683. TONEMAPPING_ACES: boolean;
  29684. CONTRAST: boolean;
  29685. EXPOSURE: boolean;
  29686. COLORCURVES: boolean;
  29687. COLORGRADING: boolean;
  29688. COLORGRADING3D: boolean;
  29689. SAMPLER3DGREENDEPTH: boolean;
  29690. SAMPLER3DBGRMAP: boolean;
  29691. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29692. }
  29693. /**
  29694. * @hidden
  29695. */
  29696. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29697. IMAGEPROCESSING: boolean;
  29698. VIGNETTE: boolean;
  29699. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29700. VIGNETTEBLENDMODEOPAQUE: boolean;
  29701. TONEMAPPING: boolean;
  29702. TONEMAPPING_ACES: boolean;
  29703. CONTRAST: boolean;
  29704. COLORCURVES: boolean;
  29705. COLORGRADING: boolean;
  29706. COLORGRADING3D: boolean;
  29707. SAMPLER3DGREENDEPTH: boolean;
  29708. SAMPLER3DBGRMAP: boolean;
  29709. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29710. EXPOSURE: boolean;
  29711. constructor();
  29712. }
  29713. /**
  29714. * This groups together the common properties used for image processing either in direct forward pass
  29715. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29716. * or not.
  29717. */
  29718. export class ImageProcessingConfiguration {
  29719. /**
  29720. * Default tone mapping applied in BabylonJS.
  29721. */
  29722. static readonly TONEMAPPING_STANDARD: number;
  29723. /**
  29724. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29725. * to other engines rendering to increase portability.
  29726. */
  29727. static readonly TONEMAPPING_ACES: number;
  29728. /**
  29729. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29730. */
  29731. colorCurves: Nullable<ColorCurves>;
  29732. private _colorCurvesEnabled;
  29733. /**
  29734. * Gets wether the color curves effect is enabled.
  29735. */
  29736. /**
  29737. * Sets wether the color curves effect is enabled.
  29738. */
  29739. colorCurvesEnabled: boolean;
  29740. private _colorGradingTexture;
  29741. /**
  29742. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29743. */
  29744. /**
  29745. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29746. */
  29747. colorGradingTexture: Nullable<BaseTexture>;
  29748. private _colorGradingEnabled;
  29749. /**
  29750. * Gets wether the color grading effect is enabled.
  29751. */
  29752. /**
  29753. * Sets wether the color grading effect is enabled.
  29754. */
  29755. colorGradingEnabled: boolean;
  29756. private _colorGradingWithGreenDepth;
  29757. /**
  29758. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29759. */
  29760. /**
  29761. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29762. */
  29763. colorGradingWithGreenDepth: boolean;
  29764. private _colorGradingBGR;
  29765. /**
  29766. * Gets wether the color grading texture contains BGR values.
  29767. */
  29768. /**
  29769. * Sets wether the color grading texture contains BGR values.
  29770. */
  29771. colorGradingBGR: boolean;
  29772. /** @hidden */
  29773. _exposure: number;
  29774. /**
  29775. * Gets the Exposure used in the effect.
  29776. */
  29777. /**
  29778. * Sets the Exposure used in the effect.
  29779. */
  29780. exposure: number;
  29781. private _toneMappingEnabled;
  29782. /**
  29783. * Gets wether the tone mapping effect is enabled.
  29784. */
  29785. /**
  29786. * Sets wether the tone mapping effect is enabled.
  29787. */
  29788. toneMappingEnabled: boolean;
  29789. private _toneMappingType;
  29790. /**
  29791. * Gets the type of tone mapping effect.
  29792. */
  29793. /**
  29794. * Sets the type of tone mapping effect used in BabylonJS.
  29795. */
  29796. toneMappingType: number;
  29797. protected _contrast: number;
  29798. /**
  29799. * Gets the contrast used in the effect.
  29800. */
  29801. /**
  29802. * Sets the contrast used in the effect.
  29803. */
  29804. contrast: number;
  29805. /**
  29806. * Vignette stretch size.
  29807. */
  29808. vignetteStretch: number;
  29809. /**
  29810. * Vignette centre X Offset.
  29811. */
  29812. vignetteCentreX: number;
  29813. /**
  29814. * Vignette centre Y Offset.
  29815. */
  29816. vignetteCentreY: number;
  29817. /**
  29818. * Vignette weight or intensity of the vignette effect.
  29819. */
  29820. vignetteWeight: number;
  29821. /**
  29822. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29823. * if vignetteEnabled is set to true.
  29824. */
  29825. vignetteColor: Color4;
  29826. /**
  29827. * Camera field of view used by the Vignette effect.
  29828. */
  29829. vignetteCameraFov: number;
  29830. private _vignetteBlendMode;
  29831. /**
  29832. * Gets the vignette blend mode allowing different kind of effect.
  29833. */
  29834. /**
  29835. * Sets the vignette blend mode allowing different kind of effect.
  29836. */
  29837. vignetteBlendMode: number;
  29838. private _vignetteEnabled;
  29839. /**
  29840. * Gets wether the vignette effect is enabled.
  29841. */
  29842. /**
  29843. * Sets wether the vignette effect is enabled.
  29844. */
  29845. vignetteEnabled: boolean;
  29846. private _applyByPostProcess;
  29847. /**
  29848. * Gets wether the image processing is applied through a post process or not.
  29849. */
  29850. /**
  29851. * Sets wether the image processing is applied through a post process or not.
  29852. */
  29853. applyByPostProcess: boolean;
  29854. private _isEnabled;
  29855. /**
  29856. * Gets wether the image processing is enabled or not.
  29857. */
  29858. /**
  29859. * Sets wether the image processing is enabled or not.
  29860. */
  29861. isEnabled: boolean;
  29862. /**
  29863. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29864. */
  29865. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29866. /**
  29867. * Method called each time the image processing information changes requires to recompile the effect.
  29868. */
  29869. protected _updateParameters(): void;
  29870. /**
  29871. * Gets the current class name.
  29872. * @return "ImageProcessingConfiguration"
  29873. */
  29874. getClassName(): string;
  29875. /**
  29876. * Prepare the list of uniforms associated with the Image Processing effects.
  29877. * @param uniforms The list of uniforms used in the effect
  29878. * @param defines the list of defines currently in use
  29879. */
  29880. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29881. /**
  29882. * Prepare the list of samplers associated with the Image Processing effects.
  29883. * @param samplersList The list of uniforms used in the effect
  29884. * @param defines the list of defines currently in use
  29885. */
  29886. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29887. /**
  29888. * Prepare the list of defines associated to the shader.
  29889. * @param defines the list of defines to complete
  29890. * @param forPostProcess Define if we are currently in post process mode or not
  29891. */
  29892. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29893. /**
  29894. * Returns true if all the image processing information are ready.
  29895. * @returns True if ready, otherwise, false
  29896. */
  29897. isReady(): boolean;
  29898. /**
  29899. * Binds the image processing to the shader.
  29900. * @param effect The effect to bind to
  29901. * @param aspectRatio Define the current aspect ratio of the effect
  29902. */
  29903. bind(effect: Effect, aspectRatio?: number): void;
  29904. /**
  29905. * Clones the current image processing instance.
  29906. * @return The cloned image processing
  29907. */
  29908. clone(): ImageProcessingConfiguration;
  29909. /**
  29910. * Serializes the current image processing instance to a json representation.
  29911. * @return a JSON representation
  29912. */
  29913. serialize(): any;
  29914. /**
  29915. * Parses the image processing from a json representation.
  29916. * @param source the JSON source to parse
  29917. * @return The parsed image processing
  29918. */
  29919. static Parse(source: any): ImageProcessingConfiguration;
  29920. private static _VIGNETTEMODE_MULTIPLY;
  29921. private static _VIGNETTEMODE_OPAQUE;
  29922. /**
  29923. * Used to apply the vignette as a mix with the pixel color.
  29924. */
  29925. static readonly VIGNETTEMODE_MULTIPLY: number;
  29926. /**
  29927. * Used to apply the vignette as a replacement of the pixel color.
  29928. */
  29929. static readonly VIGNETTEMODE_OPAQUE: number;
  29930. }
  29931. }
  29932. declare module BABYLON {
  29933. /**
  29934. * This represents all the required information to add a fresnel effect on a material:
  29935. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29936. */
  29937. export class FresnelParameters {
  29938. private _isEnabled;
  29939. /**
  29940. * Define if the fresnel effect is enable or not.
  29941. */
  29942. isEnabled: boolean;
  29943. /**
  29944. * Define the color used on edges (grazing angle)
  29945. */
  29946. leftColor: Color3;
  29947. /**
  29948. * Define the color used on center
  29949. */
  29950. rightColor: Color3;
  29951. /**
  29952. * Define bias applied to computed fresnel term
  29953. */
  29954. bias: number;
  29955. /**
  29956. * Defined the power exponent applied to fresnel term
  29957. */
  29958. power: number;
  29959. /**
  29960. * Clones the current fresnel and its valuues
  29961. * @returns a clone fresnel configuration
  29962. */
  29963. clone(): FresnelParameters;
  29964. /**
  29965. * Serializes the current fresnel parameters to a JSON representation.
  29966. * @return the JSON serialization
  29967. */
  29968. serialize(): any;
  29969. /**
  29970. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29971. * @param parsedFresnelParameters Define the JSON representation
  29972. * @returns the parsed parameters
  29973. */
  29974. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29975. }
  29976. }
  29977. declare module BABYLON {
  29978. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29979. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29980. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29981. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29982. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29983. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29984. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29985. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29986. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29987. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29988. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29989. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29990. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29991. /**
  29992. * Decorator used to define property that can be serialized as reference to a camera
  29993. * @param sourceName defines the name of the property to decorate
  29994. */
  29995. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29996. /**
  29997. * Class used to help serialization objects
  29998. */
  29999. export class SerializationHelper {
  30000. /** hidden */
  30001. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30002. /** hidden */
  30003. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30004. /** hidden */
  30005. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30006. /** hidden */
  30007. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30008. /**
  30009. * Appends the serialized animations from the source animations
  30010. * @param source Source containing the animations
  30011. * @param destination Target to store the animations
  30012. */
  30013. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30014. /**
  30015. * Static function used to serialized a specific entity
  30016. * @param entity defines the entity to serialize
  30017. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30018. * @returns a JSON compatible object representing the serialization of the entity
  30019. */
  30020. static Serialize<T>(entity: T, serializationObject?: any): any;
  30021. /**
  30022. * Creates a new entity from a serialization data object
  30023. * @param creationFunction defines a function used to instanciated the new entity
  30024. * @param source defines the source serialization data
  30025. * @param scene defines the hosting scene
  30026. * @param rootUrl defines the root url for resources
  30027. * @returns a new entity
  30028. */
  30029. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30030. /**
  30031. * Clones an object
  30032. * @param creationFunction defines the function used to instanciate the new object
  30033. * @param source defines the source object
  30034. * @returns the cloned object
  30035. */
  30036. static Clone<T>(creationFunction: () => T, source: T): T;
  30037. /**
  30038. * Instanciates a new object based on a source one (some data will be shared between both object)
  30039. * @param creationFunction defines the function used to instanciate the new object
  30040. * @param source defines the source object
  30041. * @returns the new object
  30042. */
  30043. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30044. }
  30045. }
  30046. declare module BABYLON {
  30047. /**
  30048. * This is the base class of all the camera used in the application.
  30049. * @see http://doc.babylonjs.com/features/cameras
  30050. */
  30051. export class Camera extends Node {
  30052. /** @hidden */
  30053. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30054. /**
  30055. * This is the default projection mode used by the cameras.
  30056. * It helps recreating a feeling of perspective and better appreciate depth.
  30057. * This is the best way to simulate real life cameras.
  30058. */
  30059. static readonly PERSPECTIVE_CAMERA: number;
  30060. /**
  30061. * This helps creating camera with an orthographic mode.
  30062. * 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.
  30063. */
  30064. static readonly ORTHOGRAPHIC_CAMERA: number;
  30065. /**
  30066. * This is the default FOV mode for perspective cameras.
  30067. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30068. */
  30069. static readonly FOVMODE_VERTICAL_FIXED: number;
  30070. /**
  30071. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30072. */
  30073. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30074. /**
  30075. * This specifies ther is no need for a camera rig.
  30076. * Basically only one eye is rendered corresponding to the camera.
  30077. */
  30078. static readonly RIG_MODE_NONE: number;
  30079. /**
  30080. * Simulates a camera Rig with one blue eye and one red eye.
  30081. * This can be use with 3d blue and red glasses.
  30082. */
  30083. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30084. /**
  30085. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30086. */
  30087. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30088. /**
  30089. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30090. */
  30091. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30092. /**
  30093. * Defines that both eyes of the camera will be rendered over under each other.
  30094. */
  30095. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30096. /**
  30097. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30098. */
  30099. static readonly RIG_MODE_VR: number;
  30100. /**
  30101. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30102. */
  30103. static readonly RIG_MODE_WEBVR: number;
  30104. /**
  30105. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30106. */
  30107. static readonly RIG_MODE_CUSTOM: number;
  30108. /**
  30109. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30110. */
  30111. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30112. /**
  30113. * Define the input manager associated with the camera.
  30114. */
  30115. inputs: CameraInputsManager<Camera>;
  30116. /** @hidden */
  30117. _position: Vector3;
  30118. /**
  30119. * Define the current local position of the camera in the scene
  30120. */
  30121. position: Vector3;
  30122. /**
  30123. * The vector the camera should consider as up.
  30124. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30125. */
  30126. upVector: Vector3;
  30127. /**
  30128. * Define the current limit on the left side for an orthographic camera
  30129. * In scene unit
  30130. */
  30131. orthoLeft: Nullable<number>;
  30132. /**
  30133. * Define the current limit on the right side for an orthographic camera
  30134. * In scene unit
  30135. */
  30136. orthoRight: Nullable<number>;
  30137. /**
  30138. * Define the current limit on the bottom side for an orthographic camera
  30139. * In scene unit
  30140. */
  30141. orthoBottom: Nullable<number>;
  30142. /**
  30143. * Define the current limit on the top side for an orthographic camera
  30144. * In scene unit
  30145. */
  30146. orthoTop: Nullable<number>;
  30147. /**
  30148. * Field Of View is set in Radians. (default is 0.8)
  30149. */
  30150. fov: number;
  30151. /**
  30152. * Define the minimum distance the camera can see from.
  30153. * This is important to note that the depth buffer are not infinite and the closer it starts
  30154. * the more your scene might encounter depth fighting issue.
  30155. */
  30156. minZ: number;
  30157. /**
  30158. * Define the maximum distance the camera can see to.
  30159. * This is important to note that the depth buffer are not infinite and the further it end
  30160. * the more your scene might encounter depth fighting issue.
  30161. */
  30162. maxZ: number;
  30163. /**
  30164. * Define the default inertia of the camera.
  30165. * This helps giving a smooth feeling to the camera movement.
  30166. */
  30167. inertia: number;
  30168. /**
  30169. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30170. */
  30171. mode: number;
  30172. /**
  30173. * Define wether the camera is intermediate.
  30174. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30175. */
  30176. isIntermediate: boolean;
  30177. /**
  30178. * Define the viewport of the camera.
  30179. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30180. */
  30181. viewport: Viewport;
  30182. /**
  30183. * Restricts the camera to viewing objects with the same layerMask.
  30184. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30185. */
  30186. layerMask: number;
  30187. /**
  30188. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30189. */
  30190. fovMode: number;
  30191. /**
  30192. * Rig mode of the camera.
  30193. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30194. * This is normally controlled byt the camera themselves as internal use.
  30195. */
  30196. cameraRigMode: number;
  30197. /**
  30198. * Defines the distance between both "eyes" in case of a RIG
  30199. */
  30200. interaxialDistance: number;
  30201. /**
  30202. * Defines if stereoscopic rendering is done side by side or over under.
  30203. */
  30204. isStereoscopicSideBySide: boolean;
  30205. /**
  30206. * 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
  30207. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30208. * else in the scene.
  30209. */
  30210. customRenderTargets: RenderTargetTexture[];
  30211. /**
  30212. * When set, the camera will render to this render target instead of the default canvas
  30213. */
  30214. outputRenderTarget: Nullable<RenderTargetTexture>;
  30215. /**
  30216. * Observable triggered when the camera view matrix has changed.
  30217. */
  30218. onViewMatrixChangedObservable: Observable<Camera>;
  30219. /**
  30220. * Observable triggered when the camera Projection matrix has changed.
  30221. */
  30222. onProjectionMatrixChangedObservable: Observable<Camera>;
  30223. /**
  30224. * Observable triggered when the inputs have been processed.
  30225. */
  30226. onAfterCheckInputsObservable: Observable<Camera>;
  30227. /**
  30228. * Observable triggered when reset has been called and applied to the camera.
  30229. */
  30230. onRestoreStateObservable: Observable<Camera>;
  30231. /** @hidden */
  30232. _cameraRigParams: any;
  30233. /** @hidden */
  30234. _rigCameras: Camera[];
  30235. /** @hidden */
  30236. _rigPostProcess: Nullable<PostProcess>;
  30237. protected _webvrViewMatrix: Matrix;
  30238. /** @hidden */
  30239. _skipRendering: boolean;
  30240. /** @hidden */
  30241. _projectionMatrix: Matrix;
  30242. /** @hidden */
  30243. _postProcesses: Nullable<PostProcess>[];
  30244. /** @hidden */
  30245. _activeMeshes: SmartArray<AbstractMesh>;
  30246. protected _globalPosition: Vector3;
  30247. /** hidden */
  30248. _computedViewMatrix: Matrix;
  30249. private _doNotComputeProjectionMatrix;
  30250. private _transformMatrix;
  30251. private _frustumPlanes;
  30252. private _refreshFrustumPlanes;
  30253. private _storedFov;
  30254. private _stateStored;
  30255. /**
  30256. * Instantiates a new camera object.
  30257. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30258. * @see http://doc.babylonjs.com/features/cameras
  30259. * @param name Defines the name of the camera in the scene
  30260. * @param position Defines the position of the camera
  30261. * @param scene Defines the scene the camera belongs too
  30262. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30263. */
  30264. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30265. /**
  30266. * Store current camera state (fov, position, etc..)
  30267. * @returns the camera
  30268. */
  30269. storeState(): Camera;
  30270. /**
  30271. * Restores the camera state values if it has been stored. You must call storeState() first
  30272. */
  30273. protected _restoreStateValues(): boolean;
  30274. /**
  30275. * Restored camera state. You must call storeState() first.
  30276. * @returns true if restored and false otherwise
  30277. */
  30278. restoreState(): boolean;
  30279. /**
  30280. * Gets the class name of the camera.
  30281. * @returns the class name
  30282. */
  30283. getClassName(): string;
  30284. /** @hidden */
  30285. readonly _isCamera: boolean;
  30286. /**
  30287. * Gets a string representation of the camera useful for debug purpose.
  30288. * @param fullDetails Defines that a more verboe level of logging is required
  30289. * @returns the string representation
  30290. */
  30291. toString(fullDetails?: boolean): string;
  30292. /**
  30293. * Gets the current world space position of the camera.
  30294. */
  30295. readonly globalPosition: Vector3;
  30296. /**
  30297. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30298. * @returns the active meshe list
  30299. */
  30300. getActiveMeshes(): SmartArray<AbstractMesh>;
  30301. /**
  30302. * Check wether a mesh is part of the current active mesh list of the camera
  30303. * @param mesh Defines the mesh to check
  30304. * @returns true if active, false otherwise
  30305. */
  30306. isActiveMesh(mesh: Mesh): boolean;
  30307. /**
  30308. * Is this camera ready to be used/rendered
  30309. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30310. * @return true if the camera is ready
  30311. */
  30312. isReady(completeCheck?: boolean): boolean;
  30313. /** @hidden */
  30314. _initCache(): void;
  30315. /** @hidden */
  30316. _updateCache(ignoreParentClass?: boolean): void;
  30317. /** @hidden */
  30318. _isSynchronized(): boolean;
  30319. /** @hidden */
  30320. _isSynchronizedViewMatrix(): boolean;
  30321. /** @hidden */
  30322. _isSynchronizedProjectionMatrix(): boolean;
  30323. /**
  30324. * Attach the input controls to a specific dom element to get the input from.
  30325. * @param element Defines the element the controls should be listened from
  30326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30327. */
  30328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30329. /**
  30330. * Detach the current controls from the specified dom element.
  30331. * @param element Defines the element to stop listening the inputs from
  30332. */
  30333. detachControl(element: HTMLElement): void;
  30334. /**
  30335. * Update the camera state according to the different inputs gathered during the frame.
  30336. */
  30337. update(): void;
  30338. /** @hidden */
  30339. _checkInputs(): void;
  30340. /** @hidden */
  30341. readonly rigCameras: Camera[];
  30342. /**
  30343. * Gets the post process used by the rig cameras
  30344. */
  30345. readonly rigPostProcess: Nullable<PostProcess>;
  30346. /**
  30347. * Internal, gets the first post proces.
  30348. * @returns the first post process to be run on this camera.
  30349. */
  30350. _getFirstPostProcess(): Nullable<PostProcess>;
  30351. private _cascadePostProcessesToRigCams;
  30352. /**
  30353. * Attach a post process to the camera.
  30354. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30355. * @param postProcess The post process to attach to the camera
  30356. * @param insertAt The position of the post process in case several of them are in use in the scene
  30357. * @returns the position the post process has been inserted at
  30358. */
  30359. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30360. /**
  30361. * Detach a post process to the camera.
  30362. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30363. * @param postProcess The post process to detach from the camera
  30364. */
  30365. detachPostProcess(postProcess: PostProcess): void;
  30366. /**
  30367. * Gets the current world matrix of the camera
  30368. */
  30369. getWorldMatrix(): Matrix;
  30370. /** @hidden */
  30371. _getViewMatrix(): Matrix;
  30372. /**
  30373. * Gets the current view matrix of the camera.
  30374. * @param force forces the camera to recompute the matrix without looking at the cached state
  30375. * @returns the view matrix
  30376. */
  30377. getViewMatrix(force?: boolean): Matrix;
  30378. /**
  30379. * Freeze the projection matrix.
  30380. * It will prevent the cache check of the camera projection compute and can speed up perf
  30381. * if no parameter of the camera are meant to change
  30382. * @param projection Defines manually a projection if necessary
  30383. */
  30384. freezeProjectionMatrix(projection?: Matrix): void;
  30385. /**
  30386. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30387. */
  30388. unfreezeProjectionMatrix(): void;
  30389. /**
  30390. * Gets the current projection matrix of the camera.
  30391. * @param force forces the camera to recompute the matrix without looking at the cached state
  30392. * @returns the projection matrix
  30393. */
  30394. getProjectionMatrix(force?: boolean): Matrix;
  30395. /**
  30396. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30397. * @returns a Matrix
  30398. */
  30399. getTransformationMatrix(): Matrix;
  30400. private _updateFrustumPlanes;
  30401. /**
  30402. * Checks if a cullable object (mesh...) is in the camera frustum
  30403. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30404. * @param target The object to check
  30405. * @returns true if the object is in frustum otherwise false
  30406. */
  30407. isInFrustum(target: ICullable): boolean;
  30408. /**
  30409. * Checks if a cullable object (mesh...) is in the camera frustum
  30410. * Unlike isInFrustum this cheks the full bounding box
  30411. * @param target The object to check
  30412. * @returns true if the object is in frustum otherwise false
  30413. */
  30414. isCompletelyInFrustum(target: ICullable): boolean;
  30415. /**
  30416. * Gets a ray in the forward direction from the camera.
  30417. * @param length Defines the length of the ray to create
  30418. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30419. * @param origin Defines the start point of the ray which defaults to the camera position
  30420. * @returns the forward ray
  30421. */
  30422. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30423. /**
  30424. * Releases resources associated with this node.
  30425. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30426. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30427. */
  30428. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30429. /** @hidden */
  30430. _isLeftCamera: boolean;
  30431. /**
  30432. * Gets the left camera of a rig setup in case of Rigged Camera
  30433. */
  30434. readonly isLeftCamera: boolean;
  30435. /** @hidden */
  30436. _isRightCamera: boolean;
  30437. /**
  30438. * Gets the right camera of a rig setup in case of Rigged Camera
  30439. */
  30440. readonly isRightCamera: boolean;
  30441. /**
  30442. * Gets the left camera of a rig setup in case of Rigged Camera
  30443. */
  30444. readonly leftCamera: Nullable<FreeCamera>;
  30445. /**
  30446. * Gets the right camera of a rig setup in case of Rigged Camera
  30447. */
  30448. readonly rightCamera: Nullable<FreeCamera>;
  30449. /**
  30450. * Gets the left camera target of a rig setup in case of Rigged Camera
  30451. * @returns the target position
  30452. */
  30453. getLeftTarget(): Nullable<Vector3>;
  30454. /**
  30455. * Gets the right camera target of a rig setup in case of Rigged Camera
  30456. * @returns the target position
  30457. */
  30458. getRightTarget(): Nullable<Vector3>;
  30459. /**
  30460. * @hidden
  30461. */
  30462. setCameraRigMode(mode: number, rigParams: any): void;
  30463. /** @hidden */
  30464. static _setStereoscopicRigMode(camera: Camera): void;
  30465. /** @hidden */
  30466. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30467. /** @hidden */
  30468. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30469. /** @hidden */
  30470. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30471. /** @hidden */
  30472. _getVRProjectionMatrix(): Matrix;
  30473. protected _updateCameraRotationMatrix(): void;
  30474. protected _updateWebVRCameraRotationMatrix(): void;
  30475. /**
  30476. * This function MUST be overwritten by the different WebVR cameras available.
  30477. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30478. * @hidden
  30479. */
  30480. _getWebVRProjectionMatrix(): Matrix;
  30481. /**
  30482. * This function MUST be overwritten by the different WebVR cameras available.
  30483. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30484. * @hidden
  30485. */
  30486. _getWebVRViewMatrix(): Matrix;
  30487. /** @hidden */
  30488. setCameraRigParameter(name: string, value: any): void;
  30489. /**
  30490. * needs to be overridden by children so sub has required properties to be copied
  30491. * @hidden
  30492. */
  30493. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30494. /**
  30495. * May need to be overridden by children
  30496. * @hidden
  30497. */
  30498. _updateRigCameras(): void;
  30499. /** @hidden */
  30500. _setupInputs(): void;
  30501. /**
  30502. * Serialiaze the camera setup to a json represention
  30503. * @returns the JSON representation
  30504. */
  30505. serialize(): any;
  30506. /**
  30507. * Clones the current camera.
  30508. * @param name The cloned camera name
  30509. * @returns the cloned camera
  30510. */
  30511. clone(name: string): Camera;
  30512. /**
  30513. * Gets the direction of the camera relative to a given local axis.
  30514. * @param localAxis Defines the reference axis to provide a relative direction.
  30515. * @return the direction
  30516. */
  30517. getDirection(localAxis: Vector3): Vector3;
  30518. /**
  30519. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30520. * @param localAxis Defines the reference axis to provide a relative direction.
  30521. * @param result Defines the vector to store the result in
  30522. */
  30523. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30524. /**
  30525. * Gets a camera constructor for a given camera type
  30526. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30527. * @param name The name of the camera the result will be able to instantiate
  30528. * @param scene The scene the result will construct the camera in
  30529. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30530. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30531. * @returns a factory method to construc the camera
  30532. */
  30533. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30534. /**
  30535. * Compute the world matrix of the camera.
  30536. * @returns the camera workd matrix
  30537. */
  30538. computeWorldMatrix(): Matrix;
  30539. /**
  30540. * Parse a JSON and creates the camera from the parsed information
  30541. * @param parsedCamera The JSON to parse
  30542. * @param scene The scene to instantiate the camera in
  30543. * @returns the newly constructed camera
  30544. */
  30545. static Parse(parsedCamera: any, scene: Scene): Camera;
  30546. }
  30547. }
  30548. declare module BABYLON {
  30549. /**
  30550. * Interface for any object that can request an animation frame
  30551. */
  30552. export interface ICustomAnimationFrameRequester {
  30553. /**
  30554. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30555. */
  30556. renderFunction?: Function;
  30557. /**
  30558. * Called to request the next frame to render to
  30559. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30560. */
  30561. requestAnimationFrame: Function;
  30562. /**
  30563. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30564. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30565. */
  30566. requestID?: number;
  30567. }
  30568. /**
  30569. * Interface containing an array of animations
  30570. */
  30571. export interface IAnimatable {
  30572. /**
  30573. * Array of animations
  30574. */
  30575. animations: Array<Animation>;
  30576. }
  30577. /** Interface used by value gradients (color, factor, ...) */
  30578. export interface IValueGradient {
  30579. /**
  30580. * Gets or sets the gradient value (between 0 and 1)
  30581. */
  30582. gradient: number;
  30583. }
  30584. /** Class used to store color4 gradient */
  30585. export class ColorGradient implements IValueGradient {
  30586. /**
  30587. * Gets or sets the gradient value (between 0 and 1)
  30588. */
  30589. gradient: number;
  30590. /**
  30591. * Gets or sets first associated color
  30592. */
  30593. color1: Color4;
  30594. /**
  30595. * Gets or sets second associated color
  30596. */
  30597. color2?: Color4;
  30598. /**
  30599. * Will get a color picked randomly between color1 and color2.
  30600. * If color2 is undefined then color1 will be used
  30601. * @param result defines the target Color4 to store the result in
  30602. */
  30603. getColorToRef(result: Color4): void;
  30604. }
  30605. /** Class used to store color 3 gradient */
  30606. export class Color3Gradient implements IValueGradient {
  30607. /**
  30608. * Gets or sets the gradient value (between 0 and 1)
  30609. */
  30610. gradient: number;
  30611. /**
  30612. * Gets or sets the associated color
  30613. */
  30614. color: Color3;
  30615. }
  30616. /** Class used to store factor gradient */
  30617. export class FactorGradient implements IValueGradient {
  30618. /**
  30619. * Gets or sets the gradient value (between 0 and 1)
  30620. */
  30621. gradient: number;
  30622. /**
  30623. * Gets or sets first associated factor
  30624. */
  30625. factor1: number;
  30626. /**
  30627. * Gets or sets second associated factor
  30628. */
  30629. factor2?: number;
  30630. /**
  30631. * Will get a number picked randomly between factor1 and factor2.
  30632. * If factor2 is undefined then factor1 will be used
  30633. * @returns the picked number
  30634. */
  30635. getFactor(): number;
  30636. }
  30637. /**
  30638. * @ignore
  30639. * Application error to support additional information when loading a file
  30640. */
  30641. export class LoadFileError extends Error {
  30642. /** defines the optional web request */
  30643. request?: WebRequest | undefined;
  30644. private static _setPrototypeOf;
  30645. /**
  30646. * Creates a new LoadFileError
  30647. * @param message defines the message of the error
  30648. * @param request defines the optional web request
  30649. */
  30650. constructor(message: string,
  30651. /** defines the optional web request */
  30652. request?: WebRequest | undefined);
  30653. }
  30654. /**
  30655. * Class used to define a retry strategy when error happens while loading assets
  30656. */
  30657. export class RetryStrategy {
  30658. /**
  30659. * Function used to defines an exponential back off strategy
  30660. * @param maxRetries defines the maximum number of retries (3 by default)
  30661. * @param baseInterval defines the interval between retries
  30662. * @returns the strategy function to use
  30663. */
  30664. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30665. }
  30666. /**
  30667. * File request interface
  30668. */
  30669. export interface IFileRequest {
  30670. /**
  30671. * Raised when the request is complete (success or error).
  30672. */
  30673. onCompleteObservable: Observable<IFileRequest>;
  30674. /**
  30675. * Aborts the request for a file.
  30676. */
  30677. abort: () => void;
  30678. }
  30679. /**
  30680. * Class containing a set of static utilities functions
  30681. */
  30682. export class Tools {
  30683. /**
  30684. * Gets or sets the base URL to use to load assets
  30685. */
  30686. static BaseUrl: string;
  30687. /**
  30688. * Enable/Disable Custom HTTP Request Headers globally.
  30689. * default = false
  30690. * @see CustomRequestHeaders
  30691. */
  30692. static UseCustomRequestHeaders: boolean;
  30693. /**
  30694. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30695. * i.e. when loading files, where the server/service expects an Authorization header
  30696. */
  30697. static CustomRequestHeaders: {
  30698. [key: string]: string;
  30699. };
  30700. /**
  30701. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30702. */
  30703. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30704. /**
  30705. * Default behaviour for cors in the application.
  30706. * It can be a string if the expected behavior is identical in the entire app.
  30707. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30708. */
  30709. static CorsBehavior: string | ((url: string | string[]) => string);
  30710. /**
  30711. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30712. * @ignorenaming
  30713. */
  30714. static UseFallbackTexture: boolean;
  30715. /**
  30716. * Use this object to register external classes like custom textures or material
  30717. * to allow the laoders to instantiate them
  30718. */
  30719. static RegisteredExternalClasses: {
  30720. [key: string]: Object;
  30721. };
  30722. /**
  30723. * Texture content used if a texture cannot loaded
  30724. * @ignorenaming
  30725. */
  30726. static fallbackTexture: string;
  30727. /**
  30728. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30729. * @param u defines the coordinate on X axis
  30730. * @param v defines the coordinate on Y axis
  30731. * @param width defines the width of the source data
  30732. * @param height defines the height of the source data
  30733. * @param pixels defines the source byte array
  30734. * @param color defines the output color
  30735. */
  30736. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30737. /**
  30738. * Interpolates between a and b via alpha
  30739. * @param a The lower value (returned when alpha = 0)
  30740. * @param b The upper value (returned when alpha = 1)
  30741. * @param alpha The interpolation-factor
  30742. * @return The mixed value
  30743. */
  30744. static Mix(a: number, b: number, alpha: number): number;
  30745. /**
  30746. * Tries to instantiate a new object from a given class name
  30747. * @param className defines the class name to instantiate
  30748. * @returns the new object or null if the system was not able to do the instantiation
  30749. */
  30750. static Instantiate(className: string): any;
  30751. /**
  30752. * Provides a slice function that will work even on IE
  30753. * @param data defines the array to slice
  30754. * @param start defines the start of the data (optional)
  30755. * @param end defines the end of the data (optional)
  30756. * @returns the new sliced array
  30757. */
  30758. static Slice<T>(data: T, start?: number, end?: number): T;
  30759. /**
  30760. * Polyfill for setImmediate
  30761. * @param action defines the action to execute after the current execution block
  30762. */
  30763. static SetImmediate(action: () => void): void;
  30764. /**
  30765. * Function indicating if a number is an exponent of 2
  30766. * @param value defines the value to test
  30767. * @returns true if the value is an exponent of 2
  30768. */
  30769. static IsExponentOfTwo(value: number): boolean;
  30770. private static _tmpFloatArray;
  30771. /**
  30772. * Returns the nearest 32-bit single precision float representation of a Number
  30773. * @param value A Number. If the parameter is of a different type, it will get converted
  30774. * to a number or to NaN if it cannot be converted
  30775. * @returns number
  30776. */
  30777. static FloatRound(value: number): number;
  30778. /**
  30779. * Find the next highest power of two.
  30780. * @param x Number to start search from.
  30781. * @return Next highest power of two.
  30782. */
  30783. static CeilingPOT(x: number): number;
  30784. /**
  30785. * Find the next lowest power of two.
  30786. * @param x Number to start search from.
  30787. * @return Next lowest power of two.
  30788. */
  30789. static FloorPOT(x: number): number;
  30790. /**
  30791. * Find the nearest power of two.
  30792. * @param x Number to start search from.
  30793. * @return Next nearest power of two.
  30794. */
  30795. static NearestPOT(x: number): number;
  30796. /**
  30797. * Get the closest exponent of two
  30798. * @param value defines the value to approximate
  30799. * @param max defines the maximum value to return
  30800. * @param mode defines how to define the closest value
  30801. * @returns closest exponent of two of the given value
  30802. */
  30803. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30804. /**
  30805. * Extracts the filename from a path
  30806. * @param path defines the path to use
  30807. * @returns the filename
  30808. */
  30809. static GetFilename(path: string): string;
  30810. /**
  30811. * Extracts the "folder" part of a path (everything before the filename).
  30812. * @param uri The URI to extract the info from
  30813. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30814. * @returns The "folder" part of the path
  30815. */
  30816. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30817. /**
  30818. * Extracts text content from a DOM element hierarchy
  30819. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30820. */
  30821. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30822. /**
  30823. * Convert an angle in radians to degrees
  30824. * @param angle defines the angle to convert
  30825. * @returns the angle in degrees
  30826. */
  30827. static ToDegrees(angle: number): number;
  30828. /**
  30829. * Convert an angle in degrees to radians
  30830. * @param angle defines the angle to convert
  30831. * @returns the angle in radians
  30832. */
  30833. static ToRadians(angle: number): number;
  30834. /**
  30835. * Encode a buffer to a base64 string
  30836. * @param buffer defines the buffer to encode
  30837. * @returns the encoded string
  30838. */
  30839. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30840. /**
  30841. * Extracts minimum and maximum values from a list of indexed positions
  30842. * @param positions defines the positions to use
  30843. * @param indices defines the indices to the positions
  30844. * @param indexStart defines the start index
  30845. * @param indexCount defines the end index
  30846. * @param bias defines bias value to add to the result
  30847. * @return minimum and maximum values
  30848. */
  30849. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30850. minimum: Vector3;
  30851. maximum: Vector3;
  30852. };
  30853. /**
  30854. * Extracts minimum and maximum values from a list of positions
  30855. * @param positions defines the positions to use
  30856. * @param start defines the start index in the positions array
  30857. * @param count defines the number of positions to handle
  30858. * @param bias defines bias value to add to the result
  30859. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30860. * @return minimum and maximum values
  30861. */
  30862. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30863. minimum: Vector3;
  30864. maximum: Vector3;
  30865. };
  30866. /**
  30867. * Returns an array if obj is not an array
  30868. * @param obj defines the object to evaluate as an array
  30869. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30870. * @returns either obj directly if obj is an array or a new array containing obj
  30871. */
  30872. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30873. /**
  30874. * Gets the pointer prefix to use
  30875. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30876. */
  30877. static GetPointerPrefix(): string;
  30878. /**
  30879. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30880. * @param func - the function to be called
  30881. * @param requester - the object that will request the next frame. Falls back to window.
  30882. * @returns frame number
  30883. */
  30884. static QueueNewFrame(func: () => void, requester?: any): number;
  30885. /**
  30886. * Ask the browser to promote the current element to fullscreen rendering mode
  30887. * @param element defines the DOM element to promote
  30888. */
  30889. static RequestFullscreen(element: HTMLElement): void;
  30890. /**
  30891. * Asks the browser to exit fullscreen mode
  30892. */
  30893. static ExitFullscreen(): void;
  30894. /**
  30895. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30896. * @param url define the url we are trying
  30897. * @param element define the dom element where to configure the cors policy
  30898. */
  30899. static SetCorsBehavior(url: string | string[], element: {
  30900. crossOrigin: string | null;
  30901. }): void;
  30902. /**
  30903. * Removes unwanted characters from an url
  30904. * @param url defines the url to clean
  30905. * @returns the cleaned url
  30906. */
  30907. static CleanUrl(url: string): string;
  30908. /**
  30909. * Gets or sets a function used to pre-process url before using them to load assets
  30910. */
  30911. static PreprocessUrl: (url: string) => string;
  30912. /**
  30913. * Loads an image as an HTMLImageElement.
  30914. * @param input url string, ArrayBuffer, or Blob to load
  30915. * @param onLoad callback called when the image successfully loads
  30916. * @param onError callback called when the image fails to load
  30917. * @param offlineProvider offline provider for caching
  30918. * @returns the HTMLImageElement of the loaded image
  30919. */
  30920. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30921. /**
  30922. * Loads a file
  30923. * @param url url string, ArrayBuffer, or Blob to load
  30924. * @param onSuccess callback called when the file successfully loads
  30925. * @param onProgress callback called while file is loading (if the server supports this mode)
  30926. * @param offlineProvider defines the offline provider for caching
  30927. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30928. * @param onError callback called when the file fails to load
  30929. * @returns a file request object
  30930. */
  30931. 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;
  30932. /**
  30933. * Load a script (identified by an url). When the url returns, the
  30934. * content of this file is added into a new script element, attached to the DOM (body element)
  30935. * @param scriptUrl defines the url of the script to laod
  30936. * @param onSuccess defines the callback called when the script is loaded
  30937. * @param onError defines the callback to call if an error occurs
  30938. * @param scriptId defines the id of the script element
  30939. */
  30940. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30941. /**
  30942. * Load an asynchronous script (identified by an url). When the url returns, the
  30943. * content of this file is added into a new script element, attached to the DOM (body element)
  30944. * @param scriptUrl defines the url of the script to laod
  30945. * @param scriptId defines the id of the script element
  30946. * @returns a promise request object
  30947. */
  30948. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30949. /**
  30950. * Loads a file from a blob
  30951. * @param fileToLoad defines the blob to use
  30952. * @param callback defines the callback to call when data is loaded
  30953. * @param progressCallback defines the callback to call during loading process
  30954. * @returns a file request object
  30955. */
  30956. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30957. /**
  30958. * Loads a file
  30959. * @param fileToLoad defines the file to load
  30960. * @param callback defines the callback to call when data is loaded
  30961. * @param progressCallBack defines the callback to call during loading process
  30962. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30963. * @returns a file request object
  30964. */
  30965. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30966. /**
  30967. * Creates a data url from a given string content
  30968. * @param content defines the content to convert
  30969. * @returns the new data url link
  30970. */
  30971. static FileAsURL(content: string): string;
  30972. /**
  30973. * Format the given number to a specific decimal format
  30974. * @param value defines the number to format
  30975. * @param decimals defines the number of decimals to use
  30976. * @returns the formatted string
  30977. */
  30978. static Format(value: number, decimals?: number): string;
  30979. /**
  30980. * Checks if a given vector is inside a specific range
  30981. * @param v defines the vector to test
  30982. * @param min defines the minimum range
  30983. * @param max defines the maximum range
  30984. */
  30985. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30986. /**
  30987. * Tries to copy an object by duplicating every property
  30988. * @param source defines the source object
  30989. * @param destination defines the target object
  30990. * @param doNotCopyList defines a list of properties to avoid
  30991. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30992. */
  30993. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30994. /**
  30995. * Gets a boolean indicating if the given object has no own property
  30996. * @param obj defines the object to test
  30997. * @returns true if object has no own property
  30998. */
  30999. static IsEmpty(obj: any): boolean;
  31000. /**
  31001. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31002. * @param str Source string
  31003. * @param suffix Suffix to search for in the source string
  31004. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31005. */
  31006. static EndsWith(str: string, suffix: string): boolean;
  31007. /**
  31008. * Function used to register events at window level
  31009. * @param events defines the events to register
  31010. */
  31011. static RegisterTopRootEvents(events: {
  31012. name: string;
  31013. handler: Nullable<(e: FocusEvent) => any>;
  31014. }[]): void;
  31015. /**
  31016. * Function used to unregister events from window level
  31017. * @param events defines the events to unregister
  31018. */
  31019. static UnregisterTopRootEvents(events: {
  31020. name: string;
  31021. handler: Nullable<(e: FocusEvent) => any>;
  31022. }[]): void;
  31023. /**
  31024. * @ignore
  31025. */
  31026. static _ScreenshotCanvas: HTMLCanvasElement;
  31027. /**
  31028. * Dumps the current bound framebuffer
  31029. * @param width defines the rendering width
  31030. * @param height defines the rendering height
  31031. * @param engine defines the hosting engine
  31032. * @param successCallback defines the callback triggered once the data are available
  31033. * @param mimeType defines the mime type of the result
  31034. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31035. */
  31036. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31037. /**
  31038. * Converts the canvas data to blob.
  31039. * This acts as a polyfill for browsers not supporting the to blob function.
  31040. * @param canvas Defines the canvas to extract the data from
  31041. * @param successCallback Defines the callback triggered once the data are available
  31042. * @param mimeType Defines the mime type of the result
  31043. */
  31044. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31045. /**
  31046. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31047. * @param successCallback defines the callback triggered once the data are available
  31048. * @param mimeType defines the mime type of the result
  31049. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31050. */
  31051. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31052. /**
  31053. * Downloads a blob in the browser
  31054. * @param blob defines the blob to download
  31055. * @param fileName defines the name of the downloaded file
  31056. */
  31057. static Download(blob: Blob, fileName: string): void;
  31058. /**
  31059. * Captures a screenshot of the current rendering
  31060. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31061. * @param engine defines the rendering engine
  31062. * @param camera defines the source camera
  31063. * @param size This parameter can be set to a single number or to an object with the
  31064. * following (optional) properties: precision, width, height. If a single number is passed,
  31065. * it will be used for both width and height. If an object is passed, the screenshot size
  31066. * will be derived from the parameters. The precision property is a multiplier allowing
  31067. * rendering at a higher or lower resolution
  31068. * @param successCallback defines the callback receives a single parameter which contains the
  31069. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31070. * src parameter of an <img> to display it
  31071. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31072. * Check your browser for supported MIME types
  31073. */
  31074. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31075. /**
  31076. * Generates an image screenshot from the specified camera.
  31077. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31078. * @param engine The engine to use for rendering
  31079. * @param camera The camera to use for rendering
  31080. * @param size This parameter can be set to a single number or to an object with the
  31081. * following (optional) properties: precision, width, height. If a single number is passed,
  31082. * it will be used for both width and height. If an object is passed, the screenshot size
  31083. * will be derived from the parameters. The precision property is a multiplier allowing
  31084. * rendering at a higher or lower resolution
  31085. * @param successCallback The callback receives a single parameter which contains the
  31086. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31087. * src parameter of an <img> to display it
  31088. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31089. * Check your browser for supported MIME types
  31090. * @param samples Texture samples (default: 1)
  31091. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31092. * @param fileName A name for for the downloaded file.
  31093. */
  31094. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31095. /**
  31096. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31097. * Be aware Math.random() could cause collisions, but:
  31098. * "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"
  31099. * @returns a pseudo random id
  31100. */
  31101. static RandomId(): string;
  31102. /**
  31103. * Test if the given uri is a base64 string
  31104. * @param uri The uri to test
  31105. * @return True if the uri is a base64 string or false otherwise
  31106. */
  31107. static IsBase64(uri: string): boolean;
  31108. /**
  31109. * Decode the given base64 uri.
  31110. * @param uri The uri to decode
  31111. * @return The decoded base64 data.
  31112. */
  31113. static DecodeBase64(uri: string): ArrayBuffer;
  31114. /**
  31115. * No log
  31116. */
  31117. static readonly NoneLogLevel: number;
  31118. /**
  31119. * Only message logs
  31120. */
  31121. static readonly MessageLogLevel: number;
  31122. /**
  31123. * Only warning logs
  31124. */
  31125. static readonly WarningLogLevel: number;
  31126. /**
  31127. * Only error logs
  31128. */
  31129. static readonly ErrorLogLevel: number;
  31130. /**
  31131. * All logs
  31132. */
  31133. static readonly AllLogLevel: number;
  31134. /**
  31135. * Gets a value indicating the number of loading errors
  31136. * @ignorenaming
  31137. */
  31138. static readonly errorsCount: number;
  31139. /**
  31140. * Callback called when a new log is added
  31141. */
  31142. static OnNewCacheEntry: (entry: string) => void;
  31143. /**
  31144. * Log a message to the console
  31145. * @param message defines the message to log
  31146. */
  31147. static Log(message: string): void;
  31148. /**
  31149. * Write a warning message to the console
  31150. * @param message defines the message to log
  31151. */
  31152. static Warn(message: string): void;
  31153. /**
  31154. * Write an error message to the console
  31155. * @param message defines the message to log
  31156. */
  31157. static Error(message: string): void;
  31158. /**
  31159. * Gets current log cache (list of logs)
  31160. */
  31161. static readonly LogCache: string;
  31162. /**
  31163. * Clears the log cache
  31164. */
  31165. static ClearLogCache(): void;
  31166. /**
  31167. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31168. */
  31169. static LogLevels: number;
  31170. /**
  31171. * Checks if the loaded document was accessed via `file:`-Protocol.
  31172. * @returns boolean
  31173. */
  31174. static IsFileURL(): boolean;
  31175. /**
  31176. * Checks if the window object exists
  31177. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31178. */
  31179. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31180. /**
  31181. * No performance log
  31182. */
  31183. static readonly PerformanceNoneLogLevel: number;
  31184. /**
  31185. * Use user marks to log performance
  31186. */
  31187. static readonly PerformanceUserMarkLogLevel: number;
  31188. /**
  31189. * Log performance to the console
  31190. */
  31191. static readonly PerformanceConsoleLogLevel: number;
  31192. private static _performance;
  31193. /**
  31194. * Sets the current performance log level
  31195. */
  31196. static PerformanceLogLevel: number;
  31197. private static _StartPerformanceCounterDisabled;
  31198. private static _EndPerformanceCounterDisabled;
  31199. private static _StartUserMark;
  31200. private static _EndUserMark;
  31201. private static _StartPerformanceConsole;
  31202. private static _EndPerformanceConsole;
  31203. /**
  31204. * Starts a performance counter
  31205. */
  31206. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31207. /**
  31208. * Ends a specific performance coutner
  31209. */
  31210. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31211. /**
  31212. * Gets either window.performance.now() if supported or Date.now() else
  31213. */
  31214. static readonly Now: number;
  31215. /**
  31216. * This method will return the name of the class used to create the instance of the given object.
  31217. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31218. * @param object the object to get the class name from
  31219. * @param isType defines if the object is actually a type
  31220. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31221. */
  31222. static GetClassName(object: any, isType?: boolean): string;
  31223. /**
  31224. * Gets the first element of an array satisfying a given predicate
  31225. * @param array defines the array to browse
  31226. * @param predicate defines the predicate to use
  31227. * @returns null if not found or the element
  31228. */
  31229. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31230. /**
  31231. * This method will return the name of the full name of the class, including its owning module (if any).
  31232. * 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).
  31233. * @param object the object to get the class name from
  31234. * @param isType defines if the object is actually a type
  31235. * @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.
  31236. * @ignorenaming
  31237. */
  31238. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31239. /**
  31240. * Returns a promise that resolves after the given amount of time.
  31241. * @param delay Number of milliseconds to delay
  31242. * @returns Promise that resolves after the given amount of time
  31243. */
  31244. static DelayAsync(delay: number): Promise<void>;
  31245. /**
  31246. * Gets the current gradient from an array of IValueGradient
  31247. * @param ratio defines the current ratio to get
  31248. * @param gradients defines the array of IValueGradient
  31249. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31250. */
  31251. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31252. }
  31253. /**
  31254. * This class is used to track a performance counter which is number based.
  31255. * The user has access to many properties which give statistics of different nature.
  31256. *
  31257. * The implementer can track two kinds of Performance Counter: time and count.
  31258. * 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.
  31259. * 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.
  31260. */
  31261. export class PerfCounter {
  31262. /**
  31263. * Gets or sets a global boolean to turn on and off all the counters
  31264. */
  31265. static Enabled: boolean;
  31266. /**
  31267. * Returns the smallest value ever
  31268. */
  31269. readonly min: number;
  31270. /**
  31271. * Returns the biggest value ever
  31272. */
  31273. readonly max: number;
  31274. /**
  31275. * Returns the average value since the performance counter is running
  31276. */
  31277. readonly average: number;
  31278. /**
  31279. * Returns the average value of the last second the counter was monitored
  31280. */
  31281. readonly lastSecAverage: number;
  31282. /**
  31283. * Returns the current value
  31284. */
  31285. readonly current: number;
  31286. /**
  31287. * Gets the accumulated total
  31288. */
  31289. readonly total: number;
  31290. /**
  31291. * Gets the total value count
  31292. */
  31293. readonly count: number;
  31294. /**
  31295. * Creates a new counter
  31296. */
  31297. constructor();
  31298. /**
  31299. * Call this method to start monitoring a new frame.
  31300. * 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.
  31301. */
  31302. fetchNewFrame(): void;
  31303. /**
  31304. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31305. * @param newCount the count value to add to the monitored count
  31306. * @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.
  31307. */
  31308. addCount(newCount: number, fetchResult: boolean): void;
  31309. /**
  31310. * Start monitoring this performance counter
  31311. */
  31312. beginMonitoring(): void;
  31313. /**
  31314. * Compute the time lapsed since the previous beginMonitoring() call.
  31315. * @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
  31316. */
  31317. endMonitoring(newFrame?: boolean): void;
  31318. private _fetchResult;
  31319. private _startMonitoringTime;
  31320. private _min;
  31321. private _max;
  31322. private _average;
  31323. private _current;
  31324. private _totalValueCount;
  31325. private _totalAccumulated;
  31326. private _lastSecAverage;
  31327. private _lastSecAccumulated;
  31328. private _lastSecTime;
  31329. private _lastSecValueCount;
  31330. }
  31331. /**
  31332. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31333. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31334. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31335. * @param name The name of the class, case should be preserved
  31336. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31337. */
  31338. export function className(name: string, module?: string): (target: Object) => void;
  31339. /**
  31340. * An implementation of a loop for asynchronous functions.
  31341. */
  31342. export class AsyncLoop {
  31343. /**
  31344. * Defines the number of iterations for the loop
  31345. */
  31346. iterations: number;
  31347. /**
  31348. * Defines the current index of the loop.
  31349. */
  31350. index: number;
  31351. private _done;
  31352. private _fn;
  31353. private _successCallback;
  31354. /**
  31355. * Constructor.
  31356. * @param iterations the number of iterations.
  31357. * @param func the function to run each iteration
  31358. * @param successCallback the callback that will be called upon succesful execution
  31359. * @param offset starting offset.
  31360. */
  31361. constructor(
  31362. /**
  31363. * Defines the number of iterations for the loop
  31364. */
  31365. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31366. /**
  31367. * Execute the next iteration. Must be called after the last iteration was finished.
  31368. */
  31369. executeNext(): void;
  31370. /**
  31371. * Break the loop and run the success callback.
  31372. */
  31373. breakLoop(): void;
  31374. /**
  31375. * Create and run an async loop.
  31376. * @param iterations the number of iterations.
  31377. * @param fn the function to run each iteration
  31378. * @param successCallback the callback that will be called upon succesful execution
  31379. * @param offset starting offset.
  31380. * @returns the created async loop object
  31381. */
  31382. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31383. /**
  31384. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31385. * @param iterations total number of iterations
  31386. * @param syncedIterations number of synchronous iterations in each async iteration.
  31387. * @param fn the function to call each iteration.
  31388. * @param callback a success call back that will be called when iterating stops.
  31389. * @param breakFunction a break condition (optional)
  31390. * @param timeout timeout settings for the setTimeout function. default - 0.
  31391. * @returns the created async loop object
  31392. */
  31393. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31394. }
  31395. }
  31396. declare module BABYLON {
  31397. /** @hidden */
  31398. export interface ICollisionCoordinator {
  31399. createCollider(): Collider;
  31400. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31401. init(scene: Scene): void;
  31402. }
  31403. /** @hidden */
  31404. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31405. private _scene;
  31406. private _scaledPosition;
  31407. private _scaledVelocity;
  31408. private _finalPosition;
  31409. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31410. createCollider(): Collider;
  31411. init(scene: Scene): void;
  31412. private _collideWithWorld;
  31413. }
  31414. }
  31415. declare module BABYLON {
  31416. /**
  31417. * This class defines the direct association between an animation and a target
  31418. */
  31419. export class TargetedAnimation {
  31420. /**
  31421. * Animation to perform
  31422. */
  31423. animation: Animation;
  31424. /**
  31425. * Target to animate
  31426. */
  31427. target: any;
  31428. }
  31429. /**
  31430. * Use this class to create coordinated animations on multiple targets
  31431. */
  31432. export class AnimationGroup implements IDisposable {
  31433. /** The name of the animation group */
  31434. name: string;
  31435. private _scene;
  31436. private _targetedAnimations;
  31437. private _animatables;
  31438. private _from;
  31439. private _to;
  31440. private _isStarted;
  31441. private _isPaused;
  31442. private _speedRatio;
  31443. /**
  31444. * Gets or sets the unique id of the node
  31445. */
  31446. uniqueId: number;
  31447. /**
  31448. * This observable will notify when one animation have ended
  31449. */
  31450. onAnimationEndObservable: Observable<TargetedAnimation>;
  31451. /**
  31452. * Observer raised when one animation loops
  31453. */
  31454. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31455. /**
  31456. * This observable will notify when all animations have ended.
  31457. */
  31458. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31459. /**
  31460. * This observable will notify when all animations have paused.
  31461. */
  31462. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31463. /**
  31464. * This observable will notify when all animations are playing.
  31465. */
  31466. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31467. /**
  31468. * Gets the first frame
  31469. */
  31470. readonly from: number;
  31471. /**
  31472. * Gets the last frame
  31473. */
  31474. readonly to: number;
  31475. /**
  31476. * Define if the animations are started
  31477. */
  31478. readonly isStarted: boolean;
  31479. /**
  31480. * Gets a value indicating that the current group is playing
  31481. */
  31482. readonly isPlaying: boolean;
  31483. /**
  31484. * Gets or sets the speed ratio to use for all animations
  31485. */
  31486. /**
  31487. * Gets or sets the speed ratio to use for all animations
  31488. */
  31489. speedRatio: number;
  31490. /**
  31491. * Gets the targeted animations for this animation group
  31492. */
  31493. readonly targetedAnimations: Array<TargetedAnimation>;
  31494. /**
  31495. * returning the list of animatables controlled by this animation group.
  31496. */
  31497. readonly animatables: Array<Animatable>;
  31498. /**
  31499. * Instantiates a new Animation Group.
  31500. * This helps managing several animations at once.
  31501. * @see http://doc.babylonjs.com/how_to/group
  31502. * @param name Defines the name of the group
  31503. * @param scene Defines the scene the group belongs to
  31504. */
  31505. constructor(
  31506. /** The name of the animation group */
  31507. name: string, scene?: Nullable<Scene>);
  31508. /**
  31509. * Add an animation (with its target) in the group
  31510. * @param animation defines the animation we want to add
  31511. * @param target defines the target of the animation
  31512. * @returns the TargetedAnimation object
  31513. */
  31514. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31515. /**
  31516. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31517. * It can add constant keys at begin or end
  31518. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31519. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31520. * @returns the animation group
  31521. */
  31522. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31523. /**
  31524. * Start all animations on given targets
  31525. * @param loop defines if animations must loop
  31526. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31527. * @param from defines the from key (optional)
  31528. * @param to defines the to key (optional)
  31529. * @returns the current animation group
  31530. */
  31531. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31532. /**
  31533. * Pause all animations
  31534. * @returns the animation group
  31535. */
  31536. pause(): AnimationGroup;
  31537. /**
  31538. * Play all animations to initial state
  31539. * This function will start() the animations if they were not started or will restart() them if they were paused
  31540. * @param loop defines if animations must loop
  31541. * @returns the animation group
  31542. */
  31543. play(loop?: boolean): AnimationGroup;
  31544. /**
  31545. * Reset all animations to initial state
  31546. * @returns the animation group
  31547. */
  31548. reset(): AnimationGroup;
  31549. /**
  31550. * Restart animations from key 0
  31551. * @returns the animation group
  31552. */
  31553. restart(): AnimationGroup;
  31554. /**
  31555. * Stop all animations
  31556. * @returns the animation group
  31557. */
  31558. stop(): AnimationGroup;
  31559. /**
  31560. * Set animation weight for all animatables
  31561. * @param weight defines the weight to use
  31562. * @return the animationGroup
  31563. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31564. */
  31565. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31566. /**
  31567. * Synchronize and normalize all animatables with a source animatable
  31568. * @param root defines the root animatable to synchronize with
  31569. * @return the animationGroup
  31570. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31571. */
  31572. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31573. /**
  31574. * Goes to a specific frame in this animation group
  31575. * @param frame the frame number to go to
  31576. * @return the animationGroup
  31577. */
  31578. goToFrame(frame: number): AnimationGroup;
  31579. /**
  31580. * Dispose all associated resources
  31581. */
  31582. dispose(): void;
  31583. private _checkAnimationGroupEnded;
  31584. /**
  31585. * Clone the current animation group and returns a copy
  31586. * @param newName defines the name of the new group
  31587. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31588. * @returns the new aniamtion group
  31589. */
  31590. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31591. /**
  31592. * Returns a new AnimationGroup object parsed from the source provided.
  31593. * @param parsedAnimationGroup defines the source
  31594. * @param scene defines the scene that will receive the animationGroup
  31595. * @returns a new AnimationGroup
  31596. */
  31597. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31598. /**
  31599. * Returns the string "AnimationGroup"
  31600. * @returns "AnimationGroup"
  31601. */
  31602. getClassName(): string;
  31603. /**
  31604. * Creates a detailled string about the object
  31605. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31606. * @returns a string representing the object
  31607. */
  31608. toString(fullDetails?: boolean): string;
  31609. }
  31610. }
  31611. declare module BABYLON {
  31612. /**
  31613. * Define an interface for all classes that will hold resources
  31614. */
  31615. export interface IDisposable {
  31616. /**
  31617. * Releases all held resources
  31618. */
  31619. dispose(): void;
  31620. }
  31621. /** Interface defining initialization parameters for Scene class */
  31622. export interface SceneOptions {
  31623. /**
  31624. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31625. * It will improve performance when the number of geometries becomes important.
  31626. */
  31627. useGeometryUniqueIdsMap?: boolean;
  31628. /**
  31629. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31630. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31631. */
  31632. useMaterialMeshMap?: boolean;
  31633. /**
  31634. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31635. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31636. */
  31637. useClonedMeshhMap?: boolean;
  31638. }
  31639. /**
  31640. * Represents a scene to be rendered by the engine.
  31641. * @see http://doc.babylonjs.com/features/scene
  31642. */
  31643. export class Scene extends AbstractScene implements IAnimatable {
  31644. private static _uniqueIdCounter;
  31645. /** The fog is deactivated */
  31646. static readonly FOGMODE_NONE: number;
  31647. /** The fog density is following an exponential function */
  31648. static readonly FOGMODE_EXP: number;
  31649. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31650. static readonly FOGMODE_EXP2: number;
  31651. /** The fog density is following a linear function. */
  31652. static readonly FOGMODE_LINEAR: number;
  31653. /**
  31654. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31655. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31656. */
  31657. static MinDeltaTime: number;
  31658. /**
  31659. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31660. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31661. */
  31662. static MaxDeltaTime: number;
  31663. /**
  31664. * Factory used to create the default material.
  31665. * @param name The name of the material to create
  31666. * @param scene The scene to create the material for
  31667. * @returns The default material
  31668. */
  31669. static DefaultMaterialFactory(scene: Scene): Material;
  31670. /**
  31671. * Factory used to create the a collision coordinator.
  31672. * @returns The collision coordinator
  31673. */
  31674. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31675. /** @hidden */
  31676. readonly _isScene: boolean;
  31677. /**
  31678. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31679. */
  31680. autoClear: boolean;
  31681. /**
  31682. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31683. */
  31684. autoClearDepthAndStencil: boolean;
  31685. /**
  31686. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31687. */
  31688. clearColor: Color4;
  31689. /**
  31690. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31691. */
  31692. ambientColor: Color3;
  31693. /**
  31694. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31695. * It should only be one of the following (if not the default embedded one):
  31696. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31697. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31698. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31699. * The material properties need to be setup according to the type of texture in use.
  31700. */
  31701. environmentBRDFTexture: BaseTexture;
  31702. /** @hidden */
  31703. protected _environmentTexture: Nullable<BaseTexture>;
  31704. /**
  31705. * Texture used in all pbr material as the reflection texture.
  31706. * As in the majority of the scene they are the same (exception for multi room and so on),
  31707. * this is easier to reference from here than from all the materials.
  31708. */
  31709. /**
  31710. * Texture used in all pbr material as the reflection texture.
  31711. * As in the majority of the scene they are the same (exception for multi room and so on),
  31712. * this is easier to set here than in all the materials.
  31713. */
  31714. environmentTexture: Nullable<BaseTexture>;
  31715. /** @hidden */
  31716. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31717. /**
  31718. * Default image processing configuration used either in the rendering
  31719. * Forward main pass or through the imageProcessingPostProcess if present.
  31720. * As in the majority of the scene they are the same (exception for multi camera),
  31721. * this is easier to reference from here than from all the materials and post process.
  31722. *
  31723. * No setter as we it is a shared configuration, you can set the values instead.
  31724. */
  31725. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31726. private _forceWireframe;
  31727. /**
  31728. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31729. */
  31730. forceWireframe: boolean;
  31731. private _forcePointsCloud;
  31732. /**
  31733. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31734. */
  31735. forcePointsCloud: boolean;
  31736. /**
  31737. * Gets or sets the active clipplane 1
  31738. */
  31739. clipPlane: Nullable<Plane>;
  31740. /**
  31741. * Gets or sets the active clipplane 2
  31742. */
  31743. clipPlane2: Nullable<Plane>;
  31744. /**
  31745. * Gets or sets the active clipplane 3
  31746. */
  31747. clipPlane3: Nullable<Plane>;
  31748. /**
  31749. * Gets or sets the active clipplane 4
  31750. */
  31751. clipPlane4: Nullable<Plane>;
  31752. /**
  31753. * Gets or sets a boolean indicating if animations are enabled
  31754. */
  31755. animationsEnabled: boolean;
  31756. private _animationPropertiesOverride;
  31757. /**
  31758. * Gets or sets the animation properties override
  31759. */
  31760. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31761. /**
  31762. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31763. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31764. */
  31765. useConstantAnimationDeltaTime: boolean;
  31766. /**
  31767. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31768. * Please note that it requires to run a ray cast through the scene on every frame
  31769. */
  31770. constantlyUpdateMeshUnderPointer: boolean;
  31771. /**
  31772. * Defines the HTML cursor to use when hovering over interactive elements
  31773. */
  31774. hoverCursor: string;
  31775. /**
  31776. * Defines the HTML default cursor to use (empty by default)
  31777. */
  31778. defaultCursor: string;
  31779. /**
  31780. * This is used to call preventDefault() on pointer down
  31781. * in order to block unwanted artifacts like system double clicks
  31782. */
  31783. preventDefaultOnPointerDown: boolean;
  31784. /**
  31785. * This is used to call preventDefault() on pointer up
  31786. * in order to block unwanted artifacts like system double clicks
  31787. */
  31788. preventDefaultOnPointerUp: boolean;
  31789. /**
  31790. * Gets or sets user defined metadata
  31791. */
  31792. metadata: any;
  31793. /**
  31794. * For internal use only. Please do not use.
  31795. */
  31796. reservedDataStore: any;
  31797. /**
  31798. * Gets the name of the plugin used to load this scene (null by default)
  31799. */
  31800. loadingPluginName: string;
  31801. /**
  31802. * Use this array to add regular expressions used to disable offline support for specific urls
  31803. */
  31804. disableOfflineSupportExceptionRules: RegExp[];
  31805. /**
  31806. * An event triggered when the scene is disposed.
  31807. */
  31808. onDisposeObservable: Observable<Scene>;
  31809. private _onDisposeObserver;
  31810. /** Sets a function to be executed when this scene is disposed. */
  31811. onDispose: () => void;
  31812. /**
  31813. * An event triggered before rendering the scene (right after animations and physics)
  31814. */
  31815. onBeforeRenderObservable: Observable<Scene>;
  31816. private _onBeforeRenderObserver;
  31817. /** Sets a function to be executed before rendering this scene */
  31818. beforeRender: Nullable<() => void>;
  31819. /**
  31820. * An event triggered after rendering the scene
  31821. */
  31822. onAfterRenderObservable: Observable<Scene>;
  31823. private _onAfterRenderObserver;
  31824. /** Sets a function to be executed after rendering this scene */
  31825. afterRender: Nullable<() => void>;
  31826. /**
  31827. * An event triggered before animating the scene
  31828. */
  31829. onBeforeAnimationsObservable: Observable<Scene>;
  31830. /**
  31831. * An event triggered after animations processing
  31832. */
  31833. onAfterAnimationsObservable: Observable<Scene>;
  31834. /**
  31835. * An event triggered before draw calls are ready to be sent
  31836. */
  31837. onBeforeDrawPhaseObservable: Observable<Scene>;
  31838. /**
  31839. * An event triggered after draw calls have been sent
  31840. */
  31841. onAfterDrawPhaseObservable: Observable<Scene>;
  31842. /**
  31843. * An event triggered when the scene is ready
  31844. */
  31845. onReadyObservable: Observable<Scene>;
  31846. /**
  31847. * An event triggered before rendering a camera
  31848. */
  31849. onBeforeCameraRenderObservable: Observable<Camera>;
  31850. private _onBeforeCameraRenderObserver;
  31851. /** Sets a function to be executed before rendering a camera*/
  31852. beforeCameraRender: () => void;
  31853. /**
  31854. * An event triggered after rendering a camera
  31855. */
  31856. onAfterCameraRenderObservable: Observable<Camera>;
  31857. private _onAfterCameraRenderObserver;
  31858. /** Sets a function to be executed after rendering a camera*/
  31859. afterCameraRender: () => void;
  31860. /**
  31861. * An event triggered when active meshes evaluation is about to start
  31862. */
  31863. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31864. /**
  31865. * An event triggered when active meshes evaluation is done
  31866. */
  31867. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31868. /**
  31869. * An event triggered when particles rendering is about to start
  31870. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31871. */
  31872. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31873. /**
  31874. * An event triggered when particles rendering is done
  31875. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31876. */
  31877. onAfterParticlesRenderingObservable: Observable<Scene>;
  31878. /**
  31879. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31880. */
  31881. onDataLoadedObservable: Observable<Scene>;
  31882. /**
  31883. * An event triggered when a camera is created
  31884. */
  31885. onNewCameraAddedObservable: Observable<Camera>;
  31886. /**
  31887. * An event triggered when a camera is removed
  31888. */
  31889. onCameraRemovedObservable: Observable<Camera>;
  31890. /**
  31891. * An event triggered when a light is created
  31892. */
  31893. onNewLightAddedObservable: Observable<Light>;
  31894. /**
  31895. * An event triggered when a light is removed
  31896. */
  31897. onLightRemovedObservable: Observable<Light>;
  31898. /**
  31899. * An event triggered when a geometry is created
  31900. */
  31901. onNewGeometryAddedObservable: Observable<Geometry>;
  31902. /**
  31903. * An event triggered when a geometry is removed
  31904. */
  31905. onGeometryRemovedObservable: Observable<Geometry>;
  31906. /**
  31907. * An event triggered when a transform node is created
  31908. */
  31909. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31910. /**
  31911. * An event triggered when a transform node is removed
  31912. */
  31913. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31914. /**
  31915. * An event triggered when a mesh is created
  31916. */
  31917. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31918. /**
  31919. * An event triggered when a mesh is removed
  31920. */
  31921. onMeshRemovedObservable: Observable<AbstractMesh>;
  31922. /**
  31923. * An event triggered when a skeleton is created
  31924. */
  31925. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31926. /**
  31927. * An event triggered when a skeleton is removed
  31928. */
  31929. onSkeletonRemovedObservable: Observable<Skeleton>;
  31930. /**
  31931. * An event triggered when a material is created
  31932. */
  31933. onNewMaterialAddedObservable: Observable<Material>;
  31934. /**
  31935. * An event triggered when a material is removed
  31936. */
  31937. onMaterialRemovedObservable: Observable<Material>;
  31938. /**
  31939. * An event triggered when a texture is created
  31940. */
  31941. onNewTextureAddedObservable: Observable<BaseTexture>;
  31942. /**
  31943. * An event triggered when a texture is removed
  31944. */
  31945. onTextureRemovedObservable: Observable<BaseTexture>;
  31946. /**
  31947. * An event triggered when render targets are about to be rendered
  31948. * Can happen multiple times per frame.
  31949. */
  31950. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31951. /**
  31952. * An event triggered when render targets were rendered.
  31953. * Can happen multiple times per frame.
  31954. */
  31955. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31956. /**
  31957. * An event triggered before calculating deterministic simulation step
  31958. */
  31959. onBeforeStepObservable: Observable<Scene>;
  31960. /**
  31961. * An event triggered after calculating deterministic simulation step
  31962. */
  31963. onAfterStepObservable: Observable<Scene>;
  31964. /**
  31965. * An event triggered when the activeCamera property is updated
  31966. */
  31967. onActiveCameraChanged: Observable<Scene>;
  31968. /**
  31969. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31970. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31971. * 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)
  31972. */
  31973. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31974. /**
  31975. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31976. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31977. * 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)
  31978. */
  31979. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31980. /**
  31981. * This Observable will when a mesh has been imported into the scene.
  31982. */
  31983. onMeshImportedObservable: Observable<AbstractMesh>;
  31984. /**
  31985. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31986. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31987. */
  31988. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31989. /** @hidden */
  31990. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31991. /**
  31992. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31993. */
  31994. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31995. /**
  31996. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31997. */
  31998. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31999. /**
  32000. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32001. */
  32002. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32003. private _onPointerMove;
  32004. private _onPointerDown;
  32005. private _onPointerUp;
  32006. /** Callback called when a pointer move is detected */
  32007. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32008. /** Callback called when a pointer down is detected */
  32009. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32010. /** Callback called when a pointer up is detected */
  32011. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32012. /** Callback called when a pointer pick is detected */
  32013. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32014. /**
  32015. * 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).
  32016. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32017. */
  32018. onPrePointerObservable: Observable<PointerInfoPre>;
  32019. /**
  32020. * Observable event triggered each time an input event is received from the rendering canvas
  32021. */
  32022. onPointerObservable: Observable<PointerInfo>;
  32023. /**
  32024. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32025. */
  32026. readonly unTranslatedPointer: Vector2;
  32027. /** The distance in pixel that you have to move to prevent some events */
  32028. static DragMovementThreshold: number;
  32029. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32030. static LongPressDelay: number;
  32031. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32032. static DoubleClickDelay: number;
  32033. /** If you need to check double click without raising a single click at first click, enable this flag */
  32034. static ExclusiveDoubleClickMode: boolean;
  32035. private _initClickEvent;
  32036. private _initActionManager;
  32037. private _delayedSimpleClick;
  32038. private _delayedSimpleClickTimeout;
  32039. private _previousDelayedSimpleClickTimeout;
  32040. private _meshPickProceed;
  32041. private _previousButtonPressed;
  32042. private _currentPickResult;
  32043. private _previousPickResult;
  32044. private _totalPointersPressed;
  32045. private _doubleClickOccured;
  32046. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32047. cameraToUseForPointers: Nullable<Camera>;
  32048. private _pointerX;
  32049. private _pointerY;
  32050. private _unTranslatedPointerX;
  32051. private _unTranslatedPointerY;
  32052. private _startingPointerPosition;
  32053. private _previousStartingPointerPosition;
  32054. private _startingPointerTime;
  32055. private _previousStartingPointerTime;
  32056. private _pointerCaptures;
  32057. private _timeAccumulator;
  32058. private _currentStepId;
  32059. private _currentInternalStep;
  32060. /** @hidden */
  32061. _mirroredCameraPosition: Nullable<Vector3>;
  32062. /**
  32063. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32064. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32065. */
  32066. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32067. /**
  32068. * Observable event triggered each time an keyboard event is received from the hosting window
  32069. */
  32070. onKeyboardObservable: Observable<KeyboardInfo>;
  32071. private _onKeyDown;
  32072. private _onKeyUp;
  32073. private _onCanvasFocusObserver;
  32074. private _onCanvasBlurObserver;
  32075. private _useRightHandedSystem;
  32076. /**
  32077. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32078. */
  32079. useRightHandedSystem: boolean;
  32080. /**
  32081. * Sets the step Id used by deterministic lock step
  32082. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32083. * @param newStepId defines the step Id
  32084. */
  32085. setStepId(newStepId: number): void;
  32086. /**
  32087. * Gets the step Id used by deterministic lock step
  32088. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32089. * @returns the step Id
  32090. */
  32091. getStepId(): number;
  32092. /**
  32093. * Gets the internal step used by deterministic lock step
  32094. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32095. * @returns the internal step
  32096. */
  32097. getInternalStep(): number;
  32098. private _fogEnabled;
  32099. /**
  32100. * Gets or sets a boolean indicating if fog is enabled on this scene
  32101. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32102. * (Default is true)
  32103. */
  32104. fogEnabled: boolean;
  32105. private _fogMode;
  32106. /**
  32107. * Gets or sets the fog mode to use
  32108. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32109. * | mode | value |
  32110. * | --- | --- |
  32111. * | FOGMODE_NONE | 0 |
  32112. * | FOGMODE_EXP | 1 |
  32113. * | FOGMODE_EXP2 | 2 |
  32114. * | FOGMODE_LINEAR | 3 |
  32115. */
  32116. fogMode: number;
  32117. /**
  32118. * Gets or sets the fog color to use
  32119. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32120. * (Default is Color3(0.2, 0.2, 0.3))
  32121. */
  32122. fogColor: Color3;
  32123. /**
  32124. * Gets or sets the fog density to use
  32125. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32126. * (Default is 0.1)
  32127. */
  32128. fogDensity: number;
  32129. /**
  32130. * Gets or sets the fog start distance to use
  32131. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32132. * (Default is 0)
  32133. */
  32134. fogStart: number;
  32135. /**
  32136. * Gets or sets the fog end distance to use
  32137. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32138. * (Default is 1000)
  32139. */
  32140. fogEnd: number;
  32141. private _shadowsEnabled;
  32142. /**
  32143. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32144. */
  32145. shadowsEnabled: boolean;
  32146. private _lightsEnabled;
  32147. /**
  32148. * Gets or sets a boolean indicating if lights are enabled on this scene
  32149. */
  32150. lightsEnabled: boolean;
  32151. /** All of the active cameras added to this scene. */
  32152. activeCameras: Camera[];
  32153. /** @hidden */
  32154. _activeCamera: Nullable<Camera>;
  32155. /** Gets or sets the current active camera */
  32156. activeCamera: Nullable<Camera>;
  32157. private _defaultMaterial;
  32158. /** The default material used on meshes when no material is affected */
  32159. /** The default material used on meshes when no material is affected */
  32160. defaultMaterial: Material;
  32161. private _texturesEnabled;
  32162. /**
  32163. * Gets or sets a boolean indicating if textures are enabled on this scene
  32164. */
  32165. texturesEnabled: boolean;
  32166. /**
  32167. * Gets or sets a boolean indicating if particles are enabled on this scene
  32168. */
  32169. particlesEnabled: boolean;
  32170. /**
  32171. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32172. */
  32173. spritesEnabled: boolean;
  32174. private _skeletonsEnabled;
  32175. /**
  32176. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32177. */
  32178. skeletonsEnabled: boolean;
  32179. /**
  32180. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32181. */
  32182. lensFlaresEnabled: boolean;
  32183. /**
  32184. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32185. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32186. */
  32187. collisionsEnabled: boolean;
  32188. private _collisionCoordinator;
  32189. /** @hidden */
  32190. readonly collisionCoordinator: ICollisionCoordinator;
  32191. /**
  32192. * Defines the gravity applied to this scene (used only for collisions)
  32193. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32194. */
  32195. gravity: Vector3;
  32196. /**
  32197. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32198. */
  32199. postProcessesEnabled: boolean;
  32200. /**
  32201. * The list of postprocesses added to the scene
  32202. */
  32203. postProcesses: PostProcess[];
  32204. /**
  32205. * Gets the current postprocess manager
  32206. */
  32207. postProcessManager: PostProcessManager;
  32208. /**
  32209. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32210. */
  32211. renderTargetsEnabled: boolean;
  32212. /**
  32213. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32214. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32215. */
  32216. dumpNextRenderTargets: boolean;
  32217. /**
  32218. * The list of user defined render targets added to the scene
  32219. */
  32220. customRenderTargets: RenderTargetTexture[];
  32221. /**
  32222. * Defines if texture loading must be delayed
  32223. * If true, textures will only be loaded when they need to be rendered
  32224. */
  32225. useDelayedTextureLoading: boolean;
  32226. /**
  32227. * Gets the list of meshes imported to the scene through SceneLoader
  32228. */
  32229. importedMeshesFiles: String[];
  32230. /**
  32231. * Gets or sets a boolean indicating if probes are enabled on this scene
  32232. */
  32233. probesEnabled: boolean;
  32234. /**
  32235. * Gets or sets the current offline provider to use to store scene data
  32236. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32237. */
  32238. offlineProvider: IOfflineProvider;
  32239. /**
  32240. * Gets or sets the action manager associated with the scene
  32241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32242. */
  32243. actionManager: AbstractActionManager;
  32244. private _meshesForIntersections;
  32245. /**
  32246. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32247. */
  32248. proceduralTexturesEnabled: boolean;
  32249. private _engine;
  32250. private _totalVertices;
  32251. /** @hidden */
  32252. _activeIndices: PerfCounter;
  32253. /** @hidden */
  32254. _activeParticles: PerfCounter;
  32255. /** @hidden */
  32256. _activeBones: PerfCounter;
  32257. private _animationRatio;
  32258. /** @hidden */
  32259. _animationTimeLast: number;
  32260. /** @hidden */
  32261. _animationTime: number;
  32262. /**
  32263. * Gets or sets a general scale for animation speed
  32264. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32265. */
  32266. animationTimeScale: number;
  32267. /** @hidden */
  32268. _cachedMaterial: Nullable<Material>;
  32269. /** @hidden */
  32270. _cachedEffect: Nullable<Effect>;
  32271. /** @hidden */
  32272. _cachedVisibility: Nullable<number>;
  32273. private _renderId;
  32274. private _frameId;
  32275. private _executeWhenReadyTimeoutId;
  32276. private _intermediateRendering;
  32277. private _viewUpdateFlag;
  32278. private _projectionUpdateFlag;
  32279. /** @hidden */
  32280. _toBeDisposed: Nullable<IDisposable>[];
  32281. private _activeRequests;
  32282. /** @hidden */
  32283. _pendingData: any[];
  32284. private _isDisposed;
  32285. /**
  32286. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32287. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32288. */
  32289. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32290. private _activeMeshes;
  32291. private _processedMaterials;
  32292. private _renderTargets;
  32293. /** @hidden */
  32294. _activeParticleSystems: SmartArray<IParticleSystem>;
  32295. private _activeSkeletons;
  32296. private _softwareSkinnedMeshes;
  32297. private _renderingManager;
  32298. /** @hidden */
  32299. _activeAnimatables: Animatable[];
  32300. private _transformMatrix;
  32301. private _sceneUbo;
  32302. /** @hidden */
  32303. _viewMatrix: Matrix;
  32304. private _projectionMatrix;
  32305. private _wheelEventName;
  32306. /** @hidden */
  32307. _forcedViewPosition: Nullable<Vector3>;
  32308. /** @hidden */
  32309. _frustumPlanes: Plane[];
  32310. /**
  32311. * Gets the list of frustum planes (built from the active camera)
  32312. */
  32313. readonly frustumPlanes: Plane[];
  32314. /**
  32315. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32316. * This is useful if there are more lights that the maximum simulteanous authorized
  32317. */
  32318. requireLightSorting: boolean;
  32319. /** @hidden */
  32320. readonly useMaterialMeshMap: boolean;
  32321. /** @hidden */
  32322. readonly useClonedMeshhMap: boolean;
  32323. private _pointerOverMesh;
  32324. private _pickedDownMesh;
  32325. private _pickedUpMesh;
  32326. private _externalData;
  32327. private _uid;
  32328. /**
  32329. * @hidden
  32330. * Backing store of defined scene components.
  32331. */
  32332. _components: ISceneComponent[];
  32333. /**
  32334. * @hidden
  32335. * Backing store of defined scene components.
  32336. */
  32337. _serializableComponents: ISceneSerializableComponent[];
  32338. /**
  32339. * List of components to register on the next registration step.
  32340. */
  32341. private _transientComponents;
  32342. /**
  32343. * Registers the transient components if needed.
  32344. */
  32345. private _registerTransientComponents;
  32346. /**
  32347. * @hidden
  32348. * Add a component to the scene.
  32349. * Note that the ccomponent could be registered on th next frame if this is called after
  32350. * the register component stage.
  32351. * @param component Defines the component to add to the scene
  32352. */
  32353. _addComponent(component: ISceneComponent): void;
  32354. /**
  32355. * @hidden
  32356. * Gets a component from the scene.
  32357. * @param name defines the name of the component to retrieve
  32358. * @returns the component or null if not present
  32359. */
  32360. _getComponent(name: string): Nullable<ISceneComponent>;
  32361. /**
  32362. * @hidden
  32363. * Defines the actions happening before camera updates.
  32364. */
  32365. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32366. /**
  32367. * @hidden
  32368. * Defines the actions happening before clear the canvas.
  32369. */
  32370. _beforeClearStage: Stage<SimpleStageAction>;
  32371. /**
  32372. * @hidden
  32373. * Defines the actions when collecting render targets for the frame.
  32374. */
  32375. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32376. /**
  32377. * @hidden
  32378. * Defines the actions happening for one camera in the frame.
  32379. */
  32380. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32381. /**
  32382. * @hidden
  32383. * Defines the actions happening during the per mesh ready checks.
  32384. */
  32385. _isReadyForMeshStage: Stage<MeshStageAction>;
  32386. /**
  32387. * @hidden
  32388. * Defines the actions happening before evaluate active mesh checks.
  32389. */
  32390. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32391. /**
  32392. * @hidden
  32393. * Defines the actions happening during the evaluate sub mesh checks.
  32394. */
  32395. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32396. /**
  32397. * @hidden
  32398. * Defines the actions happening during the active mesh stage.
  32399. */
  32400. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32401. /**
  32402. * @hidden
  32403. * Defines the actions happening during the per camera render target step.
  32404. */
  32405. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32406. /**
  32407. * @hidden
  32408. * Defines the actions happening just before the active camera is drawing.
  32409. */
  32410. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32411. /**
  32412. * @hidden
  32413. * Defines the actions happening just before a render target is drawing.
  32414. */
  32415. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32416. /**
  32417. * @hidden
  32418. * Defines the actions happening just before a rendering group is drawing.
  32419. */
  32420. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32421. /**
  32422. * @hidden
  32423. * Defines the actions happening just before a mesh is drawing.
  32424. */
  32425. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32426. /**
  32427. * @hidden
  32428. * Defines the actions happening just after a mesh has been drawn.
  32429. */
  32430. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32431. /**
  32432. * @hidden
  32433. * Defines the actions happening just after a rendering group has been drawn.
  32434. */
  32435. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32436. /**
  32437. * @hidden
  32438. * Defines the actions happening just after the active camera has been drawn.
  32439. */
  32440. _afterCameraDrawStage: Stage<CameraStageAction>;
  32441. /**
  32442. * @hidden
  32443. * Defines the actions happening just after a render target has been drawn.
  32444. */
  32445. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32446. /**
  32447. * @hidden
  32448. * Defines the actions happening just after rendering all cameras and computing intersections.
  32449. */
  32450. _afterRenderStage: Stage<SimpleStageAction>;
  32451. /**
  32452. * @hidden
  32453. * Defines the actions happening when a pointer move event happens.
  32454. */
  32455. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32456. /**
  32457. * @hidden
  32458. * Defines the actions happening when a pointer down event happens.
  32459. */
  32460. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32461. /**
  32462. * @hidden
  32463. * Defines the actions happening when a pointer up event happens.
  32464. */
  32465. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32466. /**
  32467. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32468. */
  32469. private geometriesByUniqueId;
  32470. /**
  32471. * Creates a new Scene
  32472. * @param engine defines the engine to use to render this scene
  32473. * @param options defines the scene options
  32474. */
  32475. constructor(engine: Engine, options?: SceneOptions);
  32476. /**
  32477. * Gets a string idenfifying the name of the class
  32478. * @returns "Scene" string
  32479. */
  32480. getClassName(): string;
  32481. private _defaultMeshCandidates;
  32482. /**
  32483. * @hidden
  32484. */
  32485. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32486. private _defaultSubMeshCandidates;
  32487. /**
  32488. * @hidden
  32489. */
  32490. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32491. /**
  32492. * Sets the default candidate providers for the scene.
  32493. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32494. * and getCollidingSubMeshCandidates to their default function
  32495. */
  32496. setDefaultCandidateProviders(): void;
  32497. /**
  32498. * Gets the mesh that is currently under the pointer
  32499. */
  32500. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32501. /**
  32502. * Gets or sets the current on-screen X position of the pointer
  32503. */
  32504. pointerX: number;
  32505. /**
  32506. * Gets or sets the current on-screen Y position of the pointer
  32507. */
  32508. pointerY: number;
  32509. /**
  32510. * Gets the cached material (ie. the latest rendered one)
  32511. * @returns the cached material
  32512. */
  32513. getCachedMaterial(): Nullable<Material>;
  32514. /**
  32515. * Gets the cached effect (ie. the latest rendered one)
  32516. * @returns the cached effect
  32517. */
  32518. getCachedEffect(): Nullable<Effect>;
  32519. /**
  32520. * Gets the cached visibility state (ie. the latest rendered one)
  32521. * @returns the cached visibility state
  32522. */
  32523. getCachedVisibility(): Nullable<number>;
  32524. /**
  32525. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32526. * @param material defines the current material
  32527. * @param effect defines the current effect
  32528. * @param visibility defines the current visibility state
  32529. * @returns true if one parameter is not cached
  32530. */
  32531. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32532. /**
  32533. * Gets the engine associated with the scene
  32534. * @returns an Engine
  32535. */
  32536. getEngine(): Engine;
  32537. /**
  32538. * Gets the total number of vertices rendered per frame
  32539. * @returns the total number of vertices rendered per frame
  32540. */
  32541. getTotalVertices(): number;
  32542. /**
  32543. * Gets the performance counter for total vertices
  32544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32545. */
  32546. readonly totalVerticesPerfCounter: PerfCounter;
  32547. /**
  32548. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32549. * @returns the total number of active indices rendered per frame
  32550. */
  32551. getActiveIndices(): number;
  32552. /**
  32553. * Gets the performance counter for active indices
  32554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32555. */
  32556. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32557. /**
  32558. * Gets the total number of active particles rendered per frame
  32559. * @returns the total number of active particles rendered per frame
  32560. */
  32561. getActiveParticles(): number;
  32562. /**
  32563. * Gets the performance counter for active particles
  32564. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32565. */
  32566. readonly activeParticlesPerfCounter: PerfCounter;
  32567. /**
  32568. * Gets the total number of active bones rendered per frame
  32569. * @returns the total number of active bones rendered per frame
  32570. */
  32571. getActiveBones(): number;
  32572. /**
  32573. * Gets the performance counter for active bones
  32574. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32575. */
  32576. readonly activeBonesPerfCounter: PerfCounter;
  32577. /**
  32578. * Gets the array of active meshes
  32579. * @returns an array of AbstractMesh
  32580. */
  32581. getActiveMeshes(): SmartArray<AbstractMesh>;
  32582. /**
  32583. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32584. * @returns a number
  32585. */
  32586. getAnimationRatio(): number;
  32587. /**
  32588. * Gets an unique Id for the current render phase
  32589. * @returns a number
  32590. */
  32591. getRenderId(): number;
  32592. /**
  32593. * Gets an unique Id for the current frame
  32594. * @returns a number
  32595. */
  32596. getFrameId(): number;
  32597. /** Call this function if you want to manually increment the render Id*/
  32598. incrementRenderId(): void;
  32599. private _updatePointerPosition;
  32600. private _createUbo;
  32601. private _setRayOnPointerInfo;
  32602. /**
  32603. * Use this method to simulate a pointer move on a mesh
  32604. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32605. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32606. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32607. * @returns the current scene
  32608. */
  32609. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32610. private _processPointerMove;
  32611. private _checkPrePointerObservable;
  32612. /**
  32613. * Use this method to simulate a pointer down on a mesh
  32614. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32615. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32616. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32617. * @returns the current scene
  32618. */
  32619. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32620. private _processPointerDown;
  32621. /**
  32622. * Use this method to simulate a pointer up on a mesh
  32623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32626. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32627. * @returns the current scene
  32628. */
  32629. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32630. private _processPointerUp;
  32631. /**
  32632. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32633. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32634. * @returns true if the pointer was captured
  32635. */
  32636. isPointerCaptured(pointerId?: number): boolean;
  32637. /** @hidden */
  32638. _isPointerSwiping(): boolean;
  32639. /**
  32640. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32641. * @param attachUp defines if you want to attach events to pointerup
  32642. * @param attachDown defines if you want to attach events to pointerdown
  32643. * @param attachMove defines if you want to attach events to pointermove
  32644. */
  32645. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32646. /** Detaches all event handlers*/
  32647. detachControl(): void;
  32648. /**
  32649. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32650. * Delay loaded resources are not taking in account
  32651. * @return true if all required resources are ready
  32652. */
  32653. isReady(): boolean;
  32654. /** Resets all cached information relative to material (including effect and visibility) */
  32655. resetCachedMaterial(): void;
  32656. /**
  32657. * Registers a function to be called before every frame render
  32658. * @param func defines the function to register
  32659. */
  32660. registerBeforeRender(func: () => void): void;
  32661. /**
  32662. * Unregisters a function called before every frame render
  32663. * @param func defines the function to unregister
  32664. */
  32665. unregisterBeforeRender(func: () => void): void;
  32666. /**
  32667. * Registers a function to be called after every frame render
  32668. * @param func defines the function to register
  32669. */
  32670. registerAfterRender(func: () => void): void;
  32671. /**
  32672. * Unregisters a function called after every frame render
  32673. * @param func defines the function to unregister
  32674. */
  32675. unregisterAfterRender(func: () => void): void;
  32676. private _executeOnceBeforeRender;
  32677. /**
  32678. * The provided function will run before render once and will be disposed afterwards.
  32679. * A timeout delay can be provided so that the function will be executed in N ms.
  32680. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32681. * @param func The function to be executed.
  32682. * @param timeout optional delay in ms
  32683. */
  32684. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32685. /** @hidden */
  32686. _addPendingData(data: any): void;
  32687. /** @hidden */
  32688. _removePendingData(data: any): void;
  32689. /**
  32690. * Returns the number of items waiting to be loaded
  32691. * @returns the number of items waiting to be loaded
  32692. */
  32693. getWaitingItemsCount(): number;
  32694. /**
  32695. * Returns a boolean indicating if the scene is still loading data
  32696. */
  32697. readonly isLoading: boolean;
  32698. /**
  32699. * Registers a function to be executed when the scene is ready
  32700. * @param {Function} func - the function to be executed
  32701. */
  32702. executeWhenReady(func: () => void): void;
  32703. /**
  32704. * Returns a promise that resolves when the scene is ready
  32705. * @returns A promise that resolves when the scene is ready
  32706. */
  32707. whenReadyAsync(): Promise<void>;
  32708. /** @hidden */
  32709. _checkIsReady(): void;
  32710. /**
  32711. * Gets all animatable attached to the scene
  32712. */
  32713. readonly animatables: Animatable[];
  32714. /**
  32715. * Resets the last animation time frame.
  32716. * Useful to override when animations start running when loading a scene for the first time.
  32717. */
  32718. resetLastAnimationTimeFrame(): void;
  32719. /**
  32720. * Gets the current view matrix
  32721. * @returns a Matrix
  32722. */
  32723. getViewMatrix(): Matrix;
  32724. /**
  32725. * Gets the current projection matrix
  32726. * @returns a Matrix
  32727. */
  32728. getProjectionMatrix(): Matrix;
  32729. /**
  32730. * Gets the current transform matrix
  32731. * @returns a Matrix made of View * Projection
  32732. */
  32733. getTransformMatrix(): Matrix;
  32734. /**
  32735. * Sets the current transform matrix
  32736. * @param viewL defines the View matrix to use
  32737. * @param projectionL defines the Projection matrix to use
  32738. * @param viewR defines the right View matrix to use (if provided)
  32739. * @param projectionR defines the right Projection matrix to use (if provided)
  32740. */
  32741. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32742. /**
  32743. * Gets the uniform buffer used to store scene data
  32744. * @returns a UniformBuffer
  32745. */
  32746. getSceneUniformBuffer(): UniformBuffer;
  32747. /**
  32748. * Gets an unique (relatively to the current scene) Id
  32749. * @returns an unique number for the scene
  32750. */
  32751. getUniqueId(): number;
  32752. /**
  32753. * Add a mesh to the list of scene's meshes
  32754. * @param newMesh defines the mesh to add
  32755. * @param recursive if all child meshes should also be added to the scene
  32756. */
  32757. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32758. /**
  32759. * Remove a mesh for the list of scene's meshes
  32760. * @param toRemove defines the mesh to remove
  32761. * @param recursive if all child meshes should also be removed from the scene
  32762. * @returns the index where the mesh was in the mesh list
  32763. */
  32764. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32765. /**
  32766. * Add a transform node to the list of scene's transform nodes
  32767. * @param newTransformNode defines the transform node to add
  32768. */
  32769. addTransformNode(newTransformNode: TransformNode): void;
  32770. /**
  32771. * Remove a transform node for the list of scene's transform nodes
  32772. * @param toRemove defines the transform node to remove
  32773. * @returns the index where the transform node was in the transform node list
  32774. */
  32775. removeTransformNode(toRemove: TransformNode): number;
  32776. /**
  32777. * Remove a skeleton for the list of scene's skeletons
  32778. * @param toRemove defines the skeleton to remove
  32779. * @returns the index where the skeleton was in the skeleton list
  32780. */
  32781. removeSkeleton(toRemove: Skeleton): number;
  32782. /**
  32783. * Remove a morph target for the list of scene's morph targets
  32784. * @param toRemove defines the morph target to remove
  32785. * @returns the index where the morph target was in the morph target list
  32786. */
  32787. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32788. /**
  32789. * Remove a light for the list of scene's lights
  32790. * @param toRemove defines the light to remove
  32791. * @returns the index where the light was in the light list
  32792. */
  32793. removeLight(toRemove: Light): number;
  32794. /**
  32795. * Remove a camera for the list of scene's cameras
  32796. * @param toRemove defines the camera to remove
  32797. * @returns the index where the camera was in the camera list
  32798. */
  32799. removeCamera(toRemove: Camera): number;
  32800. /**
  32801. * Remove a particle system for the list of scene's particle systems
  32802. * @param toRemove defines the particle system to remove
  32803. * @returns the index where the particle system was in the particle system list
  32804. */
  32805. removeParticleSystem(toRemove: IParticleSystem): number;
  32806. /**
  32807. * Remove a animation for the list of scene's animations
  32808. * @param toRemove defines the animation to remove
  32809. * @returns the index where the animation was in the animation list
  32810. */
  32811. removeAnimation(toRemove: Animation): number;
  32812. /**
  32813. * Removes the given animation group from this scene.
  32814. * @param toRemove The animation group to remove
  32815. * @returns The index of the removed animation group
  32816. */
  32817. removeAnimationGroup(toRemove: AnimationGroup): number;
  32818. /**
  32819. * Removes the given multi-material from this scene.
  32820. * @param toRemove The multi-material to remove
  32821. * @returns The index of the removed multi-material
  32822. */
  32823. removeMultiMaterial(toRemove: MultiMaterial): number;
  32824. /**
  32825. * Removes the given material from this scene.
  32826. * @param toRemove The material to remove
  32827. * @returns The index of the removed material
  32828. */
  32829. removeMaterial(toRemove: Material): number;
  32830. /**
  32831. * Removes the given action manager from this scene.
  32832. * @param toRemove The action manager to remove
  32833. * @returns The index of the removed action manager
  32834. */
  32835. removeActionManager(toRemove: AbstractActionManager): number;
  32836. /**
  32837. * Removes the given texture from this scene.
  32838. * @param toRemove The texture to remove
  32839. * @returns The index of the removed texture
  32840. */
  32841. removeTexture(toRemove: BaseTexture): number;
  32842. /**
  32843. * Adds the given light to this scene
  32844. * @param newLight The light to add
  32845. */
  32846. addLight(newLight: Light): void;
  32847. /**
  32848. * Sorts the list list based on light priorities
  32849. */
  32850. sortLightsByPriority(): void;
  32851. /**
  32852. * Adds the given camera to this scene
  32853. * @param newCamera The camera to add
  32854. */
  32855. addCamera(newCamera: Camera): void;
  32856. /**
  32857. * Adds the given skeleton to this scene
  32858. * @param newSkeleton The skeleton to add
  32859. */
  32860. addSkeleton(newSkeleton: Skeleton): void;
  32861. /**
  32862. * Adds the given particle system to this scene
  32863. * @param newParticleSystem The particle system to add
  32864. */
  32865. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32866. /**
  32867. * Adds the given animation to this scene
  32868. * @param newAnimation The animation to add
  32869. */
  32870. addAnimation(newAnimation: Animation): void;
  32871. /**
  32872. * Adds the given animation group to this scene.
  32873. * @param newAnimationGroup The animation group to add
  32874. */
  32875. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32876. /**
  32877. * Adds the given multi-material to this scene
  32878. * @param newMultiMaterial The multi-material to add
  32879. */
  32880. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32881. /**
  32882. * Adds the given material to this scene
  32883. * @param newMaterial The material to add
  32884. */
  32885. addMaterial(newMaterial: Material): void;
  32886. /**
  32887. * Adds the given morph target to this scene
  32888. * @param newMorphTargetManager The morph target to add
  32889. */
  32890. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32891. /**
  32892. * Adds the given geometry to this scene
  32893. * @param newGeometry The geometry to add
  32894. */
  32895. addGeometry(newGeometry: Geometry): void;
  32896. /**
  32897. * Adds the given action manager to this scene
  32898. * @param newActionManager The action manager to add
  32899. */
  32900. addActionManager(newActionManager: AbstractActionManager): void;
  32901. /**
  32902. * Adds the given texture to this scene.
  32903. * @param newTexture The texture to add
  32904. */
  32905. addTexture(newTexture: BaseTexture): void;
  32906. /**
  32907. * Switch active camera
  32908. * @param newCamera defines the new active camera
  32909. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32910. */
  32911. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32912. /**
  32913. * sets the active camera of the scene using its ID
  32914. * @param id defines the camera's ID
  32915. * @return the new active camera or null if none found.
  32916. */
  32917. setActiveCameraByID(id: string): Nullable<Camera>;
  32918. /**
  32919. * sets the active camera of the scene using its name
  32920. * @param name defines the camera's name
  32921. * @returns the new active camera or null if none found.
  32922. */
  32923. setActiveCameraByName(name: string): Nullable<Camera>;
  32924. /**
  32925. * get an animation group using its name
  32926. * @param name defines the material's name
  32927. * @return the animation group or null if none found.
  32928. */
  32929. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32930. /**
  32931. * Get a material using its unique id
  32932. * @param uniqueId defines the material's unique id
  32933. * @return the material or null if none found.
  32934. */
  32935. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32936. /**
  32937. * get a material using its id
  32938. * @param id defines the material's ID
  32939. * @return the material or null if none found.
  32940. */
  32941. getMaterialByID(id: string): Nullable<Material>;
  32942. /**
  32943. * Gets a material using its name
  32944. * @param name defines the material's name
  32945. * @return the material or null if none found.
  32946. */
  32947. getMaterialByName(name: string): Nullable<Material>;
  32948. /**
  32949. * Gets a camera using its id
  32950. * @param id defines the id to look for
  32951. * @returns the camera or null if not found
  32952. */
  32953. getCameraByID(id: string): Nullable<Camera>;
  32954. /**
  32955. * Gets a camera using its unique id
  32956. * @param uniqueId defines the unique id to look for
  32957. * @returns the camera or null if not found
  32958. */
  32959. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32960. /**
  32961. * Gets a camera using its name
  32962. * @param name defines the camera's name
  32963. * @return the camera or null if none found.
  32964. */
  32965. getCameraByName(name: string): Nullable<Camera>;
  32966. /**
  32967. * Gets a bone using its id
  32968. * @param id defines the bone's id
  32969. * @return the bone or null if not found
  32970. */
  32971. getBoneByID(id: string): Nullable<Bone>;
  32972. /**
  32973. * Gets a bone using its id
  32974. * @param name defines the bone's name
  32975. * @return the bone or null if not found
  32976. */
  32977. getBoneByName(name: string): Nullable<Bone>;
  32978. /**
  32979. * Gets a light node using its name
  32980. * @param name defines the the light's name
  32981. * @return the light or null if none found.
  32982. */
  32983. getLightByName(name: string): Nullable<Light>;
  32984. /**
  32985. * Gets a light node using its id
  32986. * @param id defines the light's id
  32987. * @return the light or null if none found.
  32988. */
  32989. getLightByID(id: string): Nullable<Light>;
  32990. /**
  32991. * Gets a light node using its scene-generated unique ID
  32992. * @param uniqueId defines the light's unique id
  32993. * @return the light or null if none found.
  32994. */
  32995. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32996. /**
  32997. * Gets a particle system by id
  32998. * @param id defines the particle system id
  32999. * @return the corresponding system or null if none found
  33000. */
  33001. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33002. /**
  33003. * Gets a geometry using its ID
  33004. * @param id defines the geometry's id
  33005. * @return the geometry or null if none found.
  33006. */
  33007. getGeometryByID(id: string): Nullable<Geometry>;
  33008. private _getGeometryByUniqueID;
  33009. /**
  33010. * Add a new geometry to this scene
  33011. * @param geometry defines the geometry to be added to the scene.
  33012. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33013. * @return a boolean defining if the geometry was added or not
  33014. */
  33015. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33016. /**
  33017. * Removes an existing geometry
  33018. * @param geometry defines the geometry to be removed from the scene
  33019. * @return a boolean defining if the geometry was removed or not
  33020. */
  33021. removeGeometry(geometry: Geometry): boolean;
  33022. /**
  33023. * Gets the list of geometries attached to the scene
  33024. * @returns an array of Geometry
  33025. */
  33026. getGeometries(): Geometry[];
  33027. /**
  33028. * Gets the first added mesh found of a given ID
  33029. * @param id defines the id to search for
  33030. * @return the mesh found or null if not found at all
  33031. */
  33032. getMeshByID(id: string): Nullable<AbstractMesh>;
  33033. /**
  33034. * Gets a list of meshes using their id
  33035. * @param id defines the id to search for
  33036. * @returns a list of meshes
  33037. */
  33038. getMeshesByID(id: string): Array<AbstractMesh>;
  33039. /**
  33040. * Gets the first added transform node found of a given ID
  33041. * @param id defines the id to search for
  33042. * @return the found transform node or null if not found at all.
  33043. */
  33044. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33045. /**
  33046. * Gets a transform node with its auto-generated unique id
  33047. * @param uniqueId efines the unique id to search for
  33048. * @return the found transform node or null if not found at all.
  33049. */
  33050. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33051. /**
  33052. * Gets a list of transform nodes using their id
  33053. * @param id defines the id to search for
  33054. * @returns a list of transform nodes
  33055. */
  33056. getTransformNodesByID(id: string): Array<TransformNode>;
  33057. /**
  33058. * Gets a mesh with its auto-generated unique id
  33059. * @param uniqueId defines the unique id to search for
  33060. * @return the found mesh or null if not found at all.
  33061. */
  33062. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33063. /**
  33064. * Gets a the last added mesh using a given id
  33065. * @param id defines the id to search for
  33066. * @return the found mesh or null if not found at all.
  33067. */
  33068. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33069. /**
  33070. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33071. * @param id defines the id to search for
  33072. * @return the found node or null if not found at all
  33073. */
  33074. getLastEntryByID(id: string): Nullable<Node>;
  33075. /**
  33076. * Gets a node (Mesh, Camera, Light) using a given id
  33077. * @param id defines the id to search for
  33078. * @return the found node or null if not found at all
  33079. */
  33080. getNodeByID(id: string): Nullable<Node>;
  33081. /**
  33082. * Gets a node (Mesh, Camera, Light) using a given name
  33083. * @param name defines the name to search for
  33084. * @return the found node or null if not found at all.
  33085. */
  33086. getNodeByName(name: string): Nullable<Node>;
  33087. /**
  33088. * Gets a mesh using a given name
  33089. * @param name defines the name to search for
  33090. * @return the found mesh or null if not found at all.
  33091. */
  33092. getMeshByName(name: string): Nullable<AbstractMesh>;
  33093. /**
  33094. * Gets a transform node using a given name
  33095. * @param name defines the name to search for
  33096. * @return the found transform node or null if not found at all.
  33097. */
  33098. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33099. /**
  33100. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33101. * @param id defines the id to search for
  33102. * @return the found skeleton or null if not found at all.
  33103. */
  33104. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33105. /**
  33106. * Gets a skeleton using a given auto generated unique id
  33107. * @param uniqueId defines the unique id to search for
  33108. * @return the found skeleton or null if not found at all.
  33109. */
  33110. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33111. /**
  33112. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33113. * @param id defines the id to search for
  33114. * @return the found skeleton or null if not found at all.
  33115. */
  33116. getSkeletonById(id: string): Nullable<Skeleton>;
  33117. /**
  33118. * Gets a skeleton using a given name
  33119. * @param name defines the name to search for
  33120. * @return the found skeleton or null if not found at all.
  33121. */
  33122. getSkeletonByName(name: string): Nullable<Skeleton>;
  33123. /**
  33124. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33125. * @param id defines the id to search for
  33126. * @return the found morph target manager or null if not found at all.
  33127. */
  33128. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33129. /**
  33130. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33131. * @param id defines the id to search for
  33132. * @return the found morph target or null if not found at all.
  33133. */
  33134. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33135. /**
  33136. * Gets a boolean indicating if the given mesh is active
  33137. * @param mesh defines the mesh to look for
  33138. * @returns true if the mesh is in the active list
  33139. */
  33140. isActiveMesh(mesh: AbstractMesh): boolean;
  33141. /**
  33142. * Return a unique id as a string which can serve as an identifier for the scene
  33143. */
  33144. readonly uid: string;
  33145. /**
  33146. * Add an externaly attached data from its key.
  33147. * This method call will fail and return false, if such key already exists.
  33148. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33149. * @param key the unique key that identifies the data
  33150. * @param data the data object to associate to the key for this Engine instance
  33151. * @return true if no such key were already present and the data was added successfully, false otherwise
  33152. */
  33153. addExternalData<T>(key: string, data: T): boolean;
  33154. /**
  33155. * Get an externaly attached data from its key
  33156. * @param key the unique key that identifies the data
  33157. * @return the associated data, if present (can be null), or undefined if not present
  33158. */
  33159. getExternalData<T>(key: string): Nullable<T>;
  33160. /**
  33161. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33162. * @param key the unique key that identifies the data
  33163. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33164. * @return the associated data, can be null if the factory returned null.
  33165. */
  33166. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33167. /**
  33168. * Remove an externaly attached data from the Engine instance
  33169. * @param key the unique key that identifies the data
  33170. * @return true if the data was successfully removed, false if it doesn't exist
  33171. */
  33172. removeExternalData(key: string): boolean;
  33173. private _evaluateSubMesh;
  33174. /**
  33175. * Clear the processed materials smart array preventing retention point in material dispose.
  33176. */
  33177. freeProcessedMaterials(): void;
  33178. private _preventFreeActiveMeshesAndRenderingGroups;
  33179. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33180. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33181. * when disposing several meshes in a row or a hierarchy of meshes.
  33182. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33183. */
  33184. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33185. /**
  33186. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33187. */
  33188. freeActiveMeshes(): void;
  33189. /**
  33190. * Clear the info related to rendering groups preventing retention points during dispose.
  33191. */
  33192. freeRenderingGroups(): void;
  33193. /** @hidden */
  33194. _isInIntermediateRendering(): boolean;
  33195. /**
  33196. * Lambda returning the list of potentially active meshes.
  33197. */
  33198. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33199. /**
  33200. * Lambda returning the list of potentially active sub meshes.
  33201. */
  33202. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33203. /**
  33204. * Lambda returning the list of potentially intersecting sub meshes.
  33205. */
  33206. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33207. /**
  33208. * Lambda returning the list of potentially colliding sub meshes.
  33209. */
  33210. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33211. private _activeMeshesFrozen;
  33212. /**
  33213. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33214. * @returns the current scene
  33215. */
  33216. freezeActiveMeshes(): Scene;
  33217. /**
  33218. * Use this function to restart evaluating active meshes on every frame
  33219. * @returns the current scene
  33220. */
  33221. unfreezeActiveMeshes(): Scene;
  33222. private _evaluateActiveMeshes;
  33223. private _activeMesh;
  33224. /**
  33225. * Update the transform matrix to update from the current active camera
  33226. * @param force defines a boolean used to force the update even if cache is up to date
  33227. */
  33228. updateTransformMatrix(force?: boolean): void;
  33229. private _bindFrameBuffer;
  33230. /** @hidden */
  33231. _allowPostProcessClearColor: boolean;
  33232. /** @hidden */
  33233. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33234. private _processSubCameras;
  33235. private _checkIntersections;
  33236. /** @hidden */
  33237. _advancePhysicsEngineStep(step: number): void;
  33238. /**
  33239. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33240. */
  33241. getDeterministicFrameTime: () => number;
  33242. /** @hidden */
  33243. _animate(): void;
  33244. /**
  33245. * Render the scene
  33246. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33247. */
  33248. render(updateCameras?: boolean): void;
  33249. /**
  33250. * Freeze all materials
  33251. * A frozen material will not be updatable but should be faster to render
  33252. */
  33253. freezeMaterials(): void;
  33254. /**
  33255. * Unfreeze all materials
  33256. * A frozen material will not be updatable but should be faster to render
  33257. */
  33258. unfreezeMaterials(): void;
  33259. /**
  33260. * Releases all held ressources
  33261. */
  33262. dispose(): void;
  33263. /**
  33264. * Gets if the scene is already disposed
  33265. */
  33266. readonly isDisposed: boolean;
  33267. /**
  33268. * Call this function to reduce memory footprint of the scene.
  33269. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33270. */
  33271. clearCachedVertexData(): void;
  33272. /**
  33273. * This function will remove the local cached buffer data from texture.
  33274. * It will save memory but will prevent the texture from being rebuilt
  33275. */
  33276. cleanCachedTextureBuffer(): void;
  33277. /**
  33278. * Get the world extend vectors with an optional filter
  33279. *
  33280. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33281. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33282. */
  33283. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33284. min: Vector3;
  33285. max: Vector3;
  33286. };
  33287. /**
  33288. * Creates a ray that can be used to pick in the scene
  33289. * @param x defines the x coordinate of the origin (on-screen)
  33290. * @param y defines the y coordinate of the origin (on-screen)
  33291. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33292. * @param camera defines the camera to use for the picking
  33293. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33294. * @returns a Ray
  33295. */
  33296. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33297. /**
  33298. * Creates a ray that can be used to pick in the scene
  33299. * @param x defines the x coordinate of the origin (on-screen)
  33300. * @param y defines the y coordinate of the origin (on-screen)
  33301. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33302. * @param result defines the ray where to store the picking ray
  33303. * @param camera defines the camera to use for the picking
  33304. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33305. * @returns the current scene
  33306. */
  33307. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33308. /**
  33309. * Creates a ray that can be used to pick in the scene
  33310. * @param x defines the x coordinate of the origin (on-screen)
  33311. * @param y defines the y coordinate of the origin (on-screen)
  33312. * @param camera defines the camera to use for the picking
  33313. * @returns a Ray
  33314. */
  33315. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33316. /**
  33317. * Creates a ray that can be used to pick in the scene
  33318. * @param x defines the x coordinate of the origin (on-screen)
  33319. * @param y defines the y coordinate of the origin (on-screen)
  33320. * @param result defines the ray where to store the picking ray
  33321. * @param camera defines the camera to use for the picking
  33322. * @returns the current scene
  33323. */
  33324. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33325. /** Launch a ray to try to pick a mesh in the scene
  33326. * @param x position on screen
  33327. * @param y position on screen
  33328. * @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
  33329. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33330. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33331. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33332. * @returns a PickingInfo
  33333. */
  33334. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33335. /** Use the given ray to pick a mesh in the scene
  33336. * @param ray The ray to use to pick meshes
  33337. * @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
  33338. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33339. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33340. * @returns a PickingInfo
  33341. */
  33342. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33343. /**
  33344. * Launch a ray to try to pick a mesh in the scene
  33345. * @param x X position on screen
  33346. * @param y Y position on screen
  33347. * @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
  33348. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33349. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33350. * @returns an array of PickingInfo
  33351. */
  33352. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33353. /**
  33354. * Launch a ray to try to pick a mesh in the scene
  33355. * @param ray Ray to use
  33356. * @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
  33357. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33358. * @returns an array of PickingInfo
  33359. */
  33360. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33361. /**
  33362. * Force the value of meshUnderPointer
  33363. * @param mesh defines the mesh to use
  33364. */
  33365. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33366. /**
  33367. * Gets the mesh under the pointer
  33368. * @returns a Mesh or null if no mesh is under the pointer
  33369. */
  33370. getPointerOverMesh(): Nullable<AbstractMesh>;
  33371. /** @hidden */
  33372. _rebuildGeometries(): void;
  33373. /** @hidden */
  33374. _rebuildTextures(): void;
  33375. private _getByTags;
  33376. /**
  33377. * Get a list of meshes by tags
  33378. * @param tagsQuery defines the tags query to use
  33379. * @param forEach defines a predicate used to filter results
  33380. * @returns an array of Mesh
  33381. */
  33382. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33383. /**
  33384. * Get a list of cameras by tags
  33385. * @param tagsQuery defines the tags query to use
  33386. * @param forEach defines a predicate used to filter results
  33387. * @returns an array of Camera
  33388. */
  33389. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33390. /**
  33391. * Get a list of lights by tags
  33392. * @param tagsQuery defines the tags query to use
  33393. * @param forEach defines a predicate used to filter results
  33394. * @returns an array of Light
  33395. */
  33396. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33397. /**
  33398. * Get a list of materials by tags
  33399. * @param tagsQuery defines the tags query to use
  33400. * @param forEach defines a predicate used to filter results
  33401. * @returns an array of Material
  33402. */
  33403. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33404. /**
  33405. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33406. * This allowed control for front to back rendering or reversly depending of the special needs.
  33407. *
  33408. * @param renderingGroupId The rendering group id corresponding to its index
  33409. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33410. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33411. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33412. */
  33413. 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;
  33414. /**
  33415. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33416. *
  33417. * @param renderingGroupId The rendering group id corresponding to its index
  33418. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33419. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33420. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33421. */
  33422. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33423. /**
  33424. * Gets the current auto clear configuration for one rendering group of the rendering
  33425. * manager.
  33426. * @param index the rendering group index to get the information for
  33427. * @returns The auto clear setup for the requested rendering group
  33428. */
  33429. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33430. private _blockMaterialDirtyMechanism;
  33431. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33432. blockMaterialDirtyMechanism: boolean;
  33433. /**
  33434. * Will flag all materials as dirty to trigger new shader compilation
  33435. * @param flag defines the flag used to specify which material part must be marked as dirty
  33436. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33437. */
  33438. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33439. /** @hidden */
  33440. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33441. /** @hidden */
  33442. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33443. }
  33444. }
  33445. declare module BABYLON {
  33446. /**
  33447. * Set of assets to keep when moving a scene into an asset container.
  33448. */
  33449. export class KeepAssets extends AbstractScene {
  33450. }
  33451. /**
  33452. * Container with a set of assets that can be added or removed from a scene.
  33453. */
  33454. export class AssetContainer extends AbstractScene {
  33455. /**
  33456. * The scene the AssetContainer belongs to.
  33457. */
  33458. scene: Scene;
  33459. /**
  33460. * Instantiates an AssetContainer.
  33461. * @param scene The scene the AssetContainer belongs to.
  33462. */
  33463. constructor(scene: Scene);
  33464. /**
  33465. * Adds all the assets from the container to the scene.
  33466. */
  33467. addAllToScene(): void;
  33468. /**
  33469. * Removes all the assets in the container from the scene
  33470. */
  33471. removeAllFromScene(): void;
  33472. /**
  33473. * Disposes all the assets in the container
  33474. */
  33475. dispose(): void;
  33476. private _moveAssets;
  33477. /**
  33478. * Removes all the assets contained in the scene and adds them to the container.
  33479. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33480. */
  33481. moveAllFromScene(keepAssets?: KeepAssets): void;
  33482. /**
  33483. * 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.
  33484. * @returns the root mesh
  33485. */
  33486. createRootMesh(): Mesh;
  33487. }
  33488. }
  33489. declare module BABYLON {
  33490. /**
  33491. * Defines how the parser contract is defined.
  33492. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33493. */
  33494. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33495. /**
  33496. * Defines how the individual parser contract is defined.
  33497. * These parser can parse an individual asset
  33498. */
  33499. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33500. /**
  33501. * Base class of the scene acting as a container for the different elements composing a scene.
  33502. * This class is dynamically extended by the different components of the scene increasing
  33503. * flexibility and reducing coupling
  33504. */
  33505. export abstract class AbstractScene {
  33506. /**
  33507. * Stores the list of available parsers in the application.
  33508. */
  33509. private static _BabylonFileParsers;
  33510. /**
  33511. * Stores the list of available individual parsers in the application.
  33512. */
  33513. private static _IndividualBabylonFileParsers;
  33514. /**
  33515. * Adds a parser in the list of available ones
  33516. * @param name Defines the name of the parser
  33517. * @param parser Defines the parser to add
  33518. */
  33519. static AddParser(name: string, parser: BabylonFileParser): void;
  33520. /**
  33521. * Gets a general parser from the list of avaialble ones
  33522. * @param name Defines the name of the parser
  33523. * @returns the requested parser or null
  33524. */
  33525. static GetParser(name: string): Nullable<BabylonFileParser>;
  33526. /**
  33527. * Adds n individual parser in the list of available ones
  33528. * @param name Defines the name of the parser
  33529. * @param parser Defines the parser to add
  33530. */
  33531. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33532. /**
  33533. * Gets an individual parser from the list of avaialble ones
  33534. * @param name Defines the name of the parser
  33535. * @returns the requested parser or null
  33536. */
  33537. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33538. /**
  33539. * Parser json data and populate both a scene and its associated container object
  33540. * @param jsonData Defines the data to parse
  33541. * @param scene Defines the scene to parse the data for
  33542. * @param container Defines the container attached to the parsing sequence
  33543. * @param rootUrl Defines the root url of the data
  33544. */
  33545. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33546. /**
  33547. * Gets the list of root nodes (ie. nodes with no parent)
  33548. */
  33549. rootNodes: Node[];
  33550. /** All of the cameras added to this scene
  33551. * @see http://doc.babylonjs.com/babylon101/cameras
  33552. */
  33553. cameras: Camera[];
  33554. /**
  33555. * All of the lights added to this scene
  33556. * @see http://doc.babylonjs.com/babylon101/lights
  33557. */
  33558. lights: Light[];
  33559. /**
  33560. * All of the (abstract) meshes added to this scene
  33561. */
  33562. meshes: AbstractMesh[];
  33563. /**
  33564. * The list of skeletons added to the scene
  33565. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33566. */
  33567. skeletons: Skeleton[];
  33568. /**
  33569. * All of the particle systems added to this scene
  33570. * @see http://doc.babylonjs.com/babylon101/particles
  33571. */
  33572. particleSystems: IParticleSystem[];
  33573. /**
  33574. * Gets a list of Animations associated with the scene
  33575. */
  33576. animations: Animation[];
  33577. /**
  33578. * All of the animation groups added to this scene
  33579. * @see http://doc.babylonjs.com/how_to/group
  33580. */
  33581. animationGroups: AnimationGroup[];
  33582. /**
  33583. * All of the multi-materials added to this scene
  33584. * @see http://doc.babylonjs.com/how_to/multi_materials
  33585. */
  33586. multiMaterials: MultiMaterial[];
  33587. /**
  33588. * All of the materials added to this scene
  33589. * In the context of a Scene, it is not supposed to be modified manually.
  33590. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33591. * Note also that the order of the Material wihin the array is not significant and might change.
  33592. * @see http://doc.babylonjs.com/babylon101/materials
  33593. */
  33594. materials: Material[];
  33595. /**
  33596. * The list of morph target managers added to the scene
  33597. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33598. */
  33599. morphTargetManagers: MorphTargetManager[];
  33600. /**
  33601. * The list of geometries used in the scene.
  33602. */
  33603. geometries: Geometry[];
  33604. /**
  33605. * All of the tranform nodes added to this scene
  33606. * In the context of a Scene, it is not supposed to be modified manually.
  33607. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33608. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33609. * @see http://doc.babylonjs.com/how_to/transformnode
  33610. */
  33611. transformNodes: TransformNode[];
  33612. /**
  33613. * ActionManagers available on the scene.
  33614. */
  33615. actionManagers: AbstractActionManager[];
  33616. /**
  33617. * Textures to keep.
  33618. */
  33619. textures: BaseTexture[];
  33620. /**
  33621. * Environment texture for the scene
  33622. */
  33623. environmentTexture: Nullable<BaseTexture>;
  33624. }
  33625. }
  33626. declare module BABYLON {
  33627. /**
  33628. * Defines a sound that can be played in the application.
  33629. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33631. */
  33632. export class Sound {
  33633. /**
  33634. * The name of the sound in the scene.
  33635. */
  33636. name: string;
  33637. /**
  33638. * Does the sound autoplay once loaded.
  33639. */
  33640. autoplay: boolean;
  33641. /**
  33642. * Does the sound loop after it finishes playing once.
  33643. */
  33644. loop: boolean;
  33645. /**
  33646. * Does the sound use a custom attenuation curve to simulate the falloff
  33647. * happening when the source gets further away from the camera.
  33648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33649. */
  33650. useCustomAttenuation: boolean;
  33651. /**
  33652. * The sound track id this sound belongs to.
  33653. */
  33654. soundTrackId: number;
  33655. /**
  33656. * Is this sound currently played.
  33657. */
  33658. isPlaying: boolean;
  33659. /**
  33660. * Is this sound currently paused.
  33661. */
  33662. isPaused: boolean;
  33663. /**
  33664. * Does this sound enables spatial sound.
  33665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33666. */
  33667. spatialSound: boolean;
  33668. /**
  33669. * Define the reference distance the sound should be heard perfectly.
  33670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33671. */
  33672. refDistance: number;
  33673. /**
  33674. * Define the roll off factor of spatial sounds.
  33675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33676. */
  33677. rolloffFactor: number;
  33678. /**
  33679. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33681. */
  33682. maxDistance: number;
  33683. /**
  33684. * Define the distance attenuation model the sound will follow.
  33685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33686. */
  33687. distanceModel: string;
  33688. /**
  33689. * @hidden
  33690. * Back Compat
  33691. **/
  33692. onended: () => any;
  33693. /**
  33694. * Observable event when the current playing sound finishes.
  33695. */
  33696. onEndedObservable: Observable<Sound>;
  33697. private _panningModel;
  33698. private _playbackRate;
  33699. private _streaming;
  33700. private _startTime;
  33701. private _startOffset;
  33702. private _position;
  33703. /** @hidden */
  33704. _positionInEmitterSpace: boolean;
  33705. private _localDirection;
  33706. private _volume;
  33707. private _isReadyToPlay;
  33708. private _isDirectional;
  33709. private _readyToPlayCallback;
  33710. private _audioBuffer;
  33711. private _soundSource;
  33712. private _streamingSource;
  33713. private _soundPanner;
  33714. private _soundGain;
  33715. private _inputAudioNode;
  33716. private _outputAudioNode;
  33717. private _coneInnerAngle;
  33718. private _coneOuterAngle;
  33719. private _coneOuterGain;
  33720. private _scene;
  33721. private _connectedTransformNode;
  33722. private _customAttenuationFunction;
  33723. private _registerFunc;
  33724. private _isOutputConnected;
  33725. private _htmlAudioElement;
  33726. private _urlType;
  33727. /** @hidden */
  33728. static _SceneComponentInitialization: (scene: Scene) => void;
  33729. /**
  33730. * Create a sound and attach it to a scene
  33731. * @param name Name of your sound
  33732. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33733. * @param scene defines the scene the sound belongs to
  33734. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33735. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33736. */
  33737. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33738. /**
  33739. * Release the sound and its associated resources
  33740. */
  33741. dispose(): void;
  33742. /**
  33743. * Gets if the sounds is ready to be played or not.
  33744. * @returns true if ready, otherwise false
  33745. */
  33746. isReady(): boolean;
  33747. private _soundLoaded;
  33748. /**
  33749. * Sets the data of the sound from an audiobuffer
  33750. * @param audioBuffer The audioBuffer containing the data
  33751. */
  33752. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33753. /**
  33754. * Updates the current sounds options such as maxdistance, loop...
  33755. * @param options A JSON object containing values named as the object properties
  33756. */
  33757. updateOptions(options: any): void;
  33758. private _createSpatialParameters;
  33759. private _updateSpatialParameters;
  33760. /**
  33761. * Switch the panning model to HRTF:
  33762. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33764. */
  33765. switchPanningModelToHRTF(): void;
  33766. /**
  33767. * Switch the panning model to Equal Power:
  33768. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33770. */
  33771. switchPanningModelToEqualPower(): void;
  33772. private _switchPanningModel;
  33773. /**
  33774. * Connect this sound to a sound track audio node like gain...
  33775. * @param soundTrackAudioNode the sound track audio node to connect to
  33776. */
  33777. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33778. /**
  33779. * Transform this sound into a directional source
  33780. * @param coneInnerAngle Size of the inner cone in degree
  33781. * @param coneOuterAngle Size of the outer cone in degree
  33782. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33783. */
  33784. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33785. /**
  33786. * Gets or sets the inner angle for the directional cone.
  33787. */
  33788. /**
  33789. * Gets or sets the inner angle for the directional cone.
  33790. */
  33791. directionalConeInnerAngle: number;
  33792. /**
  33793. * Gets or sets the outer angle for the directional cone.
  33794. */
  33795. /**
  33796. * Gets or sets the outer angle for the directional cone.
  33797. */
  33798. directionalConeOuterAngle: number;
  33799. /**
  33800. * Sets the position of the emitter if spatial sound is enabled
  33801. * @param newPosition Defines the new posisiton
  33802. */
  33803. setPosition(newPosition: Vector3): void;
  33804. /**
  33805. * Sets the local direction of the emitter if spatial sound is enabled
  33806. * @param newLocalDirection Defines the new local direction
  33807. */
  33808. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33809. private _updateDirection;
  33810. /** @hidden */
  33811. updateDistanceFromListener(): void;
  33812. /**
  33813. * Sets a new custom attenuation function for the sound.
  33814. * @param callback Defines the function used for the attenuation
  33815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33816. */
  33817. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33818. /**
  33819. * Play the sound
  33820. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33821. * @param offset (optional) Start the sound setting it at a specific time
  33822. */
  33823. play(time?: number, offset?: number): void;
  33824. private _onended;
  33825. /**
  33826. * Stop the sound
  33827. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33828. */
  33829. stop(time?: number): void;
  33830. /**
  33831. * Put the sound in pause
  33832. */
  33833. pause(): void;
  33834. /**
  33835. * Sets a dedicated volume for this sounds
  33836. * @param newVolume Define the new volume of the sound
  33837. * @param time Define in how long the sound should be at this value
  33838. */
  33839. setVolume(newVolume: number, time?: number): void;
  33840. /**
  33841. * Set the sound play back rate
  33842. * @param newPlaybackRate Define the playback rate the sound should be played at
  33843. */
  33844. setPlaybackRate(newPlaybackRate: number): void;
  33845. /**
  33846. * Gets the volume of the sound.
  33847. * @returns the volume of the sound
  33848. */
  33849. getVolume(): number;
  33850. /**
  33851. * Attach the sound to a dedicated mesh
  33852. * @param transformNode The transform node to connect the sound with
  33853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33854. */
  33855. attachToMesh(transformNode: TransformNode): void;
  33856. /**
  33857. * Detach the sound from the previously attached mesh
  33858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33859. */
  33860. detachFromMesh(): void;
  33861. private _onRegisterAfterWorldMatrixUpdate;
  33862. /**
  33863. * Clone the current sound in the scene.
  33864. * @returns the new sound clone
  33865. */
  33866. clone(): Nullable<Sound>;
  33867. /**
  33868. * Gets the current underlying audio buffer containing the data
  33869. * @returns the audio buffer
  33870. */
  33871. getAudioBuffer(): Nullable<AudioBuffer>;
  33872. /**
  33873. * Serializes the Sound in a JSON representation
  33874. * @returns the JSON representation of the sound
  33875. */
  33876. serialize(): any;
  33877. /**
  33878. * Parse a JSON representation of a sound to innstantiate in a given scene
  33879. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33880. * @param scene Define the scene the new parsed sound should be created in
  33881. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33882. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33883. * @returns the newly parsed sound
  33884. */
  33885. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33886. }
  33887. }
  33888. declare module BABYLON {
  33889. /**
  33890. * This defines an action helpful to play a defined sound on a triggered action.
  33891. */
  33892. export class PlaySoundAction extends Action {
  33893. private _sound;
  33894. /**
  33895. * Instantiate the action
  33896. * @param triggerOptions defines the trigger options
  33897. * @param sound defines the sound to play
  33898. * @param condition defines the trigger related conditions
  33899. */
  33900. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33901. /** @hidden */
  33902. _prepare(): void;
  33903. /**
  33904. * Execute the action and play the sound.
  33905. */
  33906. execute(): void;
  33907. /**
  33908. * Serializes the actions and its related information.
  33909. * @param parent defines the object to serialize in
  33910. * @returns the serialized object
  33911. */
  33912. serialize(parent: any): any;
  33913. }
  33914. /**
  33915. * This defines an action helpful to stop a defined sound on a triggered action.
  33916. */
  33917. export class StopSoundAction extends Action {
  33918. private _sound;
  33919. /**
  33920. * Instantiate the action
  33921. * @param triggerOptions defines the trigger options
  33922. * @param sound defines the sound to stop
  33923. * @param condition defines the trigger related conditions
  33924. */
  33925. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33926. /** @hidden */
  33927. _prepare(): void;
  33928. /**
  33929. * Execute the action and stop the sound.
  33930. */
  33931. execute(): void;
  33932. /**
  33933. * Serializes the actions and its related information.
  33934. * @param parent defines the object to serialize in
  33935. * @returns the serialized object
  33936. */
  33937. serialize(parent: any): any;
  33938. }
  33939. }
  33940. declare module BABYLON {
  33941. /**
  33942. * This defines an action responsible to change the value of a property
  33943. * by interpolating between its current value and the newly set one once triggered.
  33944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33945. */
  33946. export class InterpolateValueAction extends Action {
  33947. /**
  33948. * Defines the path of the property where the value should be interpolated
  33949. */
  33950. propertyPath: string;
  33951. /**
  33952. * Defines the target value at the end of the interpolation.
  33953. */
  33954. value: any;
  33955. /**
  33956. * Defines the time it will take for the property to interpolate to the value.
  33957. */
  33958. duration: number;
  33959. /**
  33960. * Defines if the other scene animations should be stopped when the action has been triggered
  33961. */
  33962. stopOtherAnimations?: boolean;
  33963. /**
  33964. * Defines a callback raised once the interpolation animation has been done.
  33965. */
  33966. onInterpolationDone?: () => void;
  33967. /**
  33968. * Observable triggered once the interpolation animation has been done.
  33969. */
  33970. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33971. private _target;
  33972. private _effectiveTarget;
  33973. private _property;
  33974. /**
  33975. * Instantiate the action
  33976. * @param triggerOptions defines the trigger options
  33977. * @param target defines the object containing the value to interpolate
  33978. * @param propertyPath defines the path to the property in the target object
  33979. * @param value defines the target value at the end of the interpolation
  33980. * @param duration deines the time it will take for the property to interpolate to the value.
  33981. * @param condition defines the trigger related conditions
  33982. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33983. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33984. */
  33985. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33986. /** @hidden */
  33987. _prepare(): void;
  33988. /**
  33989. * Execute the action starts the value interpolation.
  33990. */
  33991. execute(): void;
  33992. /**
  33993. * Serializes the actions and its related information.
  33994. * @param parent defines the object to serialize in
  33995. * @returns the serialized object
  33996. */
  33997. serialize(parent: any): any;
  33998. }
  33999. }
  34000. declare module BABYLON {
  34001. /**
  34002. * Options allowed during the creation of a sound track.
  34003. */
  34004. export interface ISoundTrackOptions {
  34005. /**
  34006. * The volume the sound track should take during creation
  34007. */
  34008. volume?: number;
  34009. /**
  34010. * Define if the sound track is the main sound track of the scene
  34011. */
  34012. mainTrack?: boolean;
  34013. }
  34014. /**
  34015. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34016. * It will be also used in a future release to apply effects on a specific track.
  34017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34018. */
  34019. export class SoundTrack {
  34020. /**
  34021. * The unique identifier of the sound track in the scene.
  34022. */
  34023. id: number;
  34024. /**
  34025. * The list of sounds included in the sound track.
  34026. */
  34027. soundCollection: Array<Sound>;
  34028. private _outputAudioNode;
  34029. private _scene;
  34030. private _isMainTrack;
  34031. private _connectedAnalyser;
  34032. private _options;
  34033. private _isInitialized;
  34034. /**
  34035. * Creates a new sound track.
  34036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34037. * @param scene Define the scene the sound track belongs to
  34038. * @param options
  34039. */
  34040. constructor(scene: Scene, options?: ISoundTrackOptions);
  34041. private _initializeSoundTrackAudioGraph;
  34042. /**
  34043. * Release the sound track and its associated resources
  34044. */
  34045. dispose(): void;
  34046. /**
  34047. * Adds a sound to this sound track
  34048. * @param sound define the cound to add
  34049. * @ignoreNaming
  34050. */
  34051. AddSound(sound: Sound): void;
  34052. /**
  34053. * Removes a sound to this sound track
  34054. * @param sound define the cound to remove
  34055. * @ignoreNaming
  34056. */
  34057. RemoveSound(sound: Sound): void;
  34058. /**
  34059. * Set a global volume for the full sound track.
  34060. * @param newVolume Define the new volume of the sound track
  34061. */
  34062. setVolume(newVolume: number): void;
  34063. /**
  34064. * Switch the panning model to HRTF:
  34065. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34067. */
  34068. switchPanningModelToHRTF(): void;
  34069. /**
  34070. * Switch the panning model to Equal Power:
  34071. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34073. */
  34074. switchPanningModelToEqualPower(): void;
  34075. /**
  34076. * Connect the sound track to an audio analyser allowing some amazing
  34077. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34079. * @param analyser The analyser to connect to the engine
  34080. */
  34081. connectToAnalyser(analyser: Analyser): void;
  34082. }
  34083. }
  34084. declare module BABYLON {
  34085. interface AbstractScene {
  34086. /**
  34087. * The list of sounds used in the scene.
  34088. */
  34089. sounds: Nullable<Array<Sound>>;
  34090. }
  34091. interface Scene {
  34092. /**
  34093. * @hidden
  34094. * Backing field
  34095. */
  34096. _mainSoundTrack: SoundTrack;
  34097. /**
  34098. * The main sound track played by the scene.
  34099. * It cotains your primary collection of sounds.
  34100. */
  34101. mainSoundTrack: SoundTrack;
  34102. /**
  34103. * The list of sound tracks added to the scene
  34104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34105. */
  34106. soundTracks: Nullable<Array<SoundTrack>>;
  34107. /**
  34108. * Gets a sound using a given name
  34109. * @param name defines the name to search for
  34110. * @return the found sound or null if not found at all.
  34111. */
  34112. getSoundByName(name: string): Nullable<Sound>;
  34113. /**
  34114. * Gets or sets if audio support is enabled
  34115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34116. */
  34117. audioEnabled: boolean;
  34118. /**
  34119. * Gets or sets if audio will be output to headphones
  34120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34121. */
  34122. headphone: boolean;
  34123. }
  34124. /**
  34125. * Defines the sound scene component responsible to manage any sounds
  34126. * in a given scene.
  34127. */
  34128. export class AudioSceneComponent implements ISceneSerializableComponent {
  34129. /**
  34130. * The component name helpfull to identify the component in the list of scene components.
  34131. */
  34132. readonly name: string;
  34133. /**
  34134. * The scene the component belongs to.
  34135. */
  34136. scene: Scene;
  34137. private _audioEnabled;
  34138. /**
  34139. * Gets whether audio is enabled or not.
  34140. * Please use related enable/disable method to switch state.
  34141. */
  34142. readonly audioEnabled: boolean;
  34143. private _headphone;
  34144. /**
  34145. * Gets whether audio is outputing to headphone or not.
  34146. * Please use the according Switch methods to change output.
  34147. */
  34148. readonly headphone: boolean;
  34149. /**
  34150. * Creates a new instance of the component for the given scene
  34151. * @param scene Defines the scene to register the component in
  34152. */
  34153. constructor(scene: Scene);
  34154. /**
  34155. * Registers the component in a given scene
  34156. */
  34157. register(): void;
  34158. /**
  34159. * Rebuilds the elements related to this component in case of
  34160. * context lost for instance.
  34161. */
  34162. rebuild(): void;
  34163. /**
  34164. * Serializes the component data to the specified json object
  34165. * @param serializationObject The object to serialize to
  34166. */
  34167. serialize(serializationObject: any): void;
  34168. /**
  34169. * Adds all the element from the container to the scene
  34170. * @param container the container holding the elements
  34171. */
  34172. addFromContainer(container: AbstractScene): void;
  34173. /**
  34174. * Removes all the elements in the container from the scene
  34175. * @param container contains the elements to remove
  34176. * @param dispose if the removed element should be disposed (default: false)
  34177. */
  34178. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34179. /**
  34180. * Disposes the component and the associated ressources.
  34181. */
  34182. dispose(): void;
  34183. /**
  34184. * Disables audio in the associated scene.
  34185. */
  34186. disableAudio(): void;
  34187. /**
  34188. * Enables audio in the associated scene.
  34189. */
  34190. enableAudio(): void;
  34191. /**
  34192. * Switch audio to headphone output.
  34193. */
  34194. switchAudioModeForHeadphones(): void;
  34195. /**
  34196. * Switch audio to normal speakers.
  34197. */
  34198. switchAudioModeForNormalSpeakers(): void;
  34199. private _afterRender;
  34200. }
  34201. }
  34202. declare module BABYLON {
  34203. /**
  34204. * Wraps one or more Sound objects and selects one with random weight for playback.
  34205. */
  34206. export class WeightedSound {
  34207. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34208. loop: boolean;
  34209. private _coneInnerAngle;
  34210. private _coneOuterAngle;
  34211. private _volume;
  34212. /** A Sound is currently playing. */
  34213. isPlaying: boolean;
  34214. /** A Sound is currently paused. */
  34215. isPaused: boolean;
  34216. private _sounds;
  34217. private _weights;
  34218. private _currentIndex?;
  34219. /**
  34220. * Creates a new WeightedSound from the list of sounds given.
  34221. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34222. * @param sounds Array of Sounds that will be selected from.
  34223. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34224. */
  34225. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34226. /**
  34227. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34228. */
  34229. /**
  34230. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34231. */
  34232. directionalConeInnerAngle: number;
  34233. /**
  34234. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34235. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34236. */
  34237. /**
  34238. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34239. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34240. */
  34241. directionalConeOuterAngle: number;
  34242. /**
  34243. * Playback volume.
  34244. */
  34245. /**
  34246. * Playback volume.
  34247. */
  34248. volume: number;
  34249. private _onended;
  34250. /**
  34251. * Suspend playback
  34252. */
  34253. pause(): void;
  34254. /**
  34255. * Stop playback
  34256. */
  34257. stop(): void;
  34258. /**
  34259. * Start playback.
  34260. * @param startOffset Position the clip head at a specific time in seconds.
  34261. */
  34262. play(startOffset?: number): void;
  34263. }
  34264. }
  34265. declare module BABYLON {
  34266. /**
  34267. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34269. */
  34270. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34271. /**
  34272. * Gets the name of the behavior.
  34273. */
  34274. readonly name: string;
  34275. /**
  34276. * The easing function used by animations
  34277. */
  34278. static EasingFunction: BackEase;
  34279. /**
  34280. * The easing mode used by animations
  34281. */
  34282. static EasingMode: number;
  34283. /**
  34284. * The duration of the animation, in milliseconds
  34285. */
  34286. transitionDuration: number;
  34287. /**
  34288. * Length of the distance animated by the transition when lower radius is reached
  34289. */
  34290. lowerRadiusTransitionRange: number;
  34291. /**
  34292. * Length of the distance animated by the transition when upper radius is reached
  34293. */
  34294. upperRadiusTransitionRange: number;
  34295. private _autoTransitionRange;
  34296. /**
  34297. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34298. */
  34299. /**
  34300. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34301. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34302. */
  34303. autoTransitionRange: boolean;
  34304. private _attachedCamera;
  34305. private _onAfterCheckInputsObserver;
  34306. private _onMeshTargetChangedObserver;
  34307. /**
  34308. * Initializes the behavior.
  34309. */
  34310. init(): void;
  34311. /**
  34312. * Attaches the behavior to its arc rotate camera.
  34313. * @param camera Defines the camera to attach the behavior to
  34314. */
  34315. attach(camera: ArcRotateCamera): void;
  34316. /**
  34317. * Detaches the behavior from its current arc rotate camera.
  34318. */
  34319. detach(): void;
  34320. private _radiusIsAnimating;
  34321. private _radiusBounceTransition;
  34322. private _animatables;
  34323. private _cachedWheelPrecision;
  34324. /**
  34325. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34326. * @param radiusLimit The limit to check against.
  34327. * @return Bool to indicate if at limit.
  34328. */
  34329. private _isRadiusAtLimit;
  34330. /**
  34331. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34332. * @param radiusDelta The delta by which to animate to. Can be negative.
  34333. */
  34334. private _applyBoundRadiusAnimation;
  34335. /**
  34336. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34337. */
  34338. protected _clearAnimationLocks(): void;
  34339. /**
  34340. * Stops and removes all animations that have been applied to the camera
  34341. */
  34342. stopAllAnimations(): void;
  34343. }
  34344. }
  34345. declare module BABYLON {
  34346. /**
  34347. * 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.
  34348. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34349. */
  34350. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34351. /**
  34352. * Gets the name of the behavior.
  34353. */
  34354. readonly name: string;
  34355. private _mode;
  34356. private _radiusScale;
  34357. private _positionScale;
  34358. private _defaultElevation;
  34359. private _elevationReturnTime;
  34360. private _elevationReturnWaitTime;
  34361. private _zoomStopsAnimation;
  34362. private _framingTime;
  34363. /**
  34364. * The easing function used by animations
  34365. */
  34366. static EasingFunction: ExponentialEase;
  34367. /**
  34368. * The easing mode used by animations
  34369. */
  34370. static EasingMode: number;
  34371. /**
  34372. * Sets the current mode used by the behavior
  34373. */
  34374. /**
  34375. * Gets current mode used by the behavior.
  34376. */
  34377. mode: number;
  34378. /**
  34379. * Sets the scale applied to the radius (1 by default)
  34380. */
  34381. /**
  34382. * Gets the scale applied to the radius
  34383. */
  34384. radiusScale: number;
  34385. /**
  34386. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34387. */
  34388. /**
  34389. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34390. */
  34391. positionScale: number;
  34392. /**
  34393. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34394. * behaviour is triggered, in radians.
  34395. */
  34396. /**
  34397. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34398. * behaviour is triggered, in radians.
  34399. */
  34400. defaultElevation: number;
  34401. /**
  34402. * Sets the time (in milliseconds) taken to return to the default beta position.
  34403. * Negative value indicates camera should not return to default.
  34404. */
  34405. /**
  34406. * Gets the time (in milliseconds) taken to return to the default beta position.
  34407. * Negative value indicates camera should not return to default.
  34408. */
  34409. elevationReturnTime: number;
  34410. /**
  34411. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34412. */
  34413. /**
  34414. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34415. */
  34416. elevationReturnWaitTime: number;
  34417. /**
  34418. * Sets the flag that indicates if user zooming should stop animation.
  34419. */
  34420. /**
  34421. * Gets the flag that indicates if user zooming should stop animation.
  34422. */
  34423. zoomStopsAnimation: boolean;
  34424. /**
  34425. * Sets the transition time when framing the mesh, in milliseconds
  34426. */
  34427. /**
  34428. * Gets the transition time when framing the mesh, in milliseconds
  34429. */
  34430. framingTime: number;
  34431. /**
  34432. * Define if the behavior should automatically change the configured
  34433. * camera limits and sensibilities.
  34434. */
  34435. autoCorrectCameraLimitsAndSensibility: boolean;
  34436. private _onPrePointerObservableObserver;
  34437. private _onAfterCheckInputsObserver;
  34438. private _onMeshTargetChangedObserver;
  34439. private _attachedCamera;
  34440. private _isPointerDown;
  34441. private _lastInteractionTime;
  34442. /**
  34443. * Initializes the behavior.
  34444. */
  34445. init(): void;
  34446. /**
  34447. * Attaches the behavior to its arc rotate camera.
  34448. * @param camera Defines the camera to attach the behavior to
  34449. */
  34450. attach(camera: ArcRotateCamera): void;
  34451. /**
  34452. * Detaches the behavior from its current arc rotate camera.
  34453. */
  34454. detach(): void;
  34455. private _animatables;
  34456. private _betaIsAnimating;
  34457. private _betaTransition;
  34458. private _radiusTransition;
  34459. private _vectorTransition;
  34460. /**
  34461. * Targets the given mesh and updates zoom level accordingly.
  34462. * @param mesh The mesh to target.
  34463. * @param radius Optional. If a cached radius position already exists, overrides default.
  34464. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34465. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34466. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34467. */
  34468. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34469. /**
  34470. * Targets the given mesh with its children and updates zoom level accordingly.
  34471. * @param mesh The mesh to target.
  34472. * @param radius Optional. If a cached radius position already exists, overrides default.
  34473. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34474. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34475. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34476. */
  34477. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34478. /**
  34479. * Targets the given meshes with their children and updates zoom level accordingly.
  34480. * @param meshes The mesh to target.
  34481. * @param radius Optional. If a cached radius position already exists, overrides default.
  34482. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34483. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34484. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34485. */
  34486. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34487. /**
  34488. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34489. * @param minimumWorld Determines the smaller position of the bounding box extend
  34490. * @param maximumWorld Determines the bigger position of the bounding box extend
  34491. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34492. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34493. */
  34494. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34495. /**
  34496. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34497. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34498. * frustum width.
  34499. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34500. * to fully enclose the mesh in the viewing frustum.
  34501. */
  34502. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34503. /**
  34504. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34505. * is automatically returned to its default position (expected to be above ground plane).
  34506. */
  34507. private _maintainCameraAboveGround;
  34508. /**
  34509. * Returns the frustum slope based on the canvas ratio and camera FOV
  34510. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34511. */
  34512. private _getFrustumSlope;
  34513. /**
  34514. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34515. */
  34516. private _clearAnimationLocks;
  34517. /**
  34518. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34519. */
  34520. private _applyUserInteraction;
  34521. /**
  34522. * Stops and removes all animations that have been applied to the camera
  34523. */
  34524. stopAllAnimations(): void;
  34525. /**
  34526. * Gets a value indicating if the user is moving the camera
  34527. */
  34528. readonly isUserIsMoving: boolean;
  34529. /**
  34530. * The camera can move all the way towards the mesh.
  34531. */
  34532. static IgnoreBoundsSizeMode: number;
  34533. /**
  34534. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34535. */
  34536. static FitFrustumSidesMode: number;
  34537. }
  34538. }
  34539. declare module BABYLON {
  34540. /**
  34541. * Base class for Camera Pointer Inputs.
  34542. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34543. * for example usage.
  34544. */
  34545. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34546. /**
  34547. * Defines the camera the input is attached to.
  34548. */
  34549. abstract camera: Camera;
  34550. /**
  34551. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34552. */
  34553. protected _altKey: boolean;
  34554. protected _ctrlKey: boolean;
  34555. protected _metaKey: boolean;
  34556. protected _shiftKey: boolean;
  34557. /**
  34558. * Which mouse buttons were pressed at time of last mouse event.
  34559. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34560. */
  34561. protected _buttonsPressed: number;
  34562. /**
  34563. * Defines the buttons associated with the input to handle camera move.
  34564. */
  34565. buttons: number[];
  34566. /**
  34567. * Attach the input controls to a specific dom element to get the input from.
  34568. * @param element Defines the element the controls should be listened from
  34569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34570. */
  34571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34572. /**
  34573. * Detach the current controls from the specified dom element.
  34574. * @param element Defines the element to stop listening the inputs from
  34575. */
  34576. detachControl(element: Nullable<HTMLElement>): void;
  34577. /**
  34578. * Gets the class name of the current input.
  34579. * @returns the class name
  34580. */
  34581. getClassName(): string;
  34582. /**
  34583. * Get the friendly name associated with the input class.
  34584. * @returns the input friendly name
  34585. */
  34586. getSimpleName(): string;
  34587. /**
  34588. * Called on pointer POINTERDOUBLETAP event.
  34589. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34590. */
  34591. protected onDoubleTap(type: string): void;
  34592. /**
  34593. * Called on pointer POINTERMOVE event if only a single touch is active.
  34594. * Override this method to provide functionality.
  34595. */
  34596. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34597. /**
  34598. * Called on pointer POINTERMOVE event if multiple touches are active.
  34599. * Override this method to provide functionality.
  34600. */
  34601. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34602. /**
  34603. * Called on JS contextmenu event.
  34604. * Override this method to provide functionality.
  34605. */
  34606. protected onContextMenu(evt: PointerEvent): void;
  34607. /**
  34608. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34609. * press.
  34610. * Override this method to provide functionality.
  34611. */
  34612. protected onButtonDown(evt: PointerEvent): void;
  34613. /**
  34614. * Called each time a new POINTERUP event occurs. Ie, for each button
  34615. * release.
  34616. * Override this method to provide functionality.
  34617. */
  34618. protected onButtonUp(evt: PointerEvent): void;
  34619. /**
  34620. * Called when window becomes inactive.
  34621. * Override this method to provide functionality.
  34622. */
  34623. protected onLostFocus(): void;
  34624. private _pointerInput;
  34625. private _observer;
  34626. private _onLostFocus;
  34627. private pointA;
  34628. private pointB;
  34629. }
  34630. }
  34631. declare module BABYLON {
  34632. /**
  34633. * Manage the pointers inputs to control an arc rotate camera.
  34634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34635. */
  34636. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34637. /**
  34638. * Defines the camera the input is attached to.
  34639. */
  34640. camera: ArcRotateCamera;
  34641. /**
  34642. * Gets the class name of the current input.
  34643. * @returns the class name
  34644. */
  34645. getClassName(): string;
  34646. /**
  34647. * Defines the buttons associated with the input to handle camera move.
  34648. */
  34649. buttons: number[];
  34650. /**
  34651. * Defines the pointer angular sensibility along the X axis or how fast is
  34652. * the camera rotating.
  34653. */
  34654. angularSensibilityX: number;
  34655. /**
  34656. * Defines the pointer angular sensibility along the Y axis or how fast is
  34657. * the camera rotating.
  34658. */
  34659. angularSensibilityY: number;
  34660. /**
  34661. * Defines the pointer pinch precision or how fast is the camera zooming.
  34662. */
  34663. pinchPrecision: number;
  34664. /**
  34665. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34666. * from 0.
  34667. * It defines the percentage of current camera.radius to use as delta when
  34668. * pinch zoom is used.
  34669. */
  34670. pinchDeltaPercentage: number;
  34671. /**
  34672. * Defines the pointer panning sensibility or how fast is the camera moving.
  34673. */
  34674. panningSensibility: number;
  34675. /**
  34676. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34677. */
  34678. multiTouchPanning: boolean;
  34679. /**
  34680. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34681. * zoom (pinch) through multitouch.
  34682. */
  34683. multiTouchPanAndZoom: boolean;
  34684. /**
  34685. * Revers pinch action direction.
  34686. */
  34687. pinchInwards: boolean;
  34688. private _isPanClick;
  34689. private _twoFingerActivityCount;
  34690. private _isPinching;
  34691. /**
  34692. * Called on pointer POINTERMOVE event if only a single touch is active.
  34693. */
  34694. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34695. /**
  34696. * Called on pointer POINTERDOUBLETAP event.
  34697. */
  34698. protected onDoubleTap(type: string): void;
  34699. /**
  34700. * Called on pointer POINTERMOVE event if multiple touches are active.
  34701. */
  34702. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34703. /**
  34704. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34705. * press.
  34706. */
  34707. protected onButtonDown(evt: PointerEvent): void;
  34708. /**
  34709. * Called each time a new POINTERUP event occurs. Ie, for each button
  34710. * release.
  34711. */
  34712. protected onButtonUp(evt: PointerEvent): void;
  34713. /**
  34714. * Called when window becomes inactive.
  34715. */
  34716. protected onLostFocus(): void;
  34717. }
  34718. }
  34719. declare module BABYLON {
  34720. /**
  34721. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34723. */
  34724. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34725. /**
  34726. * Defines the camera the input is attached to.
  34727. */
  34728. camera: ArcRotateCamera;
  34729. /**
  34730. * Defines the list of key codes associated with the up action (increase alpha)
  34731. */
  34732. keysUp: number[];
  34733. /**
  34734. * Defines the list of key codes associated with the down action (decrease alpha)
  34735. */
  34736. keysDown: number[];
  34737. /**
  34738. * Defines the list of key codes associated with the left action (increase beta)
  34739. */
  34740. keysLeft: number[];
  34741. /**
  34742. * Defines the list of key codes associated with the right action (decrease beta)
  34743. */
  34744. keysRight: number[];
  34745. /**
  34746. * Defines the list of key codes associated with the reset action.
  34747. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34748. */
  34749. keysReset: number[];
  34750. /**
  34751. * Defines the panning sensibility of the inputs.
  34752. * (How fast is the camera paning)
  34753. */
  34754. panningSensibility: number;
  34755. /**
  34756. * Defines the zooming sensibility of the inputs.
  34757. * (How fast is the camera zooming)
  34758. */
  34759. zoomingSensibility: number;
  34760. /**
  34761. * Defines wether maintaining the alt key down switch the movement mode from
  34762. * orientation to zoom.
  34763. */
  34764. useAltToZoom: boolean;
  34765. /**
  34766. * Rotation speed of the camera
  34767. */
  34768. angularSpeed: number;
  34769. private _keys;
  34770. private _ctrlPressed;
  34771. private _altPressed;
  34772. private _onCanvasBlurObserver;
  34773. private _onKeyboardObserver;
  34774. private _engine;
  34775. private _scene;
  34776. /**
  34777. * Attach the input controls to a specific dom element to get the input from.
  34778. * @param element Defines the element the controls should be listened from
  34779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34780. */
  34781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34782. /**
  34783. * Detach the current controls from the specified dom element.
  34784. * @param element Defines the element to stop listening the inputs from
  34785. */
  34786. detachControl(element: Nullable<HTMLElement>): void;
  34787. /**
  34788. * Update the current camera state depending on the inputs that have been used this frame.
  34789. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34790. */
  34791. checkInputs(): void;
  34792. /**
  34793. * Gets the class name of the current intput.
  34794. * @returns the class name
  34795. */
  34796. getClassName(): string;
  34797. /**
  34798. * Get the friendly name associated with the input class.
  34799. * @returns the input friendly name
  34800. */
  34801. getSimpleName(): string;
  34802. }
  34803. }
  34804. declare module BABYLON {
  34805. /**
  34806. * Manage the mouse wheel inputs to control an arc rotate camera.
  34807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34808. */
  34809. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34810. /**
  34811. * Defines the camera the input is attached to.
  34812. */
  34813. camera: ArcRotateCamera;
  34814. /**
  34815. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34816. */
  34817. wheelPrecision: number;
  34818. /**
  34819. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34820. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34821. */
  34822. wheelDeltaPercentage: number;
  34823. private _wheel;
  34824. private _observer;
  34825. /**
  34826. * Attach the input controls to a specific dom element to get the input from.
  34827. * @param element Defines the element the controls should be listened from
  34828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34829. */
  34830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34831. /**
  34832. * Detach the current controls from the specified dom element.
  34833. * @param element Defines the element to stop listening the inputs from
  34834. */
  34835. detachControl(element: Nullable<HTMLElement>): void;
  34836. /**
  34837. * Gets the class name of the current intput.
  34838. * @returns the class name
  34839. */
  34840. getClassName(): string;
  34841. /**
  34842. * Get the friendly name associated with the input class.
  34843. * @returns the input friendly name
  34844. */
  34845. getSimpleName(): string;
  34846. }
  34847. }
  34848. declare module BABYLON {
  34849. /**
  34850. * Default Inputs manager for the ArcRotateCamera.
  34851. * It groups all the default supported inputs for ease of use.
  34852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34853. */
  34854. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34855. /**
  34856. * Instantiates a new ArcRotateCameraInputsManager.
  34857. * @param camera Defines the camera the inputs belong to
  34858. */
  34859. constructor(camera: ArcRotateCamera);
  34860. /**
  34861. * Add mouse wheel input support to the input manager.
  34862. * @returns the current input manager
  34863. */
  34864. addMouseWheel(): ArcRotateCameraInputsManager;
  34865. /**
  34866. * Add pointers input support to the input manager.
  34867. * @returns the current input manager
  34868. */
  34869. addPointers(): ArcRotateCameraInputsManager;
  34870. /**
  34871. * Add keyboard input support to the input manager.
  34872. * @returns the current input manager
  34873. */
  34874. addKeyboard(): ArcRotateCameraInputsManager;
  34875. }
  34876. }
  34877. declare module BABYLON {
  34878. /**
  34879. * This represents an orbital type of camera.
  34880. *
  34881. * 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.
  34882. * 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.
  34883. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34884. */
  34885. export class ArcRotateCamera extends TargetCamera {
  34886. /**
  34887. * Defines the rotation angle of the camera along the longitudinal axis.
  34888. */
  34889. alpha: number;
  34890. /**
  34891. * Defines the rotation angle of the camera along the latitudinal axis.
  34892. */
  34893. beta: number;
  34894. /**
  34895. * Defines the radius of the camera from it s target point.
  34896. */
  34897. radius: number;
  34898. protected _target: Vector3;
  34899. protected _targetHost: Nullable<AbstractMesh>;
  34900. /**
  34901. * Defines the target point of the camera.
  34902. * The camera looks towards it form the radius distance.
  34903. */
  34904. target: Vector3;
  34905. /**
  34906. * Define the current local position of the camera in the scene
  34907. */
  34908. position: Vector3;
  34909. /**
  34910. * Current inertia value on the longitudinal axis.
  34911. * The bigger this number the longer it will take for the camera to stop.
  34912. */
  34913. inertialAlphaOffset: number;
  34914. /**
  34915. * Current inertia value on the latitudinal axis.
  34916. * The bigger this number the longer it will take for the camera to stop.
  34917. */
  34918. inertialBetaOffset: number;
  34919. /**
  34920. * Current inertia value on the radius axis.
  34921. * The bigger this number the longer it will take for the camera to stop.
  34922. */
  34923. inertialRadiusOffset: number;
  34924. /**
  34925. * Minimum allowed angle on the longitudinal axis.
  34926. * This can help limiting how the Camera is able to move in the scene.
  34927. */
  34928. lowerAlphaLimit: Nullable<number>;
  34929. /**
  34930. * Maximum allowed angle on the longitudinal axis.
  34931. * This can help limiting how the Camera is able to move in the scene.
  34932. */
  34933. upperAlphaLimit: Nullable<number>;
  34934. /**
  34935. * Minimum allowed angle on the latitudinal axis.
  34936. * This can help limiting how the Camera is able to move in the scene.
  34937. */
  34938. lowerBetaLimit: number;
  34939. /**
  34940. * Maximum allowed angle on the latitudinal axis.
  34941. * This can help limiting how the Camera is able to move in the scene.
  34942. */
  34943. upperBetaLimit: number;
  34944. /**
  34945. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34946. * This can help limiting how the Camera is able to move in the scene.
  34947. */
  34948. lowerRadiusLimit: Nullable<number>;
  34949. /**
  34950. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34951. * This can help limiting how the Camera is able to move in the scene.
  34952. */
  34953. upperRadiusLimit: Nullable<number>;
  34954. /**
  34955. * Defines the current inertia value used during panning of the camera along the X axis.
  34956. */
  34957. inertialPanningX: number;
  34958. /**
  34959. * Defines the current inertia value used during panning of the camera along the Y axis.
  34960. */
  34961. inertialPanningY: number;
  34962. /**
  34963. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34964. * Basically if your fingers moves away from more than this distance you will be considered
  34965. * in pinch mode.
  34966. */
  34967. pinchToPanMaxDistance: number;
  34968. /**
  34969. * Defines the maximum distance the camera can pan.
  34970. * This could help keeping the cammera always in your scene.
  34971. */
  34972. panningDistanceLimit: Nullable<number>;
  34973. /**
  34974. * Defines the target of the camera before paning.
  34975. */
  34976. panningOriginTarget: Vector3;
  34977. /**
  34978. * Defines the value of the inertia used during panning.
  34979. * 0 would mean stop inertia and one would mean no decelleration at all.
  34980. */
  34981. panningInertia: number;
  34982. /**
  34983. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34984. */
  34985. angularSensibilityX: number;
  34986. /**
  34987. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34988. */
  34989. angularSensibilityY: number;
  34990. /**
  34991. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34992. */
  34993. pinchPrecision: number;
  34994. /**
  34995. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34996. * It will be used instead of pinchDeltaPrecision if different from 0.
  34997. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34998. */
  34999. pinchDeltaPercentage: number;
  35000. /**
  35001. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35002. */
  35003. panningSensibility: number;
  35004. /**
  35005. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35006. */
  35007. keysUp: number[];
  35008. /**
  35009. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35010. */
  35011. keysDown: number[];
  35012. /**
  35013. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35014. */
  35015. keysLeft: number[];
  35016. /**
  35017. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35018. */
  35019. keysRight: number[];
  35020. /**
  35021. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35022. */
  35023. wheelPrecision: number;
  35024. /**
  35025. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35026. * It will be used instead of pinchDeltaPrecision if different from 0.
  35027. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35028. */
  35029. wheelDeltaPercentage: number;
  35030. /**
  35031. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35032. */
  35033. zoomOnFactor: number;
  35034. /**
  35035. * Defines a screen offset for the camera position.
  35036. */
  35037. targetScreenOffset: Vector2;
  35038. /**
  35039. * Allows the camera to be completely reversed.
  35040. * If false the camera can not arrive upside down.
  35041. */
  35042. allowUpsideDown: boolean;
  35043. /**
  35044. * Define if double tap/click is used to restore the previously saved state of the camera.
  35045. */
  35046. useInputToRestoreState: boolean;
  35047. /** @hidden */
  35048. _viewMatrix: Matrix;
  35049. /** @hidden */
  35050. _useCtrlForPanning: boolean;
  35051. /** @hidden */
  35052. _panningMouseButton: number;
  35053. /**
  35054. * Defines the input associated to the camera.
  35055. */
  35056. inputs: ArcRotateCameraInputsManager;
  35057. /** @hidden */
  35058. _reset: () => void;
  35059. /**
  35060. * Defines the allowed panning axis.
  35061. */
  35062. panningAxis: Vector3;
  35063. protected _localDirection: Vector3;
  35064. protected _transformedDirection: Vector3;
  35065. private _bouncingBehavior;
  35066. /**
  35067. * Gets the bouncing behavior of the camera if it has been enabled.
  35068. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35069. */
  35070. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35071. /**
  35072. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35073. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35074. */
  35075. useBouncingBehavior: boolean;
  35076. private _framingBehavior;
  35077. /**
  35078. * Gets the framing behavior of the camera if it has been enabled.
  35079. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35080. */
  35081. readonly framingBehavior: Nullable<FramingBehavior>;
  35082. /**
  35083. * Defines if the framing behavior of the camera is enabled on the camera.
  35084. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35085. */
  35086. useFramingBehavior: boolean;
  35087. private _autoRotationBehavior;
  35088. /**
  35089. * Gets the auto rotation behavior of the camera if it has been enabled.
  35090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35091. */
  35092. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35093. /**
  35094. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35095. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35096. */
  35097. useAutoRotationBehavior: boolean;
  35098. /**
  35099. * Observable triggered when the mesh target has been changed on the camera.
  35100. */
  35101. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35102. /**
  35103. * Event raised when the camera is colliding with a mesh.
  35104. */
  35105. onCollide: (collidedMesh: AbstractMesh) => void;
  35106. /**
  35107. * Defines whether the camera should check collision with the objects oh the scene.
  35108. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35109. */
  35110. checkCollisions: boolean;
  35111. /**
  35112. * Defines the collision radius of the camera.
  35113. * This simulates a sphere around the camera.
  35114. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35115. */
  35116. collisionRadius: Vector3;
  35117. protected _collider: Collider;
  35118. protected _previousPosition: Vector3;
  35119. protected _collisionVelocity: Vector3;
  35120. protected _newPosition: Vector3;
  35121. protected _previousAlpha: number;
  35122. protected _previousBeta: number;
  35123. protected _previousRadius: number;
  35124. protected _collisionTriggered: boolean;
  35125. protected _targetBoundingCenter: Nullable<Vector3>;
  35126. private _computationVector;
  35127. private _tempAxisVector;
  35128. private _tempAxisRotationMatrix;
  35129. /**
  35130. * Instantiates a new ArcRotateCamera in a given scene
  35131. * @param name Defines the name of the camera
  35132. * @param alpha Defines the camera rotation along the logitudinal axis
  35133. * @param beta Defines the camera rotation along the latitudinal axis
  35134. * @param radius Defines the camera distance from its target
  35135. * @param target Defines the camera target
  35136. * @param scene Defines the scene the camera belongs to
  35137. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35138. */
  35139. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35140. /** @hidden */
  35141. _initCache(): void;
  35142. /** @hidden */
  35143. _updateCache(ignoreParentClass?: boolean): void;
  35144. protected _getTargetPosition(): Vector3;
  35145. private _storedAlpha;
  35146. private _storedBeta;
  35147. private _storedRadius;
  35148. private _storedTarget;
  35149. /**
  35150. * Stores the current state of the camera (alpha, beta, radius and target)
  35151. * @returns the camera itself
  35152. */
  35153. storeState(): Camera;
  35154. /**
  35155. * @hidden
  35156. * Restored camera state. You must call storeState() first
  35157. */
  35158. _restoreStateValues(): boolean;
  35159. /** @hidden */
  35160. _isSynchronizedViewMatrix(): boolean;
  35161. /**
  35162. * Attached controls to the current camera.
  35163. * @param element Defines the element the controls should be listened from
  35164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35165. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35166. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35167. */
  35168. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35169. /**
  35170. * Detach the current controls from the camera.
  35171. * The camera will stop reacting to inputs.
  35172. * @param element Defines the element to stop listening the inputs from
  35173. */
  35174. detachControl(element: HTMLElement): void;
  35175. /** @hidden */
  35176. _checkInputs(): void;
  35177. protected _checkLimits(): void;
  35178. /**
  35179. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35180. */
  35181. rebuildAnglesAndRadius(): void;
  35182. /**
  35183. * Use a position to define the current camera related information like aplha, beta and radius
  35184. * @param position Defines the position to set the camera at
  35185. */
  35186. setPosition(position: Vector3): void;
  35187. /**
  35188. * Defines the target the camera should look at.
  35189. * This will automatically adapt alpha beta and radius to fit within the new target.
  35190. * @param target Defines the new target as a Vector or a mesh
  35191. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35192. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35193. */
  35194. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35195. /** @hidden */
  35196. _getViewMatrix(): Matrix;
  35197. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35198. /**
  35199. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35200. * @param meshes Defines the mesh to zoom on
  35201. * @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)
  35202. */
  35203. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35204. /**
  35205. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35206. * The target will be changed but the radius
  35207. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35208. * @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)
  35209. */
  35210. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35211. min: Vector3;
  35212. max: Vector3;
  35213. distance: number;
  35214. }, doNotUpdateMaxZ?: boolean): void;
  35215. /**
  35216. * @override
  35217. * Override Camera.createRigCamera
  35218. */
  35219. createRigCamera(name: string, cameraIndex: number): Camera;
  35220. /**
  35221. * @hidden
  35222. * @override
  35223. * Override Camera._updateRigCameras
  35224. */
  35225. _updateRigCameras(): void;
  35226. /**
  35227. * Destroy the camera and release the current resources hold by it.
  35228. */
  35229. dispose(): void;
  35230. /**
  35231. * Gets the current object class name.
  35232. * @return the class name
  35233. */
  35234. getClassName(): string;
  35235. }
  35236. }
  35237. declare module BABYLON {
  35238. /**
  35239. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35240. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35241. */
  35242. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35243. /**
  35244. * Gets the name of the behavior.
  35245. */
  35246. readonly name: string;
  35247. private _zoomStopsAnimation;
  35248. private _idleRotationSpeed;
  35249. private _idleRotationWaitTime;
  35250. private _idleRotationSpinupTime;
  35251. /**
  35252. * Sets the flag that indicates if user zooming should stop animation.
  35253. */
  35254. /**
  35255. * Gets the flag that indicates if user zooming should stop animation.
  35256. */
  35257. zoomStopsAnimation: boolean;
  35258. /**
  35259. * Sets the default speed at which the camera rotates around the model.
  35260. */
  35261. /**
  35262. * Gets the default speed at which the camera rotates around the model.
  35263. */
  35264. idleRotationSpeed: number;
  35265. /**
  35266. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35267. */
  35268. /**
  35269. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35270. */
  35271. idleRotationWaitTime: number;
  35272. /**
  35273. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35274. */
  35275. /**
  35276. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35277. */
  35278. idleRotationSpinupTime: number;
  35279. /**
  35280. * Gets a value indicating if the camera is currently rotating because of this behavior
  35281. */
  35282. readonly rotationInProgress: boolean;
  35283. private _onPrePointerObservableObserver;
  35284. private _onAfterCheckInputsObserver;
  35285. private _attachedCamera;
  35286. private _isPointerDown;
  35287. private _lastFrameTime;
  35288. private _lastInteractionTime;
  35289. private _cameraRotationSpeed;
  35290. /**
  35291. * Initializes the behavior.
  35292. */
  35293. init(): void;
  35294. /**
  35295. * Attaches the behavior to its arc rotate camera.
  35296. * @param camera Defines the camera to attach the behavior to
  35297. */
  35298. attach(camera: ArcRotateCamera): void;
  35299. /**
  35300. * Detaches the behavior from its current arc rotate camera.
  35301. */
  35302. detach(): void;
  35303. /**
  35304. * Returns true if user is scrolling.
  35305. * @return true if user is scrolling.
  35306. */
  35307. private _userIsZooming;
  35308. private _lastFrameRadius;
  35309. private _shouldAnimationStopForInteraction;
  35310. /**
  35311. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35312. */
  35313. private _applyUserInteraction;
  35314. private _userIsMoving;
  35315. }
  35316. }
  35317. declare module BABYLON {
  35318. /**
  35319. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35320. */
  35321. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35322. private ui;
  35323. /**
  35324. * The name of the behavior
  35325. */
  35326. name: string;
  35327. /**
  35328. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35329. */
  35330. distanceAwayFromFace: number;
  35331. /**
  35332. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35333. */
  35334. distanceAwayFromBottomOfFace: number;
  35335. private _faceVectors;
  35336. private _target;
  35337. private _scene;
  35338. private _onRenderObserver;
  35339. private _tmpMatrix;
  35340. private _tmpVector;
  35341. /**
  35342. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35343. * @param ui The transform node that should be attched to the mesh
  35344. */
  35345. constructor(ui: TransformNode);
  35346. /**
  35347. * Initializes the behavior
  35348. */
  35349. init(): void;
  35350. private _closestFace;
  35351. private _zeroVector;
  35352. private _lookAtTmpMatrix;
  35353. private _lookAtToRef;
  35354. /**
  35355. * Attaches the AttachToBoxBehavior to the passed in mesh
  35356. * @param target The mesh that the specified node will be attached to
  35357. */
  35358. attach(target: Mesh): void;
  35359. /**
  35360. * Detaches the behavior from the mesh
  35361. */
  35362. detach(): void;
  35363. }
  35364. }
  35365. declare module BABYLON {
  35366. /**
  35367. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35368. */
  35369. export class FadeInOutBehavior implements Behavior<Mesh> {
  35370. /**
  35371. * Time in milliseconds to delay before fading in (Default: 0)
  35372. */
  35373. delay: number;
  35374. /**
  35375. * Time in milliseconds for the mesh to fade in (Default: 300)
  35376. */
  35377. fadeInTime: number;
  35378. private _millisecondsPerFrame;
  35379. private _hovered;
  35380. private _hoverValue;
  35381. private _ownerNode;
  35382. /**
  35383. * Instatiates the FadeInOutBehavior
  35384. */
  35385. constructor();
  35386. /**
  35387. * The name of the behavior
  35388. */
  35389. readonly name: string;
  35390. /**
  35391. * Initializes the behavior
  35392. */
  35393. init(): void;
  35394. /**
  35395. * Attaches the fade behavior on the passed in mesh
  35396. * @param ownerNode The mesh that will be faded in/out once attached
  35397. */
  35398. attach(ownerNode: Mesh): void;
  35399. /**
  35400. * Detaches the behavior from the mesh
  35401. */
  35402. detach(): void;
  35403. /**
  35404. * Triggers the mesh to begin fading in or out
  35405. * @param value if the object should fade in or out (true to fade in)
  35406. */
  35407. fadeIn(value: boolean): void;
  35408. private _update;
  35409. private _setAllVisibility;
  35410. }
  35411. }
  35412. declare module BABYLON {
  35413. /**
  35414. * Class containing a set of static utilities functions for managing Pivots
  35415. * @hidden
  35416. */
  35417. export class PivotTools {
  35418. private static _PivotCached;
  35419. private static _OldPivotPoint;
  35420. private static _PivotTranslation;
  35421. private static _PivotTmpVector;
  35422. /** @hidden */
  35423. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35424. /** @hidden */
  35425. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35426. }
  35427. }
  35428. declare module BABYLON {
  35429. /**
  35430. * Class containing static functions to help procedurally build meshes
  35431. */
  35432. export class PlaneBuilder {
  35433. /**
  35434. * Creates a plane mesh
  35435. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35436. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35437. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35439. * * 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
  35440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35441. * @param name defines the name of the mesh
  35442. * @param options defines the options used to create the mesh
  35443. * @param scene defines the hosting scene
  35444. * @returns the plane mesh
  35445. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35446. */
  35447. static CreatePlane(name: string, options: {
  35448. size?: number;
  35449. width?: number;
  35450. height?: number;
  35451. sideOrientation?: number;
  35452. frontUVs?: Vector4;
  35453. backUVs?: Vector4;
  35454. updatable?: boolean;
  35455. sourcePlane?: Plane;
  35456. }, scene: Scene): Mesh;
  35457. }
  35458. }
  35459. declare module BABYLON {
  35460. /**
  35461. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35462. */
  35463. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35464. private static _AnyMouseID;
  35465. private _attachedNode;
  35466. private _dragPlane;
  35467. private _scene;
  35468. private _pointerObserver;
  35469. private _beforeRenderObserver;
  35470. private static _planeScene;
  35471. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35472. /**
  35473. * 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)
  35474. */
  35475. maxDragAngle: number;
  35476. /**
  35477. * @hidden
  35478. */
  35479. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35480. /**
  35481. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35482. */
  35483. currentDraggingPointerID: number;
  35484. /**
  35485. * The last position where the pointer hit the drag plane in world space
  35486. */
  35487. lastDragPosition: Vector3;
  35488. /**
  35489. * If the behavior is currently in a dragging state
  35490. */
  35491. dragging: boolean;
  35492. /**
  35493. * 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)
  35494. */
  35495. dragDeltaRatio: number;
  35496. /**
  35497. * If the drag plane orientation should be updated during the dragging (Default: true)
  35498. */
  35499. updateDragPlane: boolean;
  35500. private _debugMode;
  35501. private _moving;
  35502. /**
  35503. * Fires each time the attached mesh is dragged with the pointer
  35504. * * delta between last drag position and current drag position in world space
  35505. * * dragDistance along the drag axis
  35506. * * dragPlaneNormal normal of the current drag plane used during the drag
  35507. * * dragPlanePoint in world space where the drag intersects the drag plane
  35508. */
  35509. onDragObservable: Observable<{
  35510. delta: Vector3;
  35511. dragPlanePoint: Vector3;
  35512. dragPlaneNormal: Vector3;
  35513. dragDistance: number;
  35514. pointerId: number;
  35515. }>;
  35516. /**
  35517. * Fires each time a drag begins (eg. mouse down on mesh)
  35518. */
  35519. onDragStartObservable: Observable<{
  35520. dragPlanePoint: Vector3;
  35521. pointerId: number;
  35522. }>;
  35523. /**
  35524. * Fires each time a drag ends (eg. mouse release after drag)
  35525. */
  35526. onDragEndObservable: Observable<{
  35527. dragPlanePoint: Vector3;
  35528. pointerId: number;
  35529. }>;
  35530. /**
  35531. * If the attached mesh should be moved when dragged
  35532. */
  35533. moveAttached: boolean;
  35534. /**
  35535. * If the drag behavior will react to drag events (Default: true)
  35536. */
  35537. enabled: boolean;
  35538. /**
  35539. * If camera controls should be detached during the drag
  35540. */
  35541. detachCameraControls: boolean;
  35542. /**
  35543. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35544. */
  35545. useObjectOrienationForDragging: boolean;
  35546. private _options;
  35547. /**
  35548. * Creates a pointer drag behavior that can be attached to a mesh
  35549. * @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)
  35550. */
  35551. constructor(options?: {
  35552. dragAxis?: Vector3;
  35553. dragPlaneNormal?: Vector3;
  35554. });
  35555. /**
  35556. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35557. */
  35558. validateDrag: (targetPosition: Vector3) => boolean;
  35559. /**
  35560. * The name of the behavior
  35561. */
  35562. readonly name: string;
  35563. /**
  35564. * Initializes the behavior
  35565. */
  35566. init(): void;
  35567. private _tmpVector;
  35568. private _alternatePickedPoint;
  35569. private _worldDragAxis;
  35570. private _targetPosition;
  35571. private _attachedElement;
  35572. /**
  35573. * Attaches the drag behavior the passed in mesh
  35574. * @param ownerNode The mesh that will be dragged around once attached
  35575. */
  35576. attach(ownerNode: AbstractMesh): void;
  35577. /**
  35578. * Force relase the drag action by code.
  35579. */
  35580. releaseDrag(): void;
  35581. private _startDragRay;
  35582. private _lastPointerRay;
  35583. /**
  35584. * Simulates the start of a pointer drag event on the behavior
  35585. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35586. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35587. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35588. */
  35589. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35590. private _startDrag;
  35591. private _dragDelta;
  35592. private _moveDrag;
  35593. private _pickWithRayOnDragPlane;
  35594. private _pointA;
  35595. private _pointB;
  35596. private _pointC;
  35597. private _lineA;
  35598. private _lineB;
  35599. private _localAxis;
  35600. private _lookAt;
  35601. private _updateDragPlanePosition;
  35602. /**
  35603. * Detaches the behavior from the mesh
  35604. */
  35605. detach(): void;
  35606. }
  35607. }
  35608. declare module BABYLON {
  35609. /**
  35610. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35611. */
  35612. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35613. private _dragBehaviorA;
  35614. private _dragBehaviorB;
  35615. private _startDistance;
  35616. private _initialScale;
  35617. private _targetScale;
  35618. private _ownerNode;
  35619. private _sceneRenderObserver;
  35620. /**
  35621. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35622. */
  35623. constructor();
  35624. /**
  35625. * The name of the behavior
  35626. */
  35627. readonly name: string;
  35628. /**
  35629. * Initializes the behavior
  35630. */
  35631. init(): void;
  35632. private _getCurrentDistance;
  35633. /**
  35634. * Attaches the scale behavior the passed in mesh
  35635. * @param ownerNode The mesh that will be scaled around once attached
  35636. */
  35637. attach(ownerNode: Mesh): void;
  35638. /**
  35639. * Detaches the behavior from the mesh
  35640. */
  35641. detach(): void;
  35642. }
  35643. }
  35644. declare module BABYLON {
  35645. /**
  35646. * 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
  35647. */
  35648. export class SixDofDragBehavior implements Behavior<Mesh> {
  35649. private static _virtualScene;
  35650. private _ownerNode;
  35651. private _sceneRenderObserver;
  35652. private _scene;
  35653. private _targetPosition;
  35654. private _virtualOriginMesh;
  35655. private _virtualDragMesh;
  35656. private _pointerObserver;
  35657. private _moving;
  35658. private _startingOrientation;
  35659. /**
  35660. * 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)
  35661. */
  35662. private zDragFactor;
  35663. /**
  35664. * If the object should rotate to face the drag origin
  35665. */
  35666. rotateDraggedObject: boolean;
  35667. /**
  35668. * If the behavior is currently in a dragging state
  35669. */
  35670. dragging: boolean;
  35671. /**
  35672. * 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)
  35673. */
  35674. dragDeltaRatio: number;
  35675. /**
  35676. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35677. */
  35678. currentDraggingPointerID: number;
  35679. /**
  35680. * If camera controls should be detached during the drag
  35681. */
  35682. detachCameraControls: boolean;
  35683. /**
  35684. * Fires each time a drag starts
  35685. */
  35686. onDragStartObservable: Observable<{}>;
  35687. /**
  35688. * Fires each time a drag ends (eg. mouse release after drag)
  35689. */
  35690. onDragEndObservable: Observable<{}>;
  35691. /**
  35692. * 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
  35693. */
  35694. constructor();
  35695. /**
  35696. * The name of the behavior
  35697. */
  35698. readonly name: string;
  35699. /**
  35700. * Initializes the behavior
  35701. */
  35702. init(): void;
  35703. /**
  35704. * Attaches the scale behavior the passed in mesh
  35705. * @param ownerNode The mesh that will be scaled around once attached
  35706. */
  35707. attach(ownerNode: Mesh): void;
  35708. /**
  35709. * Detaches the behavior from the mesh
  35710. */
  35711. detach(): void;
  35712. }
  35713. }
  35714. declare module BABYLON {
  35715. /**
  35716. * Class used to apply inverse kinematics to bones
  35717. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35718. */
  35719. export class BoneIKController {
  35720. private static _tmpVecs;
  35721. private static _tmpQuat;
  35722. private static _tmpMats;
  35723. /**
  35724. * Gets or sets the target mesh
  35725. */
  35726. targetMesh: AbstractMesh;
  35727. /** Gets or sets the mesh used as pole */
  35728. poleTargetMesh: AbstractMesh;
  35729. /**
  35730. * Gets or sets the bone used as pole
  35731. */
  35732. poleTargetBone: Nullable<Bone>;
  35733. /**
  35734. * Gets or sets the target position
  35735. */
  35736. targetPosition: Vector3;
  35737. /**
  35738. * Gets or sets the pole target position
  35739. */
  35740. poleTargetPosition: Vector3;
  35741. /**
  35742. * Gets or sets the pole target local offset
  35743. */
  35744. poleTargetLocalOffset: Vector3;
  35745. /**
  35746. * Gets or sets the pole angle
  35747. */
  35748. poleAngle: number;
  35749. /**
  35750. * Gets or sets the mesh associated with the controller
  35751. */
  35752. mesh: AbstractMesh;
  35753. /**
  35754. * 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)
  35755. */
  35756. slerpAmount: number;
  35757. private _bone1Quat;
  35758. private _bone1Mat;
  35759. private _bone2Ang;
  35760. private _bone1;
  35761. private _bone2;
  35762. private _bone1Length;
  35763. private _bone2Length;
  35764. private _maxAngle;
  35765. private _maxReach;
  35766. private _rightHandedSystem;
  35767. private _bendAxis;
  35768. private _slerping;
  35769. private _adjustRoll;
  35770. /**
  35771. * Gets or sets maximum allowed angle
  35772. */
  35773. maxAngle: number;
  35774. /**
  35775. * Creates a new BoneIKController
  35776. * @param mesh defines the mesh to control
  35777. * @param bone defines the bone to control
  35778. * @param options defines options to set up the controller
  35779. */
  35780. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35781. targetMesh?: AbstractMesh;
  35782. poleTargetMesh?: AbstractMesh;
  35783. poleTargetBone?: Bone;
  35784. poleTargetLocalOffset?: Vector3;
  35785. poleAngle?: number;
  35786. bendAxis?: Vector3;
  35787. maxAngle?: number;
  35788. slerpAmount?: number;
  35789. });
  35790. private _setMaxAngle;
  35791. /**
  35792. * Force the controller to update the bones
  35793. */
  35794. update(): void;
  35795. }
  35796. }
  35797. declare module BABYLON {
  35798. /**
  35799. * Class used to make a bone look toward a point in space
  35800. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35801. */
  35802. export class BoneLookController {
  35803. private static _tmpVecs;
  35804. private static _tmpQuat;
  35805. private static _tmpMats;
  35806. /**
  35807. * The target Vector3 that the bone will look at
  35808. */
  35809. target: Vector3;
  35810. /**
  35811. * The mesh that the bone is attached to
  35812. */
  35813. mesh: AbstractMesh;
  35814. /**
  35815. * The bone that will be looking to the target
  35816. */
  35817. bone: Bone;
  35818. /**
  35819. * The up axis of the coordinate system that is used when the bone is rotated
  35820. */
  35821. upAxis: Vector3;
  35822. /**
  35823. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35824. */
  35825. upAxisSpace: Space;
  35826. /**
  35827. * Used to make an adjustment to the yaw of the bone
  35828. */
  35829. adjustYaw: number;
  35830. /**
  35831. * Used to make an adjustment to the pitch of the bone
  35832. */
  35833. adjustPitch: number;
  35834. /**
  35835. * Used to make an adjustment to the roll of the bone
  35836. */
  35837. adjustRoll: number;
  35838. /**
  35839. * 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)
  35840. */
  35841. slerpAmount: number;
  35842. private _minYaw;
  35843. private _maxYaw;
  35844. private _minPitch;
  35845. private _maxPitch;
  35846. private _minYawSin;
  35847. private _minYawCos;
  35848. private _maxYawSin;
  35849. private _maxYawCos;
  35850. private _midYawConstraint;
  35851. private _minPitchTan;
  35852. private _maxPitchTan;
  35853. private _boneQuat;
  35854. private _slerping;
  35855. private _transformYawPitch;
  35856. private _transformYawPitchInv;
  35857. private _firstFrameSkipped;
  35858. private _yawRange;
  35859. private _fowardAxis;
  35860. /**
  35861. * Gets or sets the minimum yaw angle that the bone can look to
  35862. */
  35863. minYaw: number;
  35864. /**
  35865. * Gets or sets the maximum yaw angle that the bone can look to
  35866. */
  35867. maxYaw: number;
  35868. /**
  35869. * Gets or sets the minimum pitch angle that the bone can look to
  35870. */
  35871. minPitch: number;
  35872. /**
  35873. * Gets or sets the maximum pitch angle that the bone can look to
  35874. */
  35875. maxPitch: number;
  35876. /**
  35877. * Create a BoneLookController
  35878. * @param mesh the mesh that the bone belongs to
  35879. * @param bone the bone that will be looking to the target
  35880. * @param target the target Vector3 to look at
  35881. * @param options optional settings:
  35882. * * maxYaw: the maximum angle the bone will yaw to
  35883. * * minYaw: the minimum angle the bone will yaw to
  35884. * * maxPitch: the maximum angle the bone will pitch to
  35885. * * minPitch: the minimum angle the bone will yaw to
  35886. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35887. * * upAxis: the up axis of the coordinate system
  35888. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35889. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35890. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35891. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35892. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35893. * * adjustRoll: used to make an adjustment to the roll of the bone
  35894. **/
  35895. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35896. maxYaw?: number;
  35897. minYaw?: number;
  35898. maxPitch?: number;
  35899. minPitch?: number;
  35900. slerpAmount?: number;
  35901. upAxis?: Vector3;
  35902. upAxisSpace?: Space;
  35903. yawAxis?: Vector3;
  35904. pitchAxis?: Vector3;
  35905. adjustYaw?: number;
  35906. adjustPitch?: number;
  35907. adjustRoll?: number;
  35908. });
  35909. /**
  35910. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35911. */
  35912. update(): void;
  35913. private _getAngleDiff;
  35914. private _getAngleBetween;
  35915. private _isAngleBetween;
  35916. }
  35917. }
  35918. declare module BABYLON {
  35919. /**
  35920. * Manage the gamepad inputs to control an arc rotate camera.
  35921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35922. */
  35923. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35924. /**
  35925. * Defines the camera the input is attached to.
  35926. */
  35927. camera: ArcRotateCamera;
  35928. /**
  35929. * Defines the gamepad the input is gathering event from.
  35930. */
  35931. gamepad: Nullable<Gamepad>;
  35932. /**
  35933. * Defines the gamepad rotation sensiblity.
  35934. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35935. */
  35936. gamepadRotationSensibility: number;
  35937. /**
  35938. * Defines the gamepad move sensiblity.
  35939. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35940. */
  35941. gamepadMoveSensibility: number;
  35942. private _onGamepadConnectedObserver;
  35943. private _onGamepadDisconnectedObserver;
  35944. /**
  35945. * Attach the input controls to a specific dom element to get the input from.
  35946. * @param element Defines the element the controls should be listened from
  35947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35948. */
  35949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35950. /**
  35951. * Detach the current controls from the specified dom element.
  35952. * @param element Defines the element to stop listening the inputs from
  35953. */
  35954. detachControl(element: Nullable<HTMLElement>): void;
  35955. /**
  35956. * Update the current camera state depending on the inputs that have been used this frame.
  35957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35958. */
  35959. checkInputs(): void;
  35960. /**
  35961. * Gets the class name of the current intput.
  35962. * @returns the class name
  35963. */
  35964. getClassName(): string;
  35965. /**
  35966. * Get the friendly name associated with the input class.
  35967. * @returns the input friendly name
  35968. */
  35969. getSimpleName(): string;
  35970. }
  35971. }
  35972. declare module BABYLON {
  35973. interface ArcRotateCameraInputsManager {
  35974. /**
  35975. * Add orientation input support to the input manager.
  35976. * @returns the current input manager
  35977. */
  35978. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35979. }
  35980. /**
  35981. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35983. */
  35984. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35985. /**
  35986. * Defines the camera the input is attached to.
  35987. */
  35988. camera: ArcRotateCamera;
  35989. /**
  35990. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35991. */
  35992. alphaCorrection: number;
  35993. /**
  35994. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35995. */
  35996. gammaCorrection: number;
  35997. private _alpha;
  35998. private _gamma;
  35999. private _dirty;
  36000. private _deviceOrientationHandler;
  36001. /**
  36002. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36003. */
  36004. constructor();
  36005. /**
  36006. * Attach the input controls to a specific dom element to get the input from.
  36007. * @param element Defines the element the controls should be listened from
  36008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36009. */
  36010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36011. /** @hidden */
  36012. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36013. /**
  36014. * Update the current camera state depending on the inputs that have been used this frame.
  36015. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36016. */
  36017. checkInputs(): void;
  36018. /**
  36019. * Detach the current controls from the specified dom element.
  36020. * @param element Defines the element to stop listening the inputs from
  36021. */
  36022. detachControl(element: Nullable<HTMLElement>): void;
  36023. /**
  36024. * Gets the class name of the current intput.
  36025. * @returns the class name
  36026. */
  36027. getClassName(): string;
  36028. /**
  36029. * Get the friendly name associated with the input class.
  36030. * @returns the input friendly name
  36031. */
  36032. getSimpleName(): string;
  36033. }
  36034. }
  36035. declare module BABYLON {
  36036. /**
  36037. * Listen to mouse events to control the camera.
  36038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36039. */
  36040. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36041. /**
  36042. * Defines the camera the input is attached to.
  36043. */
  36044. camera: FlyCamera;
  36045. /**
  36046. * Defines if touch is enabled. (Default is true.)
  36047. */
  36048. touchEnabled: boolean;
  36049. /**
  36050. * Defines the buttons associated with the input to handle camera rotation.
  36051. */
  36052. buttons: number[];
  36053. /**
  36054. * Assign buttons for Yaw control.
  36055. */
  36056. buttonsYaw: number[];
  36057. /**
  36058. * Assign buttons for Pitch control.
  36059. */
  36060. buttonsPitch: number[];
  36061. /**
  36062. * Assign buttons for Roll control.
  36063. */
  36064. buttonsRoll: number[];
  36065. /**
  36066. * Detect if any button is being pressed while mouse is moved.
  36067. * -1 = Mouse locked.
  36068. * 0 = Left button.
  36069. * 1 = Middle Button.
  36070. * 2 = Right Button.
  36071. */
  36072. activeButton: number;
  36073. /**
  36074. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36075. * Higher values reduce its sensitivity.
  36076. */
  36077. angularSensibility: number;
  36078. private _mousemoveCallback;
  36079. private _observer;
  36080. private _rollObserver;
  36081. private previousPosition;
  36082. private noPreventDefault;
  36083. private element;
  36084. /**
  36085. * Listen to mouse events to control the camera.
  36086. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36088. */
  36089. constructor(touchEnabled?: boolean);
  36090. /**
  36091. * Attach the mouse control to the HTML DOM element.
  36092. * @param element Defines the element that listens to the input events.
  36093. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36094. */
  36095. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36096. /**
  36097. * Detach the current controls from the specified dom element.
  36098. * @param element Defines the element to stop listening the inputs from
  36099. */
  36100. detachControl(element: Nullable<HTMLElement>): void;
  36101. /**
  36102. * Gets the class name of the current input.
  36103. * @returns the class name.
  36104. */
  36105. getClassName(): string;
  36106. /**
  36107. * Get the friendly name associated with the input class.
  36108. * @returns the input's friendly name.
  36109. */
  36110. getSimpleName(): string;
  36111. private _pointerInput;
  36112. private _onMouseMove;
  36113. /**
  36114. * Rotate camera by mouse offset.
  36115. */
  36116. private rotateCamera;
  36117. }
  36118. }
  36119. declare module BABYLON {
  36120. /**
  36121. * Default Inputs manager for the FlyCamera.
  36122. * It groups all the default supported inputs for ease of use.
  36123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36124. */
  36125. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36126. /**
  36127. * Instantiates a new FlyCameraInputsManager.
  36128. * @param camera Defines the camera the inputs belong to.
  36129. */
  36130. constructor(camera: FlyCamera);
  36131. /**
  36132. * Add keyboard input support to the input manager.
  36133. * @returns the new FlyCameraKeyboardMoveInput().
  36134. */
  36135. addKeyboard(): FlyCameraInputsManager;
  36136. /**
  36137. * Add mouse input support to the input manager.
  36138. * @param touchEnabled Enable touch screen support.
  36139. * @returns the new FlyCameraMouseInput().
  36140. */
  36141. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36142. }
  36143. }
  36144. declare module BABYLON {
  36145. /**
  36146. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36147. * such as in a 3D Space Shooter or a Flight Simulator.
  36148. */
  36149. export class FlyCamera extends TargetCamera {
  36150. /**
  36151. * Define the collision ellipsoid of the camera.
  36152. * This is helpful for simulating a camera body, like a player's body.
  36153. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36154. */
  36155. ellipsoid: Vector3;
  36156. /**
  36157. * Define an offset for the position of the ellipsoid around the camera.
  36158. * This can be helpful if the camera is attached away from the player's body center,
  36159. * such as at its head.
  36160. */
  36161. ellipsoidOffset: Vector3;
  36162. /**
  36163. * Enable or disable collisions of the camera with the rest of the scene objects.
  36164. */
  36165. checkCollisions: boolean;
  36166. /**
  36167. * Enable or disable gravity on the camera.
  36168. */
  36169. applyGravity: boolean;
  36170. /**
  36171. * Define the current direction the camera is moving to.
  36172. */
  36173. cameraDirection: Vector3;
  36174. /**
  36175. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36176. * This overrides and empties cameraRotation.
  36177. */
  36178. rotationQuaternion: Quaternion;
  36179. /**
  36180. * Track Roll to maintain the wanted Rolling when looking around.
  36181. */
  36182. _trackRoll: number;
  36183. /**
  36184. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36185. */
  36186. rollCorrect: number;
  36187. /**
  36188. * Mimic a banked turn, Rolling the camera when Yawing.
  36189. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36190. */
  36191. bankedTurn: boolean;
  36192. /**
  36193. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36194. */
  36195. bankedTurnLimit: number;
  36196. /**
  36197. * Value of 0 disables the banked Roll.
  36198. * Value of 1 is equal to the Yaw angle in radians.
  36199. */
  36200. bankedTurnMultiplier: number;
  36201. /**
  36202. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36203. */
  36204. inputs: FlyCameraInputsManager;
  36205. /**
  36206. * Gets the input sensibility for mouse input.
  36207. * Higher values reduce sensitivity.
  36208. */
  36209. /**
  36210. * Sets the input sensibility for a mouse input.
  36211. * Higher values reduce sensitivity.
  36212. */
  36213. angularSensibility: number;
  36214. /**
  36215. * Get the keys for camera movement forward.
  36216. */
  36217. /**
  36218. * Set the keys for camera movement forward.
  36219. */
  36220. keysForward: number[];
  36221. /**
  36222. * Get the keys for camera movement backward.
  36223. */
  36224. keysBackward: number[];
  36225. /**
  36226. * Get the keys for camera movement up.
  36227. */
  36228. /**
  36229. * Set the keys for camera movement up.
  36230. */
  36231. keysUp: number[];
  36232. /**
  36233. * Get the keys for camera movement down.
  36234. */
  36235. /**
  36236. * Set the keys for camera movement down.
  36237. */
  36238. keysDown: number[];
  36239. /**
  36240. * Get the keys for camera movement left.
  36241. */
  36242. /**
  36243. * Set the keys for camera movement left.
  36244. */
  36245. keysLeft: number[];
  36246. /**
  36247. * Set the keys for camera movement right.
  36248. */
  36249. /**
  36250. * Set the keys for camera movement right.
  36251. */
  36252. keysRight: number[];
  36253. /**
  36254. * Event raised when the camera collides with a mesh in the scene.
  36255. */
  36256. onCollide: (collidedMesh: AbstractMesh) => void;
  36257. private _collider;
  36258. private _needMoveForGravity;
  36259. private _oldPosition;
  36260. private _diffPosition;
  36261. private _newPosition;
  36262. /** @hidden */
  36263. _localDirection: Vector3;
  36264. /** @hidden */
  36265. _transformedDirection: Vector3;
  36266. /**
  36267. * Instantiates a FlyCamera.
  36268. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36269. * such as in a 3D Space Shooter or a Flight Simulator.
  36270. * @param name Define the name of the camera in the scene.
  36271. * @param position Define the starting position of the camera in the scene.
  36272. * @param scene Define the scene the camera belongs to.
  36273. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36274. */
  36275. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36276. /**
  36277. * Attach a control to the HTML DOM element.
  36278. * @param element Defines the element that listens to the input events.
  36279. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36280. */
  36281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36282. /**
  36283. * Detach a control from the HTML DOM element.
  36284. * The camera will stop reacting to that input.
  36285. * @param element Defines the element that listens to the input events.
  36286. */
  36287. detachControl(element: HTMLElement): void;
  36288. private _collisionMask;
  36289. /**
  36290. * Get the mask that the camera ignores in collision events.
  36291. */
  36292. /**
  36293. * Set the mask that the camera ignores in collision events.
  36294. */
  36295. collisionMask: number;
  36296. /** @hidden */
  36297. _collideWithWorld(displacement: Vector3): void;
  36298. /** @hidden */
  36299. private _onCollisionPositionChange;
  36300. /** @hidden */
  36301. _checkInputs(): void;
  36302. /** @hidden */
  36303. _decideIfNeedsToMove(): boolean;
  36304. /** @hidden */
  36305. _updatePosition(): void;
  36306. /**
  36307. * Restore the Roll to its target value at the rate specified.
  36308. * @param rate - Higher means slower restoring.
  36309. * @hidden
  36310. */
  36311. restoreRoll(rate: number): void;
  36312. /**
  36313. * Destroy the camera and release the current resources held by it.
  36314. */
  36315. dispose(): void;
  36316. /**
  36317. * Get the current object class name.
  36318. * @returns the class name.
  36319. */
  36320. getClassName(): string;
  36321. }
  36322. }
  36323. declare module BABYLON {
  36324. /**
  36325. * Listen to keyboard events to control the camera.
  36326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36327. */
  36328. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36329. /**
  36330. * Defines the camera the input is attached to.
  36331. */
  36332. camera: FlyCamera;
  36333. /**
  36334. * The list of keyboard keys used to control the forward move of the camera.
  36335. */
  36336. keysForward: number[];
  36337. /**
  36338. * The list of keyboard keys used to control the backward move of the camera.
  36339. */
  36340. keysBackward: number[];
  36341. /**
  36342. * The list of keyboard keys used to control the forward move of the camera.
  36343. */
  36344. keysUp: number[];
  36345. /**
  36346. * The list of keyboard keys used to control the backward move of the camera.
  36347. */
  36348. keysDown: number[];
  36349. /**
  36350. * The list of keyboard keys used to control the right strafe move of the camera.
  36351. */
  36352. keysRight: number[];
  36353. /**
  36354. * The list of keyboard keys used to control the left strafe move of the camera.
  36355. */
  36356. keysLeft: number[];
  36357. private _keys;
  36358. private _onCanvasBlurObserver;
  36359. private _onKeyboardObserver;
  36360. private _engine;
  36361. private _scene;
  36362. /**
  36363. * Attach the input controls to a specific dom element to get the input from.
  36364. * @param element Defines the element the controls should be listened from
  36365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36366. */
  36367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36368. /**
  36369. * Detach the current controls from the specified dom element.
  36370. * @param element Defines the element to stop listening the inputs from
  36371. */
  36372. detachControl(element: Nullable<HTMLElement>): void;
  36373. /**
  36374. * Gets the class name of the current intput.
  36375. * @returns the class name
  36376. */
  36377. getClassName(): string;
  36378. /** @hidden */
  36379. _onLostFocus(e: FocusEvent): void;
  36380. /**
  36381. * Get the friendly name associated with the input class.
  36382. * @returns the input friendly name
  36383. */
  36384. getSimpleName(): string;
  36385. /**
  36386. * Update the current camera state depending on the inputs that have been used this frame.
  36387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36388. */
  36389. checkInputs(): void;
  36390. }
  36391. }
  36392. declare module BABYLON {
  36393. /**
  36394. * Manage the mouse wheel inputs to control a follow camera.
  36395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36396. */
  36397. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36398. /**
  36399. * Defines the camera the input is attached to.
  36400. */
  36401. camera: FollowCamera;
  36402. /**
  36403. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36404. */
  36405. axisControlRadius: boolean;
  36406. /**
  36407. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36408. */
  36409. axisControlHeight: boolean;
  36410. /**
  36411. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36412. */
  36413. axisControlRotation: boolean;
  36414. /**
  36415. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36416. * relation to mouseWheel events.
  36417. */
  36418. wheelPrecision: number;
  36419. /**
  36420. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36421. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36422. */
  36423. wheelDeltaPercentage: number;
  36424. private _wheel;
  36425. private _observer;
  36426. /**
  36427. * Attach the input controls to a specific dom element to get the input from.
  36428. * @param element Defines the element the controls should be listened from
  36429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36430. */
  36431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36432. /**
  36433. * Detach the current controls from the specified dom element.
  36434. * @param element Defines the element to stop listening the inputs from
  36435. */
  36436. detachControl(element: Nullable<HTMLElement>): void;
  36437. /**
  36438. * Gets the class name of the current intput.
  36439. * @returns the class name
  36440. */
  36441. getClassName(): string;
  36442. /**
  36443. * Get the friendly name associated with the input class.
  36444. * @returns the input friendly name
  36445. */
  36446. getSimpleName(): string;
  36447. }
  36448. }
  36449. declare module BABYLON {
  36450. /**
  36451. * Manage the pointers inputs to control an follow camera.
  36452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36453. */
  36454. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36455. /**
  36456. * Defines the camera the input is attached to.
  36457. */
  36458. camera: FollowCamera;
  36459. /**
  36460. * Gets the class name of the current input.
  36461. * @returns the class name
  36462. */
  36463. getClassName(): string;
  36464. /**
  36465. * Defines the pointer angular sensibility along the X axis or how fast is
  36466. * the camera rotating.
  36467. * A negative number will reverse the axis direction.
  36468. */
  36469. angularSensibilityX: number;
  36470. /**
  36471. * Defines the pointer angular sensibility along the Y axis or how fast is
  36472. * the camera rotating.
  36473. * A negative number will reverse the axis direction.
  36474. */
  36475. angularSensibilityY: number;
  36476. /**
  36477. * Defines the pointer pinch precision or how fast is the camera zooming.
  36478. * A negative number will reverse the axis direction.
  36479. */
  36480. pinchPrecision: number;
  36481. /**
  36482. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36483. * from 0.
  36484. * It defines the percentage of current camera.radius to use as delta when
  36485. * pinch zoom is used.
  36486. */
  36487. pinchDeltaPercentage: number;
  36488. /**
  36489. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36490. */
  36491. axisXControlRadius: boolean;
  36492. /**
  36493. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36494. */
  36495. axisXControlHeight: boolean;
  36496. /**
  36497. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36498. */
  36499. axisXControlRotation: boolean;
  36500. /**
  36501. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36502. */
  36503. axisYControlRadius: boolean;
  36504. /**
  36505. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36506. */
  36507. axisYControlHeight: boolean;
  36508. /**
  36509. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36510. */
  36511. axisYControlRotation: boolean;
  36512. /**
  36513. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36514. */
  36515. axisPinchControlRadius: boolean;
  36516. /**
  36517. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36518. */
  36519. axisPinchControlHeight: boolean;
  36520. /**
  36521. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36522. */
  36523. axisPinchControlRotation: boolean;
  36524. /**
  36525. * Log error messages if basic misconfiguration has occurred.
  36526. */
  36527. warningEnable: boolean;
  36528. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36529. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36530. private _warningCounter;
  36531. private _warning;
  36532. }
  36533. }
  36534. declare module BABYLON {
  36535. /**
  36536. * Default Inputs manager for the FollowCamera.
  36537. * It groups all the default supported inputs for ease of use.
  36538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36539. */
  36540. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36541. /**
  36542. * Instantiates a new FollowCameraInputsManager.
  36543. * @param camera Defines the camera the inputs belong to
  36544. */
  36545. constructor(camera: FollowCamera);
  36546. /**
  36547. * Add keyboard input support to the input manager.
  36548. * @returns the current input manager
  36549. */
  36550. addKeyboard(): FollowCameraInputsManager;
  36551. /**
  36552. * Add mouse wheel input support to the input manager.
  36553. * @returns the current input manager
  36554. */
  36555. addMouseWheel(): FollowCameraInputsManager;
  36556. /**
  36557. * Add pointers input support to the input manager.
  36558. * @returns the current input manager
  36559. */
  36560. addPointers(): FollowCameraInputsManager;
  36561. /**
  36562. * Add orientation input support to the input manager.
  36563. * @returns the current input manager
  36564. */
  36565. addVRDeviceOrientation(): FollowCameraInputsManager;
  36566. }
  36567. }
  36568. declare module BABYLON {
  36569. /**
  36570. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36571. * an arc rotate version arcFollowCamera are available.
  36572. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36573. */
  36574. export class FollowCamera extends TargetCamera {
  36575. /**
  36576. * Distance the follow camera should follow an object at
  36577. */
  36578. radius: number;
  36579. /**
  36580. * Minimum allowed distance of the camera to the axis of rotation
  36581. * (The camera can not get closer).
  36582. * This can help limiting how the Camera is able to move in the scene.
  36583. */
  36584. lowerRadiusLimit: Nullable<number>;
  36585. /**
  36586. * Maximum allowed distance of the camera to the axis of rotation
  36587. * (The camera can not get further).
  36588. * This can help limiting how the Camera is able to move in the scene.
  36589. */
  36590. upperRadiusLimit: Nullable<number>;
  36591. /**
  36592. * Define a rotation offset between the camera and the object it follows
  36593. */
  36594. rotationOffset: number;
  36595. /**
  36596. * Minimum allowed angle to camera position relative to target object.
  36597. * This can help limiting how the Camera is able to move in the scene.
  36598. */
  36599. lowerRotationOffsetLimit: Nullable<number>;
  36600. /**
  36601. * Maximum allowed angle to camera position relative to target object.
  36602. * This can help limiting how the Camera is able to move in the scene.
  36603. */
  36604. upperRotationOffsetLimit: Nullable<number>;
  36605. /**
  36606. * Define a height offset between the camera and the object it follows.
  36607. * It can help following an object from the top (like a car chaing a plane)
  36608. */
  36609. heightOffset: number;
  36610. /**
  36611. * Minimum allowed height of camera position relative to target object.
  36612. * This can help limiting how the Camera is able to move in the scene.
  36613. */
  36614. lowerHeightOffsetLimit: Nullable<number>;
  36615. /**
  36616. * Maximum allowed height of camera position relative to target object.
  36617. * This can help limiting how the Camera is able to move in the scene.
  36618. */
  36619. upperHeightOffsetLimit: Nullable<number>;
  36620. /**
  36621. * Define how fast the camera can accelerate to follow it s target.
  36622. */
  36623. cameraAcceleration: number;
  36624. /**
  36625. * Define the speed limit of the camera following an object.
  36626. */
  36627. maxCameraSpeed: number;
  36628. /**
  36629. * Define the target of the camera.
  36630. */
  36631. lockedTarget: Nullable<AbstractMesh>;
  36632. /**
  36633. * Defines the input associated with the camera.
  36634. */
  36635. inputs: FollowCameraInputsManager;
  36636. /**
  36637. * Instantiates the follow camera.
  36638. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36639. * @param name Define the name of the camera in the scene
  36640. * @param position Define the position of the camera
  36641. * @param scene Define the scene the camera belong to
  36642. * @param lockedTarget Define the target of the camera
  36643. */
  36644. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36645. private _follow;
  36646. /**
  36647. * Attached controls to the current camera.
  36648. * @param element Defines the element the controls should be listened from
  36649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36650. */
  36651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36652. /**
  36653. * Detach the current controls from the camera.
  36654. * The camera will stop reacting to inputs.
  36655. * @param element Defines the element to stop listening the inputs from
  36656. */
  36657. detachControl(element: HTMLElement): void;
  36658. /** @hidden */
  36659. _checkInputs(): void;
  36660. private _checkLimits;
  36661. /**
  36662. * Gets the camera class name.
  36663. * @returns the class name
  36664. */
  36665. getClassName(): string;
  36666. }
  36667. /**
  36668. * Arc Rotate version of the follow camera.
  36669. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36670. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36671. */
  36672. export class ArcFollowCamera extends TargetCamera {
  36673. /** The longitudinal angle of the camera */
  36674. alpha: number;
  36675. /** The latitudinal angle of the camera */
  36676. beta: number;
  36677. /** The radius of the camera from its target */
  36678. radius: number;
  36679. /** Define the camera target (the messh it should follow) */
  36680. target: Nullable<AbstractMesh>;
  36681. private _cartesianCoordinates;
  36682. /**
  36683. * Instantiates a new ArcFollowCamera
  36684. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36685. * @param name Define the name of the camera
  36686. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36687. * @param beta Define the rotation angle of the camera around the elevation axis
  36688. * @param radius Define the radius of the camera from its target point
  36689. * @param target Define the target of the camera
  36690. * @param scene Define the scene the camera belongs to
  36691. */
  36692. constructor(name: string,
  36693. /** The longitudinal angle of the camera */
  36694. alpha: number,
  36695. /** The latitudinal angle of the camera */
  36696. beta: number,
  36697. /** The radius of the camera from its target */
  36698. radius: number,
  36699. /** Define the camera target (the messh it should follow) */
  36700. target: Nullable<AbstractMesh>, scene: Scene);
  36701. private _follow;
  36702. /** @hidden */
  36703. _checkInputs(): void;
  36704. /**
  36705. * Returns the class name of the object.
  36706. * It is mostly used internally for serialization purposes.
  36707. */
  36708. getClassName(): string;
  36709. }
  36710. }
  36711. declare module BABYLON {
  36712. /**
  36713. * Manage the keyboard inputs to control the movement of a follow camera.
  36714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36715. */
  36716. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36717. /**
  36718. * Defines the camera the input is attached to.
  36719. */
  36720. camera: FollowCamera;
  36721. /**
  36722. * Defines the list of key codes associated with the up action (increase heightOffset)
  36723. */
  36724. keysHeightOffsetIncr: number[];
  36725. /**
  36726. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36727. */
  36728. keysHeightOffsetDecr: number[];
  36729. /**
  36730. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36731. */
  36732. keysHeightOffsetModifierAlt: boolean;
  36733. /**
  36734. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36735. */
  36736. keysHeightOffsetModifierCtrl: boolean;
  36737. /**
  36738. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36739. */
  36740. keysHeightOffsetModifierShift: boolean;
  36741. /**
  36742. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36743. */
  36744. keysRotationOffsetIncr: number[];
  36745. /**
  36746. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36747. */
  36748. keysRotationOffsetDecr: number[];
  36749. /**
  36750. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36751. */
  36752. keysRotationOffsetModifierAlt: boolean;
  36753. /**
  36754. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36755. */
  36756. keysRotationOffsetModifierCtrl: boolean;
  36757. /**
  36758. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36759. */
  36760. keysRotationOffsetModifierShift: boolean;
  36761. /**
  36762. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36763. */
  36764. keysRadiusIncr: number[];
  36765. /**
  36766. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36767. */
  36768. keysRadiusDecr: number[];
  36769. /**
  36770. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36771. */
  36772. keysRadiusModifierAlt: boolean;
  36773. /**
  36774. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36775. */
  36776. keysRadiusModifierCtrl: boolean;
  36777. /**
  36778. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36779. */
  36780. keysRadiusModifierShift: boolean;
  36781. /**
  36782. * Defines the rate of change of heightOffset.
  36783. */
  36784. heightSensibility: number;
  36785. /**
  36786. * Defines the rate of change of rotationOffset.
  36787. */
  36788. rotationSensibility: number;
  36789. /**
  36790. * Defines the rate of change of radius.
  36791. */
  36792. radiusSensibility: number;
  36793. private _keys;
  36794. private _ctrlPressed;
  36795. private _altPressed;
  36796. private _shiftPressed;
  36797. private _onCanvasBlurObserver;
  36798. private _onKeyboardObserver;
  36799. private _engine;
  36800. private _scene;
  36801. /**
  36802. * Attach the input controls to a specific dom element to get the input from.
  36803. * @param element Defines the element the controls should be listened from
  36804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36805. */
  36806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36807. /**
  36808. * Detach the current controls from the specified dom element.
  36809. * @param element Defines the element to stop listening the inputs from
  36810. */
  36811. detachControl(element: Nullable<HTMLElement>): void;
  36812. /**
  36813. * Update the current camera state depending on the inputs that have been used this frame.
  36814. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36815. */
  36816. checkInputs(): void;
  36817. /**
  36818. * Gets the class name of the current input.
  36819. * @returns the class name
  36820. */
  36821. getClassName(): string;
  36822. /**
  36823. * Get the friendly name associated with the input class.
  36824. * @returns the input friendly name
  36825. */
  36826. getSimpleName(): string;
  36827. /**
  36828. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36829. * allow modification of the heightOffset value.
  36830. */
  36831. private _modifierHeightOffset;
  36832. /**
  36833. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36834. * allow modification of the rotationOffset value.
  36835. */
  36836. private _modifierRotationOffset;
  36837. /**
  36838. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36839. * allow modification of the radius value.
  36840. */
  36841. private _modifierRadius;
  36842. }
  36843. }
  36844. declare module BABYLON {
  36845. interface FreeCameraInputsManager {
  36846. /**
  36847. * @hidden
  36848. */
  36849. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36850. /**
  36851. * Add orientation input support to the input manager.
  36852. * @returns the current input manager
  36853. */
  36854. addDeviceOrientation(): FreeCameraInputsManager;
  36855. }
  36856. /**
  36857. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36858. * Screen rotation is taken into account.
  36859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36860. */
  36861. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36862. private _camera;
  36863. private _screenOrientationAngle;
  36864. private _constantTranform;
  36865. private _screenQuaternion;
  36866. private _alpha;
  36867. private _beta;
  36868. private _gamma;
  36869. /**
  36870. * @hidden
  36871. */
  36872. _onDeviceOrientationChangedObservable: Observable<void>;
  36873. /**
  36874. * Instantiates a new input
  36875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36876. */
  36877. constructor();
  36878. /**
  36879. * Define the camera controlled by the input.
  36880. */
  36881. camera: FreeCamera;
  36882. /**
  36883. * Attach the input controls to a specific dom element to get the input from.
  36884. * @param element Defines the element the controls should be listened from
  36885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36886. */
  36887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36888. private _orientationChanged;
  36889. private _deviceOrientation;
  36890. /**
  36891. * Detach the current controls from the specified dom element.
  36892. * @param element Defines the element to stop listening the inputs from
  36893. */
  36894. detachControl(element: Nullable<HTMLElement>): void;
  36895. /**
  36896. * Update the current camera state depending on the inputs that have been used this frame.
  36897. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36898. */
  36899. checkInputs(): void;
  36900. /**
  36901. * Gets the class name of the current intput.
  36902. * @returns the class name
  36903. */
  36904. getClassName(): string;
  36905. /**
  36906. * Get the friendly name associated with the input class.
  36907. * @returns the input friendly name
  36908. */
  36909. getSimpleName(): string;
  36910. }
  36911. }
  36912. declare module BABYLON {
  36913. /**
  36914. * Manage the gamepad inputs to control a free camera.
  36915. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36916. */
  36917. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36918. /**
  36919. * Define the camera the input is attached to.
  36920. */
  36921. camera: FreeCamera;
  36922. /**
  36923. * Define the Gamepad controlling the input
  36924. */
  36925. gamepad: Nullable<Gamepad>;
  36926. /**
  36927. * Defines the gamepad rotation sensiblity.
  36928. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36929. */
  36930. gamepadAngularSensibility: number;
  36931. /**
  36932. * Defines the gamepad move sensiblity.
  36933. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36934. */
  36935. gamepadMoveSensibility: number;
  36936. private _onGamepadConnectedObserver;
  36937. private _onGamepadDisconnectedObserver;
  36938. private _cameraTransform;
  36939. private _deltaTransform;
  36940. private _vector3;
  36941. private _vector2;
  36942. /**
  36943. * Attach the input controls to a specific dom element to get the input from.
  36944. * @param element Defines the element the controls should be listened from
  36945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36946. */
  36947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36948. /**
  36949. * Detach the current controls from the specified dom element.
  36950. * @param element Defines the element to stop listening the inputs from
  36951. */
  36952. detachControl(element: Nullable<HTMLElement>): void;
  36953. /**
  36954. * Update the current camera state depending on the inputs that have been used this frame.
  36955. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36956. */
  36957. checkInputs(): void;
  36958. /**
  36959. * Gets the class name of the current intput.
  36960. * @returns the class name
  36961. */
  36962. getClassName(): string;
  36963. /**
  36964. * Get the friendly name associated with the input class.
  36965. * @returns the input friendly name
  36966. */
  36967. getSimpleName(): string;
  36968. }
  36969. }
  36970. declare module BABYLON {
  36971. /**
  36972. * Defines the potential axis of a Joystick
  36973. */
  36974. export enum JoystickAxis {
  36975. /** X axis */
  36976. X = 0,
  36977. /** Y axis */
  36978. Y = 1,
  36979. /** Z axis */
  36980. Z = 2
  36981. }
  36982. /**
  36983. * Class used to define virtual joystick (used in touch mode)
  36984. */
  36985. export class VirtualJoystick {
  36986. /**
  36987. * Gets or sets a boolean indicating that left and right values must be inverted
  36988. */
  36989. reverseLeftRight: boolean;
  36990. /**
  36991. * Gets or sets a boolean indicating that up and down values must be inverted
  36992. */
  36993. reverseUpDown: boolean;
  36994. /**
  36995. * Gets the offset value for the position (ie. the change of the position value)
  36996. */
  36997. deltaPosition: Vector3;
  36998. /**
  36999. * Gets a boolean indicating if the virtual joystick was pressed
  37000. */
  37001. pressed: boolean;
  37002. /**
  37003. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37004. */
  37005. static Canvas: Nullable<HTMLCanvasElement>;
  37006. private static _globalJoystickIndex;
  37007. private static vjCanvasContext;
  37008. private static vjCanvasWidth;
  37009. private static vjCanvasHeight;
  37010. private static halfWidth;
  37011. private _action;
  37012. private _axisTargetedByLeftAndRight;
  37013. private _axisTargetedByUpAndDown;
  37014. private _joystickSensibility;
  37015. private _inversedSensibility;
  37016. private _joystickPointerID;
  37017. private _joystickColor;
  37018. private _joystickPointerPos;
  37019. private _joystickPreviousPointerPos;
  37020. private _joystickPointerStartPos;
  37021. private _deltaJoystickVector;
  37022. private _leftJoystick;
  37023. private _touches;
  37024. private _onPointerDownHandlerRef;
  37025. private _onPointerMoveHandlerRef;
  37026. private _onPointerUpHandlerRef;
  37027. private _onResize;
  37028. /**
  37029. * Creates a new virtual joystick
  37030. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37031. */
  37032. constructor(leftJoystick?: boolean);
  37033. /**
  37034. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37035. * @param newJoystickSensibility defines the new sensibility
  37036. */
  37037. setJoystickSensibility(newJoystickSensibility: number): void;
  37038. private _onPointerDown;
  37039. private _onPointerMove;
  37040. private _onPointerUp;
  37041. /**
  37042. * Change the color of the virtual joystick
  37043. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37044. */
  37045. setJoystickColor(newColor: string): void;
  37046. /**
  37047. * Defines a callback to call when the joystick is touched
  37048. * @param action defines the callback
  37049. */
  37050. setActionOnTouch(action: () => any): void;
  37051. /**
  37052. * Defines which axis you'd like to control for left & right
  37053. * @param axis defines the axis to use
  37054. */
  37055. setAxisForLeftRight(axis: JoystickAxis): void;
  37056. /**
  37057. * Defines which axis you'd like to control for up & down
  37058. * @param axis defines the axis to use
  37059. */
  37060. setAxisForUpDown(axis: JoystickAxis): void;
  37061. private _drawVirtualJoystick;
  37062. /**
  37063. * Release internal HTML canvas
  37064. */
  37065. releaseCanvas(): void;
  37066. }
  37067. }
  37068. declare module BABYLON {
  37069. interface FreeCameraInputsManager {
  37070. /**
  37071. * Add virtual joystick input support to the input manager.
  37072. * @returns the current input manager
  37073. */
  37074. addVirtualJoystick(): FreeCameraInputsManager;
  37075. }
  37076. /**
  37077. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37079. */
  37080. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37081. /**
  37082. * Defines the camera the input is attached to.
  37083. */
  37084. camera: FreeCamera;
  37085. private _leftjoystick;
  37086. private _rightjoystick;
  37087. /**
  37088. * Gets the left stick of the virtual joystick.
  37089. * @returns The virtual Joystick
  37090. */
  37091. getLeftJoystick(): VirtualJoystick;
  37092. /**
  37093. * Gets the right stick of the virtual joystick.
  37094. * @returns The virtual Joystick
  37095. */
  37096. getRightJoystick(): VirtualJoystick;
  37097. /**
  37098. * Update the current camera state depending on the inputs that have been used this frame.
  37099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37100. */
  37101. checkInputs(): void;
  37102. /**
  37103. * Attach the input controls to a specific dom element to get the input from.
  37104. * @param element Defines the element the controls should be listened from
  37105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37106. */
  37107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37108. /**
  37109. * Detach the current controls from the specified dom element.
  37110. * @param element Defines the element to stop listening the inputs from
  37111. */
  37112. detachControl(element: Nullable<HTMLElement>): void;
  37113. /**
  37114. * Gets the class name of the current intput.
  37115. * @returns the class name
  37116. */
  37117. getClassName(): string;
  37118. /**
  37119. * Get the friendly name associated with the input class.
  37120. * @returns the input friendly name
  37121. */
  37122. getSimpleName(): string;
  37123. }
  37124. }
  37125. declare module BABYLON {
  37126. /**
  37127. * This represents a FPS type of camera controlled by touch.
  37128. * This is like a universal camera minus the Gamepad controls.
  37129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37130. */
  37131. export class TouchCamera extends FreeCamera {
  37132. /**
  37133. * Defines the touch sensibility for rotation.
  37134. * The higher the faster.
  37135. */
  37136. touchAngularSensibility: number;
  37137. /**
  37138. * Defines the touch sensibility for move.
  37139. * The higher the faster.
  37140. */
  37141. touchMoveSensibility: number;
  37142. /**
  37143. * Instantiates a new touch camera.
  37144. * This represents a FPS type of camera controlled by touch.
  37145. * This is like a universal camera minus the Gamepad controls.
  37146. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37147. * @param name Define the name of the camera in the scene
  37148. * @param position Define the start position of the camera in the scene
  37149. * @param scene Define the scene the camera belongs to
  37150. */
  37151. constructor(name: string, position: Vector3, scene: Scene);
  37152. /**
  37153. * Gets the current object class name.
  37154. * @return the class name
  37155. */
  37156. getClassName(): string;
  37157. /** @hidden */
  37158. _setupInputs(): void;
  37159. }
  37160. }
  37161. declare module BABYLON {
  37162. /**
  37163. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37164. * being tilted forward or back and left or right.
  37165. */
  37166. export class DeviceOrientationCamera extends FreeCamera {
  37167. private _initialQuaternion;
  37168. private _quaternionCache;
  37169. private _tmpDragQuaternion;
  37170. /**
  37171. * Creates a new device orientation camera
  37172. * @param name The name of the camera
  37173. * @param position The start position camera
  37174. * @param scene The scene the camera belongs to
  37175. */
  37176. constructor(name: string, position: Vector3, scene: Scene);
  37177. /**
  37178. * Disabled pointer input on first orientation sensor update (Default: true)
  37179. */
  37180. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37181. private _dragFactor;
  37182. /**
  37183. * Enabled turning on the y axis when the orientation sensor is active
  37184. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37185. */
  37186. enableHorizontalDragging(dragFactor?: number): void;
  37187. /**
  37188. * Gets the current instance class name ("DeviceOrientationCamera").
  37189. * This helps avoiding instanceof at run time.
  37190. * @returns the class name
  37191. */
  37192. getClassName(): string;
  37193. /**
  37194. * @hidden
  37195. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37196. */
  37197. _checkInputs(): void;
  37198. /**
  37199. * Reset the camera to its default orientation on the specified axis only.
  37200. * @param axis The axis to reset
  37201. */
  37202. resetToCurrentRotation(axis?: Axis): void;
  37203. }
  37204. }
  37205. declare module BABYLON {
  37206. /**
  37207. * 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,
  37208. * which still works and will still be found in many Playgrounds.
  37209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37210. */
  37211. export class UniversalCamera extends TouchCamera {
  37212. /**
  37213. * Defines the gamepad rotation sensiblity.
  37214. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37215. */
  37216. gamepadAngularSensibility: number;
  37217. /**
  37218. * Defines the gamepad move sensiblity.
  37219. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37220. */
  37221. gamepadMoveSensibility: number;
  37222. /**
  37223. * 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,
  37224. * which still works and will still be found in many Playgrounds.
  37225. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37226. * @param name Define the name of the camera in the scene
  37227. * @param position Define the start position of the camera in the scene
  37228. * @param scene Define the scene the camera belongs to
  37229. */
  37230. constructor(name: string, position: Vector3, scene: Scene);
  37231. /**
  37232. * Gets the current object class name.
  37233. * @return the class name
  37234. */
  37235. getClassName(): string;
  37236. }
  37237. }
  37238. declare module BABYLON {
  37239. /**
  37240. * This represents a FPS type of camera. This is only here for back compat purpose.
  37241. * Please use the UniversalCamera instead as both are identical.
  37242. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37243. */
  37244. export class GamepadCamera extends UniversalCamera {
  37245. /**
  37246. * Instantiates a new Gamepad Camera
  37247. * This represents a FPS type of camera. This is only here for back compat purpose.
  37248. * Please use the UniversalCamera instead as both are identical.
  37249. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37250. * @param name Define the name of the camera in the scene
  37251. * @param position Define the start position of the camera in the scene
  37252. * @param scene Define the scene the camera belongs to
  37253. */
  37254. constructor(name: string, position: Vector3, scene: Scene);
  37255. /**
  37256. * Gets the current object class name.
  37257. * @return the class name
  37258. */
  37259. getClassName(): string;
  37260. }
  37261. }
  37262. declare module BABYLON {
  37263. /** @hidden */
  37264. export var passPixelShader: {
  37265. name: string;
  37266. shader: string;
  37267. };
  37268. }
  37269. declare module BABYLON {
  37270. /** @hidden */
  37271. export var passCubePixelShader: {
  37272. name: string;
  37273. shader: string;
  37274. };
  37275. }
  37276. declare module BABYLON {
  37277. /**
  37278. * PassPostProcess which produces an output the same as it's input
  37279. */
  37280. export class PassPostProcess extends PostProcess {
  37281. /**
  37282. * Creates the PassPostProcess
  37283. * @param name The name of the effect.
  37284. * @param options The required width/height ratio to downsize to before computing the render pass.
  37285. * @param camera The camera to apply the render pass to.
  37286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37287. * @param engine The engine which the post process will be applied. (default: current engine)
  37288. * @param reusable If the post process can be reused on the same frame. (default: false)
  37289. * @param textureType The type of texture to be used when performing the post processing.
  37290. * @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)
  37291. */
  37292. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37293. }
  37294. /**
  37295. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37296. */
  37297. export class PassCubePostProcess extends PostProcess {
  37298. private _face;
  37299. /**
  37300. * Gets or sets the cube face to display.
  37301. * * 0 is +X
  37302. * * 1 is -X
  37303. * * 2 is +Y
  37304. * * 3 is -Y
  37305. * * 4 is +Z
  37306. * * 5 is -Z
  37307. */
  37308. face: number;
  37309. /**
  37310. * Creates the PassCubePostProcess
  37311. * @param name The name of the effect.
  37312. * @param options The required width/height ratio to downsize to before computing the render pass.
  37313. * @param camera The camera to apply the render pass to.
  37314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37315. * @param engine The engine which the post process will be applied. (default: current engine)
  37316. * @param reusable If the post process can be reused on the same frame. (default: false)
  37317. * @param textureType The type of texture to be used when performing the post processing.
  37318. * @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)
  37319. */
  37320. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37321. }
  37322. }
  37323. declare module BABYLON {
  37324. /** @hidden */
  37325. export var anaglyphPixelShader: {
  37326. name: string;
  37327. shader: string;
  37328. };
  37329. }
  37330. declare module BABYLON {
  37331. /**
  37332. * Postprocess used to generate anaglyphic rendering
  37333. */
  37334. export class AnaglyphPostProcess extends PostProcess {
  37335. private _passedProcess;
  37336. /**
  37337. * Creates a new AnaglyphPostProcess
  37338. * @param name defines postprocess name
  37339. * @param options defines creation options or target ratio scale
  37340. * @param rigCameras defines cameras using this postprocess
  37341. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37342. * @param engine defines hosting engine
  37343. * @param reusable defines if the postprocess will be reused multiple times per frame
  37344. */
  37345. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37346. }
  37347. }
  37348. declare module BABYLON {
  37349. /**
  37350. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37351. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37352. */
  37353. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37354. /**
  37355. * Creates a new AnaglyphArcRotateCamera
  37356. * @param name defines camera name
  37357. * @param alpha defines alpha angle (in radians)
  37358. * @param beta defines beta angle (in radians)
  37359. * @param radius defines radius
  37360. * @param target defines camera target
  37361. * @param interaxialDistance defines distance between each color axis
  37362. * @param scene defines the hosting scene
  37363. */
  37364. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37365. /**
  37366. * Gets camera class name
  37367. * @returns AnaglyphArcRotateCamera
  37368. */
  37369. getClassName(): string;
  37370. }
  37371. }
  37372. declare module BABYLON {
  37373. /**
  37374. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37375. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37376. */
  37377. export class AnaglyphFreeCamera extends FreeCamera {
  37378. /**
  37379. * Creates a new AnaglyphFreeCamera
  37380. * @param name defines camera name
  37381. * @param position defines initial position
  37382. * @param interaxialDistance defines distance between each color axis
  37383. * @param scene defines the hosting scene
  37384. */
  37385. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37386. /**
  37387. * Gets camera class name
  37388. * @returns AnaglyphFreeCamera
  37389. */
  37390. getClassName(): string;
  37391. }
  37392. }
  37393. declare module BABYLON {
  37394. /**
  37395. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37396. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37397. */
  37398. export class AnaglyphGamepadCamera extends GamepadCamera {
  37399. /**
  37400. * Creates a new AnaglyphGamepadCamera
  37401. * @param name defines camera name
  37402. * @param position defines initial position
  37403. * @param interaxialDistance defines distance between each color axis
  37404. * @param scene defines the hosting scene
  37405. */
  37406. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37407. /**
  37408. * Gets camera class name
  37409. * @returns AnaglyphGamepadCamera
  37410. */
  37411. getClassName(): string;
  37412. }
  37413. }
  37414. declare module BABYLON {
  37415. /**
  37416. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37417. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37418. */
  37419. export class AnaglyphUniversalCamera extends UniversalCamera {
  37420. /**
  37421. * Creates a new AnaglyphUniversalCamera
  37422. * @param name defines camera name
  37423. * @param position defines initial position
  37424. * @param interaxialDistance defines distance between each color axis
  37425. * @param scene defines the hosting scene
  37426. */
  37427. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37428. /**
  37429. * Gets camera class name
  37430. * @returns AnaglyphUniversalCamera
  37431. */
  37432. getClassName(): string;
  37433. }
  37434. }
  37435. declare module BABYLON {
  37436. /** @hidden */
  37437. export var stereoscopicInterlacePixelShader: {
  37438. name: string;
  37439. shader: string;
  37440. };
  37441. }
  37442. declare module BABYLON {
  37443. /**
  37444. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37445. */
  37446. export class StereoscopicInterlacePostProcess extends PostProcess {
  37447. private _stepSize;
  37448. private _passedProcess;
  37449. /**
  37450. * Initializes a StereoscopicInterlacePostProcess
  37451. * @param name The name of the effect.
  37452. * @param rigCameras The rig cameras to be appled to the post process
  37453. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37455. * @param engine The engine which the post process will be applied. (default: current engine)
  37456. * @param reusable If the post process can be reused on the same frame. (default: false)
  37457. */
  37458. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37459. }
  37460. }
  37461. declare module BABYLON {
  37462. /**
  37463. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37464. * @see http://doc.babylonjs.com/features/cameras
  37465. */
  37466. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37467. /**
  37468. * Creates a new StereoscopicArcRotateCamera
  37469. * @param name defines camera name
  37470. * @param alpha defines alpha angle (in radians)
  37471. * @param beta defines beta angle (in radians)
  37472. * @param radius defines radius
  37473. * @param target defines camera target
  37474. * @param interaxialDistance defines distance between each color axis
  37475. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37476. * @param scene defines the hosting scene
  37477. */
  37478. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37479. /**
  37480. * Gets camera class name
  37481. * @returns StereoscopicArcRotateCamera
  37482. */
  37483. getClassName(): string;
  37484. }
  37485. }
  37486. declare module BABYLON {
  37487. /**
  37488. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37489. * @see http://doc.babylonjs.com/features/cameras
  37490. */
  37491. export class StereoscopicFreeCamera extends FreeCamera {
  37492. /**
  37493. * Creates a new StereoscopicFreeCamera
  37494. * @param name defines camera name
  37495. * @param position defines initial position
  37496. * @param interaxialDistance defines distance between each color axis
  37497. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37498. * @param scene defines the hosting scene
  37499. */
  37500. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37501. /**
  37502. * Gets camera class name
  37503. * @returns StereoscopicFreeCamera
  37504. */
  37505. getClassName(): string;
  37506. }
  37507. }
  37508. declare module BABYLON {
  37509. /**
  37510. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37511. * @see http://doc.babylonjs.com/features/cameras
  37512. */
  37513. export class StereoscopicGamepadCamera extends GamepadCamera {
  37514. /**
  37515. * Creates a new StereoscopicGamepadCamera
  37516. * @param name defines camera name
  37517. * @param position defines initial position
  37518. * @param interaxialDistance defines distance between each color axis
  37519. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37520. * @param scene defines the hosting scene
  37521. */
  37522. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37523. /**
  37524. * Gets camera class name
  37525. * @returns StereoscopicGamepadCamera
  37526. */
  37527. getClassName(): string;
  37528. }
  37529. }
  37530. declare module BABYLON {
  37531. /**
  37532. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37533. * @see http://doc.babylonjs.com/features/cameras
  37534. */
  37535. export class StereoscopicUniversalCamera extends UniversalCamera {
  37536. /**
  37537. * Creates a new StereoscopicUniversalCamera
  37538. * @param name defines camera name
  37539. * @param position defines initial position
  37540. * @param interaxialDistance defines distance between each color axis
  37541. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37542. * @param scene defines the hosting scene
  37543. */
  37544. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37545. /**
  37546. * Gets camera class name
  37547. * @returns StereoscopicUniversalCamera
  37548. */
  37549. getClassName(): string;
  37550. }
  37551. }
  37552. declare module BABYLON {
  37553. /**
  37554. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37555. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37556. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37557. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37558. */
  37559. export class VirtualJoysticksCamera extends FreeCamera {
  37560. /**
  37561. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37562. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37563. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37564. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37565. * @param name Define the name of the camera in the scene
  37566. * @param position Define the start position of the camera in the scene
  37567. * @param scene Define the scene the camera belongs to
  37568. */
  37569. constructor(name: string, position: Vector3, scene: Scene);
  37570. /**
  37571. * Gets the current object class name.
  37572. * @return the class name
  37573. */
  37574. getClassName(): string;
  37575. }
  37576. }
  37577. declare module BABYLON {
  37578. /**
  37579. * This represents all the required metrics to create a VR camera.
  37580. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37581. */
  37582. export class VRCameraMetrics {
  37583. /**
  37584. * Define the horizontal resolution off the screen.
  37585. */
  37586. hResolution: number;
  37587. /**
  37588. * Define the vertical resolution off the screen.
  37589. */
  37590. vResolution: number;
  37591. /**
  37592. * Define the horizontal screen size.
  37593. */
  37594. hScreenSize: number;
  37595. /**
  37596. * Define the vertical screen size.
  37597. */
  37598. vScreenSize: number;
  37599. /**
  37600. * Define the vertical screen center position.
  37601. */
  37602. vScreenCenter: number;
  37603. /**
  37604. * Define the distance of the eyes to the screen.
  37605. */
  37606. eyeToScreenDistance: number;
  37607. /**
  37608. * Define the distance between both lenses
  37609. */
  37610. lensSeparationDistance: number;
  37611. /**
  37612. * Define the distance between both viewer's eyes.
  37613. */
  37614. interpupillaryDistance: number;
  37615. /**
  37616. * Define the distortion factor of the VR postprocess.
  37617. * Please, touch with care.
  37618. */
  37619. distortionK: number[];
  37620. /**
  37621. * Define the chromatic aberration correction factors for the VR post process.
  37622. */
  37623. chromaAbCorrection: number[];
  37624. /**
  37625. * Define the scale factor of the post process.
  37626. * The smaller the better but the slower.
  37627. */
  37628. postProcessScaleFactor: number;
  37629. /**
  37630. * Define an offset for the lens center.
  37631. */
  37632. lensCenterOffset: number;
  37633. /**
  37634. * Define if the current vr camera should compensate the distortion of the lense or not.
  37635. */
  37636. compensateDistortion: boolean;
  37637. /**
  37638. * Defines if multiview should be enabled when rendering (Default: false)
  37639. */
  37640. multiviewEnabled: boolean;
  37641. /**
  37642. * Gets the rendering aspect ratio based on the provided resolutions.
  37643. */
  37644. readonly aspectRatio: number;
  37645. /**
  37646. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37647. */
  37648. readonly aspectRatioFov: number;
  37649. /**
  37650. * @hidden
  37651. */
  37652. readonly leftHMatrix: Matrix;
  37653. /**
  37654. * @hidden
  37655. */
  37656. readonly rightHMatrix: Matrix;
  37657. /**
  37658. * @hidden
  37659. */
  37660. readonly leftPreViewMatrix: Matrix;
  37661. /**
  37662. * @hidden
  37663. */
  37664. readonly rightPreViewMatrix: Matrix;
  37665. /**
  37666. * Get the default VRMetrics based on the most generic setup.
  37667. * @returns the default vr metrics
  37668. */
  37669. static GetDefault(): VRCameraMetrics;
  37670. }
  37671. }
  37672. declare module BABYLON {
  37673. /** @hidden */
  37674. export var vrDistortionCorrectionPixelShader: {
  37675. name: string;
  37676. shader: string;
  37677. };
  37678. }
  37679. declare module BABYLON {
  37680. /**
  37681. * VRDistortionCorrectionPostProcess used for mobile VR
  37682. */
  37683. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37684. private _isRightEye;
  37685. private _distortionFactors;
  37686. private _postProcessScaleFactor;
  37687. private _lensCenterOffset;
  37688. private _scaleIn;
  37689. private _scaleFactor;
  37690. private _lensCenter;
  37691. /**
  37692. * Initializes the VRDistortionCorrectionPostProcess
  37693. * @param name The name of the effect.
  37694. * @param camera The camera to apply the render pass to.
  37695. * @param isRightEye If this is for the right eye distortion
  37696. * @param vrMetrics All the required metrics for the VR camera
  37697. */
  37698. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37699. }
  37700. }
  37701. declare module BABYLON {
  37702. /**
  37703. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37704. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37705. */
  37706. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37707. /**
  37708. * Creates a new VRDeviceOrientationArcRotateCamera
  37709. * @param name defines camera name
  37710. * @param alpha defines the camera rotation along the logitudinal axis
  37711. * @param beta defines the camera rotation along the latitudinal axis
  37712. * @param radius defines the camera distance from its target
  37713. * @param target defines the camera target
  37714. * @param scene defines the scene the camera belongs to
  37715. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37716. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37717. */
  37718. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37719. /**
  37720. * Gets camera class name
  37721. * @returns VRDeviceOrientationArcRotateCamera
  37722. */
  37723. getClassName(): string;
  37724. }
  37725. }
  37726. declare module BABYLON {
  37727. /**
  37728. * Camera used to simulate VR rendering (based on FreeCamera)
  37729. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37730. */
  37731. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37732. /**
  37733. * Creates a new VRDeviceOrientationFreeCamera
  37734. * @param name defines camera name
  37735. * @param position defines the start position of the camera
  37736. * @param scene defines the scene the camera belongs to
  37737. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37738. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37739. */
  37740. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37741. /**
  37742. * Gets camera class name
  37743. * @returns VRDeviceOrientationFreeCamera
  37744. */
  37745. getClassName(): string;
  37746. }
  37747. }
  37748. declare module BABYLON {
  37749. /**
  37750. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37751. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37752. */
  37753. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37754. /**
  37755. * Creates a new VRDeviceOrientationGamepadCamera
  37756. * @param name defines camera name
  37757. * @param position defines the start position of the camera
  37758. * @param scene defines the scene the camera belongs to
  37759. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37760. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37761. */
  37762. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37763. /**
  37764. * Gets camera class name
  37765. * @returns VRDeviceOrientationGamepadCamera
  37766. */
  37767. getClassName(): string;
  37768. }
  37769. }
  37770. declare module BABYLON {
  37771. /**
  37772. * Defines supported buttons for XBox360 compatible gamepads
  37773. */
  37774. export enum Xbox360Button {
  37775. /** A */
  37776. A = 0,
  37777. /** B */
  37778. B = 1,
  37779. /** X */
  37780. X = 2,
  37781. /** Y */
  37782. Y = 3,
  37783. /** Start */
  37784. Start = 4,
  37785. /** Back */
  37786. Back = 5,
  37787. /** Left button */
  37788. LB = 6,
  37789. /** Right button */
  37790. RB = 7,
  37791. /** Left stick */
  37792. LeftStick = 8,
  37793. /** Right stick */
  37794. RightStick = 9
  37795. }
  37796. /** Defines values for XBox360 DPad */
  37797. export enum Xbox360Dpad {
  37798. /** Up */
  37799. Up = 0,
  37800. /** Down */
  37801. Down = 1,
  37802. /** Left */
  37803. Left = 2,
  37804. /** Right */
  37805. Right = 3
  37806. }
  37807. /**
  37808. * Defines a XBox360 gamepad
  37809. */
  37810. export class Xbox360Pad extends Gamepad {
  37811. private _leftTrigger;
  37812. private _rightTrigger;
  37813. private _onlefttriggerchanged;
  37814. private _onrighttriggerchanged;
  37815. private _onbuttondown;
  37816. private _onbuttonup;
  37817. private _ondpaddown;
  37818. private _ondpadup;
  37819. /** Observable raised when a button is pressed */
  37820. onButtonDownObservable: Observable<Xbox360Button>;
  37821. /** Observable raised when a button is released */
  37822. onButtonUpObservable: Observable<Xbox360Button>;
  37823. /** Observable raised when a pad is pressed */
  37824. onPadDownObservable: Observable<Xbox360Dpad>;
  37825. /** Observable raised when a pad is released */
  37826. onPadUpObservable: Observable<Xbox360Dpad>;
  37827. private _buttonA;
  37828. private _buttonB;
  37829. private _buttonX;
  37830. private _buttonY;
  37831. private _buttonBack;
  37832. private _buttonStart;
  37833. private _buttonLB;
  37834. private _buttonRB;
  37835. private _buttonLeftStick;
  37836. private _buttonRightStick;
  37837. private _dPadUp;
  37838. private _dPadDown;
  37839. private _dPadLeft;
  37840. private _dPadRight;
  37841. private _isXboxOnePad;
  37842. /**
  37843. * Creates a new XBox360 gamepad object
  37844. * @param id defines the id of this gamepad
  37845. * @param index defines its index
  37846. * @param gamepad defines the internal HTML gamepad object
  37847. * @param xboxOne defines if it is a XBox One gamepad
  37848. */
  37849. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37850. /**
  37851. * Defines the callback to call when left trigger is pressed
  37852. * @param callback defines the callback to use
  37853. */
  37854. onlefttriggerchanged(callback: (value: number) => void): void;
  37855. /**
  37856. * Defines the callback to call when right trigger is pressed
  37857. * @param callback defines the callback to use
  37858. */
  37859. onrighttriggerchanged(callback: (value: number) => void): void;
  37860. /**
  37861. * Gets the left trigger value
  37862. */
  37863. /**
  37864. * Sets the left trigger value
  37865. */
  37866. leftTrigger: number;
  37867. /**
  37868. * Gets the right trigger value
  37869. */
  37870. /**
  37871. * Sets the right trigger value
  37872. */
  37873. rightTrigger: number;
  37874. /**
  37875. * Defines the callback to call when a button is pressed
  37876. * @param callback defines the callback to use
  37877. */
  37878. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37879. /**
  37880. * Defines the callback to call when a button is released
  37881. * @param callback defines the callback to use
  37882. */
  37883. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37884. /**
  37885. * Defines the callback to call when a pad is pressed
  37886. * @param callback defines the callback to use
  37887. */
  37888. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37889. /**
  37890. * Defines the callback to call when a pad is released
  37891. * @param callback defines the callback to use
  37892. */
  37893. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37894. private _setButtonValue;
  37895. private _setDPadValue;
  37896. /**
  37897. * Gets the value of the `A` button
  37898. */
  37899. /**
  37900. * Sets the value of the `A` button
  37901. */
  37902. buttonA: number;
  37903. /**
  37904. * Gets the value of the `B` button
  37905. */
  37906. /**
  37907. * Sets the value of the `B` button
  37908. */
  37909. buttonB: number;
  37910. /**
  37911. * Gets the value of the `X` button
  37912. */
  37913. /**
  37914. * Sets the value of the `X` button
  37915. */
  37916. buttonX: number;
  37917. /**
  37918. * Gets the value of the `Y` button
  37919. */
  37920. /**
  37921. * Sets the value of the `Y` button
  37922. */
  37923. buttonY: number;
  37924. /**
  37925. * Gets the value of the `Start` button
  37926. */
  37927. /**
  37928. * Sets the value of the `Start` button
  37929. */
  37930. buttonStart: number;
  37931. /**
  37932. * Gets the value of the `Back` button
  37933. */
  37934. /**
  37935. * Sets the value of the `Back` button
  37936. */
  37937. buttonBack: number;
  37938. /**
  37939. * Gets the value of the `Left` button
  37940. */
  37941. /**
  37942. * Sets the value of the `Left` button
  37943. */
  37944. buttonLB: number;
  37945. /**
  37946. * Gets the value of the `Right` button
  37947. */
  37948. /**
  37949. * Sets the value of the `Right` button
  37950. */
  37951. buttonRB: number;
  37952. /**
  37953. * Gets the value of the Left joystick
  37954. */
  37955. /**
  37956. * Sets the value of the Left joystick
  37957. */
  37958. buttonLeftStick: number;
  37959. /**
  37960. * Gets the value of the Right joystick
  37961. */
  37962. /**
  37963. * Sets the value of the Right joystick
  37964. */
  37965. buttonRightStick: number;
  37966. /**
  37967. * Gets the value of D-pad up
  37968. */
  37969. /**
  37970. * Sets the value of D-pad up
  37971. */
  37972. dPadUp: number;
  37973. /**
  37974. * Gets the value of D-pad down
  37975. */
  37976. /**
  37977. * Sets the value of D-pad down
  37978. */
  37979. dPadDown: number;
  37980. /**
  37981. * Gets the value of D-pad left
  37982. */
  37983. /**
  37984. * Sets the value of D-pad left
  37985. */
  37986. dPadLeft: number;
  37987. /**
  37988. * Gets the value of D-pad right
  37989. */
  37990. /**
  37991. * Sets the value of D-pad right
  37992. */
  37993. dPadRight: number;
  37994. /**
  37995. * Force the gamepad to synchronize with device values
  37996. */
  37997. update(): void;
  37998. /**
  37999. * Disposes the gamepad
  38000. */
  38001. dispose(): void;
  38002. }
  38003. }
  38004. declare module BABYLON {
  38005. /**
  38006. * Base class of materials working in push mode in babylon JS
  38007. * @hidden
  38008. */
  38009. export class PushMaterial extends Material {
  38010. protected _activeEffect: Effect;
  38011. protected _normalMatrix: Matrix;
  38012. /**
  38013. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38014. * This means that the material can keep using a previous shader while a new one is being compiled.
  38015. * This is mostly used when shader parallel compilation is supported (true by default)
  38016. */
  38017. allowShaderHotSwapping: boolean;
  38018. constructor(name: string, scene: Scene);
  38019. getEffect(): Effect;
  38020. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38021. /**
  38022. * Binds the given world matrix to the active effect
  38023. *
  38024. * @param world the matrix to bind
  38025. */
  38026. bindOnlyWorldMatrix(world: Matrix): void;
  38027. /**
  38028. * Binds the given normal matrix to the active effect
  38029. *
  38030. * @param normalMatrix the matrix to bind
  38031. */
  38032. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38033. bind(world: Matrix, mesh?: Mesh): void;
  38034. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38035. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38036. }
  38037. }
  38038. declare module BABYLON {
  38039. /**
  38040. * This groups all the flags used to control the materials channel.
  38041. */
  38042. export class MaterialFlags {
  38043. private static _DiffuseTextureEnabled;
  38044. /**
  38045. * Are diffuse textures enabled in the application.
  38046. */
  38047. static DiffuseTextureEnabled: boolean;
  38048. private static _AmbientTextureEnabled;
  38049. /**
  38050. * Are ambient textures enabled in the application.
  38051. */
  38052. static AmbientTextureEnabled: boolean;
  38053. private static _OpacityTextureEnabled;
  38054. /**
  38055. * Are opacity textures enabled in the application.
  38056. */
  38057. static OpacityTextureEnabled: boolean;
  38058. private static _ReflectionTextureEnabled;
  38059. /**
  38060. * Are reflection textures enabled in the application.
  38061. */
  38062. static ReflectionTextureEnabled: boolean;
  38063. private static _EmissiveTextureEnabled;
  38064. /**
  38065. * Are emissive textures enabled in the application.
  38066. */
  38067. static EmissiveTextureEnabled: boolean;
  38068. private static _SpecularTextureEnabled;
  38069. /**
  38070. * Are specular textures enabled in the application.
  38071. */
  38072. static SpecularTextureEnabled: boolean;
  38073. private static _BumpTextureEnabled;
  38074. /**
  38075. * Are bump textures enabled in the application.
  38076. */
  38077. static BumpTextureEnabled: boolean;
  38078. private static _LightmapTextureEnabled;
  38079. /**
  38080. * Are lightmap textures enabled in the application.
  38081. */
  38082. static LightmapTextureEnabled: boolean;
  38083. private static _RefractionTextureEnabled;
  38084. /**
  38085. * Are refraction textures enabled in the application.
  38086. */
  38087. static RefractionTextureEnabled: boolean;
  38088. private static _ColorGradingTextureEnabled;
  38089. /**
  38090. * Are color grading textures enabled in the application.
  38091. */
  38092. static ColorGradingTextureEnabled: boolean;
  38093. private static _FresnelEnabled;
  38094. /**
  38095. * Are fresnels enabled in the application.
  38096. */
  38097. static FresnelEnabled: boolean;
  38098. private static _ClearCoatTextureEnabled;
  38099. /**
  38100. * Are clear coat textures enabled in the application.
  38101. */
  38102. static ClearCoatTextureEnabled: boolean;
  38103. private static _ClearCoatBumpTextureEnabled;
  38104. /**
  38105. * Are clear coat bump textures enabled in the application.
  38106. */
  38107. static ClearCoatBumpTextureEnabled: boolean;
  38108. private static _ClearCoatTintTextureEnabled;
  38109. /**
  38110. * Are clear coat tint textures enabled in the application.
  38111. */
  38112. static ClearCoatTintTextureEnabled: boolean;
  38113. private static _SheenTextureEnabled;
  38114. /**
  38115. * Are sheen textures enabled in the application.
  38116. */
  38117. static SheenTextureEnabled: boolean;
  38118. private static _AnisotropicTextureEnabled;
  38119. /**
  38120. * Are anisotropic textures enabled in the application.
  38121. */
  38122. static AnisotropicTextureEnabled: boolean;
  38123. private static _ThicknessTextureEnabled;
  38124. /**
  38125. * Are thickness textures enabled in the application.
  38126. */
  38127. static ThicknessTextureEnabled: boolean;
  38128. }
  38129. }
  38130. declare module BABYLON {
  38131. /** @hidden */
  38132. export var defaultFragmentDeclaration: {
  38133. name: string;
  38134. shader: string;
  38135. };
  38136. }
  38137. declare module BABYLON {
  38138. /** @hidden */
  38139. export var defaultUboDeclaration: {
  38140. name: string;
  38141. shader: string;
  38142. };
  38143. }
  38144. declare module BABYLON {
  38145. /** @hidden */
  38146. export var lightFragmentDeclaration: {
  38147. name: string;
  38148. shader: string;
  38149. };
  38150. }
  38151. declare module BABYLON {
  38152. /** @hidden */
  38153. export var lightUboDeclaration: {
  38154. name: string;
  38155. shader: string;
  38156. };
  38157. }
  38158. declare module BABYLON {
  38159. /** @hidden */
  38160. export var lightsFragmentFunctions: {
  38161. name: string;
  38162. shader: string;
  38163. };
  38164. }
  38165. declare module BABYLON {
  38166. /** @hidden */
  38167. export var shadowsFragmentFunctions: {
  38168. name: string;
  38169. shader: string;
  38170. };
  38171. }
  38172. declare module BABYLON {
  38173. /** @hidden */
  38174. export var fresnelFunction: {
  38175. name: string;
  38176. shader: string;
  38177. };
  38178. }
  38179. declare module BABYLON {
  38180. /** @hidden */
  38181. export var reflectionFunction: {
  38182. name: string;
  38183. shader: string;
  38184. };
  38185. }
  38186. declare module BABYLON {
  38187. /** @hidden */
  38188. export var bumpFragmentFunctions: {
  38189. name: string;
  38190. shader: string;
  38191. };
  38192. }
  38193. declare module BABYLON {
  38194. /** @hidden */
  38195. export var logDepthDeclaration: {
  38196. name: string;
  38197. shader: string;
  38198. };
  38199. }
  38200. declare module BABYLON {
  38201. /** @hidden */
  38202. export var bumpFragment: {
  38203. name: string;
  38204. shader: string;
  38205. };
  38206. }
  38207. declare module BABYLON {
  38208. /** @hidden */
  38209. export var depthPrePass: {
  38210. name: string;
  38211. shader: string;
  38212. };
  38213. }
  38214. declare module BABYLON {
  38215. /** @hidden */
  38216. export var lightFragment: {
  38217. name: string;
  38218. shader: string;
  38219. };
  38220. }
  38221. declare module BABYLON {
  38222. /** @hidden */
  38223. export var logDepthFragment: {
  38224. name: string;
  38225. shader: string;
  38226. };
  38227. }
  38228. declare module BABYLON {
  38229. /** @hidden */
  38230. export var defaultPixelShader: {
  38231. name: string;
  38232. shader: string;
  38233. };
  38234. }
  38235. declare module BABYLON {
  38236. /** @hidden */
  38237. export var defaultVertexDeclaration: {
  38238. name: string;
  38239. shader: string;
  38240. };
  38241. }
  38242. declare module BABYLON {
  38243. /** @hidden */
  38244. export var bumpVertexDeclaration: {
  38245. name: string;
  38246. shader: string;
  38247. };
  38248. }
  38249. declare module BABYLON {
  38250. /** @hidden */
  38251. export var bumpVertex: {
  38252. name: string;
  38253. shader: string;
  38254. };
  38255. }
  38256. declare module BABYLON {
  38257. /** @hidden */
  38258. export var fogVertex: {
  38259. name: string;
  38260. shader: string;
  38261. };
  38262. }
  38263. declare module BABYLON {
  38264. /** @hidden */
  38265. export var shadowsVertex: {
  38266. name: string;
  38267. shader: string;
  38268. };
  38269. }
  38270. declare module BABYLON {
  38271. /** @hidden */
  38272. export var pointCloudVertex: {
  38273. name: string;
  38274. shader: string;
  38275. };
  38276. }
  38277. declare module BABYLON {
  38278. /** @hidden */
  38279. export var logDepthVertex: {
  38280. name: string;
  38281. shader: string;
  38282. };
  38283. }
  38284. declare module BABYLON {
  38285. /** @hidden */
  38286. export var defaultVertexShader: {
  38287. name: string;
  38288. shader: string;
  38289. };
  38290. }
  38291. declare module BABYLON {
  38292. /** @hidden */
  38293. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38294. MAINUV1: boolean;
  38295. MAINUV2: boolean;
  38296. DIFFUSE: boolean;
  38297. DIFFUSEDIRECTUV: number;
  38298. AMBIENT: boolean;
  38299. AMBIENTDIRECTUV: number;
  38300. OPACITY: boolean;
  38301. OPACITYDIRECTUV: number;
  38302. OPACITYRGB: boolean;
  38303. REFLECTION: boolean;
  38304. EMISSIVE: boolean;
  38305. EMISSIVEDIRECTUV: number;
  38306. SPECULAR: boolean;
  38307. SPECULARDIRECTUV: number;
  38308. BUMP: boolean;
  38309. BUMPDIRECTUV: number;
  38310. PARALLAX: boolean;
  38311. PARALLAXOCCLUSION: boolean;
  38312. SPECULAROVERALPHA: boolean;
  38313. CLIPPLANE: boolean;
  38314. CLIPPLANE2: boolean;
  38315. CLIPPLANE3: boolean;
  38316. CLIPPLANE4: boolean;
  38317. ALPHATEST: boolean;
  38318. DEPTHPREPASS: boolean;
  38319. ALPHAFROMDIFFUSE: boolean;
  38320. POINTSIZE: boolean;
  38321. FOG: boolean;
  38322. SPECULARTERM: boolean;
  38323. DIFFUSEFRESNEL: boolean;
  38324. OPACITYFRESNEL: boolean;
  38325. REFLECTIONFRESNEL: boolean;
  38326. REFRACTIONFRESNEL: boolean;
  38327. EMISSIVEFRESNEL: boolean;
  38328. FRESNEL: boolean;
  38329. NORMAL: boolean;
  38330. UV1: boolean;
  38331. UV2: boolean;
  38332. VERTEXCOLOR: boolean;
  38333. VERTEXALPHA: boolean;
  38334. NUM_BONE_INFLUENCERS: number;
  38335. BonesPerMesh: number;
  38336. BONETEXTURE: boolean;
  38337. INSTANCES: boolean;
  38338. GLOSSINESS: boolean;
  38339. ROUGHNESS: boolean;
  38340. EMISSIVEASILLUMINATION: boolean;
  38341. LINKEMISSIVEWITHDIFFUSE: boolean;
  38342. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38343. LIGHTMAP: boolean;
  38344. LIGHTMAPDIRECTUV: number;
  38345. OBJECTSPACE_NORMALMAP: boolean;
  38346. USELIGHTMAPASSHADOWMAP: boolean;
  38347. REFLECTIONMAP_3D: boolean;
  38348. REFLECTIONMAP_SPHERICAL: boolean;
  38349. REFLECTIONMAP_PLANAR: boolean;
  38350. REFLECTIONMAP_CUBIC: boolean;
  38351. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38352. REFLECTIONMAP_PROJECTION: boolean;
  38353. REFLECTIONMAP_SKYBOX: boolean;
  38354. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38355. REFLECTIONMAP_EXPLICIT: boolean;
  38356. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38357. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38358. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38359. INVERTCUBICMAP: boolean;
  38360. LOGARITHMICDEPTH: boolean;
  38361. REFRACTION: boolean;
  38362. REFRACTIONMAP_3D: boolean;
  38363. REFLECTIONOVERALPHA: boolean;
  38364. TWOSIDEDLIGHTING: boolean;
  38365. SHADOWFLOAT: boolean;
  38366. MORPHTARGETS: boolean;
  38367. MORPHTARGETS_NORMAL: boolean;
  38368. MORPHTARGETS_TANGENT: boolean;
  38369. NUM_MORPH_INFLUENCERS: number;
  38370. NONUNIFORMSCALING: boolean;
  38371. PREMULTIPLYALPHA: boolean;
  38372. IMAGEPROCESSING: boolean;
  38373. VIGNETTE: boolean;
  38374. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38375. VIGNETTEBLENDMODEOPAQUE: boolean;
  38376. TONEMAPPING: boolean;
  38377. TONEMAPPING_ACES: boolean;
  38378. CONTRAST: boolean;
  38379. COLORCURVES: boolean;
  38380. COLORGRADING: boolean;
  38381. COLORGRADING3D: boolean;
  38382. SAMPLER3DGREENDEPTH: boolean;
  38383. SAMPLER3DBGRMAP: boolean;
  38384. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38385. MULTIVIEW: boolean;
  38386. /**
  38387. * If the reflection texture on this material is in linear color space
  38388. * @hidden
  38389. */
  38390. IS_REFLECTION_LINEAR: boolean;
  38391. /**
  38392. * If the refraction texture on this material is in linear color space
  38393. * @hidden
  38394. */
  38395. IS_REFRACTION_LINEAR: boolean;
  38396. EXPOSURE: boolean;
  38397. constructor();
  38398. setReflectionMode(modeToEnable: string): void;
  38399. }
  38400. /**
  38401. * This is the default material used in Babylon. It is the best trade off between quality
  38402. * and performances.
  38403. * @see http://doc.babylonjs.com/babylon101/materials
  38404. */
  38405. export class StandardMaterial extends PushMaterial {
  38406. private _diffuseTexture;
  38407. /**
  38408. * The basic texture of the material as viewed under a light.
  38409. */
  38410. diffuseTexture: Nullable<BaseTexture>;
  38411. private _ambientTexture;
  38412. /**
  38413. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38414. */
  38415. ambientTexture: Nullable<BaseTexture>;
  38416. private _opacityTexture;
  38417. /**
  38418. * Define the transparency of the material from a texture.
  38419. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38420. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38421. */
  38422. opacityTexture: Nullable<BaseTexture>;
  38423. private _reflectionTexture;
  38424. /**
  38425. * Define the texture used to display the reflection.
  38426. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38427. */
  38428. reflectionTexture: Nullable<BaseTexture>;
  38429. private _emissiveTexture;
  38430. /**
  38431. * Define texture of the material as if self lit.
  38432. * This will be mixed in the final result even in the absence of light.
  38433. */
  38434. emissiveTexture: Nullable<BaseTexture>;
  38435. private _specularTexture;
  38436. /**
  38437. * Define how the color and intensity of the highlight given by the light in the material.
  38438. */
  38439. specularTexture: Nullable<BaseTexture>;
  38440. private _bumpTexture;
  38441. /**
  38442. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38443. * 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.
  38444. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38445. */
  38446. bumpTexture: Nullable<BaseTexture>;
  38447. private _lightmapTexture;
  38448. /**
  38449. * Complex lighting can be computationally expensive to compute at runtime.
  38450. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38451. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38452. */
  38453. lightmapTexture: Nullable<BaseTexture>;
  38454. private _refractionTexture;
  38455. /**
  38456. * Define the texture used to display the refraction.
  38457. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38458. */
  38459. refractionTexture: Nullable<BaseTexture>;
  38460. /**
  38461. * The color of the material lit by the environmental background lighting.
  38462. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38463. */
  38464. ambientColor: Color3;
  38465. /**
  38466. * The basic color of the material as viewed under a light.
  38467. */
  38468. diffuseColor: Color3;
  38469. /**
  38470. * Define how the color and intensity of the highlight given by the light in the material.
  38471. */
  38472. specularColor: Color3;
  38473. /**
  38474. * Define the color of the material as if self lit.
  38475. * This will be mixed in the final result even in the absence of light.
  38476. */
  38477. emissiveColor: Color3;
  38478. /**
  38479. * Defines how sharp are the highlights in the material.
  38480. * The bigger the value the sharper giving a more glossy feeling to the result.
  38481. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38482. */
  38483. specularPower: number;
  38484. private _useAlphaFromDiffuseTexture;
  38485. /**
  38486. * Does the transparency come from the diffuse texture alpha channel.
  38487. */
  38488. useAlphaFromDiffuseTexture: boolean;
  38489. private _useEmissiveAsIllumination;
  38490. /**
  38491. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38492. */
  38493. useEmissiveAsIllumination: boolean;
  38494. private _linkEmissiveWithDiffuse;
  38495. /**
  38496. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38497. * the emissive level when the final color is close to one.
  38498. */
  38499. linkEmissiveWithDiffuse: boolean;
  38500. private _useSpecularOverAlpha;
  38501. /**
  38502. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38503. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38504. */
  38505. useSpecularOverAlpha: boolean;
  38506. private _useReflectionOverAlpha;
  38507. /**
  38508. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38509. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38510. */
  38511. useReflectionOverAlpha: boolean;
  38512. private _disableLighting;
  38513. /**
  38514. * Does lights from the scene impacts this material.
  38515. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38516. */
  38517. disableLighting: boolean;
  38518. private _useObjectSpaceNormalMap;
  38519. /**
  38520. * Allows using an object space normal map (instead of tangent space).
  38521. */
  38522. useObjectSpaceNormalMap: boolean;
  38523. private _useParallax;
  38524. /**
  38525. * Is parallax enabled or not.
  38526. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38527. */
  38528. useParallax: boolean;
  38529. private _useParallaxOcclusion;
  38530. /**
  38531. * Is parallax occlusion enabled or not.
  38532. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38533. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38534. */
  38535. useParallaxOcclusion: boolean;
  38536. /**
  38537. * 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.
  38538. */
  38539. parallaxScaleBias: number;
  38540. private _roughness;
  38541. /**
  38542. * Helps to define how blurry the reflections should appears in the material.
  38543. */
  38544. roughness: number;
  38545. /**
  38546. * In case of refraction, define the value of the indice of refraction.
  38547. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38548. */
  38549. indexOfRefraction: number;
  38550. /**
  38551. * Invert the refraction texture alongside the y axis.
  38552. * It can be useful with procedural textures or probe for instance.
  38553. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38554. */
  38555. invertRefractionY: boolean;
  38556. /**
  38557. * Defines the alpha limits in alpha test mode.
  38558. */
  38559. alphaCutOff: number;
  38560. private _useLightmapAsShadowmap;
  38561. /**
  38562. * In case of light mapping, define whether the map contains light or shadow informations.
  38563. */
  38564. useLightmapAsShadowmap: boolean;
  38565. private _diffuseFresnelParameters;
  38566. /**
  38567. * Define the diffuse fresnel parameters of the material.
  38568. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38569. */
  38570. diffuseFresnelParameters: FresnelParameters;
  38571. private _opacityFresnelParameters;
  38572. /**
  38573. * Define the opacity fresnel parameters of the material.
  38574. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38575. */
  38576. opacityFresnelParameters: FresnelParameters;
  38577. private _reflectionFresnelParameters;
  38578. /**
  38579. * Define the reflection fresnel parameters of the material.
  38580. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38581. */
  38582. reflectionFresnelParameters: FresnelParameters;
  38583. private _refractionFresnelParameters;
  38584. /**
  38585. * Define the refraction fresnel parameters of the material.
  38586. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38587. */
  38588. refractionFresnelParameters: FresnelParameters;
  38589. private _emissiveFresnelParameters;
  38590. /**
  38591. * Define the emissive fresnel parameters of the material.
  38592. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38593. */
  38594. emissiveFresnelParameters: FresnelParameters;
  38595. private _useReflectionFresnelFromSpecular;
  38596. /**
  38597. * If true automatically deducts the fresnels values from the material specularity.
  38598. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38599. */
  38600. useReflectionFresnelFromSpecular: boolean;
  38601. private _useGlossinessFromSpecularMapAlpha;
  38602. /**
  38603. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38604. */
  38605. useGlossinessFromSpecularMapAlpha: boolean;
  38606. private _maxSimultaneousLights;
  38607. /**
  38608. * Defines the maximum number of lights that can be used in the material
  38609. */
  38610. maxSimultaneousLights: number;
  38611. private _invertNormalMapX;
  38612. /**
  38613. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38614. */
  38615. invertNormalMapX: boolean;
  38616. private _invertNormalMapY;
  38617. /**
  38618. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38619. */
  38620. invertNormalMapY: boolean;
  38621. private _twoSidedLighting;
  38622. /**
  38623. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38624. */
  38625. twoSidedLighting: boolean;
  38626. /**
  38627. * Default configuration related to image processing available in the standard Material.
  38628. */
  38629. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38630. /**
  38631. * Gets the image processing configuration used either in this material.
  38632. */
  38633. /**
  38634. * Sets the Default image processing configuration used either in the this material.
  38635. *
  38636. * If sets to null, the scene one is in use.
  38637. */
  38638. imageProcessingConfiguration: ImageProcessingConfiguration;
  38639. /**
  38640. * Keep track of the image processing observer to allow dispose and replace.
  38641. */
  38642. private _imageProcessingObserver;
  38643. /**
  38644. * Attaches a new image processing configuration to the Standard Material.
  38645. * @param configuration
  38646. */
  38647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38648. /**
  38649. * Gets wether the color curves effect is enabled.
  38650. */
  38651. /**
  38652. * Sets wether the color curves effect is enabled.
  38653. */
  38654. cameraColorCurvesEnabled: boolean;
  38655. /**
  38656. * Gets wether the color grading effect is enabled.
  38657. */
  38658. /**
  38659. * Gets wether the color grading effect is enabled.
  38660. */
  38661. cameraColorGradingEnabled: boolean;
  38662. /**
  38663. * Gets wether tonemapping is enabled or not.
  38664. */
  38665. /**
  38666. * Sets wether tonemapping is enabled or not
  38667. */
  38668. cameraToneMappingEnabled: boolean;
  38669. /**
  38670. * The camera exposure used on this material.
  38671. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38672. * This corresponds to a photographic exposure.
  38673. */
  38674. /**
  38675. * The camera exposure used on this material.
  38676. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38677. * This corresponds to a photographic exposure.
  38678. */
  38679. cameraExposure: number;
  38680. /**
  38681. * Gets The camera contrast used on this material.
  38682. */
  38683. /**
  38684. * Sets The camera contrast used on this material.
  38685. */
  38686. cameraContrast: number;
  38687. /**
  38688. * Gets the Color Grading 2D Lookup Texture.
  38689. */
  38690. /**
  38691. * Sets the Color Grading 2D Lookup Texture.
  38692. */
  38693. cameraColorGradingTexture: Nullable<BaseTexture>;
  38694. /**
  38695. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38696. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38697. * 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;
  38698. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38699. */
  38700. /**
  38701. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38702. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38703. * 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;
  38704. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38705. */
  38706. cameraColorCurves: Nullable<ColorCurves>;
  38707. /**
  38708. * Custom callback helping to override the default shader used in the material.
  38709. */
  38710. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38711. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38712. protected _worldViewProjectionMatrix: Matrix;
  38713. protected _globalAmbientColor: Color3;
  38714. protected _useLogarithmicDepth: boolean;
  38715. /**
  38716. * Instantiates a new standard material.
  38717. * This is the default material used in Babylon. It is the best trade off between quality
  38718. * and performances.
  38719. * @see http://doc.babylonjs.com/babylon101/materials
  38720. * @param name Define the name of the material in the scene
  38721. * @param scene Define the scene the material belong to
  38722. */
  38723. constructor(name: string, scene: Scene);
  38724. /**
  38725. * Gets a boolean indicating that current material needs to register RTT
  38726. */
  38727. readonly hasRenderTargetTextures: boolean;
  38728. /**
  38729. * Gets the current class name of the material e.g. "StandardMaterial"
  38730. * Mainly use in serialization.
  38731. * @returns the class name
  38732. */
  38733. getClassName(): string;
  38734. /**
  38735. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38736. * You can try switching to logarithmic depth.
  38737. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38738. */
  38739. useLogarithmicDepth: boolean;
  38740. /**
  38741. * Specifies if the material will require alpha blending
  38742. * @returns a boolean specifying if alpha blending is needed
  38743. */
  38744. needAlphaBlending(): boolean;
  38745. /**
  38746. * Specifies if this material should be rendered in alpha test mode
  38747. * @returns a boolean specifying if an alpha test is needed.
  38748. */
  38749. needAlphaTesting(): boolean;
  38750. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38751. /**
  38752. * Get the texture used for alpha test purpose.
  38753. * @returns the diffuse texture in case of the standard material.
  38754. */
  38755. getAlphaTestTexture(): Nullable<BaseTexture>;
  38756. /**
  38757. * Get if the submesh is ready to be used and all its information available.
  38758. * Child classes can use it to update shaders
  38759. * @param mesh defines the mesh to check
  38760. * @param subMesh defines which submesh to check
  38761. * @param useInstances specifies that instances should be used
  38762. * @returns a boolean indicating that the submesh is ready or not
  38763. */
  38764. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38765. /**
  38766. * Builds the material UBO layouts.
  38767. * Used internally during the effect preparation.
  38768. */
  38769. buildUniformLayout(): void;
  38770. /**
  38771. * Unbinds the material from the mesh
  38772. */
  38773. unbind(): void;
  38774. /**
  38775. * Binds the submesh to this material by preparing the effect and shader to draw
  38776. * @param world defines the world transformation matrix
  38777. * @param mesh defines the mesh containing the submesh
  38778. * @param subMesh defines the submesh to bind the material to
  38779. */
  38780. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38781. /**
  38782. * Get the list of animatables in the material.
  38783. * @returns the list of animatables object used in the material
  38784. */
  38785. getAnimatables(): IAnimatable[];
  38786. /**
  38787. * Gets the active textures from the material
  38788. * @returns an array of textures
  38789. */
  38790. getActiveTextures(): BaseTexture[];
  38791. /**
  38792. * Specifies if the material uses a texture
  38793. * @param texture defines the texture to check against the material
  38794. * @returns a boolean specifying if the material uses the texture
  38795. */
  38796. hasTexture(texture: BaseTexture): boolean;
  38797. /**
  38798. * Disposes the material
  38799. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38800. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38801. */
  38802. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38803. /**
  38804. * Makes a duplicate of the material, and gives it a new name
  38805. * @param name defines the new name for the duplicated material
  38806. * @returns the cloned material
  38807. */
  38808. clone(name: string): StandardMaterial;
  38809. /**
  38810. * Serializes this material in a JSON representation
  38811. * @returns the serialized material object
  38812. */
  38813. serialize(): any;
  38814. /**
  38815. * Creates a standard material from parsed material data
  38816. * @param source defines the JSON representation of the material
  38817. * @param scene defines the hosting scene
  38818. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38819. * @returns a new standard material
  38820. */
  38821. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38822. /**
  38823. * Are diffuse textures enabled in the application.
  38824. */
  38825. static DiffuseTextureEnabled: boolean;
  38826. /**
  38827. * Are ambient textures enabled in the application.
  38828. */
  38829. static AmbientTextureEnabled: boolean;
  38830. /**
  38831. * Are opacity textures enabled in the application.
  38832. */
  38833. static OpacityTextureEnabled: boolean;
  38834. /**
  38835. * Are reflection textures enabled in the application.
  38836. */
  38837. static ReflectionTextureEnabled: boolean;
  38838. /**
  38839. * Are emissive textures enabled in the application.
  38840. */
  38841. static EmissiveTextureEnabled: boolean;
  38842. /**
  38843. * Are specular textures enabled in the application.
  38844. */
  38845. static SpecularTextureEnabled: boolean;
  38846. /**
  38847. * Are bump textures enabled in the application.
  38848. */
  38849. static BumpTextureEnabled: boolean;
  38850. /**
  38851. * Are lightmap textures enabled in the application.
  38852. */
  38853. static LightmapTextureEnabled: boolean;
  38854. /**
  38855. * Are refraction textures enabled in the application.
  38856. */
  38857. static RefractionTextureEnabled: boolean;
  38858. /**
  38859. * Are color grading textures enabled in the application.
  38860. */
  38861. static ColorGradingTextureEnabled: boolean;
  38862. /**
  38863. * Are fresnels enabled in the application.
  38864. */
  38865. static FresnelEnabled: boolean;
  38866. }
  38867. }
  38868. declare module BABYLON {
  38869. /**
  38870. * A class extending Texture allowing drawing on a texture
  38871. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38872. */
  38873. export class DynamicTexture extends Texture {
  38874. private _generateMipMaps;
  38875. private _canvas;
  38876. private _context;
  38877. private _engine;
  38878. /**
  38879. * Creates a DynamicTexture
  38880. * @param name defines the name of the texture
  38881. * @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
  38882. * @param scene defines the scene where you want the texture
  38883. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38884. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38885. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38886. */
  38887. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38888. /**
  38889. * Get the current class name of the texture useful for serialization or dynamic coding.
  38890. * @returns "DynamicTexture"
  38891. */
  38892. getClassName(): string;
  38893. /**
  38894. * Gets the current state of canRescale
  38895. */
  38896. readonly canRescale: boolean;
  38897. private _recreate;
  38898. /**
  38899. * Scales the texture
  38900. * @param ratio the scale factor to apply to both width and height
  38901. */
  38902. scale(ratio: number): void;
  38903. /**
  38904. * Resizes the texture
  38905. * @param width the new width
  38906. * @param height the new height
  38907. */
  38908. scaleTo(width: number, height: number): void;
  38909. /**
  38910. * Gets the context of the canvas used by the texture
  38911. * @returns the canvas context of the dynamic texture
  38912. */
  38913. getContext(): CanvasRenderingContext2D;
  38914. /**
  38915. * Clears the texture
  38916. */
  38917. clear(): void;
  38918. /**
  38919. * Updates the texture
  38920. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38921. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38922. */
  38923. update(invertY?: boolean, premulAlpha?: boolean): void;
  38924. /**
  38925. * Draws text onto the texture
  38926. * @param text defines the text to be drawn
  38927. * @param x defines the placement of the text from the left
  38928. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38929. * @param font defines the font to be used with font-style, font-size, font-name
  38930. * @param color defines the color used for the text
  38931. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38932. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38933. * @param update defines whether texture is immediately update (default is true)
  38934. */
  38935. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38936. /**
  38937. * Clones the texture
  38938. * @returns the clone of the texture.
  38939. */
  38940. clone(): DynamicTexture;
  38941. /**
  38942. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38943. * @returns a serialized dynamic texture object
  38944. */
  38945. serialize(): any;
  38946. /** @hidden */
  38947. _rebuild(): void;
  38948. }
  38949. }
  38950. declare module BABYLON {
  38951. /** @hidden */
  38952. export var imageProcessingPixelShader: {
  38953. name: string;
  38954. shader: string;
  38955. };
  38956. }
  38957. declare module BABYLON {
  38958. /**
  38959. * ImageProcessingPostProcess
  38960. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38961. */
  38962. export class ImageProcessingPostProcess extends PostProcess {
  38963. /**
  38964. * Default configuration related to image processing available in the PBR Material.
  38965. */
  38966. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38967. /**
  38968. * Gets the image processing configuration used either in this material.
  38969. */
  38970. /**
  38971. * Sets the Default image processing configuration used either in the this material.
  38972. *
  38973. * If sets to null, the scene one is in use.
  38974. */
  38975. imageProcessingConfiguration: ImageProcessingConfiguration;
  38976. /**
  38977. * Keep track of the image processing observer to allow dispose and replace.
  38978. */
  38979. private _imageProcessingObserver;
  38980. /**
  38981. * Attaches a new image processing configuration to the PBR Material.
  38982. * @param configuration
  38983. */
  38984. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38985. /**
  38986. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38987. */
  38988. /**
  38989. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38990. */
  38991. colorCurves: Nullable<ColorCurves>;
  38992. /**
  38993. * Gets wether the color curves effect is enabled.
  38994. */
  38995. /**
  38996. * Sets wether the color curves effect is enabled.
  38997. */
  38998. colorCurvesEnabled: boolean;
  38999. /**
  39000. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39001. */
  39002. /**
  39003. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39004. */
  39005. colorGradingTexture: Nullable<BaseTexture>;
  39006. /**
  39007. * Gets wether the color grading effect is enabled.
  39008. */
  39009. /**
  39010. * Gets wether the color grading effect is enabled.
  39011. */
  39012. colorGradingEnabled: boolean;
  39013. /**
  39014. * Gets exposure used in the effect.
  39015. */
  39016. /**
  39017. * Sets exposure used in the effect.
  39018. */
  39019. exposure: number;
  39020. /**
  39021. * Gets wether tonemapping is enabled or not.
  39022. */
  39023. /**
  39024. * Sets wether tonemapping is enabled or not
  39025. */
  39026. toneMappingEnabled: boolean;
  39027. /**
  39028. * Gets the type of tone mapping effect.
  39029. */
  39030. /**
  39031. * Sets the type of tone mapping effect.
  39032. */
  39033. toneMappingType: number;
  39034. /**
  39035. * Gets contrast used in the effect.
  39036. */
  39037. /**
  39038. * Sets contrast used in the effect.
  39039. */
  39040. contrast: number;
  39041. /**
  39042. * Gets Vignette stretch size.
  39043. */
  39044. /**
  39045. * Sets Vignette stretch size.
  39046. */
  39047. vignetteStretch: number;
  39048. /**
  39049. * Gets Vignette centre X Offset.
  39050. */
  39051. /**
  39052. * Sets Vignette centre X Offset.
  39053. */
  39054. vignetteCentreX: number;
  39055. /**
  39056. * Gets Vignette centre Y Offset.
  39057. */
  39058. /**
  39059. * Sets Vignette centre Y Offset.
  39060. */
  39061. vignetteCentreY: number;
  39062. /**
  39063. * Gets Vignette weight or intensity of the vignette effect.
  39064. */
  39065. /**
  39066. * Sets Vignette weight or intensity of the vignette effect.
  39067. */
  39068. vignetteWeight: number;
  39069. /**
  39070. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39071. * if vignetteEnabled is set to true.
  39072. */
  39073. /**
  39074. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39075. * if vignetteEnabled is set to true.
  39076. */
  39077. vignetteColor: Color4;
  39078. /**
  39079. * Gets Camera field of view used by the Vignette effect.
  39080. */
  39081. /**
  39082. * Sets Camera field of view used by the Vignette effect.
  39083. */
  39084. vignetteCameraFov: number;
  39085. /**
  39086. * Gets the vignette blend mode allowing different kind of effect.
  39087. */
  39088. /**
  39089. * Sets the vignette blend mode allowing different kind of effect.
  39090. */
  39091. vignetteBlendMode: number;
  39092. /**
  39093. * Gets wether the vignette effect is enabled.
  39094. */
  39095. /**
  39096. * Sets wether the vignette effect is enabled.
  39097. */
  39098. vignetteEnabled: boolean;
  39099. private _fromLinearSpace;
  39100. /**
  39101. * Gets wether the input of the processing is in Gamma or Linear Space.
  39102. */
  39103. /**
  39104. * Sets wether the input of the processing is in Gamma or Linear Space.
  39105. */
  39106. fromLinearSpace: boolean;
  39107. /**
  39108. * Defines cache preventing GC.
  39109. */
  39110. private _defines;
  39111. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39112. /**
  39113. * "ImageProcessingPostProcess"
  39114. * @returns "ImageProcessingPostProcess"
  39115. */
  39116. getClassName(): string;
  39117. protected _updateParameters(): void;
  39118. dispose(camera?: Camera): void;
  39119. }
  39120. }
  39121. declare module BABYLON {
  39122. /**
  39123. * Class containing static functions to help procedurally build meshes
  39124. */
  39125. export class GroundBuilder {
  39126. /**
  39127. * Creates a ground mesh
  39128. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39129. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39131. * @param name defines the name of the mesh
  39132. * @param options defines the options used to create the mesh
  39133. * @param scene defines the hosting scene
  39134. * @returns the ground mesh
  39135. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39136. */
  39137. static CreateGround(name: string, options: {
  39138. width?: number;
  39139. height?: number;
  39140. subdivisions?: number;
  39141. subdivisionsX?: number;
  39142. subdivisionsY?: number;
  39143. updatable?: boolean;
  39144. }, scene: any): Mesh;
  39145. /**
  39146. * Creates a tiled ground mesh
  39147. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39148. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39149. * * 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
  39150. * * 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
  39151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39152. * @param name defines the name of the mesh
  39153. * @param options defines the options used to create the mesh
  39154. * @param scene defines the hosting scene
  39155. * @returns the tiled ground mesh
  39156. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39157. */
  39158. static CreateTiledGround(name: string, options: {
  39159. xmin: number;
  39160. zmin: number;
  39161. xmax: number;
  39162. zmax: number;
  39163. subdivisions?: {
  39164. w: number;
  39165. h: number;
  39166. };
  39167. precision?: {
  39168. w: number;
  39169. h: number;
  39170. };
  39171. updatable?: boolean;
  39172. }, scene: Scene): Mesh;
  39173. /**
  39174. * Creates a ground mesh from a height map
  39175. * * The parameter `url` sets the URL of the height map image resource.
  39176. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39177. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39178. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39179. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39180. * * 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.
  39181. * * 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).
  39182. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39184. * @param name defines the name of the mesh
  39185. * @param url defines the url to the height map
  39186. * @param options defines the options used to create the mesh
  39187. * @param scene defines the hosting scene
  39188. * @returns the ground mesh
  39189. * @see https://doc.babylonjs.com/babylon101/height_map
  39190. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39191. */
  39192. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39193. width?: number;
  39194. height?: number;
  39195. subdivisions?: number;
  39196. minHeight?: number;
  39197. maxHeight?: number;
  39198. colorFilter?: Color3;
  39199. alphaFilter?: number;
  39200. updatable?: boolean;
  39201. onReady?: (mesh: GroundMesh) => void;
  39202. }, scene: Scene): GroundMesh;
  39203. }
  39204. }
  39205. declare module BABYLON {
  39206. /**
  39207. * Class containing static functions to help procedurally build meshes
  39208. */
  39209. export class TorusBuilder {
  39210. /**
  39211. * Creates a torus mesh
  39212. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39213. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39214. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39216. * * 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
  39217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39218. * @param name defines the name of the mesh
  39219. * @param options defines the options used to create the mesh
  39220. * @param scene defines the hosting scene
  39221. * @returns the torus mesh
  39222. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39223. */
  39224. static CreateTorus(name: string, options: {
  39225. diameter?: number;
  39226. thickness?: number;
  39227. tessellation?: number;
  39228. updatable?: boolean;
  39229. sideOrientation?: number;
  39230. frontUVs?: Vector4;
  39231. backUVs?: Vector4;
  39232. }, scene: any): Mesh;
  39233. }
  39234. }
  39235. declare module BABYLON {
  39236. /**
  39237. * Class containing static functions to help procedurally build meshes
  39238. */
  39239. export class CylinderBuilder {
  39240. /**
  39241. * Creates a cylinder or a cone mesh
  39242. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39243. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39244. * * 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.
  39245. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39246. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39247. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39248. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39249. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39250. * * 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).
  39251. * * 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
  39252. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39253. * * 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
  39254. * * 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.
  39255. * * If `enclose` is false, a ring surface is one element.
  39256. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39257. * * 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
  39258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39259. * * 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
  39260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39261. * @param name defines the name of the mesh
  39262. * @param options defines the options used to create the mesh
  39263. * @param scene defines the hosting scene
  39264. * @returns the cylinder mesh
  39265. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39266. */
  39267. static CreateCylinder(name: string, options: {
  39268. height?: number;
  39269. diameterTop?: number;
  39270. diameterBottom?: number;
  39271. diameter?: number;
  39272. tessellation?: number;
  39273. subdivisions?: number;
  39274. arc?: number;
  39275. faceColors?: Color4[];
  39276. faceUV?: Vector4[];
  39277. updatable?: boolean;
  39278. hasRings?: boolean;
  39279. enclose?: boolean;
  39280. sideOrientation?: number;
  39281. frontUVs?: Vector4;
  39282. backUVs?: Vector4;
  39283. }, scene: any): Mesh;
  39284. }
  39285. }
  39286. declare module BABYLON {
  39287. /**
  39288. * Manager for handling gamepads
  39289. */
  39290. export class GamepadManager {
  39291. private _scene?;
  39292. private _babylonGamepads;
  39293. private _oneGamepadConnected;
  39294. /** @hidden */
  39295. _isMonitoring: boolean;
  39296. private _gamepadEventSupported;
  39297. private _gamepadSupport;
  39298. /**
  39299. * observable to be triggered when the gamepad controller has been connected
  39300. */
  39301. onGamepadConnectedObservable: Observable<Gamepad>;
  39302. /**
  39303. * observable to be triggered when the gamepad controller has been disconnected
  39304. */
  39305. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39306. private _onGamepadConnectedEvent;
  39307. private _onGamepadDisconnectedEvent;
  39308. /**
  39309. * Initializes the gamepad manager
  39310. * @param _scene BabylonJS scene
  39311. */
  39312. constructor(_scene?: Scene | undefined);
  39313. /**
  39314. * The gamepads in the game pad manager
  39315. */
  39316. readonly gamepads: Gamepad[];
  39317. /**
  39318. * Get the gamepad controllers based on type
  39319. * @param type The type of gamepad controller
  39320. * @returns Nullable gamepad
  39321. */
  39322. getGamepadByType(type?: number): Nullable<Gamepad>;
  39323. /**
  39324. * Disposes the gamepad manager
  39325. */
  39326. dispose(): void;
  39327. private _addNewGamepad;
  39328. private _startMonitoringGamepads;
  39329. private _stopMonitoringGamepads;
  39330. /** @hidden */
  39331. _checkGamepadsStatus(): void;
  39332. private _updateGamepadObjects;
  39333. }
  39334. }
  39335. declare module BABYLON {
  39336. interface Scene {
  39337. /** @hidden */
  39338. _gamepadManager: Nullable<GamepadManager>;
  39339. /**
  39340. * Gets the gamepad manager associated with the scene
  39341. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39342. */
  39343. gamepadManager: GamepadManager;
  39344. }
  39345. /**
  39346. * Interface representing a free camera inputs manager
  39347. */
  39348. interface FreeCameraInputsManager {
  39349. /**
  39350. * Adds gamepad input support to the FreeCameraInputsManager.
  39351. * @returns the FreeCameraInputsManager
  39352. */
  39353. addGamepad(): FreeCameraInputsManager;
  39354. }
  39355. /**
  39356. * Interface representing an arc rotate camera inputs manager
  39357. */
  39358. interface ArcRotateCameraInputsManager {
  39359. /**
  39360. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39361. * @returns the camera inputs manager
  39362. */
  39363. addGamepad(): ArcRotateCameraInputsManager;
  39364. }
  39365. /**
  39366. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39367. */
  39368. export class GamepadSystemSceneComponent implements ISceneComponent {
  39369. /**
  39370. * The component name helpfull to identify the component in the list of scene components.
  39371. */
  39372. readonly name: string;
  39373. /**
  39374. * The scene the component belongs to.
  39375. */
  39376. scene: Scene;
  39377. /**
  39378. * Creates a new instance of the component for the given scene
  39379. * @param scene Defines the scene to register the component in
  39380. */
  39381. constructor(scene: Scene);
  39382. /**
  39383. * Registers the component in a given scene
  39384. */
  39385. register(): void;
  39386. /**
  39387. * Rebuilds the elements related to this component in case of
  39388. * context lost for instance.
  39389. */
  39390. rebuild(): void;
  39391. /**
  39392. * Disposes the component and the associated ressources
  39393. */
  39394. dispose(): void;
  39395. private _beforeCameraUpdate;
  39396. }
  39397. }
  39398. declare module BABYLON {
  39399. /**
  39400. * Options to modify the vr teleportation behavior.
  39401. */
  39402. export interface VRTeleportationOptions {
  39403. /**
  39404. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39405. */
  39406. floorMeshName?: string;
  39407. /**
  39408. * A list of meshes to be used as the teleportation floor. (default: empty)
  39409. */
  39410. floorMeshes?: Mesh[];
  39411. }
  39412. /**
  39413. * Options to modify the vr experience helper's behavior.
  39414. */
  39415. export interface VRExperienceHelperOptions extends WebVROptions {
  39416. /**
  39417. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39418. */
  39419. createDeviceOrientationCamera?: boolean;
  39420. /**
  39421. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39422. */
  39423. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39424. /**
  39425. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39426. */
  39427. laserToggle?: boolean;
  39428. /**
  39429. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39430. */
  39431. floorMeshes?: Mesh[];
  39432. /**
  39433. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39434. */
  39435. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39436. }
  39437. /**
  39438. * Event containing information after VR has been entered
  39439. */
  39440. export class OnAfterEnteringVRObservableEvent {
  39441. /**
  39442. * If entering vr was successful
  39443. */
  39444. success: boolean;
  39445. }
  39446. /**
  39447. * Helps to quickly add VR support to an existing scene.
  39448. * See http://doc.babylonjs.com/how_to/webvr_helper
  39449. */
  39450. export class VRExperienceHelper {
  39451. /** Options to modify the vr experience helper's behavior. */
  39452. webVROptions: VRExperienceHelperOptions;
  39453. private _scene;
  39454. private _position;
  39455. private _btnVR;
  39456. private _btnVRDisplayed;
  39457. private _webVRsupported;
  39458. private _webVRready;
  39459. private _webVRrequesting;
  39460. private _webVRpresenting;
  39461. private _hasEnteredVR;
  39462. private _fullscreenVRpresenting;
  39463. private _canvas;
  39464. private _webVRCamera;
  39465. private _vrDeviceOrientationCamera;
  39466. private _deviceOrientationCamera;
  39467. private _existingCamera;
  39468. private _onKeyDown;
  39469. private _onVrDisplayPresentChange;
  39470. private _onVRDisplayChanged;
  39471. private _onVRRequestPresentStart;
  39472. private _onVRRequestPresentComplete;
  39473. /**
  39474. * Observable raised right before entering VR.
  39475. */
  39476. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39477. /**
  39478. * Observable raised when entering VR has completed.
  39479. */
  39480. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39481. /**
  39482. * Observable raised when exiting VR.
  39483. */
  39484. onExitingVRObservable: Observable<VRExperienceHelper>;
  39485. /**
  39486. * Observable raised when controller mesh is loaded.
  39487. */
  39488. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39489. /** Return this.onEnteringVRObservable
  39490. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39491. */
  39492. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39493. /** Return this.onExitingVRObservable
  39494. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39495. */
  39496. readonly onExitingVR: Observable<VRExperienceHelper>;
  39497. /** Return this.onControllerMeshLoadedObservable
  39498. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39499. */
  39500. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39501. private _rayLength;
  39502. private _useCustomVRButton;
  39503. private _teleportationRequested;
  39504. private _teleportActive;
  39505. private _floorMeshName;
  39506. private _floorMeshesCollection;
  39507. private _rotationAllowed;
  39508. private _teleportBackwardsVector;
  39509. private _teleportationTarget;
  39510. private _isDefaultTeleportationTarget;
  39511. private _postProcessMove;
  39512. private _teleportationFillColor;
  39513. private _teleportationBorderColor;
  39514. private _rotationAngle;
  39515. private _haloCenter;
  39516. private _cameraGazer;
  39517. private _padSensibilityUp;
  39518. private _padSensibilityDown;
  39519. private _leftController;
  39520. private _rightController;
  39521. /**
  39522. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39523. */
  39524. onNewMeshSelected: Observable<AbstractMesh>;
  39525. /**
  39526. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39527. */
  39528. onNewMeshPicked: Observable<PickingInfo>;
  39529. private _circleEase;
  39530. /**
  39531. * Observable raised before camera teleportation
  39532. */
  39533. onBeforeCameraTeleport: Observable<Vector3>;
  39534. /**
  39535. * Observable raised after camera teleportation
  39536. */
  39537. onAfterCameraTeleport: Observable<Vector3>;
  39538. /**
  39539. * Observable raised when current selected mesh gets unselected
  39540. */
  39541. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39542. private _raySelectionPredicate;
  39543. /**
  39544. * To be optionaly changed by user to define custom ray selection
  39545. */
  39546. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39547. /**
  39548. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39549. */
  39550. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39551. /**
  39552. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39553. */
  39554. teleportationEnabled: boolean;
  39555. private _defaultHeight;
  39556. private _teleportationInitialized;
  39557. private _interactionsEnabled;
  39558. private _interactionsRequested;
  39559. private _displayGaze;
  39560. private _displayLaserPointer;
  39561. /**
  39562. * The mesh used to display where the user is going to teleport.
  39563. */
  39564. /**
  39565. * Sets the mesh to be used to display where the user is going to teleport.
  39566. */
  39567. teleportationTarget: Mesh;
  39568. /**
  39569. * 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
  39570. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39571. * See http://doc.babylonjs.com/resources/baking_transformations
  39572. */
  39573. gazeTrackerMesh: Mesh;
  39574. /**
  39575. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39576. */
  39577. updateGazeTrackerScale: boolean;
  39578. /**
  39579. * If the gaze trackers color should be updated when selecting meshes
  39580. */
  39581. updateGazeTrackerColor: boolean;
  39582. /**
  39583. * The gaze tracking mesh corresponding to the left controller
  39584. */
  39585. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39586. /**
  39587. * The gaze tracking mesh corresponding to the right controller
  39588. */
  39589. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39590. /**
  39591. * If the ray of the gaze should be displayed.
  39592. */
  39593. /**
  39594. * Sets if the ray of the gaze should be displayed.
  39595. */
  39596. displayGaze: boolean;
  39597. /**
  39598. * If the ray of the LaserPointer should be displayed.
  39599. */
  39600. /**
  39601. * Sets if the ray of the LaserPointer should be displayed.
  39602. */
  39603. displayLaserPointer: boolean;
  39604. /**
  39605. * The deviceOrientationCamera used as the camera when not in VR.
  39606. */
  39607. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39608. /**
  39609. * Based on the current WebVR support, returns the current VR camera used.
  39610. */
  39611. readonly currentVRCamera: Nullable<Camera>;
  39612. /**
  39613. * The webVRCamera which is used when in VR.
  39614. */
  39615. readonly webVRCamera: WebVRFreeCamera;
  39616. /**
  39617. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39618. */
  39619. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39620. private readonly _teleportationRequestInitiated;
  39621. /**
  39622. * Defines wether or not Pointer lock should be requested when switching to
  39623. * full screen.
  39624. */
  39625. requestPointerLockOnFullScreen: boolean;
  39626. /**
  39627. * Instantiates a VRExperienceHelper.
  39628. * Helps to quickly add VR support to an existing scene.
  39629. * @param scene The scene the VRExperienceHelper belongs to.
  39630. * @param webVROptions Options to modify the vr experience helper's behavior.
  39631. */
  39632. constructor(scene: Scene,
  39633. /** Options to modify the vr experience helper's behavior. */
  39634. webVROptions?: VRExperienceHelperOptions);
  39635. private _onDefaultMeshLoaded;
  39636. private _onResize;
  39637. private _onFullscreenChange;
  39638. /**
  39639. * Gets a value indicating if we are currently in VR mode.
  39640. */
  39641. readonly isInVRMode: boolean;
  39642. private onVrDisplayPresentChange;
  39643. private onVRDisplayChanged;
  39644. private moveButtonToBottomRight;
  39645. private displayVRButton;
  39646. private updateButtonVisibility;
  39647. private _cachedAngularSensibility;
  39648. /**
  39649. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39650. * Otherwise, will use the fullscreen API.
  39651. */
  39652. enterVR(): void;
  39653. /**
  39654. * Attempt to exit VR, or fullscreen.
  39655. */
  39656. exitVR(): void;
  39657. /**
  39658. * The position of the vr experience helper.
  39659. */
  39660. /**
  39661. * Sets the position of the vr experience helper.
  39662. */
  39663. position: Vector3;
  39664. /**
  39665. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39666. */
  39667. enableInteractions(): void;
  39668. private readonly _noControllerIsActive;
  39669. private beforeRender;
  39670. private _isTeleportationFloor;
  39671. /**
  39672. * Adds a floor mesh to be used for teleportation.
  39673. * @param floorMesh the mesh to be used for teleportation.
  39674. */
  39675. addFloorMesh(floorMesh: Mesh): void;
  39676. /**
  39677. * Removes a floor mesh from being used for teleportation.
  39678. * @param floorMesh the mesh to be removed.
  39679. */
  39680. removeFloorMesh(floorMesh: Mesh): void;
  39681. /**
  39682. * Enables interactions and teleportation using the VR controllers and gaze.
  39683. * @param vrTeleportationOptions options to modify teleportation behavior.
  39684. */
  39685. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39686. private _onNewGamepadConnected;
  39687. private _tryEnableInteractionOnController;
  39688. private _onNewGamepadDisconnected;
  39689. private _enableInteractionOnController;
  39690. private _checkTeleportWithRay;
  39691. private _checkRotate;
  39692. private _checkTeleportBackwards;
  39693. private _enableTeleportationOnController;
  39694. private _createTeleportationCircles;
  39695. private _displayTeleportationTarget;
  39696. private _hideTeleportationTarget;
  39697. private _rotateCamera;
  39698. private _moveTeleportationSelectorTo;
  39699. private _workingVector;
  39700. private _workingQuaternion;
  39701. private _workingMatrix;
  39702. /**
  39703. * Teleports the users feet to the desired location
  39704. * @param location The location where the user's feet should be placed
  39705. */
  39706. teleportCamera(location: Vector3): void;
  39707. private _convertNormalToDirectionOfRay;
  39708. private _castRayAndSelectObject;
  39709. private _notifySelectedMeshUnselected;
  39710. /**
  39711. * Sets the color of the laser ray from the vr controllers.
  39712. * @param color new color for the ray.
  39713. */
  39714. changeLaserColor(color: Color3): void;
  39715. /**
  39716. * Sets the color of the ray from the vr headsets gaze.
  39717. * @param color new color for the ray.
  39718. */
  39719. changeGazeColor(color: Color3): void;
  39720. /**
  39721. * Exits VR and disposes of the vr experience helper
  39722. */
  39723. dispose(): void;
  39724. /**
  39725. * Gets the name of the VRExperienceHelper class
  39726. * @returns "VRExperienceHelper"
  39727. */
  39728. getClassName(): string;
  39729. }
  39730. }
  39731. declare module BABYLON {
  39732. /**
  39733. * Manages an XRSession
  39734. * @see https://doc.babylonjs.com/how_to/webxr
  39735. */
  39736. export class WebXRSessionManager implements IDisposable {
  39737. private scene;
  39738. /**
  39739. * Fires every time a new xrFrame arrives which can be used to update the camera
  39740. */
  39741. onXRFrameObservable: Observable<any>;
  39742. /**
  39743. * Fires when the xr session is ended either by the device or manually done
  39744. */
  39745. onXRSessionEnded: Observable<any>;
  39746. /** @hidden */
  39747. _xrSession: XRSession;
  39748. /** @hidden */
  39749. _frameOfReference: XRFrameOfReference;
  39750. /** @hidden */
  39751. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39752. /** @hidden */
  39753. _currentXRFrame: Nullable<XRFrame>;
  39754. private _xrNavigator;
  39755. private _xrDevice;
  39756. private _tmpMatrix;
  39757. /**
  39758. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39759. * @param scene The scene which the session should be created for
  39760. */
  39761. constructor(scene: Scene);
  39762. /**
  39763. * Initializes the manager
  39764. * After initialization enterXR can be called to start an XR session
  39765. * @returns Promise which resolves after it is initialized
  39766. */
  39767. initializeAsync(): Promise<void>;
  39768. /**
  39769. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39770. * @param sessionCreationOptions xr options to create the session with
  39771. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39772. * @returns Promise which resolves after it enters XR
  39773. */
  39774. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39775. /**
  39776. * Stops the xrSession and restores the renderloop
  39777. * @returns Promise which resolves after it exits XR
  39778. */
  39779. exitXRAsync(): Promise<void>;
  39780. /**
  39781. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39782. * @param ray ray to cast into the environment
  39783. * @returns Promise which resolves with a collision point in the environment if it exists
  39784. */
  39785. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39786. /**
  39787. * Checks if a session would be supported for the creation options specified
  39788. * @param options creation options to check if they are supported
  39789. * @returns true if supported
  39790. */
  39791. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39792. /**
  39793. * @hidden
  39794. * Converts the render layer of xrSession to a render target
  39795. * @param session session to create render target for
  39796. * @param scene scene the new render target should be created for
  39797. */
  39798. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39799. /**
  39800. * Disposes of the session manager
  39801. */
  39802. dispose(): void;
  39803. }
  39804. }
  39805. declare module BABYLON {
  39806. /**
  39807. * WebXR Camera which holds the views for the xrSession
  39808. * @see https://doc.babylonjs.com/how_to/webxr
  39809. */
  39810. export class WebXRCamera extends FreeCamera {
  39811. private static _TmpMatrix;
  39812. /**
  39813. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39814. * @param name the name of the camera
  39815. * @param scene the scene to add the camera to
  39816. */
  39817. constructor(name: string, scene: Scene);
  39818. private _updateNumberOfRigCameras;
  39819. /** @hidden */
  39820. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39821. /**
  39822. * Updates the cameras position from the current pose information of the XR session
  39823. * @param xrSessionManager the session containing pose information
  39824. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39825. */
  39826. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39827. }
  39828. }
  39829. declare module BABYLON {
  39830. /**
  39831. * States of the webXR experience
  39832. */
  39833. export enum WebXRState {
  39834. /**
  39835. * Transitioning to being in XR mode
  39836. */
  39837. ENTERING_XR = 0,
  39838. /**
  39839. * Transitioning to non XR mode
  39840. */
  39841. EXITING_XR = 1,
  39842. /**
  39843. * In XR mode and presenting
  39844. */
  39845. IN_XR = 2,
  39846. /**
  39847. * Not entered XR mode
  39848. */
  39849. NOT_IN_XR = 3
  39850. }
  39851. /**
  39852. * Helper class used to enable XR
  39853. * @see https://doc.babylonjs.com/how_to/webxr
  39854. */
  39855. export class WebXRExperienceHelper implements IDisposable {
  39856. private scene;
  39857. /**
  39858. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  39859. */
  39860. container: AbstractMesh;
  39861. /**
  39862. * Camera used to render xr content
  39863. */
  39864. camera: WebXRCamera;
  39865. /**
  39866. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39867. */
  39868. state: WebXRState;
  39869. private _setState;
  39870. private static _TmpVector;
  39871. /**
  39872. * Fires when the state of the experience helper has changed
  39873. */
  39874. onStateChangedObservable: Observable<WebXRState>;
  39875. /** @hidden */
  39876. _sessionManager: WebXRSessionManager;
  39877. private _nonVRCamera;
  39878. private _originalSceneAutoClear;
  39879. private _supported;
  39880. /**
  39881. * Creates the experience helper
  39882. * @param scene the scene to attach the experience helper to
  39883. * @returns a promise for the experience helper
  39884. */
  39885. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39886. /**
  39887. * Creates a WebXRExperienceHelper
  39888. * @param scene The scene the helper should be created in
  39889. */
  39890. private constructor();
  39891. /**
  39892. * Exits XR mode and returns the scene to its original state
  39893. * @returns promise that resolves after xr mode has exited
  39894. */
  39895. exitXRAsync(): Promise<void>;
  39896. /**
  39897. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39898. * @param sessionCreationOptions options for the XR session
  39899. * @param frameOfReference frame of reference of the XR session
  39900. * @returns promise that resolves after xr mode has entered
  39901. */
  39902. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39903. /**
  39904. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39905. * @param ray ray to cast into the environment
  39906. * @returns Promise which resolves with a collision point in the environment if it exists
  39907. */
  39908. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39909. /**
  39910. * Updates the global position of the camera by moving the camera's container
  39911. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39912. * @param position The desired global position of the camera
  39913. */
  39914. setPositionOfCameraUsingContainer(position: Vector3): void;
  39915. /**
  39916. * Rotates the xr camera by rotating the camera's container around the camera's position
  39917. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39918. * @param rotation the desired quaternion rotation to apply to the camera
  39919. */
  39920. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39921. /**
  39922. * Checks if the creation options are supported by the xr session
  39923. * @param options creation options
  39924. * @returns true if supported
  39925. */
  39926. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39927. /**
  39928. * Disposes of the experience helper
  39929. */
  39930. dispose(): void;
  39931. }
  39932. }
  39933. declare module BABYLON {
  39934. /**
  39935. * Button which can be used to enter a different mode of XR
  39936. */
  39937. export class WebXREnterExitUIButton {
  39938. /** button element */
  39939. element: HTMLElement;
  39940. /** XR initialization options for the button */
  39941. initializationOptions: XRSessionCreationOptions;
  39942. /**
  39943. * Creates a WebXREnterExitUIButton
  39944. * @param element button element
  39945. * @param initializationOptions XR initialization options for the button
  39946. */
  39947. constructor(
  39948. /** button element */
  39949. element: HTMLElement,
  39950. /** XR initialization options for the button */
  39951. initializationOptions: XRSessionCreationOptions);
  39952. /**
  39953. * Overwritable function which can be used to update the button's visuals when the state changes
  39954. * @param activeButton the current active button in the UI
  39955. */
  39956. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39957. }
  39958. /**
  39959. * Options to create the webXR UI
  39960. */
  39961. export class WebXREnterExitUIOptions {
  39962. /**
  39963. * Context to enter xr with
  39964. */
  39965. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39966. /**
  39967. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39968. */
  39969. customButtons?: Array<WebXREnterExitUIButton>;
  39970. }
  39971. /**
  39972. * UI to allow the user to enter/exit XR mode
  39973. */
  39974. export class WebXREnterExitUI implements IDisposable {
  39975. private scene;
  39976. private _overlay;
  39977. private _buttons;
  39978. private _activeButton;
  39979. /**
  39980. * Fired every time the active button is changed.
  39981. *
  39982. * When xr is entered via a button that launches xr that button will be the callback parameter
  39983. *
  39984. * When exiting xr the callback parameter will be null)
  39985. */
  39986. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39987. /**
  39988. * Creates UI to allow the user to enter/exit XR mode
  39989. * @param scene the scene to add the ui to
  39990. * @param helper the xr experience helper to enter/exit xr with
  39991. * @param options options to configure the UI
  39992. * @returns the created ui
  39993. */
  39994. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39995. private constructor();
  39996. private _updateButtons;
  39997. /**
  39998. * Disposes of the object
  39999. */
  40000. dispose(): void;
  40001. }
  40002. }
  40003. declare module BABYLON {
  40004. /**
  40005. * Represents an XR input
  40006. */
  40007. export class WebXRController {
  40008. /**
  40009. * 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
  40010. */
  40011. grip?: AbstractMesh;
  40012. /**
  40013. * Pointer which can be used to select objects or attach a visible laser to
  40014. */
  40015. pointer: AbstractMesh;
  40016. /**
  40017. * Creates the controller
  40018. * @see https://doc.babylonjs.com/how_to/webxr
  40019. * @param scene the scene which the controller should be associated to
  40020. */
  40021. constructor(scene: Scene);
  40022. /**
  40023. * Disposes of the object
  40024. */
  40025. dispose(): void;
  40026. }
  40027. /**
  40028. * XR input used to track XR inputs such as controllers/rays
  40029. */
  40030. export class WebXRInput implements IDisposable {
  40031. private helper;
  40032. /**
  40033. * XR controllers being tracked
  40034. */
  40035. controllers: Array<WebXRController>;
  40036. private _tmpMatrix;
  40037. private _frameObserver;
  40038. /**
  40039. * Initializes the WebXRInput
  40040. * @param helper experience helper which the input should be created for
  40041. */
  40042. constructor(helper: WebXRExperienceHelper);
  40043. /**
  40044. * Disposes of the object
  40045. */
  40046. dispose(): void;
  40047. }
  40048. }
  40049. declare module BABYLON {
  40050. /**
  40051. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40052. */
  40053. export class WebXRManagedOutputCanvas implements IDisposable {
  40054. private _canvas;
  40055. /**
  40056. * xrpresent context of the canvas which can be used to display/mirror xr content
  40057. */
  40058. canvasContext: Nullable<WebGLRenderingContext>;
  40059. /**
  40060. * Initializes the canvas to be added/removed upon entering/exiting xr
  40061. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40062. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40063. */
  40064. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40065. /**
  40066. * Disposes of the object
  40067. */
  40068. dispose(): void;
  40069. private _setManagedOutputCanvas;
  40070. private _addCanvas;
  40071. private _removeCanvas;
  40072. }
  40073. }
  40074. declare module BABYLON {
  40075. /**
  40076. * Contains an array of blocks representing the octree
  40077. */
  40078. export interface IOctreeContainer<T> {
  40079. /**
  40080. * Blocks within the octree
  40081. */
  40082. blocks: Array<OctreeBlock<T>>;
  40083. }
  40084. /**
  40085. * Class used to store a cell in an octree
  40086. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40087. */
  40088. export class OctreeBlock<T> {
  40089. /**
  40090. * Gets the content of the current block
  40091. */
  40092. entries: T[];
  40093. /**
  40094. * Gets the list of block children
  40095. */
  40096. blocks: Array<OctreeBlock<T>>;
  40097. private _depth;
  40098. private _maxDepth;
  40099. private _capacity;
  40100. private _minPoint;
  40101. private _maxPoint;
  40102. private _boundingVectors;
  40103. private _creationFunc;
  40104. /**
  40105. * Creates a new block
  40106. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40107. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40108. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40109. * @param depth defines the current depth of this block in the octree
  40110. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40111. * @param creationFunc defines a callback to call when an element is added to the block
  40112. */
  40113. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40114. /**
  40115. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40116. */
  40117. readonly capacity: number;
  40118. /**
  40119. * Gets the minimum vector (in world space) of the block's bounding box
  40120. */
  40121. readonly minPoint: Vector3;
  40122. /**
  40123. * Gets the maximum vector (in world space) of the block's bounding box
  40124. */
  40125. readonly maxPoint: Vector3;
  40126. /**
  40127. * Add a new element to this block
  40128. * @param entry defines the element to add
  40129. */
  40130. addEntry(entry: T): void;
  40131. /**
  40132. * Remove an element from this block
  40133. * @param entry defines the element to remove
  40134. */
  40135. removeEntry(entry: T): void;
  40136. /**
  40137. * Add an array of elements to this block
  40138. * @param entries defines the array of elements to add
  40139. */
  40140. addEntries(entries: T[]): void;
  40141. /**
  40142. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40143. * @param frustumPlanes defines the frustum planes to test
  40144. * @param selection defines the array to store current content if selection is positive
  40145. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40146. */
  40147. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40148. /**
  40149. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40150. * @param sphereCenter defines the bounding sphere center
  40151. * @param sphereRadius defines the bounding sphere radius
  40152. * @param selection defines the array to store current content if selection is positive
  40153. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40154. */
  40155. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40156. /**
  40157. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40158. * @param ray defines the ray to test with
  40159. * @param selection defines the array to store current content if selection is positive
  40160. */
  40161. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40162. /**
  40163. * Subdivide the content into child blocks (this block will then be empty)
  40164. */
  40165. createInnerBlocks(): void;
  40166. /**
  40167. * @hidden
  40168. */
  40169. 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;
  40170. }
  40171. }
  40172. declare module BABYLON {
  40173. /**
  40174. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40175. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40176. */
  40177. export class Octree<T> {
  40178. /** 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.) */
  40179. maxDepth: number;
  40180. /**
  40181. * Blocks within the octree containing objects
  40182. */
  40183. blocks: Array<OctreeBlock<T>>;
  40184. /**
  40185. * Content stored in the octree
  40186. */
  40187. dynamicContent: T[];
  40188. private _maxBlockCapacity;
  40189. private _selectionContent;
  40190. private _creationFunc;
  40191. /**
  40192. * Creates a octree
  40193. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40194. * @param creationFunc function to be used to instatiate the octree
  40195. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40196. * @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.)
  40197. */
  40198. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40199. /** 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.) */
  40200. maxDepth?: number);
  40201. /**
  40202. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40203. * @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);
  40204. * @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);
  40205. * @param entries meshes to be added to the octree blocks
  40206. */
  40207. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40208. /**
  40209. * Adds a mesh to the octree
  40210. * @param entry Mesh to add to the octree
  40211. */
  40212. addMesh(entry: T): void;
  40213. /**
  40214. * Remove an element from the octree
  40215. * @param entry defines the element to remove
  40216. */
  40217. removeMesh(entry: T): void;
  40218. /**
  40219. * Selects an array of meshes within the frustum
  40220. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40221. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40222. * @returns array of meshes within the frustum
  40223. */
  40224. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40225. /**
  40226. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40227. * @param sphereCenter defines the bounding sphere center
  40228. * @param sphereRadius defines the bounding sphere radius
  40229. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40230. * @returns an array of objects that intersect the sphere
  40231. */
  40232. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40233. /**
  40234. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40235. * @param ray defines the ray to test with
  40236. * @returns array of intersected objects
  40237. */
  40238. intersectsRay(ray: Ray): SmartArray<T>;
  40239. /**
  40240. * Adds a mesh into the octree block if it intersects the block
  40241. */
  40242. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40243. /**
  40244. * Adds a submesh into the octree block if it intersects the block
  40245. */
  40246. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40247. }
  40248. }
  40249. declare module BABYLON {
  40250. interface Scene {
  40251. /**
  40252. * @hidden
  40253. * Backing Filed
  40254. */
  40255. _selectionOctree: Octree<AbstractMesh>;
  40256. /**
  40257. * Gets the octree used to boost mesh selection (picking)
  40258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40259. */
  40260. selectionOctree: Octree<AbstractMesh>;
  40261. /**
  40262. * Creates or updates the octree used to boost selection (picking)
  40263. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40264. * @param maxCapacity defines the maximum capacity per leaf
  40265. * @param maxDepth defines the maximum depth of the octree
  40266. * @returns an octree of AbstractMesh
  40267. */
  40268. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40269. }
  40270. interface AbstractMesh {
  40271. /**
  40272. * @hidden
  40273. * Backing Field
  40274. */
  40275. _submeshesOctree: Octree<SubMesh>;
  40276. /**
  40277. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40278. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40279. * @param maxCapacity defines the maximum size of each block (64 by default)
  40280. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40281. * @returns the new octree
  40282. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40283. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40284. */
  40285. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40286. }
  40287. /**
  40288. * Defines the octree scene component responsible to manage any octrees
  40289. * in a given scene.
  40290. */
  40291. export class OctreeSceneComponent {
  40292. /**
  40293. * The component name helpfull to identify the component in the list of scene components.
  40294. */
  40295. readonly name: string;
  40296. /**
  40297. * The scene the component belongs to.
  40298. */
  40299. scene: Scene;
  40300. /**
  40301. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40302. */
  40303. readonly checksIsEnabled: boolean;
  40304. /**
  40305. * Creates a new instance of the component for the given scene
  40306. * @param scene Defines the scene to register the component in
  40307. */
  40308. constructor(scene: Scene);
  40309. /**
  40310. * Registers the component in a given scene
  40311. */
  40312. register(): void;
  40313. /**
  40314. * Return the list of active meshes
  40315. * @returns the list of active meshes
  40316. */
  40317. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40318. /**
  40319. * Return the list of active sub meshes
  40320. * @param mesh The mesh to get the candidates sub meshes from
  40321. * @returns the list of active sub meshes
  40322. */
  40323. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40324. private _tempRay;
  40325. /**
  40326. * Return the list of sub meshes intersecting with a given local ray
  40327. * @param mesh defines the mesh to find the submesh for
  40328. * @param localRay defines the ray in local space
  40329. * @returns the list of intersecting sub meshes
  40330. */
  40331. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40332. /**
  40333. * Return the list of sub meshes colliding with a collider
  40334. * @param mesh defines the mesh to find the submesh for
  40335. * @param collider defines the collider to evaluate the collision against
  40336. * @returns the list of colliding sub meshes
  40337. */
  40338. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40339. /**
  40340. * Rebuilds the elements related to this component in case of
  40341. * context lost for instance.
  40342. */
  40343. rebuild(): void;
  40344. /**
  40345. * Disposes the component and the associated ressources.
  40346. */
  40347. dispose(): void;
  40348. }
  40349. }
  40350. declare module BABYLON {
  40351. /**
  40352. * Renders a layer on top of an existing scene
  40353. */
  40354. export class UtilityLayerRenderer implements IDisposable {
  40355. /** the original scene that will be rendered on top of */
  40356. originalScene: Scene;
  40357. private _pointerCaptures;
  40358. private _lastPointerEvents;
  40359. private static _DefaultUtilityLayer;
  40360. private static _DefaultKeepDepthUtilityLayer;
  40361. private _sharedGizmoLight;
  40362. /**
  40363. * @hidden
  40364. * Light which used by gizmos to get light shading
  40365. */
  40366. _getSharedGizmoLight(): HemisphericLight;
  40367. /**
  40368. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40369. */
  40370. pickUtilitySceneFirst: boolean;
  40371. /**
  40372. * 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)
  40373. */
  40374. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40375. /**
  40376. * 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)
  40377. */
  40378. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40379. /**
  40380. * The scene that is rendered on top of the original scene
  40381. */
  40382. utilityLayerScene: Scene;
  40383. /**
  40384. * If the utility layer should automatically be rendered on top of existing scene
  40385. */
  40386. shouldRender: boolean;
  40387. /**
  40388. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40389. */
  40390. onlyCheckPointerDownEvents: boolean;
  40391. /**
  40392. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40393. */
  40394. processAllEvents: boolean;
  40395. /**
  40396. * Observable raised when the pointer move from the utility layer scene to the main scene
  40397. */
  40398. onPointerOutObservable: Observable<number>;
  40399. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40400. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40401. private _afterRenderObserver;
  40402. private _sceneDisposeObserver;
  40403. private _originalPointerObserver;
  40404. /**
  40405. * Instantiates a UtilityLayerRenderer
  40406. * @param originalScene the original scene that will be rendered on top of
  40407. * @param handleEvents boolean indicating if the utility layer should handle events
  40408. */
  40409. constructor(
  40410. /** the original scene that will be rendered on top of */
  40411. originalScene: Scene, handleEvents?: boolean);
  40412. private _notifyObservers;
  40413. /**
  40414. * Renders the utility layers scene on top of the original scene
  40415. */
  40416. render(): void;
  40417. /**
  40418. * Disposes of the renderer
  40419. */
  40420. dispose(): void;
  40421. private _updateCamera;
  40422. }
  40423. }
  40424. declare module BABYLON {
  40425. /**
  40426. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40427. */
  40428. export class Gizmo implements IDisposable {
  40429. /** The utility layer the gizmo will be added to */
  40430. gizmoLayer: UtilityLayerRenderer;
  40431. /**
  40432. * The root mesh of the gizmo
  40433. */
  40434. _rootMesh: Mesh;
  40435. private _attachedMesh;
  40436. /**
  40437. * Ratio for the scale of the gizmo (Default: 1)
  40438. */
  40439. scaleRatio: number;
  40440. private _tmpMatrix;
  40441. /**
  40442. * If a custom mesh has been set (Default: false)
  40443. */
  40444. protected _customMeshSet: boolean;
  40445. /**
  40446. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40447. * * When set, interactions will be enabled
  40448. */
  40449. attachedMesh: Nullable<AbstractMesh>;
  40450. /**
  40451. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40452. * @param mesh The mesh to replace the default mesh of the gizmo
  40453. */
  40454. setCustomMesh(mesh: Mesh): void;
  40455. /**
  40456. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40457. */
  40458. updateGizmoRotationToMatchAttachedMesh: boolean;
  40459. /**
  40460. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40461. */
  40462. updateGizmoPositionToMatchAttachedMesh: boolean;
  40463. /**
  40464. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40465. */
  40466. protected _updateScale: boolean;
  40467. protected _interactionsEnabled: boolean;
  40468. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40469. private _beforeRenderObserver;
  40470. /**
  40471. * Creates a gizmo
  40472. * @param gizmoLayer The utility layer the gizmo will be added to
  40473. */
  40474. constructor(
  40475. /** The utility layer the gizmo will be added to */
  40476. gizmoLayer?: UtilityLayerRenderer);
  40477. private _tempVector;
  40478. /**
  40479. * @hidden
  40480. * Updates the gizmo to match the attached mesh's position/rotation
  40481. */
  40482. protected _update(): void;
  40483. /**
  40484. * Disposes of the gizmo
  40485. */
  40486. dispose(): void;
  40487. }
  40488. }
  40489. declare module BABYLON {
  40490. /**
  40491. * Single axis drag gizmo
  40492. */
  40493. export class AxisDragGizmo extends Gizmo {
  40494. /**
  40495. * Drag behavior responsible for the gizmos dragging interactions
  40496. */
  40497. dragBehavior: PointerDragBehavior;
  40498. private _pointerObserver;
  40499. /**
  40500. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40501. */
  40502. snapDistance: number;
  40503. /**
  40504. * Event that fires each time the gizmo snaps to a new location.
  40505. * * snapDistance is the the change in distance
  40506. */
  40507. onSnapObservable: Observable<{
  40508. snapDistance: number;
  40509. }>;
  40510. /** @hidden */
  40511. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40512. /** @hidden */
  40513. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40514. /**
  40515. * Creates an AxisDragGizmo
  40516. * @param gizmoLayer The utility layer the gizmo will be added to
  40517. * @param dragAxis The axis which the gizmo will be able to drag on
  40518. * @param color The color of the gizmo
  40519. */
  40520. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40521. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40522. /**
  40523. * Disposes of the gizmo
  40524. */
  40525. dispose(): void;
  40526. }
  40527. }
  40528. declare module BABYLON.Debug {
  40529. /**
  40530. * The Axes viewer will show 3 axes in a specific point in space
  40531. */
  40532. export class AxesViewer {
  40533. private _xAxis;
  40534. private _yAxis;
  40535. private _zAxis;
  40536. private _scaleLinesFactor;
  40537. private _instanced;
  40538. /**
  40539. * Gets the hosting scene
  40540. */
  40541. scene: Scene;
  40542. /**
  40543. * Gets or sets a number used to scale line length
  40544. */
  40545. scaleLines: number;
  40546. /** Gets the node hierarchy used to render x-axis */
  40547. readonly xAxis: TransformNode;
  40548. /** Gets the node hierarchy used to render y-axis */
  40549. readonly yAxis: TransformNode;
  40550. /** Gets the node hierarchy used to render z-axis */
  40551. readonly zAxis: TransformNode;
  40552. /**
  40553. * Creates a new AxesViewer
  40554. * @param scene defines the hosting scene
  40555. * @param scaleLines defines a number used to scale line length (1 by default)
  40556. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40557. * @param xAxis defines the node hierarchy used to render the x-axis
  40558. * @param yAxis defines the node hierarchy used to render the y-axis
  40559. * @param zAxis defines the node hierarchy used to render the z-axis
  40560. */
  40561. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40562. /**
  40563. * Force the viewer to update
  40564. * @param position defines the position of the viewer
  40565. * @param xaxis defines the x axis of the viewer
  40566. * @param yaxis defines the y axis of the viewer
  40567. * @param zaxis defines the z axis of the viewer
  40568. */
  40569. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40570. /**
  40571. * Creates an instance of this axes viewer.
  40572. * @returns a new axes viewer with instanced meshes
  40573. */
  40574. createInstance(): AxesViewer;
  40575. /** Releases resources */
  40576. dispose(): void;
  40577. private static _SetRenderingGroupId;
  40578. }
  40579. }
  40580. declare module BABYLON.Debug {
  40581. /**
  40582. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40583. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40584. */
  40585. export class BoneAxesViewer extends AxesViewer {
  40586. /**
  40587. * Gets or sets the target mesh where to display the axes viewer
  40588. */
  40589. mesh: Nullable<Mesh>;
  40590. /**
  40591. * Gets or sets the target bone where to display the axes viewer
  40592. */
  40593. bone: Nullable<Bone>;
  40594. /** Gets current position */
  40595. pos: Vector3;
  40596. /** Gets direction of X axis */
  40597. xaxis: Vector3;
  40598. /** Gets direction of Y axis */
  40599. yaxis: Vector3;
  40600. /** Gets direction of Z axis */
  40601. zaxis: Vector3;
  40602. /**
  40603. * Creates a new BoneAxesViewer
  40604. * @param scene defines the hosting scene
  40605. * @param bone defines the target bone
  40606. * @param mesh defines the target mesh
  40607. * @param scaleLines defines a scaling factor for line length (1 by default)
  40608. */
  40609. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40610. /**
  40611. * Force the viewer to update
  40612. */
  40613. update(): void;
  40614. /** Releases resources */
  40615. dispose(): void;
  40616. }
  40617. }
  40618. declare module BABYLON {
  40619. /**
  40620. * Interface used to define scene explorer extensibility option
  40621. */
  40622. export interface IExplorerExtensibilityOption {
  40623. /**
  40624. * Define the option label
  40625. */
  40626. label: string;
  40627. /**
  40628. * Defines the action to execute on click
  40629. */
  40630. action: (entity: any) => void;
  40631. }
  40632. /**
  40633. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40634. */
  40635. export interface IExplorerExtensibilityGroup {
  40636. /**
  40637. * Defines a predicate to test if a given type mut be extended
  40638. */
  40639. predicate: (entity: any) => boolean;
  40640. /**
  40641. * Gets the list of options added to a type
  40642. */
  40643. entries: IExplorerExtensibilityOption[];
  40644. }
  40645. /**
  40646. * Interface used to define the options to use to create the Inspector
  40647. */
  40648. export interface IInspectorOptions {
  40649. /**
  40650. * Display in overlay mode (default: false)
  40651. */
  40652. overlay?: boolean;
  40653. /**
  40654. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40655. */
  40656. globalRoot?: HTMLElement;
  40657. /**
  40658. * Display the Scene explorer
  40659. */
  40660. showExplorer?: boolean;
  40661. /**
  40662. * Display the property inspector
  40663. */
  40664. showInspector?: boolean;
  40665. /**
  40666. * Display in embed mode (both panes on the right)
  40667. */
  40668. embedMode?: boolean;
  40669. /**
  40670. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40671. */
  40672. handleResize?: boolean;
  40673. /**
  40674. * Allow the panes to popup (default: true)
  40675. */
  40676. enablePopup?: boolean;
  40677. /**
  40678. * Allow the panes to be closed by users (default: true)
  40679. */
  40680. enableClose?: boolean;
  40681. /**
  40682. * Optional list of extensibility entries
  40683. */
  40684. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40685. /**
  40686. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40687. */
  40688. inspectorURL?: string;
  40689. }
  40690. interface Scene {
  40691. /**
  40692. * @hidden
  40693. * Backing field
  40694. */
  40695. _debugLayer: DebugLayer;
  40696. /**
  40697. * Gets the debug layer (aka Inspector) associated with the scene
  40698. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40699. */
  40700. debugLayer: DebugLayer;
  40701. }
  40702. /**
  40703. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40704. * what is happening in your scene
  40705. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40706. */
  40707. export class DebugLayer {
  40708. /**
  40709. * Define the url to get the inspector script from.
  40710. * By default it uses the babylonjs CDN.
  40711. * @ignoreNaming
  40712. */
  40713. static InspectorURL: string;
  40714. private _scene;
  40715. private BJSINSPECTOR;
  40716. /**
  40717. * Observable triggered when a property is changed through the inspector.
  40718. */
  40719. onPropertyChangedObservable: Observable<{
  40720. object: any;
  40721. property: string;
  40722. value: any;
  40723. initialValue: any;
  40724. }>;
  40725. /**
  40726. * Instantiates a new debug layer.
  40727. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40728. * what is happening in your scene
  40729. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40730. * @param scene Defines the scene to inspect
  40731. */
  40732. constructor(scene: Scene);
  40733. /** Creates the inspector window. */
  40734. private _createInspector;
  40735. /**
  40736. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40737. * @param entity defines the entity to select
  40738. * @param lineContainerTitle defines the specific block to highlight
  40739. */
  40740. select(entity: any, lineContainerTitle?: string): void;
  40741. /** Get the inspector from bundle or global */
  40742. private _getGlobalInspector;
  40743. /**
  40744. * Get if the inspector is visible or not.
  40745. * @returns true if visible otherwise, false
  40746. */
  40747. isVisible(): boolean;
  40748. /**
  40749. * Hide the inspector and close its window.
  40750. */
  40751. hide(): void;
  40752. /**
  40753. * Launch the debugLayer.
  40754. * @param config Define the configuration of the inspector
  40755. * @return a promise fulfilled when the debug layer is visible
  40756. */
  40757. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40758. }
  40759. }
  40760. declare module BABYLON {
  40761. /**
  40762. * Class containing static functions to help procedurally build meshes
  40763. */
  40764. export class BoxBuilder {
  40765. /**
  40766. * Creates a box mesh
  40767. * * The parameter `size` sets the size (float) of each box side (default 1)
  40768. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40769. * * 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)
  40770. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40772. * * 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
  40773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40774. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40775. * @param name defines the name of the mesh
  40776. * @param options defines the options used to create the mesh
  40777. * @param scene defines the hosting scene
  40778. * @returns the box mesh
  40779. */
  40780. static CreateBox(name: string, options: {
  40781. size?: number;
  40782. width?: number;
  40783. height?: number;
  40784. depth?: number;
  40785. faceUV?: Vector4[];
  40786. faceColors?: Color4[];
  40787. sideOrientation?: number;
  40788. frontUVs?: Vector4;
  40789. backUVs?: Vector4;
  40790. updatable?: boolean;
  40791. }, scene?: Nullable<Scene>): Mesh;
  40792. }
  40793. }
  40794. declare module BABYLON {
  40795. /**
  40796. * Class containing static functions to help procedurally build meshes
  40797. */
  40798. export class SphereBuilder {
  40799. /**
  40800. * Creates a sphere mesh
  40801. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40802. * * 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`)
  40803. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40804. * * 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
  40805. * * 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)
  40806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40807. * * 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
  40808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40809. * @param name defines the name of the mesh
  40810. * @param options defines the options used to create the mesh
  40811. * @param scene defines the hosting scene
  40812. * @returns the sphere mesh
  40813. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40814. */
  40815. static CreateSphere(name: string, options: {
  40816. segments?: number;
  40817. diameter?: number;
  40818. diameterX?: number;
  40819. diameterY?: number;
  40820. diameterZ?: number;
  40821. arc?: number;
  40822. slice?: number;
  40823. sideOrientation?: number;
  40824. frontUVs?: Vector4;
  40825. backUVs?: Vector4;
  40826. updatable?: boolean;
  40827. }, scene: any): Mesh;
  40828. }
  40829. }
  40830. declare module BABYLON.Debug {
  40831. /**
  40832. * Used to show the physics impostor around the specific mesh
  40833. */
  40834. export class PhysicsViewer {
  40835. /** @hidden */
  40836. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40837. /** @hidden */
  40838. protected _meshes: Array<Nullable<AbstractMesh>>;
  40839. /** @hidden */
  40840. protected _scene: Nullable<Scene>;
  40841. /** @hidden */
  40842. protected _numMeshes: number;
  40843. /** @hidden */
  40844. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40845. private _renderFunction;
  40846. private _utilityLayer;
  40847. private _debugBoxMesh;
  40848. private _debugSphereMesh;
  40849. private _debugMaterial;
  40850. private _debugMeshMeshes;
  40851. /**
  40852. * Creates a new PhysicsViewer
  40853. * @param scene defines the hosting scene
  40854. */
  40855. constructor(scene: Scene);
  40856. /** @hidden */
  40857. protected _updateDebugMeshes(): void;
  40858. /**
  40859. * Renders a specified physic impostor
  40860. * @param impostor defines the impostor to render
  40861. * @param targetMesh defines the mesh represented by the impostor
  40862. * @returns the new debug mesh used to render the impostor
  40863. */
  40864. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40865. /**
  40866. * Hides a specified physic impostor
  40867. * @param impostor defines the impostor to hide
  40868. */
  40869. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40870. private _getDebugMaterial;
  40871. private _getDebugBoxMesh;
  40872. private _getDebugSphereMesh;
  40873. private _getDebugMeshMesh;
  40874. private _getDebugMesh;
  40875. /** Releases all resources */
  40876. dispose(): void;
  40877. }
  40878. }
  40879. declare module BABYLON {
  40880. /**
  40881. * Class containing static functions to help procedurally build meshes
  40882. */
  40883. export class LinesBuilder {
  40884. /**
  40885. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40886. * * 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
  40887. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40888. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40889. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40890. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40891. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40892. * * 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
  40893. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40895. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40896. * @param name defines the name of the new line system
  40897. * @param options defines the options used to create the line system
  40898. * @param scene defines the hosting scene
  40899. * @returns a new line system mesh
  40900. */
  40901. static CreateLineSystem(name: string, options: {
  40902. lines: Vector3[][];
  40903. updatable?: boolean;
  40904. instance?: Nullable<LinesMesh>;
  40905. colors?: Nullable<Color4[][]>;
  40906. useVertexAlpha?: boolean;
  40907. }, scene: Nullable<Scene>): LinesMesh;
  40908. /**
  40909. * Creates a line mesh
  40910. * 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
  40911. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40912. * * The parameter `points` is an array successive Vector3
  40913. * * 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
  40914. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40915. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40916. * * When updating an instance, remember that only point positions can change, not the number of points
  40917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40919. * @param name defines the name of the new line system
  40920. * @param options defines the options used to create the line system
  40921. * @param scene defines the hosting scene
  40922. * @returns a new line mesh
  40923. */
  40924. static CreateLines(name: string, options: {
  40925. points: Vector3[];
  40926. updatable?: boolean;
  40927. instance?: Nullable<LinesMesh>;
  40928. colors?: Color4[];
  40929. useVertexAlpha?: boolean;
  40930. }, scene?: Nullable<Scene>): LinesMesh;
  40931. /**
  40932. * Creates a dashed line mesh
  40933. * * 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
  40934. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40935. * * The parameter `points` is an array successive Vector3
  40936. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40937. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40938. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40939. * * 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
  40940. * * When updating an instance, remember that only point positions can change, not the number of points
  40941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40942. * @param name defines the name of the mesh
  40943. * @param options defines the options used to create the mesh
  40944. * @param scene defines the hosting scene
  40945. * @returns the dashed line mesh
  40946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40947. */
  40948. static CreateDashedLines(name: string, options: {
  40949. points: Vector3[];
  40950. dashSize?: number;
  40951. gapSize?: number;
  40952. dashNb?: number;
  40953. updatable?: boolean;
  40954. instance?: LinesMesh;
  40955. }, scene?: Nullable<Scene>): LinesMesh;
  40956. }
  40957. }
  40958. declare module BABYLON {
  40959. /**
  40960. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40961. * in order to better appreciate the issue one might have.
  40962. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40963. */
  40964. export class RayHelper {
  40965. /**
  40966. * Defines the ray we are currently tryin to visualize.
  40967. */
  40968. ray: Nullable<Ray>;
  40969. private _renderPoints;
  40970. private _renderLine;
  40971. private _renderFunction;
  40972. private _scene;
  40973. private _updateToMeshFunction;
  40974. private _attachedToMesh;
  40975. private _meshSpaceDirection;
  40976. private _meshSpaceOrigin;
  40977. /**
  40978. * Helper function to create a colored helper in a scene in one line.
  40979. * @param ray Defines the ray we are currently tryin to visualize
  40980. * @param scene Defines the scene the ray is used in
  40981. * @param color Defines the color we want to see the ray in
  40982. * @returns The newly created ray helper.
  40983. */
  40984. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40985. /**
  40986. * Instantiate a new ray helper.
  40987. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40988. * in order to better appreciate the issue one might have.
  40989. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40990. * @param ray Defines the ray we are currently tryin to visualize
  40991. */
  40992. constructor(ray: Ray);
  40993. /**
  40994. * Shows the ray we are willing to debug.
  40995. * @param scene Defines the scene the ray needs to be rendered in
  40996. * @param color Defines the color the ray needs to be rendered in
  40997. */
  40998. show(scene: Scene, color?: Color3): void;
  40999. /**
  41000. * Hides the ray we are debugging.
  41001. */
  41002. hide(): void;
  41003. private _render;
  41004. /**
  41005. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41006. * @param mesh Defines the mesh we want the helper attached to
  41007. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41008. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41009. * @param length Defines the length of the ray
  41010. */
  41011. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41012. /**
  41013. * Detach the ray helper from the mesh it has previously been attached to.
  41014. */
  41015. detachFromMesh(): void;
  41016. private _updateToMesh;
  41017. /**
  41018. * Dispose the helper and release its associated resources.
  41019. */
  41020. dispose(): void;
  41021. }
  41022. }
  41023. declare module BABYLON.Debug {
  41024. /**
  41025. * Class used to render a debug view of a given skeleton
  41026. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41027. */
  41028. export class SkeletonViewer {
  41029. /** defines the skeleton to render */
  41030. skeleton: Skeleton;
  41031. /** defines the mesh attached to the skeleton */
  41032. mesh: AbstractMesh;
  41033. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41034. autoUpdateBonesMatrices: boolean;
  41035. /** defines the rendering group id to use with the viewer */
  41036. renderingGroupId: number;
  41037. /** Gets or sets the color used to render the skeleton */
  41038. color: Color3;
  41039. private _scene;
  41040. private _debugLines;
  41041. private _debugMesh;
  41042. private _isEnabled;
  41043. private _renderFunction;
  41044. private _utilityLayer;
  41045. /**
  41046. * Returns the mesh used to render the bones
  41047. */
  41048. readonly debugMesh: Nullable<LinesMesh>;
  41049. /**
  41050. * Creates a new SkeletonViewer
  41051. * @param skeleton defines the skeleton to render
  41052. * @param mesh defines the mesh attached to the skeleton
  41053. * @param scene defines the hosting scene
  41054. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41055. * @param renderingGroupId defines the rendering group id to use with the viewer
  41056. */
  41057. constructor(
  41058. /** defines the skeleton to render */
  41059. skeleton: Skeleton,
  41060. /** defines the mesh attached to the skeleton */
  41061. mesh: AbstractMesh, scene: Scene,
  41062. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41063. autoUpdateBonesMatrices?: boolean,
  41064. /** defines the rendering group id to use with the viewer */
  41065. renderingGroupId?: number);
  41066. /** Gets or sets a boolean indicating if the viewer is enabled */
  41067. isEnabled: boolean;
  41068. private _getBonePosition;
  41069. private _getLinesForBonesWithLength;
  41070. private _getLinesForBonesNoLength;
  41071. /** Update the viewer to sync with current skeleton state */
  41072. update(): void;
  41073. /** Release associated resources */
  41074. dispose(): void;
  41075. }
  41076. }
  41077. declare module BABYLON {
  41078. /**
  41079. * Options to create the null engine
  41080. */
  41081. export class NullEngineOptions {
  41082. /**
  41083. * Render width (Default: 512)
  41084. */
  41085. renderWidth: number;
  41086. /**
  41087. * Render height (Default: 256)
  41088. */
  41089. renderHeight: number;
  41090. /**
  41091. * Texture size (Default: 512)
  41092. */
  41093. textureSize: number;
  41094. /**
  41095. * If delta time between frames should be constant
  41096. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41097. */
  41098. deterministicLockstep: boolean;
  41099. /**
  41100. * Maximum about of steps between frames (Default: 4)
  41101. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41102. */
  41103. lockstepMaxSteps: number;
  41104. }
  41105. /**
  41106. * The null engine class provides support for headless version of babylon.js.
  41107. * This can be used in server side scenario or for testing purposes
  41108. */
  41109. export class NullEngine extends Engine {
  41110. private _options;
  41111. /**
  41112. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41113. */
  41114. isDeterministicLockStep(): boolean;
  41115. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41116. getLockstepMaxSteps(): number;
  41117. /**
  41118. * Sets hardware scaling, used to save performance if needed
  41119. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41120. */
  41121. getHardwareScalingLevel(): number;
  41122. constructor(options?: NullEngineOptions);
  41123. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41124. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41125. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41126. getRenderWidth(useScreen?: boolean): number;
  41127. getRenderHeight(useScreen?: boolean): number;
  41128. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41129. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41130. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41131. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41132. bindSamplers(effect: Effect): void;
  41133. enableEffect(effect: Effect): void;
  41134. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41135. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41136. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41137. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41138. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41139. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41140. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41141. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41142. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41143. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41144. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41145. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41146. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41147. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41148. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41149. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41150. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41151. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41152. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41153. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41154. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41155. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41156. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41157. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41158. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41159. bindBuffers(vertexBuffers: {
  41160. [key: string]: VertexBuffer;
  41161. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41162. wipeCaches(bruteForce?: boolean): void;
  41163. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41164. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41165. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41166. /** @hidden */
  41167. _createTexture(): WebGLTexture;
  41168. /** @hidden */
  41169. _releaseTexture(texture: InternalTexture): void;
  41170. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  41171. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41172. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41173. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41174. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41175. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41176. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41177. areAllEffectsReady(): boolean;
  41178. /**
  41179. * @hidden
  41180. * Get the current error code of the webGL context
  41181. * @returns the error code
  41182. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41183. */
  41184. getError(): number;
  41185. /** @hidden */
  41186. _getUnpackAlignement(): number;
  41187. /** @hidden */
  41188. _unpackFlipY(value: boolean): void;
  41189. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41190. /**
  41191. * Updates a dynamic vertex buffer.
  41192. * @param vertexBuffer the vertex buffer to update
  41193. * @param data the data used to update the vertex buffer
  41194. * @param byteOffset the byte offset of the data (optional)
  41195. * @param byteLength the byte length of the data (optional)
  41196. */
  41197. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41198. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41199. /** @hidden */
  41200. _bindTexture(channel: number, texture: InternalTexture): void;
  41201. /** @hidden */
  41202. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41203. releaseEffects(): void;
  41204. displayLoadingUI(): void;
  41205. hideLoadingUI(): void;
  41206. /** @hidden */
  41207. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41208. /** @hidden */
  41209. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41210. /** @hidden */
  41211. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41212. /** @hidden */
  41213. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41214. }
  41215. }
  41216. declare module BABYLON {
  41217. /** @hidden */
  41218. export class _OcclusionDataStorage {
  41219. /** @hidden */
  41220. occlusionInternalRetryCounter: number;
  41221. /** @hidden */
  41222. isOcclusionQueryInProgress: boolean;
  41223. /** @hidden */
  41224. isOccluded: boolean;
  41225. /** @hidden */
  41226. occlusionRetryCount: number;
  41227. /** @hidden */
  41228. occlusionType: number;
  41229. /** @hidden */
  41230. occlusionQueryAlgorithmType: number;
  41231. }
  41232. interface Engine {
  41233. /**
  41234. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41235. * @return the new query
  41236. */
  41237. createQuery(): WebGLQuery;
  41238. /**
  41239. * Delete and release a webGL query
  41240. * @param query defines the query to delete
  41241. * @return the current engine
  41242. */
  41243. deleteQuery(query: WebGLQuery): Engine;
  41244. /**
  41245. * Check if a given query has resolved and got its value
  41246. * @param query defines the query to check
  41247. * @returns true if the query got its value
  41248. */
  41249. isQueryResultAvailable(query: WebGLQuery): boolean;
  41250. /**
  41251. * Gets the value of a given query
  41252. * @param query defines the query to check
  41253. * @returns the value of the query
  41254. */
  41255. getQueryResult(query: WebGLQuery): number;
  41256. /**
  41257. * Initiates an occlusion query
  41258. * @param algorithmType defines the algorithm to use
  41259. * @param query defines the query to use
  41260. * @returns the current engine
  41261. * @see http://doc.babylonjs.com/features/occlusionquery
  41262. */
  41263. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41264. /**
  41265. * Ends an occlusion query
  41266. * @see http://doc.babylonjs.com/features/occlusionquery
  41267. * @param algorithmType defines the algorithm to use
  41268. * @returns the current engine
  41269. */
  41270. endOcclusionQuery(algorithmType: number): Engine;
  41271. /**
  41272. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41273. * Please note that only one query can be issued at a time
  41274. * @returns a time token used to track the time span
  41275. */
  41276. startTimeQuery(): Nullable<_TimeToken>;
  41277. /**
  41278. * Ends a time query
  41279. * @param token defines the token used to measure the time span
  41280. * @returns the time spent (in ns)
  41281. */
  41282. endTimeQuery(token: _TimeToken): int;
  41283. /** @hidden */
  41284. _currentNonTimestampToken: Nullable<_TimeToken>;
  41285. /** @hidden */
  41286. _createTimeQuery(): WebGLQuery;
  41287. /** @hidden */
  41288. _deleteTimeQuery(query: WebGLQuery): void;
  41289. /** @hidden */
  41290. _getGlAlgorithmType(algorithmType: number): number;
  41291. /** @hidden */
  41292. _getTimeQueryResult(query: WebGLQuery): any;
  41293. /** @hidden */
  41294. _getTimeQueryAvailability(query: WebGLQuery): any;
  41295. }
  41296. interface AbstractMesh {
  41297. /**
  41298. * Backing filed
  41299. * @hidden
  41300. */
  41301. __occlusionDataStorage: _OcclusionDataStorage;
  41302. /**
  41303. * Access property
  41304. * @hidden
  41305. */
  41306. _occlusionDataStorage: _OcclusionDataStorage;
  41307. /**
  41308. * 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.
  41309. * The default value is -1 which means don't break the query and wait till the result
  41310. * @see http://doc.babylonjs.com/features/occlusionquery
  41311. */
  41312. occlusionRetryCount: number;
  41313. /**
  41314. * 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:
  41315. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41316. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41317. * * 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.
  41318. * @see http://doc.babylonjs.com/features/occlusionquery
  41319. */
  41320. occlusionType: number;
  41321. /**
  41322. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41323. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41324. * * 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.
  41325. * @see http://doc.babylonjs.com/features/occlusionquery
  41326. */
  41327. occlusionQueryAlgorithmType: number;
  41328. /**
  41329. * 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
  41330. * @see http://doc.babylonjs.com/features/occlusionquery
  41331. */
  41332. isOccluded: boolean;
  41333. /**
  41334. * Flag to check the progress status of the query
  41335. * @see http://doc.babylonjs.com/features/occlusionquery
  41336. */
  41337. isOcclusionQueryInProgress: boolean;
  41338. }
  41339. }
  41340. declare module BABYLON {
  41341. /** @hidden */
  41342. export var _forceTransformFeedbackToBundle: boolean;
  41343. interface Engine {
  41344. /**
  41345. * Creates a webGL transform feedback object
  41346. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41347. * @returns the webGL transform feedback object
  41348. */
  41349. createTransformFeedback(): WebGLTransformFeedback;
  41350. /**
  41351. * Delete a webGL transform feedback object
  41352. * @param value defines the webGL transform feedback object to delete
  41353. */
  41354. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41355. /**
  41356. * Bind a webGL transform feedback object to the webgl context
  41357. * @param value defines the webGL transform feedback object to bind
  41358. */
  41359. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41360. /**
  41361. * Begins a transform feedback operation
  41362. * @param usePoints defines if points or triangles must be used
  41363. */
  41364. beginTransformFeedback(usePoints: boolean): void;
  41365. /**
  41366. * Ends a transform feedback operation
  41367. */
  41368. endTransformFeedback(): void;
  41369. /**
  41370. * Specify the varyings to use with transform feedback
  41371. * @param program defines the associated webGL program
  41372. * @param value defines the list of strings representing the varying names
  41373. */
  41374. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41375. /**
  41376. * Bind a webGL buffer for a transform feedback operation
  41377. * @param value defines the webGL buffer to bind
  41378. */
  41379. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41380. }
  41381. }
  41382. declare module BABYLON {
  41383. /**
  41384. * Gather the list of clipboard event types as constants.
  41385. */
  41386. export class ClipboardEventTypes {
  41387. /**
  41388. * The clipboard event is fired when a copy command is active (pressed).
  41389. */
  41390. static readonly COPY: number;
  41391. /**
  41392. * The clipboard event is fired when a cut command is active (pressed).
  41393. */
  41394. static readonly CUT: number;
  41395. /**
  41396. * The clipboard event is fired when a paste command is active (pressed).
  41397. */
  41398. static readonly PASTE: number;
  41399. }
  41400. /**
  41401. * This class is used to store clipboard related info for the onClipboardObservable event.
  41402. */
  41403. export class ClipboardInfo {
  41404. /**
  41405. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41406. */
  41407. type: number;
  41408. /**
  41409. * Defines the related dom event
  41410. */
  41411. event: ClipboardEvent;
  41412. /**
  41413. *Creates an instance of ClipboardInfo.
  41414. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41415. * @param event Defines the related dom event
  41416. */
  41417. constructor(
  41418. /**
  41419. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41420. */
  41421. type: number,
  41422. /**
  41423. * Defines the related dom event
  41424. */
  41425. event: ClipboardEvent);
  41426. /**
  41427. * Get the clipboard event's type from the keycode.
  41428. * @param keyCode Defines the keyCode for the current keyboard event.
  41429. * @return {number}
  41430. */
  41431. static GetTypeFromCharacter(keyCode: number): number;
  41432. }
  41433. }
  41434. declare module BABYLON {
  41435. /**
  41436. * Class used to represent data loading progression
  41437. */
  41438. export class SceneLoaderProgressEvent {
  41439. /** defines if data length to load can be evaluated */
  41440. readonly lengthComputable: boolean;
  41441. /** defines the loaded data length */
  41442. readonly loaded: number;
  41443. /** defines the data length to load */
  41444. readonly total: number;
  41445. /**
  41446. * Create a new progress event
  41447. * @param lengthComputable defines if data length to load can be evaluated
  41448. * @param loaded defines the loaded data length
  41449. * @param total defines the data length to load
  41450. */
  41451. constructor(
  41452. /** defines if data length to load can be evaluated */
  41453. lengthComputable: boolean,
  41454. /** defines the loaded data length */
  41455. loaded: number,
  41456. /** defines the data length to load */
  41457. total: number);
  41458. /**
  41459. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41460. * @param event defines the source event
  41461. * @returns a new SceneLoaderProgressEvent
  41462. */
  41463. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41464. }
  41465. /**
  41466. * Interface used by SceneLoader plugins to define supported file extensions
  41467. */
  41468. export interface ISceneLoaderPluginExtensions {
  41469. /**
  41470. * Defines the list of supported extensions
  41471. */
  41472. [extension: string]: {
  41473. isBinary: boolean;
  41474. };
  41475. }
  41476. /**
  41477. * Interface used by SceneLoader plugin factory
  41478. */
  41479. export interface ISceneLoaderPluginFactory {
  41480. /**
  41481. * Defines the name of the factory
  41482. */
  41483. name: string;
  41484. /**
  41485. * Function called to create a new plugin
  41486. * @return the new plugin
  41487. */
  41488. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41489. /**
  41490. * Boolean indicating if the plugin can direct load specific data
  41491. */
  41492. canDirectLoad?: (data: string) => boolean;
  41493. }
  41494. /**
  41495. * Interface used to define a SceneLoader plugin
  41496. */
  41497. export interface ISceneLoaderPlugin {
  41498. /**
  41499. * The friendly name of this plugin.
  41500. */
  41501. name: string;
  41502. /**
  41503. * The file extensions supported by this plugin.
  41504. */
  41505. extensions: string | ISceneLoaderPluginExtensions;
  41506. /**
  41507. * Import meshes into a scene.
  41508. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41509. * @param scene The scene to import into
  41510. * @param data The data to import
  41511. * @param rootUrl The root url for scene and resources
  41512. * @param meshes The meshes array to import into
  41513. * @param particleSystems The particle systems array to import into
  41514. * @param skeletons The skeletons array to import into
  41515. * @param onError The callback when import fails
  41516. * @returns True if successful or false otherwise
  41517. */
  41518. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41519. /**
  41520. * Load into a scene.
  41521. * @param scene The scene to load into
  41522. * @param data The data to import
  41523. * @param rootUrl The root url for scene and resources
  41524. * @param onError The callback when import fails
  41525. * @returns true if successful or false otherwise
  41526. */
  41527. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41528. /**
  41529. * The callback that returns true if the data can be directly loaded.
  41530. */
  41531. canDirectLoad?: (data: string) => boolean;
  41532. /**
  41533. * The callback that allows custom handling of the root url based on the response url.
  41534. */
  41535. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41536. /**
  41537. * Load into an asset container.
  41538. * @param scene The scene to load into
  41539. * @param data The data to import
  41540. * @param rootUrl The root url for scene and resources
  41541. * @param onError The callback when import fails
  41542. * @returns The loaded asset container
  41543. */
  41544. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41545. }
  41546. /**
  41547. * Interface used to define an async SceneLoader plugin
  41548. */
  41549. export interface ISceneLoaderPluginAsync {
  41550. /**
  41551. * The friendly name of this plugin.
  41552. */
  41553. name: string;
  41554. /**
  41555. * The file extensions supported by this plugin.
  41556. */
  41557. extensions: string | ISceneLoaderPluginExtensions;
  41558. /**
  41559. * Import meshes into a scene.
  41560. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41561. * @param scene The scene to import into
  41562. * @param data The data to import
  41563. * @param rootUrl The root url for scene and resources
  41564. * @param onProgress The callback when the load progresses
  41565. * @param fileName Defines the name of the file to load
  41566. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41567. */
  41568. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41569. meshes: AbstractMesh[];
  41570. particleSystems: IParticleSystem[];
  41571. skeletons: Skeleton[];
  41572. animationGroups: AnimationGroup[];
  41573. }>;
  41574. /**
  41575. * Load into a scene.
  41576. * @param scene The scene to load into
  41577. * @param data The data to import
  41578. * @param rootUrl The root url for scene and resources
  41579. * @param onProgress The callback when the load progresses
  41580. * @param fileName Defines the name of the file to load
  41581. * @returns Nothing
  41582. */
  41583. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41584. /**
  41585. * The callback that returns true if the data can be directly loaded.
  41586. */
  41587. canDirectLoad?: (data: string) => boolean;
  41588. /**
  41589. * The callback that allows custom handling of the root url based on the response url.
  41590. */
  41591. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41592. /**
  41593. * Load into an asset container.
  41594. * @param scene The scene to load into
  41595. * @param data The data to import
  41596. * @param rootUrl The root url for scene and resources
  41597. * @param onProgress The callback when the load progresses
  41598. * @param fileName Defines the name of the file to load
  41599. * @returns The loaded asset container
  41600. */
  41601. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41602. }
  41603. /**
  41604. * Class used to load scene from various file formats using registered plugins
  41605. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41606. */
  41607. export class SceneLoader {
  41608. /**
  41609. * No logging while loading
  41610. */
  41611. static readonly NO_LOGGING: number;
  41612. /**
  41613. * Minimal logging while loading
  41614. */
  41615. static readonly MINIMAL_LOGGING: number;
  41616. /**
  41617. * Summary logging while loading
  41618. */
  41619. static readonly SUMMARY_LOGGING: number;
  41620. /**
  41621. * Detailled logging while loading
  41622. */
  41623. static readonly DETAILED_LOGGING: number;
  41624. /**
  41625. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41626. */
  41627. static ForceFullSceneLoadingForIncremental: boolean;
  41628. /**
  41629. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41630. */
  41631. static ShowLoadingScreen: boolean;
  41632. /**
  41633. * Defines the current logging level (while loading the scene)
  41634. * @ignorenaming
  41635. */
  41636. static loggingLevel: number;
  41637. /**
  41638. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41639. */
  41640. static CleanBoneMatrixWeights: boolean;
  41641. /**
  41642. * Event raised when a plugin is used to load a scene
  41643. */
  41644. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41645. private static _registeredPlugins;
  41646. private static _getDefaultPlugin;
  41647. private static _getPluginForExtension;
  41648. private static _getPluginForDirectLoad;
  41649. private static _getPluginForFilename;
  41650. private static _getDirectLoad;
  41651. private static _loadData;
  41652. private static _getFileInfo;
  41653. /**
  41654. * Gets a plugin that can load the given extension
  41655. * @param extension defines the extension to load
  41656. * @returns a plugin or null if none works
  41657. */
  41658. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41659. /**
  41660. * Gets a boolean indicating that the given extension can be loaded
  41661. * @param extension defines the extension to load
  41662. * @returns true if the extension is supported
  41663. */
  41664. static IsPluginForExtensionAvailable(extension: string): boolean;
  41665. /**
  41666. * Adds a new plugin to the list of registered plugins
  41667. * @param plugin defines the plugin to add
  41668. */
  41669. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41670. /**
  41671. * Import meshes into a scene
  41672. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41673. * @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)
  41674. * @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)
  41675. * @param scene the instance of BABYLON.Scene to append to
  41676. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41677. * @param onProgress a callback with a progress event for each file being loaded
  41678. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41679. * @param pluginExtension the extension used to determine the plugin
  41680. * @returns The loaded plugin
  41681. */
  41682. 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>;
  41683. /**
  41684. * Import meshes into a scene
  41685. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41686. * @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)
  41687. * @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)
  41688. * @param scene the instance of BABYLON.Scene to append to
  41689. * @param onProgress a callback with a progress event for each file being loaded
  41690. * @param pluginExtension the extension used to determine the plugin
  41691. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41692. */
  41693. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41694. meshes: AbstractMesh[];
  41695. particleSystems: IParticleSystem[];
  41696. skeletons: Skeleton[];
  41697. animationGroups: AnimationGroup[];
  41698. }>;
  41699. /**
  41700. * Load a scene
  41701. * @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)
  41702. * @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)
  41703. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41704. * @param onSuccess a callback with the scene when import succeeds
  41705. * @param onProgress a callback with a progress event for each file being loaded
  41706. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41707. * @param pluginExtension the extension used to determine the plugin
  41708. * @returns The loaded plugin
  41709. */
  41710. 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>;
  41711. /**
  41712. * Load a scene
  41713. * @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)
  41714. * @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)
  41715. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41716. * @param onProgress a callback with a progress event for each file being loaded
  41717. * @param pluginExtension the extension used to determine the plugin
  41718. * @returns The loaded scene
  41719. */
  41720. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41721. /**
  41722. * Append a scene
  41723. * @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)
  41724. * @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)
  41725. * @param scene is the instance of BABYLON.Scene to append to
  41726. * @param onSuccess a callback with the scene when import succeeds
  41727. * @param onProgress a callback with a progress event for each file being loaded
  41728. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41729. * @param pluginExtension the extension used to determine the plugin
  41730. * @returns The loaded plugin
  41731. */
  41732. 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>;
  41733. /**
  41734. * Append a scene
  41735. * @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)
  41736. * @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)
  41737. * @param scene is the instance of BABYLON.Scene to append to
  41738. * @param onProgress a callback with a progress event for each file being loaded
  41739. * @param pluginExtension the extension used to determine the plugin
  41740. * @returns The given scene
  41741. */
  41742. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41743. /**
  41744. * Load a scene into an asset container
  41745. * @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)
  41746. * @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)
  41747. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41748. * @param onSuccess a callback with the scene when import succeeds
  41749. * @param onProgress a callback with a progress event for each file being loaded
  41750. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41751. * @param pluginExtension the extension used to determine the plugin
  41752. * @returns The loaded plugin
  41753. */
  41754. 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>;
  41755. /**
  41756. * Load a scene into an asset container
  41757. * @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)
  41758. * @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)
  41759. * @param scene is the instance of Scene to append to
  41760. * @param onProgress a callback with a progress event for each file being loaded
  41761. * @param pluginExtension the extension used to determine the plugin
  41762. * @returns The loaded asset container
  41763. */
  41764. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41765. }
  41766. }
  41767. declare module BABYLON {
  41768. /**
  41769. * Google Daydream controller
  41770. */
  41771. export class DaydreamController extends WebVRController {
  41772. /**
  41773. * Base Url for the controller model.
  41774. */
  41775. static MODEL_BASE_URL: string;
  41776. /**
  41777. * File name for the controller model.
  41778. */
  41779. static MODEL_FILENAME: string;
  41780. /**
  41781. * Gamepad Id prefix used to identify Daydream Controller.
  41782. */
  41783. static readonly GAMEPAD_ID_PREFIX: string;
  41784. /**
  41785. * Creates a new DaydreamController from a gamepad
  41786. * @param vrGamepad the gamepad that the controller should be created from
  41787. */
  41788. constructor(vrGamepad: any);
  41789. /**
  41790. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41791. * @param scene scene in which to add meshes
  41792. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41793. */
  41794. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41795. /**
  41796. * Called once for each button that changed state since the last frame
  41797. * @param buttonIdx Which button index changed
  41798. * @param state New state of the button
  41799. * @param changes Which properties on the state changed since last frame
  41800. */
  41801. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41802. }
  41803. }
  41804. declare module BABYLON {
  41805. /**
  41806. * Gear VR Controller
  41807. */
  41808. export class GearVRController extends WebVRController {
  41809. /**
  41810. * Base Url for the controller model.
  41811. */
  41812. static MODEL_BASE_URL: string;
  41813. /**
  41814. * File name for the controller model.
  41815. */
  41816. static MODEL_FILENAME: string;
  41817. /**
  41818. * Gamepad Id prefix used to identify this controller.
  41819. */
  41820. static readonly GAMEPAD_ID_PREFIX: string;
  41821. private readonly _buttonIndexToObservableNameMap;
  41822. /**
  41823. * Creates a new GearVRController from a gamepad
  41824. * @param vrGamepad the gamepad that the controller should be created from
  41825. */
  41826. constructor(vrGamepad: any);
  41827. /**
  41828. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41829. * @param scene scene in which to add meshes
  41830. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41831. */
  41832. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41833. /**
  41834. * Called once for each button that changed state since the last frame
  41835. * @param buttonIdx Which button index changed
  41836. * @param state New state of the button
  41837. * @param changes Which properties on the state changed since last frame
  41838. */
  41839. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41840. }
  41841. }
  41842. declare module BABYLON {
  41843. /**
  41844. * Generic Controller
  41845. */
  41846. export class GenericController extends WebVRController {
  41847. /**
  41848. * Base Url for the controller model.
  41849. */
  41850. static readonly MODEL_BASE_URL: string;
  41851. /**
  41852. * File name for the controller model.
  41853. */
  41854. static readonly MODEL_FILENAME: string;
  41855. /**
  41856. * Creates a new GenericController from a gamepad
  41857. * @param vrGamepad the gamepad that the controller should be created from
  41858. */
  41859. constructor(vrGamepad: any);
  41860. /**
  41861. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41862. * @param scene scene in which to add meshes
  41863. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41864. */
  41865. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41866. /**
  41867. * Called once for each button that changed state since the last frame
  41868. * @param buttonIdx Which button index changed
  41869. * @param state New state of the button
  41870. * @param changes Which properties on the state changed since last frame
  41871. */
  41872. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41873. }
  41874. }
  41875. declare module BABYLON {
  41876. /**
  41877. * Oculus Touch Controller
  41878. */
  41879. export class OculusTouchController extends WebVRController {
  41880. /**
  41881. * Base Url for the controller model.
  41882. */
  41883. static MODEL_BASE_URL: string;
  41884. /**
  41885. * File name for the left controller model.
  41886. */
  41887. static MODEL_LEFT_FILENAME: string;
  41888. /**
  41889. * File name for the right controller model.
  41890. */
  41891. static MODEL_RIGHT_FILENAME: string;
  41892. /**
  41893. * Fired when the secondary trigger on this controller is modified
  41894. */
  41895. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41896. /**
  41897. * Fired when the thumb rest on this controller is modified
  41898. */
  41899. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41900. /**
  41901. * Creates a new OculusTouchController from a gamepad
  41902. * @param vrGamepad the gamepad that the controller should be created from
  41903. */
  41904. constructor(vrGamepad: any);
  41905. /**
  41906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41907. * @param scene scene in which to add meshes
  41908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41909. */
  41910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41911. /**
  41912. * Fired when the A button on this controller is modified
  41913. */
  41914. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41915. /**
  41916. * Fired when the B button on this controller is modified
  41917. */
  41918. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41919. /**
  41920. * Fired when the X button on this controller is modified
  41921. */
  41922. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41923. /**
  41924. * Fired when the Y button on this controller is modified
  41925. */
  41926. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41927. /**
  41928. * Called once for each button that changed state since the last frame
  41929. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41930. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41931. * 2) secondary trigger (same)
  41932. * 3) A (right) X (left), touch, pressed = value
  41933. * 4) B / Y
  41934. * 5) thumb rest
  41935. * @param buttonIdx Which button index changed
  41936. * @param state New state of the button
  41937. * @param changes Which properties on the state changed since last frame
  41938. */
  41939. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41940. }
  41941. }
  41942. declare module BABYLON {
  41943. /**
  41944. * Vive Controller
  41945. */
  41946. export class ViveController extends WebVRController {
  41947. /**
  41948. * Base Url for the controller model.
  41949. */
  41950. static MODEL_BASE_URL: string;
  41951. /**
  41952. * File name for the controller model.
  41953. */
  41954. static MODEL_FILENAME: string;
  41955. /**
  41956. * Creates a new ViveController from a gamepad
  41957. * @param vrGamepad the gamepad that the controller should be created from
  41958. */
  41959. constructor(vrGamepad: any);
  41960. /**
  41961. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41962. * @param scene scene in which to add meshes
  41963. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41964. */
  41965. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41966. /**
  41967. * Fired when the left button on this controller is modified
  41968. */
  41969. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41970. /**
  41971. * Fired when the right button on this controller is modified
  41972. */
  41973. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41974. /**
  41975. * Fired when the menu button on this controller is modified
  41976. */
  41977. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41978. /**
  41979. * Called once for each button that changed state since the last frame
  41980. * Vive mapping:
  41981. * 0: touchpad
  41982. * 1: trigger
  41983. * 2: left AND right buttons
  41984. * 3: menu button
  41985. * @param buttonIdx Which button index changed
  41986. * @param state New state of the button
  41987. * @param changes Which properties on the state changed since last frame
  41988. */
  41989. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41990. }
  41991. }
  41992. declare module BABYLON {
  41993. /**
  41994. * Defines the WindowsMotionController object that the state of the windows motion controller
  41995. */
  41996. export class WindowsMotionController extends WebVRController {
  41997. /**
  41998. * The base url used to load the left and right controller models
  41999. */
  42000. static MODEL_BASE_URL: string;
  42001. /**
  42002. * The name of the left controller model file
  42003. */
  42004. static MODEL_LEFT_FILENAME: string;
  42005. /**
  42006. * The name of the right controller model file
  42007. */
  42008. static MODEL_RIGHT_FILENAME: string;
  42009. /**
  42010. * The controller name prefix for this controller type
  42011. */
  42012. static readonly GAMEPAD_ID_PREFIX: string;
  42013. /**
  42014. * The controller id pattern for this controller type
  42015. */
  42016. private static readonly GAMEPAD_ID_PATTERN;
  42017. private _loadedMeshInfo;
  42018. private readonly _mapping;
  42019. /**
  42020. * Fired when the trackpad on this controller is clicked
  42021. */
  42022. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42023. /**
  42024. * Fired when the trackpad on this controller is modified
  42025. */
  42026. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42027. /**
  42028. * The current x and y values of this controller's trackpad
  42029. */
  42030. trackpad: StickValues;
  42031. /**
  42032. * Creates a new WindowsMotionController from a gamepad
  42033. * @param vrGamepad the gamepad that the controller should be created from
  42034. */
  42035. constructor(vrGamepad: any);
  42036. /**
  42037. * Fired when the trigger on this controller is modified
  42038. */
  42039. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42040. /**
  42041. * Fired when the menu button on this controller is modified
  42042. */
  42043. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42044. /**
  42045. * Fired when the grip button on this controller is modified
  42046. */
  42047. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42048. /**
  42049. * Fired when the thumbstick button on this controller is modified
  42050. */
  42051. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42052. /**
  42053. * Fired when the touchpad button on this controller is modified
  42054. */
  42055. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42056. /**
  42057. * Fired when the touchpad values on this controller are modified
  42058. */
  42059. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42060. private _updateTrackpad;
  42061. /**
  42062. * Called once per frame by the engine.
  42063. */
  42064. update(): void;
  42065. /**
  42066. * Called once for each button that changed state since the last frame
  42067. * @param buttonIdx Which button index changed
  42068. * @param state New state of the button
  42069. * @param changes Which properties on the state changed since last frame
  42070. */
  42071. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42072. /**
  42073. * Moves the buttons on the controller mesh based on their current state
  42074. * @param buttonName the name of the button to move
  42075. * @param buttonValue the value of the button which determines the buttons new position
  42076. */
  42077. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42078. /**
  42079. * Moves the axis on the controller mesh based on its current state
  42080. * @param axis the index of the axis
  42081. * @param axisValue the value of the axis which determines the meshes new position
  42082. * @hidden
  42083. */
  42084. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42085. /**
  42086. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42087. * @param scene scene in which to add meshes
  42088. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42089. */
  42090. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42091. /**
  42092. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42093. * can be transformed by button presses and axes values, based on this._mapping.
  42094. *
  42095. * @param scene scene in which the meshes exist
  42096. * @param meshes list of meshes that make up the controller model to process
  42097. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42098. */
  42099. private processModel;
  42100. private createMeshInfo;
  42101. /**
  42102. * Gets the ray of the controller in the direction the controller is pointing
  42103. * @param length the length the resulting ray should be
  42104. * @returns a ray in the direction the controller is pointing
  42105. */
  42106. getForwardRay(length?: number): Ray;
  42107. /**
  42108. * Disposes of the controller
  42109. */
  42110. dispose(): void;
  42111. }
  42112. }
  42113. declare module BABYLON {
  42114. /**
  42115. * Single axis scale gizmo
  42116. */
  42117. export class AxisScaleGizmo extends Gizmo {
  42118. private _coloredMaterial;
  42119. /**
  42120. * Drag behavior responsible for the gizmos dragging interactions
  42121. */
  42122. dragBehavior: PointerDragBehavior;
  42123. private _pointerObserver;
  42124. /**
  42125. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42126. */
  42127. snapDistance: number;
  42128. /**
  42129. * Event that fires each time the gizmo snaps to a new location.
  42130. * * snapDistance is the the change in distance
  42131. */
  42132. onSnapObservable: Observable<{
  42133. snapDistance: number;
  42134. }>;
  42135. /**
  42136. * If the scaling operation should be done on all axis (default: false)
  42137. */
  42138. uniformScaling: boolean;
  42139. /**
  42140. * Creates an AxisScaleGizmo
  42141. * @param gizmoLayer The utility layer the gizmo will be added to
  42142. * @param dragAxis The axis which the gizmo will be able to scale on
  42143. * @param color The color of the gizmo
  42144. */
  42145. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42146. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42147. /**
  42148. * Disposes of the gizmo
  42149. */
  42150. dispose(): void;
  42151. /**
  42152. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42153. * @param mesh The mesh to replace the default mesh of the gizmo
  42154. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42155. */
  42156. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42157. }
  42158. }
  42159. declare module BABYLON {
  42160. /**
  42161. * Bounding box gizmo
  42162. */
  42163. export class BoundingBoxGizmo extends Gizmo {
  42164. private _lineBoundingBox;
  42165. private _rotateSpheresParent;
  42166. private _scaleBoxesParent;
  42167. private _boundingDimensions;
  42168. private _renderObserver;
  42169. private _pointerObserver;
  42170. private _scaleDragSpeed;
  42171. private _tmpQuaternion;
  42172. private _tmpVector;
  42173. private _tmpRotationMatrix;
  42174. /**
  42175. * 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)
  42176. */
  42177. ignoreChildren: boolean;
  42178. /**
  42179. * 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)
  42180. */
  42181. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42182. /**
  42183. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42184. */
  42185. rotationSphereSize: number;
  42186. /**
  42187. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42188. */
  42189. scaleBoxSize: number;
  42190. /**
  42191. * 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)
  42192. */
  42193. fixedDragMeshScreenSize: boolean;
  42194. /**
  42195. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42196. */
  42197. fixedDragMeshScreenSizeDistanceFactor: number;
  42198. /**
  42199. * Fired when a rotation sphere or scale box is dragged
  42200. */
  42201. onDragStartObservable: Observable<{}>;
  42202. /**
  42203. * Fired when a scale box is dragged
  42204. */
  42205. onScaleBoxDragObservable: Observable<{}>;
  42206. /**
  42207. * Fired when a scale box drag is ended
  42208. */
  42209. onScaleBoxDragEndObservable: Observable<{}>;
  42210. /**
  42211. * Fired when a rotation sphere is dragged
  42212. */
  42213. onRotationSphereDragObservable: Observable<{}>;
  42214. /**
  42215. * Fired when a rotation sphere drag is ended
  42216. */
  42217. onRotationSphereDragEndObservable: Observable<{}>;
  42218. /**
  42219. * 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)
  42220. */
  42221. scalePivot: Nullable<Vector3>;
  42222. private _anchorMesh;
  42223. private _existingMeshScale;
  42224. private _dragMesh;
  42225. private pointerDragBehavior;
  42226. private coloredMaterial;
  42227. private hoverColoredMaterial;
  42228. /**
  42229. * Sets the color of the bounding box gizmo
  42230. * @param color the color to set
  42231. */
  42232. setColor(color: Color3): void;
  42233. /**
  42234. * Creates an BoundingBoxGizmo
  42235. * @param gizmoLayer The utility layer the gizmo will be added to
  42236. * @param color The color of the gizmo
  42237. */
  42238. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42239. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42240. private _selectNode;
  42241. /**
  42242. * Updates the bounding box information for the Gizmo
  42243. */
  42244. updateBoundingBox(): void;
  42245. private _updateRotationSpheres;
  42246. private _updateScaleBoxes;
  42247. /**
  42248. * Enables rotation on the specified axis and disables rotation on the others
  42249. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42250. */
  42251. setEnabledRotationAxis(axis: string): void;
  42252. /**
  42253. * Enables/disables scaling
  42254. * @param enable if scaling should be enabled
  42255. */
  42256. setEnabledScaling(enable: boolean): void;
  42257. private _updateDummy;
  42258. /**
  42259. * Enables a pointer drag behavior on the bounding box of the gizmo
  42260. */
  42261. enableDragBehavior(): void;
  42262. /**
  42263. * Disposes of the gizmo
  42264. */
  42265. dispose(): void;
  42266. /**
  42267. * 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)
  42268. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42269. * @returns the bounding box mesh with the passed in mesh as a child
  42270. */
  42271. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42272. /**
  42273. * CustomMeshes are not supported by this gizmo
  42274. * @param mesh The mesh to replace the default mesh of the gizmo
  42275. */
  42276. setCustomMesh(mesh: Mesh): void;
  42277. }
  42278. }
  42279. declare module BABYLON {
  42280. /**
  42281. * Single plane rotation gizmo
  42282. */
  42283. export class PlaneRotationGizmo extends Gizmo {
  42284. /**
  42285. * Drag behavior responsible for the gizmos dragging interactions
  42286. */
  42287. dragBehavior: PointerDragBehavior;
  42288. private _pointerObserver;
  42289. /**
  42290. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42291. */
  42292. snapDistance: number;
  42293. /**
  42294. * Event that fires each time the gizmo snaps to a new location.
  42295. * * snapDistance is the the change in distance
  42296. */
  42297. onSnapObservable: Observable<{
  42298. snapDistance: number;
  42299. }>;
  42300. /**
  42301. * Creates a PlaneRotationGizmo
  42302. * @param gizmoLayer The utility layer the gizmo will be added to
  42303. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42304. * @param color The color of the gizmo
  42305. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42306. */
  42307. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42308. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42309. /**
  42310. * Disposes of the gizmo
  42311. */
  42312. dispose(): void;
  42313. }
  42314. }
  42315. declare module BABYLON {
  42316. /**
  42317. * Gizmo that enables rotating a mesh along 3 axis
  42318. */
  42319. export class RotationGizmo extends Gizmo {
  42320. /**
  42321. * Internal gizmo used for interactions on the x axis
  42322. */
  42323. xGizmo: PlaneRotationGizmo;
  42324. /**
  42325. * Internal gizmo used for interactions on the y axis
  42326. */
  42327. yGizmo: PlaneRotationGizmo;
  42328. /**
  42329. * Internal gizmo used for interactions on the z axis
  42330. */
  42331. zGizmo: PlaneRotationGizmo;
  42332. /** Fires an event when any of it's sub gizmos are dragged */
  42333. onDragStartObservable: Observable<{}>;
  42334. /** Fires an event when any of it's sub gizmos are released from dragging */
  42335. onDragEndObservable: Observable<{}>;
  42336. attachedMesh: Nullable<AbstractMesh>;
  42337. /**
  42338. * Creates a RotationGizmo
  42339. * @param gizmoLayer The utility layer the gizmo will be added to
  42340. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42341. */
  42342. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42343. updateGizmoRotationToMatchAttachedMesh: boolean;
  42344. /**
  42345. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42346. */
  42347. snapDistance: number;
  42348. /**
  42349. * Ratio for the scale of the gizmo (Default: 1)
  42350. */
  42351. scaleRatio: number;
  42352. /**
  42353. * Disposes of the gizmo
  42354. */
  42355. dispose(): void;
  42356. /**
  42357. * CustomMeshes are not supported by this gizmo
  42358. * @param mesh The mesh to replace the default mesh of the gizmo
  42359. */
  42360. setCustomMesh(mesh: Mesh): void;
  42361. }
  42362. }
  42363. declare module BABYLON {
  42364. /**
  42365. * Gizmo that enables dragging a mesh along 3 axis
  42366. */
  42367. export class PositionGizmo extends Gizmo {
  42368. /**
  42369. * Internal gizmo used for interactions on the x axis
  42370. */
  42371. xGizmo: AxisDragGizmo;
  42372. /**
  42373. * Internal gizmo used for interactions on the y axis
  42374. */
  42375. yGizmo: AxisDragGizmo;
  42376. /**
  42377. * Internal gizmo used for interactions on the z axis
  42378. */
  42379. zGizmo: AxisDragGizmo;
  42380. /** Fires an event when any of it's sub gizmos are dragged */
  42381. onDragStartObservable: Observable<{}>;
  42382. /** Fires an event when any of it's sub gizmos are released from dragging */
  42383. onDragEndObservable: Observable<{}>;
  42384. attachedMesh: Nullable<AbstractMesh>;
  42385. /**
  42386. * Creates a PositionGizmo
  42387. * @param gizmoLayer The utility layer the gizmo will be added to
  42388. */
  42389. constructor(gizmoLayer?: UtilityLayerRenderer);
  42390. updateGizmoRotationToMatchAttachedMesh: boolean;
  42391. /**
  42392. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42393. */
  42394. snapDistance: number;
  42395. /**
  42396. * Ratio for the scale of the gizmo (Default: 1)
  42397. */
  42398. scaleRatio: number;
  42399. /**
  42400. * Disposes of the gizmo
  42401. */
  42402. dispose(): void;
  42403. /**
  42404. * CustomMeshes are not supported by this gizmo
  42405. * @param mesh The mesh to replace the default mesh of the gizmo
  42406. */
  42407. setCustomMesh(mesh: Mesh): void;
  42408. }
  42409. }
  42410. declare module BABYLON {
  42411. /**
  42412. * Class containing static functions to help procedurally build meshes
  42413. */
  42414. export class PolyhedronBuilder {
  42415. /**
  42416. * Creates a polyhedron mesh
  42417. * * 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
  42418. * * The parameter `size` (positive float, default 1) sets the polygon size
  42419. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42420. * * 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`
  42421. * * 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
  42422. * * 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)`)
  42423. * * 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
  42424. * * 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
  42425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42426. * * 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
  42427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42428. * @param name defines the name of the mesh
  42429. * @param options defines the options used to create the mesh
  42430. * @param scene defines the hosting scene
  42431. * @returns the polyhedron mesh
  42432. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42433. */
  42434. static CreatePolyhedron(name: string, options: {
  42435. type?: number;
  42436. size?: number;
  42437. sizeX?: number;
  42438. sizeY?: number;
  42439. sizeZ?: number;
  42440. custom?: any;
  42441. faceUV?: Vector4[];
  42442. faceColors?: Color4[];
  42443. flat?: boolean;
  42444. updatable?: boolean;
  42445. sideOrientation?: number;
  42446. frontUVs?: Vector4;
  42447. backUVs?: Vector4;
  42448. }, scene: Scene): Mesh;
  42449. }
  42450. }
  42451. declare module BABYLON {
  42452. /**
  42453. * Gizmo that enables scaling a mesh along 3 axis
  42454. */
  42455. export class ScaleGizmo extends Gizmo {
  42456. /**
  42457. * Internal gizmo used for interactions on the x axis
  42458. */
  42459. xGizmo: AxisScaleGizmo;
  42460. /**
  42461. * Internal gizmo used for interactions on the y axis
  42462. */
  42463. yGizmo: AxisScaleGizmo;
  42464. /**
  42465. * Internal gizmo used for interactions on the z axis
  42466. */
  42467. zGizmo: AxisScaleGizmo;
  42468. /**
  42469. * Internal gizmo used to scale all axis equally
  42470. */
  42471. uniformScaleGizmo: AxisScaleGizmo;
  42472. /** Fires an event when any of it's sub gizmos are dragged */
  42473. onDragStartObservable: Observable<{}>;
  42474. /** Fires an event when any of it's sub gizmos are released from dragging */
  42475. onDragEndObservable: Observable<{}>;
  42476. attachedMesh: Nullable<AbstractMesh>;
  42477. /**
  42478. * Creates a ScaleGizmo
  42479. * @param gizmoLayer The utility layer the gizmo will be added to
  42480. */
  42481. constructor(gizmoLayer?: UtilityLayerRenderer);
  42482. updateGizmoRotationToMatchAttachedMesh: boolean;
  42483. /**
  42484. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42485. */
  42486. snapDistance: number;
  42487. /**
  42488. * Ratio for the scale of the gizmo (Default: 1)
  42489. */
  42490. scaleRatio: number;
  42491. /**
  42492. * Disposes of the gizmo
  42493. */
  42494. dispose(): void;
  42495. }
  42496. }
  42497. declare module BABYLON {
  42498. /**
  42499. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42500. */
  42501. export class GizmoManager implements IDisposable {
  42502. private scene;
  42503. /**
  42504. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42505. */
  42506. gizmos: {
  42507. positionGizmo: Nullable<PositionGizmo>;
  42508. rotationGizmo: Nullable<RotationGizmo>;
  42509. scaleGizmo: Nullable<ScaleGizmo>;
  42510. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42511. };
  42512. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42513. clearGizmoOnEmptyPointerEvent: boolean;
  42514. /** Fires an event when the manager is attached to a mesh */
  42515. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42516. private _gizmosEnabled;
  42517. private _pointerObserver;
  42518. private _attachedMesh;
  42519. private _boundingBoxColor;
  42520. private _defaultUtilityLayer;
  42521. private _defaultKeepDepthUtilityLayer;
  42522. /**
  42523. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42524. */
  42525. boundingBoxDragBehavior: SixDofDragBehavior;
  42526. /**
  42527. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42528. */
  42529. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42530. /**
  42531. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42532. */
  42533. usePointerToAttachGizmos: boolean;
  42534. /**
  42535. * Instatiates a gizmo manager
  42536. * @param scene the scene to overlay the gizmos on top of
  42537. */
  42538. constructor(scene: Scene);
  42539. /**
  42540. * Attaches a set of gizmos to the specified mesh
  42541. * @param mesh The mesh the gizmo's should be attached to
  42542. */
  42543. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42544. /**
  42545. * If the position gizmo is enabled
  42546. */
  42547. positionGizmoEnabled: boolean;
  42548. /**
  42549. * If the rotation gizmo is enabled
  42550. */
  42551. rotationGizmoEnabled: boolean;
  42552. /**
  42553. * If the scale gizmo is enabled
  42554. */
  42555. scaleGizmoEnabled: boolean;
  42556. /**
  42557. * If the boundingBox gizmo is enabled
  42558. */
  42559. boundingBoxGizmoEnabled: boolean;
  42560. /**
  42561. * Disposes of the gizmo manager
  42562. */
  42563. dispose(): void;
  42564. }
  42565. }
  42566. declare module BABYLON {
  42567. /**
  42568. * A directional light is defined by a direction (what a surprise!).
  42569. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42570. * 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.
  42571. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42572. */
  42573. export class DirectionalLight extends ShadowLight {
  42574. private _shadowFrustumSize;
  42575. /**
  42576. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42577. */
  42578. /**
  42579. * Specifies a fix frustum size for the shadow generation.
  42580. */
  42581. shadowFrustumSize: number;
  42582. private _shadowOrthoScale;
  42583. /**
  42584. * Gets the shadow projection scale against the optimal computed one.
  42585. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42586. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42587. */
  42588. /**
  42589. * Sets the shadow projection scale against the optimal computed one.
  42590. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42591. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42592. */
  42593. shadowOrthoScale: number;
  42594. /**
  42595. * Automatically compute the projection matrix to best fit (including all the casters)
  42596. * on each frame.
  42597. */
  42598. autoUpdateExtends: boolean;
  42599. private _orthoLeft;
  42600. private _orthoRight;
  42601. private _orthoTop;
  42602. private _orthoBottom;
  42603. /**
  42604. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42605. * The directional light is emitted from everywhere in the given direction.
  42606. * It can cast shadows.
  42607. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42608. * @param name The friendly name of the light
  42609. * @param direction The direction of the light
  42610. * @param scene The scene the light belongs to
  42611. */
  42612. constructor(name: string, direction: Vector3, scene: Scene);
  42613. /**
  42614. * Returns the string "DirectionalLight".
  42615. * @return The class name
  42616. */
  42617. getClassName(): string;
  42618. /**
  42619. * Returns the integer 1.
  42620. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42621. */
  42622. getTypeID(): number;
  42623. /**
  42624. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42625. * Returns the DirectionalLight Shadow projection matrix.
  42626. */
  42627. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42628. /**
  42629. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42630. * Returns the DirectionalLight Shadow projection matrix.
  42631. */
  42632. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42633. /**
  42634. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42635. * Returns the DirectionalLight Shadow projection matrix.
  42636. */
  42637. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42638. protected _buildUniformLayout(): void;
  42639. /**
  42640. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42641. * @param effect The effect to update
  42642. * @param lightIndex The index of the light in the effect to update
  42643. * @returns The directional light
  42644. */
  42645. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42646. /**
  42647. * Gets the minZ used for shadow according to both the scene and the light.
  42648. *
  42649. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42650. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42651. * @param activeCamera The camera we are returning the min for
  42652. * @returns the depth min z
  42653. */
  42654. getDepthMinZ(activeCamera: Camera): number;
  42655. /**
  42656. * Gets the maxZ used for shadow according to both the scene and the light.
  42657. *
  42658. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42659. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42660. * @param activeCamera The camera we are returning the max for
  42661. * @returns the depth max z
  42662. */
  42663. getDepthMaxZ(activeCamera: Camera): number;
  42664. /**
  42665. * Prepares the list of defines specific to the light type.
  42666. * @param defines the list of defines
  42667. * @param lightIndex defines the index of the light for the effect
  42668. */
  42669. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42670. }
  42671. }
  42672. declare module BABYLON {
  42673. /**
  42674. * Class containing static functions to help procedurally build meshes
  42675. */
  42676. export class HemisphereBuilder {
  42677. /**
  42678. * Creates a hemisphere mesh
  42679. * @param name defines the name of the mesh
  42680. * @param options defines the options used to create the mesh
  42681. * @param scene defines the hosting scene
  42682. * @returns the hemisphere mesh
  42683. */
  42684. static CreateHemisphere(name: string, options: {
  42685. segments?: number;
  42686. diameter?: number;
  42687. sideOrientation?: number;
  42688. }, scene: any): Mesh;
  42689. }
  42690. }
  42691. declare module BABYLON {
  42692. /**
  42693. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42694. * These values define a cone of light starting from the position, emitting toward the direction.
  42695. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42696. * and the exponent defines the speed of the decay of the light with distance (reach).
  42697. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42698. */
  42699. export class SpotLight extends ShadowLight {
  42700. private _angle;
  42701. private _innerAngle;
  42702. private _cosHalfAngle;
  42703. private _lightAngleScale;
  42704. private _lightAngleOffset;
  42705. /**
  42706. * Gets the cone angle of the spot light in Radians.
  42707. */
  42708. /**
  42709. * Sets the cone angle of the spot light in Radians.
  42710. */
  42711. angle: number;
  42712. /**
  42713. * Only used in gltf falloff mode, this defines the angle where
  42714. * the directional falloff will start before cutting at angle which could be seen
  42715. * as outer angle.
  42716. */
  42717. /**
  42718. * Only used in gltf falloff mode, this defines the angle where
  42719. * the directional falloff will start before cutting at angle which could be seen
  42720. * as outer angle.
  42721. */
  42722. innerAngle: number;
  42723. private _shadowAngleScale;
  42724. /**
  42725. * Allows scaling the angle of the light for shadow generation only.
  42726. */
  42727. /**
  42728. * Allows scaling the angle of the light for shadow generation only.
  42729. */
  42730. shadowAngleScale: number;
  42731. /**
  42732. * The light decay speed with the distance from the emission spot.
  42733. */
  42734. exponent: number;
  42735. private _projectionTextureMatrix;
  42736. /**
  42737. * Allows reading the projecton texture
  42738. */
  42739. readonly projectionTextureMatrix: Matrix;
  42740. protected _projectionTextureLightNear: number;
  42741. /**
  42742. * Gets the near clip of the Spotlight for texture projection.
  42743. */
  42744. /**
  42745. * Sets the near clip of the Spotlight for texture projection.
  42746. */
  42747. projectionTextureLightNear: number;
  42748. protected _projectionTextureLightFar: number;
  42749. /**
  42750. * Gets the far clip of the Spotlight for texture projection.
  42751. */
  42752. /**
  42753. * Sets the far clip of the Spotlight for texture projection.
  42754. */
  42755. projectionTextureLightFar: number;
  42756. protected _projectionTextureUpDirection: Vector3;
  42757. /**
  42758. * Gets the Up vector of the Spotlight for texture projection.
  42759. */
  42760. /**
  42761. * Sets the Up vector of the Spotlight for texture projection.
  42762. */
  42763. projectionTextureUpDirection: Vector3;
  42764. private _projectionTexture;
  42765. /**
  42766. * Gets the projection texture of the light.
  42767. */
  42768. /**
  42769. * Sets the projection texture of the light.
  42770. */
  42771. projectionTexture: Nullable<BaseTexture>;
  42772. private _projectionTextureViewLightDirty;
  42773. private _projectionTextureProjectionLightDirty;
  42774. private _projectionTextureDirty;
  42775. private _projectionTextureViewTargetVector;
  42776. private _projectionTextureViewLightMatrix;
  42777. private _projectionTextureProjectionLightMatrix;
  42778. private _projectionTextureScalingMatrix;
  42779. /**
  42780. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42781. * It can cast shadows.
  42782. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42783. * @param name The light friendly name
  42784. * @param position The position of the spot light in the scene
  42785. * @param direction The direction of the light in the scene
  42786. * @param angle The cone angle of the light in Radians
  42787. * @param exponent The light decay speed with the distance from the emission spot
  42788. * @param scene The scene the lights belongs to
  42789. */
  42790. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42791. /**
  42792. * Returns the string "SpotLight".
  42793. * @returns the class name
  42794. */
  42795. getClassName(): string;
  42796. /**
  42797. * Returns the integer 2.
  42798. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42799. */
  42800. getTypeID(): number;
  42801. /**
  42802. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42803. */
  42804. protected _setDirection(value: Vector3): void;
  42805. /**
  42806. * Overrides the position setter to recompute the projection texture view light Matrix.
  42807. */
  42808. protected _setPosition(value: Vector3): void;
  42809. /**
  42810. * 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.
  42811. * Returns the SpotLight.
  42812. */
  42813. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42814. protected _computeProjectionTextureViewLightMatrix(): void;
  42815. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42816. /**
  42817. * Main function for light texture projection matrix computing.
  42818. */
  42819. protected _computeProjectionTextureMatrix(): void;
  42820. protected _buildUniformLayout(): void;
  42821. private _computeAngleValues;
  42822. /**
  42823. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42824. * @param effect The effect to update
  42825. * @param lightIndex The index of the light in the effect to update
  42826. * @returns The spot light
  42827. */
  42828. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42829. /**
  42830. * Disposes the light and the associated resources.
  42831. */
  42832. dispose(): void;
  42833. /**
  42834. * Prepares the list of defines specific to the light type.
  42835. * @param defines the list of defines
  42836. * @param lightIndex defines the index of the light for the effect
  42837. */
  42838. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42839. }
  42840. }
  42841. declare module BABYLON {
  42842. /**
  42843. * Gizmo that enables viewing a light
  42844. */
  42845. export class LightGizmo extends Gizmo {
  42846. private _lightMesh;
  42847. private _material;
  42848. /**
  42849. * Creates a LightGizmo
  42850. * @param gizmoLayer The utility layer the gizmo will be added to
  42851. */
  42852. constructor(gizmoLayer?: UtilityLayerRenderer);
  42853. private _light;
  42854. /**
  42855. * The light that the gizmo is attached to
  42856. */
  42857. light: Nullable<Light>;
  42858. /**
  42859. * @hidden
  42860. * Updates the gizmo to match the attached mesh's position/rotation
  42861. */
  42862. protected _update(): void;
  42863. private static _Scale;
  42864. /**
  42865. * Creates the lines for a light mesh
  42866. */
  42867. private static _createLightLines;
  42868. private static _CreateHemisphericLightMesh;
  42869. private static _CreatePointLightMesh;
  42870. private static _CreateSpotLightMesh;
  42871. private static _CreateDirectionalLightMesh;
  42872. }
  42873. }
  42874. declare module BABYLON {
  42875. /** @hidden */
  42876. export var backgroundFragmentDeclaration: {
  42877. name: string;
  42878. shader: string;
  42879. };
  42880. }
  42881. declare module BABYLON {
  42882. /** @hidden */
  42883. export var backgroundUboDeclaration: {
  42884. name: string;
  42885. shader: string;
  42886. };
  42887. }
  42888. declare module BABYLON {
  42889. /** @hidden */
  42890. export var backgroundPixelShader: {
  42891. name: string;
  42892. shader: string;
  42893. };
  42894. }
  42895. declare module BABYLON {
  42896. /** @hidden */
  42897. export var backgroundVertexDeclaration: {
  42898. name: string;
  42899. shader: string;
  42900. };
  42901. }
  42902. declare module BABYLON {
  42903. /** @hidden */
  42904. export var backgroundVertexShader: {
  42905. name: string;
  42906. shader: string;
  42907. };
  42908. }
  42909. declare module BABYLON {
  42910. /**
  42911. * Background material used to create an efficient environement around your scene.
  42912. */
  42913. export class BackgroundMaterial extends PushMaterial {
  42914. /**
  42915. * Standard reflectance value at parallel view angle.
  42916. */
  42917. static StandardReflectance0: number;
  42918. /**
  42919. * Standard reflectance value at grazing angle.
  42920. */
  42921. static StandardReflectance90: number;
  42922. protected _primaryColor: Color3;
  42923. /**
  42924. * Key light Color (multiply against the environement texture)
  42925. */
  42926. primaryColor: Color3;
  42927. protected __perceptualColor: Nullable<Color3>;
  42928. /**
  42929. * Experimental Internal Use Only.
  42930. *
  42931. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42932. * This acts as a helper to set the primary color to a more "human friendly" value.
  42933. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42934. * output color as close as possible from the chosen value.
  42935. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42936. * part of lighting setup.)
  42937. */
  42938. _perceptualColor: Nullable<Color3>;
  42939. protected _primaryColorShadowLevel: float;
  42940. /**
  42941. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42942. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42943. */
  42944. primaryColorShadowLevel: float;
  42945. protected _primaryColorHighlightLevel: float;
  42946. /**
  42947. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42948. * The primary color is used at the level chosen to define what the white area would look.
  42949. */
  42950. primaryColorHighlightLevel: float;
  42951. protected _reflectionTexture: Nullable<BaseTexture>;
  42952. /**
  42953. * Reflection Texture used in the material.
  42954. * Should be author in a specific way for the best result (refer to the documentation).
  42955. */
  42956. reflectionTexture: Nullable<BaseTexture>;
  42957. protected _reflectionBlur: float;
  42958. /**
  42959. * Reflection Texture level of blur.
  42960. *
  42961. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42962. * texture twice.
  42963. */
  42964. reflectionBlur: float;
  42965. protected _diffuseTexture: Nullable<BaseTexture>;
  42966. /**
  42967. * Diffuse Texture used in the material.
  42968. * Should be author in a specific way for the best result (refer to the documentation).
  42969. */
  42970. diffuseTexture: Nullable<BaseTexture>;
  42971. protected _shadowLights: Nullable<IShadowLight[]>;
  42972. /**
  42973. * Specify the list of lights casting shadow on the material.
  42974. * All scene shadow lights will be included if null.
  42975. */
  42976. shadowLights: Nullable<IShadowLight[]>;
  42977. protected _shadowLevel: float;
  42978. /**
  42979. * Helps adjusting the shadow to a softer level if required.
  42980. * 0 means black shadows and 1 means no shadows.
  42981. */
  42982. shadowLevel: float;
  42983. protected _sceneCenter: Vector3;
  42984. /**
  42985. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42986. * It is usually zero but might be interesting to modify according to your setup.
  42987. */
  42988. sceneCenter: Vector3;
  42989. protected _opacityFresnel: boolean;
  42990. /**
  42991. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42992. * This helps ensuring a nice transition when the camera goes under the ground.
  42993. */
  42994. opacityFresnel: boolean;
  42995. protected _reflectionFresnel: boolean;
  42996. /**
  42997. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42998. * This helps adding a mirror texture on the ground.
  42999. */
  43000. reflectionFresnel: boolean;
  43001. protected _reflectionFalloffDistance: number;
  43002. /**
  43003. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43004. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43005. */
  43006. reflectionFalloffDistance: number;
  43007. protected _reflectionAmount: number;
  43008. /**
  43009. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43010. */
  43011. reflectionAmount: number;
  43012. protected _reflectionReflectance0: number;
  43013. /**
  43014. * This specifies the weight of the reflection at grazing angle.
  43015. */
  43016. reflectionReflectance0: number;
  43017. protected _reflectionReflectance90: number;
  43018. /**
  43019. * This specifies the weight of the reflection at a perpendicular point of view.
  43020. */
  43021. reflectionReflectance90: number;
  43022. /**
  43023. * Sets the reflection reflectance fresnel values according to the default standard
  43024. * empirically know to work well :-)
  43025. */
  43026. reflectionStandardFresnelWeight: number;
  43027. protected _useRGBColor: boolean;
  43028. /**
  43029. * Helps to directly use the maps channels instead of their level.
  43030. */
  43031. useRGBColor: boolean;
  43032. protected _enableNoise: boolean;
  43033. /**
  43034. * This helps reducing the banding effect that could occur on the background.
  43035. */
  43036. enableNoise: boolean;
  43037. /**
  43038. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43039. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43040. * Recommended to be keep at 1.0 except for special cases.
  43041. */
  43042. fovMultiplier: number;
  43043. private _fovMultiplier;
  43044. /**
  43045. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43046. */
  43047. useEquirectangularFOV: boolean;
  43048. private _maxSimultaneousLights;
  43049. /**
  43050. * Number of Simultaneous lights allowed on the material.
  43051. */
  43052. maxSimultaneousLights: int;
  43053. /**
  43054. * Default configuration related to image processing available in the Background Material.
  43055. */
  43056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43057. /**
  43058. * Keep track of the image processing observer to allow dispose and replace.
  43059. */
  43060. private _imageProcessingObserver;
  43061. /**
  43062. * Attaches a new image processing configuration to the PBR Material.
  43063. * @param configuration (if null the scene configuration will be use)
  43064. */
  43065. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43066. /**
  43067. * Gets the image processing configuration used either in this material.
  43068. */
  43069. /**
  43070. * Sets the Default image processing configuration used either in the this material.
  43071. *
  43072. * If sets to null, the scene one is in use.
  43073. */
  43074. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43075. /**
  43076. * Gets wether the color curves effect is enabled.
  43077. */
  43078. /**
  43079. * Sets wether the color curves effect is enabled.
  43080. */
  43081. cameraColorCurvesEnabled: boolean;
  43082. /**
  43083. * Gets wether the color grading effect is enabled.
  43084. */
  43085. /**
  43086. * Gets wether the color grading effect is enabled.
  43087. */
  43088. cameraColorGradingEnabled: boolean;
  43089. /**
  43090. * Gets wether tonemapping is enabled or not.
  43091. */
  43092. /**
  43093. * Sets wether tonemapping is enabled or not
  43094. */
  43095. cameraToneMappingEnabled: boolean;
  43096. /**
  43097. * The camera exposure used on this material.
  43098. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43099. * This corresponds to a photographic exposure.
  43100. */
  43101. /**
  43102. * The camera exposure used on this material.
  43103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43104. * This corresponds to a photographic exposure.
  43105. */
  43106. cameraExposure: float;
  43107. /**
  43108. * Gets The camera contrast used on this material.
  43109. */
  43110. /**
  43111. * Sets The camera contrast used on this material.
  43112. */
  43113. cameraContrast: float;
  43114. /**
  43115. * Gets the Color Grading 2D Lookup Texture.
  43116. */
  43117. /**
  43118. * Sets the Color Grading 2D Lookup Texture.
  43119. */
  43120. cameraColorGradingTexture: Nullable<BaseTexture>;
  43121. /**
  43122. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43123. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43124. * 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;
  43125. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43126. */
  43127. /**
  43128. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43129. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43130. * 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;
  43131. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43132. */
  43133. cameraColorCurves: Nullable<ColorCurves>;
  43134. /**
  43135. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43136. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43137. */
  43138. switchToBGR: boolean;
  43139. private _renderTargets;
  43140. private _reflectionControls;
  43141. private _white;
  43142. private _primaryShadowColor;
  43143. private _primaryHighlightColor;
  43144. /**
  43145. * Instantiates a Background Material in the given scene
  43146. * @param name The friendly name of the material
  43147. * @param scene The scene to add the material to
  43148. */
  43149. constructor(name: string, scene: Scene);
  43150. /**
  43151. * Gets a boolean indicating that current material needs to register RTT
  43152. */
  43153. readonly hasRenderTargetTextures: boolean;
  43154. /**
  43155. * The entire material has been created in order to prevent overdraw.
  43156. * @returns false
  43157. */
  43158. needAlphaTesting(): boolean;
  43159. /**
  43160. * The entire material has been created in order to prevent overdraw.
  43161. * @returns true if blending is enable
  43162. */
  43163. needAlphaBlending(): boolean;
  43164. /**
  43165. * Checks wether the material is ready to be rendered for a given mesh.
  43166. * @param mesh The mesh to render
  43167. * @param subMesh The submesh to check against
  43168. * @param useInstances Specify wether or not the material is used with instances
  43169. * @returns true if all the dependencies are ready (Textures, Effects...)
  43170. */
  43171. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43172. /**
  43173. * Compute the primary color according to the chosen perceptual color.
  43174. */
  43175. private _computePrimaryColorFromPerceptualColor;
  43176. /**
  43177. * Compute the highlights and shadow colors according to their chosen levels.
  43178. */
  43179. private _computePrimaryColors;
  43180. /**
  43181. * Build the uniform buffer used in the material.
  43182. */
  43183. buildUniformLayout(): void;
  43184. /**
  43185. * Unbind the material.
  43186. */
  43187. unbind(): void;
  43188. /**
  43189. * Bind only the world matrix to the material.
  43190. * @param world The world matrix to bind.
  43191. */
  43192. bindOnlyWorldMatrix(world: Matrix): void;
  43193. /**
  43194. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43195. * @param world The world matrix to bind.
  43196. * @param subMesh The submesh to bind for.
  43197. */
  43198. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43199. /**
  43200. * Dispose the material.
  43201. * @param forceDisposeEffect Force disposal of the associated effect.
  43202. * @param forceDisposeTextures Force disposal of the associated textures.
  43203. */
  43204. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43205. /**
  43206. * Clones the material.
  43207. * @param name The cloned name.
  43208. * @returns The cloned material.
  43209. */
  43210. clone(name: string): BackgroundMaterial;
  43211. /**
  43212. * Serializes the current material to its JSON representation.
  43213. * @returns The JSON representation.
  43214. */
  43215. serialize(): any;
  43216. /**
  43217. * Gets the class name of the material
  43218. * @returns "BackgroundMaterial"
  43219. */
  43220. getClassName(): string;
  43221. /**
  43222. * Parse a JSON input to create back a background material.
  43223. * @param source The JSON data to parse
  43224. * @param scene The scene to create the parsed material in
  43225. * @param rootUrl The root url of the assets the material depends upon
  43226. * @returns the instantiated BackgroundMaterial.
  43227. */
  43228. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43229. }
  43230. }
  43231. declare module BABYLON {
  43232. /**
  43233. * Represents the different options available during the creation of
  43234. * a Environment helper.
  43235. *
  43236. * This can control the default ground, skybox and image processing setup of your scene.
  43237. */
  43238. export interface IEnvironmentHelperOptions {
  43239. /**
  43240. * Specifies wether or not to create a ground.
  43241. * True by default.
  43242. */
  43243. createGround: boolean;
  43244. /**
  43245. * Specifies the ground size.
  43246. * 15 by default.
  43247. */
  43248. groundSize: number;
  43249. /**
  43250. * The texture used on the ground for the main color.
  43251. * Comes from the BabylonJS CDN by default.
  43252. *
  43253. * Remarks: Can be either a texture or a url.
  43254. */
  43255. groundTexture: string | BaseTexture;
  43256. /**
  43257. * The color mixed in the ground texture by default.
  43258. * BabylonJS clearColor by default.
  43259. */
  43260. groundColor: Color3;
  43261. /**
  43262. * Specifies the ground opacity.
  43263. * 1 by default.
  43264. */
  43265. groundOpacity: number;
  43266. /**
  43267. * Enables the ground to receive shadows.
  43268. * True by default.
  43269. */
  43270. enableGroundShadow: boolean;
  43271. /**
  43272. * Helps preventing the shadow to be fully black on the ground.
  43273. * 0.5 by default.
  43274. */
  43275. groundShadowLevel: number;
  43276. /**
  43277. * Creates a mirror texture attach to the ground.
  43278. * false by default.
  43279. */
  43280. enableGroundMirror: boolean;
  43281. /**
  43282. * Specifies the ground mirror size ratio.
  43283. * 0.3 by default as the default kernel is 64.
  43284. */
  43285. groundMirrorSizeRatio: number;
  43286. /**
  43287. * Specifies the ground mirror blur kernel size.
  43288. * 64 by default.
  43289. */
  43290. groundMirrorBlurKernel: number;
  43291. /**
  43292. * Specifies the ground mirror visibility amount.
  43293. * 1 by default
  43294. */
  43295. groundMirrorAmount: number;
  43296. /**
  43297. * Specifies the ground mirror reflectance weight.
  43298. * This uses the standard weight of the background material to setup the fresnel effect
  43299. * of the mirror.
  43300. * 1 by default.
  43301. */
  43302. groundMirrorFresnelWeight: number;
  43303. /**
  43304. * Specifies the ground mirror Falloff distance.
  43305. * This can helps reducing the size of the reflection.
  43306. * 0 by Default.
  43307. */
  43308. groundMirrorFallOffDistance: number;
  43309. /**
  43310. * Specifies the ground mirror texture type.
  43311. * Unsigned Int by Default.
  43312. */
  43313. groundMirrorTextureType: number;
  43314. /**
  43315. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43316. * the shown objects.
  43317. */
  43318. groundYBias: number;
  43319. /**
  43320. * Specifies wether or not to create a skybox.
  43321. * True by default.
  43322. */
  43323. createSkybox: boolean;
  43324. /**
  43325. * Specifies the skybox size.
  43326. * 20 by default.
  43327. */
  43328. skyboxSize: number;
  43329. /**
  43330. * The texture used on the skybox for the main color.
  43331. * Comes from the BabylonJS CDN by default.
  43332. *
  43333. * Remarks: Can be either a texture or a url.
  43334. */
  43335. skyboxTexture: string | BaseTexture;
  43336. /**
  43337. * The color mixed in the skybox texture by default.
  43338. * BabylonJS clearColor by default.
  43339. */
  43340. skyboxColor: Color3;
  43341. /**
  43342. * The background rotation around the Y axis of the scene.
  43343. * This helps aligning the key lights of your scene with the background.
  43344. * 0 by default.
  43345. */
  43346. backgroundYRotation: number;
  43347. /**
  43348. * Compute automatically the size of the elements to best fit with the scene.
  43349. */
  43350. sizeAuto: boolean;
  43351. /**
  43352. * Default position of the rootMesh if autoSize is not true.
  43353. */
  43354. rootPosition: Vector3;
  43355. /**
  43356. * Sets up the image processing in the scene.
  43357. * true by default.
  43358. */
  43359. setupImageProcessing: boolean;
  43360. /**
  43361. * The texture used as your environment texture in the scene.
  43362. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43363. *
  43364. * Remarks: Can be either a texture or a url.
  43365. */
  43366. environmentTexture: string | BaseTexture;
  43367. /**
  43368. * The value of the exposure to apply to the scene.
  43369. * 0.6 by default if setupImageProcessing is true.
  43370. */
  43371. cameraExposure: number;
  43372. /**
  43373. * The value of the contrast to apply to the scene.
  43374. * 1.6 by default if setupImageProcessing is true.
  43375. */
  43376. cameraContrast: number;
  43377. /**
  43378. * Specifies wether or not tonemapping should be enabled in the scene.
  43379. * true by default if setupImageProcessing is true.
  43380. */
  43381. toneMappingEnabled: boolean;
  43382. }
  43383. /**
  43384. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43385. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43386. * It also helps with the default setup of your imageProcessing configuration.
  43387. */
  43388. export class EnvironmentHelper {
  43389. /**
  43390. * Default ground texture URL.
  43391. */
  43392. private static _groundTextureCDNUrl;
  43393. /**
  43394. * Default skybox texture URL.
  43395. */
  43396. private static _skyboxTextureCDNUrl;
  43397. /**
  43398. * Default environment texture URL.
  43399. */
  43400. private static _environmentTextureCDNUrl;
  43401. /**
  43402. * Creates the default options for the helper.
  43403. */
  43404. private static _getDefaultOptions;
  43405. private _rootMesh;
  43406. /**
  43407. * Gets the root mesh created by the helper.
  43408. */
  43409. readonly rootMesh: Mesh;
  43410. private _skybox;
  43411. /**
  43412. * Gets the skybox created by the helper.
  43413. */
  43414. readonly skybox: Nullable<Mesh>;
  43415. private _skyboxTexture;
  43416. /**
  43417. * Gets the skybox texture created by the helper.
  43418. */
  43419. readonly skyboxTexture: Nullable<BaseTexture>;
  43420. private _skyboxMaterial;
  43421. /**
  43422. * Gets the skybox material created by the helper.
  43423. */
  43424. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43425. private _ground;
  43426. /**
  43427. * Gets the ground mesh created by the helper.
  43428. */
  43429. readonly ground: Nullable<Mesh>;
  43430. private _groundTexture;
  43431. /**
  43432. * Gets the ground texture created by the helper.
  43433. */
  43434. readonly groundTexture: Nullable<BaseTexture>;
  43435. private _groundMirror;
  43436. /**
  43437. * Gets the ground mirror created by the helper.
  43438. */
  43439. readonly groundMirror: Nullable<MirrorTexture>;
  43440. /**
  43441. * Gets the ground mirror render list to helps pushing the meshes
  43442. * you wish in the ground reflection.
  43443. */
  43444. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43445. private _groundMaterial;
  43446. /**
  43447. * Gets the ground material created by the helper.
  43448. */
  43449. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43450. /**
  43451. * Stores the creation options.
  43452. */
  43453. private readonly _scene;
  43454. private _options;
  43455. /**
  43456. * This observable will be notified with any error during the creation of the environment,
  43457. * mainly texture creation errors.
  43458. */
  43459. onErrorObservable: Observable<{
  43460. message?: string;
  43461. exception?: any;
  43462. }>;
  43463. /**
  43464. * constructor
  43465. * @param options Defines the options we want to customize the helper
  43466. * @param scene The scene to add the material to
  43467. */
  43468. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43469. /**
  43470. * Updates the background according to the new options
  43471. * @param options
  43472. */
  43473. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43474. /**
  43475. * Sets the primary color of all the available elements.
  43476. * @param color the main color to affect to the ground and the background
  43477. */
  43478. setMainColor(color: Color3): void;
  43479. /**
  43480. * Setup the image processing according to the specified options.
  43481. */
  43482. private _setupImageProcessing;
  43483. /**
  43484. * Setup the environment texture according to the specified options.
  43485. */
  43486. private _setupEnvironmentTexture;
  43487. /**
  43488. * Setup the background according to the specified options.
  43489. */
  43490. private _setupBackground;
  43491. /**
  43492. * Get the scene sizes according to the setup.
  43493. */
  43494. private _getSceneSize;
  43495. /**
  43496. * Setup the ground according to the specified options.
  43497. */
  43498. private _setupGround;
  43499. /**
  43500. * Setup the ground material according to the specified options.
  43501. */
  43502. private _setupGroundMaterial;
  43503. /**
  43504. * Setup the ground diffuse texture according to the specified options.
  43505. */
  43506. private _setupGroundDiffuseTexture;
  43507. /**
  43508. * Setup the ground mirror texture according to the specified options.
  43509. */
  43510. private _setupGroundMirrorTexture;
  43511. /**
  43512. * Setup the ground to receive the mirror texture.
  43513. */
  43514. private _setupMirrorInGroundMaterial;
  43515. /**
  43516. * Setup the skybox according to the specified options.
  43517. */
  43518. private _setupSkybox;
  43519. /**
  43520. * Setup the skybox material according to the specified options.
  43521. */
  43522. private _setupSkyboxMaterial;
  43523. /**
  43524. * Setup the skybox reflection texture according to the specified options.
  43525. */
  43526. private _setupSkyboxReflectionTexture;
  43527. private _errorHandler;
  43528. /**
  43529. * Dispose all the elements created by the Helper.
  43530. */
  43531. dispose(): void;
  43532. }
  43533. }
  43534. declare module BABYLON {
  43535. /**
  43536. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43537. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43538. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43539. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43540. */
  43541. export class PhotoDome extends TransformNode {
  43542. private _useDirectMapping;
  43543. /**
  43544. * The texture being displayed on the sphere
  43545. */
  43546. protected _photoTexture: Texture;
  43547. /**
  43548. * Gets or sets the texture being displayed on the sphere
  43549. */
  43550. photoTexture: Texture;
  43551. /**
  43552. * Observable raised when an error occured while loading the 360 image
  43553. */
  43554. onLoadErrorObservable: Observable<string>;
  43555. /**
  43556. * The skybox material
  43557. */
  43558. protected _material: BackgroundMaterial;
  43559. /**
  43560. * The surface used for the skybox
  43561. */
  43562. protected _mesh: Mesh;
  43563. /**
  43564. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43565. * Also see the options.resolution property.
  43566. */
  43567. fovMultiplier: number;
  43568. /**
  43569. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43570. * @param name Element's name, child elements will append suffixes for their own names.
  43571. * @param urlsOfPhoto defines the url of the photo to display
  43572. * @param options defines an object containing optional or exposed sub element properties
  43573. * @param onError defines a callback called when an error occured while loading the texture
  43574. */
  43575. constructor(name: string, urlOfPhoto: string, options: {
  43576. resolution?: number;
  43577. size?: number;
  43578. useDirectMapping?: boolean;
  43579. faceForward?: boolean;
  43580. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43581. /**
  43582. * Releases resources associated with this node.
  43583. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43584. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43585. */
  43586. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43587. }
  43588. }
  43589. declare module BABYLON {
  43590. /** @hidden */
  43591. export var rgbdDecodePixelShader: {
  43592. name: string;
  43593. shader: string;
  43594. };
  43595. }
  43596. declare module BABYLON {
  43597. /**
  43598. * Class used to host texture specific utilities
  43599. */
  43600. export class BRDFTextureTools {
  43601. /**
  43602. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43603. * @param texture the texture to expand.
  43604. */
  43605. private static _ExpandDefaultBRDFTexture;
  43606. /**
  43607. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43608. * @param scene defines the hosting scene
  43609. * @returns the environment BRDF texture
  43610. */
  43611. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43612. private static _environmentBRDFBase64Texture;
  43613. }
  43614. }
  43615. declare module BABYLON {
  43616. /**
  43617. * @hidden
  43618. */
  43619. export interface IMaterialClearCoatDefines {
  43620. CLEARCOAT: boolean;
  43621. CLEARCOAT_DEFAULTIOR: boolean;
  43622. CLEARCOAT_TEXTURE: boolean;
  43623. CLEARCOAT_TEXTUREDIRECTUV: number;
  43624. CLEARCOAT_BUMP: boolean;
  43625. CLEARCOAT_BUMPDIRECTUV: number;
  43626. CLEARCOAT_TINT: boolean;
  43627. CLEARCOAT_TINT_TEXTURE: boolean;
  43628. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43629. /** @hidden */
  43630. _areTexturesDirty: boolean;
  43631. }
  43632. /**
  43633. * Define the code related to the clear coat parameters of the pbr material.
  43634. */
  43635. export class PBRClearCoatConfiguration {
  43636. /**
  43637. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43638. * The default fits with a polyurethane material.
  43639. */
  43640. private static readonly _DefaultIndiceOfRefraction;
  43641. private _isEnabled;
  43642. /**
  43643. * Defines if the clear coat is enabled in the material.
  43644. */
  43645. isEnabled: boolean;
  43646. /**
  43647. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43648. */
  43649. intensity: number;
  43650. /**
  43651. * Defines the clear coat layer roughness.
  43652. */
  43653. roughness: number;
  43654. private _indiceOfRefraction;
  43655. /**
  43656. * Defines the indice of refraction of the clear coat.
  43657. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43658. * The default fits with a polyurethane material.
  43659. * Changing the default value is more performance intensive.
  43660. */
  43661. indiceOfRefraction: number;
  43662. private _texture;
  43663. /**
  43664. * Stores the clear coat values in a texture.
  43665. */
  43666. texture: Nullable<BaseTexture>;
  43667. private _bumpTexture;
  43668. /**
  43669. * Define the clear coat specific bump texture.
  43670. */
  43671. bumpTexture: Nullable<BaseTexture>;
  43672. private _isTintEnabled;
  43673. /**
  43674. * Defines if the clear coat tint is enabled in the material.
  43675. */
  43676. isTintEnabled: boolean;
  43677. /**
  43678. * Defines the clear coat tint of the material.
  43679. * This is only use if tint is enabled
  43680. */
  43681. tintColor: Color3;
  43682. /**
  43683. * Defines the distance at which the tint color should be found in the
  43684. * clear coat media.
  43685. * This is only use if tint is enabled
  43686. */
  43687. tintColorAtDistance: number;
  43688. /**
  43689. * Defines the clear coat layer thickness.
  43690. * This is only use if tint is enabled
  43691. */
  43692. tintThickness: number;
  43693. private _tintTexture;
  43694. /**
  43695. * Stores the clear tint values in a texture.
  43696. * rgb is tint
  43697. * a is a thickness factor
  43698. */
  43699. tintTexture: Nullable<BaseTexture>;
  43700. /** @hidden */
  43701. private _internalMarkAllSubMeshesAsTexturesDirty;
  43702. /** @hidden */
  43703. _markAllSubMeshesAsTexturesDirty(): void;
  43704. /**
  43705. * Instantiate a new istance of clear coat configuration.
  43706. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43707. */
  43708. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43709. /**
  43710. * Gets wehter the submesh is ready to be used or not.
  43711. * @param defines the list of "defines" to update.
  43712. * @param scene defines the scene the material belongs to.
  43713. * @param engine defines the engine the material belongs to.
  43714. * @param disableBumpMap defines wether the material disables bump or not.
  43715. * @returns - boolean indicating that the submesh is ready or not.
  43716. */
  43717. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43718. /**
  43719. * Checks to see if a texture is used in the material.
  43720. * @param defines the list of "defines" to update.
  43721. * @param scene defines the scene to the material belongs to.
  43722. */
  43723. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43724. /**
  43725. * Binds the material data.
  43726. * @param uniformBuffer defines the Uniform buffer to fill in.
  43727. * @param scene defines the scene the material belongs to.
  43728. * @param engine defines the engine the material belongs to.
  43729. * @param disableBumpMap defines wether the material disables bump or not.
  43730. * @param isFrozen defines wether the material is frozen or not.
  43731. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43732. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43733. */
  43734. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43735. /**
  43736. * Checks to see if a texture is used in the material.
  43737. * @param texture - Base texture to use.
  43738. * @returns - Boolean specifying if a texture is used in the material.
  43739. */
  43740. hasTexture(texture: BaseTexture): boolean;
  43741. /**
  43742. * Returns an array of the actively used textures.
  43743. * @param activeTextures Array of BaseTextures
  43744. */
  43745. getActiveTextures(activeTextures: BaseTexture[]): void;
  43746. /**
  43747. * Returns the animatable textures.
  43748. * @param animatables Array of animatable textures.
  43749. */
  43750. getAnimatables(animatables: IAnimatable[]): void;
  43751. /**
  43752. * Disposes the resources of the material.
  43753. * @param forceDisposeTextures - Forces the disposal of all textures.
  43754. */
  43755. dispose(forceDisposeTextures?: boolean): void;
  43756. /**
  43757. * Get the current class name of the texture useful for serialization or dynamic coding.
  43758. * @returns "PBRClearCoatConfiguration"
  43759. */
  43760. getClassName(): string;
  43761. /**
  43762. * Add fallbacks to the effect fallbacks list.
  43763. * @param defines defines the Base texture to use.
  43764. * @param fallbacks defines the current fallback list.
  43765. * @param currentRank defines the current fallback rank.
  43766. * @returns the new fallback rank.
  43767. */
  43768. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43769. /**
  43770. * Add the required uniforms to the current list.
  43771. * @param uniforms defines the current uniform list.
  43772. */
  43773. static AddUniforms(uniforms: string[]): void;
  43774. /**
  43775. * Add the required samplers to the current list.
  43776. * @param samplers defines the current sampler list.
  43777. */
  43778. static AddSamplers(samplers: string[]): void;
  43779. /**
  43780. * Add the required uniforms to the current buffer.
  43781. * @param uniformBuffer defines the current uniform buffer.
  43782. */
  43783. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43784. /**
  43785. * Makes a duplicate of the current configuration into another one.
  43786. * @param clearCoatConfiguration define the config where to copy the info
  43787. */
  43788. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43789. /**
  43790. * Serializes this clear coat configuration.
  43791. * @returns - An object with the serialized config.
  43792. */
  43793. serialize(): any;
  43794. /**
  43795. * Parses a Clear Coat Configuration from a serialized object.
  43796. * @param source - Serialized object.
  43797. */
  43798. parse(source: any): void;
  43799. }
  43800. }
  43801. declare module BABYLON {
  43802. /**
  43803. * @hidden
  43804. */
  43805. export interface IMaterialAnisotropicDefines {
  43806. ANISOTROPIC: boolean;
  43807. ANISOTROPIC_TEXTURE: boolean;
  43808. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43809. MAINUV1: boolean;
  43810. _areTexturesDirty: boolean;
  43811. _needUVs: boolean;
  43812. }
  43813. /**
  43814. * Define the code related to the anisotropic parameters of the pbr material.
  43815. */
  43816. export class PBRAnisotropicConfiguration {
  43817. private _isEnabled;
  43818. /**
  43819. * Defines if the anisotropy is enabled in the material.
  43820. */
  43821. isEnabled: boolean;
  43822. /**
  43823. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43824. */
  43825. intensity: number;
  43826. /**
  43827. * Defines if the effect is along the tangents, bitangents or in between.
  43828. * By default, the effect is "strectching" the highlights along the tangents.
  43829. */
  43830. direction: Vector2;
  43831. private _texture;
  43832. /**
  43833. * Stores the anisotropy values in a texture.
  43834. * rg is direction (like normal from -1 to 1)
  43835. * b is a intensity
  43836. */
  43837. texture: Nullable<BaseTexture>;
  43838. /** @hidden */
  43839. private _internalMarkAllSubMeshesAsTexturesDirty;
  43840. /** @hidden */
  43841. _markAllSubMeshesAsTexturesDirty(): void;
  43842. /**
  43843. * Instantiate a new istance of anisotropy configuration.
  43844. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43845. */
  43846. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43847. /**
  43848. * Specifies that the submesh is ready to be used.
  43849. * @param defines the list of "defines" to update.
  43850. * @param scene defines the scene the material belongs to.
  43851. * @returns - boolean indicating that the submesh is ready or not.
  43852. */
  43853. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43854. /**
  43855. * Checks to see if a texture is used in the material.
  43856. * @param defines the list of "defines" to update.
  43857. * @param mesh the mesh we are preparing the defines for.
  43858. * @param scene defines the scene the material belongs to.
  43859. */
  43860. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43861. /**
  43862. * Binds the material data.
  43863. * @param uniformBuffer defines the Uniform buffer to fill in.
  43864. * @param scene defines the scene the material belongs to.
  43865. * @param isFrozen defines wether the material is frozen or not.
  43866. */
  43867. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43868. /**
  43869. * Checks to see if a texture is used in the material.
  43870. * @param texture - Base texture to use.
  43871. * @returns - Boolean specifying if a texture is used in the material.
  43872. */
  43873. hasTexture(texture: BaseTexture): boolean;
  43874. /**
  43875. * Returns an array of the actively used textures.
  43876. * @param activeTextures Array of BaseTextures
  43877. */
  43878. getActiveTextures(activeTextures: BaseTexture[]): void;
  43879. /**
  43880. * Returns the animatable textures.
  43881. * @param animatables Array of animatable textures.
  43882. */
  43883. getAnimatables(animatables: IAnimatable[]): void;
  43884. /**
  43885. * Disposes the resources of the material.
  43886. * @param forceDisposeTextures - Forces the disposal of all textures.
  43887. */
  43888. dispose(forceDisposeTextures?: boolean): void;
  43889. /**
  43890. * Get the current class name of the texture useful for serialization or dynamic coding.
  43891. * @returns "PBRAnisotropicConfiguration"
  43892. */
  43893. getClassName(): string;
  43894. /**
  43895. * Add fallbacks to the effect fallbacks list.
  43896. * @param defines defines the Base texture to use.
  43897. * @param fallbacks defines the current fallback list.
  43898. * @param currentRank defines the current fallback rank.
  43899. * @returns the new fallback rank.
  43900. */
  43901. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43902. /**
  43903. * Add the required uniforms to the current list.
  43904. * @param uniforms defines the current uniform list.
  43905. */
  43906. static AddUniforms(uniforms: string[]): void;
  43907. /**
  43908. * Add the required uniforms to the current buffer.
  43909. * @param uniformBuffer defines the current uniform buffer.
  43910. */
  43911. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43912. /**
  43913. * Add the required samplers to the current list.
  43914. * @param samplers defines the current sampler list.
  43915. */
  43916. static AddSamplers(samplers: string[]): void;
  43917. /**
  43918. * Makes a duplicate of the current configuration into another one.
  43919. * @param anisotropicConfiguration define the config where to copy the info
  43920. */
  43921. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43922. /**
  43923. * Serializes this anisotropy configuration.
  43924. * @returns - An object with the serialized config.
  43925. */
  43926. serialize(): any;
  43927. /**
  43928. * Parses a anisotropy Configuration from a serialized object.
  43929. * @param source - Serialized object.
  43930. */
  43931. parse(source: any): void;
  43932. }
  43933. }
  43934. declare module BABYLON {
  43935. /**
  43936. * @hidden
  43937. */
  43938. export interface IMaterialBRDFDefines {
  43939. BRDF_V_HEIGHT_CORRELATED: boolean;
  43940. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43941. /** @hidden */
  43942. _areMiscDirty: boolean;
  43943. }
  43944. /**
  43945. * Define the code related to the BRDF parameters of the pbr material.
  43946. */
  43947. export class PBRBRDFConfiguration {
  43948. /**
  43949. * Default value used for the energy conservation.
  43950. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43951. */
  43952. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43953. /**
  43954. * Default value used for the Smith Visibility Height Correlated mode.
  43955. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43956. */
  43957. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43958. private _useEnergyConservation;
  43959. /**
  43960. * Defines if the material uses energy conservation.
  43961. */
  43962. useEnergyConservation: boolean;
  43963. private _useSmithVisibilityHeightCorrelated;
  43964. /**
  43965. * LEGACY Mode set to false
  43966. * Defines if the material uses height smith correlated visibility term.
  43967. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43968. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43969. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43970. * Not relying on height correlated will also disable energy conservation.
  43971. */
  43972. useSmithVisibilityHeightCorrelated: boolean;
  43973. /** @hidden */
  43974. private _internalMarkAllSubMeshesAsMiscDirty;
  43975. /** @hidden */
  43976. _markAllSubMeshesAsMiscDirty(): void;
  43977. /**
  43978. * Instantiate a new istance of clear coat configuration.
  43979. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43980. */
  43981. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43982. /**
  43983. * Checks to see if a texture is used in the material.
  43984. * @param defines the list of "defines" to update.
  43985. */
  43986. prepareDefines(defines: IMaterialBRDFDefines): void;
  43987. /**
  43988. * Get the current class name of the texture useful for serialization or dynamic coding.
  43989. * @returns "PBRClearCoatConfiguration"
  43990. */
  43991. getClassName(): string;
  43992. /**
  43993. * Makes a duplicate of the current configuration into another one.
  43994. * @param brdfConfiguration define the config where to copy the info
  43995. */
  43996. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43997. /**
  43998. * Serializes this BRDF configuration.
  43999. * @returns - An object with the serialized config.
  44000. */
  44001. serialize(): any;
  44002. /**
  44003. * Parses a BRDF Configuration from a serialized object.
  44004. * @param source - Serialized object.
  44005. */
  44006. parse(source: any): void;
  44007. }
  44008. }
  44009. declare module BABYLON {
  44010. /**
  44011. * @hidden
  44012. */
  44013. export interface IMaterialSheenDefines {
  44014. SHEEN: boolean;
  44015. SHEEN_TEXTURE: boolean;
  44016. SHEEN_TEXTUREDIRECTUV: number;
  44017. SHEEN_LINKWITHALBEDO: boolean;
  44018. /** @hidden */
  44019. _areTexturesDirty: boolean;
  44020. }
  44021. /**
  44022. * Define the code related to the Sheen parameters of the pbr material.
  44023. */
  44024. export class PBRSheenConfiguration {
  44025. private _isEnabled;
  44026. /**
  44027. * Defines if the material uses sheen.
  44028. */
  44029. isEnabled: boolean;
  44030. private _linkSheenWithAlbedo;
  44031. /**
  44032. * Defines if the sheen is linked to the sheen color.
  44033. */
  44034. linkSheenWithAlbedo: boolean;
  44035. /**
  44036. * Defines the sheen intensity.
  44037. */
  44038. intensity: number;
  44039. /**
  44040. * Defines the sheen color.
  44041. */
  44042. color: Color3;
  44043. private _texture;
  44044. /**
  44045. * Stores the sheen tint values in a texture.
  44046. * rgb is tint
  44047. * a is a intensity
  44048. */
  44049. texture: Nullable<BaseTexture>;
  44050. /** @hidden */
  44051. private _internalMarkAllSubMeshesAsTexturesDirty;
  44052. /** @hidden */
  44053. _markAllSubMeshesAsTexturesDirty(): void;
  44054. /**
  44055. * Instantiate a new istance of clear coat configuration.
  44056. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44057. */
  44058. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44059. /**
  44060. * Specifies that the submesh is ready to be used.
  44061. * @param defines the list of "defines" to update.
  44062. * @param scene defines the scene the material belongs to.
  44063. * @returns - boolean indicating that the submesh is ready or not.
  44064. */
  44065. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44066. /**
  44067. * Checks to see if a texture is used in the material.
  44068. * @param defines the list of "defines" to update.
  44069. * @param scene defines the scene the material belongs to.
  44070. */
  44071. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44072. /**
  44073. * Binds the material data.
  44074. * @param uniformBuffer defines the Uniform buffer to fill in.
  44075. * @param scene defines the scene the material belongs to.
  44076. * @param isFrozen defines wether the material is frozen or not.
  44077. */
  44078. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44079. /**
  44080. * Checks to see if a texture is used in the material.
  44081. * @param texture - Base texture to use.
  44082. * @returns - Boolean specifying if a texture is used in the material.
  44083. */
  44084. hasTexture(texture: BaseTexture): boolean;
  44085. /**
  44086. * Returns an array of the actively used textures.
  44087. * @param activeTextures Array of BaseTextures
  44088. */
  44089. getActiveTextures(activeTextures: BaseTexture[]): void;
  44090. /**
  44091. * Returns the animatable textures.
  44092. * @param animatables Array of animatable textures.
  44093. */
  44094. getAnimatables(animatables: IAnimatable[]): void;
  44095. /**
  44096. * Disposes the resources of the material.
  44097. * @param forceDisposeTextures - Forces the disposal of all textures.
  44098. */
  44099. dispose(forceDisposeTextures?: boolean): void;
  44100. /**
  44101. * Get the current class name of the texture useful for serialization or dynamic coding.
  44102. * @returns "PBRSheenConfiguration"
  44103. */
  44104. getClassName(): string;
  44105. /**
  44106. * Add fallbacks to the effect fallbacks list.
  44107. * @param defines defines the Base texture to use.
  44108. * @param fallbacks defines the current fallback list.
  44109. * @param currentRank defines the current fallback rank.
  44110. * @returns the new fallback rank.
  44111. */
  44112. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44113. /**
  44114. * Add the required uniforms to the current list.
  44115. * @param uniforms defines the current uniform list.
  44116. */
  44117. static AddUniforms(uniforms: string[]): void;
  44118. /**
  44119. * Add the required uniforms to the current buffer.
  44120. * @param uniformBuffer defines the current uniform buffer.
  44121. */
  44122. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44123. /**
  44124. * Add the required samplers to the current list.
  44125. * @param samplers defines the current sampler list.
  44126. */
  44127. static AddSamplers(samplers: string[]): void;
  44128. /**
  44129. * Makes a duplicate of the current configuration into another one.
  44130. * @param sheenConfiguration define the config where to copy the info
  44131. */
  44132. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44133. /**
  44134. * Serializes this BRDF configuration.
  44135. * @returns - An object with the serialized config.
  44136. */
  44137. serialize(): any;
  44138. /**
  44139. * Parses a Sheen Configuration from a serialized object.
  44140. * @param source - Serialized object.
  44141. */
  44142. parse(source: any): void;
  44143. }
  44144. }
  44145. declare module BABYLON {
  44146. /**
  44147. * @hidden
  44148. */
  44149. export interface IMaterialSubSurfaceDefines {
  44150. SUBSURFACE: boolean;
  44151. SS_REFRACTION: boolean;
  44152. SS_TRANSLUCENCY: boolean;
  44153. SS_SCATERRING: boolean;
  44154. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44155. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44156. SS_REFRACTIONMAP_3D: boolean;
  44157. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44158. SS_LODINREFRACTIONALPHA: boolean;
  44159. SS_GAMMAREFRACTION: boolean;
  44160. SS_RGBDREFRACTION: boolean;
  44161. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44162. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44163. /** @hidden */
  44164. _areTexturesDirty: boolean;
  44165. }
  44166. /**
  44167. * Define the code related to the sub surface parameters of the pbr material.
  44168. */
  44169. export class PBRSubSurfaceConfiguration {
  44170. private _isRefractionEnabled;
  44171. /**
  44172. * Defines if the refraction is enabled in the material.
  44173. */
  44174. isRefractionEnabled: boolean;
  44175. private _isTranslucencyEnabled;
  44176. /**
  44177. * Defines if the translucency is enabled in the material.
  44178. */
  44179. isTranslucencyEnabled: boolean;
  44180. private _isScatteringEnabled;
  44181. /**
  44182. * Defines the refraction intensity of the material.
  44183. * The refraction when enabled replaces the Diffuse part of the material.
  44184. * The intensity helps transitionning between diffuse and refraction.
  44185. */
  44186. refractionIntensity: number;
  44187. /**
  44188. * Defines the translucency intensity of the material.
  44189. * When translucency has been enabled, this defines how much of the "translucency"
  44190. * is addded to the diffuse part of the material.
  44191. */
  44192. translucencyIntensity: number;
  44193. /**
  44194. * Defines the scattering intensity of the material.
  44195. * When scattering has been enabled, this defines how much of the "scattered light"
  44196. * is addded to the diffuse part of the material.
  44197. */
  44198. scatteringIntensity: number;
  44199. private _thicknessTexture;
  44200. /**
  44201. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44202. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44203. * 0 would mean minimumThickness
  44204. * 1 would mean maximumThickness
  44205. * The other channels might be use as a mask to vary the different effects intensity.
  44206. */
  44207. thicknessTexture: Nullable<BaseTexture>;
  44208. private _refractionTexture;
  44209. /**
  44210. * Defines the texture to use for refraction.
  44211. */
  44212. refractionTexture: Nullable<BaseTexture>;
  44213. private _indexOfRefraction;
  44214. /**
  44215. * Defines the indice of refraction used in the material.
  44216. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44217. */
  44218. indexOfRefraction: number;
  44219. private _invertRefractionY;
  44220. /**
  44221. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44222. */
  44223. invertRefractionY: boolean;
  44224. private _linkRefractionWithTransparency;
  44225. /**
  44226. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44227. * Materials half opaque for instance using refraction could benefit from this control.
  44228. */
  44229. linkRefractionWithTransparency: boolean;
  44230. /**
  44231. * Defines the minimum thickness stored in the thickness map.
  44232. * If no thickness map is defined, this value will be used to simulate thickness.
  44233. */
  44234. minimumThickness: number;
  44235. /**
  44236. * Defines the maximum thickness stored in the thickness map.
  44237. */
  44238. maximumThickness: number;
  44239. /**
  44240. * Defines the volume tint of the material.
  44241. * This is used for both translucency and scattering.
  44242. */
  44243. tintColor: Color3;
  44244. /**
  44245. * Defines the distance at which the tint color should be found in the media.
  44246. * This is used for refraction only.
  44247. */
  44248. tintColorAtDistance: number;
  44249. /**
  44250. * Defines how far each channel transmit through the media.
  44251. * It is defined as a color to simplify it selection.
  44252. */
  44253. diffusionDistance: Color3;
  44254. private _useMaskFromThicknessTexture;
  44255. /**
  44256. * Stores the intensity of the different subsurface effects in the thickness texture.
  44257. * * the green channel is the translucency intensity.
  44258. * * the blue channel is the scattering intensity.
  44259. * * the alpha channel is the refraction intensity.
  44260. */
  44261. useMaskFromThicknessTexture: boolean;
  44262. /** @hidden */
  44263. private _internalMarkAllSubMeshesAsTexturesDirty;
  44264. /** @hidden */
  44265. _markAllSubMeshesAsTexturesDirty(): void;
  44266. /**
  44267. * Instantiate a new istance of sub surface configuration.
  44268. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44269. */
  44270. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44271. /**
  44272. * Gets wehter the submesh is ready to be used or not.
  44273. * @param defines the list of "defines" to update.
  44274. * @param scene defines the scene the material belongs to.
  44275. * @returns - boolean indicating that the submesh is ready or not.
  44276. */
  44277. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44278. /**
  44279. * Checks to see if a texture is used in the material.
  44280. * @param defines the list of "defines" to update.
  44281. * @param scene defines the scene to the material belongs to.
  44282. */
  44283. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44284. /**
  44285. * Binds the material data.
  44286. * @param uniformBuffer defines the Uniform buffer to fill in.
  44287. * @param scene defines the scene the material belongs to.
  44288. * @param engine defines the engine the material belongs to.
  44289. * @param isFrozen defines wether the material is frozen or not.
  44290. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44291. */
  44292. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44293. /**
  44294. * Unbinds the material from the mesh.
  44295. * @param activeEffect defines the effect that should be unbound from.
  44296. * @returns true if unbound, otherwise false
  44297. */
  44298. unbind(activeEffect: Effect): boolean;
  44299. /**
  44300. * Returns the texture used for refraction or null if none is used.
  44301. * @param scene defines the scene the material belongs to.
  44302. * @returns - Refraction texture if present. If no refraction texture and refraction
  44303. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44304. */
  44305. private _getRefractionTexture;
  44306. /**
  44307. * Returns true if alpha blending should be disabled.
  44308. */
  44309. readonly disableAlphaBlending: boolean;
  44310. /**
  44311. * Fills the list of render target textures.
  44312. * @param renderTargets the list of render targets to update
  44313. */
  44314. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44315. /**
  44316. * Checks to see if a texture is used in the material.
  44317. * @param texture - Base texture to use.
  44318. * @returns - Boolean specifying if a texture is used in the material.
  44319. */
  44320. hasTexture(texture: BaseTexture): boolean;
  44321. /**
  44322. * Gets a boolean indicating that current material needs to register RTT
  44323. * @returns true if this uses a render target otherwise false.
  44324. */
  44325. hasRenderTargetTextures(): boolean;
  44326. /**
  44327. * Returns an array of the actively used textures.
  44328. * @param activeTextures Array of BaseTextures
  44329. */
  44330. getActiveTextures(activeTextures: BaseTexture[]): void;
  44331. /**
  44332. * Returns the animatable textures.
  44333. * @param animatables Array of animatable textures.
  44334. */
  44335. getAnimatables(animatables: IAnimatable[]): void;
  44336. /**
  44337. * Disposes the resources of the material.
  44338. * @param forceDisposeTextures - Forces the disposal of all textures.
  44339. */
  44340. dispose(forceDisposeTextures?: boolean): void;
  44341. /**
  44342. * Get the current class name of the texture useful for serialization or dynamic coding.
  44343. * @returns "PBRSubSurfaceConfiguration"
  44344. */
  44345. getClassName(): string;
  44346. /**
  44347. * Add fallbacks to the effect fallbacks list.
  44348. * @param defines defines the Base texture to use.
  44349. * @param fallbacks defines the current fallback list.
  44350. * @param currentRank defines the current fallback rank.
  44351. * @returns the new fallback rank.
  44352. */
  44353. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44354. /**
  44355. * Add the required uniforms to the current list.
  44356. * @param uniforms defines the current uniform list.
  44357. */
  44358. static AddUniforms(uniforms: string[]): void;
  44359. /**
  44360. * Add the required samplers to the current list.
  44361. * @param samplers defines the current sampler list.
  44362. */
  44363. static AddSamplers(samplers: string[]): void;
  44364. /**
  44365. * Add the required uniforms to the current buffer.
  44366. * @param uniformBuffer defines the current uniform buffer.
  44367. */
  44368. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44369. /**
  44370. * Makes a duplicate of the current configuration into another one.
  44371. * @param configuration define the config where to copy the info
  44372. */
  44373. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44374. /**
  44375. * Serializes this Sub Surface configuration.
  44376. * @returns - An object with the serialized config.
  44377. */
  44378. serialize(): any;
  44379. /**
  44380. * Parses a Sub Surface Configuration from a serialized object.
  44381. * @param source - Serialized object.
  44382. */
  44383. parse(source: any): void;
  44384. }
  44385. }
  44386. declare module BABYLON {
  44387. /** @hidden */
  44388. export var pbrFragmentDeclaration: {
  44389. name: string;
  44390. shader: string;
  44391. };
  44392. }
  44393. declare module BABYLON {
  44394. /** @hidden */
  44395. export var pbrUboDeclaration: {
  44396. name: string;
  44397. shader: string;
  44398. };
  44399. }
  44400. declare module BABYLON {
  44401. /** @hidden */
  44402. export var pbrFragmentExtraDeclaration: {
  44403. name: string;
  44404. shader: string;
  44405. };
  44406. }
  44407. declare module BABYLON {
  44408. /** @hidden */
  44409. export var pbrFragmentSamplersDeclaration: {
  44410. name: string;
  44411. shader: string;
  44412. };
  44413. }
  44414. declare module BABYLON {
  44415. /** @hidden */
  44416. export var pbrHelperFunctions: {
  44417. name: string;
  44418. shader: string;
  44419. };
  44420. }
  44421. declare module BABYLON {
  44422. /** @hidden */
  44423. export var harmonicsFunctions: {
  44424. name: string;
  44425. shader: string;
  44426. };
  44427. }
  44428. declare module BABYLON {
  44429. /** @hidden */
  44430. export var pbrDirectLightingSetupFunctions: {
  44431. name: string;
  44432. shader: string;
  44433. };
  44434. }
  44435. declare module BABYLON {
  44436. /** @hidden */
  44437. export var pbrDirectLightingFalloffFunctions: {
  44438. name: string;
  44439. shader: string;
  44440. };
  44441. }
  44442. declare module BABYLON {
  44443. /** @hidden */
  44444. export var pbrBRDFFunctions: {
  44445. name: string;
  44446. shader: string;
  44447. };
  44448. }
  44449. declare module BABYLON {
  44450. /** @hidden */
  44451. export var pbrDirectLightingFunctions: {
  44452. name: string;
  44453. shader: string;
  44454. };
  44455. }
  44456. declare module BABYLON {
  44457. /** @hidden */
  44458. export var pbrIBLFunctions: {
  44459. name: string;
  44460. shader: string;
  44461. };
  44462. }
  44463. declare module BABYLON {
  44464. /** @hidden */
  44465. export var pbrDebug: {
  44466. name: string;
  44467. shader: string;
  44468. };
  44469. }
  44470. declare module BABYLON {
  44471. /** @hidden */
  44472. export var pbrPixelShader: {
  44473. name: string;
  44474. shader: string;
  44475. };
  44476. }
  44477. declare module BABYLON {
  44478. /** @hidden */
  44479. export var pbrVertexDeclaration: {
  44480. name: string;
  44481. shader: string;
  44482. };
  44483. }
  44484. declare module BABYLON {
  44485. /** @hidden */
  44486. export var pbrVertexShader: {
  44487. name: string;
  44488. shader: string;
  44489. };
  44490. }
  44491. declare module BABYLON {
  44492. /**
  44493. * Manages the defines for the PBR Material.
  44494. * @hidden
  44495. */
  44496. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44497. PBR: boolean;
  44498. MAINUV1: boolean;
  44499. MAINUV2: boolean;
  44500. UV1: boolean;
  44501. UV2: boolean;
  44502. ALBEDO: boolean;
  44503. ALBEDODIRECTUV: number;
  44504. VERTEXCOLOR: boolean;
  44505. AMBIENT: boolean;
  44506. AMBIENTDIRECTUV: number;
  44507. AMBIENTINGRAYSCALE: boolean;
  44508. OPACITY: boolean;
  44509. VERTEXALPHA: boolean;
  44510. OPACITYDIRECTUV: number;
  44511. OPACITYRGB: boolean;
  44512. ALPHATEST: boolean;
  44513. DEPTHPREPASS: boolean;
  44514. ALPHABLEND: boolean;
  44515. ALPHAFROMALBEDO: boolean;
  44516. ALPHATESTVALUE: string;
  44517. SPECULAROVERALPHA: boolean;
  44518. RADIANCEOVERALPHA: boolean;
  44519. ALPHAFRESNEL: boolean;
  44520. LINEARALPHAFRESNEL: boolean;
  44521. PREMULTIPLYALPHA: boolean;
  44522. EMISSIVE: boolean;
  44523. EMISSIVEDIRECTUV: number;
  44524. REFLECTIVITY: boolean;
  44525. REFLECTIVITYDIRECTUV: number;
  44526. SPECULARTERM: boolean;
  44527. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44528. MICROSURFACEAUTOMATIC: boolean;
  44529. LODBASEDMICROSFURACE: boolean;
  44530. MICROSURFACEMAP: boolean;
  44531. MICROSURFACEMAPDIRECTUV: number;
  44532. METALLICWORKFLOW: boolean;
  44533. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44534. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44535. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44536. AOSTOREINMETALMAPRED: boolean;
  44537. ENVIRONMENTBRDF: boolean;
  44538. ENVIRONMENTBRDF_RGBD: boolean;
  44539. NORMAL: boolean;
  44540. TANGENT: boolean;
  44541. BUMP: boolean;
  44542. BUMPDIRECTUV: number;
  44543. OBJECTSPACE_NORMALMAP: boolean;
  44544. PARALLAX: boolean;
  44545. PARALLAXOCCLUSION: boolean;
  44546. NORMALXYSCALE: boolean;
  44547. LIGHTMAP: boolean;
  44548. LIGHTMAPDIRECTUV: number;
  44549. USELIGHTMAPASSHADOWMAP: boolean;
  44550. GAMMALIGHTMAP: boolean;
  44551. REFLECTION: boolean;
  44552. REFLECTIONMAP_3D: boolean;
  44553. REFLECTIONMAP_SPHERICAL: boolean;
  44554. REFLECTIONMAP_PLANAR: boolean;
  44555. REFLECTIONMAP_CUBIC: boolean;
  44556. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44557. REFLECTIONMAP_PROJECTION: boolean;
  44558. REFLECTIONMAP_SKYBOX: boolean;
  44559. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44560. REFLECTIONMAP_EXPLICIT: boolean;
  44561. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44562. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44563. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44564. INVERTCUBICMAP: boolean;
  44565. USESPHERICALFROMREFLECTIONMAP: boolean;
  44566. USESPHERICALINVERTEX: boolean;
  44567. REFLECTIONMAP_OPPOSITEZ: boolean;
  44568. LODINREFLECTIONALPHA: boolean;
  44569. GAMMAREFLECTION: boolean;
  44570. RGBDREFLECTION: boolean;
  44571. RADIANCEOCCLUSION: boolean;
  44572. HORIZONOCCLUSION: boolean;
  44573. INSTANCES: boolean;
  44574. NUM_BONE_INFLUENCERS: number;
  44575. BonesPerMesh: number;
  44576. BONETEXTURE: boolean;
  44577. NONUNIFORMSCALING: boolean;
  44578. MORPHTARGETS: boolean;
  44579. MORPHTARGETS_NORMAL: boolean;
  44580. MORPHTARGETS_TANGENT: boolean;
  44581. NUM_MORPH_INFLUENCERS: number;
  44582. IMAGEPROCESSING: boolean;
  44583. VIGNETTE: boolean;
  44584. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44585. VIGNETTEBLENDMODEOPAQUE: boolean;
  44586. TONEMAPPING: boolean;
  44587. TONEMAPPING_ACES: boolean;
  44588. CONTRAST: boolean;
  44589. COLORCURVES: boolean;
  44590. COLORGRADING: boolean;
  44591. COLORGRADING3D: boolean;
  44592. SAMPLER3DGREENDEPTH: boolean;
  44593. SAMPLER3DBGRMAP: boolean;
  44594. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44595. EXPOSURE: boolean;
  44596. MULTIVIEW: boolean;
  44597. USEPHYSICALLIGHTFALLOFF: boolean;
  44598. USEGLTFLIGHTFALLOFF: boolean;
  44599. TWOSIDEDLIGHTING: boolean;
  44600. SHADOWFLOAT: boolean;
  44601. CLIPPLANE: boolean;
  44602. CLIPPLANE2: boolean;
  44603. CLIPPLANE3: boolean;
  44604. CLIPPLANE4: boolean;
  44605. POINTSIZE: boolean;
  44606. FOG: boolean;
  44607. LOGARITHMICDEPTH: boolean;
  44608. FORCENORMALFORWARD: boolean;
  44609. SPECULARAA: boolean;
  44610. CLEARCOAT: boolean;
  44611. CLEARCOAT_DEFAULTIOR: boolean;
  44612. CLEARCOAT_TEXTURE: boolean;
  44613. CLEARCOAT_TEXTUREDIRECTUV: number;
  44614. CLEARCOAT_BUMP: boolean;
  44615. CLEARCOAT_BUMPDIRECTUV: number;
  44616. CLEARCOAT_TINT: boolean;
  44617. CLEARCOAT_TINT_TEXTURE: boolean;
  44618. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44619. ANISOTROPIC: boolean;
  44620. ANISOTROPIC_TEXTURE: boolean;
  44621. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44622. BRDF_V_HEIGHT_CORRELATED: boolean;
  44623. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44624. SHEEN: boolean;
  44625. SHEEN_TEXTURE: boolean;
  44626. SHEEN_TEXTUREDIRECTUV: number;
  44627. SHEEN_LINKWITHALBEDO: boolean;
  44628. SUBSURFACE: boolean;
  44629. SS_REFRACTION: boolean;
  44630. SS_TRANSLUCENCY: boolean;
  44631. SS_SCATERRING: boolean;
  44632. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44633. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44634. SS_REFRACTIONMAP_3D: boolean;
  44635. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44636. SS_LODINREFRACTIONALPHA: boolean;
  44637. SS_GAMMAREFRACTION: boolean;
  44638. SS_RGBDREFRACTION: boolean;
  44639. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44640. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44641. UNLIT: boolean;
  44642. DEBUGMODE: number;
  44643. /**
  44644. * Initializes the PBR Material defines.
  44645. */
  44646. constructor();
  44647. /**
  44648. * Resets the PBR Material defines.
  44649. */
  44650. reset(): void;
  44651. }
  44652. /**
  44653. * The Physically based material base class of BJS.
  44654. *
  44655. * This offers the main features of a standard PBR material.
  44656. * For more information, please refer to the documentation :
  44657. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44658. */
  44659. export abstract class PBRBaseMaterial extends PushMaterial {
  44660. /**
  44661. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44662. */
  44663. static readonly PBRMATERIAL_OPAQUE: number;
  44664. /**
  44665. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44666. */
  44667. static readonly PBRMATERIAL_ALPHATEST: number;
  44668. /**
  44669. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44670. */
  44671. static readonly PBRMATERIAL_ALPHABLEND: number;
  44672. /**
  44673. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44674. * They are also discarded below the alpha cutoff threshold to improve performances.
  44675. */
  44676. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44677. /**
  44678. * Defines the default value of how much AO map is occluding the analytical lights
  44679. * (point spot...).
  44680. */
  44681. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44682. /**
  44683. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44684. */
  44685. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44686. /**
  44687. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44688. * to enhance interoperability with other engines.
  44689. */
  44690. static readonly LIGHTFALLOFF_GLTF: number;
  44691. /**
  44692. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44693. * to enhance interoperability with other materials.
  44694. */
  44695. static readonly LIGHTFALLOFF_STANDARD: number;
  44696. /**
  44697. * Intensity of the direct lights e.g. the four lights available in your scene.
  44698. * This impacts both the direct diffuse and specular highlights.
  44699. */
  44700. protected _directIntensity: number;
  44701. /**
  44702. * Intensity of the emissive part of the material.
  44703. * This helps controlling the emissive effect without modifying the emissive color.
  44704. */
  44705. protected _emissiveIntensity: number;
  44706. /**
  44707. * Intensity of the environment e.g. how much the environment will light the object
  44708. * either through harmonics for rough material or through the refelction for shiny ones.
  44709. */
  44710. protected _environmentIntensity: number;
  44711. /**
  44712. * This is a special control allowing the reduction of the specular highlights coming from the
  44713. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44714. */
  44715. protected _specularIntensity: number;
  44716. /**
  44717. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44718. */
  44719. private _lightingInfos;
  44720. /**
  44721. * Debug Control allowing disabling the bump map on this material.
  44722. */
  44723. protected _disableBumpMap: boolean;
  44724. /**
  44725. * AKA Diffuse Texture in standard nomenclature.
  44726. */
  44727. protected _albedoTexture: BaseTexture;
  44728. /**
  44729. * AKA Occlusion Texture in other nomenclature.
  44730. */
  44731. protected _ambientTexture: BaseTexture;
  44732. /**
  44733. * AKA Occlusion Texture Intensity in other nomenclature.
  44734. */
  44735. protected _ambientTextureStrength: number;
  44736. /**
  44737. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44738. * 1 means it completely occludes it
  44739. * 0 mean it has no impact
  44740. */
  44741. protected _ambientTextureImpactOnAnalyticalLights: number;
  44742. /**
  44743. * Stores the alpha values in a texture.
  44744. */
  44745. protected _opacityTexture: BaseTexture;
  44746. /**
  44747. * Stores the reflection values in a texture.
  44748. */
  44749. protected _reflectionTexture: BaseTexture;
  44750. /**
  44751. * Stores the emissive values in a texture.
  44752. */
  44753. protected _emissiveTexture: BaseTexture;
  44754. /**
  44755. * AKA Specular texture in other nomenclature.
  44756. */
  44757. protected _reflectivityTexture: BaseTexture;
  44758. /**
  44759. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44760. */
  44761. protected _metallicTexture: BaseTexture;
  44762. /**
  44763. * Specifies the metallic scalar of the metallic/roughness workflow.
  44764. * Can also be used to scale the metalness values of the metallic texture.
  44765. */
  44766. protected _metallic: Nullable<number>;
  44767. /**
  44768. * Specifies the roughness scalar of the metallic/roughness workflow.
  44769. * Can also be used to scale the roughness values of the metallic texture.
  44770. */
  44771. protected _roughness: Nullable<number>;
  44772. /**
  44773. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44774. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44775. */
  44776. protected _microSurfaceTexture: BaseTexture;
  44777. /**
  44778. * Stores surface normal data used to displace a mesh in a texture.
  44779. */
  44780. protected _bumpTexture: BaseTexture;
  44781. /**
  44782. * Stores the pre-calculated light information of a mesh in a texture.
  44783. */
  44784. protected _lightmapTexture: BaseTexture;
  44785. /**
  44786. * The color of a material in ambient lighting.
  44787. */
  44788. protected _ambientColor: Color3;
  44789. /**
  44790. * AKA Diffuse Color in other nomenclature.
  44791. */
  44792. protected _albedoColor: Color3;
  44793. /**
  44794. * AKA Specular Color in other nomenclature.
  44795. */
  44796. protected _reflectivityColor: Color3;
  44797. /**
  44798. * The color applied when light is reflected from a material.
  44799. */
  44800. protected _reflectionColor: Color3;
  44801. /**
  44802. * The color applied when light is emitted from a material.
  44803. */
  44804. protected _emissiveColor: Color3;
  44805. /**
  44806. * AKA Glossiness in other nomenclature.
  44807. */
  44808. protected _microSurface: number;
  44809. /**
  44810. * Specifies that the material will use the light map as a show map.
  44811. */
  44812. protected _useLightmapAsShadowmap: boolean;
  44813. /**
  44814. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44815. * makes the reflect vector face the model (under horizon).
  44816. */
  44817. protected _useHorizonOcclusion: boolean;
  44818. /**
  44819. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44820. * too much the area relying on ambient texture to define their ambient occlusion.
  44821. */
  44822. protected _useRadianceOcclusion: boolean;
  44823. /**
  44824. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44825. */
  44826. protected _useAlphaFromAlbedoTexture: boolean;
  44827. /**
  44828. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44829. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44830. */
  44831. protected _useSpecularOverAlpha: boolean;
  44832. /**
  44833. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44834. */
  44835. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44836. /**
  44837. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44838. */
  44839. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44840. /**
  44841. * Specifies if the metallic texture contains the roughness information in its green channel.
  44842. */
  44843. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44844. /**
  44845. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44846. */
  44847. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44848. /**
  44849. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44850. */
  44851. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44852. /**
  44853. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44854. */
  44855. protected _useAmbientInGrayScale: boolean;
  44856. /**
  44857. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44858. * The material will try to infer what glossiness each pixel should be.
  44859. */
  44860. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44861. /**
  44862. * Defines the falloff type used in this material.
  44863. * It by default is Physical.
  44864. */
  44865. protected _lightFalloff: number;
  44866. /**
  44867. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44868. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44869. */
  44870. protected _useRadianceOverAlpha: boolean;
  44871. /**
  44872. * Allows using an object space normal map (instead of tangent space).
  44873. */
  44874. protected _useObjectSpaceNormalMap: boolean;
  44875. /**
  44876. * Allows using the bump map in parallax mode.
  44877. */
  44878. protected _useParallax: boolean;
  44879. /**
  44880. * Allows using the bump map in parallax occlusion mode.
  44881. */
  44882. protected _useParallaxOcclusion: boolean;
  44883. /**
  44884. * Controls the scale bias of the parallax mode.
  44885. */
  44886. protected _parallaxScaleBias: number;
  44887. /**
  44888. * If sets to true, disables all the lights affecting the material.
  44889. */
  44890. protected _disableLighting: boolean;
  44891. /**
  44892. * Number of Simultaneous lights allowed on the material.
  44893. */
  44894. protected _maxSimultaneousLights: number;
  44895. /**
  44896. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44897. */
  44898. protected _invertNormalMapX: boolean;
  44899. /**
  44900. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44901. */
  44902. protected _invertNormalMapY: boolean;
  44903. /**
  44904. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44905. */
  44906. protected _twoSidedLighting: boolean;
  44907. /**
  44908. * Defines the alpha limits in alpha test mode.
  44909. */
  44910. protected _alphaCutOff: number;
  44911. /**
  44912. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44913. */
  44914. protected _forceAlphaTest: boolean;
  44915. /**
  44916. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44917. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44918. */
  44919. protected _useAlphaFresnel: boolean;
  44920. /**
  44921. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44922. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44923. */
  44924. protected _useLinearAlphaFresnel: boolean;
  44925. /**
  44926. * The transparency mode of the material.
  44927. */
  44928. protected _transparencyMode: Nullable<number>;
  44929. /**
  44930. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44931. * from cos thetav and roughness:
  44932. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44933. */
  44934. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44935. /**
  44936. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44937. */
  44938. protected _forceIrradianceInFragment: boolean;
  44939. /**
  44940. * Force normal to face away from face.
  44941. */
  44942. protected _forceNormalForward: boolean;
  44943. /**
  44944. * Enables specular anti aliasing in the PBR shader.
  44945. * It will both interacts on the Geometry for analytical and IBL lighting.
  44946. * It also prefilter the roughness map based on the bump values.
  44947. */
  44948. protected _enableSpecularAntiAliasing: boolean;
  44949. /**
  44950. * Default configuration related to image processing available in the PBR Material.
  44951. */
  44952. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44953. /**
  44954. * Keep track of the image processing observer to allow dispose and replace.
  44955. */
  44956. private _imageProcessingObserver;
  44957. /**
  44958. * Attaches a new image processing configuration to the PBR Material.
  44959. * @param configuration
  44960. */
  44961. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44962. /**
  44963. * Stores the available render targets.
  44964. */
  44965. private _renderTargets;
  44966. /**
  44967. * Sets the global ambient color for the material used in lighting calculations.
  44968. */
  44969. private _globalAmbientColor;
  44970. /**
  44971. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44972. */
  44973. private _useLogarithmicDepth;
  44974. /**
  44975. * If set to true, no lighting calculations will be applied.
  44976. */
  44977. private _unlit;
  44978. private _debugMode;
  44979. /**
  44980. * @hidden
  44981. * This is reserved for the inspector.
  44982. * Defines the material debug mode.
  44983. * It helps seeing only some components of the material while troubleshooting.
  44984. */
  44985. debugMode: number;
  44986. /**
  44987. * @hidden
  44988. * This is reserved for the inspector.
  44989. * Specify from where on screen the debug mode should start.
  44990. * The value goes from -1 (full screen) to 1 (not visible)
  44991. * It helps with side by side comparison against the final render
  44992. * This defaults to -1
  44993. */
  44994. private debugLimit;
  44995. /**
  44996. * @hidden
  44997. * This is reserved for the inspector.
  44998. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44999. * You can use the factor to better multiply the final value.
  45000. */
  45001. private debugFactor;
  45002. /**
  45003. * Defines the clear coat layer parameters for the material.
  45004. */
  45005. readonly clearCoat: PBRClearCoatConfiguration;
  45006. /**
  45007. * Defines the anisotropic parameters for the material.
  45008. */
  45009. readonly anisotropy: PBRAnisotropicConfiguration;
  45010. /**
  45011. * Defines the BRDF parameters for the material.
  45012. */
  45013. readonly brdf: PBRBRDFConfiguration;
  45014. /**
  45015. * Defines the Sheen parameters for the material.
  45016. */
  45017. readonly sheen: PBRSheenConfiguration;
  45018. /**
  45019. * Defines the SubSurface parameters for the material.
  45020. */
  45021. readonly subSurface: PBRSubSurfaceConfiguration;
  45022. /**
  45023. * Custom callback helping to override the default shader used in the material.
  45024. */
  45025. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45026. /**
  45027. * Instantiates a new PBRMaterial instance.
  45028. *
  45029. * @param name The material name
  45030. * @param scene The scene the material will be use in.
  45031. */
  45032. constructor(name: string, scene: Scene);
  45033. /**
  45034. * Gets a boolean indicating that current material needs to register RTT
  45035. */
  45036. readonly hasRenderTargetTextures: boolean;
  45037. /**
  45038. * Gets the name of the material class.
  45039. */
  45040. getClassName(): string;
  45041. /**
  45042. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45043. */
  45044. /**
  45045. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45046. */
  45047. useLogarithmicDepth: boolean;
  45048. /**
  45049. * Gets the current transparency mode.
  45050. */
  45051. /**
  45052. * Sets the transparency mode of the material.
  45053. *
  45054. * | Value | Type | Description |
  45055. * | ----- | ----------------------------------- | ----------- |
  45056. * | 0 | OPAQUE | |
  45057. * | 1 | ALPHATEST | |
  45058. * | 2 | ALPHABLEND | |
  45059. * | 3 | ALPHATESTANDBLEND | |
  45060. *
  45061. */
  45062. transparencyMode: Nullable<number>;
  45063. /**
  45064. * Returns true if alpha blending should be disabled.
  45065. */
  45066. private readonly _disableAlphaBlending;
  45067. /**
  45068. * Specifies whether or not this material should be rendered in alpha blend mode.
  45069. */
  45070. needAlphaBlending(): boolean;
  45071. /**
  45072. * Specifies if the mesh will require alpha blending.
  45073. * @param mesh - BJS mesh.
  45074. */
  45075. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45076. /**
  45077. * Specifies whether or not this material should be rendered in alpha test mode.
  45078. */
  45079. needAlphaTesting(): boolean;
  45080. /**
  45081. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45082. */
  45083. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45084. /**
  45085. * Gets the texture used for the alpha test.
  45086. */
  45087. getAlphaTestTexture(): BaseTexture;
  45088. /**
  45089. * Specifies that the submesh is ready to be used.
  45090. * @param mesh - BJS mesh.
  45091. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45092. * @param useInstances - Specifies that instances should be used.
  45093. * @returns - boolean indicating that the submesh is ready or not.
  45094. */
  45095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45096. /**
  45097. * Specifies if the material uses metallic roughness workflow.
  45098. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45099. */
  45100. isMetallicWorkflow(): boolean;
  45101. private _prepareEffect;
  45102. private _prepareDefines;
  45103. /**
  45104. * Force shader compilation
  45105. */
  45106. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45107. clipPlane: boolean;
  45108. }>): void;
  45109. /**
  45110. * Initializes the uniform buffer layout for the shader.
  45111. */
  45112. buildUniformLayout(): void;
  45113. /**
  45114. * Unbinds the material from the mesh
  45115. */
  45116. unbind(): void;
  45117. /**
  45118. * Binds the submesh data.
  45119. * @param world - The world matrix.
  45120. * @param mesh - The BJS mesh.
  45121. * @param subMesh - A submesh of the BJS mesh.
  45122. */
  45123. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45124. /**
  45125. * Returns the animatable textures.
  45126. * @returns - Array of animatable textures.
  45127. */
  45128. getAnimatables(): IAnimatable[];
  45129. /**
  45130. * Returns the texture used for reflections.
  45131. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45132. */
  45133. private _getReflectionTexture;
  45134. /**
  45135. * Returns an array of the actively used textures.
  45136. * @returns - Array of BaseTextures
  45137. */
  45138. getActiveTextures(): BaseTexture[];
  45139. /**
  45140. * Checks to see if a texture is used in the material.
  45141. * @param texture - Base texture to use.
  45142. * @returns - Boolean specifying if a texture is used in the material.
  45143. */
  45144. hasTexture(texture: BaseTexture): boolean;
  45145. /**
  45146. * Disposes the resources of the material.
  45147. * @param forceDisposeEffect - Forces the disposal of effects.
  45148. * @param forceDisposeTextures - Forces the disposal of all textures.
  45149. */
  45150. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45151. }
  45152. }
  45153. declare module BABYLON {
  45154. /**
  45155. * The Physically based material of BJS.
  45156. *
  45157. * This offers the main features of a standard PBR material.
  45158. * For more information, please refer to the documentation :
  45159. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45160. */
  45161. export class PBRMaterial extends PBRBaseMaterial {
  45162. /**
  45163. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45164. */
  45165. static readonly PBRMATERIAL_OPAQUE: number;
  45166. /**
  45167. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45168. */
  45169. static readonly PBRMATERIAL_ALPHATEST: number;
  45170. /**
  45171. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45172. */
  45173. static readonly PBRMATERIAL_ALPHABLEND: number;
  45174. /**
  45175. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45176. * They are also discarded below the alpha cutoff threshold to improve performances.
  45177. */
  45178. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45179. /**
  45180. * Defines the default value of how much AO map is occluding the analytical lights
  45181. * (point spot...).
  45182. */
  45183. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45184. /**
  45185. * Intensity of the direct lights e.g. the four lights available in your scene.
  45186. * This impacts both the direct diffuse and specular highlights.
  45187. */
  45188. directIntensity: number;
  45189. /**
  45190. * Intensity of the emissive part of the material.
  45191. * This helps controlling the emissive effect without modifying the emissive color.
  45192. */
  45193. emissiveIntensity: number;
  45194. /**
  45195. * Intensity of the environment e.g. how much the environment will light the object
  45196. * either through harmonics for rough material or through the refelction for shiny ones.
  45197. */
  45198. environmentIntensity: number;
  45199. /**
  45200. * This is a special control allowing the reduction of the specular highlights coming from the
  45201. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45202. */
  45203. specularIntensity: number;
  45204. /**
  45205. * Debug Control allowing disabling the bump map on this material.
  45206. */
  45207. disableBumpMap: boolean;
  45208. /**
  45209. * AKA Diffuse Texture in standard nomenclature.
  45210. */
  45211. albedoTexture: BaseTexture;
  45212. /**
  45213. * AKA Occlusion Texture in other nomenclature.
  45214. */
  45215. ambientTexture: BaseTexture;
  45216. /**
  45217. * AKA Occlusion Texture Intensity in other nomenclature.
  45218. */
  45219. ambientTextureStrength: number;
  45220. /**
  45221. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45222. * 1 means it completely occludes it
  45223. * 0 mean it has no impact
  45224. */
  45225. ambientTextureImpactOnAnalyticalLights: number;
  45226. /**
  45227. * Stores the alpha values in a texture.
  45228. */
  45229. opacityTexture: BaseTexture;
  45230. /**
  45231. * Stores the reflection values in a texture.
  45232. */
  45233. reflectionTexture: Nullable<BaseTexture>;
  45234. /**
  45235. * Stores the emissive values in a texture.
  45236. */
  45237. emissiveTexture: BaseTexture;
  45238. /**
  45239. * AKA Specular texture in other nomenclature.
  45240. */
  45241. reflectivityTexture: BaseTexture;
  45242. /**
  45243. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45244. */
  45245. metallicTexture: BaseTexture;
  45246. /**
  45247. * Specifies the metallic scalar of the metallic/roughness workflow.
  45248. * Can also be used to scale the metalness values of the metallic texture.
  45249. */
  45250. metallic: Nullable<number>;
  45251. /**
  45252. * Specifies the roughness scalar of the metallic/roughness workflow.
  45253. * Can also be used to scale the roughness values of the metallic texture.
  45254. */
  45255. roughness: Nullable<number>;
  45256. /**
  45257. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45258. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45259. */
  45260. microSurfaceTexture: BaseTexture;
  45261. /**
  45262. * Stores surface normal data used to displace a mesh in a texture.
  45263. */
  45264. bumpTexture: BaseTexture;
  45265. /**
  45266. * Stores the pre-calculated light information of a mesh in a texture.
  45267. */
  45268. lightmapTexture: BaseTexture;
  45269. /**
  45270. * Stores the refracted light information in a texture.
  45271. */
  45272. refractionTexture: Nullable<BaseTexture>;
  45273. /**
  45274. * The color of a material in ambient lighting.
  45275. */
  45276. ambientColor: Color3;
  45277. /**
  45278. * AKA Diffuse Color in other nomenclature.
  45279. */
  45280. albedoColor: Color3;
  45281. /**
  45282. * AKA Specular Color in other nomenclature.
  45283. */
  45284. reflectivityColor: Color3;
  45285. /**
  45286. * The color reflected from the material.
  45287. */
  45288. reflectionColor: Color3;
  45289. /**
  45290. * The color emitted from the material.
  45291. */
  45292. emissiveColor: Color3;
  45293. /**
  45294. * AKA Glossiness in other nomenclature.
  45295. */
  45296. microSurface: number;
  45297. /**
  45298. * source material index of refraction (IOR)' / 'destination material IOR.
  45299. */
  45300. indexOfRefraction: number;
  45301. /**
  45302. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45303. */
  45304. invertRefractionY: boolean;
  45305. /**
  45306. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45307. * Materials half opaque for instance using refraction could benefit from this control.
  45308. */
  45309. linkRefractionWithTransparency: boolean;
  45310. /**
  45311. * If true, the light map contains occlusion information instead of lighting info.
  45312. */
  45313. useLightmapAsShadowmap: boolean;
  45314. /**
  45315. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45316. */
  45317. useAlphaFromAlbedoTexture: boolean;
  45318. /**
  45319. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45320. */
  45321. forceAlphaTest: boolean;
  45322. /**
  45323. * Defines the alpha limits in alpha test mode.
  45324. */
  45325. alphaCutOff: number;
  45326. /**
  45327. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45328. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45329. */
  45330. useSpecularOverAlpha: boolean;
  45331. /**
  45332. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45333. */
  45334. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45335. /**
  45336. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45337. */
  45338. useRoughnessFromMetallicTextureAlpha: boolean;
  45339. /**
  45340. * Specifies if the metallic texture contains the roughness information in its green channel.
  45341. */
  45342. useRoughnessFromMetallicTextureGreen: boolean;
  45343. /**
  45344. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45345. */
  45346. useMetallnessFromMetallicTextureBlue: boolean;
  45347. /**
  45348. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45349. */
  45350. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45351. /**
  45352. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45353. */
  45354. useAmbientInGrayScale: boolean;
  45355. /**
  45356. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45357. * The material will try to infer what glossiness each pixel should be.
  45358. */
  45359. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45360. /**
  45361. * BJS is using an harcoded light falloff based on a manually sets up range.
  45362. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45363. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45364. */
  45365. /**
  45366. * BJS is using an harcoded light falloff based on a manually sets up range.
  45367. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45368. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45369. */
  45370. usePhysicalLightFalloff: boolean;
  45371. /**
  45372. * In order to support the falloff compatibility with gltf, a special mode has been added
  45373. * to reproduce the gltf light falloff.
  45374. */
  45375. /**
  45376. * In order to support the falloff compatibility with gltf, a special mode has been added
  45377. * to reproduce the gltf light falloff.
  45378. */
  45379. useGLTFLightFalloff: boolean;
  45380. /**
  45381. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45382. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45383. */
  45384. useRadianceOverAlpha: boolean;
  45385. /**
  45386. * Allows using an object space normal map (instead of tangent space).
  45387. */
  45388. useObjectSpaceNormalMap: boolean;
  45389. /**
  45390. * Allows using the bump map in parallax mode.
  45391. */
  45392. useParallax: boolean;
  45393. /**
  45394. * Allows using the bump map in parallax occlusion mode.
  45395. */
  45396. useParallaxOcclusion: boolean;
  45397. /**
  45398. * Controls the scale bias of the parallax mode.
  45399. */
  45400. parallaxScaleBias: number;
  45401. /**
  45402. * If sets to true, disables all the lights affecting the material.
  45403. */
  45404. disableLighting: boolean;
  45405. /**
  45406. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45407. */
  45408. forceIrradianceInFragment: boolean;
  45409. /**
  45410. * Number of Simultaneous lights allowed on the material.
  45411. */
  45412. maxSimultaneousLights: number;
  45413. /**
  45414. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45415. */
  45416. invertNormalMapX: boolean;
  45417. /**
  45418. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45419. */
  45420. invertNormalMapY: boolean;
  45421. /**
  45422. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45423. */
  45424. twoSidedLighting: boolean;
  45425. /**
  45426. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45427. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45428. */
  45429. useAlphaFresnel: boolean;
  45430. /**
  45431. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45432. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45433. */
  45434. useLinearAlphaFresnel: boolean;
  45435. /**
  45436. * Let user defines the brdf lookup texture used for IBL.
  45437. * A default 8bit version is embedded but you could point at :
  45438. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45439. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45440. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45441. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45442. */
  45443. environmentBRDFTexture: Nullable<BaseTexture>;
  45444. /**
  45445. * Force normal to face away from face.
  45446. */
  45447. forceNormalForward: boolean;
  45448. /**
  45449. * Enables specular anti aliasing in the PBR shader.
  45450. * It will both interacts on the Geometry for analytical and IBL lighting.
  45451. * It also prefilter the roughness map based on the bump values.
  45452. */
  45453. enableSpecularAntiAliasing: boolean;
  45454. /**
  45455. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45456. * makes the reflect vector face the model (under horizon).
  45457. */
  45458. useHorizonOcclusion: boolean;
  45459. /**
  45460. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45461. * too much the area relying on ambient texture to define their ambient occlusion.
  45462. */
  45463. useRadianceOcclusion: boolean;
  45464. /**
  45465. * If set to true, no lighting calculations will be applied.
  45466. */
  45467. unlit: boolean;
  45468. /**
  45469. * Gets the image processing configuration used either in this material.
  45470. */
  45471. /**
  45472. * Sets the Default image processing configuration used either in the this material.
  45473. *
  45474. * If sets to null, the scene one is in use.
  45475. */
  45476. imageProcessingConfiguration: ImageProcessingConfiguration;
  45477. /**
  45478. * Gets wether the color curves effect is enabled.
  45479. */
  45480. /**
  45481. * Sets wether the color curves effect is enabled.
  45482. */
  45483. cameraColorCurvesEnabled: boolean;
  45484. /**
  45485. * Gets wether the color grading effect is enabled.
  45486. */
  45487. /**
  45488. * Gets wether the color grading effect is enabled.
  45489. */
  45490. cameraColorGradingEnabled: boolean;
  45491. /**
  45492. * Gets wether tonemapping is enabled or not.
  45493. */
  45494. /**
  45495. * Sets wether tonemapping is enabled or not
  45496. */
  45497. cameraToneMappingEnabled: boolean;
  45498. /**
  45499. * The camera exposure used on this material.
  45500. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45501. * This corresponds to a photographic exposure.
  45502. */
  45503. /**
  45504. * The camera exposure used on this material.
  45505. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45506. * This corresponds to a photographic exposure.
  45507. */
  45508. cameraExposure: number;
  45509. /**
  45510. * Gets The camera contrast used on this material.
  45511. */
  45512. /**
  45513. * Sets The camera contrast used on this material.
  45514. */
  45515. cameraContrast: number;
  45516. /**
  45517. * Gets the Color Grading 2D Lookup Texture.
  45518. */
  45519. /**
  45520. * Sets the Color Grading 2D Lookup Texture.
  45521. */
  45522. cameraColorGradingTexture: Nullable<BaseTexture>;
  45523. /**
  45524. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45525. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45526. * 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;
  45527. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45528. */
  45529. /**
  45530. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45531. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45532. * 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;
  45533. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45534. */
  45535. cameraColorCurves: Nullable<ColorCurves>;
  45536. /**
  45537. * Instantiates a new PBRMaterial instance.
  45538. *
  45539. * @param name The material name
  45540. * @param scene The scene the material will be use in.
  45541. */
  45542. constructor(name: string, scene: Scene);
  45543. /**
  45544. * Returns the name of this material class.
  45545. */
  45546. getClassName(): string;
  45547. /**
  45548. * Makes a duplicate of the current material.
  45549. * @param name - name to use for the new material.
  45550. */
  45551. clone(name: string): PBRMaterial;
  45552. /**
  45553. * Serializes this PBR Material.
  45554. * @returns - An object with the serialized material.
  45555. */
  45556. serialize(): any;
  45557. /**
  45558. * Parses a PBR Material from a serialized object.
  45559. * @param source - Serialized object.
  45560. * @param scene - BJS scene instance.
  45561. * @param rootUrl - url for the scene object
  45562. * @returns - PBRMaterial
  45563. */
  45564. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45565. }
  45566. }
  45567. declare module BABYLON {
  45568. /**
  45569. * Direct draw surface info
  45570. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45571. */
  45572. export interface DDSInfo {
  45573. /**
  45574. * Width of the texture
  45575. */
  45576. width: number;
  45577. /**
  45578. * Width of the texture
  45579. */
  45580. height: number;
  45581. /**
  45582. * Number of Mipmaps for the texture
  45583. * @see https://en.wikipedia.org/wiki/Mipmap
  45584. */
  45585. mipmapCount: number;
  45586. /**
  45587. * If the textures format is a known fourCC format
  45588. * @see https://www.fourcc.org/
  45589. */
  45590. isFourCC: boolean;
  45591. /**
  45592. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45593. */
  45594. isRGB: boolean;
  45595. /**
  45596. * If the texture is a lumincance format
  45597. */
  45598. isLuminance: boolean;
  45599. /**
  45600. * If this is a cube texture
  45601. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45602. */
  45603. isCube: boolean;
  45604. /**
  45605. * If the texture is a compressed format eg. FOURCC_DXT1
  45606. */
  45607. isCompressed: boolean;
  45608. /**
  45609. * The dxgiFormat of the texture
  45610. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45611. */
  45612. dxgiFormat: number;
  45613. /**
  45614. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45615. */
  45616. textureType: number;
  45617. /**
  45618. * Sphericle polynomial created for the dds texture
  45619. */
  45620. sphericalPolynomial?: SphericalPolynomial;
  45621. }
  45622. /**
  45623. * Class used to provide DDS decompression tools
  45624. */
  45625. export class DDSTools {
  45626. /**
  45627. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45628. */
  45629. static StoreLODInAlphaChannel: boolean;
  45630. /**
  45631. * Gets DDS information from an array buffer
  45632. * @param arrayBuffer defines the array buffer to read data from
  45633. * @returns the DDS information
  45634. */
  45635. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45636. private static _FloatView;
  45637. private static _Int32View;
  45638. private static _ToHalfFloat;
  45639. private static _FromHalfFloat;
  45640. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45641. private static _GetHalfFloatRGBAArrayBuffer;
  45642. private static _GetFloatRGBAArrayBuffer;
  45643. private static _GetFloatAsUIntRGBAArrayBuffer;
  45644. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45645. private static _GetRGBAArrayBuffer;
  45646. private static _ExtractLongWordOrder;
  45647. private static _GetRGBArrayBuffer;
  45648. private static _GetLuminanceArrayBuffer;
  45649. /**
  45650. * Uploads DDS Levels to a Babylon Texture
  45651. * @hidden
  45652. */
  45653. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45654. }
  45655. interface Engine {
  45656. /**
  45657. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45658. * @param rootUrl defines the url where the file to load is located
  45659. * @param scene defines the current scene
  45660. * @param lodScale defines scale to apply to the mip map selection
  45661. * @param lodOffset defines offset to apply to the mip map selection
  45662. * @param onLoad defines an optional callback raised when the texture is loaded
  45663. * @param onError defines an optional callback raised if there is an issue to load the texture
  45664. * @param format defines the format of the data
  45665. * @param forcedExtension defines the extension to use to pick the right loader
  45666. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45667. * @returns the cube texture as an InternalTexture
  45668. */
  45669. 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;
  45670. }
  45671. }
  45672. declare module BABYLON {
  45673. /**
  45674. * Implementation of the DDS Texture Loader.
  45675. * @hidden
  45676. */
  45677. export class _DDSTextureLoader implements IInternalTextureLoader {
  45678. /**
  45679. * Defines wether the loader supports cascade loading the different faces.
  45680. */
  45681. readonly supportCascades: boolean;
  45682. /**
  45683. * This returns if the loader support the current file information.
  45684. * @param extension defines the file extension of the file being loaded
  45685. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45686. * @param fallback defines the fallback internal texture if any
  45687. * @param isBase64 defines whether the texture is encoded as a base64
  45688. * @param isBuffer defines whether the texture data are stored as a buffer
  45689. * @returns true if the loader can load the specified file
  45690. */
  45691. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45692. /**
  45693. * Transform the url before loading if required.
  45694. * @param rootUrl the url of the texture
  45695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45696. * @returns the transformed texture
  45697. */
  45698. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45699. /**
  45700. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45701. * @param rootUrl the url of the texture
  45702. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45703. * @returns the fallback texture
  45704. */
  45705. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45706. /**
  45707. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45708. * @param data contains the texture data
  45709. * @param texture defines the BabylonJS internal texture
  45710. * @param createPolynomials will be true if polynomials have been requested
  45711. * @param onLoad defines the callback to trigger once the texture is ready
  45712. * @param onError defines the callback to trigger in case of error
  45713. */
  45714. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45715. /**
  45716. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45717. * @param data contains the texture data
  45718. * @param texture defines the BabylonJS internal texture
  45719. * @param callback defines the method to call once ready to upload
  45720. */
  45721. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45722. }
  45723. }
  45724. declare module BABYLON {
  45725. /** @hidden */
  45726. export var rgbdEncodePixelShader: {
  45727. name: string;
  45728. shader: string;
  45729. };
  45730. }
  45731. declare module BABYLON {
  45732. /**
  45733. * Raw texture data and descriptor sufficient for WebGL texture upload
  45734. */
  45735. export interface EnvironmentTextureInfo {
  45736. /**
  45737. * Version of the environment map
  45738. */
  45739. version: number;
  45740. /**
  45741. * Width of image
  45742. */
  45743. width: number;
  45744. /**
  45745. * Irradiance information stored in the file.
  45746. */
  45747. irradiance: any;
  45748. /**
  45749. * Specular information stored in the file.
  45750. */
  45751. specular: any;
  45752. }
  45753. /**
  45754. * Sets of helpers addressing the serialization and deserialization of environment texture
  45755. * stored in a BabylonJS env file.
  45756. * Those files are usually stored as .env files.
  45757. */
  45758. export class EnvironmentTextureTools {
  45759. /**
  45760. * Magic number identifying the env file.
  45761. */
  45762. private static _MagicBytes;
  45763. /**
  45764. * Gets the environment info from an env file.
  45765. * @param data The array buffer containing the .env bytes.
  45766. * @returns the environment file info (the json header) if successfully parsed.
  45767. */
  45768. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45769. /**
  45770. * Creates an environment texture from a loaded cube texture.
  45771. * @param texture defines the cube texture to convert in env file
  45772. * @return a promise containing the environment data if succesfull.
  45773. */
  45774. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45775. /**
  45776. * Creates a JSON representation of the spherical data.
  45777. * @param texture defines the texture containing the polynomials
  45778. * @return the JSON representation of the spherical info
  45779. */
  45780. private static _CreateEnvTextureIrradiance;
  45781. /**
  45782. * Uploads the texture info contained in the env file to the GPU.
  45783. * @param texture defines the internal texture to upload to
  45784. * @param arrayBuffer defines the buffer cotaining the data to load
  45785. * @param info defines the texture info retrieved through the GetEnvInfo method
  45786. * @returns a promise
  45787. */
  45788. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45789. /**
  45790. * Uploads the levels of image data to the GPU.
  45791. * @param texture defines the internal texture to upload to
  45792. * @param imageData defines the array buffer views of image data [mipmap][face]
  45793. * @returns a promise
  45794. */
  45795. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45796. /**
  45797. * Uploads spherical polynomials information to the texture.
  45798. * @param texture defines the texture we are trying to upload the information to
  45799. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45800. */
  45801. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45802. /** @hidden */
  45803. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45804. }
  45805. }
  45806. declare module BABYLON {
  45807. /**
  45808. * Implementation of the ENV Texture Loader.
  45809. * @hidden
  45810. */
  45811. export class _ENVTextureLoader implements IInternalTextureLoader {
  45812. /**
  45813. * Defines wether the loader supports cascade loading the different faces.
  45814. */
  45815. readonly supportCascades: boolean;
  45816. /**
  45817. * This returns if the loader support the current file information.
  45818. * @param extension defines the file extension of the file being loaded
  45819. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45820. * @param fallback defines the fallback internal texture if any
  45821. * @param isBase64 defines whether the texture is encoded as a base64
  45822. * @param isBuffer defines whether the texture data are stored as a buffer
  45823. * @returns true if the loader can load the specified file
  45824. */
  45825. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45826. /**
  45827. * Transform the url before loading if required.
  45828. * @param rootUrl the url of the texture
  45829. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45830. * @returns the transformed texture
  45831. */
  45832. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45833. /**
  45834. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45835. * @param rootUrl the url of the texture
  45836. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45837. * @returns the fallback texture
  45838. */
  45839. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45840. /**
  45841. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45842. * @param data contains the texture data
  45843. * @param texture defines the BabylonJS internal texture
  45844. * @param createPolynomials will be true if polynomials have been requested
  45845. * @param onLoad defines the callback to trigger once the texture is ready
  45846. * @param onError defines the callback to trigger in case of error
  45847. */
  45848. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45849. /**
  45850. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45851. * @param data contains the texture data
  45852. * @param texture defines the BabylonJS internal texture
  45853. * @param callback defines the method to call once ready to upload
  45854. */
  45855. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45856. }
  45857. }
  45858. declare module BABYLON {
  45859. /**
  45860. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45861. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45862. */
  45863. export class KhronosTextureContainer {
  45864. /** contents of the KTX container file */
  45865. arrayBuffer: any;
  45866. private static HEADER_LEN;
  45867. private static COMPRESSED_2D;
  45868. private static COMPRESSED_3D;
  45869. private static TEX_2D;
  45870. private static TEX_3D;
  45871. /**
  45872. * Gets the openGL type
  45873. */
  45874. glType: number;
  45875. /**
  45876. * Gets the openGL type size
  45877. */
  45878. glTypeSize: number;
  45879. /**
  45880. * Gets the openGL format
  45881. */
  45882. glFormat: number;
  45883. /**
  45884. * Gets the openGL internal format
  45885. */
  45886. glInternalFormat: number;
  45887. /**
  45888. * Gets the base internal format
  45889. */
  45890. glBaseInternalFormat: number;
  45891. /**
  45892. * Gets image width in pixel
  45893. */
  45894. pixelWidth: number;
  45895. /**
  45896. * Gets image height in pixel
  45897. */
  45898. pixelHeight: number;
  45899. /**
  45900. * Gets image depth in pixels
  45901. */
  45902. pixelDepth: number;
  45903. /**
  45904. * Gets the number of array elements
  45905. */
  45906. numberOfArrayElements: number;
  45907. /**
  45908. * Gets the number of faces
  45909. */
  45910. numberOfFaces: number;
  45911. /**
  45912. * Gets the number of mipmap levels
  45913. */
  45914. numberOfMipmapLevels: number;
  45915. /**
  45916. * Gets the bytes of key value data
  45917. */
  45918. bytesOfKeyValueData: number;
  45919. /**
  45920. * Gets the load type
  45921. */
  45922. loadType: number;
  45923. /**
  45924. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45925. */
  45926. isInvalid: boolean;
  45927. /**
  45928. * Creates a new KhronosTextureContainer
  45929. * @param arrayBuffer contents of the KTX container file
  45930. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45931. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45932. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45933. */
  45934. constructor(
  45935. /** contents of the KTX container file */
  45936. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45937. /**
  45938. * Uploads KTX content to a Babylon Texture.
  45939. * It is assumed that the texture has already been created & is currently bound
  45940. * @hidden
  45941. */
  45942. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45943. private _upload2DCompressedLevels;
  45944. }
  45945. }
  45946. declare module BABYLON {
  45947. /**
  45948. * Implementation of the KTX Texture Loader.
  45949. * @hidden
  45950. */
  45951. export class _KTXTextureLoader implements IInternalTextureLoader {
  45952. /**
  45953. * Defines wether the loader supports cascade loading the different faces.
  45954. */
  45955. readonly supportCascades: boolean;
  45956. /**
  45957. * This returns if the loader support the current file information.
  45958. * @param extension defines the file extension of the file being loaded
  45959. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45960. * @param fallback defines the fallback internal texture if any
  45961. * @param isBase64 defines whether the texture is encoded as a base64
  45962. * @param isBuffer defines whether the texture data are stored as a buffer
  45963. * @returns true if the loader can load the specified file
  45964. */
  45965. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45966. /**
  45967. * Transform the url before loading if required.
  45968. * @param rootUrl the url of the texture
  45969. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45970. * @returns the transformed texture
  45971. */
  45972. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45973. /**
  45974. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45975. * @param rootUrl the url of the texture
  45976. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45977. * @returns the fallback texture
  45978. */
  45979. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45980. /**
  45981. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45982. * @param data contains the texture data
  45983. * @param texture defines the BabylonJS internal texture
  45984. * @param createPolynomials will be true if polynomials have been requested
  45985. * @param onLoad defines the callback to trigger once the texture is ready
  45986. * @param onError defines the callback to trigger in case of error
  45987. */
  45988. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45989. /**
  45990. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45991. * @param data contains the texture data
  45992. * @param texture defines the BabylonJS internal texture
  45993. * @param callback defines the method to call once ready to upload
  45994. */
  45995. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45996. }
  45997. }
  45998. declare module BABYLON {
  45999. /** @hidden */
  46000. export var _forceSceneHelpersToBundle: boolean;
  46001. interface Scene {
  46002. /**
  46003. * Creates a default light for the scene.
  46004. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46005. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46006. */
  46007. createDefaultLight(replace?: boolean): void;
  46008. /**
  46009. * Creates a default camera for the scene.
  46010. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46011. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46012. * @param replace has default false, when true replaces the active camera in the scene
  46013. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46014. */
  46015. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46016. /**
  46017. * Creates a default camera and a default light.
  46018. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46019. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46020. * @param replace has the default false, when true replaces the active camera/light in the scene
  46021. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46022. */
  46023. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46024. /**
  46025. * Creates a new sky box
  46026. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46027. * @param environmentTexture defines the texture to use as environment texture
  46028. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46029. * @param scale defines the overall scale of the skybox
  46030. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46031. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46032. * @returns a new mesh holding the sky box
  46033. */
  46034. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46035. /**
  46036. * Creates a new environment
  46037. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46038. * @param options defines the options you can use to configure the environment
  46039. * @returns the new EnvironmentHelper
  46040. */
  46041. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46042. /**
  46043. * Creates a new VREXperienceHelper
  46044. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46045. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46046. * @returns a new VREXperienceHelper
  46047. */
  46048. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46049. /**
  46050. * Creates a new XREXperienceHelper
  46051. * @see http://doc.babylonjs.com/how_to/webxr
  46052. * @returns a promise for a new XREXperienceHelper
  46053. */
  46054. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46055. }
  46056. }
  46057. declare module BABYLON {
  46058. /**
  46059. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46060. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46061. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46062. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46063. */
  46064. export class VideoDome extends TransformNode {
  46065. /**
  46066. * Define the video source as a Monoscopic panoramic 360 video.
  46067. */
  46068. static readonly MODE_MONOSCOPIC: number;
  46069. /**
  46070. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46071. */
  46072. static readonly MODE_TOPBOTTOM: number;
  46073. /**
  46074. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46075. */
  46076. static readonly MODE_SIDEBYSIDE: number;
  46077. private _useDirectMapping;
  46078. /**
  46079. * The video texture being displayed on the sphere
  46080. */
  46081. protected _videoTexture: VideoTexture;
  46082. /**
  46083. * Gets the video texture being displayed on the sphere
  46084. */
  46085. readonly videoTexture: VideoTexture;
  46086. /**
  46087. * The skybox material
  46088. */
  46089. protected _material: BackgroundMaterial;
  46090. /**
  46091. * The surface used for the skybox
  46092. */
  46093. protected _mesh: Mesh;
  46094. /**
  46095. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46096. * Also see the options.resolution property.
  46097. */
  46098. fovMultiplier: number;
  46099. private _videoMode;
  46100. /**
  46101. * Gets or set the current video mode for the video. It can be:
  46102. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46103. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46104. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46105. */
  46106. videoMode: number;
  46107. /**
  46108. * Oberserver used in Stereoscopic VR Mode.
  46109. */
  46110. private _onBeforeCameraRenderObserver;
  46111. /**
  46112. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46113. * @param name Element's name, child elements will append suffixes for their own names.
  46114. * @param urlsOrVideo defines the url(s) or the video element to use
  46115. * @param options An object containing optional or exposed sub element properties
  46116. */
  46117. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46118. resolution?: number;
  46119. clickToPlay?: boolean;
  46120. autoPlay?: boolean;
  46121. loop?: boolean;
  46122. size?: number;
  46123. poster?: string;
  46124. faceForward?: boolean;
  46125. useDirectMapping?: boolean;
  46126. }, scene: Scene);
  46127. private _changeVideoMode;
  46128. /**
  46129. * Releases resources associated with this node.
  46130. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46131. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46132. */
  46133. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46134. }
  46135. }
  46136. declare module BABYLON {
  46137. /**
  46138. * This class can be used to get instrumentation data from a Babylon engine
  46139. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46140. */
  46141. export class EngineInstrumentation implements IDisposable {
  46142. /**
  46143. * Define the instrumented engine.
  46144. */
  46145. engine: Engine;
  46146. private _captureGPUFrameTime;
  46147. private _gpuFrameTimeToken;
  46148. private _gpuFrameTime;
  46149. private _captureShaderCompilationTime;
  46150. private _shaderCompilationTime;
  46151. private _onBeginFrameObserver;
  46152. private _onEndFrameObserver;
  46153. private _onBeforeShaderCompilationObserver;
  46154. private _onAfterShaderCompilationObserver;
  46155. /**
  46156. * Gets the perf counter used for GPU frame time
  46157. */
  46158. readonly gpuFrameTimeCounter: PerfCounter;
  46159. /**
  46160. * Gets the GPU frame time capture status
  46161. */
  46162. /**
  46163. * Enable or disable the GPU frame time capture
  46164. */
  46165. captureGPUFrameTime: boolean;
  46166. /**
  46167. * Gets the perf counter used for shader compilation time
  46168. */
  46169. readonly shaderCompilationTimeCounter: PerfCounter;
  46170. /**
  46171. * Gets the shader compilation time capture status
  46172. */
  46173. /**
  46174. * Enable or disable the shader compilation time capture
  46175. */
  46176. captureShaderCompilationTime: boolean;
  46177. /**
  46178. * Instantiates a new engine instrumentation.
  46179. * This class can be used to get instrumentation data from a Babylon engine
  46180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46181. * @param engine Defines the engine to instrument
  46182. */
  46183. constructor(
  46184. /**
  46185. * Define the instrumented engine.
  46186. */
  46187. engine: Engine);
  46188. /**
  46189. * Dispose and release associated resources.
  46190. */
  46191. dispose(): void;
  46192. }
  46193. }
  46194. declare module BABYLON {
  46195. /**
  46196. * This class can be used to get instrumentation data from a Babylon engine
  46197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46198. */
  46199. export class SceneInstrumentation implements IDisposable {
  46200. /**
  46201. * Defines the scene to instrument
  46202. */
  46203. scene: Scene;
  46204. private _captureActiveMeshesEvaluationTime;
  46205. private _activeMeshesEvaluationTime;
  46206. private _captureRenderTargetsRenderTime;
  46207. private _renderTargetsRenderTime;
  46208. private _captureFrameTime;
  46209. private _frameTime;
  46210. private _captureRenderTime;
  46211. private _renderTime;
  46212. private _captureInterFrameTime;
  46213. private _interFrameTime;
  46214. private _captureParticlesRenderTime;
  46215. private _particlesRenderTime;
  46216. private _captureSpritesRenderTime;
  46217. private _spritesRenderTime;
  46218. private _capturePhysicsTime;
  46219. private _physicsTime;
  46220. private _captureAnimationsTime;
  46221. private _animationsTime;
  46222. private _captureCameraRenderTime;
  46223. private _cameraRenderTime;
  46224. private _onBeforeActiveMeshesEvaluationObserver;
  46225. private _onAfterActiveMeshesEvaluationObserver;
  46226. private _onBeforeRenderTargetsRenderObserver;
  46227. private _onAfterRenderTargetsRenderObserver;
  46228. private _onAfterRenderObserver;
  46229. private _onBeforeDrawPhaseObserver;
  46230. private _onAfterDrawPhaseObserver;
  46231. private _onBeforeAnimationsObserver;
  46232. private _onBeforeParticlesRenderingObserver;
  46233. private _onAfterParticlesRenderingObserver;
  46234. private _onBeforeSpritesRenderingObserver;
  46235. private _onAfterSpritesRenderingObserver;
  46236. private _onBeforePhysicsObserver;
  46237. private _onAfterPhysicsObserver;
  46238. private _onAfterAnimationsObserver;
  46239. private _onBeforeCameraRenderObserver;
  46240. private _onAfterCameraRenderObserver;
  46241. /**
  46242. * Gets the perf counter used for active meshes evaluation time
  46243. */
  46244. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46245. /**
  46246. * Gets the active meshes evaluation time capture status
  46247. */
  46248. /**
  46249. * Enable or disable the active meshes evaluation time capture
  46250. */
  46251. captureActiveMeshesEvaluationTime: boolean;
  46252. /**
  46253. * Gets the perf counter used for render targets render time
  46254. */
  46255. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46256. /**
  46257. * Gets the render targets render time capture status
  46258. */
  46259. /**
  46260. * Enable or disable the render targets render time capture
  46261. */
  46262. captureRenderTargetsRenderTime: boolean;
  46263. /**
  46264. * Gets the perf counter used for particles render time
  46265. */
  46266. readonly particlesRenderTimeCounter: PerfCounter;
  46267. /**
  46268. * Gets the particles render time capture status
  46269. */
  46270. /**
  46271. * Enable or disable the particles render time capture
  46272. */
  46273. captureParticlesRenderTime: boolean;
  46274. /**
  46275. * Gets the perf counter used for sprites render time
  46276. */
  46277. readonly spritesRenderTimeCounter: PerfCounter;
  46278. /**
  46279. * Gets the sprites render time capture status
  46280. */
  46281. /**
  46282. * Enable or disable the sprites render time capture
  46283. */
  46284. captureSpritesRenderTime: boolean;
  46285. /**
  46286. * Gets the perf counter used for physics time
  46287. */
  46288. readonly physicsTimeCounter: PerfCounter;
  46289. /**
  46290. * Gets the physics time capture status
  46291. */
  46292. /**
  46293. * Enable or disable the physics time capture
  46294. */
  46295. capturePhysicsTime: boolean;
  46296. /**
  46297. * Gets the perf counter used for animations time
  46298. */
  46299. readonly animationsTimeCounter: PerfCounter;
  46300. /**
  46301. * Gets the animations time capture status
  46302. */
  46303. /**
  46304. * Enable or disable the animations time capture
  46305. */
  46306. captureAnimationsTime: boolean;
  46307. /**
  46308. * Gets the perf counter used for frame time capture
  46309. */
  46310. readonly frameTimeCounter: PerfCounter;
  46311. /**
  46312. * Gets the frame time capture status
  46313. */
  46314. /**
  46315. * Enable or disable the frame time capture
  46316. */
  46317. captureFrameTime: boolean;
  46318. /**
  46319. * Gets the perf counter used for inter-frames time capture
  46320. */
  46321. readonly interFrameTimeCounter: PerfCounter;
  46322. /**
  46323. * Gets the inter-frames time capture status
  46324. */
  46325. /**
  46326. * Enable or disable the inter-frames time capture
  46327. */
  46328. captureInterFrameTime: boolean;
  46329. /**
  46330. * Gets the perf counter used for render time capture
  46331. */
  46332. readonly renderTimeCounter: PerfCounter;
  46333. /**
  46334. * Gets the render time capture status
  46335. */
  46336. /**
  46337. * Enable or disable the render time capture
  46338. */
  46339. captureRenderTime: boolean;
  46340. /**
  46341. * Gets the perf counter used for camera render time capture
  46342. */
  46343. readonly cameraRenderTimeCounter: PerfCounter;
  46344. /**
  46345. * Gets the camera render time capture status
  46346. */
  46347. /**
  46348. * Enable or disable the camera render time capture
  46349. */
  46350. captureCameraRenderTime: boolean;
  46351. /**
  46352. * Gets the perf counter used for draw calls
  46353. */
  46354. readonly drawCallsCounter: PerfCounter;
  46355. /**
  46356. * Gets the perf counter used for texture collisions
  46357. */
  46358. readonly textureCollisionsCounter: PerfCounter;
  46359. /**
  46360. * Instantiates a new scene instrumentation.
  46361. * This class can be used to get instrumentation data from a Babylon engine
  46362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46363. * @param scene Defines the scene to instrument
  46364. */
  46365. constructor(
  46366. /**
  46367. * Defines the scene to instrument
  46368. */
  46369. scene: Scene);
  46370. /**
  46371. * Dispose and release associated resources.
  46372. */
  46373. dispose(): void;
  46374. }
  46375. }
  46376. declare module BABYLON {
  46377. /** @hidden */
  46378. export var glowMapGenerationPixelShader: {
  46379. name: string;
  46380. shader: string;
  46381. };
  46382. }
  46383. declare module BABYLON {
  46384. /** @hidden */
  46385. export var glowMapGenerationVertexShader: {
  46386. name: string;
  46387. shader: string;
  46388. };
  46389. }
  46390. declare module BABYLON {
  46391. /**
  46392. * Effect layer options. This helps customizing the behaviour
  46393. * of the effect layer.
  46394. */
  46395. export interface IEffectLayerOptions {
  46396. /**
  46397. * Multiplication factor apply to the canvas size to compute the render target size
  46398. * used to generated the objects (the smaller the faster).
  46399. */
  46400. mainTextureRatio: number;
  46401. /**
  46402. * Enforces a fixed size texture to ensure effect stability across devices.
  46403. */
  46404. mainTextureFixedSize?: number;
  46405. /**
  46406. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46407. */
  46408. alphaBlendingMode: number;
  46409. /**
  46410. * The camera attached to the layer.
  46411. */
  46412. camera: Nullable<Camera>;
  46413. /**
  46414. * The rendering group to draw the layer in.
  46415. */
  46416. renderingGroupId: number;
  46417. }
  46418. /**
  46419. * The effect layer Helps adding post process effect blended with the main pass.
  46420. *
  46421. * This can be for instance use to generate glow or higlight effects on the scene.
  46422. *
  46423. * The effect layer class can not be used directly and is intented to inherited from to be
  46424. * customized per effects.
  46425. */
  46426. export abstract class EffectLayer {
  46427. private _vertexBuffers;
  46428. private _indexBuffer;
  46429. private _cachedDefines;
  46430. private _effectLayerMapGenerationEffect;
  46431. private _effectLayerOptions;
  46432. private _mergeEffect;
  46433. protected _scene: Scene;
  46434. protected _engine: Engine;
  46435. protected _maxSize: number;
  46436. protected _mainTextureDesiredSize: ISize;
  46437. protected _mainTexture: RenderTargetTexture;
  46438. protected _shouldRender: boolean;
  46439. protected _postProcesses: PostProcess[];
  46440. protected _textures: BaseTexture[];
  46441. protected _emissiveTextureAndColor: {
  46442. texture: Nullable<BaseTexture>;
  46443. color: Color4;
  46444. };
  46445. /**
  46446. * The name of the layer
  46447. */
  46448. name: string;
  46449. /**
  46450. * The clear color of the texture used to generate the glow map.
  46451. */
  46452. neutralColor: Color4;
  46453. /**
  46454. * Specifies wether the highlight layer is enabled or not.
  46455. */
  46456. isEnabled: boolean;
  46457. /**
  46458. * Gets the camera attached to the layer.
  46459. */
  46460. readonly camera: Nullable<Camera>;
  46461. /**
  46462. * Gets the rendering group id the layer should render in.
  46463. */
  46464. readonly renderingGroupId: number;
  46465. /**
  46466. * An event triggered when the effect layer has been disposed.
  46467. */
  46468. onDisposeObservable: Observable<EffectLayer>;
  46469. /**
  46470. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46471. */
  46472. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46473. /**
  46474. * An event triggered when the generated texture is being merged in the scene.
  46475. */
  46476. onBeforeComposeObservable: Observable<EffectLayer>;
  46477. /**
  46478. * An event triggered when the generated texture has been merged in the scene.
  46479. */
  46480. onAfterComposeObservable: Observable<EffectLayer>;
  46481. /**
  46482. * An event triggered when the efffect layer changes its size.
  46483. */
  46484. onSizeChangedObservable: Observable<EffectLayer>;
  46485. /** @hidden */
  46486. static _SceneComponentInitialization: (scene: Scene) => void;
  46487. /**
  46488. * Instantiates a new effect Layer and references it in the scene.
  46489. * @param name The name of the layer
  46490. * @param scene The scene to use the layer in
  46491. */
  46492. constructor(
  46493. /** The Friendly of the effect in the scene */
  46494. name: string, scene: Scene);
  46495. /**
  46496. * Get the effect name of the layer.
  46497. * @return The effect name
  46498. */
  46499. abstract getEffectName(): string;
  46500. /**
  46501. * Checks for the readiness of the element composing the layer.
  46502. * @param subMesh the mesh to check for
  46503. * @param useInstances specify wether or not to use instances to render the mesh
  46504. * @return true if ready otherwise, false
  46505. */
  46506. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46507. /**
  46508. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46509. * @returns true if the effect requires stencil during the main canvas render pass.
  46510. */
  46511. abstract needStencil(): boolean;
  46512. /**
  46513. * Create the merge effect. This is the shader use to blit the information back
  46514. * to the main canvas at the end of the scene rendering.
  46515. * @returns The effect containing the shader used to merge the effect on the main canvas
  46516. */
  46517. protected abstract _createMergeEffect(): Effect;
  46518. /**
  46519. * Creates the render target textures and post processes used in the effect layer.
  46520. */
  46521. protected abstract _createTextureAndPostProcesses(): void;
  46522. /**
  46523. * Implementation specific of rendering the generating effect on the main canvas.
  46524. * @param effect The effect used to render through
  46525. */
  46526. protected abstract _internalRender(effect: Effect): void;
  46527. /**
  46528. * Sets the required values for both the emissive texture and and the main color.
  46529. */
  46530. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46531. /**
  46532. * Free any resources and references associated to a mesh.
  46533. * Internal use
  46534. * @param mesh The mesh to free.
  46535. */
  46536. abstract _disposeMesh(mesh: Mesh): void;
  46537. /**
  46538. * Serializes this layer (Glow or Highlight for example)
  46539. * @returns a serialized layer object
  46540. */
  46541. abstract serialize?(): any;
  46542. /**
  46543. * Initializes the effect layer with the required options.
  46544. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46545. */
  46546. protected _init(options: Partial<IEffectLayerOptions>): void;
  46547. /**
  46548. * Generates the index buffer of the full screen quad blending to the main canvas.
  46549. */
  46550. private _generateIndexBuffer;
  46551. /**
  46552. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46553. */
  46554. private _genrateVertexBuffer;
  46555. /**
  46556. * Sets the main texture desired size which is the closest power of two
  46557. * of the engine canvas size.
  46558. */
  46559. private _setMainTextureSize;
  46560. /**
  46561. * Creates the main texture for the effect layer.
  46562. */
  46563. protected _createMainTexture(): void;
  46564. /**
  46565. * Adds specific effects defines.
  46566. * @param defines The defines to add specifics to.
  46567. */
  46568. protected _addCustomEffectDefines(defines: string[]): void;
  46569. /**
  46570. * Checks for the readiness of the element composing the layer.
  46571. * @param subMesh the mesh to check for
  46572. * @param useInstances specify wether or not to use instances to render the mesh
  46573. * @param emissiveTexture the associated emissive texture used to generate the glow
  46574. * @return true if ready otherwise, false
  46575. */
  46576. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46577. /**
  46578. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46579. */
  46580. render(): void;
  46581. /**
  46582. * Determine if a given mesh will be used in the current effect.
  46583. * @param mesh mesh to test
  46584. * @returns true if the mesh will be used
  46585. */
  46586. hasMesh(mesh: AbstractMesh): boolean;
  46587. /**
  46588. * Returns true if the layer contains information to display, otherwise false.
  46589. * @returns true if the glow layer should be rendered
  46590. */
  46591. shouldRender(): boolean;
  46592. /**
  46593. * Returns true if the mesh should render, otherwise false.
  46594. * @param mesh The mesh to render
  46595. * @returns true if it should render otherwise false
  46596. */
  46597. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46598. /**
  46599. * Returns true if the mesh can be rendered, otherwise false.
  46600. * @param mesh The mesh to render
  46601. * @param material The material used on the mesh
  46602. * @returns true if it can be rendered otherwise false
  46603. */
  46604. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46605. /**
  46606. * Returns true if the mesh should render, otherwise false.
  46607. * @param mesh The mesh to render
  46608. * @returns true if it should render otherwise false
  46609. */
  46610. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46611. /**
  46612. * Renders the submesh passed in parameter to the generation map.
  46613. */
  46614. protected _renderSubMesh(subMesh: SubMesh): void;
  46615. /**
  46616. * Rebuild the required buffers.
  46617. * @hidden Internal use only.
  46618. */
  46619. _rebuild(): void;
  46620. /**
  46621. * Dispose only the render target textures and post process.
  46622. */
  46623. private _disposeTextureAndPostProcesses;
  46624. /**
  46625. * Dispose the highlight layer and free resources.
  46626. */
  46627. dispose(): void;
  46628. /**
  46629. * Gets the class name of the effect layer
  46630. * @returns the string with the class name of the effect layer
  46631. */
  46632. getClassName(): string;
  46633. /**
  46634. * Creates an effect layer from parsed effect layer data
  46635. * @param parsedEffectLayer defines effect layer data
  46636. * @param scene defines the current scene
  46637. * @param rootUrl defines the root URL containing the effect layer information
  46638. * @returns a parsed effect Layer
  46639. */
  46640. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46641. }
  46642. }
  46643. declare module BABYLON {
  46644. interface AbstractScene {
  46645. /**
  46646. * The list of effect layers (highlights/glow) added to the scene
  46647. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46648. * @see http://doc.babylonjs.com/how_to/glow_layer
  46649. */
  46650. effectLayers: Array<EffectLayer>;
  46651. /**
  46652. * Removes the given effect layer from this scene.
  46653. * @param toRemove defines the effect layer to remove
  46654. * @returns the index of the removed effect layer
  46655. */
  46656. removeEffectLayer(toRemove: EffectLayer): number;
  46657. /**
  46658. * Adds the given effect layer to this scene
  46659. * @param newEffectLayer defines the effect layer to add
  46660. */
  46661. addEffectLayer(newEffectLayer: EffectLayer): void;
  46662. }
  46663. /**
  46664. * Defines the layer scene component responsible to manage any effect layers
  46665. * in a given scene.
  46666. */
  46667. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46668. /**
  46669. * The component name helpfull to identify the component in the list of scene components.
  46670. */
  46671. readonly name: string;
  46672. /**
  46673. * The scene the component belongs to.
  46674. */
  46675. scene: Scene;
  46676. private _engine;
  46677. private _renderEffects;
  46678. private _needStencil;
  46679. private _previousStencilState;
  46680. /**
  46681. * Creates a new instance of the component for the given scene
  46682. * @param scene Defines the scene to register the component in
  46683. */
  46684. constructor(scene: Scene);
  46685. /**
  46686. * Registers the component in a given scene
  46687. */
  46688. register(): void;
  46689. /**
  46690. * Rebuilds the elements related to this component in case of
  46691. * context lost for instance.
  46692. */
  46693. rebuild(): void;
  46694. /**
  46695. * Serializes the component data to the specified json object
  46696. * @param serializationObject The object to serialize to
  46697. */
  46698. serialize(serializationObject: any): void;
  46699. /**
  46700. * Adds all the element from the container to the scene
  46701. * @param container the container holding the elements
  46702. */
  46703. addFromContainer(container: AbstractScene): void;
  46704. /**
  46705. * Removes all the elements in the container from the scene
  46706. * @param container contains the elements to remove
  46707. * @param dispose if the removed element should be disposed (default: false)
  46708. */
  46709. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46710. /**
  46711. * Disposes the component and the associated ressources.
  46712. */
  46713. dispose(): void;
  46714. private _isReadyForMesh;
  46715. private _renderMainTexture;
  46716. private _setStencil;
  46717. private _setStencilBack;
  46718. private _draw;
  46719. private _drawCamera;
  46720. private _drawRenderingGroup;
  46721. }
  46722. }
  46723. declare module BABYLON {
  46724. /** @hidden */
  46725. export var glowMapMergePixelShader: {
  46726. name: string;
  46727. shader: string;
  46728. };
  46729. }
  46730. declare module BABYLON {
  46731. /** @hidden */
  46732. export var glowMapMergeVertexShader: {
  46733. name: string;
  46734. shader: string;
  46735. };
  46736. }
  46737. declare module BABYLON {
  46738. interface AbstractScene {
  46739. /**
  46740. * Return a the first highlight layer of the scene with a given name.
  46741. * @param name The name of the highlight layer to look for.
  46742. * @return The highlight layer if found otherwise null.
  46743. */
  46744. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46745. }
  46746. /**
  46747. * Glow layer options. This helps customizing the behaviour
  46748. * of the glow layer.
  46749. */
  46750. export interface IGlowLayerOptions {
  46751. /**
  46752. * Multiplication factor apply to the canvas size to compute the render target size
  46753. * used to generated the glowing objects (the smaller the faster).
  46754. */
  46755. mainTextureRatio: number;
  46756. /**
  46757. * Enforces a fixed size texture to ensure resize independant blur.
  46758. */
  46759. mainTextureFixedSize?: number;
  46760. /**
  46761. * How big is the kernel of the blur texture.
  46762. */
  46763. blurKernelSize: number;
  46764. /**
  46765. * The camera attached to the layer.
  46766. */
  46767. camera: Nullable<Camera>;
  46768. /**
  46769. * Enable MSAA by chosing the number of samples.
  46770. */
  46771. mainTextureSamples?: number;
  46772. /**
  46773. * The rendering group to draw the layer in.
  46774. */
  46775. renderingGroupId: number;
  46776. }
  46777. /**
  46778. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46779. *
  46780. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46781. * glowy meshes to your scene.
  46782. *
  46783. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46784. */
  46785. export class GlowLayer extends EffectLayer {
  46786. /**
  46787. * Effect Name of the layer.
  46788. */
  46789. static readonly EffectName: string;
  46790. /**
  46791. * The default blur kernel size used for the glow.
  46792. */
  46793. static DefaultBlurKernelSize: number;
  46794. /**
  46795. * The default texture size ratio used for the glow.
  46796. */
  46797. static DefaultTextureRatio: number;
  46798. /**
  46799. * Sets the kernel size of the blur.
  46800. */
  46801. /**
  46802. * Gets the kernel size of the blur.
  46803. */
  46804. blurKernelSize: number;
  46805. /**
  46806. * Sets the glow intensity.
  46807. */
  46808. /**
  46809. * Gets the glow intensity.
  46810. */
  46811. intensity: number;
  46812. private _options;
  46813. private _intensity;
  46814. private _horizontalBlurPostprocess1;
  46815. private _verticalBlurPostprocess1;
  46816. private _horizontalBlurPostprocess2;
  46817. private _verticalBlurPostprocess2;
  46818. private _blurTexture1;
  46819. private _blurTexture2;
  46820. private _postProcesses1;
  46821. private _postProcesses2;
  46822. private _includedOnlyMeshes;
  46823. private _excludedMeshes;
  46824. /**
  46825. * Callback used to let the user override the color selection on a per mesh basis
  46826. */
  46827. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46828. /**
  46829. * Callback used to let the user override the texture selection on a per mesh basis
  46830. */
  46831. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46832. /**
  46833. * Instantiates a new glow Layer and references it to the scene.
  46834. * @param name The name of the layer
  46835. * @param scene The scene to use the layer in
  46836. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46837. */
  46838. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46839. /**
  46840. * Get the effect name of the layer.
  46841. * @return The effect name
  46842. */
  46843. getEffectName(): string;
  46844. /**
  46845. * Create the merge effect. This is the shader use to blit the information back
  46846. * to the main canvas at the end of the scene rendering.
  46847. */
  46848. protected _createMergeEffect(): Effect;
  46849. /**
  46850. * Creates the render target textures and post processes used in the glow layer.
  46851. */
  46852. protected _createTextureAndPostProcesses(): void;
  46853. /**
  46854. * Checks for the readiness of the element composing the layer.
  46855. * @param subMesh the mesh to check for
  46856. * @param useInstances specify wether or not to use instances to render the mesh
  46857. * @param emissiveTexture the associated emissive texture used to generate the glow
  46858. * @return true if ready otherwise, false
  46859. */
  46860. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46861. /**
  46862. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46863. */
  46864. needStencil(): boolean;
  46865. /**
  46866. * Returns true if the mesh can be rendered, otherwise false.
  46867. * @param mesh The mesh to render
  46868. * @param material The material used on the mesh
  46869. * @returns true if it can be rendered otherwise false
  46870. */
  46871. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46872. /**
  46873. * Implementation specific of rendering the generating effect on the main canvas.
  46874. * @param effect The effect used to render through
  46875. */
  46876. protected _internalRender(effect: Effect): void;
  46877. /**
  46878. * Sets the required values for both the emissive texture and and the main color.
  46879. */
  46880. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46881. /**
  46882. * Returns true if the mesh should render, otherwise false.
  46883. * @param mesh The mesh to render
  46884. * @returns true if it should render otherwise false
  46885. */
  46886. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46887. /**
  46888. * Adds specific effects defines.
  46889. * @param defines The defines to add specifics to.
  46890. */
  46891. protected _addCustomEffectDefines(defines: string[]): void;
  46892. /**
  46893. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46894. * @param mesh The mesh to exclude from the glow layer
  46895. */
  46896. addExcludedMesh(mesh: Mesh): void;
  46897. /**
  46898. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46899. * @param mesh The mesh to remove
  46900. */
  46901. removeExcludedMesh(mesh: Mesh): void;
  46902. /**
  46903. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46904. * @param mesh The mesh to include in the glow layer
  46905. */
  46906. addIncludedOnlyMesh(mesh: Mesh): void;
  46907. /**
  46908. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46909. * @param mesh The mesh to remove
  46910. */
  46911. removeIncludedOnlyMesh(mesh: Mesh): void;
  46912. /**
  46913. * Determine if a given mesh will be used in the glow layer
  46914. * @param mesh The mesh to test
  46915. * @returns true if the mesh will be highlighted by the current glow layer
  46916. */
  46917. hasMesh(mesh: AbstractMesh): boolean;
  46918. /**
  46919. * Free any resources and references associated to a mesh.
  46920. * Internal use
  46921. * @param mesh The mesh to free.
  46922. * @hidden
  46923. */
  46924. _disposeMesh(mesh: Mesh): void;
  46925. /**
  46926. * Gets the class name of the effect layer
  46927. * @returns the string with the class name of the effect layer
  46928. */
  46929. getClassName(): string;
  46930. /**
  46931. * Serializes this glow layer
  46932. * @returns a serialized glow layer object
  46933. */
  46934. serialize(): any;
  46935. /**
  46936. * Creates a Glow Layer from parsed glow layer data
  46937. * @param parsedGlowLayer defines glow layer data
  46938. * @param scene defines the current scene
  46939. * @param rootUrl defines the root URL containing the glow layer information
  46940. * @returns a parsed Glow Layer
  46941. */
  46942. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46943. }
  46944. }
  46945. declare module BABYLON {
  46946. /** @hidden */
  46947. export var glowBlurPostProcessPixelShader: {
  46948. name: string;
  46949. shader: string;
  46950. };
  46951. }
  46952. declare module BABYLON {
  46953. interface AbstractScene {
  46954. /**
  46955. * Return a the first highlight layer of the scene with a given name.
  46956. * @param name The name of the highlight layer to look for.
  46957. * @return The highlight layer if found otherwise null.
  46958. */
  46959. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46960. }
  46961. /**
  46962. * Highlight layer options. This helps customizing the behaviour
  46963. * of the highlight layer.
  46964. */
  46965. export interface IHighlightLayerOptions {
  46966. /**
  46967. * Multiplication factor apply to the canvas size to compute the render target size
  46968. * used to generated the glowing objects (the smaller the faster).
  46969. */
  46970. mainTextureRatio: number;
  46971. /**
  46972. * Enforces a fixed size texture to ensure resize independant blur.
  46973. */
  46974. mainTextureFixedSize?: number;
  46975. /**
  46976. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46977. * of the picture to blur (the smaller the faster).
  46978. */
  46979. blurTextureSizeRatio: number;
  46980. /**
  46981. * How big in texel of the blur texture is the vertical blur.
  46982. */
  46983. blurVerticalSize: number;
  46984. /**
  46985. * How big in texel of the blur texture is the horizontal blur.
  46986. */
  46987. blurHorizontalSize: number;
  46988. /**
  46989. * Alpha blending mode used to apply the blur. Default is combine.
  46990. */
  46991. alphaBlendingMode: number;
  46992. /**
  46993. * The camera attached to the layer.
  46994. */
  46995. camera: Nullable<Camera>;
  46996. /**
  46997. * Should we display highlight as a solid stroke?
  46998. */
  46999. isStroke?: boolean;
  47000. /**
  47001. * The rendering group to draw the layer in.
  47002. */
  47003. renderingGroupId: number;
  47004. }
  47005. /**
  47006. * The highlight layer Helps adding a glow effect around a mesh.
  47007. *
  47008. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47009. * glowy meshes to your scene.
  47010. *
  47011. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47012. */
  47013. export class HighlightLayer extends EffectLayer {
  47014. name: string;
  47015. /**
  47016. * Effect Name of the highlight layer.
  47017. */
  47018. static readonly EffectName: string;
  47019. /**
  47020. * The neutral color used during the preparation of the glow effect.
  47021. * This is black by default as the blend operation is a blend operation.
  47022. */
  47023. static NeutralColor: Color4;
  47024. /**
  47025. * Stencil value used for glowing meshes.
  47026. */
  47027. static GlowingMeshStencilReference: number;
  47028. /**
  47029. * Stencil value used for the other meshes in the scene.
  47030. */
  47031. static NormalMeshStencilReference: number;
  47032. /**
  47033. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47034. */
  47035. innerGlow: boolean;
  47036. /**
  47037. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47038. */
  47039. outerGlow: boolean;
  47040. /**
  47041. * Specifies the horizontal size of the blur.
  47042. */
  47043. /**
  47044. * Gets the horizontal size of the blur.
  47045. */
  47046. blurHorizontalSize: number;
  47047. /**
  47048. * Specifies the vertical size of the blur.
  47049. */
  47050. /**
  47051. * Gets the vertical size of the blur.
  47052. */
  47053. blurVerticalSize: number;
  47054. /**
  47055. * An event triggered when the highlight layer is being blurred.
  47056. */
  47057. onBeforeBlurObservable: Observable<HighlightLayer>;
  47058. /**
  47059. * An event triggered when the highlight layer has been blurred.
  47060. */
  47061. onAfterBlurObservable: Observable<HighlightLayer>;
  47062. private _instanceGlowingMeshStencilReference;
  47063. private _options;
  47064. private _downSamplePostprocess;
  47065. private _horizontalBlurPostprocess;
  47066. private _verticalBlurPostprocess;
  47067. private _blurTexture;
  47068. private _meshes;
  47069. private _excludedMeshes;
  47070. /**
  47071. * Instantiates a new highlight Layer and references it to the scene..
  47072. * @param name The name of the layer
  47073. * @param scene The scene to use the layer in
  47074. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47075. */
  47076. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47077. /**
  47078. * Get the effect name of the layer.
  47079. * @return The effect name
  47080. */
  47081. getEffectName(): string;
  47082. /**
  47083. * Create the merge effect. This is the shader use to blit the information back
  47084. * to the main canvas at the end of the scene rendering.
  47085. */
  47086. protected _createMergeEffect(): Effect;
  47087. /**
  47088. * Creates the render target textures and post processes used in the highlight layer.
  47089. */
  47090. protected _createTextureAndPostProcesses(): void;
  47091. /**
  47092. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47093. */
  47094. needStencil(): boolean;
  47095. /**
  47096. * Checks for the readiness of the element composing the layer.
  47097. * @param subMesh the mesh to check for
  47098. * @param useInstances specify wether or not to use instances to render the mesh
  47099. * @param emissiveTexture the associated emissive texture used to generate the glow
  47100. * @return true if ready otherwise, false
  47101. */
  47102. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47103. /**
  47104. * Implementation specific of rendering the generating effect on the main canvas.
  47105. * @param effect The effect used to render through
  47106. */
  47107. protected _internalRender(effect: Effect): void;
  47108. /**
  47109. * Returns true if the layer contains information to display, otherwise false.
  47110. */
  47111. shouldRender(): boolean;
  47112. /**
  47113. * Returns true if the mesh should render, otherwise false.
  47114. * @param mesh The mesh to render
  47115. * @returns true if it should render otherwise false
  47116. */
  47117. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47118. /**
  47119. * Sets the required values for both the emissive texture and and the main color.
  47120. */
  47121. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47122. /**
  47123. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47124. * @param mesh The mesh to exclude from the highlight layer
  47125. */
  47126. addExcludedMesh(mesh: Mesh): void;
  47127. /**
  47128. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47129. * @param mesh The mesh to highlight
  47130. */
  47131. removeExcludedMesh(mesh: Mesh): void;
  47132. /**
  47133. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47134. * @param mesh mesh to test
  47135. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47136. */
  47137. hasMesh(mesh: AbstractMesh): boolean;
  47138. /**
  47139. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47140. * @param mesh The mesh to highlight
  47141. * @param color The color of the highlight
  47142. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47143. */
  47144. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47145. /**
  47146. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47147. * @param mesh The mesh to highlight
  47148. */
  47149. removeMesh(mesh: Mesh): void;
  47150. /**
  47151. * Force the stencil to the normal expected value for none glowing parts
  47152. */
  47153. private _defaultStencilReference;
  47154. /**
  47155. * Free any resources and references associated to a mesh.
  47156. * Internal use
  47157. * @param mesh The mesh to free.
  47158. * @hidden
  47159. */
  47160. _disposeMesh(mesh: Mesh): void;
  47161. /**
  47162. * Dispose the highlight layer and free resources.
  47163. */
  47164. dispose(): void;
  47165. /**
  47166. * Gets the class name of the effect layer
  47167. * @returns the string with the class name of the effect layer
  47168. */
  47169. getClassName(): string;
  47170. /**
  47171. * Serializes this Highlight layer
  47172. * @returns a serialized Highlight layer object
  47173. */
  47174. serialize(): any;
  47175. /**
  47176. * Creates a Highlight layer from parsed Highlight layer data
  47177. * @param parsedHightlightLayer defines the Highlight layer data
  47178. * @param scene defines the current scene
  47179. * @param rootUrl defines the root URL containing the Highlight layer information
  47180. * @returns a parsed Highlight layer
  47181. */
  47182. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47183. }
  47184. }
  47185. declare module BABYLON {
  47186. /** @hidden */
  47187. export var lensFlarePixelShader: {
  47188. name: string;
  47189. shader: string;
  47190. };
  47191. }
  47192. declare module BABYLON {
  47193. /** @hidden */
  47194. export var lensFlareVertexShader: {
  47195. name: string;
  47196. shader: string;
  47197. };
  47198. }
  47199. declare module BABYLON {
  47200. /**
  47201. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47202. * It is usually composed of several `lensFlare`.
  47203. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47204. */
  47205. export class LensFlareSystem {
  47206. /**
  47207. * Define the name of the lens flare system
  47208. */
  47209. name: string;
  47210. /**
  47211. * List of lens flares used in this system.
  47212. */
  47213. lensFlares: LensFlare[];
  47214. /**
  47215. * Define a limit from the border the lens flare can be visible.
  47216. */
  47217. borderLimit: number;
  47218. /**
  47219. * Define a viewport border we do not want to see the lens flare in.
  47220. */
  47221. viewportBorder: number;
  47222. /**
  47223. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47224. */
  47225. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47226. /**
  47227. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47228. */
  47229. layerMask: number;
  47230. /**
  47231. * Define the id of the lens flare system in the scene.
  47232. * (equal to name by default)
  47233. */
  47234. id: string;
  47235. private _scene;
  47236. private _emitter;
  47237. private _vertexBuffers;
  47238. private _indexBuffer;
  47239. private _effect;
  47240. private _positionX;
  47241. private _positionY;
  47242. private _isEnabled;
  47243. /** @hidden */
  47244. static _SceneComponentInitialization: (scene: Scene) => void;
  47245. /**
  47246. * Instantiates a lens flare system.
  47247. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47248. * It is usually composed of several `lensFlare`.
  47249. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47250. * @param name Define the name of the lens flare system in the scene
  47251. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47252. * @param scene Define the scene the lens flare system belongs to
  47253. */
  47254. constructor(
  47255. /**
  47256. * Define the name of the lens flare system
  47257. */
  47258. name: string, emitter: any, scene: Scene);
  47259. /**
  47260. * Define if the lens flare system is enabled.
  47261. */
  47262. isEnabled: boolean;
  47263. /**
  47264. * Get the scene the effects belongs to.
  47265. * @returns the scene holding the lens flare system
  47266. */
  47267. getScene(): Scene;
  47268. /**
  47269. * Get the emitter of the lens flare system.
  47270. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47271. * @returns the emitter of the lens flare system
  47272. */
  47273. getEmitter(): any;
  47274. /**
  47275. * Set the emitter of the lens flare system.
  47276. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47277. * @param newEmitter Define the new emitter of the system
  47278. */
  47279. setEmitter(newEmitter: any): void;
  47280. /**
  47281. * Get the lens flare system emitter position.
  47282. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47283. * @returns the position
  47284. */
  47285. getEmitterPosition(): Vector3;
  47286. /**
  47287. * @hidden
  47288. */
  47289. computeEffectivePosition(globalViewport: Viewport): boolean;
  47290. /** @hidden */
  47291. _isVisible(): boolean;
  47292. /**
  47293. * @hidden
  47294. */
  47295. render(): boolean;
  47296. /**
  47297. * Dispose and release the lens flare with its associated resources.
  47298. */
  47299. dispose(): void;
  47300. /**
  47301. * Parse a lens flare system from a JSON repressentation
  47302. * @param parsedLensFlareSystem Define the JSON to parse
  47303. * @param scene Define the scene the parsed system should be instantiated in
  47304. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47305. * @returns the parsed system
  47306. */
  47307. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47308. /**
  47309. * Serialize the current Lens Flare System into a JSON representation.
  47310. * @returns the serialized JSON
  47311. */
  47312. serialize(): any;
  47313. }
  47314. }
  47315. declare module BABYLON {
  47316. /**
  47317. * This represents one of the lens effect in a `lensFlareSystem`.
  47318. * It controls one of the indiviual texture used in the effect.
  47319. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47320. */
  47321. export class LensFlare {
  47322. /**
  47323. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47324. */
  47325. size: number;
  47326. /**
  47327. * 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.
  47328. */
  47329. position: number;
  47330. /**
  47331. * Define the lens color.
  47332. */
  47333. color: Color3;
  47334. /**
  47335. * Define the lens texture.
  47336. */
  47337. texture: Nullable<Texture>;
  47338. /**
  47339. * Define the alpha mode to render this particular lens.
  47340. */
  47341. alphaMode: number;
  47342. private _system;
  47343. /**
  47344. * Creates a new Lens Flare.
  47345. * This represents one of the lens effect in a `lensFlareSystem`.
  47346. * It controls one of the indiviual texture used in the effect.
  47347. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47348. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47349. * @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.
  47350. * @param color Define the lens color
  47351. * @param imgUrl Define the lens texture url
  47352. * @param system Define the `lensFlareSystem` this flare is part of
  47353. * @returns The newly created Lens Flare
  47354. */
  47355. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47356. /**
  47357. * Instantiates a new Lens Flare.
  47358. * This represents one of the lens effect in a `lensFlareSystem`.
  47359. * It controls one of the indiviual texture used in the effect.
  47360. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47361. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47362. * @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.
  47363. * @param color Define the lens color
  47364. * @param imgUrl Define the lens texture url
  47365. * @param system Define the `lensFlareSystem` this flare is part of
  47366. */
  47367. constructor(
  47368. /**
  47369. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47370. */
  47371. size: number,
  47372. /**
  47373. * 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.
  47374. */
  47375. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47376. /**
  47377. * Dispose and release the lens flare with its associated resources.
  47378. */
  47379. dispose(): void;
  47380. }
  47381. }
  47382. declare module BABYLON {
  47383. interface AbstractScene {
  47384. /**
  47385. * The list of lens flare system added to the scene
  47386. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47387. */
  47388. lensFlareSystems: Array<LensFlareSystem>;
  47389. /**
  47390. * Removes the given lens flare system from this scene.
  47391. * @param toRemove The lens flare system to remove
  47392. * @returns The index of the removed lens flare system
  47393. */
  47394. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47395. /**
  47396. * Adds the given lens flare system to this scene
  47397. * @param newLensFlareSystem The lens flare system to add
  47398. */
  47399. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47400. /**
  47401. * Gets a lens flare system using its name
  47402. * @param name defines the name to look for
  47403. * @returns the lens flare system or null if not found
  47404. */
  47405. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47406. /**
  47407. * Gets a lens flare system using its id
  47408. * @param id defines the id to look for
  47409. * @returns the lens flare system or null if not found
  47410. */
  47411. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47412. }
  47413. /**
  47414. * Defines the lens flare scene component responsible to manage any lens flares
  47415. * in a given scene.
  47416. */
  47417. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47418. /**
  47419. * The component name helpfull to identify the component in the list of scene components.
  47420. */
  47421. readonly name: string;
  47422. /**
  47423. * The scene the component belongs to.
  47424. */
  47425. scene: Scene;
  47426. /**
  47427. * Creates a new instance of the component for the given scene
  47428. * @param scene Defines the scene to register the component in
  47429. */
  47430. constructor(scene: Scene);
  47431. /**
  47432. * Registers the component in a given scene
  47433. */
  47434. register(): void;
  47435. /**
  47436. * Rebuilds the elements related to this component in case of
  47437. * context lost for instance.
  47438. */
  47439. rebuild(): void;
  47440. /**
  47441. * Adds all the element from the container to the scene
  47442. * @param container the container holding the elements
  47443. */
  47444. addFromContainer(container: AbstractScene): void;
  47445. /**
  47446. * Removes all the elements in the container from the scene
  47447. * @param container contains the elements to remove
  47448. * @param dispose if the removed element should be disposed (default: false)
  47449. */
  47450. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47451. /**
  47452. * Serializes the component data to the specified json object
  47453. * @param serializationObject The object to serialize to
  47454. */
  47455. serialize(serializationObject: any): void;
  47456. /**
  47457. * Disposes the component and the associated ressources.
  47458. */
  47459. dispose(): void;
  47460. private _draw;
  47461. }
  47462. }
  47463. declare module BABYLON {
  47464. /**
  47465. * Defines the shadow generator component responsible to manage any shadow generators
  47466. * in a given scene.
  47467. */
  47468. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47469. /**
  47470. * The component name helpfull to identify the component in the list of scene components.
  47471. */
  47472. readonly name: string;
  47473. /**
  47474. * The scene the component belongs to.
  47475. */
  47476. scene: Scene;
  47477. /**
  47478. * Creates a new instance of the component for the given scene
  47479. * @param scene Defines the scene to register the component in
  47480. */
  47481. constructor(scene: Scene);
  47482. /**
  47483. * Registers the component in a given scene
  47484. */
  47485. register(): void;
  47486. /**
  47487. * Rebuilds the elements related to this component in case of
  47488. * context lost for instance.
  47489. */
  47490. rebuild(): void;
  47491. /**
  47492. * Serializes the component data to the specified json object
  47493. * @param serializationObject The object to serialize to
  47494. */
  47495. serialize(serializationObject: any): void;
  47496. /**
  47497. * Adds all the element from the container to the scene
  47498. * @param container the container holding the elements
  47499. */
  47500. addFromContainer(container: AbstractScene): void;
  47501. /**
  47502. * Removes all the elements in the container from the scene
  47503. * @param container contains the elements to remove
  47504. * @param dispose if the removed element should be disposed (default: false)
  47505. */
  47506. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47507. /**
  47508. * Rebuilds the elements related to this component in case of
  47509. * context lost for instance.
  47510. */
  47511. dispose(): void;
  47512. private _gatherRenderTargets;
  47513. }
  47514. }
  47515. declare module BABYLON {
  47516. /**
  47517. * A point light is a light defined by an unique point in world space.
  47518. * The light is emitted in every direction from this point.
  47519. * A good example of a point light is a standard light bulb.
  47520. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47521. */
  47522. export class PointLight extends ShadowLight {
  47523. private _shadowAngle;
  47524. /**
  47525. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47526. * This specifies what angle the shadow will use to be created.
  47527. *
  47528. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47529. */
  47530. /**
  47531. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47532. * This specifies what angle the shadow will use to be created.
  47533. *
  47534. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47535. */
  47536. shadowAngle: number;
  47537. /**
  47538. * Gets the direction if it has been set.
  47539. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47540. */
  47541. /**
  47542. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47543. */
  47544. direction: Vector3;
  47545. /**
  47546. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47547. * A PointLight emits the light in every direction.
  47548. * It can cast shadows.
  47549. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47550. * ```javascript
  47551. * var pointLight = new PointLight("pl", camera.position, scene);
  47552. * ```
  47553. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47554. * @param name The light friendly name
  47555. * @param position The position of the point light in the scene
  47556. * @param scene The scene the lights belongs to
  47557. */
  47558. constructor(name: string, position: Vector3, scene: Scene);
  47559. /**
  47560. * Returns the string "PointLight"
  47561. * @returns the class name
  47562. */
  47563. getClassName(): string;
  47564. /**
  47565. * Returns the integer 0.
  47566. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47567. */
  47568. getTypeID(): number;
  47569. /**
  47570. * Specifies wether or not the shadowmap should be a cube texture.
  47571. * @returns true if the shadowmap needs to be a cube texture.
  47572. */
  47573. needCube(): boolean;
  47574. /**
  47575. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47576. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47577. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47578. */
  47579. getShadowDirection(faceIndex?: number): Vector3;
  47580. /**
  47581. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47582. * - fov = PI / 2
  47583. * - aspect ratio : 1.0
  47584. * - z-near and far equal to the active camera minZ and maxZ.
  47585. * Returns the PointLight.
  47586. */
  47587. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47588. protected _buildUniformLayout(): void;
  47589. /**
  47590. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47591. * @param effect The effect to update
  47592. * @param lightIndex The index of the light in the effect to update
  47593. * @returns The point light
  47594. */
  47595. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47596. /**
  47597. * Prepares the list of defines specific to the light type.
  47598. * @param defines the list of defines
  47599. * @param lightIndex defines the index of the light for the effect
  47600. */
  47601. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47602. }
  47603. }
  47604. declare module BABYLON {
  47605. /**
  47606. * Header information of HDR texture files.
  47607. */
  47608. export interface HDRInfo {
  47609. /**
  47610. * The height of the texture in pixels.
  47611. */
  47612. height: number;
  47613. /**
  47614. * The width of the texture in pixels.
  47615. */
  47616. width: number;
  47617. /**
  47618. * The index of the beginning of the data in the binary file.
  47619. */
  47620. dataPosition: number;
  47621. }
  47622. /**
  47623. * This groups tools to convert HDR texture to native colors array.
  47624. */
  47625. export class HDRTools {
  47626. private static Ldexp;
  47627. private static Rgbe2float;
  47628. private static readStringLine;
  47629. /**
  47630. * Reads header information from an RGBE texture stored in a native array.
  47631. * More information on this format are available here:
  47632. * https://en.wikipedia.org/wiki/RGBE_image_format
  47633. *
  47634. * @param uint8array The binary file stored in native array.
  47635. * @return The header information.
  47636. */
  47637. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47638. /**
  47639. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47640. * This RGBE texture needs to store the information as a panorama.
  47641. *
  47642. * More information on this format are available here:
  47643. * https://en.wikipedia.org/wiki/RGBE_image_format
  47644. *
  47645. * @param buffer The binary file stored in an array buffer.
  47646. * @param size The expected size of the extracted cubemap.
  47647. * @return The Cube Map information.
  47648. */
  47649. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47650. /**
  47651. * Returns the pixels data extracted from an RGBE texture.
  47652. * This pixels will be stored left to right up to down in the R G B order in one array.
  47653. *
  47654. * More information on this format are available here:
  47655. * https://en.wikipedia.org/wiki/RGBE_image_format
  47656. *
  47657. * @param uint8array The binary file stored in an array buffer.
  47658. * @param hdrInfo The header information of the file.
  47659. * @return The pixels data in RGB right to left up to down order.
  47660. */
  47661. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47662. private static RGBE_ReadPixels_RLE;
  47663. }
  47664. }
  47665. declare module BABYLON {
  47666. /**
  47667. * This represents a texture coming from an HDR input.
  47668. *
  47669. * The only supported format is currently panorama picture stored in RGBE format.
  47670. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47671. */
  47672. export class HDRCubeTexture extends BaseTexture {
  47673. private static _facesMapping;
  47674. private _generateHarmonics;
  47675. private _noMipmap;
  47676. private _textureMatrix;
  47677. private _size;
  47678. private _onLoad;
  47679. private _onError;
  47680. /**
  47681. * The texture URL.
  47682. */
  47683. url: string;
  47684. /**
  47685. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47686. */
  47687. coordinatesMode: number;
  47688. protected _isBlocking: boolean;
  47689. /**
  47690. * Sets wether or not the texture is blocking during loading.
  47691. */
  47692. /**
  47693. * Gets wether or not the texture is blocking during loading.
  47694. */
  47695. isBlocking: boolean;
  47696. protected _rotationY: number;
  47697. /**
  47698. * Sets texture matrix rotation angle around Y axis in radians.
  47699. */
  47700. /**
  47701. * Gets texture matrix rotation angle around Y axis radians.
  47702. */
  47703. rotationY: number;
  47704. /**
  47705. * Gets or sets the center of the bounding box associated with the cube texture
  47706. * It must define where the camera used to render the texture was set
  47707. */
  47708. boundingBoxPosition: Vector3;
  47709. private _boundingBoxSize;
  47710. /**
  47711. * Gets or sets the size of the bounding box associated with the cube texture
  47712. * When defined, the cubemap will switch to local mode
  47713. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47714. * @example https://www.babylonjs-playground.com/#RNASML
  47715. */
  47716. boundingBoxSize: Vector3;
  47717. /**
  47718. * Instantiates an HDRTexture from the following parameters.
  47719. *
  47720. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47721. * @param scene The scene the texture will be used in
  47722. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47723. * @param noMipmap Forces to not generate the mipmap if true
  47724. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47725. * @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)
  47726. * @param reserved Reserved flag for internal use.
  47727. */
  47728. 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>);
  47729. /**
  47730. * Get the current class name of the texture useful for serialization or dynamic coding.
  47731. * @returns "HDRCubeTexture"
  47732. */
  47733. getClassName(): string;
  47734. /**
  47735. * Occurs when the file is raw .hdr file.
  47736. */
  47737. private loadTexture;
  47738. clone(): HDRCubeTexture;
  47739. delayLoad(): void;
  47740. /**
  47741. * Get the texture reflection matrix used to rotate/transform the reflection.
  47742. * @returns the reflection matrix
  47743. */
  47744. getReflectionTextureMatrix(): Matrix;
  47745. /**
  47746. * Set the texture reflection matrix used to rotate/transform the reflection.
  47747. * @param value Define the reflection matrix to set
  47748. */
  47749. setReflectionTextureMatrix(value: Matrix): void;
  47750. /**
  47751. * Parses a JSON representation of an HDR Texture in order to create the texture
  47752. * @param parsedTexture Define the JSON representation
  47753. * @param scene Define the scene the texture should be created in
  47754. * @param rootUrl Define the root url in case we need to load relative dependencies
  47755. * @returns the newly created texture after parsing
  47756. */
  47757. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47758. serialize(): any;
  47759. }
  47760. }
  47761. declare module BABYLON {
  47762. /**
  47763. * Class used to control physics engine
  47764. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47765. */
  47766. export class PhysicsEngine implements IPhysicsEngine {
  47767. private _physicsPlugin;
  47768. /**
  47769. * Global value used to control the smallest number supported by the simulation
  47770. */
  47771. static Epsilon: number;
  47772. private _impostors;
  47773. private _joints;
  47774. /**
  47775. * Gets the gravity vector used by the simulation
  47776. */
  47777. gravity: Vector3;
  47778. /**
  47779. * Factory used to create the default physics plugin.
  47780. * @returns The default physics plugin
  47781. */
  47782. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47783. /**
  47784. * Creates a new Physics Engine
  47785. * @param gravity defines the gravity vector used by the simulation
  47786. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47787. */
  47788. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47789. /**
  47790. * Sets the gravity vector used by the simulation
  47791. * @param gravity defines the gravity vector to use
  47792. */
  47793. setGravity(gravity: Vector3): void;
  47794. /**
  47795. * Set the time step of the physics engine.
  47796. * Default is 1/60.
  47797. * To slow it down, enter 1/600 for example.
  47798. * To speed it up, 1/30
  47799. * @param newTimeStep defines the new timestep to apply to this world.
  47800. */
  47801. setTimeStep(newTimeStep?: number): void;
  47802. /**
  47803. * Get the time step of the physics engine.
  47804. * @returns the current time step
  47805. */
  47806. getTimeStep(): number;
  47807. /**
  47808. * Release all resources
  47809. */
  47810. dispose(): void;
  47811. /**
  47812. * Gets the name of the current physics plugin
  47813. * @returns the name of the plugin
  47814. */
  47815. getPhysicsPluginName(): string;
  47816. /**
  47817. * Adding a new impostor for the impostor tracking.
  47818. * This will be done by the impostor itself.
  47819. * @param impostor the impostor to add
  47820. */
  47821. addImpostor(impostor: PhysicsImpostor): void;
  47822. /**
  47823. * Remove an impostor from the engine.
  47824. * This impostor and its mesh will not longer be updated by the physics engine.
  47825. * @param impostor the impostor to remove
  47826. */
  47827. removeImpostor(impostor: PhysicsImpostor): void;
  47828. /**
  47829. * Add a joint to the physics engine
  47830. * @param mainImpostor defines the main impostor to which the joint is added.
  47831. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47832. * @param joint defines the joint that will connect both impostors.
  47833. */
  47834. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47835. /**
  47836. * Removes a joint from the simulation
  47837. * @param mainImpostor defines the impostor used with the joint
  47838. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47839. * @param joint defines the joint to remove
  47840. */
  47841. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47842. /**
  47843. * Called by the scene. No need to call it.
  47844. * @param delta defines the timespam between frames
  47845. */
  47846. _step(delta: number): void;
  47847. /**
  47848. * Gets the current plugin used to run the simulation
  47849. * @returns current plugin
  47850. */
  47851. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47852. /**
  47853. * Gets the list of physic impostors
  47854. * @returns an array of PhysicsImpostor
  47855. */
  47856. getImpostors(): Array<PhysicsImpostor>;
  47857. /**
  47858. * Gets the impostor for a physics enabled object
  47859. * @param object defines the object impersonated by the impostor
  47860. * @returns the PhysicsImpostor or null if not found
  47861. */
  47862. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47863. /**
  47864. * Gets the impostor for a physics body object
  47865. * @param body defines physics body used by the impostor
  47866. * @returns the PhysicsImpostor or null if not found
  47867. */
  47868. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47869. /**
  47870. * Does a raycast in the physics world
  47871. * @param from when should the ray start?
  47872. * @param to when should the ray end?
  47873. * @returns PhysicsRaycastResult
  47874. */
  47875. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47876. }
  47877. }
  47878. declare module BABYLON {
  47879. /** @hidden */
  47880. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47881. private _useDeltaForWorldStep;
  47882. world: any;
  47883. name: string;
  47884. private _physicsMaterials;
  47885. private _fixedTimeStep;
  47886. private _cannonRaycastResult;
  47887. private _raycastResult;
  47888. private _removeAfterStep;
  47889. BJSCANNON: any;
  47890. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47891. setGravity(gravity: Vector3): void;
  47892. setTimeStep(timeStep: number): void;
  47893. getTimeStep(): number;
  47894. executeStep(delta: number): void;
  47895. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47896. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47897. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47898. private _processChildMeshes;
  47899. removePhysicsBody(impostor: PhysicsImpostor): void;
  47900. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47901. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47902. private _addMaterial;
  47903. private _checkWithEpsilon;
  47904. private _createShape;
  47905. private _createHeightmap;
  47906. private _minus90X;
  47907. private _plus90X;
  47908. private _tmpPosition;
  47909. private _tmpDeltaPosition;
  47910. private _tmpUnityRotation;
  47911. private _updatePhysicsBodyTransformation;
  47912. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47913. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47914. isSupported(): boolean;
  47915. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47916. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47917. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47918. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47919. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47920. getBodyMass(impostor: PhysicsImpostor): number;
  47921. getBodyFriction(impostor: PhysicsImpostor): number;
  47922. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47923. getBodyRestitution(impostor: PhysicsImpostor): number;
  47924. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47925. sleepBody(impostor: PhysicsImpostor): void;
  47926. wakeUpBody(impostor: PhysicsImpostor): void;
  47927. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47928. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47929. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47930. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47931. getRadius(impostor: PhysicsImpostor): number;
  47932. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47933. dispose(): void;
  47934. private _extendNamespace;
  47935. /**
  47936. * Does a raycast in the physics world
  47937. * @param from when should the ray start?
  47938. * @param to when should the ray end?
  47939. * @returns PhysicsRaycastResult
  47940. */
  47941. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47942. }
  47943. }
  47944. declare module BABYLON {
  47945. /** @hidden */
  47946. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47947. world: any;
  47948. name: string;
  47949. BJSOIMO: any;
  47950. private _raycastResult;
  47951. constructor(iterations?: number, oimoInjection?: any);
  47952. setGravity(gravity: Vector3): void;
  47953. setTimeStep(timeStep: number): void;
  47954. getTimeStep(): number;
  47955. private _tmpImpostorsArray;
  47956. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47957. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47958. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47959. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47960. private _tmpPositionVector;
  47961. removePhysicsBody(impostor: PhysicsImpostor): void;
  47962. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47963. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47964. isSupported(): boolean;
  47965. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47966. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47967. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47968. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47969. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47970. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47971. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47972. getBodyMass(impostor: PhysicsImpostor): number;
  47973. getBodyFriction(impostor: PhysicsImpostor): number;
  47974. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47975. getBodyRestitution(impostor: PhysicsImpostor): number;
  47976. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47977. sleepBody(impostor: PhysicsImpostor): void;
  47978. wakeUpBody(impostor: PhysicsImpostor): void;
  47979. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47980. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47981. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47982. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47983. getRadius(impostor: PhysicsImpostor): number;
  47984. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47985. dispose(): void;
  47986. /**
  47987. * Does a raycast in the physics world
  47988. * @param from when should the ray start?
  47989. * @param to when should the ray end?
  47990. * @returns PhysicsRaycastResult
  47991. */
  47992. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47993. }
  47994. }
  47995. declare module BABYLON {
  47996. /**
  47997. * Class containing static functions to help procedurally build meshes
  47998. */
  47999. export class RibbonBuilder {
  48000. /**
  48001. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48002. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48003. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48004. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48005. * * 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
  48006. * * 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
  48007. * * 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
  48008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48009. * * 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
  48010. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48011. * * 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
  48012. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48013. * * 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
  48014. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48016. * @param name defines the name of the mesh
  48017. * @param options defines the options used to create the mesh
  48018. * @param scene defines the hosting scene
  48019. * @returns the ribbon mesh
  48020. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48021. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48022. */
  48023. static CreateRibbon(name: string, options: {
  48024. pathArray: Vector3[][];
  48025. closeArray?: boolean;
  48026. closePath?: boolean;
  48027. offset?: number;
  48028. updatable?: boolean;
  48029. sideOrientation?: number;
  48030. frontUVs?: Vector4;
  48031. backUVs?: Vector4;
  48032. instance?: Mesh;
  48033. invertUV?: boolean;
  48034. uvs?: Vector2[];
  48035. colors?: Color4[];
  48036. }, scene?: Nullable<Scene>): Mesh;
  48037. }
  48038. }
  48039. declare module BABYLON {
  48040. /**
  48041. * Class containing static functions to help procedurally build meshes
  48042. */
  48043. export class ShapeBuilder {
  48044. /**
  48045. * 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.
  48046. * * 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.
  48047. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48048. * * 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.
  48049. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48050. * * 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
  48051. * * 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
  48052. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48054. * * 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
  48055. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48057. * @param name defines the name of the mesh
  48058. * @param options defines the options used to create the mesh
  48059. * @param scene defines the hosting scene
  48060. * @returns the extruded shape mesh
  48061. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48063. */
  48064. static ExtrudeShape(name: string, options: {
  48065. shape: Vector3[];
  48066. path: Vector3[];
  48067. scale?: number;
  48068. rotation?: number;
  48069. cap?: number;
  48070. updatable?: boolean;
  48071. sideOrientation?: number;
  48072. frontUVs?: Vector4;
  48073. backUVs?: Vector4;
  48074. instance?: Mesh;
  48075. invertUV?: boolean;
  48076. }, scene?: Nullable<Scene>): Mesh;
  48077. /**
  48078. * Creates an custom extruded shape mesh.
  48079. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48080. * * 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.
  48081. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48082. * * 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
  48083. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48084. * * 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
  48085. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48086. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48087. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48088. * * 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
  48089. * * 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
  48090. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48092. * * 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
  48093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48095. * @param name defines the name of the mesh
  48096. * @param options defines the options used to create the mesh
  48097. * @param scene defines the hosting scene
  48098. * @returns the custom extruded shape mesh
  48099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48100. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48102. */
  48103. static ExtrudeShapeCustom(name: string, options: {
  48104. shape: Vector3[];
  48105. path: Vector3[];
  48106. scaleFunction?: any;
  48107. rotationFunction?: any;
  48108. ribbonCloseArray?: boolean;
  48109. ribbonClosePath?: boolean;
  48110. cap?: number;
  48111. updatable?: boolean;
  48112. sideOrientation?: number;
  48113. frontUVs?: Vector4;
  48114. backUVs?: Vector4;
  48115. instance?: Mesh;
  48116. invertUV?: boolean;
  48117. }, scene: Scene): Mesh;
  48118. private static _ExtrudeShapeGeneric;
  48119. }
  48120. }
  48121. declare module BABYLON {
  48122. /**
  48123. * AmmoJS Physics plugin
  48124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48125. * @see https://github.com/kripken/ammo.js/
  48126. */
  48127. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48128. private _useDeltaForWorldStep;
  48129. /**
  48130. * Reference to the Ammo library
  48131. */
  48132. bjsAMMO: any;
  48133. /**
  48134. * Created ammoJS world which physics bodies are added to
  48135. */
  48136. world: any;
  48137. /**
  48138. * Name of the plugin
  48139. */
  48140. name: string;
  48141. private _timeStep;
  48142. private _fixedTimeStep;
  48143. private _maxSteps;
  48144. private _tmpQuaternion;
  48145. private _tmpAmmoTransform;
  48146. private _tmpAmmoQuaternion;
  48147. private _tmpAmmoConcreteContactResultCallback;
  48148. private _collisionConfiguration;
  48149. private _dispatcher;
  48150. private _overlappingPairCache;
  48151. private _solver;
  48152. private _softBodySolver;
  48153. private _tmpAmmoVectorA;
  48154. private _tmpAmmoVectorB;
  48155. private _tmpAmmoVectorC;
  48156. private _tmpAmmoVectorD;
  48157. private _tmpContactCallbackResult;
  48158. private _tmpAmmoVectorRCA;
  48159. private _tmpAmmoVectorRCB;
  48160. private _raycastResult;
  48161. private static readonly DISABLE_COLLISION_FLAG;
  48162. private static readonly KINEMATIC_FLAG;
  48163. private static readonly DISABLE_DEACTIVATION_FLAG;
  48164. /**
  48165. * Initializes the ammoJS plugin
  48166. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48167. * @param ammoInjection can be used to inject your own ammo reference
  48168. */
  48169. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48170. /**
  48171. * Sets the gravity of the physics world (m/(s^2))
  48172. * @param gravity Gravity to set
  48173. */
  48174. setGravity(gravity: Vector3): void;
  48175. /**
  48176. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48177. * @param timeStep timestep to use in seconds
  48178. */
  48179. setTimeStep(timeStep: number): void;
  48180. /**
  48181. * 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)
  48182. * @param fixedTimeStep fixedTimeStep to use in seconds
  48183. */
  48184. setFixedTimeStep(fixedTimeStep: number): void;
  48185. /**
  48186. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48187. * @param maxSteps the maximum number of steps by the physics engine per frame
  48188. */
  48189. setMaxSteps(maxSteps: number): void;
  48190. /**
  48191. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48192. * @returns the current timestep in seconds
  48193. */
  48194. getTimeStep(): number;
  48195. private _isImpostorInContact;
  48196. private _isImpostorPairInContact;
  48197. private _stepSimulation;
  48198. /**
  48199. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48200. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48201. * After the step the babylon meshes are set to the position of the physics imposters
  48202. * @param delta amount of time to step forward
  48203. * @param impostors array of imposters to update before/after the step
  48204. */
  48205. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48206. /**
  48207. * Update babylon mesh to match physics world object
  48208. * @param impostor imposter to match
  48209. */
  48210. private _afterSoftStep;
  48211. /**
  48212. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48213. * @param impostor imposter to match
  48214. */
  48215. private _ropeStep;
  48216. /**
  48217. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48218. * @param impostor imposter to match
  48219. */
  48220. private _softbodyOrClothStep;
  48221. private _tmpVector;
  48222. private _tmpMatrix;
  48223. /**
  48224. * Applies an impulse on the imposter
  48225. * @param impostor imposter to apply impulse to
  48226. * @param force amount of force to be applied to the imposter
  48227. * @param contactPoint the location to apply the impulse on the imposter
  48228. */
  48229. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48230. /**
  48231. * Applies a force on the imposter
  48232. * @param impostor imposter to apply force
  48233. * @param force amount of force to be applied to the imposter
  48234. * @param contactPoint the location to apply the force on the imposter
  48235. */
  48236. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48237. /**
  48238. * Creates a physics body using the plugin
  48239. * @param impostor the imposter to create the physics body on
  48240. */
  48241. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48242. /**
  48243. * Removes the physics body from the imposter and disposes of the body's memory
  48244. * @param impostor imposter to remove the physics body from
  48245. */
  48246. removePhysicsBody(impostor: PhysicsImpostor): void;
  48247. /**
  48248. * Generates a joint
  48249. * @param impostorJoint the imposter joint to create the joint with
  48250. */
  48251. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48252. /**
  48253. * Removes a joint
  48254. * @param impostorJoint the imposter joint to remove the joint from
  48255. */
  48256. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48257. private _addMeshVerts;
  48258. /**
  48259. * Initialise the soft body vertices to match its object's (mesh) vertices
  48260. * Softbody vertices (nodes) are in world space and to match this
  48261. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48262. * @param impostor to create the softbody for
  48263. */
  48264. private _softVertexData;
  48265. /**
  48266. * Create an impostor's soft body
  48267. * @param impostor to create the softbody for
  48268. */
  48269. private _createSoftbody;
  48270. /**
  48271. * Create cloth for an impostor
  48272. * @param impostor to create the softbody for
  48273. */
  48274. private _createCloth;
  48275. /**
  48276. * Create rope for an impostor
  48277. * @param impostor to create the softbody for
  48278. */
  48279. private _createRope;
  48280. private _addHullVerts;
  48281. private _createShape;
  48282. /**
  48283. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48284. * @param impostor imposter containing the physics body and babylon object
  48285. */
  48286. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48287. /**
  48288. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48289. * @param impostor imposter containing the physics body and babylon object
  48290. * @param newPosition new position
  48291. * @param newRotation new rotation
  48292. */
  48293. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48294. /**
  48295. * If this plugin is supported
  48296. * @returns true if its supported
  48297. */
  48298. isSupported(): boolean;
  48299. /**
  48300. * Sets the linear velocity of the physics body
  48301. * @param impostor imposter to set the velocity on
  48302. * @param velocity velocity to set
  48303. */
  48304. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48305. /**
  48306. * Sets the angular velocity of the physics body
  48307. * @param impostor imposter to set the velocity on
  48308. * @param velocity velocity to set
  48309. */
  48310. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48311. /**
  48312. * gets the linear velocity
  48313. * @param impostor imposter to get linear velocity from
  48314. * @returns linear velocity
  48315. */
  48316. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48317. /**
  48318. * gets the angular velocity
  48319. * @param impostor imposter to get angular velocity from
  48320. * @returns angular velocity
  48321. */
  48322. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48323. /**
  48324. * Sets the mass of physics body
  48325. * @param impostor imposter to set the mass on
  48326. * @param mass mass to set
  48327. */
  48328. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48329. /**
  48330. * Gets the mass of the physics body
  48331. * @param impostor imposter to get the mass from
  48332. * @returns mass
  48333. */
  48334. getBodyMass(impostor: PhysicsImpostor): number;
  48335. /**
  48336. * Gets friction of the impostor
  48337. * @param impostor impostor to get friction from
  48338. * @returns friction value
  48339. */
  48340. getBodyFriction(impostor: PhysicsImpostor): number;
  48341. /**
  48342. * Sets friction of the impostor
  48343. * @param impostor impostor to set friction on
  48344. * @param friction friction value
  48345. */
  48346. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48347. /**
  48348. * Gets restitution of the impostor
  48349. * @param impostor impostor to get restitution from
  48350. * @returns restitution value
  48351. */
  48352. getBodyRestitution(impostor: PhysicsImpostor): number;
  48353. /**
  48354. * Sets resitution of the impostor
  48355. * @param impostor impostor to set resitution on
  48356. * @param restitution resitution value
  48357. */
  48358. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48359. /**
  48360. * Gets pressure inside the impostor
  48361. * @param impostor impostor to get pressure from
  48362. * @returns pressure value
  48363. */
  48364. getBodyPressure(impostor: PhysicsImpostor): number;
  48365. /**
  48366. * Sets pressure inside a soft body impostor
  48367. * Cloth and rope must remain 0 pressure
  48368. * @param impostor impostor to set pressure on
  48369. * @param pressure pressure value
  48370. */
  48371. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48372. /**
  48373. * Gets stiffness of the impostor
  48374. * @param impostor impostor to get stiffness from
  48375. * @returns pressure value
  48376. */
  48377. getBodyStiffness(impostor: PhysicsImpostor): number;
  48378. /**
  48379. * Sets stiffness of the impostor
  48380. * @param impostor impostor to set stiffness on
  48381. * @param stiffness stiffness value from 0 to 1
  48382. */
  48383. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48384. /**
  48385. * Gets velocityIterations of the impostor
  48386. * @param impostor impostor to get velocity iterations from
  48387. * @returns velocityIterations value
  48388. */
  48389. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48390. /**
  48391. * Sets velocityIterations of the impostor
  48392. * @param impostor impostor to set velocity iterations on
  48393. * @param velocityIterations velocityIterations value
  48394. */
  48395. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48396. /**
  48397. * Gets positionIterations of the impostor
  48398. * @param impostor impostor to get position iterations from
  48399. * @returns positionIterations value
  48400. */
  48401. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48402. /**
  48403. * Sets positionIterations of the impostor
  48404. * @param impostor impostor to set position on
  48405. * @param positionIterations positionIterations value
  48406. */
  48407. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48408. /**
  48409. * Append an anchor to a cloth object
  48410. * @param impostor is the cloth impostor to add anchor to
  48411. * @param otherImpostor is the rigid impostor to anchor to
  48412. * @param width ratio across width from 0 to 1
  48413. * @param height ratio up height from 0 to 1
  48414. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48415. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48416. */
  48417. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48418. /**
  48419. * Append an hook to a rope object
  48420. * @param impostor is the rope impostor to add hook to
  48421. * @param otherImpostor is the rigid impostor to hook to
  48422. * @param length ratio along the rope from 0 to 1
  48423. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48424. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48425. */
  48426. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48427. /**
  48428. * Sleeps the physics body and stops it from being active
  48429. * @param impostor impostor to sleep
  48430. */
  48431. sleepBody(impostor: PhysicsImpostor): void;
  48432. /**
  48433. * Activates the physics body
  48434. * @param impostor impostor to activate
  48435. */
  48436. wakeUpBody(impostor: PhysicsImpostor): void;
  48437. /**
  48438. * Updates the distance parameters of the joint
  48439. * @param joint joint to update
  48440. * @param maxDistance maximum distance of the joint
  48441. * @param minDistance minimum distance of the joint
  48442. */
  48443. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48444. /**
  48445. * Sets a motor on the joint
  48446. * @param joint joint to set motor on
  48447. * @param speed speed of the motor
  48448. * @param maxForce maximum force of the motor
  48449. * @param motorIndex index of the motor
  48450. */
  48451. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48452. /**
  48453. * Sets the motors limit
  48454. * @param joint joint to set limit on
  48455. * @param upperLimit upper limit
  48456. * @param lowerLimit lower limit
  48457. */
  48458. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48459. /**
  48460. * Syncs the position and rotation of a mesh with the impostor
  48461. * @param mesh mesh to sync
  48462. * @param impostor impostor to update the mesh with
  48463. */
  48464. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48465. /**
  48466. * Gets the radius of the impostor
  48467. * @param impostor impostor to get radius from
  48468. * @returns the radius
  48469. */
  48470. getRadius(impostor: PhysicsImpostor): number;
  48471. /**
  48472. * Gets the box size of the impostor
  48473. * @param impostor impostor to get box size from
  48474. * @param result the resulting box size
  48475. */
  48476. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48477. /**
  48478. * Disposes of the impostor
  48479. */
  48480. dispose(): void;
  48481. /**
  48482. * Does a raycast in the physics world
  48483. * @param from when should the ray start?
  48484. * @param to when should the ray end?
  48485. * @returns PhysicsRaycastResult
  48486. */
  48487. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48488. }
  48489. }
  48490. declare module BABYLON {
  48491. interface AbstractScene {
  48492. /**
  48493. * The list of reflection probes added to the scene
  48494. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48495. */
  48496. reflectionProbes: Array<ReflectionProbe>;
  48497. /**
  48498. * Removes the given reflection probe from this scene.
  48499. * @param toRemove The reflection probe to remove
  48500. * @returns The index of the removed reflection probe
  48501. */
  48502. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48503. /**
  48504. * Adds the given reflection probe to this scene.
  48505. * @param newReflectionProbe The reflection probe to add
  48506. */
  48507. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48508. }
  48509. /**
  48510. * Class used to generate realtime reflection / refraction cube textures
  48511. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48512. */
  48513. export class ReflectionProbe {
  48514. /** defines the name of the probe */
  48515. name: string;
  48516. private _scene;
  48517. private _renderTargetTexture;
  48518. private _projectionMatrix;
  48519. private _viewMatrix;
  48520. private _target;
  48521. private _add;
  48522. private _attachedMesh;
  48523. private _invertYAxis;
  48524. /** Gets or sets probe position (center of the cube map) */
  48525. position: Vector3;
  48526. /**
  48527. * Creates a new reflection probe
  48528. * @param name defines the name of the probe
  48529. * @param size defines the texture resolution (for each face)
  48530. * @param scene defines the hosting scene
  48531. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48532. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48533. */
  48534. constructor(
  48535. /** defines the name of the probe */
  48536. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48537. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48538. samples: number;
  48539. /** Gets or sets the refresh rate to use (on every frame by default) */
  48540. refreshRate: number;
  48541. /**
  48542. * Gets the hosting scene
  48543. * @returns a Scene
  48544. */
  48545. getScene(): Scene;
  48546. /** Gets the internal CubeTexture used to render to */
  48547. readonly cubeTexture: RenderTargetTexture;
  48548. /** Gets the list of meshes to render */
  48549. readonly renderList: Nullable<AbstractMesh[]>;
  48550. /**
  48551. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48552. * @param mesh defines the mesh to attach to
  48553. */
  48554. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48555. /**
  48556. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48557. * @param renderingGroupId The rendering group id corresponding to its index
  48558. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48559. */
  48560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48561. /**
  48562. * Clean all associated resources
  48563. */
  48564. dispose(): void;
  48565. /**
  48566. * Converts the reflection probe information to a readable string for debug purpose.
  48567. * @param fullDetails Supports for multiple levels of logging within scene loading
  48568. * @returns the human readable reflection probe info
  48569. */
  48570. toString(fullDetails?: boolean): string;
  48571. /**
  48572. * Get the class name of the relfection probe.
  48573. * @returns "ReflectionProbe"
  48574. */
  48575. getClassName(): string;
  48576. /**
  48577. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48578. * @returns The JSON representation of the texture
  48579. */
  48580. serialize(): any;
  48581. /**
  48582. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48583. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48584. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48585. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48586. * @returns The parsed reflection probe if successful
  48587. */
  48588. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48589. }
  48590. }
  48591. declare module BABYLON {
  48592. /** @hidden */
  48593. export var _BabylonLoaderRegistered: boolean;
  48594. }
  48595. declare module BABYLON {
  48596. /**
  48597. * The Physically based simple base material of BJS.
  48598. *
  48599. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48600. * It is used as the base class for both the specGloss and metalRough conventions.
  48601. */
  48602. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48603. /**
  48604. * Number of Simultaneous lights allowed on the material.
  48605. */
  48606. maxSimultaneousLights: number;
  48607. /**
  48608. * If sets to true, disables all the lights affecting the material.
  48609. */
  48610. disableLighting: boolean;
  48611. /**
  48612. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48613. */
  48614. environmentTexture: BaseTexture;
  48615. /**
  48616. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48617. */
  48618. invertNormalMapX: boolean;
  48619. /**
  48620. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48621. */
  48622. invertNormalMapY: boolean;
  48623. /**
  48624. * Normal map used in the model.
  48625. */
  48626. normalTexture: BaseTexture;
  48627. /**
  48628. * Emissivie color used to self-illuminate the model.
  48629. */
  48630. emissiveColor: Color3;
  48631. /**
  48632. * Emissivie texture used to self-illuminate the model.
  48633. */
  48634. emissiveTexture: BaseTexture;
  48635. /**
  48636. * Occlusion Channel Strenght.
  48637. */
  48638. occlusionStrength: number;
  48639. /**
  48640. * Occlusion Texture of the material (adding extra occlusion effects).
  48641. */
  48642. occlusionTexture: BaseTexture;
  48643. /**
  48644. * Defines the alpha limits in alpha test mode.
  48645. */
  48646. alphaCutOff: number;
  48647. /**
  48648. * Gets the current double sided mode.
  48649. */
  48650. /**
  48651. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48652. */
  48653. doubleSided: boolean;
  48654. /**
  48655. * Stores the pre-calculated light information of a mesh in a texture.
  48656. */
  48657. lightmapTexture: BaseTexture;
  48658. /**
  48659. * If true, the light map contains occlusion information instead of lighting info.
  48660. */
  48661. useLightmapAsShadowmap: boolean;
  48662. /**
  48663. * Instantiates a new PBRMaterial instance.
  48664. *
  48665. * @param name The material name
  48666. * @param scene The scene the material will be use in.
  48667. */
  48668. constructor(name: string, scene: Scene);
  48669. getClassName(): string;
  48670. }
  48671. }
  48672. declare module BABYLON {
  48673. /**
  48674. * The PBR material of BJS following the metal roughness convention.
  48675. *
  48676. * This fits to the PBR convention in the GLTF definition:
  48677. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48678. */
  48679. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48680. /**
  48681. * The base color has two different interpretations depending on the value of metalness.
  48682. * When the material is a metal, the base color is the specific measured reflectance value
  48683. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48684. * of the material.
  48685. */
  48686. baseColor: Color3;
  48687. /**
  48688. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48689. * well as opacity information in the alpha channel.
  48690. */
  48691. baseTexture: BaseTexture;
  48692. /**
  48693. * Specifies the metallic scalar value of the material.
  48694. * Can also be used to scale the metalness values of the metallic texture.
  48695. */
  48696. metallic: number;
  48697. /**
  48698. * Specifies the roughness scalar value of the material.
  48699. * Can also be used to scale the roughness values of the metallic texture.
  48700. */
  48701. roughness: number;
  48702. /**
  48703. * Texture containing both the metallic value in the B channel and the
  48704. * roughness value in the G channel to keep better precision.
  48705. */
  48706. metallicRoughnessTexture: BaseTexture;
  48707. /**
  48708. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48709. *
  48710. * @param name The material name
  48711. * @param scene The scene the material will be use in.
  48712. */
  48713. constructor(name: string, scene: Scene);
  48714. /**
  48715. * Return the currrent class name of the material.
  48716. */
  48717. getClassName(): string;
  48718. /**
  48719. * Makes a duplicate of the current material.
  48720. * @param name - name to use for the new material.
  48721. */
  48722. clone(name: string): PBRMetallicRoughnessMaterial;
  48723. /**
  48724. * Serialize the material to a parsable JSON object.
  48725. */
  48726. serialize(): any;
  48727. /**
  48728. * Parses a JSON object correponding to the serialize function.
  48729. */
  48730. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48731. }
  48732. }
  48733. declare module BABYLON {
  48734. /**
  48735. * The PBR material of BJS following the specular glossiness convention.
  48736. *
  48737. * This fits to the PBR convention in the GLTF definition:
  48738. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48739. */
  48740. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48741. /**
  48742. * Specifies the diffuse color of the material.
  48743. */
  48744. diffuseColor: Color3;
  48745. /**
  48746. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48747. * channel.
  48748. */
  48749. diffuseTexture: BaseTexture;
  48750. /**
  48751. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48752. */
  48753. specularColor: Color3;
  48754. /**
  48755. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48756. */
  48757. glossiness: number;
  48758. /**
  48759. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48760. */
  48761. specularGlossinessTexture: BaseTexture;
  48762. /**
  48763. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48764. *
  48765. * @param name The material name
  48766. * @param scene The scene the material will be use in.
  48767. */
  48768. constructor(name: string, scene: Scene);
  48769. /**
  48770. * Return the currrent class name of the material.
  48771. */
  48772. getClassName(): string;
  48773. /**
  48774. * Makes a duplicate of the current material.
  48775. * @param name - name to use for the new material.
  48776. */
  48777. clone(name: string): PBRSpecularGlossinessMaterial;
  48778. /**
  48779. * Serialize the material to a parsable JSON object.
  48780. */
  48781. serialize(): any;
  48782. /**
  48783. * Parses a JSON object correponding to the serialize function.
  48784. */
  48785. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48786. }
  48787. }
  48788. declare module BABYLON {
  48789. /**
  48790. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48791. * It can help converting any input color in a desired output one. This can then be used to create effects
  48792. * from sepia, black and white to sixties or futuristic rendering...
  48793. *
  48794. * The only supported format is currently 3dl.
  48795. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48796. */
  48797. export class ColorGradingTexture extends BaseTexture {
  48798. /**
  48799. * The current texture matrix. (will always be identity in color grading texture)
  48800. */
  48801. private _textureMatrix;
  48802. /**
  48803. * The texture URL.
  48804. */
  48805. url: string;
  48806. /**
  48807. * Empty line regex stored for GC.
  48808. */
  48809. private static _noneEmptyLineRegex;
  48810. private _engine;
  48811. /**
  48812. * Instantiates a ColorGradingTexture from the following parameters.
  48813. *
  48814. * @param url The location of the color gradind data (currently only supporting 3dl)
  48815. * @param scene The scene the texture will be used in
  48816. */
  48817. constructor(url: string, scene: Scene);
  48818. /**
  48819. * Returns the texture matrix used in most of the material.
  48820. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48821. */
  48822. getTextureMatrix(): Matrix;
  48823. /**
  48824. * Occurs when the file being loaded is a .3dl LUT file.
  48825. */
  48826. private load3dlTexture;
  48827. /**
  48828. * Starts the loading process of the texture.
  48829. */
  48830. private loadTexture;
  48831. /**
  48832. * Clones the color gradind texture.
  48833. */
  48834. clone(): ColorGradingTexture;
  48835. /**
  48836. * Called during delayed load for textures.
  48837. */
  48838. delayLoad(): void;
  48839. /**
  48840. * Parses a color grading texture serialized by Babylon.
  48841. * @param parsedTexture The texture information being parsedTexture
  48842. * @param scene The scene to load the texture in
  48843. * @param rootUrl The root url of the data assets to load
  48844. * @return A color gradind texture
  48845. */
  48846. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48847. /**
  48848. * Serializes the LUT texture to json format.
  48849. */
  48850. serialize(): any;
  48851. }
  48852. }
  48853. declare module BABYLON {
  48854. /**
  48855. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48856. */
  48857. export class EquiRectangularCubeTexture extends BaseTexture {
  48858. /** The six faces of the cube. */
  48859. private static _FacesMapping;
  48860. private _noMipmap;
  48861. private _onLoad;
  48862. private _onError;
  48863. /** The size of the cubemap. */
  48864. private _size;
  48865. /** The buffer of the image. */
  48866. private _buffer;
  48867. /** The width of the input image. */
  48868. private _width;
  48869. /** The height of the input image. */
  48870. private _height;
  48871. /** The URL to the image. */
  48872. url: string;
  48873. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48874. coordinatesMode: number;
  48875. /**
  48876. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48877. * @param url The location of the image
  48878. * @param scene The scene the texture will be used in
  48879. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48880. * @param noMipmap Forces to not generate the mipmap if true
  48881. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48882. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48883. * @param onLoad — defines a callback called when texture is loaded
  48884. * @param onError — defines a callback called if there is an error
  48885. */
  48886. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48887. /**
  48888. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48889. */
  48890. private loadImage;
  48891. /**
  48892. * Convert the image buffer into a cubemap and create a CubeTexture.
  48893. */
  48894. private loadTexture;
  48895. /**
  48896. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48897. * @param buffer The ArrayBuffer that should be converted.
  48898. * @returns The buffer as Float32Array.
  48899. */
  48900. private getFloat32ArrayFromArrayBuffer;
  48901. /**
  48902. * Get the current class name of the texture useful for serialization or dynamic coding.
  48903. * @returns "EquiRectangularCubeTexture"
  48904. */
  48905. getClassName(): string;
  48906. /**
  48907. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48908. * @returns A clone of the current EquiRectangularCubeTexture.
  48909. */
  48910. clone(): EquiRectangularCubeTexture;
  48911. }
  48912. }
  48913. declare module BABYLON {
  48914. /**
  48915. * Based on jsTGALoader - Javascript loader for TGA file
  48916. * By Vincent Thibault
  48917. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48918. */
  48919. export class TGATools {
  48920. private static _TYPE_INDEXED;
  48921. private static _TYPE_RGB;
  48922. private static _TYPE_GREY;
  48923. private static _TYPE_RLE_INDEXED;
  48924. private static _TYPE_RLE_RGB;
  48925. private static _TYPE_RLE_GREY;
  48926. private static _ORIGIN_MASK;
  48927. private static _ORIGIN_SHIFT;
  48928. private static _ORIGIN_BL;
  48929. private static _ORIGIN_BR;
  48930. private static _ORIGIN_UL;
  48931. private static _ORIGIN_UR;
  48932. /**
  48933. * Gets the header of a TGA file
  48934. * @param data defines the TGA data
  48935. * @returns the header
  48936. */
  48937. static GetTGAHeader(data: Uint8Array): any;
  48938. /**
  48939. * Uploads TGA content to a Babylon Texture
  48940. * @hidden
  48941. */
  48942. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48943. /** @hidden */
  48944. 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;
  48945. /** @hidden */
  48946. 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;
  48947. /** @hidden */
  48948. 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;
  48949. /** @hidden */
  48950. 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;
  48951. /** @hidden */
  48952. 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;
  48953. /** @hidden */
  48954. 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;
  48955. }
  48956. }
  48957. declare module BABYLON {
  48958. /**
  48959. * Implementation of the TGA Texture Loader.
  48960. * @hidden
  48961. */
  48962. export class _TGATextureLoader implements IInternalTextureLoader {
  48963. /**
  48964. * Defines wether the loader supports cascade loading the different faces.
  48965. */
  48966. readonly supportCascades: boolean;
  48967. /**
  48968. * This returns if the loader support the current file information.
  48969. * @param extension defines the file extension of the file being loaded
  48970. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48971. * @param fallback defines the fallback internal texture if any
  48972. * @param isBase64 defines whether the texture is encoded as a base64
  48973. * @param isBuffer defines whether the texture data are stored as a buffer
  48974. * @returns true if the loader can load the specified file
  48975. */
  48976. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48977. /**
  48978. * Transform the url before loading if required.
  48979. * @param rootUrl the url of the texture
  48980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48981. * @returns the transformed texture
  48982. */
  48983. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48984. /**
  48985. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48986. * @param rootUrl the url of the texture
  48987. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48988. * @returns the fallback texture
  48989. */
  48990. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48991. /**
  48992. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48993. * @param data contains the texture data
  48994. * @param texture defines the BabylonJS internal texture
  48995. * @param createPolynomials will be true if polynomials have been requested
  48996. * @param onLoad defines the callback to trigger once the texture is ready
  48997. * @param onError defines the callback to trigger in case of error
  48998. */
  48999. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49000. /**
  49001. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49002. * @param data contains the texture data
  49003. * @param texture defines the BabylonJS internal texture
  49004. * @param callback defines the method to call once ready to upload
  49005. */
  49006. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49007. }
  49008. }
  49009. declare module BABYLON {
  49010. /**
  49011. * 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.
  49012. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49013. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49014. */
  49015. export class CustomProceduralTexture extends ProceduralTexture {
  49016. private _animate;
  49017. private _time;
  49018. private _config;
  49019. private _texturePath;
  49020. /**
  49021. * Instantiates a new Custom Procedural Texture.
  49022. * 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.
  49023. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49024. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49025. * @param name Define the name of the texture
  49026. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49027. * @param size Define the size of the texture to create
  49028. * @param scene Define the scene the texture belongs to
  49029. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49030. * @param generateMipMaps Define if the texture should creates mip maps or not
  49031. */
  49032. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49033. private _loadJson;
  49034. /**
  49035. * Is the texture ready to be used ? (rendered at least once)
  49036. * @returns true if ready, otherwise, false.
  49037. */
  49038. isReady(): boolean;
  49039. /**
  49040. * Render the texture to its associated render target.
  49041. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49042. */
  49043. render(useCameraPostProcess?: boolean): void;
  49044. /**
  49045. * Update the list of dependant textures samplers in the shader.
  49046. */
  49047. updateTextures(): void;
  49048. /**
  49049. * Update the uniform values of the procedural texture in the shader.
  49050. */
  49051. updateShaderUniforms(): void;
  49052. /**
  49053. * Define if the texture animates or not.
  49054. */
  49055. animate: boolean;
  49056. }
  49057. }
  49058. declare module BABYLON {
  49059. /** @hidden */
  49060. export var noisePixelShader: {
  49061. name: string;
  49062. shader: string;
  49063. };
  49064. }
  49065. declare module BABYLON {
  49066. /**
  49067. * Class used to generate noise procedural textures
  49068. */
  49069. export class NoiseProceduralTexture extends ProceduralTexture {
  49070. private _time;
  49071. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49072. brightness: number;
  49073. /** Defines the number of octaves to process */
  49074. octaves: number;
  49075. /** Defines the level of persistence (0.8 by default) */
  49076. persistence: number;
  49077. /** Gets or sets animation speed factor (default is 1) */
  49078. animationSpeedFactor: number;
  49079. /**
  49080. * Creates a new NoiseProceduralTexture
  49081. * @param name defines the name fo the texture
  49082. * @param size defines the size of the texture (default is 256)
  49083. * @param scene defines the hosting scene
  49084. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49085. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49086. */
  49087. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49088. private _updateShaderUniforms;
  49089. protected _getDefines(): string;
  49090. /** Generate the current state of the procedural texture */
  49091. render(useCameraPostProcess?: boolean): void;
  49092. /**
  49093. * Serializes this noise procedural texture
  49094. * @returns a serialized noise procedural texture object
  49095. */
  49096. serialize(): any;
  49097. /**
  49098. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49099. * @param parsedTexture defines parsed texture data
  49100. * @param scene defines the current scene
  49101. * @param rootUrl defines the root URL containing noise procedural texture information
  49102. * @returns a parsed NoiseProceduralTexture
  49103. */
  49104. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49105. }
  49106. }
  49107. declare module BABYLON {
  49108. /**
  49109. * Raw cube texture where the raw buffers are passed in
  49110. */
  49111. export class RawCubeTexture extends CubeTexture {
  49112. /**
  49113. * Creates a cube texture where the raw buffers are passed in.
  49114. * @param scene defines the scene the texture is attached to
  49115. * @param data defines the array of data to use to create each face
  49116. * @param size defines the size of the textures
  49117. * @param format defines the format of the data
  49118. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49119. * @param generateMipMaps defines if the engine should generate the mip levels
  49120. * @param invertY defines if data must be stored with Y axis inverted
  49121. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49122. * @param compression defines the compression used (null by default)
  49123. */
  49124. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49125. /**
  49126. * Updates the raw cube texture.
  49127. * @param data defines the data to store
  49128. * @param format defines the data format
  49129. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49130. * @param invertY defines if data must be stored with Y axis inverted
  49131. * @param compression defines the compression used (null by default)
  49132. * @param level defines which level of the texture to update
  49133. */
  49134. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49135. /**
  49136. * Updates a raw cube texture with RGBD encoded data.
  49137. * @param data defines the array of data [mipmap][face] to use to create each face
  49138. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49139. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49140. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49141. * @returns a promsie that resolves when the operation is complete
  49142. */
  49143. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49144. /**
  49145. * Clones the raw cube texture.
  49146. * @return a new cube texture
  49147. */
  49148. clone(): CubeTexture;
  49149. /** @hidden */
  49150. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49151. }
  49152. }
  49153. declare module BABYLON {
  49154. /**
  49155. * Class used to store 3D textures containing user data
  49156. */
  49157. export class RawTexture3D extends Texture {
  49158. /** Gets or sets the texture format to use */
  49159. format: number;
  49160. private _engine;
  49161. /**
  49162. * Create a new RawTexture3D
  49163. * @param data defines the data of the texture
  49164. * @param width defines the width of the texture
  49165. * @param height defines the height of the texture
  49166. * @param depth defines the depth of the texture
  49167. * @param format defines the texture format to use
  49168. * @param scene defines the hosting scene
  49169. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49170. * @param invertY defines if texture must be stored with Y axis inverted
  49171. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49172. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49173. */
  49174. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49175. /** Gets or sets the texture format to use */
  49176. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49177. /**
  49178. * Update the texture with new data
  49179. * @param data defines the data to store in the texture
  49180. */
  49181. update(data: ArrayBufferView): void;
  49182. }
  49183. }
  49184. declare module BABYLON {
  49185. /**
  49186. * Creates a refraction texture used by refraction channel of the standard material.
  49187. * It is like a mirror but to see through a material.
  49188. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49189. */
  49190. export class RefractionTexture extends RenderTargetTexture {
  49191. /**
  49192. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49193. * 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.
  49194. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49195. */
  49196. refractionPlane: Plane;
  49197. /**
  49198. * Define how deep under the surface we should see.
  49199. */
  49200. depth: number;
  49201. /**
  49202. * Creates a refraction texture used by refraction channel of the standard material.
  49203. * It is like a mirror but to see through a material.
  49204. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49205. * @param name Define the texture name
  49206. * @param size Define the size of the underlying texture
  49207. * @param scene Define the scene the refraction belongs to
  49208. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49209. */
  49210. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49211. /**
  49212. * Clone the refraction texture.
  49213. * @returns the cloned texture
  49214. */
  49215. clone(): RefractionTexture;
  49216. /**
  49217. * Serialize the texture to a JSON representation you could use in Parse later on
  49218. * @returns the serialized JSON representation
  49219. */
  49220. serialize(): any;
  49221. }
  49222. }
  49223. declare module BABYLON {
  49224. /**
  49225. * Configuration for Draco compression
  49226. */
  49227. export interface IDracoCompressionConfiguration {
  49228. /**
  49229. * Configuration for the decoder.
  49230. */
  49231. decoder?: {
  49232. /**
  49233. * The url to the WebAssembly module.
  49234. */
  49235. wasmUrl?: string;
  49236. /**
  49237. * The url to the WebAssembly binary.
  49238. */
  49239. wasmBinaryUrl?: string;
  49240. /**
  49241. * The url to the fallback JavaScript module.
  49242. */
  49243. fallbackUrl?: string;
  49244. };
  49245. }
  49246. /**
  49247. * Draco compression (https://google.github.io/draco/)
  49248. *
  49249. * This class wraps the Draco module.
  49250. *
  49251. * **Encoder**
  49252. *
  49253. * The encoder is not currently implemented.
  49254. *
  49255. * **Decoder**
  49256. *
  49257. * 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.
  49258. *
  49259. * To update the configuration, use the following code:
  49260. * ```javascript
  49261. * DracoCompression.Configuration = {
  49262. * decoder: {
  49263. * wasmUrl: "<url to the WebAssembly library>",
  49264. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49265. * fallbackUrl: "<url to the fallback JavaScript library>",
  49266. * }
  49267. * };
  49268. * ```
  49269. *
  49270. * 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.
  49271. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49272. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49273. *
  49274. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49275. * ```javascript
  49276. * var dracoCompression = new DracoCompression();
  49277. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49278. * [VertexBuffer.PositionKind]: 0
  49279. * });
  49280. * ```
  49281. *
  49282. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49283. */
  49284. export class DracoCompression implements IDisposable {
  49285. private static _DecoderModulePromise;
  49286. /**
  49287. * The configuration. Defaults to the following urls:
  49288. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49289. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49290. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49291. */
  49292. static Configuration: IDracoCompressionConfiguration;
  49293. /**
  49294. * Returns true if the decoder is available.
  49295. */
  49296. static readonly DecoderAvailable: boolean;
  49297. /**
  49298. * Constructor
  49299. */
  49300. constructor();
  49301. /**
  49302. * Stop all async operations and release resources.
  49303. */
  49304. dispose(): void;
  49305. /**
  49306. * Decode Draco compressed mesh data to vertex data.
  49307. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49308. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49309. * @returns A promise that resolves with the decoded vertex data
  49310. */
  49311. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49312. [kind: string]: number;
  49313. }): Promise<VertexData>;
  49314. private static _GetDecoderModule;
  49315. private static _LoadScriptAsync;
  49316. private static _LoadFileAsync;
  49317. }
  49318. }
  49319. declare module BABYLON {
  49320. /**
  49321. * Class for building Constructive Solid Geometry
  49322. */
  49323. export class CSG {
  49324. private polygons;
  49325. /**
  49326. * The world matrix
  49327. */
  49328. matrix: Matrix;
  49329. /**
  49330. * Stores the position
  49331. */
  49332. position: Vector3;
  49333. /**
  49334. * Stores the rotation
  49335. */
  49336. rotation: Vector3;
  49337. /**
  49338. * Stores the rotation quaternion
  49339. */
  49340. rotationQuaternion: Nullable<Quaternion>;
  49341. /**
  49342. * Stores the scaling vector
  49343. */
  49344. scaling: Vector3;
  49345. /**
  49346. * Convert the Mesh to CSG
  49347. * @param mesh The Mesh to convert to CSG
  49348. * @returns A new CSG from the Mesh
  49349. */
  49350. static FromMesh(mesh: Mesh): CSG;
  49351. /**
  49352. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49353. * @param polygons Polygons used to construct a CSG solid
  49354. */
  49355. private static FromPolygons;
  49356. /**
  49357. * Clones, or makes a deep copy, of the CSG
  49358. * @returns A new CSG
  49359. */
  49360. clone(): CSG;
  49361. /**
  49362. * Unions this CSG with another CSG
  49363. * @param csg The CSG to union against this CSG
  49364. * @returns The unioned CSG
  49365. */
  49366. union(csg: CSG): CSG;
  49367. /**
  49368. * Unions this CSG with another CSG in place
  49369. * @param csg The CSG to union against this CSG
  49370. */
  49371. unionInPlace(csg: CSG): void;
  49372. /**
  49373. * Subtracts this CSG with another CSG
  49374. * @param csg The CSG to subtract against this CSG
  49375. * @returns A new CSG
  49376. */
  49377. subtract(csg: CSG): CSG;
  49378. /**
  49379. * Subtracts this CSG with another CSG in place
  49380. * @param csg The CSG to subtact against this CSG
  49381. */
  49382. subtractInPlace(csg: CSG): void;
  49383. /**
  49384. * Intersect this CSG with another CSG
  49385. * @param csg The CSG to intersect against this CSG
  49386. * @returns A new CSG
  49387. */
  49388. intersect(csg: CSG): CSG;
  49389. /**
  49390. * Intersects this CSG with another CSG in place
  49391. * @param csg The CSG to intersect against this CSG
  49392. */
  49393. intersectInPlace(csg: CSG): void;
  49394. /**
  49395. * Return a new CSG solid with solid and empty space switched. This solid is
  49396. * not modified.
  49397. * @returns A new CSG solid with solid and empty space switched
  49398. */
  49399. inverse(): CSG;
  49400. /**
  49401. * Inverses the CSG in place
  49402. */
  49403. inverseInPlace(): void;
  49404. /**
  49405. * This is used to keep meshes transformations so they can be restored
  49406. * when we build back a Babylon Mesh
  49407. * NB : All CSG operations are performed in world coordinates
  49408. * @param csg The CSG to copy the transform attributes from
  49409. * @returns This CSG
  49410. */
  49411. copyTransformAttributes(csg: CSG): CSG;
  49412. /**
  49413. * Build Raw mesh from CSG
  49414. * Coordinates here are in world space
  49415. * @param name The name of the mesh geometry
  49416. * @param scene The Scene
  49417. * @param keepSubMeshes Specifies if the submeshes should be kept
  49418. * @returns A new Mesh
  49419. */
  49420. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49421. /**
  49422. * Build Mesh from CSG taking material and transforms into account
  49423. * @param name The name of the Mesh
  49424. * @param material The material of the Mesh
  49425. * @param scene The Scene
  49426. * @param keepSubMeshes Specifies if submeshes should be kept
  49427. * @returns The new Mesh
  49428. */
  49429. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49430. }
  49431. }
  49432. declare module BABYLON {
  49433. /**
  49434. * Class used to create a trail following a mesh
  49435. */
  49436. export class TrailMesh extends Mesh {
  49437. private _generator;
  49438. private _autoStart;
  49439. private _running;
  49440. private _diameter;
  49441. private _length;
  49442. private _sectionPolygonPointsCount;
  49443. private _sectionVectors;
  49444. private _sectionNormalVectors;
  49445. private _beforeRenderObserver;
  49446. /**
  49447. * @constructor
  49448. * @param name The value used by scene.getMeshByName() to do a lookup.
  49449. * @param generator The mesh to generate a trail.
  49450. * @param scene The scene to add this mesh to.
  49451. * @param diameter Diameter of trailing mesh. Default is 1.
  49452. * @param length Length of trailing mesh. Default is 60.
  49453. * @param autoStart Automatically start trailing mesh. Default true.
  49454. */
  49455. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49456. /**
  49457. * "TrailMesh"
  49458. * @returns "TrailMesh"
  49459. */
  49460. getClassName(): string;
  49461. private _createMesh;
  49462. /**
  49463. * Start trailing mesh.
  49464. */
  49465. start(): void;
  49466. /**
  49467. * Stop trailing mesh.
  49468. */
  49469. stop(): void;
  49470. /**
  49471. * Update trailing mesh geometry.
  49472. */
  49473. update(): void;
  49474. /**
  49475. * Returns a new TrailMesh object.
  49476. * @param name is a string, the name given to the new mesh
  49477. * @param newGenerator use new generator object for cloned trail mesh
  49478. * @returns a new mesh
  49479. */
  49480. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49481. /**
  49482. * Serializes this trail mesh
  49483. * @param serializationObject object to write serialization to
  49484. */
  49485. serialize(serializationObject: any): void;
  49486. /**
  49487. * Parses a serialized trail mesh
  49488. * @param parsedMesh the serialized mesh
  49489. * @param scene the scene to create the trail mesh in
  49490. * @returns the created trail mesh
  49491. */
  49492. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49493. }
  49494. }
  49495. declare module BABYLON {
  49496. /**
  49497. * Class containing static functions to help procedurally build meshes
  49498. */
  49499. export class TorusKnotBuilder {
  49500. /**
  49501. * Creates a torus knot mesh
  49502. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49503. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49504. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49505. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49507. * * 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
  49508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49509. * @param name defines the name of the mesh
  49510. * @param options defines the options used to create the mesh
  49511. * @param scene defines the hosting scene
  49512. * @returns the torus knot mesh
  49513. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49514. */
  49515. static CreateTorusKnot(name: string, options: {
  49516. radius?: number;
  49517. tube?: number;
  49518. radialSegments?: number;
  49519. tubularSegments?: number;
  49520. p?: number;
  49521. q?: number;
  49522. updatable?: boolean;
  49523. sideOrientation?: number;
  49524. frontUVs?: Vector4;
  49525. backUVs?: Vector4;
  49526. }, scene: any): Mesh;
  49527. }
  49528. }
  49529. declare module BABYLON {
  49530. /**
  49531. * Polygon
  49532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49533. */
  49534. export class Polygon {
  49535. /**
  49536. * Creates a rectangle
  49537. * @param xmin bottom X coord
  49538. * @param ymin bottom Y coord
  49539. * @param xmax top X coord
  49540. * @param ymax top Y coord
  49541. * @returns points that make the resulting rectation
  49542. */
  49543. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49544. /**
  49545. * Creates a circle
  49546. * @param radius radius of circle
  49547. * @param cx scale in x
  49548. * @param cy scale in y
  49549. * @param numberOfSides number of sides that make up the circle
  49550. * @returns points that make the resulting circle
  49551. */
  49552. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49553. /**
  49554. * Creates a polygon from input string
  49555. * @param input Input polygon data
  49556. * @returns the parsed points
  49557. */
  49558. static Parse(input: string): Vector2[];
  49559. /**
  49560. * Starts building a polygon from x and y coordinates
  49561. * @param x x coordinate
  49562. * @param y y coordinate
  49563. * @returns the started path2
  49564. */
  49565. static StartingAt(x: number, y: number): Path2;
  49566. }
  49567. /**
  49568. * Builds a polygon
  49569. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49570. */
  49571. export class PolygonMeshBuilder {
  49572. private _points;
  49573. private _outlinepoints;
  49574. private _holes;
  49575. private _name;
  49576. private _scene;
  49577. private _epoints;
  49578. private _eholes;
  49579. private _addToepoint;
  49580. /**
  49581. * Babylon reference to the earcut plugin.
  49582. */
  49583. bjsEarcut: any;
  49584. /**
  49585. * Creates a PolygonMeshBuilder
  49586. * @param name name of the builder
  49587. * @param contours Path of the polygon
  49588. * @param scene scene to add to when creating the mesh
  49589. * @param earcutInjection can be used to inject your own earcut reference
  49590. */
  49591. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49592. /**
  49593. * Adds a whole within the polygon
  49594. * @param hole Array of points defining the hole
  49595. * @returns this
  49596. */
  49597. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49598. /**
  49599. * Creates the polygon
  49600. * @param updatable If the mesh should be updatable
  49601. * @param depth The depth of the mesh created
  49602. * @returns the created mesh
  49603. */
  49604. build(updatable?: boolean, depth?: number): Mesh;
  49605. /**
  49606. * Creates the polygon
  49607. * @param depth The depth of the mesh created
  49608. * @returns the created VertexData
  49609. */
  49610. buildVertexData(depth?: number): VertexData;
  49611. /**
  49612. * Adds a side to the polygon
  49613. * @param positions points that make the polygon
  49614. * @param normals normals of the polygon
  49615. * @param uvs uvs of the polygon
  49616. * @param indices indices of the polygon
  49617. * @param bounds bounds of the polygon
  49618. * @param points points of the polygon
  49619. * @param depth depth of the polygon
  49620. * @param flip flip of the polygon
  49621. */
  49622. private addSide;
  49623. }
  49624. }
  49625. declare module BABYLON {
  49626. /**
  49627. * Class containing static functions to help procedurally build meshes
  49628. */
  49629. export class PolygonBuilder {
  49630. /**
  49631. * Creates a polygon mesh
  49632. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49633. * * 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
  49634. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49636. * * 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)
  49637. * * Remember you can only change the shape positions, not their number when updating a polygon
  49638. * @param name defines the name of the mesh
  49639. * @param options defines the options used to create the mesh
  49640. * @param scene defines the hosting scene
  49641. * @param earcutInjection can be used to inject your own earcut reference
  49642. * @returns the polygon mesh
  49643. */
  49644. static CreatePolygon(name: string, options: {
  49645. shape: Vector3[];
  49646. holes?: Vector3[][];
  49647. depth?: number;
  49648. faceUV?: Vector4[];
  49649. faceColors?: Color4[];
  49650. updatable?: boolean;
  49651. sideOrientation?: number;
  49652. frontUVs?: Vector4;
  49653. backUVs?: Vector4;
  49654. }, scene: Scene, earcutInjection?: any): Mesh;
  49655. /**
  49656. * Creates an extruded polygon mesh, with depth in the Y direction.
  49657. * * 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)
  49658. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49659. * @param name defines the name of the mesh
  49660. * @param options defines the options used to create the mesh
  49661. * @param scene defines the hosting scene
  49662. * @param earcutInjection can be used to inject your own earcut reference
  49663. * @returns the polygon mesh
  49664. */
  49665. static ExtrudePolygon(name: string, options: {
  49666. shape: Vector3[];
  49667. holes?: Vector3[][];
  49668. depth?: number;
  49669. faceUV?: Vector4[];
  49670. faceColors?: Color4[];
  49671. updatable?: boolean;
  49672. sideOrientation?: number;
  49673. frontUVs?: Vector4;
  49674. backUVs?: Vector4;
  49675. }, scene: Scene, earcutInjection?: any): Mesh;
  49676. }
  49677. }
  49678. declare module BABYLON {
  49679. /**
  49680. * Class containing static functions to help procedurally build meshes
  49681. */
  49682. export class LatheBuilder {
  49683. /**
  49684. * Creates lathe mesh.
  49685. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49686. * * 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
  49687. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49688. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49689. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49690. * * 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
  49691. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49692. * * 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
  49693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49694. * * 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
  49695. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49697. * @param name defines the name of the mesh
  49698. * @param options defines the options used to create the mesh
  49699. * @param scene defines the hosting scene
  49700. * @returns the lathe mesh
  49701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49702. */
  49703. static CreateLathe(name: string, options: {
  49704. shape: Vector3[];
  49705. radius?: number;
  49706. tessellation?: number;
  49707. clip?: number;
  49708. arc?: number;
  49709. closed?: boolean;
  49710. updatable?: boolean;
  49711. sideOrientation?: number;
  49712. frontUVs?: Vector4;
  49713. backUVs?: Vector4;
  49714. cap?: number;
  49715. invertUV?: boolean;
  49716. }, scene: Scene): Mesh;
  49717. }
  49718. }
  49719. declare module BABYLON {
  49720. /**
  49721. * Class containing static functions to help procedurally build meshes
  49722. */
  49723. export class TubeBuilder {
  49724. /**
  49725. * Creates a tube mesh.
  49726. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49727. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49728. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49729. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49730. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49731. * * 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)
  49732. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49733. * * 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
  49734. * * 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
  49735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49736. * * 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
  49737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49739. * @param name defines the name of the mesh
  49740. * @param options defines the options used to create the mesh
  49741. * @param scene defines the hosting scene
  49742. * @returns the tube mesh
  49743. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49744. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49745. */
  49746. static CreateTube(name: string, options: {
  49747. path: Vector3[];
  49748. radius?: number;
  49749. tessellation?: number;
  49750. radiusFunction?: {
  49751. (i: number, distance: number): number;
  49752. };
  49753. cap?: number;
  49754. arc?: number;
  49755. updatable?: boolean;
  49756. sideOrientation?: number;
  49757. frontUVs?: Vector4;
  49758. backUVs?: Vector4;
  49759. instance?: Mesh;
  49760. invertUV?: boolean;
  49761. }, scene: Scene): Mesh;
  49762. }
  49763. }
  49764. declare module BABYLON {
  49765. /**
  49766. * Class containing static functions to help procedurally build meshes
  49767. */
  49768. export class IcoSphereBuilder {
  49769. /**
  49770. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49771. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49772. * * 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`)
  49773. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49774. * * 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
  49775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49776. * * 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
  49777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49778. * @param name defines the name of the mesh
  49779. * @param options defines the options used to create the mesh
  49780. * @param scene defines the hosting scene
  49781. * @returns the icosahedron mesh
  49782. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49783. */
  49784. static CreateIcoSphere(name: string, options: {
  49785. radius?: number;
  49786. radiusX?: number;
  49787. radiusY?: number;
  49788. radiusZ?: number;
  49789. flat?: boolean;
  49790. subdivisions?: number;
  49791. sideOrientation?: number;
  49792. frontUVs?: Vector4;
  49793. backUVs?: Vector4;
  49794. updatable?: boolean;
  49795. }, scene: Scene): Mesh;
  49796. }
  49797. }
  49798. declare module BABYLON {
  49799. /**
  49800. * Class containing static functions to help procedurally build meshes
  49801. */
  49802. export class DecalBuilder {
  49803. /**
  49804. * Creates a decal mesh.
  49805. * 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
  49806. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49807. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49808. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49809. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49810. * @param name defines the name of the mesh
  49811. * @param sourceMesh defines the mesh where the decal must be applied
  49812. * @param options defines the options used to create the mesh
  49813. * @param scene defines the hosting scene
  49814. * @returns the decal mesh
  49815. * @see https://doc.babylonjs.com/how_to/decals
  49816. */
  49817. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49818. position?: Vector3;
  49819. normal?: Vector3;
  49820. size?: Vector3;
  49821. angle?: number;
  49822. }): Mesh;
  49823. }
  49824. }
  49825. declare module BABYLON {
  49826. /**
  49827. * Class containing static functions to help procedurally build meshes
  49828. */
  49829. export class MeshBuilder {
  49830. /**
  49831. * Creates a box mesh
  49832. * * The parameter `size` sets the size (float) of each box side (default 1)
  49833. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49834. * * 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)
  49835. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49837. * * 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
  49838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49839. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49840. * @param name defines the name of the mesh
  49841. * @param options defines the options used to create the mesh
  49842. * @param scene defines the hosting scene
  49843. * @returns the box mesh
  49844. */
  49845. static CreateBox(name: string, options: {
  49846. size?: number;
  49847. width?: number;
  49848. height?: number;
  49849. depth?: number;
  49850. faceUV?: Vector4[];
  49851. faceColors?: Color4[];
  49852. sideOrientation?: number;
  49853. frontUVs?: Vector4;
  49854. backUVs?: Vector4;
  49855. updatable?: boolean;
  49856. }, scene?: Nullable<Scene>): Mesh;
  49857. /**
  49858. * Creates a sphere mesh
  49859. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49860. * * 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`)
  49861. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49862. * * 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
  49863. * * 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)
  49864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49865. * * 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
  49866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49867. * @param name defines the name of the mesh
  49868. * @param options defines the options used to create the mesh
  49869. * @param scene defines the hosting scene
  49870. * @returns the sphere mesh
  49871. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49872. */
  49873. static CreateSphere(name: string, options: {
  49874. segments?: number;
  49875. diameter?: number;
  49876. diameterX?: number;
  49877. diameterY?: number;
  49878. diameterZ?: number;
  49879. arc?: number;
  49880. slice?: number;
  49881. sideOrientation?: number;
  49882. frontUVs?: Vector4;
  49883. backUVs?: Vector4;
  49884. updatable?: boolean;
  49885. }, scene: any): Mesh;
  49886. /**
  49887. * Creates a plane polygonal mesh. By default, this is a disc
  49888. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49889. * * 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
  49890. * * 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
  49891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49892. * * 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
  49893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49894. * @param name defines the name of the mesh
  49895. * @param options defines the options used to create the mesh
  49896. * @param scene defines the hosting scene
  49897. * @returns the plane polygonal mesh
  49898. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49899. */
  49900. static CreateDisc(name: string, options: {
  49901. radius?: number;
  49902. tessellation?: number;
  49903. arc?: number;
  49904. updatable?: boolean;
  49905. sideOrientation?: number;
  49906. frontUVs?: Vector4;
  49907. backUVs?: Vector4;
  49908. }, scene?: Nullable<Scene>): Mesh;
  49909. /**
  49910. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49911. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49912. * * 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`)
  49913. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49914. * * 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
  49915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49916. * * 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
  49917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49918. * @param name defines the name of the mesh
  49919. * @param options defines the options used to create the mesh
  49920. * @param scene defines the hosting scene
  49921. * @returns the icosahedron mesh
  49922. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49923. */
  49924. static CreateIcoSphere(name: string, options: {
  49925. radius?: number;
  49926. radiusX?: number;
  49927. radiusY?: number;
  49928. radiusZ?: number;
  49929. flat?: boolean;
  49930. subdivisions?: number;
  49931. sideOrientation?: number;
  49932. frontUVs?: Vector4;
  49933. backUVs?: Vector4;
  49934. updatable?: boolean;
  49935. }, scene: Scene): Mesh;
  49936. /**
  49937. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49938. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49939. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49940. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49941. * * 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
  49942. * * 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
  49943. * * 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
  49944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49945. * * 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
  49946. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49947. * * 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
  49948. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49949. * * 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
  49950. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49952. * @param name defines the name of the mesh
  49953. * @param options defines the options used to create the mesh
  49954. * @param scene defines the hosting scene
  49955. * @returns the ribbon mesh
  49956. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49957. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49958. */
  49959. static CreateRibbon(name: string, options: {
  49960. pathArray: Vector3[][];
  49961. closeArray?: boolean;
  49962. closePath?: boolean;
  49963. offset?: number;
  49964. updatable?: boolean;
  49965. sideOrientation?: number;
  49966. frontUVs?: Vector4;
  49967. backUVs?: Vector4;
  49968. instance?: Mesh;
  49969. invertUV?: boolean;
  49970. uvs?: Vector2[];
  49971. colors?: Color4[];
  49972. }, scene?: Nullable<Scene>): Mesh;
  49973. /**
  49974. * Creates a cylinder or a cone mesh
  49975. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49976. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49977. * * 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.
  49978. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49979. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49980. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49981. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49982. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49983. * * 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).
  49984. * * 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
  49985. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49986. * * 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
  49987. * * 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.
  49988. * * If `enclose` is false, a ring surface is one element.
  49989. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49990. * * 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
  49991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49992. * * 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
  49993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49994. * @param name defines the name of the mesh
  49995. * @param options defines the options used to create the mesh
  49996. * @param scene defines the hosting scene
  49997. * @returns the cylinder mesh
  49998. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49999. */
  50000. static CreateCylinder(name: string, options: {
  50001. height?: number;
  50002. diameterTop?: number;
  50003. diameterBottom?: number;
  50004. diameter?: number;
  50005. tessellation?: number;
  50006. subdivisions?: number;
  50007. arc?: number;
  50008. faceColors?: Color4[];
  50009. faceUV?: Vector4[];
  50010. updatable?: boolean;
  50011. hasRings?: boolean;
  50012. enclose?: boolean;
  50013. sideOrientation?: number;
  50014. frontUVs?: Vector4;
  50015. backUVs?: Vector4;
  50016. }, scene: any): Mesh;
  50017. /**
  50018. * Creates a torus mesh
  50019. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50020. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50021. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50023. * * 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
  50024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50025. * @param name defines the name of the mesh
  50026. * @param options defines the options used to create the mesh
  50027. * @param scene defines the hosting scene
  50028. * @returns the torus mesh
  50029. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50030. */
  50031. static CreateTorus(name: string, options: {
  50032. diameter?: number;
  50033. thickness?: number;
  50034. tessellation?: number;
  50035. updatable?: boolean;
  50036. sideOrientation?: number;
  50037. frontUVs?: Vector4;
  50038. backUVs?: Vector4;
  50039. }, scene: any): Mesh;
  50040. /**
  50041. * Creates a torus knot mesh
  50042. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50043. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50044. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50045. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50047. * * 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
  50048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50049. * @param name defines the name of the mesh
  50050. * @param options defines the options used to create the mesh
  50051. * @param scene defines the hosting scene
  50052. * @returns the torus knot mesh
  50053. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50054. */
  50055. static CreateTorusKnot(name: string, options: {
  50056. radius?: number;
  50057. tube?: number;
  50058. radialSegments?: number;
  50059. tubularSegments?: number;
  50060. p?: number;
  50061. q?: number;
  50062. updatable?: boolean;
  50063. sideOrientation?: number;
  50064. frontUVs?: Vector4;
  50065. backUVs?: Vector4;
  50066. }, scene: any): Mesh;
  50067. /**
  50068. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50069. * * 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
  50070. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50071. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50072. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50073. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50074. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50075. * * 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
  50076. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50079. * @param name defines the name of the new line system
  50080. * @param options defines the options used to create the line system
  50081. * @param scene defines the hosting scene
  50082. * @returns a new line system mesh
  50083. */
  50084. static CreateLineSystem(name: string, options: {
  50085. lines: Vector3[][];
  50086. updatable?: boolean;
  50087. instance?: Nullable<LinesMesh>;
  50088. colors?: Nullable<Color4[][]>;
  50089. useVertexAlpha?: boolean;
  50090. }, scene: Nullable<Scene>): LinesMesh;
  50091. /**
  50092. * Creates a line mesh
  50093. * 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
  50094. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50095. * * The parameter `points` is an array successive Vector3
  50096. * * 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
  50097. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50098. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50099. * * When updating an instance, remember that only point positions can change, not the number of points
  50100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50102. * @param name defines the name of the new line system
  50103. * @param options defines the options used to create the line system
  50104. * @param scene defines the hosting scene
  50105. * @returns a new line mesh
  50106. */
  50107. static CreateLines(name: string, options: {
  50108. points: Vector3[];
  50109. updatable?: boolean;
  50110. instance?: Nullable<LinesMesh>;
  50111. colors?: Color4[];
  50112. useVertexAlpha?: boolean;
  50113. }, scene?: Nullable<Scene>): LinesMesh;
  50114. /**
  50115. * Creates a dashed line mesh
  50116. * * 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
  50117. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50118. * * The parameter `points` is an array successive Vector3
  50119. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50120. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50121. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50122. * * 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
  50123. * * When updating an instance, remember that only point positions can change, not the number of points
  50124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50125. * @param name defines the name of the mesh
  50126. * @param options defines the options used to create the mesh
  50127. * @param scene defines the hosting scene
  50128. * @returns the dashed line mesh
  50129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50130. */
  50131. static CreateDashedLines(name: string, options: {
  50132. points: Vector3[];
  50133. dashSize?: number;
  50134. gapSize?: number;
  50135. dashNb?: number;
  50136. updatable?: boolean;
  50137. instance?: LinesMesh;
  50138. }, scene?: Nullable<Scene>): LinesMesh;
  50139. /**
  50140. * 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.
  50141. * * 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.
  50142. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50143. * * 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.
  50144. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50145. * * 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
  50146. * * 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
  50147. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50149. * * 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
  50150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50152. * @param name defines the name of the mesh
  50153. * @param options defines the options used to create the mesh
  50154. * @param scene defines the hosting scene
  50155. * @returns the extruded shape mesh
  50156. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50158. */
  50159. static ExtrudeShape(name: string, options: {
  50160. shape: Vector3[];
  50161. path: Vector3[];
  50162. scale?: number;
  50163. rotation?: number;
  50164. cap?: number;
  50165. updatable?: boolean;
  50166. sideOrientation?: number;
  50167. frontUVs?: Vector4;
  50168. backUVs?: Vector4;
  50169. instance?: Mesh;
  50170. invertUV?: boolean;
  50171. }, scene?: Nullable<Scene>): Mesh;
  50172. /**
  50173. * Creates an custom extruded shape mesh.
  50174. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50175. * * 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.
  50176. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50177. * * 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
  50178. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50179. * * 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
  50180. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50181. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50182. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50183. * * 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
  50184. * * 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
  50185. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50187. * * 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
  50188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50190. * @param name defines the name of the mesh
  50191. * @param options defines the options used to create the mesh
  50192. * @param scene defines the hosting scene
  50193. * @returns the custom extruded shape mesh
  50194. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50195. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50197. */
  50198. static ExtrudeShapeCustom(name: string, options: {
  50199. shape: Vector3[];
  50200. path: Vector3[];
  50201. scaleFunction?: any;
  50202. rotationFunction?: any;
  50203. ribbonCloseArray?: boolean;
  50204. ribbonClosePath?: boolean;
  50205. cap?: number;
  50206. updatable?: boolean;
  50207. sideOrientation?: number;
  50208. frontUVs?: Vector4;
  50209. backUVs?: Vector4;
  50210. instance?: Mesh;
  50211. invertUV?: boolean;
  50212. }, scene: Scene): Mesh;
  50213. /**
  50214. * Creates lathe mesh.
  50215. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50216. * * 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
  50217. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50218. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50219. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50220. * * 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
  50221. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50222. * * 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
  50223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50224. * * 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
  50225. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50227. * @param name defines the name of the mesh
  50228. * @param options defines the options used to create the mesh
  50229. * @param scene defines the hosting scene
  50230. * @returns the lathe mesh
  50231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50232. */
  50233. static CreateLathe(name: string, options: {
  50234. shape: Vector3[];
  50235. radius?: number;
  50236. tessellation?: number;
  50237. clip?: number;
  50238. arc?: number;
  50239. closed?: boolean;
  50240. updatable?: boolean;
  50241. sideOrientation?: number;
  50242. frontUVs?: Vector4;
  50243. backUVs?: Vector4;
  50244. cap?: number;
  50245. invertUV?: boolean;
  50246. }, scene: Scene): Mesh;
  50247. /**
  50248. * Creates a plane mesh
  50249. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50250. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50251. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50253. * * 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
  50254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50255. * @param name defines the name of the mesh
  50256. * @param options defines the options used to create the mesh
  50257. * @param scene defines the hosting scene
  50258. * @returns the plane mesh
  50259. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50260. */
  50261. static CreatePlane(name: string, options: {
  50262. size?: number;
  50263. width?: number;
  50264. height?: number;
  50265. sideOrientation?: number;
  50266. frontUVs?: Vector4;
  50267. backUVs?: Vector4;
  50268. updatable?: boolean;
  50269. sourcePlane?: Plane;
  50270. }, scene: Scene): Mesh;
  50271. /**
  50272. * Creates a ground mesh
  50273. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50274. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50276. * @param name defines the name of the mesh
  50277. * @param options defines the options used to create the mesh
  50278. * @param scene defines the hosting scene
  50279. * @returns the ground mesh
  50280. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50281. */
  50282. static CreateGround(name: string, options: {
  50283. width?: number;
  50284. height?: number;
  50285. subdivisions?: number;
  50286. subdivisionsX?: number;
  50287. subdivisionsY?: number;
  50288. updatable?: boolean;
  50289. }, scene: any): Mesh;
  50290. /**
  50291. * Creates a tiled ground mesh
  50292. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50293. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50294. * * 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
  50295. * * 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
  50296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50297. * @param name defines the name of the mesh
  50298. * @param options defines the options used to create the mesh
  50299. * @param scene defines the hosting scene
  50300. * @returns the tiled ground mesh
  50301. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50302. */
  50303. static CreateTiledGround(name: string, options: {
  50304. xmin: number;
  50305. zmin: number;
  50306. xmax: number;
  50307. zmax: number;
  50308. subdivisions?: {
  50309. w: number;
  50310. h: number;
  50311. };
  50312. precision?: {
  50313. w: number;
  50314. h: number;
  50315. };
  50316. updatable?: boolean;
  50317. }, scene: Scene): Mesh;
  50318. /**
  50319. * Creates a ground mesh from a height map
  50320. * * The parameter `url` sets the URL of the height map image resource.
  50321. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50322. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50323. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50324. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50325. * * 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.
  50326. * * 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).
  50327. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50329. * @param name defines the name of the mesh
  50330. * @param url defines the url to the height map
  50331. * @param options defines the options used to create the mesh
  50332. * @param scene defines the hosting scene
  50333. * @returns the ground mesh
  50334. * @see https://doc.babylonjs.com/babylon101/height_map
  50335. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50336. */
  50337. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50338. width?: number;
  50339. height?: number;
  50340. subdivisions?: number;
  50341. minHeight?: number;
  50342. maxHeight?: number;
  50343. colorFilter?: Color3;
  50344. alphaFilter?: number;
  50345. updatable?: boolean;
  50346. onReady?: (mesh: GroundMesh) => void;
  50347. }, scene: Scene): GroundMesh;
  50348. /**
  50349. * Creates a polygon mesh
  50350. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50351. * * 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
  50352. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50354. * * 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)
  50355. * * Remember you can only change the shape positions, not their number when updating a polygon
  50356. * @param name defines the name of the mesh
  50357. * @param options defines the options used to create the mesh
  50358. * @param scene defines the hosting scene
  50359. * @param earcutInjection can be used to inject your own earcut reference
  50360. * @returns the polygon mesh
  50361. */
  50362. static CreatePolygon(name: string, options: {
  50363. shape: Vector3[];
  50364. holes?: Vector3[][];
  50365. depth?: number;
  50366. faceUV?: Vector4[];
  50367. faceColors?: Color4[];
  50368. updatable?: boolean;
  50369. sideOrientation?: number;
  50370. frontUVs?: Vector4;
  50371. backUVs?: Vector4;
  50372. }, scene: Scene, earcutInjection?: any): Mesh;
  50373. /**
  50374. * Creates an extruded polygon mesh, with depth in the Y direction.
  50375. * * 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)
  50376. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50377. * @param name defines the name of the mesh
  50378. * @param options defines the options used to create the mesh
  50379. * @param scene defines the hosting scene
  50380. * @param earcutInjection can be used to inject your own earcut reference
  50381. * @returns the polygon mesh
  50382. */
  50383. static ExtrudePolygon(name: string, options: {
  50384. shape: Vector3[];
  50385. holes?: Vector3[][];
  50386. depth?: number;
  50387. faceUV?: Vector4[];
  50388. faceColors?: Color4[];
  50389. updatable?: boolean;
  50390. sideOrientation?: number;
  50391. frontUVs?: Vector4;
  50392. backUVs?: Vector4;
  50393. }, scene: Scene, earcutInjection?: any): Mesh;
  50394. /**
  50395. * Creates a tube mesh.
  50396. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50397. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50398. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50399. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50400. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50401. * * 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)
  50402. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50403. * * 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
  50404. * * 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
  50405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50406. * * 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
  50407. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50409. * @param name defines the name of the mesh
  50410. * @param options defines the options used to create the mesh
  50411. * @param scene defines the hosting scene
  50412. * @returns the tube mesh
  50413. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50414. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50415. */
  50416. static CreateTube(name: string, options: {
  50417. path: Vector3[];
  50418. radius?: number;
  50419. tessellation?: number;
  50420. radiusFunction?: {
  50421. (i: number, distance: number): number;
  50422. };
  50423. cap?: number;
  50424. arc?: number;
  50425. updatable?: boolean;
  50426. sideOrientation?: number;
  50427. frontUVs?: Vector4;
  50428. backUVs?: Vector4;
  50429. instance?: Mesh;
  50430. invertUV?: boolean;
  50431. }, scene: Scene): Mesh;
  50432. /**
  50433. * Creates a polyhedron mesh
  50434. * * 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
  50435. * * The parameter `size` (positive float, default 1) sets the polygon size
  50436. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50437. * * 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`
  50438. * * 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
  50439. * * 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)`)
  50440. * * 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
  50441. * * 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
  50442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50443. * * 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
  50444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50445. * @param name defines the name of the mesh
  50446. * @param options defines the options used to create the mesh
  50447. * @param scene defines the hosting scene
  50448. * @returns the polyhedron mesh
  50449. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50450. */
  50451. static CreatePolyhedron(name: string, options: {
  50452. type?: number;
  50453. size?: number;
  50454. sizeX?: number;
  50455. sizeY?: number;
  50456. sizeZ?: number;
  50457. custom?: any;
  50458. faceUV?: Vector4[];
  50459. faceColors?: Color4[];
  50460. flat?: boolean;
  50461. updatable?: boolean;
  50462. sideOrientation?: number;
  50463. frontUVs?: Vector4;
  50464. backUVs?: Vector4;
  50465. }, scene: Scene): Mesh;
  50466. /**
  50467. * Creates a decal mesh.
  50468. * 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
  50469. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50470. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50471. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50472. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50473. * @param name defines the name of the mesh
  50474. * @param sourceMesh defines the mesh where the decal must be applied
  50475. * @param options defines the options used to create the mesh
  50476. * @param scene defines the hosting scene
  50477. * @returns the decal mesh
  50478. * @see https://doc.babylonjs.com/how_to/decals
  50479. */
  50480. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50481. position?: Vector3;
  50482. normal?: Vector3;
  50483. size?: Vector3;
  50484. angle?: number;
  50485. }): Mesh;
  50486. }
  50487. }
  50488. declare module BABYLON {
  50489. /**
  50490. * A simplifier interface for future simplification implementations
  50491. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50492. */
  50493. export interface ISimplifier {
  50494. /**
  50495. * Simplification of a given mesh according to the given settings.
  50496. * Since this requires computation, it is assumed that the function runs async.
  50497. * @param settings The settings of the simplification, including quality and distance
  50498. * @param successCallback A callback that will be called after the mesh was simplified.
  50499. * @param errorCallback in case of an error, this callback will be called. optional.
  50500. */
  50501. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50502. }
  50503. /**
  50504. * Expected simplification settings.
  50505. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50506. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50507. */
  50508. export interface ISimplificationSettings {
  50509. /**
  50510. * Gets or sets the expected quality
  50511. */
  50512. quality: number;
  50513. /**
  50514. * Gets or sets the distance when this optimized version should be used
  50515. */
  50516. distance: number;
  50517. /**
  50518. * Gets an already optimized mesh
  50519. */
  50520. optimizeMesh?: boolean;
  50521. }
  50522. /**
  50523. * Class used to specify simplification options
  50524. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50525. */
  50526. export class SimplificationSettings implements ISimplificationSettings {
  50527. /** expected quality */
  50528. quality: number;
  50529. /** distance when this optimized version should be used */
  50530. distance: number;
  50531. /** already optimized mesh */
  50532. optimizeMesh?: boolean | undefined;
  50533. /**
  50534. * Creates a SimplificationSettings
  50535. * @param quality expected quality
  50536. * @param distance distance when this optimized version should be used
  50537. * @param optimizeMesh already optimized mesh
  50538. */
  50539. constructor(
  50540. /** expected quality */
  50541. quality: number,
  50542. /** distance when this optimized version should be used */
  50543. distance: number,
  50544. /** already optimized mesh */
  50545. optimizeMesh?: boolean | undefined);
  50546. }
  50547. /**
  50548. * Interface used to define a simplification task
  50549. */
  50550. export interface ISimplificationTask {
  50551. /**
  50552. * Array of settings
  50553. */
  50554. settings: Array<ISimplificationSettings>;
  50555. /**
  50556. * Simplification type
  50557. */
  50558. simplificationType: SimplificationType;
  50559. /**
  50560. * Mesh to simplify
  50561. */
  50562. mesh: Mesh;
  50563. /**
  50564. * Callback called on success
  50565. */
  50566. successCallback?: () => void;
  50567. /**
  50568. * Defines if parallel processing can be used
  50569. */
  50570. parallelProcessing: boolean;
  50571. }
  50572. /**
  50573. * Queue used to order the simplification tasks
  50574. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50575. */
  50576. export class SimplificationQueue {
  50577. private _simplificationArray;
  50578. /**
  50579. * Gets a boolean indicating that the process is still running
  50580. */
  50581. running: boolean;
  50582. /**
  50583. * Creates a new queue
  50584. */
  50585. constructor();
  50586. /**
  50587. * Adds a new simplification task
  50588. * @param task defines a task to add
  50589. */
  50590. addTask(task: ISimplificationTask): void;
  50591. /**
  50592. * Execute next task
  50593. */
  50594. executeNext(): void;
  50595. /**
  50596. * Execute a simplification task
  50597. * @param task defines the task to run
  50598. */
  50599. runSimplification(task: ISimplificationTask): void;
  50600. private getSimplifier;
  50601. }
  50602. /**
  50603. * The implemented types of simplification
  50604. * At the moment only Quadratic Error Decimation is implemented
  50605. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50606. */
  50607. export enum SimplificationType {
  50608. /** Quadratic error decimation */
  50609. QUADRATIC = 0
  50610. }
  50611. }
  50612. declare module BABYLON {
  50613. interface Scene {
  50614. /** @hidden (Backing field) */
  50615. _simplificationQueue: SimplificationQueue;
  50616. /**
  50617. * Gets or sets the simplification queue attached to the scene
  50618. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50619. */
  50620. simplificationQueue: SimplificationQueue;
  50621. }
  50622. interface Mesh {
  50623. /**
  50624. * Simplify the mesh according to the given array of settings.
  50625. * Function will return immediately and will simplify async
  50626. * @param settings a collection of simplification settings
  50627. * @param parallelProcessing should all levels calculate parallel or one after the other
  50628. * @param simplificationType the type of simplification to run
  50629. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50630. * @returns the current mesh
  50631. */
  50632. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50633. }
  50634. /**
  50635. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50636. * created in a scene
  50637. */
  50638. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50639. /**
  50640. * The component name helpfull to identify the component in the list of scene components.
  50641. */
  50642. readonly name: string;
  50643. /**
  50644. * The scene the component belongs to.
  50645. */
  50646. scene: Scene;
  50647. /**
  50648. * Creates a new instance of the component for the given scene
  50649. * @param scene Defines the scene to register the component in
  50650. */
  50651. constructor(scene: Scene);
  50652. /**
  50653. * Registers the component in a given scene
  50654. */
  50655. register(): void;
  50656. /**
  50657. * Rebuilds the elements related to this component in case of
  50658. * context lost for instance.
  50659. */
  50660. rebuild(): void;
  50661. /**
  50662. * Disposes the component and the associated ressources
  50663. */
  50664. dispose(): void;
  50665. private _beforeCameraUpdate;
  50666. }
  50667. }
  50668. declare module BABYLON {
  50669. /**
  50670. * Class used to enable access to IndexedDB
  50671. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50672. */
  50673. export class Database implements IOfflineProvider {
  50674. private _callbackManifestChecked;
  50675. private _currentSceneUrl;
  50676. private _db;
  50677. private _enableSceneOffline;
  50678. private _enableTexturesOffline;
  50679. private _manifestVersionFound;
  50680. private _mustUpdateRessources;
  50681. private _hasReachedQuota;
  50682. private _isSupported;
  50683. private _idbFactory;
  50684. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50685. private static IsUASupportingBlobStorage;
  50686. /**
  50687. * Gets a boolean indicating if Database storate is enabled (off by default)
  50688. */
  50689. static IDBStorageEnabled: boolean;
  50690. /**
  50691. * Gets a boolean indicating if scene must be saved in the database
  50692. */
  50693. readonly enableSceneOffline: boolean;
  50694. /**
  50695. * Gets a boolean indicating if textures must be saved in the database
  50696. */
  50697. readonly enableTexturesOffline: boolean;
  50698. /**
  50699. * Creates a new Database
  50700. * @param urlToScene defines the url to load the scene
  50701. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50702. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50703. */
  50704. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50705. private static _ParseURL;
  50706. private static _ReturnFullUrlLocation;
  50707. private _checkManifestFile;
  50708. /**
  50709. * Open the database and make it available
  50710. * @param successCallback defines the callback to call on success
  50711. * @param errorCallback defines the callback to call on error
  50712. */
  50713. open(successCallback: () => void, errorCallback: () => void): void;
  50714. /**
  50715. * Loads an image from the database
  50716. * @param url defines the url to load from
  50717. * @param image defines the target DOM image
  50718. */
  50719. loadImage(url: string, image: HTMLImageElement): void;
  50720. private _loadImageFromDBAsync;
  50721. private _saveImageIntoDBAsync;
  50722. private _checkVersionFromDB;
  50723. private _loadVersionFromDBAsync;
  50724. private _saveVersionIntoDBAsync;
  50725. /**
  50726. * Loads a file from database
  50727. * @param url defines the URL to load from
  50728. * @param sceneLoaded defines a callback to call on success
  50729. * @param progressCallBack defines a callback to call when progress changed
  50730. * @param errorCallback defines a callback to call on error
  50731. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50732. */
  50733. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50734. private _loadFileAsync;
  50735. private _saveFileAsync;
  50736. /**
  50737. * Validates if xhr data is correct
  50738. * @param xhr defines the request to validate
  50739. * @param dataType defines the expected data type
  50740. * @returns true if data is correct
  50741. */
  50742. private static _ValidateXHRData;
  50743. }
  50744. }
  50745. declare module BABYLON {
  50746. /** @hidden */
  50747. export var gpuUpdateParticlesPixelShader: {
  50748. name: string;
  50749. shader: string;
  50750. };
  50751. }
  50752. declare module BABYLON {
  50753. /** @hidden */
  50754. export var gpuUpdateParticlesVertexShader: {
  50755. name: string;
  50756. shader: string;
  50757. };
  50758. }
  50759. declare module BABYLON {
  50760. /** @hidden */
  50761. export var clipPlaneFragmentDeclaration2: {
  50762. name: string;
  50763. shader: string;
  50764. };
  50765. }
  50766. declare module BABYLON {
  50767. /** @hidden */
  50768. export var gpuRenderParticlesPixelShader: {
  50769. name: string;
  50770. shader: string;
  50771. };
  50772. }
  50773. declare module BABYLON {
  50774. /** @hidden */
  50775. export var clipPlaneVertexDeclaration2: {
  50776. name: string;
  50777. shader: string;
  50778. };
  50779. }
  50780. declare module BABYLON {
  50781. /** @hidden */
  50782. export var gpuRenderParticlesVertexShader: {
  50783. name: string;
  50784. shader: string;
  50785. };
  50786. }
  50787. declare module BABYLON {
  50788. /**
  50789. * This represents a GPU particle system in Babylon
  50790. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50791. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50792. */
  50793. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50794. /**
  50795. * The layer mask we are rendering the particles through.
  50796. */
  50797. layerMask: number;
  50798. private _capacity;
  50799. private _activeCount;
  50800. private _currentActiveCount;
  50801. private _accumulatedCount;
  50802. private _renderEffect;
  50803. private _updateEffect;
  50804. private _buffer0;
  50805. private _buffer1;
  50806. private _spriteBuffer;
  50807. private _updateVAO;
  50808. private _renderVAO;
  50809. private _targetIndex;
  50810. private _sourceBuffer;
  50811. private _targetBuffer;
  50812. private _engine;
  50813. private _currentRenderId;
  50814. private _started;
  50815. private _stopped;
  50816. private _timeDelta;
  50817. private _randomTexture;
  50818. private _randomTexture2;
  50819. private _attributesStrideSize;
  50820. private _updateEffectOptions;
  50821. private _randomTextureSize;
  50822. private _actualFrame;
  50823. private readonly _rawTextureWidth;
  50824. /**
  50825. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50826. */
  50827. static readonly IsSupported: boolean;
  50828. /**
  50829. * An event triggered when the system is disposed.
  50830. */
  50831. onDisposeObservable: Observable<GPUParticleSystem>;
  50832. /**
  50833. * Gets the maximum number of particles active at the same time.
  50834. * @returns The max number of active particles.
  50835. */
  50836. getCapacity(): number;
  50837. /**
  50838. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50839. * to override the particles.
  50840. */
  50841. forceDepthWrite: boolean;
  50842. /**
  50843. * Gets or set the number of active particles
  50844. */
  50845. activeParticleCount: number;
  50846. private _preWarmDone;
  50847. /**
  50848. * Is this system ready to be used/rendered
  50849. * @return true if the system is ready
  50850. */
  50851. isReady(): boolean;
  50852. /**
  50853. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50854. * @returns True if it has been started, otherwise false.
  50855. */
  50856. isStarted(): boolean;
  50857. /**
  50858. * Starts the particle system and begins to emit
  50859. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50860. */
  50861. start(delay?: number): void;
  50862. /**
  50863. * Stops the particle system.
  50864. */
  50865. stop(): void;
  50866. /**
  50867. * Remove all active particles
  50868. */
  50869. reset(): void;
  50870. /**
  50871. * Returns the string "GPUParticleSystem"
  50872. * @returns a string containing the class name
  50873. */
  50874. getClassName(): string;
  50875. private _colorGradientsTexture;
  50876. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50877. /**
  50878. * Adds a new color gradient
  50879. * @param gradient defines the gradient to use (between 0 and 1)
  50880. * @param color1 defines the color to affect to the specified gradient
  50881. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50882. * @returns the current particle system
  50883. */
  50884. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50885. /**
  50886. * Remove a specific color gradient
  50887. * @param gradient defines the gradient to remove
  50888. * @returns the current particle system
  50889. */
  50890. removeColorGradient(gradient: number): GPUParticleSystem;
  50891. private _angularSpeedGradientsTexture;
  50892. private _sizeGradientsTexture;
  50893. private _velocityGradientsTexture;
  50894. private _limitVelocityGradientsTexture;
  50895. private _dragGradientsTexture;
  50896. private _addFactorGradient;
  50897. /**
  50898. * Adds a new size gradient
  50899. * @param gradient defines the gradient to use (between 0 and 1)
  50900. * @param factor defines the size factor to affect to the specified gradient
  50901. * @returns the current particle system
  50902. */
  50903. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50904. /**
  50905. * Remove a specific size gradient
  50906. * @param gradient defines the gradient to remove
  50907. * @returns the current particle system
  50908. */
  50909. removeSizeGradient(gradient: number): GPUParticleSystem;
  50910. /**
  50911. * Adds a new angular speed gradient
  50912. * @param gradient defines the gradient to use (between 0 and 1)
  50913. * @param factor defines the angular speed to affect to the specified gradient
  50914. * @returns the current particle system
  50915. */
  50916. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50917. /**
  50918. * Remove a specific angular speed gradient
  50919. * @param gradient defines the gradient to remove
  50920. * @returns the current particle system
  50921. */
  50922. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50923. /**
  50924. * Adds a new velocity gradient
  50925. * @param gradient defines the gradient to use (between 0 and 1)
  50926. * @param factor defines the velocity to affect to the specified gradient
  50927. * @returns the current particle system
  50928. */
  50929. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50930. /**
  50931. * Remove a specific velocity gradient
  50932. * @param gradient defines the gradient to remove
  50933. * @returns the current particle system
  50934. */
  50935. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50936. /**
  50937. * Adds a new limit velocity gradient
  50938. * @param gradient defines the gradient to use (between 0 and 1)
  50939. * @param factor defines the limit velocity value to affect to the specified gradient
  50940. * @returns the current particle system
  50941. */
  50942. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50943. /**
  50944. * Remove a specific limit velocity gradient
  50945. * @param gradient defines the gradient to remove
  50946. * @returns the current particle system
  50947. */
  50948. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50949. /**
  50950. * Adds a new drag gradient
  50951. * @param gradient defines the gradient to use (between 0 and 1)
  50952. * @param factor defines the drag value to affect to the specified gradient
  50953. * @returns the current particle system
  50954. */
  50955. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50956. /**
  50957. * Remove a specific drag gradient
  50958. * @param gradient defines the gradient to remove
  50959. * @returns the current particle system
  50960. */
  50961. removeDragGradient(gradient: number): GPUParticleSystem;
  50962. /**
  50963. * Not supported by GPUParticleSystem
  50964. * @param gradient defines the gradient to use (between 0 and 1)
  50965. * @param factor defines the emit rate value to affect to the specified gradient
  50966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50967. * @returns the current particle system
  50968. */
  50969. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50970. /**
  50971. * Not supported by GPUParticleSystem
  50972. * @param gradient defines the gradient to remove
  50973. * @returns the current particle system
  50974. */
  50975. removeEmitRateGradient(gradient: number): IParticleSystem;
  50976. /**
  50977. * Not supported by GPUParticleSystem
  50978. * @param gradient defines the gradient to use (between 0 and 1)
  50979. * @param factor defines the start size value to affect to the specified gradient
  50980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50981. * @returns the current particle system
  50982. */
  50983. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50984. /**
  50985. * Not supported by GPUParticleSystem
  50986. * @param gradient defines the gradient to remove
  50987. * @returns the current particle system
  50988. */
  50989. removeStartSizeGradient(gradient: number): IParticleSystem;
  50990. /**
  50991. * Not supported by GPUParticleSystem
  50992. * @param gradient defines the gradient to use (between 0 and 1)
  50993. * @param min defines the color remap minimal range
  50994. * @param max defines the color remap maximal range
  50995. * @returns the current particle system
  50996. */
  50997. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50998. /**
  50999. * Not supported by GPUParticleSystem
  51000. * @param gradient defines the gradient to remove
  51001. * @returns the current particle system
  51002. */
  51003. removeColorRemapGradient(): IParticleSystem;
  51004. /**
  51005. * Not supported by GPUParticleSystem
  51006. * @param gradient defines the gradient to use (between 0 and 1)
  51007. * @param min defines the alpha remap minimal range
  51008. * @param max defines the alpha remap maximal range
  51009. * @returns the current particle system
  51010. */
  51011. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51012. /**
  51013. * Not supported by GPUParticleSystem
  51014. * @param gradient defines the gradient to remove
  51015. * @returns the current particle system
  51016. */
  51017. removeAlphaRemapGradient(): IParticleSystem;
  51018. /**
  51019. * Not supported by GPUParticleSystem
  51020. * @param gradient defines the gradient to use (between 0 and 1)
  51021. * @param color defines the color to affect to the specified gradient
  51022. * @returns the current particle system
  51023. */
  51024. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51025. /**
  51026. * Not supported by GPUParticleSystem
  51027. * @param gradient defines the gradient to remove
  51028. * @returns the current particle system
  51029. */
  51030. removeRampGradient(): IParticleSystem;
  51031. /**
  51032. * Not supported by GPUParticleSystem
  51033. * @returns the list of ramp gradients
  51034. */
  51035. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51036. /**
  51037. * Not supported by GPUParticleSystem
  51038. * Gets or sets a boolean indicating that ramp gradients must be used
  51039. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51040. */
  51041. useRampGradients: boolean;
  51042. /**
  51043. * Not supported by GPUParticleSystem
  51044. * @param gradient defines the gradient to use (between 0 and 1)
  51045. * @param factor defines the life time factor to affect to the specified gradient
  51046. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51047. * @returns the current particle system
  51048. */
  51049. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51050. /**
  51051. * Not supported by GPUParticleSystem
  51052. * @param gradient defines the gradient to remove
  51053. * @returns the current particle system
  51054. */
  51055. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51056. /**
  51057. * Instantiates a GPU particle system.
  51058. * 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.
  51059. * @param name The name of the particle system
  51060. * @param options The options used to create the system
  51061. * @param scene The scene the particle system belongs to
  51062. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51063. */
  51064. constructor(name: string, options: Partial<{
  51065. capacity: number;
  51066. randomTextureSize: number;
  51067. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51068. protected _reset(): void;
  51069. private _createUpdateVAO;
  51070. private _createRenderVAO;
  51071. private _initialize;
  51072. /** @hidden */
  51073. _recreateUpdateEffect(): void;
  51074. /** @hidden */
  51075. _recreateRenderEffect(): void;
  51076. /**
  51077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51078. * @param preWarm defines if we are in the pre-warmimg phase
  51079. */
  51080. animate(preWarm?: boolean): void;
  51081. private _createFactorGradientTexture;
  51082. private _createSizeGradientTexture;
  51083. private _createAngularSpeedGradientTexture;
  51084. private _createVelocityGradientTexture;
  51085. private _createLimitVelocityGradientTexture;
  51086. private _createDragGradientTexture;
  51087. private _createColorGradientTexture;
  51088. /**
  51089. * Renders the particle system in its current state
  51090. * @param preWarm defines if the system should only update the particles but not render them
  51091. * @returns the current number of particles
  51092. */
  51093. render(preWarm?: boolean): number;
  51094. /**
  51095. * Rebuilds the particle system
  51096. */
  51097. rebuild(): void;
  51098. private _releaseBuffers;
  51099. private _releaseVAOs;
  51100. /**
  51101. * Disposes the particle system and free the associated resources
  51102. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51103. */
  51104. dispose(disposeTexture?: boolean): void;
  51105. /**
  51106. * Clones the particle system.
  51107. * @param name The name of the cloned object
  51108. * @param newEmitter The new emitter to use
  51109. * @returns the cloned particle system
  51110. */
  51111. clone(name: string, newEmitter: any): GPUParticleSystem;
  51112. /**
  51113. * Serializes the particle system to a JSON object.
  51114. * @returns the JSON object
  51115. */
  51116. serialize(): any;
  51117. /**
  51118. * Parses a JSON object to create a GPU particle system.
  51119. * @param parsedParticleSystem The JSON object to parse
  51120. * @param scene The scene to create the particle system in
  51121. * @param rootUrl The root url to use to load external dependencies like texture
  51122. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51123. * @returns the parsed GPU particle system
  51124. */
  51125. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51126. }
  51127. }
  51128. declare module BABYLON {
  51129. /**
  51130. * Represents a set of particle systems working together to create a specific effect
  51131. */
  51132. export class ParticleSystemSet implements IDisposable {
  51133. private _emitterCreationOptions;
  51134. private _emitterNode;
  51135. /**
  51136. * Gets the particle system list
  51137. */
  51138. systems: IParticleSystem[];
  51139. /**
  51140. * Gets the emitter node used with this set
  51141. */
  51142. readonly emitterNode: Nullable<TransformNode>;
  51143. /**
  51144. * Creates a new emitter mesh as a sphere
  51145. * @param options defines the options used to create the sphere
  51146. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51147. * @param scene defines the hosting scene
  51148. */
  51149. setEmitterAsSphere(options: {
  51150. diameter: number;
  51151. segments: number;
  51152. color: Color3;
  51153. }, renderingGroupId: number, scene: Scene): void;
  51154. /**
  51155. * Starts all particle systems of the set
  51156. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51157. */
  51158. start(emitter?: AbstractMesh): void;
  51159. /**
  51160. * Release all associated resources
  51161. */
  51162. dispose(): void;
  51163. /**
  51164. * Serialize the set into a JSON compatible object
  51165. * @returns a JSON compatible representation of the set
  51166. */
  51167. serialize(): any;
  51168. /**
  51169. * Parse a new ParticleSystemSet from a serialized source
  51170. * @param data defines a JSON compatible representation of the set
  51171. * @param scene defines the hosting scene
  51172. * @param gpu defines if we want GPU particles or CPU particles
  51173. * @returns a new ParticleSystemSet
  51174. */
  51175. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51176. }
  51177. }
  51178. declare module BABYLON {
  51179. /**
  51180. * This class is made for on one-liner static method to help creating particle system set.
  51181. */
  51182. export class ParticleHelper {
  51183. /**
  51184. * Gets or sets base Assets URL
  51185. */
  51186. static BaseAssetsUrl: string;
  51187. /**
  51188. * Create a default particle system that you can tweak
  51189. * @param emitter defines the emitter to use
  51190. * @param capacity defines the system capacity (default is 500 particles)
  51191. * @param scene defines the hosting scene
  51192. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51193. * @returns the new Particle system
  51194. */
  51195. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51196. /**
  51197. * This is the main static method (one-liner) of this helper to create different particle systems
  51198. * @param type This string represents the type to the particle system to create
  51199. * @param scene The scene where the particle system should live
  51200. * @param gpu If the system will use gpu
  51201. * @returns the ParticleSystemSet created
  51202. */
  51203. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51204. /**
  51205. * Static function used to export a particle system to a ParticleSystemSet variable.
  51206. * Please note that the emitter shape is not exported
  51207. * @param systems defines the particle systems to export
  51208. * @returns the created particle system set
  51209. */
  51210. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51211. }
  51212. }
  51213. declare module BABYLON {
  51214. interface Engine {
  51215. /**
  51216. * Create an effect to use with particle systems.
  51217. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51218. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51219. * @param uniformsNames defines a list of attribute names
  51220. * @param samplers defines an array of string used to represent textures
  51221. * @param defines defines the string containing the defines to use to compile the shaders
  51222. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51223. * @param onCompiled defines a function to call when the effect creation is successful
  51224. * @param onError defines a function to call when the effect creation has failed
  51225. * @returns the new Effect
  51226. */
  51227. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51228. }
  51229. interface Mesh {
  51230. /**
  51231. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51232. * @returns an array of IParticleSystem
  51233. */
  51234. getEmittedParticleSystems(): IParticleSystem[];
  51235. /**
  51236. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51237. * @returns an array of IParticleSystem
  51238. */
  51239. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51240. }
  51241. /**
  51242. * @hidden
  51243. */
  51244. export var _IDoNeedToBeInTheBuild: number;
  51245. }
  51246. declare module BABYLON {
  51247. interface Scene {
  51248. /** @hidden (Backing field) */
  51249. _physicsEngine: Nullable<IPhysicsEngine>;
  51250. /**
  51251. * Gets the current physics engine
  51252. * @returns a IPhysicsEngine or null if none attached
  51253. */
  51254. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51255. /**
  51256. * Enables physics to the current scene
  51257. * @param gravity defines the scene's gravity for the physics engine
  51258. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51259. * @return a boolean indicating if the physics engine was initialized
  51260. */
  51261. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51262. /**
  51263. * Disables and disposes the physics engine associated with the scene
  51264. */
  51265. disablePhysicsEngine(): void;
  51266. /**
  51267. * Gets a boolean indicating if there is an active physics engine
  51268. * @returns a boolean indicating if there is an active physics engine
  51269. */
  51270. isPhysicsEnabled(): boolean;
  51271. /**
  51272. * Deletes a physics compound impostor
  51273. * @param compound defines the compound to delete
  51274. */
  51275. deleteCompoundImpostor(compound: any): void;
  51276. /**
  51277. * An event triggered when physic simulation is about to be run
  51278. */
  51279. onBeforePhysicsObservable: Observable<Scene>;
  51280. /**
  51281. * An event triggered when physic simulation has been done
  51282. */
  51283. onAfterPhysicsObservable: Observable<Scene>;
  51284. }
  51285. interface AbstractMesh {
  51286. /** @hidden */
  51287. _physicsImpostor: Nullable<PhysicsImpostor>;
  51288. /**
  51289. * Gets or sets impostor used for physic simulation
  51290. * @see http://doc.babylonjs.com/features/physics_engine
  51291. */
  51292. physicsImpostor: Nullable<PhysicsImpostor>;
  51293. /**
  51294. * Gets the current physics impostor
  51295. * @see http://doc.babylonjs.com/features/physics_engine
  51296. * @returns a physics impostor or null
  51297. */
  51298. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51299. /** Apply a physic impulse to the mesh
  51300. * @param force defines the force to apply
  51301. * @param contactPoint defines where to apply the force
  51302. * @returns the current mesh
  51303. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51304. */
  51305. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51306. /**
  51307. * Creates a physic joint between two meshes
  51308. * @param otherMesh defines the other mesh to use
  51309. * @param pivot1 defines the pivot to use on this mesh
  51310. * @param pivot2 defines the pivot to use on the other mesh
  51311. * @param options defines additional options (can be plugin dependent)
  51312. * @returns the current mesh
  51313. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51314. */
  51315. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51316. /** @hidden */
  51317. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51318. }
  51319. /**
  51320. * Defines the physics engine scene component responsible to manage a physics engine
  51321. */
  51322. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51323. /**
  51324. * The component name helpful to identify the component in the list of scene components.
  51325. */
  51326. readonly name: string;
  51327. /**
  51328. * The scene the component belongs to.
  51329. */
  51330. scene: Scene;
  51331. /**
  51332. * Creates a new instance of the component for the given scene
  51333. * @param scene Defines the scene to register the component in
  51334. */
  51335. constructor(scene: Scene);
  51336. /**
  51337. * Registers the component in a given scene
  51338. */
  51339. register(): void;
  51340. /**
  51341. * Rebuilds the elements related to this component in case of
  51342. * context lost for instance.
  51343. */
  51344. rebuild(): void;
  51345. /**
  51346. * Disposes the component and the associated ressources
  51347. */
  51348. dispose(): void;
  51349. }
  51350. }
  51351. declare module BABYLON {
  51352. /**
  51353. * A helper for physics simulations
  51354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51355. */
  51356. export class PhysicsHelper {
  51357. private _scene;
  51358. private _physicsEngine;
  51359. /**
  51360. * Initializes the Physics helper
  51361. * @param scene Babylon.js scene
  51362. */
  51363. constructor(scene: Scene);
  51364. /**
  51365. * Applies a radial explosion impulse
  51366. * @param origin the origin of the explosion
  51367. * @param radiusOrEventOptions the radius or the options of radial explosion
  51368. * @param strength the explosion strength
  51369. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51370. * @returns A physics radial explosion event, or null
  51371. */
  51372. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51373. /**
  51374. * Applies a radial explosion force
  51375. * @param origin the origin of the explosion
  51376. * @param radiusOrEventOptions the radius or the options of radial explosion
  51377. * @param strength the explosion strength
  51378. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51379. * @returns A physics radial explosion event, or null
  51380. */
  51381. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51382. /**
  51383. * Creates a gravitational field
  51384. * @param origin the origin of the explosion
  51385. * @param radiusOrEventOptions the radius or the options of radial explosion
  51386. * @param strength the explosion strength
  51387. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51388. * @returns A physics gravitational field event, or null
  51389. */
  51390. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51391. /**
  51392. * Creates a physics updraft event
  51393. * @param origin the origin of the updraft
  51394. * @param radiusOrEventOptions the radius or the options of the updraft
  51395. * @param strength the strength of the updraft
  51396. * @param height the height of the updraft
  51397. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51398. * @returns A physics updraft event, or null
  51399. */
  51400. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51401. /**
  51402. * Creates a physics vortex event
  51403. * @param origin the of the vortex
  51404. * @param radiusOrEventOptions the radius or the options of the vortex
  51405. * @param strength the strength of the vortex
  51406. * @param height the height of the vortex
  51407. * @returns a Physics vortex event, or null
  51408. * A physics vortex event or null
  51409. */
  51410. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51411. }
  51412. /**
  51413. * Represents a physics radial explosion event
  51414. */
  51415. class PhysicsRadialExplosionEvent {
  51416. private _scene;
  51417. private _options;
  51418. private _sphere;
  51419. private _dataFetched;
  51420. /**
  51421. * Initializes a radial explosioin event
  51422. * @param _scene BabylonJS scene
  51423. * @param _options The options for the vortex event
  51424. */
  51425. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51426. /**
  51427. * Returns the data related to the radial explosion event (sphere).
  51428. * @returns The radial explosion event data
  51429. */
  51430. getData(): PhysicsRadialExplosionEventData;
  51431. /**
  51432. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51433. * @param impostor A physics imposter
  51434. * @param origin the origin of the explosion
  51435. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51436. */
  51437. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51438. /**
  51439. * Triggers affecterd impostors callbacks
  51440. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51441. */
  51442. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51443. /**
  51444. * Disposes the sphere.
  51445. * @param force Specifies if the sphere should be disposed by force
  51446. */
  51447. dispose(force?: boolean): void;
  51448. /*** Helpers ***/
  51449. private _prepareSphere;
  51450. private _intersectsWithSphere;
  51451. }
  51452. /**
  51453. * Represents a gravitational field event
  51454. */
  51455. class PhysicsGravitationalFieldEvent {
  51456. private _physicsHelper;
  51457. private _scene;
  51458. private _origin;
  51459. private _options;
  51460. private _tickCallback;
  51461. private _sphere;
  51462. private _dataFetched;
  51463. /**
  51464. * Initializes the physics gravitational field event
  51465. * @param _physicsHelper A physics helper
  51466. * @param _scene BabylonJS scene
  51467. * @param _origin The origin position of the gravitational field event
  51468. * @param _options The options for the vortex event
  51469. */
  51470. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51471. /**
  51472. * Returns the data related to the gravitational field event (sphere).
  51473. * @returns A gravitational field event
  51474. */
  51475. getData(): PhysicsGravitationalFieldEventData;
  51476. /**
  51477. * Enables the gravitational field.
  51478. */
  51479. enable(): void;
  51480. /**
  51481. * Disables the gravitational field.
  51482. */
  51483. disable(): void;
  51484. /**
  51485. * Disposes the sphere.
  51486. * @param force The force to dispose from the gravitational field event
  51487. */
  51488. dispose(force?: boolean): void;
  51489. private _tick;
  51490. }
  51491. /**
  51492. * Represents a physics updraft event
  51493. */
  51494. class PhysicsUpdraftEvent {
  51495. private _scene;
  51496. private _origin;
  51497. private _options;
  51498. private _physicsEngine;
  51499. private _originTop;
  51500. private _originDirection;
  51501. private _tickCallback;
  51502. private _cylinder;
  51503. private _cylinderPosition;
  51504. private _dataFetched;
  51505. /**
  51506. * Initializes the physics updraft event
  51507. * @param _scene BabylonJS scene
  51508. * @param _origin The origin position of the updraft
  51509. * @param _options The options for the updraft event
  51510. */
  51511. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51512. /**
  51513. * Returns the data related to the updraft event (cylinder).
  51514. * @returns A physics updraft event
  51515. */
  51516. getData(): PhysicsUpdraftEventData;
  51517. /**
  51518. * Enables the updraft.
  51519. */
  51520. enable(): void;
  51521. /**
  51522. * Disables the updraft.
  51523. */
  51524. disable(): void;
  51525. /**
  51526. * Disposes the cylinder.
  51527. * @param force Specifies if the updraft should be disposed by force
  51528. */
  51529. dispose(force?: boolean): void;
  51530. private getImpostorHitData;
  51531. private _tick;
  51532. /*** Helpers ***/
  51533. private _prepareCylinder;
  51534. private _intersectsWithCylinder;
  51535. }
  51536. /**
  51537. * Represents a physics vortex event
  51538. */
  51539. class PhysicsVortexEvent {
  51540. private _scene;
  51541. private _origin;
  51542. private _options;
  51543. private _physicsEngine;
  51544. private _originTop;
  51545. private _tickCallback;
  51546. private _cylinder;
  51547. private _cylinderPosition;
  51548. private _dataFetched;
  51549. /**
  51550. * Initializes the physics vortex event
  51551. * @param _scene The BabylonJS scene
  51552. * @param _origin The origin position of the vortex
  51553. * @param _options The options for the vortex event
  51554. */
  51555. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51556. /**
  51557. * Returns the data related to the vortex event (cylinder).
  51558. * @returns The physics vortex event data
  51559. */
  51560. getData(): PhysicsVortexEventData;
  51561. /**
  51562. * Enables the vortex.
  51563. */
  51564. enable(): void;
  51565. /**
  51566. * Disables the cortex.
  51567. */
  51568. disable(): void;
  51569. /**
  51570. * Disposes the sphere.
  51571. * @param force
  51572. */
  51573. dispose(force?: boolean): void;
  51574. private getImpostorHitData;
  51575. private _tick;
  51576. /*** Helpers ***/
  51577. private _prepareCylinder;
  51578. private _intersectsWithCylinder;
  51579. }
  51580. /**
  51581. * Options fot the radial explosion event
  51582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51583. */
  51584. export class PhysicsRadialExplosionEventOptions {
  51585. /**
  51586. * The radius of the sphere for the radial explosion.
  51587. */
  51588. radius: number;
  51589. /**
  51590. * The strenth of the explosion.
  51591. */
  51592. strength: number;
  51593. /**
  51594. * The strenght of the force in correspondence to the distance of the affected object
  51595. */
  51596. falloff: PhysicsRadialImpulseFalloff;
  51597. /**
  51598. * Sphere options for the radial explosion.
  51599. */
  51600. sphere: {
  51601. segments: number;
  51602. diameter: number;
  51603. };
  51604. /**
  51605. * Sphere options for the radial explosion.
  51606. */
  51607. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51608. }
  51609. /**
  51610. * Options fot the updraft event
  51611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51612. */
  51613. export class PhysicsUpdraftEventOptions {
  51614. /**
  51615. * The radius of the cylinder for the vortex
  51616. */
  51617. radius: number;
  51618. /**
  51619. * The strenth of the updraft.
  51620. */
  51621. strength: number;
  51622. /**
  51623. * The height of the cylinder for the updraft.
  51624. */
  51625. height: number;
  51626. /**
  51627. * The mode for the the updraft.
  51628. */
  51629. updraftMode: PhysicsUpdraftMode;
  51630. }
  51631. /**
  51632. * Options fot the vortex event
  51633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51634. */
  51635. export class PhysicsVortexEventOptions {
  51636. /**
  51637. * The radius of the cylinder for the vortex
  51638. */
  51639. radius: number;
  51640. /**
  51641. * The strenth of the vortex.
  51642. */
  51643. strength: number;
  51644. /**
  51645. * The height of the cylinder for the vortex.
  51646. */
  51647. height: number;
  51648. /**
  51649. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51650. */
  51651. centripetalForceThreshold: number;
  51652. /**
  51653. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51654. */
  51655. centripetalForceMultiplier: number;
  51656. /**
  51657. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51658. */
  51659. centrifugalForceMultiplier: number;
  51660. /**
  51661. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51662. */
  51663. updraftForceMultiplier: number;
  51664. }
  51665. /**
  51666. * The strenght of the force in correspondence to the distance of the affected object
  51667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51668. */
  51669. export enum PhysicsRadialImpulseFalloff {
  51670. /** Defines that impulse is constant in strength across it's whole radius */
  51671. Constant = 0,
  51672. /** Defines that impulse gets weaker if it's further from the origin */
  51673. Linear = 1
  51674. }
  51675. /**
  51676. * The strength of the force in correspondence to the distance of the affected object
  51677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51678. */
  51679. export enum PhysicsUpdraftMode {
  51680. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51681. Center = 0,
  51682. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51683. Perpendicular = 1
  51684. }
  51685. /**
  51686. * Interface for a physics hit data
  51687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51688. */
  51689. export interface PhysicsHitData {
  51690. /**
  51691. * The force applied at the contact point
  51692. */
  51693. force: Vector3;
  51694. /**
  51695. * The contact point
  51696. */
  51697. contactPoint: Vector3;
  51698. /**
  51699. * The distance from the origin to the contact point
  51700. */
  51701. distanceFromOrigin: number;
  51702. }
  51703. /**
  51704. * Interface for radial explosion event data
  51705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51706. */
  51707. export interface PhysicsRadialExplosionEventData {
  51708. /**
  51709. * A sphere used for the radial explosion event
  51710. */
  51711. sphere: Mesh;
  51712. }
  51713. /**
  51714. * Interface for gravitational field event data
  51715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51716. */
  51717. export interface PhysicsGravitationalFieldEventData {
  51718. /**
  51719. * A sphere mesh used for the gravitational field event
  51720. */
  51721. sphere: Mesh;
  51722. }
  51723. /**
  51724. * Interface for updraft event data
  51725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51726. */
  51727. export interface PhysicsUpdraftEventData {
  51728. /**
  51729. * A cylinder used for the updraft event
  51730. */
  51731. cylinder: Mesh;
  51732. }
  51733. /**
  51734. * Interface for vortex event data
  51735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51736. */
  51737. export interface PhysicsVortexEventData {
  51738. /**
  51739. * A cylinder used for the vortex event
  51740. */
  51741. cylinder: Mesh;
  51742. }
  51743. /**
  51744. * Interface for an affected physics impostor
  51745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51746. */
  51747. export interface PhysicsAffectedImpostorWithData {
  51748. /**
  51749. * The impostor affected by the effect
  51750. */
  51751. impostor: PhysicsImpostor;
  51752. /**
  51753. * The data about the hit/horce from the explosion
  51754. */
  51755. hitData: PhysicsHitData;
  51756. }
  51757. }
  51758. declare module BABYLON {
  51759. /** @hidden */
  51760. export var blackAndWhitePixelShader: {
  51761. name: string;
  51762. shader: string;
  51763. };
  51764. }
  51765. declare module BABYLON {
  51766. /**
  51767. * Post process used to render in black and white
  51768. */
  51769. export class BlackAndWhitePostProcess extends PostProcess {
  51770. /**
  51771. * Linear about to convert he result to black and white (default: 1)
  51772. */
  51773. degree: number;
  51774. /**
  51775. * Creates a black and white post process
  51776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51777. * @param name The name of the effect.
  51778. * @param options The required width/height ratio to downsize to before computing the render pass.
  51779. * @param camera The camera to apply the render pass to.
  51780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51781. * @param engine The engine which the post process will be applied. (default: current engine)
  51782. * @param reusable If the post process can be reused on the same frame. (default: false)
  51783. */
  51784. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51785. }
  51786. }
  51787. declare module BABYLON {
  51788. /**
  51789. * This represents a set of one or more post processes in Babylon.
  51790. * A post process can be used to apply a shader to a texture after it is rendered.
  51791. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51792. */
  51793. export class PostProcessRenderEffect {
  51794. private _postProcesses;
  51795. private _getPostProcesses;
  51796. private _singleInstance;
  51797. private _cameras;
  51798. private _indicesForCamera;
  51799. /**
  51800. * Name of the effect
  51801. * @hidden
  51802. */
  51803. _name: string;
  51804. /**
  51805. * Instantiates a post process render effect.
  51806. * A post process can be used to apply a shader to a texture after it is rendered.
  51807. * @param engine The engine the effect is tied to
  51808. * @param name The name of the effect
  51809. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51810. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51811. */
  51812. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51813. /**
  51814. * Checks if all the post processes in the effect are supported.
  51815. */
  51816. readonly isSupported: boolean;
  51817. /**
  51818. * Updates the current state of the effect
  51819. * @hidden
  51820. */
  51821. _update(): void;
  51822. /**
  51823. * Attaches the effect on cameras
  51824. * @param cameras The camera to attach to.
  51825. * @hidden
  51826. */
  51827. _attachCameras(cameras: Camera): void;
  51828. /**
  51829. * Attaches the effect on cameras
  51830. * @param cameras The camera to attach to.
  51831. * @hidden
  51832. */
  51833. _attachCameras(cameras: Camera[]): void;
  51834. /**
  51835. * Detatches the effect on cameras
  51836. * @param cameras The camera to detatch from.
  51837. * @hidden
  51838. */
  51839. _detachCameras(cameras: Camera): void;
  51840. /**
  51841. * Detatches the effect on cameras
  51842. * @param cameras The camera to detatch from.
  51843. * @hidden
  51844. */
  51845. _detachCameras(cameras: Camera[]): void;
  51846. /**
  51847. * Enables the effect on given cameras
  51848. * @param cameras The camera to enable.
  51849. * @hidden
  51850. */
  51851. _enable(cameras: Camera): void;
  51852. /**
  51853. * Enables the effect on given cameras
  51854. * @param cameras The camera to enable.
  51855. * @hidden
  51856. */
  51857. _enable(cameras: Nullable<Camera[]>): void;
  51858. /**
  51859. * Disables the effect on the given cameras
  51860. * @param cameras The camera to disable.
  51861. * @hidden
  51862. */
  51863. _disable(cameras: Camera): void;
  51864. /**
  51865. * Disables the effect on the given cameras
  51866. * @param cameras The camera to disable.
  51867. * @hidden
  51868. */
  51869. _disable(cameras: Nullable<Camera[]>): void;
  51870. /**
  51871. * Gets a list of the post processes contained in the effect.
  51872. * @param camera The camera to get the post processes on.
  51873. * @returns The list of the post processes in the effect.
  51874. */
  51875. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51876. }
  51877. }
  51878. declare module BABYLON {
  51879. /** @hidden */
  51880. export var extractHighlightsPixelShader: {
  51881. name: string;
  51882. shader: string;
  51883. };
  51884. }
  51885. declare module BABYLON {
  51886. /**
  51887. * 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.
  51888. */
  51889. export class ExtractHighlightsPostProcess extends PostProcess {
  51890. /**
  51891. * The luminance threshold, pixels below this value will be set to black.
  51892. */
  51893. threshold: number;
  51894. /** @hidden */
  51895. _exposure: number;
  51896. /**
  51897. * Post process which has the input texture to be used when performing highlight extraction
  51898. * @hidden
  51899. */
  51900. _inputPostProcess: Nullable<PostProcess>;
  51901. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51902. }
  51903. }
  51904. declare module BABYLON {
  51905. /** @hidden */
  51906. export var bloomMergePixelShader: {
  51907. name: string;
  51908. shader: string;
  51909. };
  51910. }
  51911. declare module BABYLON {
  51912. /**
  51913. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51914. */
  51915. export class BloomMergePostProcess extends PostProcess {
  51916. /** Weight of the bloom to be added to the original input. */
  51917. weight: number;
  51918. /**
  51919. * Creates a new instance of @see BloomMergePostProcess
  51920. * @param name The name of the effect.
  51921. * @param originalFromInput Post process which's input will be used for the merge.
  51922. * @param blurred Blurred highlights post process which's output will be used.
  51923. * @param weight Weight of the bloom to be added to the original input.
  51924. * @param options The required width/height ratio to downsize to before computing the render pass.
  51925. * @param camera The camera to apply the render pass to.
  51926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51927. * @param engine The engine which the post process will be applied. (default: current engine)
  51928. * @param reusable If the post process can be reused on the same frame. (default: false)
  51929. * @param textureType Type of textures used when performing the post process. (default: 0)
  51930. * @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)
  51931. */
  51932. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51933. /** Weight of the bloom to be added to the original input. */
  51934. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51935. }
  51936. }
  51937. declare module BABYLON {
  51938. /**
  51939. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51940. */
  51941. export class BloomEffect extends PostProcessRenderEffect {
  51942. private bloomScale;
  51943. /**
  51944. * @hidden Internal
  51945. */
  51946. _effects: Array<PostProcess>;
  51947. /**
  51948. * @hidden Internal
  51949. */
  51950. _downscale: ExtractHighlightsPostProcess;
  51951. private _blurX;
  51952. private _blurY;
  51953. private _merge;
  51954. /**
  51955. * The luminance threshold to find bright areas of the image to bloom.
  51956. */
  51957. threshold: number;
  51958. /**
  51959. * The strength of the bloom.
  51960. */
  51961. weight: number;
  51962. /**
  51963. * Specifies the size of the bloom blur kernel, relative to the final output size
  51964. */
  51965. kernel: number;
  51966. /**
  51967. * Creates a new instance of @see BloomEffect
  51968. * @param scene The scene the effect belongs to.
  51969. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51970. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51971. * @param bloomWeight The the strength of bloom.
  51972. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51973. * @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)
  51974. */
  51975. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51976. /**
  51977. * Disposes each of the internal effects for a given camera.
  51978. * @param camera The camera to dispose the effect on.
  51979. */
  51980. disposeEffects(camera: Camera): void;
  51981. /**
  51982. * @hidden Internal
  51983. */
  51984. _updateEffects(): void;
  51985. /**
  51986. * Internal
  51987. * @returns if all the contained post processes are ready.
  51988. * @hidden
  51989. */
  51990. _isReady(): boolean;
  51991. }
  51992. }
  51993. declare module BABYLON {
  51994. /** @hidden */
  51995. export var chromaticAberrationPixelShader: {
  51996. name: string;
  51997. shader: string;
  51998. };
  51999. }
  52000. declare module BABYLON {
  52001. /**
  52002. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52003. */
  52004. export class ChromaticAberrationPostProcess extends PostProcess {
  52005. /**
  52006. * The amount of seperation of rgb channels (default: 30)
  52007. */
  52008. aberrationAmount: number;
  52009. /**
  52010. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52011. */
  52012. radialIntensity: number;
  52013. /**
  52014. * 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))
  52015. */
  52016. direction: Vector2;
  52017. /**
  52018. * 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))
  52019. */
  52020. centerPosition: Vector2;
  52021. /**
  52022. * Creates a new instance ChromaticAberrationPostProcess
  52023. * @param name The name of the effect.
  52024. * @param screenWidth The width of the screen to apply the effect on.
  52025. * @param screenHeight The height of the screen to apply the effect on.
  52026. * @param options The required width/height ratio to downsize to before computing the render pass.
  52027. * @param camera The camera to apply the render pass to.
  52028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52029. * @param engine The engine which the post process will be applied. (default: current engine)
  52030. * @param reusable If the post process can be reused on the same frame. (default: false)
  52031. * @param textureType Type of textures used when performing the post process. (default: 0)
  52032. * @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)
  52033. */
  52034. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52035. }
  52036. }
  52037. declare module BABYLON {
  52038. /** @hidden */
  52039. export var circleOfConfusionPixelShader: {
  52040. name: string;
  52041. shader: string;
  52042. };
  52043. }
  52044. declare module BABYLON {
  52045. /**
  52046. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52047. */
  52048. export class CircleOfConfusionPostProcess extends PostProcess {
  52049. /**
  52050. * 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.
  52051. */
  52052. lensSize: number;
  52053. /**
  52054. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52055. */
  52056. fStop: number;
  52057. /**
  52058. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52059. */
  52060. focusDistance: number;
  52061. /**
  52062. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52063. */
  52064. focalLength: number;
  52065. private _depthTexture;
  52066. /**
  52067. * Creates a new instance CircleOfConfusionPostProcess
  52068. * @param name The name of the effect.
  52069. * @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.
  52070. * @param options The required width/height ratio to downsize to before computing the render pass.
  52071. * @param camera The camera to apply the render pass to.
  52072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52073. * @param engine The engine which the post process will be applied. (default: current engine)
  52074. * @param reusable If the post process can be reused on the same frame. (default: false)
  52075. * @param textureType Type of textures used when performing the post process. (default: 0)
  52076. * @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)
  52077. */
  52078. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52079. /**
  52080. * 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.
  52081. */
  52082. depthTexture: RenderTargetTexture;
  52083. }
  52084. }
  52085. declare module BABYLON {
  52086. /** @hidden */
  52087. export var colorCorrectionPixelShader: {
  52088. name: string;
  52089. shader: string;
  52090. };
  52091. }
  52092. declare module BABYLON {
  52093. /**
  52094. *
  52095. * This post-process allows the modification of rendered colors by using
  52096. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52097. *
  52098. * The object needs to be provided an url to a texture containing the color
  52099. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52100. * Use an image editing software to tweak the LUT to match your needs.
  52101. *
  52102. * For an example of a color LUT, see here:
  52103. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52104. * For explanations on color grading, see here:
  52105. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52106. *
  52107. */
  52108. export class ColorCorrectionPostProcess extends PostProcess {
  52109. private _colorTableTexture;
  52110. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52111. }
  52112. }
  52113. declare module BABYLON {
  52114. /** @hidden */
  52115. export var convolutionPixelShader: {
  52116. name: string;
  52117. shader: string;
  52118. };
  52119. }
  52120. declare module BABYLON {
  52121. /**
  52122. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52123. * input texture to perform effects such as edge detection or sharpening
  52124. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52125. */
  52126. export class ConvolutionPostProcess extends PostProcess {
  52127. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52128. kernel: number[];
  52129. /**
  52130. * Creates a new instance ConvolutionPostProcess
  52131. * @param name The name of the effect.
  52132. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52133. * @param options The required width/height ratio to downsize to before computing the render pass.
  52134. * @param camera The camera to apply the render pass to.
  52135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52136. * @param engine The engine which the post process will be applied. (default: current engine)
  52137. * @param reusable If the post process can be reused on the same frame. (default: false)
  52138. * @param textureType Type of textures used when performing the post process. (default: 0)
  52139. */
  52140. constructor(name: string,
  52141. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52142. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52143. /**
  52144. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52145. */
  52146. static EdgeDetect0Kernel: number[];
  52147. /**
  52148. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52149. */
  52150. static EdgeDetect1Kernel: number[];
  52151. /**
  52152. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52153. */
  52154. static EdgeDetect2Kernel: number[];
  52155. /**
  52156. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52157. */
  52158. static SharpenKernel: number[];
  52159. /**
  52160. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52161. */
  52162. static EmbossKernel: number[];
  52163. /**
  52164. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52165. */
  52166. static GaussianKernel: number[];
  52167. }
  52168. }
  52169. declare module BABYLON {
  52170. /**
  52171. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52172. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52173. * based on samples that have a large difference in distance than the center pixel.
  52174. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52175. */
  52176. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52177. direction: Vector2;
  52178. /**
  52179. * Creates a new instance CircleOfConfusionPostProcess
  52180. * @param name The name of the effect.
  52181. * @param scene The scene the effect belongs to.
  52182. * @param direction The direction the blur should be applied.
  52183. * @param kernel The size of the kernel used to blur.
  52184. * @param options The required width/height ratio to downsize to before computing the render pass.
  52185. * @param camera The camera to apply the render pass to.
  52186. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52187. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52189. * @param engine The engine which the post process will be applied. (default: current engine)
  52190. * @param reusable If the post process can be reused on the same frame. (default: false)
  52191. * @param textureType Type of textures used when performing the post process. (default: 0)
  52192. * @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)
  52193. */
  52194. 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);
  52195. }
  52196. }
  52197. declare module BABYLON {
  52198. /** @hidden */
  52199. export var depthOfFieldMergePixelShader: {
  52200. name: string;
  52201. shader: string;
  52202. };
  52203. }
  52204. declare module BABYLON {
  52205. /**
  52206. * Options to be set when merging outputs from the default pipeline.
  52207. */
  52208. export class DepthOfFieldMergePostProcessOptions {
  52209. /**
  52210. * The original image to merge on top of
  52211. */
  52212. originalFromInput: PostProcess;
  52213. /**
  52214. * Parameters to perform the merge of the depth of field effect
  52215. */
  52216. depthOfField?: {
  52217. circleOfConfusion: PostProcess;
  52218. blurSteps: Array<PostProcess>;
  52219. };
  52220. /**
  52221. * Parameters to perform the merge of bloom effect
  52222. */
  52223. bloom?: {
  52224. blurred: PostProcess;
  52225. weight: number;
  52226. };
  52227. }
  52228. /**
  52229. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52230. */
  52231. export class DepthOfFieldMergePostProcess extends PostProcess {
  52232. private blurSteps;
  52233. /**
  52234. * Creates a new instance of DepthOfFieldMergePostProcess
  52235. * @param name The name of the effect.
  52236. * @param originalFromInput Post process which's input will be used for the merge.
  52237. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52238. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52239. * @param options The required width/height ratio to downsize to before computing the render pass.
  52240. * @param camera The camera to apply the render pass to.
  52241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52242. * @param engine The engine which the post process will be applied. (default: current engine)
  52243. * @param reusable If the post process can be reused on the same frame. (default: false)
  52244. * @param textureType Type of textures used when performing the post process. (default: 0)
  52245. * @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)
  52246. */
  52247. 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);
  52248. /**
  52249. * Updates the effect with the current post process compile time values and recompiles the shader.
  52250. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52251. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52252. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52253. * @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
  52254. * @param onCompiled Called when the shader has been compiled.
  52255. * @param onError Called if there is an error when compiling a shader.
  52256. */
  52257. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52258. }
  52259. }
  52260. declare module BABYLON {
  52261. /**
  52262. * Specifies the level of max blur that should be applied when using the depth of field effect
  52263. */
  52264. export enum DepthOfFieldEffectBlurLevel {
  52265. /**
  52266. * Subtle blur
  52267. */
  52268. Low = 0,
  52269. /**
  52270. * Medium blur
  52271. */
  52272. Medium = 1,
  52273. /**
  52274. * Large blur
  52275. */
  52276. High = 2
  52277. }
  52278. /**
  52279. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52280. */
  52281. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52282. private _circleOfConfusion;
  52283. /**
  52284. * @hidden Internal, blurs from high to low
  52285. */
  52286. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52287. private _depthOfFieldBlurY;
  52288. private _dofMerge;
  52289. /**
  52290. * @hidden Internal post processes in depth of field effect
  52291. */
  52292. _effects: Array<PostProcess>;
  52293. /**
  52294. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52295. */
  52296. focalLength: number;
  52297. /**
  52298. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52299. */
  52300. fStop: number;
  52301. /**
  52302. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52303. */
  52304. focusDistance: number;
  52305. /**
  52306. * 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.
  52307. */
  52308. lensSize: number;
  52309. /**
  52310. * Creates a new instance DepthOfFieldEffect
  52311. * @param scene The scene the effect belongs to.
  52312. * @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.
  52313. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52314. * @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)
  52315. */
  52316. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52317. /**
  52318. * 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.
  52319. */
  52320. depthTexture: RenderTargetTexture;
  52321. /**
  52322. * Disposes each of the internal effects for a given camera.
  52323. * @param camera The camera to dispose the effect on.
  52324. */
  52325. disposeEffects(camera: Camera): void;
  52326. /**
  52327. * @hidden Internal
  52328. */
  52329. _updateEffects(): void;
  52330. /**
  52331. * Internal
  52332. * @returns if all the contained post processes are ready.
  52333. * @hidden
  52334. */
  52335. _isReady(): boolean;
  52336. }
  52337. }
  52338. declare module BABYLON {
  52339. /** @hidden */
  52340. export var displayPassPixelShader: {
  52341. name: string;
  52342. shader: string;
  52343. };
  52344. }
  52345. declare module BABYLON {
  52346. /**
  52347. * DisplayPassPostProcess which produces an output the same as it's input
  52348. */
  52349. export class DisplayPassPostProcess extends PostProcess {
  52350. /**
  52351. * Creates the DisplayPassPostProcess
  52352. * @param name The name of the effect.
  52353. * @param options The required width/height ratio to downsize to before computing the render pass.
  52354. * @param camera The camera to apply the render pass to.
  52355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52356. * @param engine The engine which the post process will be applied. (default: current engine)
  52357. * @param reusable If the post process can be reused on the same frame. (default: false)
  52358. */
  52359. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52360. }
  52361. }
  52362. declare module BABYLON {
  52363. /** @hidden */
  52364. export var filterPixelShader: {
  52365. name: string;
  52366. shader: string;
  52367. };
  52368. }
  52369. declare module BABYLON {
  52370. /**
  52371. * Applies a kernel filter to the image
  52372. */
  52373. export class FilterPostProcess extends PostProcess {
  52374. /** The matrix to be applied to the image */
  52375. kernelMatrix: Matrix;
  52376. /**
  52377. *
  52378. * @param name The name of the effect.
  52379. * @param kernelMatrix The matrix to be applied to the image
  52380. * @param options The required width/height ratio to downsize to before computing the render pass.
  52381. * @param camera The camera to apply the render pass to.
  52382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52383. * @param engine The engine which the post process will be applied. (default: current engine)
  52384. * @param reusable If the post process can be reused on the same frame. (default: false)
  52385. */
  52386. constructor(name: string,
  52387. /** The matrix to be applied to the image */
  52388. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52389. }
  52390. }
  52391. declare module BABYLON {
  52392. /** @hidden */
  52393. export var fxaaPixelShader: {
  52394. name: string;
  52395. shader: string;
  52396. };
  52397. }
  52398. declare module BABYLON {
  52399. /** @hidden */
  52400. export var fxaaVertexShader: {
  52401. name: string;
  52402. shader: string;
  52403. };
  52404. }
  52405. declare module BABYLON {
  52406. /**
  52407. * Fxaa post process
  52408. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52409. */
  52410. export class FxaaPostProcess extends PostProcess {
  52411. /** @hidden */
  52412. texelWidth: number;
  52413. /** @hidden */
  52414. texelHeight: number;
  52415. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52416. private _getDefines;
  52417. }
  52418. }
  52419. declare module BABYLON {
  52420. /** @hidden */
  52421. export var grainPixelShader: {
  52422. name: string;
  52423. shader: string;
  52424. };
  52425. }
  52426. declare module BABYLON {
  52427. /**
  52428. * The GrainPostProcess adds noise to the image at mid luminance levels
  52429. */
  52430. export class GrainPostProcess extends PostProcess {
  52431. /**
  52432. * The intensity of the grain added (default: 30)
  52433. */
  52434. intensity: number;
  52435. /**
  52436. * If the grain should be randomized on every frame
  52437. */
  52438. animated: boolean;
  52439. /**
  52440. * Creates a new instance of @see GrainPostProcess
  52441. * @param name The name of the effect.
  52442. * @param options The required width/height ratio to downsize to before computing the render pass.
  52443. * @param camera The camera to apply the render pass to.
  52444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52445. * @param engine The engine which the post process will be applied. (default: current engine)
  52446. * @param reusable If the post process can be reused on the same frame. (default: false)
  52447. * @param textureType Type of textures used when performing the post process. (default: 0)
  52448. * @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)
  52449. */
  52450. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52451. }
  52452. }
  52453. declare module BABYLON {
  52454. /** @hidden */
  52455. export var highlightsPixelShader: {
  52456. name: string;
  52457. shader: string;
  52458. };
  52459. }
  52460. declare module BABYLON {
  52461. /**
  52462. * Extracts highlights from the image
  52463. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52464. */
  52465. export class HighlightsPostProcess extends PostProcess {
  52466. /**
  52467. * Extracts highlights from the image
  52468. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52469. * @param name The name of the effect.
  52470. * @param options The required width/height ratio to downsize to before computing the render pass.
  52471. * @param camera The camera to apply the render pass to.
  52472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52473. * @param engine The engine which the post process will be applied. (default: current engine)
  52474. * @param reusable If the post process can be reused on the same frame. (default: false)
  52475. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52476. */
  52477. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52478. }
  52479. }
  52480. declare module BABYLON {
  52481. /** @hidden */
  52482. export var mrtFragmentDeclaration: {
  52483. name: string;
  52484. shader: string;
  52485. };
  52486. }
  52487. declare module BABYLON {
  52488. /** @hidden */
  52489. export var geometryPixelShader: {
  52490. name: string;
  52491. shader: string;
  52492. };
  52493. }
  52494. declare module BABYLON {
  52495. /** @hidden */
  52496. export var geometryVertexShader: {
  52497. name: string;
  52498. shader: string;
  52499. };
  52500. }
  52501. declare module BABYLON {
  52502. /**
  52503. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52504. */
  52505. export class GeometryBufferRenderer {
  52506. /**
  52507. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52508. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52509. */
  52510. static readonly POSITION_TEXTURE_TYPE: number;
  52511. /**
  52512. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52513. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52514. */
  52515. static readonly VELOCITY_TEXTURE_TYPE: number;
  52516. /**
  52517. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52518. * in order to compute objects velocities when enableVelocity is set to "true"
  52519. * @hidden
  52520. */
  52521. _previousTransformationMatrices: {
  52522. [index: number]: Matrix;
  52523. };
  52524. private _scene;
  52525. private _multiRenderTarget;
  52526. private _ratio;
  52527. private _enablePosition;
  52528. private _enableVelocity;
  52529. private _positionIndex;
  52530. private _velocityIndex;
  52531. protected _effect: Effect;
  52532. protected _cachedDefines: string;
  52533. /**
  52534. * Set the render list (meshes to be rendered) used in the G buffer.
  52535. */
  52536. renderList: Mesh[];
  52537. /**
  52538. * Gets wether or not G buffer are supported by the running hardware.
  52539. * This requires draw buffer supports
  52540. */
  52541. readonly isSupported: boolean;
  52542. /**
  52543. * Returns the index of the given texture type in the G-Buffer textures array
  52544. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52545. * @returns the index of the given texture type in the G-Buffer textures array
  52546. */
  52547. getTextureIndex(textureType: number): number;
  52548. /**
  52549. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52550. */
  52551. /**
  52552. * Sets whether or not objects positions are enabled for the G buffer.
  52553. */
  52554. enablePosition: boolean;
  52555. /**
  52556. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52557. */
  52558. /**
  52559. * Sets wether or not objects velocities are enabled for the G buffer.
  52560. */
  52561. enableVelocity: boolean;
  52562. /**
  52563. * Gets the scene associated with the buffer.
  52564. */
  52565. readonly scene: Scene;
  52566. /**
  52567. * Gets the ratio used by the buffer during its creation.
  52568. * How big is the buffer related to the main canvas.
  52569. */
  52570. readonly ratio: number;
  52571. /** @hidden */
  52572. static _SceneComponentInitialization: (scene: Scene) => void;
  52573. /**
  52574. * Creates a new G Buffer for the scene
  52575. * @param scene The scene the buffer belongs to
  52576. * @param ratio How big is the buffer related to the main canvas.
  52577. */
  52578. constructor(scene: Scene, ratio?: number);
  52579. /**
  52580. * Checks wether everything is ready to render a submesh to the G buffer.
  52581. * @param subMesh the submesh to check readiness for
  52582. * @param useInstances is the mesh drawn using instance or not
  52583. * @returns true if ready otherwise false
  52584. */
  52585. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52586. /**
  52587. * Gets the current underlying G Buffer.
  52588. * @returns the buffer
  52589. */
  52590. getGBuffer(): MultiRenderTarget;
  52591. /**
  52592. * Gets the number of samples used to render the buffer (anti aliasing).
  52593. */
  52594. /**
  52595. * Sets the number of samples used to render the buffer (anti aliasing).
  52596. */
  52597. samples: number;
  52598. /**
  52599. * Disposes the renderer and frees up associated resources.
  52600. */
  52601. dispose(): void;
  52602. protected _createRenderTargets(): void;
  52603. }
  52604. }
  52605. declare module BABYLON {
  52606. interface Scene {
  52607. /** @hidden (Backing field) */
  52608. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52609. /**
  52610. * Gets or Sets the current geometry buffer associated to the scene.
  52611. */
  52612. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52613. /**
  52614. * Enables a GeometryBufferRender and associates it with the scene
  52615. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52616. * @returns the GeometryBufferRenderer
  52617. */
  52618. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52619. /**
  52620. * Disables the GeometryBufferRender associated with the scene
  52621. */
  52622. disableGeometryBufferRenderer(): void;
  52623. }
  52624. /**
  52625. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52626. * in several rendering techniques.
  52627. */
  52628. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52629. /**
  52630. * The component name helpful to identify the component in the list of scene components.
  52631. */
  52632. readonly name: string;
  52633. /**
  52634. * The scene the component belongs to.
  52635. */
  52636. scene: Scene;
  52637. /**
  52638. * Creates a new instance of the component for the given scene
  52639. * @param scene Defines the scene to register the component in
  52640. */
  52641. constructor(scene: Scene);
  52642. /**
  52643. * Registers the component in a given scene
  52644. */
  52645. register(): void;
  52646. /**
  52647. * Rebuilds the elements related to this component in case of
  52648. * context lost for instance.
  52649. */
  52650. rebuild(): void;
  52651. /**
  52652. * Disposes the component and the associated ressources
  52653. */
  52654. dispose(): void;
  52655. private _gatherRenderTargets;
  52656. }
  52657. }
  52658. declare module BABYLON {
  52659. /** @hidden */
  52660. export var motionBlurPixelShader: {
  52661. name: string;
  52662. shader: string;
  52663. };
  52664. }
  52665. declare module BABYLON {
  52666. /**
  52667. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52668. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52669. * As an example, all you have to do is to create the post-process:
  52670. * var mb = new BABYLON.MotionBlurPostProcess(
  52671. * 'mb', // The name of the effect.
  52672. * scene, // The scene containing the objects to blur according to their velocity.
  52673. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52674. * camera // The camera to apply the render pass to.
  52675. * );
  52676. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52677. */
  52678. export class MotionBlurPostProcess extends PostProcess {
  52679. /**
  52680. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52681. */
  52682. motionStrength: number;
  52683. /**
  52684. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52685. */
  52686. /**
  52687. * Sets the number of iterations to be used for motion blur quality
  52688. */
  52689. motionBlurSamples: number;
  52690. private _motionBlurSamples;
  52691. private _geometryBufferRenderer;
  52692. /**
  52693. * Creates a new instance MotionBlurPostProcess
  52694. * @param name The name of the effect.
  52695. * @param scene The scene containing the objects to blur according to their velocity.
  52696. * @param options The required width/height ratio to downsize to before computing the render pass.
  52697. * @param camera The camera to apply the render pass to.
  52698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52699. * @param engine The engine which the post process will be applied. (default: current engine)
  52700. * @param reusable If the post process can be reused on the same frame. (default: false)
  52701. * @param textureType Type of textures used when performing the post process. (default: 0)
  52702. * @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)
  52703. */
  52704. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52705. /**
  52706. * Disposes the post process.
  52707. * @param camera The camera to dispose the post process on.
  52708. */
  52709. dispose(camera?: Camera): void;
  52710. }
  52711. }
  52712. declare module BABYLON {
  52713. /** @hidden */
  52714. export var refractionPixelShader: {
  52715. name: string;
  52716. shader: string;
  52717. };
  52718. }
  52719. declare module BABYLON {
  52720. /**
  52721. * Post process which applies a refractin texture
  52722. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52723. */
  52724. export class RefractionPostProcess extends PostProcess {
  52725. /** the base color of the refraction (used to taint the rendering) */
  52726. color: Color3;
  52727. /** simulated refraction depth */
  52728. depth: number;
  52729. /** the coefficient of the base color (0 to remove base color tainting) */
  52730. colorLevel: number;
  52731. private _refTexture;
  52732. private _ownRefractionTexture;
  52733. /**
  52734. * Gets or sets the refraction texture
  52735. * Please note that you are responsible for disposing the texture if you set it manually
  52736. */
  52737. refractionTexture: Texture;
  52738. /**
  52739. * Initializes the RefractionPostProcess
  52740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52741. * @param name The name of the effect.
  52742. * @param refractionTextureUrl Url of the refraction texture to use
  52743. * @param color the base color of the refraction (used to taint the rendering)
  52744. * @param depth simulated refraction depth
  52745. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52746. * @param camera The camera to apply the render pass to.
  52747. * @param options The required width/height ratio to downsize to before computing the render pass.
  52748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52749. * @param engine The engine which the post process will be applied. (default: current engine)
  52750. * @param reusable If the post process can be reused on the same frame. (default: false)
  52751. */
  52752. constructor(name: string, refractionTextureUrl: string,
  52753. /** the base color of the refraction (used to taint the rendering) */
  52754. color: Color3,
  52755. /** simulated refraction depth */
  52756. depth: number,
  52757. /** the coefficient of the base color (0 to remove base color tainting) */
  52758. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52759. /**
  52760. * Disposes of the post process
  52761. * @param camera Camera to dispose post process on
  52762. */
  52763. dispose(camera: Camera): void;
  52764. }
  52765. }
  52766. declare module BABYLON {
  52767. /** @hidden */
  52768. export var sharpenPixelShader: {
  52769. name: string;
  52770. shader: string;
  52771. };
  52772. }
  52773. declare module BABYLON {
  52774. /**
  52775. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52776. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52777. */
  52778. export class SharpenPostProcess extends PostProcess {
  52779. /**
  52780. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52781. */
  52782. colorAmount: number;
  52783. /**
  52784. * How much sharpness should be applied (default: 0.3)
  52785. */
  52786. edgeAmount: number;
  52787. /**
  52788. * Creates a new instance ConvolutionPostProcess
  52789. * @param name The name of the effect.
  52790. * @param options The required width/height ratio to downsize to before computing the render pass.
  52791. * @param camera The camera to apply the render pass to.
  52792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52793. * @param engine The engine which the post process will be applied. (default: current engine)
  52794. * @param reusable If the post process can be reused on the same frame. (default: false)
  52795. * @param textureType Type of textures used when performing the post process. (default: 0)
  52796. * @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)
  52797. */
  52798. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52799. }
  52800. }
  52801. declare module BABYLON {
  52802. /**
  52803. * PostProcessRenderPipeline
  52804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52805. */
  52806. export class PostProcessRenderPipeline {
  52807. private engine;
  52808. private _renderEffects;
  52809. private _renderEffectsForIsolatedPass;
  52810. /**
  52811. * List of inspectable custom properties (used by the Inspector)
  52812. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52813. */
  52814. inspectableCustomProperties: IInspectable[];
  52815. /**
  52816. * @hidden
  52817. */
  52818. protected _cameras: Camera[];
  52819. /** @hidden */
  52820. _name: string;
  52821. /**
  52822. * Gets pipeline name
  52823. */
  52824. readonly name: string;
  52825. /**
  52826. * Initializes a PostProcessRenderPipeline
  52827. * @param engine engine to add the pipeline to
  52828. * @param name name of the pipeline
  52829. */
  52830. constructor(engine: Engine, name: string);
  52831. /**
  52832. * Gets the class name
  52833. * @returns "PostProcessRenderPipeline"
  52834. */
  52835. getClassName(): string;
  52836. /**
  52837. * If all the render effects in the pipeline are supported
  52838. */
  52839. readonly isSupported: boolean;
  52840. /**
  52841. * Adds an effect to the pipeline
  52842. * @param renderEffect the effect to add
  52843. */
  52844. addEffect(renderEffect: PostProcessRenderEffect): void;
  52845. /** @hidden */
  52846. _rebuild(): void;
  52847. /** @hidden */
  52848. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52849. /** @hidden */
  52850. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52851. /** @hidden */
  52852. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52853. /** @hidden */
  52854. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52855. /** @hidden */
  52856. _attachCameras(cameras: Camera, unique: boolean): void;
  52857. /** @hidden */
  52858. _attachCameras(cameras: Camera[], unique: boolean): void;
  52859. /** @hidden */
  52860. _detachCameras(cameras: Camera): void;
  52861. /** @hidden */
  52862. _detachCameras(cameras: Nullable<Camera[]>): void;
  52863. /** @hidden */
  52864. _update(): void;
  52865. /** @hidden */
  52866. _reset(): void;
  52867. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52868. /**
  52869. * Disposes of the pipeline
  52870. */
  52871. dispose(): void;
  52872. }
  52873. }
  52874. declare module BABYLON {
  52875. /**
  52876. * PostProcessRenderPipelineManager class
  52877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52878. */
  52879. export class PostProcessRenderPipelineManager {
  52880. private _renderPipelines;
  52881. /**
  52882. * Initializes a PostProcessRenderPipelineManager
  52883. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52884. */
  52885. constructor();
  52886. /**
  52887. * Gets the list of supported render pipelines
  52888. */
  52889. readonly supportedPipelines: PostProcessRenderPipeline[];
  52890. /**
  52891. * Adds a pipeline to the manager
  52892. * @param renderPipeline The pipeline to add
  52893. */
  52894. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52895. /**
  52896. * Attaches a camera to the pipeline
  52897. * @param renderPipelineName The name of the pipeline to attach to
  52898. * @param cameras the camera to attach
  52899. * @param unique if the camera can be attached multiple times to the pipeline
  52900. */
  52901. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52902. /**
  52903. * Detaches a camera from the pipeline
  52904. * @param renderPipelineName The name of the pipeline to detach from
  52905. * @param cameras the camera to detach
  52906. */
  52907. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52908. /**
  52909. * Enables an effect by name on a pipeline
  52910. * @param renderPipelineName the name of the pipeline to enable the effect in
  52911. * @param renderEffectName the name of the effect to enable
  52912. * @param cameras the cameras that the effect should be enabled on
  52913. */
  52914. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52915. /**
  52916. * Disables an effect by name on a pipeline
  52917. * @param renderPipelineName the name of the pipeline to disable the effect in
  52918. * @param renderEffectName the name of the effect to disable
  52919. * @param cameras the cameras that the effect should be disabled on
  52920. */
  52921. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52922. /**
  52923. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52924. */
  52925. update(): void;
  52926. /** @hidden */
  52927. _rebuild(): void;
  52928. /**
  52929. * Disposes of the manager and pipelines
  52930. */
  52931. dispose(): void;
  52932. }
  52933. }
  52934. declare module BABYLON {
  52935. interface Scene {
  52936. /** @hidden (Backing field) */
  52937. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52938. /**
  52939. * Gets the postprocess render pipeline manager
  52940. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52941. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52942. */
  52943. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52944. }
  52945. /**
  52946. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52947. */
  52948. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52949. /**
  52950. * The component name helpfull to identify the component in the list of scene components.
  52951. */
  52952. readonly name: string;
  52953. /**
  52954. * The scene the component belongs to.
  52955. */
  52956. scene: Scene;
  52957. /**
  52958. * Creates a new instance of the component for the given scene
  52959. * @param scene Defines the scene to register the component in
  52960. */
  52961. constructor(scene: Scene);
  52962. /**
  52963. * Registers the component in a given scene
  52964. */
  52965. register(): void;
  52966. /**
  52967. * Rebuilds the elements related to this component in case of
  52968. * context lost for instance.
  52969. */
  52970. rebuild(): void;
  52971. /**
  52972. * Disposes the component and the associated ressources
  52973. */
  52974. dispose(): void;
  52975. private _gatherRenderTargets;
  52976. }
  52977. }
  52978. declare module BABYLON {
  52979. /**
  52980. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52981. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52982. */
  52983. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52984. private _scene;
  52985. private _camerasToBeAttached;
  52986. /**
  52987. * ID of the sharpen post process,
  52988. */
  52989. private readonly SharpenPostProcessId;
  52990. /**
  52991. * @ignore
  52992. * ID of the image processing post process;
  52993. */
  52994. readonly ImageProcessingPostProcessId: string;
  52995. /**
  52996. * @ignore
  52997. * ID of the Fast Approximate Anti-Aliasing post process;
  52998. */
  52999. readonly FxaaPostProcessId: string;
  53000. /**
  53001. * ID of the chromatic aberration post process,
  53002. */
  53003. private readonly ChromaticAberrationPostProcessId;
  53004. /**
  53005. * ID of the grain post process
  53006. */
  53007. private readonly GrainPostProcessId;
  53008. /**
  53009. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53010. */
  53011. sharpen: SharpenPostProcess;
  53012. private _sharpenEffect;
  53013. private bloom;
  53014. /**
  53015. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53016. */
  53017. depthOfField: DepthOfFieldEffect;
  53018. /**
  53019. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53020. */
  53021. fxaa: FxaaPostProcess;
  53022. /**
  53023. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53024. */
  53025. imageProcessing: ImageProcessingPostProcess;
  53026. /**
  53027. * Chromatic aberration post process which will shift rgb colors in the image
  53028. */
  53029. chromaticAberration: ChromaticAberrationPostProcess;
  53030. private _chromaticAberrationEffect;
  53031. /**
  53032. * Grain post process which add noise to the image
  53033. */
  53034. grain: GrainPostProcess;
  53035. private _grainEffect;
  53036. /**
  53037. * Glow post process which adds a glow to emissive areas of the image
  53038. */
  53039. private _glowLayer;
  53040. /**
  53041. * Animations which can be used to tweak settings over a period of time
  53042. */
  53043. animations: Animation[];
  53044. private _imageProcessingConfigurationObserver;
  53045. private _sharpenEnabled;
  53046. private _bloomEnabled;
  53047. private _depthOfFieldEnabled;
  53048. private _depthOfFieldBlurLevel;
  53049. private _fxaaEnabled;
  53050. private _imageProcessingEnabled;
  53051. private _defaultPipelineTextureType;
  53052. private _bloomScale;
  53053. private _chromaticAberrationEnabled;
  53054. private _grainEnabled;
  53055. private _buildAllowed;
  53056. /**
  53057. * Gets active scene
  53058. */
  53059. readonly scene: Scene;
  53060. /**
  53061. * Enable or disable the sharpen process from the pipeline
  53062. */
  53063. sharpenEnabled: boolean;
  53064. private _resizeObserver;
  53065. private _hardwareScaleLevel;
  53066. private _bloomKernel;
  53067. /**
  53068. * Specifies the size of the bloom blur kernel, relative to the final output size
  53069. */
  53070. bloomKernel: number;
  53071. /**
  53072. * Specifies the weight of the bloom in the final rendering
  53073. */
  53074. private _bloomWeight;
  53075. /**
  53076. * Specifies the luma threshold for the area that will be blurred by the bloom
  53077. */
  53078. private _bloomThreshold;
  53079. private _hdr;
  53080. /**
  53081. * The strength of the bloom.
  53082. */
  53083. bloomWeight: number;
  53084. /**
  53085. * The strength of the bloom.
  53086. */
  53087. bloomThreshold: number;
  53088. /**
  53089. * The scale of the bloom, lower value will provide better performance.
  53090. */
  53091. bloomScale: number;
  53092. /**
  53093. * Enable or disable the bloom from the pipeline
  53094. */
  53095. bloomEnabled: boolean;
  53096. private _rebuildBloom;
  53097. /**
  53098. * If the depth of field is enabled.
  53099. */
  53100. depthOfFieldEnabled: boolean;
  53101. /**
  53102. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53103. */
  53104. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53105. /**
  53106. * If the anti aliasing is enabled.
  53107. */
  53108. fxaaEnabled: boolean;
  53109. private _samples;
  53110. /**
  53111. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53112. */
  53113. samples: number;
  53114. /**
  53115. * If image processing is enabled.
  53116. */
  53117. imageProcessingEnabled: boolean;
  53118. /**
  53119. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53120. */
  53121. glowLayerEnabled: boolean;
  53122. /**
  53123. * Enable or disable the chromaticAberration process from the pipeline
  53124. */
  53125. chromaticAberrationEnabled: boolean;
  53126. /**
  53127. * Enable or disable the grain process from the pipeline
  53128. */
  53129. grainEnabled: boolean;
  53130. /**
  53131. * @constructor
  53132. * @param name - The rendering pipeline name (default: "")
  53133. * @param hdr - If high dynamic range textures should be used (default: true)
  53134. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53135. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53136. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53137. */
  53138. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53139. /**
  53140. * Get the class name
  53141. * @returns "DefaultRenderingPipeline"
  53142. */
  53143. getClassName(): string;
  53144. /**
  53145. * Force the compilation of the entire pipeline.
  53146. */
  53147. prepare(): void;
  53148. private _hasCleared;
  53149. private _prevPostProcess;
  53150. private _prevPrevPostProcess;
  53151. private _setAutoClearAndTextureSharing;
  53152. private _depthOfFieldSceneObserver;
  53153. private _buildPipeline;
  53154. private _disposePostProcesses;
  53155. /**
  53156. * Adds a camera to the pipeline
  53157. * @param camera the camera to be added
  53158. */
  53159. addCamera(camera: Camera): void;
  53160. /**
  53161. * Removes a camera from the pipeline
  53162. * @param camera the camera to remove
  53163. */
  53164. removeCamera(camera: Camera): void;
  53165. /**
  53166. * Dispose of the pipeline and stop all post processes
  53167. */
  53168. dispose(): void;
  53169. /**
  53170. * Serialize the rendering pipeline (Used when exporting)
  53171. * @returns the serialized object
  53172. */
  53173. serialize(): any;
  53174. /**
  53175. * Parse the serialized pipeline
  53176. * @param source Source pipeline.
  53177. * @param scene The scene to load the pipeline to.
  53178. * @param rootUrl The URL of the serialized pipeline.
  53179. * @returns An instantiated pipeline from the serialized object.
  53180. */
  53181. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53182. }
  53183. }
  53184. declare module BABYLON {
  53185. /** @hidden */
  53186. export var lensHighlightsPixelShader: {
  53187. name: string;
  53188. shader: string;
  53189. };
  53190. }
  53191. declare module BABYLON {
  53192. /** @hidden */
  53193. export var depthOfFieldPixelShader: {
  53194. name: string;
  53195. shader: string;
  53196. };
  53197. }
  53198. declare module BABYLON {
  53199. /**
  53200. * BABYLON.JS Chromatic Aberration GLSL Shader
  53201. * Author: Olivier Guyot
  53202. * Separates very slightly R, G and B colors on the edges of the screen
  53203. * Inspired by Francois Tarlier & Martins Upitis
  53204. */
  53205. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53206. /**
  53207. * @ignore
  53208. * The chromatic aberration PostProcess id in the pipeline
  53209. */
  53210. LensChromaticAberrationEffect: string;
  53211. /**
  53212. * @ignore
  53213. * The highlights enhancing PostProcess id in the pipeline
  53214. */
  53215. HighlightsEnhancingEffect: string;
  53216. /**
  53217. * @ignore
  53218. * The depth-of-field PostProcess id in the pipeline
  53219. */
  53220. LensDepthOfFieldEffect: string;
  53221. private _scene;
  53222. private _depthTexture;
  53223. private _grainTexture;
  53224. private _chromaticAberrationPostProcess;
  53225. private _highlightsPostProcess;
  53226. private _depthOfFieldPostProcess;
  53227. private _edgeBlur;
  53228. private _grainAmount;
  53229. private _chromaticAberration;
  53230. private _distortion;
  53231. private _highlightsGain;
  53232. private _highlightsThreshold;
  53233. private _dofDistance;
  53234. private _dofAperture;
  53235. private _dofDarken;
  53236. private _dofPentagon;
  53237. private _blurNoise;
  53238. /**
  53239. * @constructor
  53240. *
  53241. * Effect parameters are as follow:
  53242. * {
  53243. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53244. * edge_blur: number; // from 0 to x (1 for realism)
  53245. * distortion: number; // from 0 to x (1 for realism)
  53246. * grain_amount: number; // from 0 to 1
  53247. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53248. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53249. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53250. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53251. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53252. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53253. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53254. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53255. * }
  53256. * Note: if an effect parameter is unset, effect is disabled
  53257. *
  53258. * @param name The rendering pipeline name
  53259. * @param parameters - An object containing all parameters (see above)
  53260. * @param scene The scene linked to this pipeline
  53261. * @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)
  53262. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53263. */
  53264. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53265. /**
  53266. * Get the class name
  53267. * @returns "LensRenderingPipeline"
  53268. */
  53269. getClassName(): string;
  53270. /**
  53271. * Gets associated scene
  53272. */
  53273. readonly scene: Scene;
  53274. /**
  53275. * Gets or sets the edge blur
  53276. */
  53277. edgeBlur: number;
  53278. /**
  53279. * Gets or sets the grain amount
  53280. */
  53281. grainAmount: number;
  53282. /**
  53283. * Gets or sets the chromatic aberration amount
  53284. */
  53285. chromaticAberration: number;
  53286. /**
  53287. * Gets or sets the depth of field aperture
  53288. */
  53289. dofAperture: number;
  53290. /**
  53291. * Gets or sets the edge distortion
  53292. */
  53293. edgeDistortion: number;
  53294. /**
  53295. * Gets or sets the depth of field distortion
  53296. */
  53297. dofDistortion: number;
  53298. /**
  53299. * Gets or sets the darken out of focus amount
  53300. */
  53301. darkenOutOfFocus: number;
  53302. /**
  53303. * Gets or sets a boolean indicating if blur noise is enabled
  53304. */
  53305. blurNoise: boolean;
  53306. /**
  53307. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53308. */
  53309. pentagonBokeh: boolean;
  53310. /**
  53311. * Gets or sets the highlight grain amount
  53312. */
  53313. highlightsGain: number;
  53314. /**
  53315. * Gets or sets the highlight threshold
  53316. */
  53317. highlightsThreshold: number;
  53318. /**
  53319. * Sets the amount of blur at the edges
  53320. * @param amount blur amount
  53321. */
  53322. setEdgeBlur(amount: number): void;
  53323. /**
  53324. * Sets edge blur to 0
  53325. */
  53326. disableEdgeBlur(): void;
  53327. /**
  53328. * Sets the amout of grain
  53329. * @param amount Amount of grain
  53330. */
  53331. setGrainAmount(amount: number): void;
  53332. /**
  53333. * Set grain amount to 0
  53334. */
  53335. disableGrain(): void;
  53336. /**
  53337. * Sets the chromatic aberration amount
  53338. * @param amount amount of chromatic aberration
  53339. */
  53340. setChromaticAberration(amount: number): void;
  53341. /**
  53342. * Sets chromatic aberration amount to 0
  53343. */
  53344. disableChromaticAberration(): void;
  53345. /**
  53346. * Sets the EdgeDistortion amount
  53347. * @param amount amount of EdgeDistortion
  53348. */
  53349. setEdgeDistortion(amount: number): void;
  53350. /**
  53351. * Sets edge distortion to 0
  53352. */
  53353. disableEdgeDistortion(): void;
  53354. /**
  53355. * Sets the FocusDistance amount
  53356. * @param amount amount of FocusDistance
  53357. */
  53358. setFocusDistance(amount: number): void;
  53359. /**
  53360. * Disables depth of field
  53361. */
  53362. disableDepthOfField(): void;
  53363. /**
  53364. * Sets the Aperture amount
  53365. * @param amount amount of Aperture
  53366. */
  53367. setAperture(amount: number): void;
  53368. /**
  53369. * Sets the DarkenOutOfFocus amount
  53370. * @param amount amount of DarkenOutOfFocus
  53371. */
  53372. setDarkenOutOfFocus(amount: number): void;
  53373. private _pentagonBokehIsEnabled;
  53374. /**
  53375. * Creates a pentagon bokeh effect
  53376. */
  53377. enablePentagonBokeh(): void;
  53378. /**
  53379. * Disables the pentagon bokeh effect
  53380. */
  53381. disablePentagonBokeh(): void;
  53382. /**
  53383. * Enables noise blur
  53384. */
  53385. enableNoiseBlur(): void;
  53386. /**
  53387. * Disables noise blur
  53388. */
  53389. disableNoiseBlur(): void;
  53390. /**
  53391. * Sets the HighlightsGain amount
  53392. * @param amount amount of HighlightsGain
  53393. */
  53394. setHighlightsGain(amount: number): void;
  53395. /**
  53396. * Sets the HighlightsThreshold amount
  53397. * @param amount amount of HighlightsThreshold
  53398. */
  53399. setHighlightsThreshold(amount: number): void;
  53400. /**
  53401. * Disables highlights
  53402. */
  53403. disableHighlights(): void;
  53404. /**
  53405. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53406. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53407. */
  53408. dispose(disableDepthRender?: boolean): void;
  53409. private _createChromaticAberrationPostProcess;
  53410. private _createHighlightsPostProcess;
  53411. private _createDepthOfFieldPostProcess;
  53412. private _createGrainTexture;
  53413. }
  53414. }
  53415. declare module BABYLON {
  53416. /** @hidden */
  53417. export var ssao2PixelShader: {
  53418. name: string;
  53419. shader: string;
  53420. };
  53421. }
  53422. declare module BABYLON {
  53423. /** @hidden */
  53424. export var ssaoCombinePixelShader: {
  53425. name: string;
  53426. shader: string;
  53427. };
  53428. }
  53429. declare module BABYLON {
  53430. /**
  53431. * Render pipeline to produce ssao effect
  53432. */
  53433. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53434. /**
  53435. * @ignore
  53436. * The PassPostProcess id in the pipeline that contains the original scene color
  53437. */
  53438. SSAOOriginalSceneColorEffect: string;
  53439. /**
  53440. * @ignore
  53441. * The SSAO PostProcess id in the pipeline
  53442. */
  53443. SSAORenderEffect: string;
  53444. /**
  53445. * @ignore
  53446. * The horizontal blur PostProcess id in the pipeline
  53447. */
  53448. SSAOBlurHRenderEffect: string;
  53449. /**
  53450. * @ignore
  53451. * The vertical blur PostProcess id in the pipeline
  53452. */
  53453. SSAOBlurVRenderEffect: string;
  53454. /**
  53455. * @ignore
  53456. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53457. */
  53458. SSAOCombineRenderEffect: string;
  53459. /**
  53460. * The output strength of the SSAO post-process. Default value is 1.0.
  53461. */
  53462. totalStrength: number;
  53463. /**
  53464. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53465. */
  53466. maxZ: number;
  53467. /**
  53468. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53469. */
  53470. minZAspect: number;
  53471. private _samples;
  53472. /**
  53473. * Number of samples used for the SSAO calculations. Default value is 8
  53474. */
  53475. samples: number;
  53476. private _textureSamples;
  53477. /**
  53478. * Number of samples to use for antialiasing
  53479. */
  53480. textureSamples: number;
  53481. /**
  53482. * Ratio object used for SSAO ratio and blur ratio
  53483. */
  53484. private _ratio;
  53485. /**
  53486. * Dynamically generated sphere sampler.
  53487. */
  53488. private _sampleSphere;
  53489. /**
  53490. * Blur filter offsets
  53491. */
  53492. private _samplerOffsets;
  53493. private _expensiveBlur;
  53494. /**
  53495. * If bilateral blur should be used
  53496. */
  53497. expensiveBlur: boolean;
  53498. /**
  53499. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53500. */
  53501. radius: number;
  53502. /**
  53503. * The base color of the SSAO post-process
  53504. * The final result is "base + ssao" between [0, 1]
  53505. */
  53506. base: number;
  53507. /**
  53508. * Support test.
  53509. */
  53510. static readonly IsSupported: boolean;
  53511. private _scene;
  53512. private _depthTexture;
  53513. private _normalTexture;
  53514. private _randomTexture;
  53515. private _originalColorPostProcess;
  53516. private _ssaoPostProcess;
  53517. private _blurHPostProcess;
  53518. private _blurVPostProcess;
  53519. private _ssaoCombinePostProcess;
  53520. private _firstUpdate;
  53521. /**
  53522. * Gets active scene
  53523. */
  53524. readonly scene: Scene;
  53525. /**
  53526. * @constructor
  53527. * @param name The rendering pipeline name
  53528. * @param scene The scene linked to this pipeline
  53529. * @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 }
  53530. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53531. */
  53532. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53533. /**
  53534. * Get the class name
  53535. * @returns "SSAO2RenderingPipeline"
  53536. */
  53537. getClassName(): string;
  53538. /**
  53539. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53540. */
  53541. dispose(disableGeometryBufferRenderer?: boolean): void;
  53542. private _createBlurPostProcess;
  53543. /** @hidden */
  53544. _rebuild(): void;
  53545. private _bits;
  53546. private _radicalInverse_VdC;
  53547. private _hammersley;
  53548. private _hemisphereSample_uniform;
  53549. private _generateHemisphere;
  53550. private _createSSAOPostProcess;
  53551. private _createSSAOCombinePostProcess;
  53552. private _createRandomTexture;
  53553. /**
  53554. * Serialize the rendering pipeline (Used when exporting)
  53555. * @returns the serialized object
  53556. */
  53557. serialize(): any;
  53558. /**
  53559. * Parse the serialized pipeline
  53560. * @param source Source pipeline.
  53561. * @param scene The scene to load the pipeline to.
  53562. * @param rootUrl The URL of the serialized pipeline.
  53563. * @returns An instantiated pipeline from the serialized object.
  53564. */
  53565. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53566. }
  53567. }
  53568. declare module BABYLON {
  53569. /** @hidden */
  53570. export var ssaoPixelShader: {
  53571. name: string;
  53572. shader: string;
  53573. };
  53574. }
  53575. declare module BABYLON {
  53576. /**
  53577. * Render pipeline to produce ssao effect
  53578. */
  53579. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53580. /**
  53581. * @ignore
  53582. * The PassPostProcess id in the pipeline that contains the original scene color
  53583. */
  53584. SSAOOriginalSceneColorEffect: string;
  53585. /**
  53586. * @ignore
  53587. * The SSAO PostProcess id in the pipeline
  53588. */
  53589. SSAORenderEffect: string;
  53590. /**
  53591. * @ignore
  53592. * The horizontal blur PostProcess id in the pipeline
  53593. */
  53594. SSAOBlurHRenderEffect: string;
  53595. /**
  53596. * @ignore
  53597. * The vertical blur PostProcess id in the pipeline
  53598. */
  53599. SSAOBlurVRenderEffect: string;
  53600. /**
  53601. * @ignore
  53602. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53603. */
  53604. SSAOCombineRenderEffect: string;
  53605. /**
  53606. * The output strength of the SSAO post-process. Default value is 1.0.
  53607. */
  53608. totalStrength: number;
  53609. /**
  53610. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53611. */
  53612. radius: number;
  53613. /**
  53614. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53615. * Must not be equal to fallOff and superior to fallOff.
  53616. * Default value is 0.0075
  53617. */
  53618. area: number;
  53619. /**
  53620. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53621. * Must not be equal to area and inferior to area.
  53622. * Default value is 0.000001
  53623. */
  53624. fallOff: number;
  53625. /**
  53626. * The base color of the SSAO post-process
  53627. * The final result is "base + ssao" between [0, 1]
  53628. */
  53629. base: number;
  53630. private _scene;
  53631. private _depthTexture;
  53632. private _randomTexture;
  53633. private _originalColorPostProcess;
  53634. private _ssaoPostProcess;
  53635. private _blurHPostProcess;
  53636. private _blurVPostProcess;
  53637. private _ssaoCombinePostProcess;
  53638. private _firstUpdate;
  53639. /**
  53640. * Gets active scene
  53641. */
  53642. readonly scene: Scene;
  53643. /**
  53644. * @constructor
  53645. * @param name - The rendering pipeline name
  53646. * @param scene - The scene linked to this pipeline
  53647. * @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 }
  53648. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53649. */
  53650. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53651. /**
  53652. * Get the class name
  53653. * @returns "SSAORenderingPipeline"
  53654. */
  53655. getClassName(): string;
  53656. /**
  53657. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53658. */
  53659. dispose(disableDepthRender?: boolean): void;
  53660. private _createBlurPostProcess;
  53661. /** @hidden */
  53662. _rebuild(): void;
  53663. private _createSSAOPostProcess;
  53664. private _createSSAOCombinePostProcess;
  53665. private _createRandomTexture;
  53666. }
  53667. }
  53668. declare module BABYLON {
  53669. /** @hidden */
  53670. export var standardPixelShader: {
  53671. name: string;
  53672. shader: string;
  53673. };
  53674. }
  53675. declare module BABYLON {
  53676. /**
  53677. * Standard rendering pipeline
  53678. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53679. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53680. */
  53681. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53682. /**
  53683. * Public members
  53684. */
  53685. /**
  53686. * Post-process which contains the original scene color before the pipeline applies all the effects
  53687. */
  53688. originalPostProcess: Nullable<PostProcess>;
  53689. /**
  53690. * Post-process used to down scale an image x4
  53691. */
  53692. downSampleX4PostProcess: Nullable<PostProcess>;
  53693. /**
  53694. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53695. */
  53696. brightPassPostProcess: Nullable<PostProcess>;
  53697. /**
  53698. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53699. */
  53700. blurHPostProcesses: PostProcess[];
  53701. /**
  53702. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53703. */
  53704. blurVPostProcesses: PostProcess[];
  53705. /**
  53706. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53707. */
  53708. textureAdderPostProcess: Nullable<PostProcess>;
  53709. /**
  53710. * Post-process used to create volumetric lighting effect
  53711. */
  53712. volumetricLightPostProcess: Nullable<PostProcess>;
  53713. /**
  53714. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53715. */
  53716. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53717. /**
  53718. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53719. */
  53720. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53721. /**
  53722. * Post-process used to merge the volumetric light effect and the real scene color
  53723. */
  53724. volumetricLightMergePostProces: Nullable<PostProcess>;
  53725. /**
  53726. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53727. */
  53728. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53729. /**
  53730. * Base post-process used to calculate the average luminance of the final image for HDR
  53731. */
  53732. luminancePostProcess: Nullable<PostProcess>;
  53733. /**
  53734. * Post-processes used to create down sample post-processes in order to get
  53735. * the average luminance of the final image for HDR
  53736. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53737. */
  53738. luminanceDownSamplePostProcesses: PostProcess[];
  53739. /**
  53740. * Post-process used to create a HDR effect (light adaptation)
  53741. */
  53742. hdrPostProcess: Nullable<PostProcess>;
  53743. /**
  53744. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53745. */
  53746. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53747. /**
  53748. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53749. */
  53750. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53751. /**
  53752. * Post-process used to merge the final HDR post-process and the real scene color
  53753. */
  53754. hdrFinalPostProcess: Nullable<PostProcess>;
  53755. /**
  53756. * Post-process used to create a lens flare effect
  53757. */
  53758. lensFlarePostProcess: Nullable<PostProcess>;
  53759. /**
  53760. * Post-process that merges the result of the lens flare post-process and the real scene color
  53761. */
  53762. lensFlareComposePostProcess: Nullable<PostProcess>;
  53763. /**
  53764. * Post-process used to create a motion blur effect
  53765. */
  53766. motionBlurPostProcess: Nullable<PostProcess>;
  53767. /**
  53768. * Post-process used to create a depth of field effect
  53769. */
  53770. depthOfFieldPostProcess: Nullable<PostProcess>;
  53771. /**
  53772. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53773. */
  53774. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53775. /**
  53776. * Represents the brightness threshold in order to configure the illuminated surfaces
  53777. */
  53778. brightThreshold: number;
  53779. /**
  53780. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53781. */
  53782. blurWidth: number;
  53783. /**
  53784. * Sets if the blur for highlighted surfaces must be only horizontal
  53785. */
  53786. horizontalBlur: boolean;
  53787. /**
  53788. * Gets the overall exposure used by the pipeline
  53789. */
  53790. /**
  53791. * Sets the overall exposure used by the pipeline
  53792. */
  53793. exposure: number;
  53794. /**
  53795. * Texture used typically to simulate "dirty" on camera lens
  53796. */
  53797. lensTexture: Nullable<Texture>;
  53798. /**
  53799. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53800. */
  53801. volumetricLightCoefficient: number;
  53802. /**
  53803. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53804. */
  53805. volumetricLightPower: number;
  53806. /**
  53807. * Used the set the blur intensity to smooth the volumetric lights
  53808. */
  53809. volumetricLightBlurScale: number;
  53810. /**
  53811. * Light (spot or directional) used to generate the volumetric lights rays
  53812. * The source light must have a shadow generate so the pipeline can get its
  53813. * depth map
  53814. */
  53815. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53816. /**
  53817. * For eye adaptation, represents the minimum luminance the eye can see
  53818. */
  53819. hdrMinimumLuminance: number;
  53820. /**
  53821. * For eye adaptation, represents the decrease luminance speed
  53822. */
  53823. hdrDecreaseRate: number;
  53824. /**
  53825. * For eye adaptation, represents the increase luminance speed
  53826. */
  53827. hdrIncreaseRate: number;
  53828. /**
  53829. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53830. */
  53831. /**
  53832. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53833. */
  53834. hdrAutoExposure: boolean;
  53835. /**
  53836. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53837. */
  53838. lensColorTexture: Nullable<Texture>;
  53839. /**
  53840. * The overall strengh for the lens flare effect
  53841. */
  53842. lensFlareStrength: number;
  53843. /**
  53844. * Dispersion coefficient for lens flare ghosts
  53845. */
  53846. lensFlareGhostDispersal: number;
  53847. /**
  53848. * Main lens flare halo width
  53849. */
  53850. lensFlareHaloWidth: number;
  53851. /**
  53852. * Based on the lens distortion effect, defines how much the lens flare result
  53853. * is distorted
  53854. */
  53855. lensFlareDistortionStrength: number;
  53856. /**
  53857. * Lens star texture must be used to simulate rays on the flares and is available
  53858. * in the documentation
  53859. */
  53860. lensStarTexture: Nullable<Texture>;
  53861. /**
  53862. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53863. * flare effect by taking account of the dirt texture
  53864. */
  53865. lensFlareDirtTexture: Nullable<Texture>;
  53866. /**
  53867. * Represents the focal length for the depth of field effect
  53868. */
  53869. depthOfFieldDistance: number;
  53870. /**
  53871. * Represents the blur intensity for the blurred part of the depth of field effect
  53872. */
  53873. depthOfFieldBlurWidth: number;
  53874. /**
  53875. * For motion blur, defines how much the image is blurred by the movement
  53876. */
  53877. motionStrength: number;
  53878. /**
  53879. * List of animations for the pipeline (IAnimatable implementation)
  53880. */
  53881. animations: Animation[];
  53882. /**
  53883. * Private members
  53884. */
  53885. private _scene;
  53886. private _currentDepthOfFieldSource;
  53887. private _basePostProcess;
  53888. private _fixedExposure;
  53889. private _currentExposure;
  53890. private _hdrAutoExposure;
  53891. private _hdrCurrentLuminance;
  53892. private _floatTextureType;
  53893. private _ratio;
  53894. private _bloomEnabled;
  53895. private _depthOfFieldEnabled;
  53896. private _vlsEnabled;
  53897. private _lensFlareEnabled;
  53898. private _hdrEnabled;
  53899. private _motionBlurEnabled;
  53900. private _fxaaEnabled;
  53901. private _motionBlurSamples;
  53902. private _volumetricLightStepsCount;
  53903. private _samples;
  53904. /**
  53905. * @ignore
  53906. * Specifies if the bloom pipeline is enabled
  53907. */
  53908. BloomEnabled: boolean;
  53909. /**
  53910. * @ignore
  53911. * Specifies if the depth of field pipeline is enabed
  53912. */
  53913. DepthOfFieldEnabled: boolean;
  53914. /**
  53915. * @ignore
  53916. * Specifies if the lens flare pipeline is enabed
  53917. */
  53918. LensFlareEnabled: boolean;
  53919. /**
  53920. * @ignore
  53921. * Specifies if the HDR pipeline is enabled
  53922. */
  53923. HDREnabled: boolean;
  53924. /**
  53925. * @ignore
  53926. * Specifies if the volumetric lights scattering effect is enabled
  53927. */
  53928. VLSEnabled: boolean;
  53929. /**
  53930. * @ignore
  53931. * Specifies if the motion blur effect is enabled
  53932. */
  53933. MotionBlurEnabled: boolean;
  53934. /**
  53935. * Specifies if anti-aliasing is enabled
  53936. */
  53937. fxaaEnabled: boolean;
  53938. /**
  53939. * Specifies the number of steps used to calculate the volumetric lights
  53940. * Typically in interval [50, 200]
  53941. */
  53942. volumetricLightStepsCount: number;
  53943. /**
  53944. * Specifies the number of samples used for the motion blur effect
  53945. * Typically in interval [16, 64]
  53946. */
  53947. motionBlurSamples: number;
  53948. /**
  53949. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53950. */
  53951. samples: number;
  53952. /**
  53953. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53954. * @constructor
  53955. * @param name The rendering pipeline name
  53956. * @param scene The scene linked to this pipeline
  53957. * @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)
  53958. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53959. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53960. */
  53961. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53962. private _buildPipeline;
  53963. private _createDownSampleX4PostProcess;
  53964. private _createBrightPassPostProcess;
  53965. private _createBlurPostProcesses;
  53966. private _createTextureAdderPostProcess;
  53967. private _createVolumetricLightPostProcess;
  53968. private _createLuminancePostProcesses;
  53969. private _createHdrPostProcess;
  53970. private _createLensFlarePostProcess;
  53971. private _createDepthOfFieldPostProcess;
  53972. private _createMotionBlurPostProcess;
  53973. private _getDepthTexture;
  53974. private _disposePostProcesses;
  53975. /**
  53976. * Dispose of the pipeline and stop all post processes
  53977. */
  53978. dispose(): void;
  53979. /**
  53980. * Serialize the rendering pipeline (Used when exporting)
  53981. * @returns the serialized object
  53982. */
  53983. serialize(): any;
  53984. /**
  53985. * Parse the serialized pipeline
  53986. * @param source Source pipeline.
  53987. * @param scene The scene to load the pipeline to.
  53988. * @param rootUrl The URL of the serialized pipeline.
  53989. * @returns An instantiated pipeline from the serialized object.
  53990. */
  53991. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53992. /**
  53993. * Luminance steps
  53994. */
  53995. static LuminanceSteps: number;
  53996. }
  53997. }
  53998. declare module BABYLON {
  53999. /** @hidden */
  54000. export var tonemapPixelShader: {
  54001. name: string;
  54002. shader: string;
  54003. };
  54004. }
  54005. declare module BABYLON {
  54006. /** Defines operator used for tonemapping */
  54007. export enum TonemappingOperator {
  54008. /** Hable */
  54009. Hable = 0,
  54010. /** Reinhard */
  54011. Reinhard = 1,
  54012. /** HejiDawson */
  54013. HejiDawson = 2,
  54014. /** Photographic */
  54015. Photographic = 3
  54016. }
  54017. /**
  54018. * Defines a post process to apply tone mapping
  54019. */
  54020. export class TonemapPostProcess extends PostProcess {
  54021. private _operator;
  54022. /** Defines the required exposure adjustement */
  54023. exposureAdjustment: number;
  54024. /**
  54025. * Creates a new TonemapPostProcess
  54026. * @param name defines the name of the postprocess
  54027. * @param _operator defines the operator to use
  54028. * @param exposureAdjustment defines the required exposure adjustement
  54029. * @param camera defines the camera to use (can be null)
  54030. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54031. * @param engine defines the hosting engine (can be ignore if camera is set)
  54032. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54033. */
  54034. constructor(name: string, _operator: TonemappingOperator,
  54035. /** Defines the required exposure adjustement */
  54036. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54037. }
  54038. }
  54039. declare module BABYLON {
  54040. /** @hidden */
  54041. export var depthVertexShader: {
  54042. name: string;
  54043. shader: string;
  54044. };
  54045. }
  54046. declare module BABYLON {
  54047. /** @hidden */
  54048. export var volumetricLightScatteringPixelShader: {
  54049. name: string;
  54050. shader: string;
  54051. };
  54052. }
  54053. declare module BABYLON {
  54054. /** @hidden */
  54055. export var volumetricLightScatteringPassPixelShader: {
  54056. name: string;
  54057. shader: string;
  54058. };
  54059. }
  54060. declare module BABYLON {
  54061. /**
  54062. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54063. */
  54064. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54065. private _volumetricLightScatteringPass;
  54066. private _volumetricLightScatteringRTT;
  54067. private _viewPort;
  54068. private _screenCoordinates;
  54069. private _cachedDefines;
  54070. /**
  54071. * If not undefined, the mesh position is computed from the attached node position
  54072. */
  54073. attachedNode: {
  54074. position: Vector3;
  54075. };
  54076. /**
  54077. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54078. */
  54079. customMeshPosition: Vector3;
  54080. /**
  54081. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54082. */
  54083. useCustomMeshPosition: boolean;
  54084. /**
  54085. * If the post-process should inverse the light scattering direction
  54086. */
  54087. invert: boolean;
  54088. /**
  54089. * The internal mesh used by the post-process
  54090. */
  54091. mesh: Mesh;
  54092. /**
  54093. * @hidden
  54094. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54095. */
  54096. useDiffuseColor: boolean;
  54097. /**
  54098. * Array containing the excluded meshes not rendered in the internal pass
  54099. */
  54100. excludedMeshes: AbstractMesh[];
  54101. /**
  54102. * Controls the overall intensity of the post-process
  54103. */
  54104. exposure: number;
  54105. /**
  54106. * Dissipates each sample's contribution in range [0, 1]
  54107. */
  54108. decay: number;
  54109. /**
  54110. * Controls the overall intensity of each sample
  54111. */
  54112. weight: number;
  54113. /**
  54114. * Controls the density of each sample
  54115. */
  54116. density: number;
  54117. /**
  54118. * @constructor
  54119. * @param name The post-process name
  54120. * @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)
  54121. * @param camera The camera that the post-process will be attached to
  54122. * @param mesh The mesh used to create the light scattering
  54123. * @param samples The post-process quality, default 100
  54124. * @param samplingModeThe post-process filtering mode
  54125. * @param engine The babylon engine
  54126. * @param reusable If the post-process is reusable
  54127. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54128. */
  54129. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54130. /**
  54131. * Returns the string "VolumetricLightScatteringPostProcess"
  54132. * @returns "VolumetricLightScatteringPostProcess"
  54133. */
  54134. getClassName(): string;
  54135. private _isReady;
  54136. /**
  54137. * Sets the new light position for light scattering effect
  54138. * @param position The new custom light position
  54139. */
  54140. setCustomMeshPosition(position: Vector3): void;
  54141. /**
  54142. * Returns the light position for light scattering effect
  54143. * @return Vector3 The custom light position
  54144. */
  54145. getCustomMeshPosition(): Vector3;
  54146. /**
  54147. * Disposes the internal assets and detaches the post-process from the camera
  54148. */
  54149. dispose(camera: Camera): void;
  54150. /**
  54151. * Returns the render target texture used by the post-process
  54152. * @return the render target texture used by the post-process
  54153. */
  54154. getPass(): RenderTargetTexture;
  54155. private _meshExcluded;
  54156. private _createPass;
  54157. private _updateMeshScreenCoordinates;
  54158. /**
  54159. * Creates a default mesh for the Volumeric Light Scattering post-process
  54160. * @param name The mesh name
  54161. * @param scene The scene where to create the mesh
  54162. * @return the default mesh
  54163. */
  54164. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54165. }
  54166. }
  54167. declare module BABYLON {
  54168. interface Scene {
  54169. /** @hidden (Backing field) */
  54170. _boundingBoxRenderer: BoundingBoxRenderer;
  54171. /** @hidden (Backing field) */
  54172. _forceShowBoundingBoxes: boolean;
  54173. /**
  54174. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54175. */
  54176. forceShowBoundingBoxes: boolean;
  54177. /**
  54178. * Gets the bounding box renderer associated with the scene
  54179. * @returns a BoundingBoxRenderer
  54180. */
  54181. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54182. }
  54183. interface AbstractMesh {
  54184. /** @hidden (Backing field) */
  54185. _showBoundingBox: boolean;
  54186. /**
  54187. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54188. */
  54189. showBoundingBox: boolean;
  54190. }
  54191. /**
  54192. * Component responsible of rendering the bounding box of the meshes in a scene.
  54193. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54194. */
  54195. export class BoundingBoxRenderer implements ISceneComponent {
  54196. /**
  54197. * The component name helpfull to identify the component in the list of scene components.
  54198. */
  54199. readonly name: string;
  54200. /**
  54201. * The scene the component belongs to.
  54202. */
  54203. scene: Scene;
  54204. /**
  54205. * Color of the bounding box lines placed in front of an object
  54206. */
  54207. frontColor: Color3;
  54208. /**
  54209. * Color of the bounding box lines placed behind an object
  54210. */
  54211. backColor: Color3;
  54212. /**
  54213. * Defines if the renderer should show the back lines or not
  54214. */
  54215. showBackLines: boolean;
  54216. /**
  54217. * @hidden
  54218. */
  54219. renderList: SmartArray<BoundingBox>;
  54220. private _colorShader;
  54221. private _vertexBuffers;
  54222. private _indexBuffer;
  54223. /**
  54224. * Instantiates a new bounding box renderer in a scene.
  54225. * @param scene the scene the renderer renders in
  54226. */
  54227. constructor(scene: Scene);
  54228. /**
  54229. * Registers the component in a given scene
  54230. */
  54231. register(): void;
  54232. private _evaluateSubMesh;
  54233. private _activeMesh;
  54234. private _prepareRessources;
  54235. private _createIndexBuffer;
  54236. /**
  54237. * Rebuilds the elements related to this component in case of
  54238. * context lost for instance.
  54239. */
  54240. rebuild(): void;
  54241. /**
  54242. * @hidden
  54243. */
  54244. reset(): void;
  54245. /**
  54246. * Render the bounding boxes of a specific rendering group
  54247. * @param renderingGroupId defines the rendering group to render
  54248. */
  54249. render(renderingGroupId: number): void;
  54250. /**
  54251. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54252. * @param mesh Define the mesh to render the occlusion bounding box for
  54253. */
  54254. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54255. /**
  54256. * Dispose and release the resources attached to this renderer.
  54257. */
  54258. dispose(): void;
  54259. }
  54260. }
  54261. declare module BABYLON {
  54262. /** @hidden */
  54263. export var depthPixelShader: {
  54264. name: string;
  54265. shader: string;
  54266. };
  54267. }
  54268. declare module BABYLON {
  54269. /**
  54270. * This represents a depth renderer in Babylon.
  54271. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54272. */
  54273. export class DepthRenderer {
  54274. private _scene;
  54275. private _depthMap;
  54276. private _effect;
  54277. private _cachedDefines;
  54278. private _camera;
  54279. /**
  54280. * Specifiess that the depth renderer will only be used within
  54281. * the camera it is created for.
  54282. * This can help forcing its rendering during the camera processing.
  54283. */
  54284. useOnlyInActiveCamera: boolean;
  54285. /** @hidden */
  54286. static _SceneComponentInitialization: (scene: Scene) => void;
  54287. /**
  54288. * Instantiates a depth renderer
  54289. * @param scene The scene the renderer belongs to
  54290. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54291. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54292. */
  54293. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54294. /**
  54295. * Creates the depth rendering effect and checks if the effect is ready.
  54296. * @param subMesh The submesh to be used to render the depth map of
  54297. * @param useInstances If multiple world instances should be used
  54298. * @returns if the depth renderer is ready to render the depth map
  54299. */
  54300. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54301. /**
  54302. * Gets the texture which the depth map will be written to.
  54303. * @returns The depth map texture
  54304. */
  54305. getDepthMap(): RenderTargetTexture;
  54306. /**
  54307. * Disposes of the depth renderer.
  54308. */
  54309. dispose(): void;
  54310. }
  54311. }
  54312. declare module BABYLON {
  54313. interface Scene {
  54314. /** @hidden (Backing field) */
  54315. _depthRenderer: {
  54316. [id: string]: DepthRenderer;
  54317. };
  54318. /**
  54319. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54320. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54321. * @returns the created depth renderer
  54322. */
  54323. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54324. /**
  54325. * Disables a depth renderer for a given camera
  54326. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54327. */
  54328. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54329. }
  54330. /**
  54331. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54332. * in several rendering techniques.
  54333. */
  54334. export class DepthRendererSceneComponent implements ISceneComponent {
  54335. /**
  54336. * The component name helpfull to identify the component in the list of scene components.
  54337. */
  54338. readonly name: string;
  54339. /**
  54340. * The scene the component belongs to.
  54341. */
  54342. scene: Scene;
  54343. /**
  54344. * Creates a new instance of the component for the given scene
  54345. * @param scene Defines the scene to register the component in
  54346. */
  54347. constructor(scene: Scene);
  54348. /**
  54349. * Registers the component in a given scene
  54350. */
  54351. register(): void;
  54352. /**
  54353. * Rebuilds the elements related to this component in case of
  54354. * context lost for instance.
  54355. */
  54356. rebuild(): void;
  54357. /**
  54358. * Disposes the component and the associated ressources
  54359. */
  54360. dispose(): void;
  54361. private _gatherRenderTargets;
  54362. private _gatherActiveCameraRenderTargets;
  54363. }
  54364. }
  54365. declare module BABYLON {
  54366. /** @hidden */
  54367. export var outlinePixelShader: {
  54368. name: string;
  54369. shader: string;
  54370. };
  54371. }
  54372. declare module BABYLON {
  54373. /** @hidden */
  54374. export var outlineVertexShader: {
  54375. name: string;
  54376. shader: string;
  54377. };
  54378. }
  54379. declare module BABYLON {
  54380. interface Scene {
  54381. /** @hidden */
  54382. _outlineRenderer: OutlineRenderer;
  54383. /**
  54384. * Gets the outline renderer associated with the scene
  54385. * @returns a OutlineRenderer
  54386. */
  54387. getOutlineRenderer(): OutlineRenderer;
  54388. }
  54389. interface AbstractMesh {
  54390. /** @hidden (Backing field) */
  54391. _renderOutline: boolean;
  54392. /**
  54393. * Gets or sets a boolean indicating if the outline must be rendered as well
  54394. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54395. */
  54396. renderOutline: boolean;
  54397. /** @hidden (Backing field) */
  54398. _renderOverlay: boolean;
  54399. /**
  54400. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54401. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54402. */
  54403. renderOverlay: boolean;
  54404. }
  54405. /**
  54406. * This class is responsible to draw bothe outline/overlay of meshes.
  54407. * It should not be used directly but through the available method on mesh.
  54408. */
  54409. export class OutlineRenderer implements ISceneComponent {
  54410. /**
  54411. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54412. */
  54413. private static _StencilReference;
  54414. /**
  54415. * The name of the component. Each component must have a unique name.
  54416. */
  54417. name: string;
  54418. /**
  54419. * The scene the component belongs to.
  54420. */
  54421. scene: Scene;
  54422. /**
  54423. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54424. */
  54425. zOffset: number;
  54426. private _engine;
  54427. private _effect;
  54428. private _cachedDefines;
  54429. private _savedDepthWrite;
  54430. /**
  54431. * Instantiates a new outline renderer. (There could be only one per scene).
  54432. * @param scene Defines the scene it belongs to
  54433. */
  54434. constructor(scene: Scene);
  54435. /**
  54436. * Register the component to one instance of a scene.
  54437. */
  54438. register(): void;
  54439. /**
  54440. * Rebuilds the elements related to this component in case of
  54441. * context lost for instance.
  54442. */
  54443. rebuild(): void;
  54444. /**
  54445. * Disposes the component and the associated ressources.
  54446. */
  54447. dispose(): void;
  54448. /**
  54449. * Renders the outline in the canvas.
  54450. * @param subMesh Defines the sumesh to render
  54451. * @param batch Defines the batch of meshes in case of instances
  54452. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54453. */
  54454. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54455. /**
  54456. * Returns whether or not the outline renderer is ready for a given submesh.
  54457. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54458. * @param subMesh Defines the submesh to check readyness for
  54459. * @param useInstances Defines wheter wee are trying to render instances or not
  54460. * @returns true if ready otherwise false
  54461. */
  54462. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54463. private _beforeRenderingMesh;
  54464. private _afterRenderingMesh;
  54465. }
  54466. }
  54467. declare module BABYLON {
  54468. /**
  54469. * Defines the list of states available for a task inside a AssetsManager
  54470. */
  54471. export enum AssetTaskState {
  54472. /**
  54473. * Initialization
  54474. */
  54475. INIT = 0,
  54476. /**
  54477. * Running
  54478. */
  54479. RUNNING = 1,
  54480. /**
  54481. * Done
  54482. */
  54483. DONE = 2,
  54484. /**
  54485. * Error
  54486. */
  54487. ERROR = 3
  54488. }
  54489. /**
  54490. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54491. */
  54492. export abstract class AbstractAssetTask {
  54493. /**
  54494. * Task name
  54495. */ name: string;
  54496. /**
  54497. * Callback called when the task is successful
  54498. */
  54499. onSuccess: (task: any) => void;
  54500. /**
  54501. * Callback called when the task is not successful
  54502. */
  54503. onError: (task: any, message?: string, exception?: any) => void;
  54504. /**
  54505. * Creates a new AssetsManager
  54506. * @param name defines the name of the task
  54507. */
  54508. constructor(
  54509. /**
  54510. * Task name
  54511. */ name: string);
  54512. private _isCompleted;
  54513. private _taskState;
  54514. private _errorObject;
  54515. /**
  54516. * Get if the task is completed
  54517. */
  54518. readonly isCompleted: boolean;
  54519. /**
  54520. * Gets the current state of the task
  54521. */
  54522. readonly taskState: AssetTaskState;
  54523. /**
  54524. * Gets the current error object (if task is in error)
  54525. */
  54526. readonly errorObject: {
  54527. message?: string;
  54528. exception?: any;
  54529. };
  54530. /**
  54531. * Internal only
  54532. * @hidden
  54533. */
  54534. _setErrorObject(message?: string, exception?: any): void;
  54535. /**
  54536. * Execute the current task
  54537. * @param scene defines the scene where you want your assets to be loaded
  54538. * @param onSuccess is a callback called when the task is successfully executed
  54539. * @param onError is a callback called if an error occurs
  54540. */
  54541. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54542. /**
  54543. * Execute the current task
  54544. * @param scene defines the scene where you want your assets to be loaded
  54545. * @param onSuccess is a callback called when the task is successfully executed
  54546. * @param onError is a callback called if an error occurs
  54547. */
  54548. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54549. /**
  54550. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54551. * This can be used with failed tasks that have the reason for failure fixed.
  54552. */
  54553. reset(): void;
  54554. private onErrorCallback;
  54555. private onDoneCallback;
  54556. }
  54557. /**
  54558. * Define the interface used by progress events raised during assets loading
  54559. */
  54560. export interface IAssetsProgressEvent {
  54561. /**
  54562. * Defines the number of remaining tasks to process
  54563. */
  54564. remainingCount: number;
  54565. /**
  54566. * Defines the total number of tasks
  54567. */
  54568. totalCount: number;
  54569. /**
  54570. * Defines the task that was just processed
  54571. */
  54572. task: AbstractAssetTask;
  54573. }
  54574. /**
  54575. * Class used to share progress information about assets loading
  54576. */
  54577. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54578. /**
  54579. * Defines the number of remaining tasks to process
  54580. */
  54581. remainingCount: number;
  54582. /**
  54583. * Defines the total number of tasks
  54584. */
  54585. totalCount: number;
  54586. /**
  54587. * Defines the task that was just processed
  54588. */
  54589. task: AbstractAssetTask;
  54590. /**
  54591. * Creates a AssetsProgressEvent
  54592. * @param remainingCount defines the number of remaining tasks to process
  54593. * @param totalCount defines the total number of tasks
  54594. * @param task defines the task that was just processed
  54595. */
  54596. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54597. }
  54598. /**
  54599. * Define a task used by AssetsManager to load meshes
  54600. */
  54601. export class MeshAssetTask extends AbstractAssetTask {
  54602. /**
  54603. * Defines the name of the task
  54604. */
  54605. name: string;
  54606. /**
  54607. * Defines the list of mesh's names you want to load
  54608. */
  54609. meshesNames: any;
  54610. /**
  54611. * Defines the root url to use as a base to load your meshes and associated resources
  54612. */
  54613. rootUrl: string;
  54614. /**
  54615. * Defines the filename of the scene to load from
  54616. */
  54617. sceneFilename: string;
  54618. /**
  54619. * Gets the list of loaded meshes
  54620. */
  54621. loadedMeshes: Array<AbstractMesh>;
  54622. /**
  54623. * Gets the list of loaded particle systems
  54624. */
  54625. loadedParticleSystems: Array<IParticleSystem>;
  54626. /**
  54627. * Gets the list of loaded skeletons
  54628. */
  54629. loadedSkeletons: Array<Skeleton>;
  54630. /**
  54631. * Gets the list of loaded animation groups
  54632. */
  54633. loadedAnimationGroups: Array<AnimationGroup>;
  54634. /**
  54635. * Callback called when the task is successful
  54636. */
  54637. onSuccess: (task: MeshAssetTask) => void;
  54638. /**
  54639. * Callback called when the task is successful
  54640. */
  54641. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54642. /**
  54643. * Creates a new MeshAssetTask
  54644. * @param name defines the name of the task
  54645. * @param meshesNames defines the list of mesh's names you want to load
  54646. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54647. * @param sceneFilename defines the filename of the scene to load from
  54648. */
  54649. constructor(
  54650. /**
  54651. * Defines the name of the task
  54652. */
  54653. name: string,
  54654. /**
  54655. * Defines the list of mesh's names you want to load
  54656. */
  54657. meshesNames: any,
  54658. /**
  54659. * Defines the root url to use as a base to load your meshes and associated resources
  54660. */
  54661. rootUrl: string,
  54662. /**
  54663. * Defines the filename of the scene to load from
  54664. */
  54665. sceneFilename: string);
  54666. /**
  54667. * Execute the current task
  54668. * @param scene defines the scene where you want your assets to be loaded
  54669. * @param onSuccess is a callback called when the task is successfully executed
  54670. * @param onError is a callback called if an error occurs
  54671. */
  54672. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54673. }
  54674. /**
  54675. * Define a task used by AssetsManager to load text content
  54676. */
  54677. export class TextFileAssetTask extends AbstractAssetTask {
  54678. /**
  54679. * Defines the name of the task
  54680. */
  54681. name: string;
  54682. /**
  54683. * Defines the location of the file to load
  54684. */
  54685. url: string;
  54686. /**
  54687. * Gets the loaded text string
  54688. */
  54689. text: string;
  54690. /**
  54691. * Callback called when the task is successful
  54692. */
  54693. onSuccess: (task: TextFileAssetTask) => void;
  54694. /**
  54695. * Callback called when the task is successful
  54696. */
  54697. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54698. /**
  54699. * Creates a new TextFileAssetTask object
  54700. * @param name defines the name of the task
  54701. * @param url defines the location of the file to load
  54702. */
  54703. constructor(
  54704. /**
  54705. * Defines the name of the task
  54706. */
  54707. name: string,
  54708. /**
  54709. * Defines the location of the file to load
  54710. */
  54711. url: string);
  54712. /**
  54713. * Execute the current task
  54714. * @param scene defines the scene where you want your assets to be loaded
  54715. * @param onSuccess is a callback called when the task is successfully executed
  54716. * @param onError is a callback called if an error occurs
  54717. */
  54718. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54719. }
  54720. /**
  54721. * Define a task used by AssetsManager to load binary data
  54722. */
  54723. export class BinaryFileAssetTask extends AbstractAssetTask {
  54724. /**
  54725. * Defines the name of the task
  54726. */
  54727. name: string;
  54728. /**
  54729. * Defines the location of the file to load
  54730. */
  54731. url: string;
  54732. /**
  54733. * Gets the lodaded data (as an array buffer)
  54734. */
  54735. data: ArrayBuffer;
  54736. /**
  54737. * Callback called when the task is successful
  54738. */
  54739. onSuccess: (task: BinaryFileAssetTask) => void;
  54740. /**
  54741. * Callback called when the task is successful
  54742. */
  54743. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54744. /**
  54745. * Creates a new BinaryFileAssetTask object
  54746. * @param name defines the name of the new task
  54747. * @param url defines the location of the file to load
  54748. */
  54749. constructor(
  54750. /**
  54751. * Defines the name of the task
  54752. */
  54753. name: string,
  54754. /**
  54755. * Defines the location of the file to load
  54756. */
  54757. url: string);
  54758. /**
  54759. * Execute the current task
  54760. * @param scene defines the scene where you want your assets to be loaded
  54761. * @param onSuccess is a callback called when the task is successfully executed
  54762. * @param onError is a callback called if an error occurs
  54763. */
  54764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54765. }
  54766. /**
  54767. * Define a task used by AssetsManager to load images
  54768. */
  54769. export class ImageAssetTask extends AbstractAssetTask {
  54770. /**
  54771. * Defines the name of the task
  54772. */
  54773. name: string;
  54774. /**
  54775. * Defines the location of the image to load
  54776. */
  54777. url: string;
  54778. /**
  54779. * Gets the loaded images
  54780. */
  54781. image: HTMLImageElement;
  54782. /**
  54783. * Callback called when the task is successful
  54784. */
  54785. onSuccess: (task: ImageAssetTask) => void;
  54786. /**
  54787. * Callback called when the task is successful
  54788. */
  54789. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54790. /**
  54791. * Creates a new ImageAssetTask
  54792. * @param name defines the name of the task
  54793. * @param url defines the location of the image to load
  54794. */
  54795. constructor(
  54796. /**
  54797. * Defines the name of the task
  54798. */
  54799. name: string,
  54800. /**
  54801. * Defines the location of the image to load
  54802. */
  54803. url: string);
  54804. /**
  54805. * Execute the current task
  54806. * @param scene defines the scene where you want your assets to be loaded
  54807. * @param onSuccess is a callback called when the task is successfully executed
  54808. * @param onError is a callback called if an error occurs
  54809. */
  54810. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54811. }
  54812. /**
  54813. * Defines the interface used by texture loading tasks
  54814. */
  54815. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54816. /**
  54817. * Gets the loaded texture
  54818. */
  54819. texture: TEX;
  54820. }
  54821. /**
  54822. * Define a task used by AssetsManager to load 2D textures
  54823. */
  54824. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54825. /**
  54826. * Defines the name of the task
  54827. */
  54828. name: string;
  54829. /**
  54830. * Defines the location of the file to load
  54831. */
  54832. url: string;
  54833. /**
  54834. * Defines if mipmap should not be generated (default is false)
  54835. */
  54836. noMipmap?: boolean | undefined;
  54837. /**
  54838. * Defines if texture must be inverted on Y axis (default is false)
  54839. */
  54840. invertY?: boolean | undefined;
  54841. /**
  54842. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54843. */
  54844. samplingMode: number;
  54845. /**
  54846. * Gets the loaded texture
  54847. */
  54848. texture: Texture;
  54849. /**
  54850. * Callback called when the task is successful
  54851. */
  54852. onSuccess: (task: TextureAssetTask) => void;
  54853. /**
  54854. * Callback called when the task is successful
  54855. */
  54856. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54857. /**
  54858. * Creates a new TextureAssetTask object
  54859. * @param name defines the name of the task
  54860. * @param url defines the location of the file to load
  54861. * @param noMipmap defines if mipmap should not be generated (default is false)
  54862. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54863. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54864. */
  54865. constructor(
  54866. /**
  54867. * Defines the name of the task
  54868. */
  54869. name: string,
  54870. /**
  54871. * Defines the location of the file to load
  54872. */
  54873. url: string,
  54874. /**
  54875. * Defines if mipmap should not be generated (default is false)
  54876. */
  54877. noMipmap?: boolean | undefined,
  54878. /**
  54879. * Defines if texture must be inverted on Y axis (default is false)
  54880. */
  54881. invertY?: boolean | undefined,
  54882. /**
  54883. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54884. */
  54885. samplingMode?: number);
  54886. /**
  54887. * Execute the current task
  54888. * @param scene defines the scene where you want your assets to be loaded
  54889. * @param onSuccess is a callback called when the task is successfully executed
  54890. * @param onError is a callback called if an error occurs
  54891. */
  54892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54893. }
  54894. /**
  54895. * Define a task used by AssetsManager to load cube textures
  54896. */
  54897. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54898. /**
  54899. * Defines the name of the task
  54900. */
  54901. name: string;
  54902. /**
  54903. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54904. */
  54905. url: string;
  54906. /**
  54907. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54908. */
  54909. extensions?: string[] | undefined;
  54910. /**
  54911. * Defines if mipmaps should not be generated (default is false)
  54912. */
  54913. noMipmap?: boolean | undefined;
  54914. /**
  54915. * Defines the explicit list of files (undefined by default)
  54916. */
  54917. files?: string[] | undefined;
  54918. /**
  54919. * Gets the loaded texture
  54920. */
  54921. texture: CubeTexture;
  54922. /**
  54923. * Callback called when the task is successful
  54924. */
  54925. onSuccess: (task: CubeTextureAssetTask) => void;
  54926. /**
  54927. * Callback called when the task is successful
  54928. */
  54929. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54930. /**
  54931. * Creates a new CubeTextureAssetTask
  54932. * @param name defines the name of the task
  54933. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54934. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54935. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54936. * @param files defines the explicit list of files (undefined by default)
  54937. */
  54938. constructor(
  54939. /**
  54940. * Defines the name of the task
  54941. */
  54942. name: string,
  54943. /**
  54944. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54945. */
  54946. url: string,
  54947. /**
  54948. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54949. */
  54950. extensions?: string[] | undefined,
  54951. /**
  54952. * Defines if mipmaps should not be generated (default is false)
  54953. */
  54954. noMipmap?: boolean | undefined,
  54955. /**
  54956. * Defines the explicit list of files (undefined by default)
  54957. */
  54958. files?: string[] | undefined);
  54959. /**
  54960. * Execute the current task
  54961. * @param scene defines the scene where you want your assets to be loaded
  54962. * @param onSuccess is a callback called when the task is successfully executed
  54963. * @param onError is a callback called if an error occurs
  54964. */
  54965. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54966. }
  54967. /**
  54968. * Define a task used by AssetsManager to load HDR cube textures
  54969. */
  54970. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54971. /**
  54972. * Defines the name of the task
  54973. */
  54974. name: string;
  54975. /**
  54976. * Defines the location of the file to load
  54977. */
  54978. url: string;
  54979. /**
  54980. * Defines the desired size (the more it increases the longer the generation will be)
  54981. */
  54982. size: number;
  54983. /**
  54984. * Defines if mipmaps should not be generated (default is false)
  54985. */
  54986. noMipmap: boolean;
  54987. /**
  54988. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54989. */
  54990. generateHarmonics: boolean;
  54991. /**
  54992. * 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)
  54993. */
  54994. gammaSpace: boolean;
  54995. /**
  54996. * Internal Use Only
  54997. */
  54998. reserved: boolean;
  54999. /**
  55000. * Gets the loaded texture
  55001. */
  55002. texture: HDRCubeTexture;
  55003. /**
  55004. * Callback called when the task is successful
  55005. */
  55006. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55007. /**
  55008. * Callback called when the task is successful
  55009. */
  55010. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55011. /**
  55012. * Creates a new HDRCubeTextureAssetTask object
  55013. * @param name defines the name of the task
  55014. * @param url defines the location of the file to load
  55015. * @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.
  55016. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55017. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55018. * @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)
  55019. * @param reserved Internal use only
  55020. */
  55021. constructor(
  55022. /**
  55023. * Defines the name of the task
  55024. */
  55025. name: string,
  55026. /**
  55027. * Defines the location of the file to load
  55028. */
  55029. url: string,
  55030. /**
  55031. * Defines the desired size (the more it increases the longer the generation will be)
  55032. */
  55033. size: number,
  55034. /**
  55035. * Defines if mipmaps should not be generated (default is false)
  55036. */
  55037. noMipmap?: boolean,
  55038. /**
  55039. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55040. */
  55041. generateHarmonics?: boolean,
  55042. /**
  55043. * 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)
  55044. */
  55045. gammaSpace?: boolean,
  55046. /**
  55047. * Internal Use Only
  55048. */
  55049. reserved?: boolean);
  55050. /**
  55051. * Execute the current task
  55052. * @param scene defines the scene where you want your assets to be loaded
  55053. * @param onSuccess is a callback called when the task is successfully executed
  55054. * @param onError is a callback called if an error occurs
  55055. */
  55056. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55057. }
  55058. /**
  55059. * Define a task used by AssetsManager to load Equirectangular cube textures
  55060. */
  55061. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55062. /**
  55063. * Defines the name of the task
  55064. */
  55065. name: string;
  55066. /**
  55067. * Defines the location of the file to load
  55068. */
  55069. url: string;
  55070. /**
  55071. * Defines the desired size (the more it increases the longer the generation will be)
  55072. */
  55073. size: number;
  55074. /**
  55075. * Defines if mipmaps should not be generated (default is false)
  55076. */
  55077. noMipmap: boolean;
  55078. /**
  55079. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55080. * but the standard material would require them in Gamma space) (default is true)
  55081. */
  55082. gammaSpace: boolean;
  55083. /**
  55084. * Gets the loaded texture
  55085. */
  55086. texture: EquiRectangularCubeTexture;
  55087. /**
  55088. * Callback called when the task is successful
  55089. */
  55090. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55091. /**
  55092. * Callback called when the task is successful
  55093. */
  55094. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55095. /**
  55096. * Creates a new EquiRectangularCubeTextureAssetTask object
  55097. * @param name defines the name of the task
  55098. * @param url defines the location of the file to load
  55099. * @param size defines the desired size (the more it increases the longer the generation will be)
  55100. * If the size is omitted this implies you are using a preprocessed cubemap.
  55101. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55102. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55103. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55104. * (default is true)
  55105. */
  55106. constructor(
  55107. /**
  55108. * Defines the name of the task
  55109. */
  55110. name: string,
  55111. /**
  55112. * Defines the location of the file to load
  55113. */
  55114. url: string,
  55115. /**
  55116. * Defines the desired size (the more it increases the longer the generation will be)
  55117. */
  55118. size: number,
  55119. /**
  55120. * Defines if mipmaps should not be generated (default is false)
  55121. */
  55122. noMipmap?: boolean,
  55123. /**
  55124. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55125. * but the standard material would require them in Gamma space) (default is true)
  55126. */
  55127. gammaSpace?: boolean);
  55128. /**
  55129. * Execute the current task
  55130. * @param scene defines the scene where you want your assets to be loaded
  55131. * @param onSuccess is a callback called when the task is successfully executed
  55132. * @param onError is a callback called if an error occurs
  55133. */
  55134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55135. }
  55136. /**
  55137. * This class can be used to easily import assets into a scene
  55138. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55139. */
  55140. export class AssetsManager {
  55141. private _scene;
  55142. private _isLoading;
  55143. protected _tasks: AbstractAssetTask[];
  55144. protected _waitingTasksCount: number;
  55145. protected _totalTasksCount: number;
  55146. /**
  55147. * Callback called when all tasks are processed
  55148. */
  55149. onFinish: (tasks: AbstractAssetTask[]) => void;
  55150. /**
  55151. * Callback called when a task is successful
  55152. */
  55153. onTaskSuccess: (task: AbstractAssetTask) => void;
  55154. /**
  55155. * Callback called when a task had an error
  55156. */
  55157. onTaskError: (task: AbstractAssetTask) => void;
  55158. /**
  55159. * Callback called when a task is done (whatever the result is)
  55160. */
  55161. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55162. /**
  55163. * Observable called when all tasks are processed
  55164. */
  55165. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55166. /**
  55167. * Observable called when a task had an error
  55168. */
  55169. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55170. /**
  55171. * Observable called when all tasks were executed
  55172. */
  55173. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55174. /**
  55175. * Observable called when a task is done (whatever the result is)
  55176. */
  55177. onProgressObservable: Observable<IAssetsProgressEvent>;
  55178. /**
  55179. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55180. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55181. */
  55182. useDefaultLoadingScreen: boolean;
  55183. /**
  55184. * Creates a new AssetsManager
  55185. * @param scene defines the scene to work on
  55186. */
  55187. constructor(scene: Scene);
  55188. /**
  55189. * Add a MeshAssetTask to the list of active tasks
  55190. * @param taskName defines the name of the new task
  55191. * @param meshesNames defines the name of meshes to load
  55192. * @param rootUrl defines the root url to use to locate files
  55193. * @param sceneFilename defines the filename of the scene file
  55194. * @returns a new MeshAssetTask object
  55195. */
  55196. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55197. /**
  55198. * Add a TextFileAssetTask to the list of active tasks
  55199. * @param taskName defines the name of the new task
  55200. * @param url defines the url of the file to load
  55201. * @returns a new TextFileAssetTask object
  55202. */
  55203. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55204. /**
  55205. * Add a BinaryFileAssetTask to the list of active tasks
  55206. * @param taskName defines the name of the new task
  55207. * @param url defines the url of the file to load
  55208. * @returns a new BinaryFileAssetTask object
  55209. */
  55210. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55211. /**
  55212. * Add a ImageAssetTask to the list of active tasks
  55213. * @param taskName defines the name of the new task
  55214. * @param url defines the url of the file to load
  55215. * @returns a new ImageAssetTask object
  55216. */
  55217. addImageTask(taskName: string, url: string): ImageAssetTask;
  55218. /**
  55219. * Add a TextureAssetTask to the list of active tasks
  55220. * @param taskName defines the name of the new task
  55221. * @param url defines the url of the file to load
  55222. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55223. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55224. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55225. * @returns a new TextureAssetTask object
  55226. */
  55227. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55228. /**
  55229. * Add a CubeTextureAssetTask to the list of active tasks
  55230. * @param taskName defines the name of the new task
  55231. * @param url defines the url of the file to load
  55232. * @param extensions defines the extension to use to load the cube map (can be null)
  55233. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55234. * @param files defines the list of files to load (can be null)
  55235. * @returns a new CubeTextureAssetTask object
  55236. */
  55237. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55238. /**
  55239. *
  55240. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55241. * @param taskName defines the name of the new task
  55242. * @param url defines the url of the file to load
  55243. * @param size defines the size you want for the cubemap (can be null)
  55244. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55245. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55246. * @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)
  55247. * @param reserved Internal use only
  55248. * @returns a new HDRCubeTextureAssetTask object
  55249. */
  55250. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55251. /**
  55252. *
  55253. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  55254. * @param taskName defines the name of the new task
  55255. * @param url defines the url of the file to load
  55256. * @param size defines the size you want for the cubemap (can be null)
  55257. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55258. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55259. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55260. * @returns a new EquiRectangularCubeTextureAssetTask object
  55261. */
  55262. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55263. /**
  55264. * Remove a task from the assets manager.
  55265. * @param task the task to remove
  55266. */
  55267. removeTask(task: AbstractAssetTask): void;
  55268. private _decreaseWaitingTasksCount;
  55269. private _runTask;
  55270. /**
  55271. * Reset the AssetsManager and remove all tasks
  55272. * @return the current instance of the AssetsManager
  55273. */
  55274. reset(): AssetsManager;
  55275. /**
  55276. * Start the loading process
  55277. * @return the current instance of the AssetsManager
  55278. */
  55279. load(): AssetsManager;
  55280. /**
  55281. * Start the loading process as an async operation
  55282. * @return a promise returning the list of failed tasks
  55283. */
  55284. loadAsync(): Promise<void>;
  55285. }
  55286. }
  55287. declare module BABYLON {
  55288. /**
  55289. * Wrapper class for promise with external resolve and reject.
  55290. */
  55291. export class Deferred<T> {
  55292. /**
  55293. * The promise associated with this deferred object.
  55294. */
  55295. readonly promise: Promise<T>;
  55296. private _resolve;
  55297. private _reject;
  55298. /**
  55299. * The resolve method of the promise associated with this deferred object.
  55300. */
  55301. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55302. /**
  55303. * The reject method of the promise associated with this deferred object.
  55304. */
  55305. readonly reject: (reason?: any) => void;
  55306. /**
  55307. * Constructor for this deferred object.
  55308. */
  55309. constructor();
  55310. }
  55311. }
  55312. declare module BABYLON {
  55313. /**
  55314. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55315. */
  55316. export class MeshExploder {
  55317. private _centerMesh;
  55318. private _meshes;
  55319. private _meshesOrigins;
  55320. private _toCenterVectors;
  55321. private _scaledDirection;
  55322. private _newPosition;
  55323. private _centerPosition;
  55324. /**
  55325. * Explodes meshes from a center mesh.
  55326. * @param meshes The meshes to explode.
  55327. * @param centerMesh The mesh to be center of explosion.
  55328. */
  55329. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55330. private _setCenterMesh;
  55331. /**
  55332. * Get class name
  55333. * @returns "MeshExploder"
  55334. */
  55335. getClassName(): string;
  55336. /**
  55337. * "Exploded meshes"
  55338. * @returns Array of meshes with the centerMesh at index 0.
  55339. */
  55340. getMeshes(): Array<Mesh>;
  55341. /**
  55342. * Explodes meshes giving a specific direction
  55343. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55344. */
  55345. explode(direction?: number): void;
  55346. }
  55347. }
  55348. declare module BABYLON {
  55349. /**
  55350. * Class used to help managing file picking and drag'n'drop
  55351. */
  55352. export class FilesInput {
  55353. /**
  55354. * List of files ready to be loaded
  55355. */
  55356. static readonly FilesToLoad: {
  55357. [key: string]: File;
  55358. };
  55359. /**
  55360. * Callback called when a file is processed
  55361. */
  55362. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55363. private _engine;
  55364. private _currentScene;
  55365. private _sceneLoadedCallback;
  55366. private _progressCallback;
  55367. private _additionalRenderLoopLogicCallback;
  55368. private _textureLoadingCallback;
  55369. private _startingProcessingFilesCallback;
  55370. private _onReloadCallback;
  55371. private _errorCallback;
  55372. private _elementToMonitor;
  55373. private _sceneFileToLoad;
  55374. private _filesToLoad;
  55375. /**
  55376. * Creates a new FilesInput
  55377. * @param engine defines the rendering engine
  55378. * @param scene defines the hosting scene
  55379. * @param sceneLoadedCallback callback called when scene is loaded
  55380. * @param progressCallback callback called to track progress
  55381. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55382. * @param textureLoadingCallback callback called when a texture is loading
  55383. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55384. * @param onReloadCallback callback called when a reload is requested
  55385. * @param errorCallback callback call if an error occurs
  55386. */
  55387. 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);
  55388. private _dragEnterHandler;
  55389. private _dragOverHandler;
  55390. private _dropHandler;
  55391. /**
  55392. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55393. * @param elementToMonitor defines the DOM element to track
  55394. */
  55395. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55396. /**
  55397. * Release all associated resources
  55398. */
  55399. dispose(): void;
  55400. private renderFunction;
  55401. private drag;
  55402. private drop;
  55403. private _traverseFolder;
  55404. private _processFiles;
  55405. /**
  55406. * Load files from a drop event
  55407. * @param event defines the drop event to use as source
  55408. */
  55409. loadFiles(event: any): void;
  55410. private _processReload;
  55411. /**
  55412. * Reload the current scene from the loaded files
  55413. */
  55414. reload(): void;
  55415. }
  55416. }
  55417. declare module BABYLON {
  55418. /**
  55419. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55421. */
  55422. export class SceneOptimization {
  55423. /**
  55424. * Defines the priority of this optimization (0 by default which means first in the list)
  55425. */
  55426. priority: number;
  55427. /**
  55428. * Gets a string describing the action executed by the current optimization
  55429. * @returns description string
  55430. */
  55431. getDescription(): string;
  55432. /**
  55433. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55434. * @param scene defines the current scene where to apply this optimization
  55435. * @param optimizer defines the current optimizer
  55436. * @returns true if everything that can be done was applied
  55437. */
  55438. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55439. /**
  55440. * Creates the SceneOptimization object
  55441. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55442. * @param desc defines the description associated with the optimization
  55443. */
  55444. constructor(
  55445. /**
  55446. * Defines the priority of this optimization (0 by default which means first in the list)
  55447. */
  55448. priority?: number);
  55449. }
  55450. /**
  55451. * Defines an optimization used to reduce the size of render target textures
  55452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55453. */
  55454. export class TextureOptimization extends SceneOptimization {
  55455. /**
  55456. * Defines the priority of this optimization (0 by default which means first in the list)
  55457. */
  55458. priority: number;
  55459. /**
  55460. * 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
  55461. */
  55462. maximumSize: number;
  55463. /**
  55464. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55465. */
  55466. step: number;
  55467. /**
  55468. * Gets a string describing the action executed by the current optimization
  55469. * @returns description string
  55470. */
  55471. getDescription(): string;
  55472. /**
  55473. * Creates the TextureOptimization object
  55474. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55475. * @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
  55476. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55477. */
  55478. constructor(
  55479. /**
  55480. * Defines the priority of this optimization (0 by default which means first in the list)
  55481. */
  55482. priority?: number,
  55483. /**
  55484. * 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
  55485. */
  55486. maximumSize?: number,
  55487. /**
  55488. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55489. */
  55490. step?: number);
  55491. /**
  55492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55493. * @param scene defines the current scene where to apply this optimization
  55494. * @param optimizer defines the current optimizer
  55495. * @returns true if everything that can be done was applied
  55496. */
  55497. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55498. }
  55499. /**
  55500. * Defines an optimization used to increase or decrease the rendering resolution
  55501. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55502. */
  55503. export class HardwareScalingOptimization extends SceneOptimization {
  55504. /**
  55505. * Defines the priority of this optimization (0 by default which means first in the list)
  55506. */
  55507. priority: number;
  55508. /**
  55509. * Defines the maximum scale to use (2 by default)
  55510. */
  55511. maximumScale: number;
  55512. /**
  55513. * Defines the step to use between two passes (0.5 by default)
  55514. */
  55515. step: number;
  55516. private _currentScale;
  55517. private _directionOffset;
  55518. /**
  55519. * Gets a string describing the action executed by the current optimization
  55520. * @return description string
  55521. */
  55522. getDescription(): string;
  55523. /**
  55524. * Creates the HardwareScalingOptimization object
  55525. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55526. * @param maximumScale defines the maximum scale to use (2 by default)
  55527. * @param step defines the step to use between two passes (0.5 by default)
  55528. */
  55529. constructor(
  55530. /**
  55531. * Defines the priority of this optimization (0 by default which means first in the list)
  55532. */
  55533. priority?: number,
  55534. /**
  55535. * Defines the maximum scale to use (2 by default)
  55536. */
  55537. maximumScale?: number,
  55538. /**
  55539. * Defines the step to use between two passes (0.5 by default)
  55540. */
  55541. step?: number);
  55542. /**
  55543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55544. * @param scene defines the current scene where to apply this optimization
  55545. * @param optimizer defines the current optimizer
  55546. * @returns true if everything that can be done was applied
  55547. */
  55548. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55549. }
  55550. /**
  55551. * Defines an optimization used to remove shadows
  55552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55553. */
  55554. export class ShadowsOptimization extends SceneOptimization {
  55555. /**
  55556. * Gets a string describing the action executed by the current optimization
  55557. * @return description string
  55558. */
  55559. getDescription(): string;
  55560. /**
  55561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55562. * @param scene defines the current scene where to apply this optimization
  55563. * @param optimizer defines the current optimizer
  55564. * @returns true if everything that can be done was applied
  55565. */
  55566. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55567. }
  55568. /**
  55569. * Defines an optimization used to turn post-processes off
  55570. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55571. */
  55572. export class PostProcessesOptimization extends SceneOptimization {
  55573. /**
  55574. * Gets a string describing the action executed by the current optimization
  55575. * @return description string
  55576. */
  55577. getDescription(): string;
  55578. /**
  55579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55580. * @param scene defines the current scene where to apply this optimization
  55581. * @param optimizer defines the current optimizer
  55582. * @returns true if everything that can be done was applied
  55583. */
  55584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55585. }
  55586. /**
  55587. * Defines an optimization used to turn lens flares off
  55588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55589. */
  55590. export class LensFlaresOptimization extends SceneOptimization {
  55591. /**
  55592. * Gets a string describing the action executed by the current optimization
  55593. * @return description string
  55594. */
  55595. getDescription(): string;
  55596. /**
  55597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55598. * @param scene defines the current scene where to apply this optimization
  55599. * @param optimizer defines the current optimizer
  55600. * @returns true if everything that can be done was applied
  55601. */
  55602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55603. }
  55604. /**
  55605. * Defines an optimization based on user defined callback.
  55606. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55607. */
  55608. export class CustomOptimization extends SceneOptimization {
  55609. /**
  55610. * Callback called to apply the custom optimization.
  55611. */
  55612. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55613. /**
  55614. * Callback called to get custom description
  55615. */
  55616. onGetDescription: () => string;
  55617. /**
  55618. * Gets a string describing the action executed by the current optimization
  55619. * @returns description string
  55620. */
  55621. getDescription(): string;
  55622. /**
  55623. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55624. * @param scene defines the current scene where to apply this optimization
  55625. * @param optimizer defines the current optimizer
  55626. * @returns true if everything that can be done was applied
  55627. */
  55628. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55629. }
  55630. /**
  55631. * Defines an optimization used to turn particles off
  55632. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55633. */
  55634. export class ParticlesOptimization extends SceneOptimization {
  55635. /**
  55636. * Gets a string describing the action executed by the current optimization
  55637. * @return description string
  55638. */
  55639. getDescription(): string;
  55640. /**
  55641. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55642. * @param scene defines the current scene where to apply this optimization
  55643. * @param optimizer defines the current optimizer
  55644. * @returns true if everything that can be done was applied
  55645. */
  55646. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55647. }
  55648. /**
  55649. * Defines an optimization used to turn render targets off
  55650. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55651. */
  55652. export class RenderTargetsOptimization extends SceneOptimization {
  55653. /**
  55654. * Gets a string describing the action executed by the current optimization
  55655. * @return description string
  55656. */
  55657. getDescription(): string;
  55658. /**
  55659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55660. * @param scene defines the current scene where to apply this optimization
  55661. * @param optimizer defines the current optimizer
  55662. * @returns true if everything that can be done was applied
  55663. */
  55664. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55665. }
  55666. /**
  55667. * Defines an optimization used to merge meshes with compatible materials
  55668. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55669. */
  55670. export class MergeMeshesOptimization extends SceneOptimization {
  55671. private static _UpdateSelectionTree;
  55672. /**
  55673. * Gets or sets a boolean which defines if optimization octree has to be updated
  55674. */
  55675. /**
  55676. * Gets or sets a boolean which defines if optimization octree has to be updated
  55677. */
  55678. static UpdateSelectionTree: boolean;
  55679. /**
  55680. * Gets a string describing the action executed by the current optimization
  55681. * @return description string
  55682. */
  55683. getDescription(): string;
  55684. private _canBeMerged;
  55685. /**
  55686. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55687. * @param scene defines the current scene where to apply this optimization
  55688. * @param optimizer defines the current optimizer
  55689. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55690. * @returns true if everything that can be done was applied
  55691. */
  55692. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55693. }
  55694. /**
  55695. * Defines a list of options used by SceneOptimizer
  55696. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55697. */
  55698. export class SceneOptimizerOptions {
  55699. /**
  55700. * Defines the target frame rate to reach (60 by default)
  55701. */
  55702. targetFrameRate: number;
  55703. /**
  55704. * Defines the interval between two checkes (2000ms by default)
  55705. */
  55706. trackerDuration: number;
  55707. /**
  55708. * Gets the list of optimizations to apply
  55709. */
  55710. optimizations: SceneOptimization[];
  55711. /**
  55712. * Creates a new list of options used by SceneOptimizer
  55713. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55714. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55715. */
  55716. constructor(
  55717. /**
  55718. * Defines the target frame rate to reach (60 by default)
  55719. */
  55720. targetFrameRate?: number,
  55721. /**
  55722. * Defines the interval between two checkes (2000ms by default)
  55723. */
  55724. trackerDuration?: number);
  55725. /**
  55726. * Add a new optimization
  55727. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55728. * @returns the current SceneOptimizerOptions
  55729. */
  55730. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55731. /**
  55732. * Add a new custom optimization
  55733. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55734. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55735. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55736. * @returns the current SceneOptimizerOptions
  55737. */
  55738. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55739. /**
  55740. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55741. * @param targetFrameRate defines the target frame rate (60 by default)
  55742. * @returns a SceneOptimizerOptions object
  55743. */
  55744. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55745. /**
  55746. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55747. * @param targetFrameRate defines the target frame rate (60 by default)
  55748. * @returns a SceneOptimizerOptions object
  55749. */
  55750. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55751. /**
  55752. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55753. * @param targetFrameRate defines the target frame rate (60 by default)
  55754. * @returns a SceneOptimizerOptions object
  55755. */
  55756. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55757. }
  55758. /**
  55759. * Class used to run optimizations in order to reach a target frame rate
  55760. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55761. */
  55762. export class SceneOptimizer implements IDisposable {
  55763. private _isRunning;
  55764. private _options;
  55765. private _scene;
  55766. private _currentPriorityLevel;
  55767. private _targetFrameRate;
  55768. private _trackerDuration;
  55769. private _currentFrameRate;
  55770. private _sceneDisposeObserver;
  55771. private _improvementMode;
  55772. /**
  55773. * Defines an observable called when the optimizer reaches the target frame rate
  55774. */
  55775. onSuccessObservable: Observable<SceneOptimizer>;
  55776. /**
  55777. * Defines an observable called when the optimizer enables an optimization
  55778. */
  55779. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55780. /**
  55781. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55782. */
  55783. onFailureObservable: Observable<SceneOptimizer>;
  55784. /**
  55785. * Gets a boolean indicating if the optimizer is in improvement mode
  55786. */
  55787. readonly isInImprovementMode: boolean;
  55788. /**
  55789. * Gets the current priority level (0 at start)
  55790. */
  55791. readonly currentPriorityLevel: number;
  55792. /**
  55793. * Gets the current frame rate checked by the SceneOptimizer
  55794. */
  55795. readonly currentFrameRate: number;
  55796. /**
  55797. * Gets or sets the current target frame rate (60 by default)
  55798. */
  55799. /**
  55800. * Gets or sets the current target frame rate (60 by default)
  55801. */
  55802. targetFrameRate: number;
  55803. /**
  55804. * Gets or sets the current interval between two checks (every 2000ms by default)
  55805. */
  55806. /**
  55807. * Gets or sets the current interval between two checks (every 2000ms by default)
  55808. */
  55809. trackerDuration: number;
  55810. /**
  55811. * Gets the list of active optimizations
  55812. */
  55813. readonly optimizations: SceneOptimization[];
  55814. /**
  55815. * Creates a new SceneOptimizer
  55816. * @param scene defines the scene to work on
  55817. * @param options defines the options to use with the SceneOptimizer
  55818. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55819. * @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)
  55820. */
  55821. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55822. /**
  55823. * Stops the current optimizer
  55824. */
  55825. stop(): void;
  55826. /**
  55827. * Reset the optimizer to initial step (current priority level = 0)
  55828. */
  55829. reset(): void;
  55830. /**
  55831. * Start the optimizer. By default it will try to reach a specific framerate
  55832. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55833. */
  55834. start(): void;
  55835. private _checkCurrentState;
  55836. /**
  55837. * Release all resources
  55838. */
  55839. dispose(): void;
  55840. /**
  55841. * Helper function to create a SceneOptimizer with one single line of code
  55842. * @param scene defines the scene to work on
  55843. * @param options defines the options to use with the SceneOptimizer
  55844. * @param onSuccess defines a callback to call on success
  55845. * @param onFailure defines a callback to call on failure
  55846. * @returns the new SceneOptimizer object
  55847. */
  55848. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55849. }
  55850. }
  55851. declare module BABYLON {
  55852. /**
  55853. * Class used to serialize a scene into a string
  55854. */
  55855. export class SceneSerializer {
  55856. /**
  55857. * Clear cache used by a previous serialization
  55858. */
  55859. static ClearCache(): void;
  55860. /**
  55861. * Serialize a scene into a JSON compatible object
  55862. * @param scene defines the scene to serialize
  55863. * @returns a JSON compatible object
  55864. */
  55865. static Serialize(scene: Scene): any;
  55866. /**
  55867. * Serialize a mesh into a JSON compatible object
  55868. * @param toSerialize defines the mesh to serialize
  55869. * @param withParents defines if parents must be serialized as well
  55870. * @param withChildren defines if children must be serialized as well
  55871. * @returns a JSON compatible object
  55872. */
  55873. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55874. }
  55875. }
  55876. declare module BABYLON {
  55877. /**
  55878. * Class used to host texture specific utilities
  55879. */
  55880. export class TextureTools {
  55881. /**
  55882. * Uses the GPU to create a copy texture rescaled at a given size
  55883. * @param texture Texture to copy from
  55884. * @param width defines the desired width
  55885. * @param height defines the desired height
  55886. * @param useBilinearMode defines if bilinear mode has to be used
  55887. * @return the generated texture
  55888. */
  55889. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55890. }
  55891. }
  55892. declare module BABYLON {
  55893. /**
  55894. * This represents the different options avilable for the video capture.
  55895. */
  55896. export interface VideoRecorderOptions {
  55897. /** Defines the mime type of the video */
  55898. mimeType: string;
  55899. /** Defines the video the video should be recorded at */
  55900. fps: number;
  55901. /** Defines the chunk size for the recording data */
  55902. recordChunckSize: number;
  55903. /** The audio tracks to attach to the record */
  55904. audioTracks?: MediaStreamTrack[];
  55905. }
  55906. /**
  55907. * This can helps recording videos from BabylonJS.
  55908. * This is based on the available WebRTC functionalities of the browser.
  55909. *
  55910. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55911. */
  55912. export class VideoRecorder {
  55913. private static readonly _defaultOptions;
  55914. /**
  55915. * Returns wehther or not the VideoRecorder is available in your browser.
  55916. * @param engine Defines the Babylon Engine to check the support for
  55917. * @returns true if supported otherwise false
  55918. */
  55919. static IsSupported(engine: Engine): boolean;
  55920. private readonly _options;
  55921. private _canvas;
  55922. private _mediaRecorder;
  55923. private _recordedChunks;
  55924. private _fileName;
  55925. private _resolve;
  55926. private _reject;
  55927. /**
  55928. * True wether a recording is already in progress.
  55929. */
  55930. readonly isRecording: boolean;
  55931. /**
  55932. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55933. * a video file.
  55934. * @param engine Defines the BabylonJS Engine you wish to record
  55935. * @param options Defines options that can be used to customized the capture
  55936. */
  55937. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55938. /**
  55939. * Stops the current recording before the default capture timeout passed in the startRecording
  55940. * functions.
  55941. */
  55942. stopRecording(): void;
  55943. /**
  55944. * Starts recording the canvas for a max duration specified in parameters.
  55945. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  55946. * @param maxDuration Defines the maximum recording time in seconds.
  55947. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55948. * @return a promise callback at the end of the recording with the video data in Blob.
  55949. */
  55950. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55951. /**
  55952. * Releases internal resources used during the recording.
  55953. */
  55954. dispose(): void;
  55955. private _handleDataAvailable;
  55956. private _handleError;
  55957. private _handleStop;
  55958. }
  55959. }
  55960. declare module BABYLON {
  55961. /**
  55962. * Helper class to push actions to a pool of workers.
  55963. */
  55964. export class WorkerPool implements IDisposable {
  55965. private _workerInfos;
  55966. private _pendingActions;
  55967. /**
  55968. * Constructor
  55969. * @param workers Array of workers to use for actions
  55970. */
  55971. constructor(workers: Array<Worker>);
  55972. /**
  55973. * Terminates all workers and clears any pending actions.
  55974. */
  55975. dispose(): void;
  55976. /**
  55977. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55978. * pended until a worker has completed its action.
  55979. * @param action The action to perform. Call onComplete when the action is complete.
  55980. */
  55981. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55982. private _execute;
  55983. }
  55984. }
  55985. declare module BABYLON {
  55986. /**
  55987. * Class containing a set of static utilities functions for screenshots
  55988. */
  55989. export class ScreenshotTools {
  55990. /**
  55991. * Captures a screenshot of the current rendering
  55992. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55993. * @param engine defines the rendering engine
  55994. * @param camera defines the source camera
  55995. * @param size This parameter can be set to a single number or to an object with the
  55996. * following (optional) properties: precision, width, height. If a single number is passed,
  55997. * it will be used for both width and height. If an object is passed, the screenshot size
  55998. * will be derived from the parameters. The precision property is a multiplier allowing
  55999. * rendering at a higher or lower resolution
  56000. * @param successCallback defines the callback receives a single parameter which contains the
  56001. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56002. * src parameter of an <img> to display it
  56003. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56004. * Check your browser for supported MIME types
  56005. */
  56006. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56007. /**
  56008. * Generates an image screenshot from the specified camera.
  56009. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56010. * @param engine The engine to use for rendering
  56011. * @param camera The camera to use for rendering
  56012. * @param size This parameter can be set to a single number or to an object with the
  56013. * following (optional) properties: precision, width, height. If a single number is passed,
  56014. * it will be used for both width and height. If an object is passed, the screenshot size
  56015. * will be derived from the parameters. The precision property is a multiplier allowing
  56016. * rendering at a higher or lower resolution
  56017. * @param successCallback The callback receives a single parameter which contains the
  56018. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56019. * src parameter of an <img> to display it
  56020. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56021. * Check your browser for supported MIME types
  56022. * @param samples Texture samples (default: 1)
  56023. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56024. * @param fileName A name for for the downloaded file.
  56025. */
  56026. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56027. }
  56028. }
  56029. declare module BABYLON {
  56030. /**
  56031. * A cursor which tracks a point on a path
  56032. */
  56033. export class PathCursor {
  56034. private path;
  56035. /**
  56036. * Stores path cursor callbacks for when an onchange event is triggered
  56037. */
  56038. private _onchange;
  56039. /**
  56040. * The value of the path cursor
  56041. */
  56042. value: number;
  56043. /**
  56044. * The animation array of the path cursor
  56045. */
  56046. animations: Animation[];
  56047. /**
  56048. * Initializes the path cursor
  56049. * @param path The path to track
  56050. */
  56051. constructor(path: Path2);
  56052. /**
  56053. * Gets the cursor point on the path
  56054. * @returns A point on the path cursor at the cursor location
  56055. */
  56056. getPoint(): Vector3;
  56057. /**
  56058. * Moves the cursor ahead by the step amount
  56059. * @param step The amount to move the cursor forward
  56060. * @returns This path cursor
  56061. */
  56062. moveAhead(step?: number): PathCursor;
  56063. /**
  56064. * Moves the cursor behind by the step amount
  56065. * @param step The amount to move the cursor back
  56066. * @returns This path cursor
  56067. */
  56068. moveBack(step?: number): PathCursor;
  56069. /**
  56070. * Moves the cursor by the step amount
  56071. * If the step amount is greater than one, an exception is thrown
  56072. * @param step The amount to move the cursor
  56073. * @returns This path cursor
  56074. */
  56075. move(step: number): PathCursor;
  56076. /**
  56077. * Ensures that the value is limited between zero and one
  56078. * @returns This path cursor
  56079. */
  56080. private ensureLimits;
  56081. /**
  56082. * Runs onchange callbacks on change (used by the animation engine)
  56083. * @returns This path cursor
  56084. */
  56085. private raiseOnChange;
  56086. /**
  56087. * Executes a function on change
  56088. * @param f A path cursor onchange callback
  56089. * @returns This path cursor
  56090. */
  56091. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56092. }
  56093. }
  56094. declare module BABYLON {
  56095. /** @hidden */
  56096. export var blurPixelShader: {
  56097. name: string;
  56098. shader: string;
  56099. };
  56100. }
  56101. declare module BABYLON {
  56102. /** @hidden */
  56103. export var bones300Declaration: {
  56104. name: string;
  56105. shader: string;
  56106. };
  56107. }
  56108. declare module BABYLON {
  56109. /** @hidden */
  56110. export var instances300Declaration: {
  56111. name: string;
  56112. shader: string;
  56113. };
  56114. }
  56115. declare module BABYLON {
  56116. /** @hidden */
  56117. export var pointCloudVertexDeclaration: {
  56118. name: string;
  56119. shader: string;
  56120. };
  56121. }
  56122. // Mixins
  56123. interface Window {
  56124. mozIndexedDB: IDBFactory;
  56125. webkitIndexedDB: IDBFactory;
  56126. msIndexedDB: IDBFactory;
  56127. webkitURL: typeof URL;
  56128. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56129. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56130. WebGLRenderingContext: WebGLRenderingContext;
  56131. MSGesture: MSGesture;
  56132. CANNON: any;
  56133. AudioContext: AudioContext;
  56134. webkitAudioContext: AudioContext;
  56135. PointerEvent: any;
  56136. Math: Math;
  56137. Uint8Array: Uint8ArrayConstructor;
  56138. Float32Array: Float32ArrayConstructor;
  56139. mozURL: typeof URL;
  56140. msURL: typeof URL;
  56141. VRFrameData: any; // WebVR, from specs 1.1
  56142. DracoDecoderModule: any;
  56143. setImmediate(handler: (...args: any[]) => void): number;
  56144. }
  56145. interface HTMLCanvasElement {
  56146. requestPointerLock(): void;
  56147. msRequestPointerLock?(): void;
  56148. mozRequestPointerLock?(): void;
  56149. webkitRequestPointerLock?(): void;
  56150. /** Track wether a record is in progress */
  56151. isRecording: boolean;
  56152. /** Capture Stream method defined by some browsers */
  56153. captureStream(fps?: number): MediaStream;
  56154. }
  56155. interface CanvasRenderingContext2D {
  56156. msImageSmoothingEnabled: boolean;
  56157. }
  56158. interface MouseEvent {
  56159. mozMovementX: number;
  56160. mozMovementY: number;
  56161. webkitMovementX: number;
  56162. webkitMovementY: number;
  56163. msMovementX: number;
  56164. msMovementY: number;
  56165. }
  56166. interface Navigator {
  56167. mozGetVRDevices: (any: any) => any;
  56168. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56169. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56170. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56171. webkitGetGamepads(): Gamepad[];
  56172. msGetGamepads(): Gamepad[];
  56173. webkitGamepads(): Gamepad[];
  56174. }
  56175. interface HTMLVideoElement {
  56176. mozSrcObject: any;
  56177. }
  56178. interface Math {
  56179. fround(x: number): number;
  56180. imul(a: number, b: number): number;
  56181. }
  56182. interface WebGLProgram {
  56183. context?: WebGLRenderingContext;
  56184. vertexShader?: WebGLShader;
  56185. fragmentShader?: WebGLShader;
  56186. isParallelCompiled: boolean;
  56187. onCompiled?: () => void;
  56188. }
  56189. interface WebGLRenderingContext {
  56190. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56191. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56192. vertexAttribDivisor(index: number, divisor: number): void;
  56193. createVertexArray(): any;
  56194. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56195. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56196. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56197. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56198. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56199. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56200. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56201. // Queries
  56202. createQuery(): WebGLQuery;
  56203. deleteQuery(query: WebGLQuery): void;
  56204. beginQuery(target: number, query: WebGLQuery): void;
  56205. endQuery(target: number): void;
  56206. getQueryParameter(query: WebGLQuery, pname: number): any;
  56207. getQuery(target: number, pname: number): any;
  56208. MAX_SAMPLES: number;
  56209. RGBA8: number;
  56210. READ_FRAMEBUFFER: number;
  56211. DRAW_FRAMEBUFFER: number;
  56212. UNIFORM_BUFFER: number;
  56213. HALF_FLOAT_OES: number;
  56214. RGBA16F: number;
  56215. RGBA32F: number;
  56216. R32F: number;
  56217. RG32F: number;
  56218. RGB32F: number;
  56219. R16F: number;
  56220. RG16F: number;
  56221. RGB16F: number;
  56222. RED: number;
  56223. RG: number;
  56224. R8: number;
  56225. RG8: number;
  56226. UNSIGNED_INT_24_8: number;
  56227. DEPTH24_STENCIL8: number;
  56228. /* Multiple Render Targets */
  56229. drawBuffers(buffers: number[]): void;
  56230. readBuffer(src: number): void;
  56231. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56232. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56233. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56234. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56235. // Occlusion Query
  56236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56237. ANY_SAMPLES_PASSED: number;
  56238. QUERY_RESULT_AVAILABLE: number;
  56239. QUERY_RESULT: number;
  56240. }
  56241. interface WebGLBuffer {
  56242. references: number;
  56243. capacity: number;
  56244. is32Bits: boolean;
  56245. }
  56246. interface WebGLProgram {
  56247. transformFeedback?: WebGLTransformFeedback | null;
  56248. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56249. }
  56250. interface EXT_disjoint_timer_query {
  56251. QUERY_COUNTER_BITS_EXT: number;
  56252. TIME_ELAPSED_EXT: number;
  56253. TIMESTAMP_EXT: number;
  56254. GPU_DISJOINT_EXT: number;
  56255. QUERY_RESULT_EXT: number;
  56256. QUERY_RESULT_AVAILABLE_EXT: number;
  56257. queryCounterEXT(query: WebGLQuery, target: number): void;
  56258. createQueryEXT(): WebGLQuery;
  56259. beginQueryEXT(target: number, query: WebGLQuery): void;
  56260. endQueryEXT(target: number): void;
  56261. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56262. deleteQueryEXT(query: WebGLQuery): void;
  56263. }
  56264. interface WebGLUniformLocation {
  56265. _currentState: any;
  56266. }
  56267. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56268. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56269. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56270. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56271. interface WebGLRenderingContext {
  56272. readonly RASTERIZER_DISCARD: number;
  56273. readonly DEPTH_COMPONENT24: number;
  56274. readonly TEXTURE_3D: number;
  56275. readonly TEXTURE_2D_ARRAY: number;
  56276. readonly TEXTURE_COMPARE_FUNC: number;
  56277. readonly TEXTURE_COMPARE_MODE: number;
  56278. readonly COMPARE_REF_TO_TEXTURE: number;
  56279. readonly TEXTURE_WRAP_R: number;
  56280. readonly HALF_FLOAT: number;
  56281. readonly RGB8: number;
  56282. readonly RED_INTEGER: number;
  56283. readonly RG_INTEGER: number;
  56284. readonly RGB_INTEGER: number;
  56285. readonly RGBA_INTEGER: number;
  56286. readonly R8_SNORM: number;
  56287. readonly RG8_SNORM: number;
  56288. readonly RGB8_SNORM: number;
  56289. readonly RGBA8_SNORM: number;
  56290. readonly R8I: number;
  56291. readonly RG8I: number;
  56292. readonly RGB8I: number;
  56293. readonly RGBA8I: number;
  56294. readonly R8UI: number;
  56295. readonly RG8UI: number;
  56296. readonly RGB8UI: number;
  56297. readonly RGBA8UI: number;
  56298. readonly R16I: number;
  56299. readonly RG16I: number;
  56300. readonly RGB16I: number;
  56301. readonly RGBA16I: number;
  56302. readonly R16UI: number;
  56303. readonly RG16UI: number;
  56304. readonly RGB16UI: number;
  56305. readonly RGBA16UI: number;
  56306. readonly R32I: number;
  56307. readonly RG32I: number;
  56308. readonly RGB32I: number;
  56309. readonly RGBA32I: number;
  56310. readonly R32UI: number;
  56311. readonly RG32UI: number;
  56312. readonly RGB32UI: number;
  56313. readonly RGBA32UI: number;
  56314. readonly RGB10_A2UI: number;
  56315. readonly R11F_G11F_B10F: number;
  56316. readonly RGB9_E5: number;
  56317. readonly RGB10_A2: number;
  56318. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56319. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56320. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56321. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56322. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56323. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56324. 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;
  56325. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56326. readonly TRANSFORM_FEEDBACK: number;
  56327. readonly INTERLEAVED_ATTRIBS: number;
  56328. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56329. createTransformFeedback(): WebGLTransformFeedback;
  56330. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56331. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56332. beginTransformFeedback(primitiveMode: number): void;
  56333. endTransformFeedback(): void;
  56334. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56335. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56336. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56337. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56338. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56339. }
  56340. interface ImageBitmap {
  56341. readonly width: number;
  56342. readonly height: number;
  56343. close(): void;
  56344. }
  56345. interface WebGLQuery extends WebGLObject {
  56346. }
  56347. declare var WebGLQuery: {
  56348. prototype: WebGLQuery;
  56349. new(): WebGLQuery;
  56350. };
  56351. interface WebGLSampler extends WebGLObject {
  56352. }
  56353. declare var WebGLSampler: {
  56354. prototype: WebGLSampler;
  56355. new(): WebGLSampler;
  56356. };
  56357. interface WebGLSync extends WebGLObject {
  56358. }
  56359. declare var WebGLSync: {
  56360. prototype: WebGLSync;
  56361. new(): WebGLSync;
  56362. };
  56363. interface WebGLTransformFeedback extends WebGLObject {
  56364. }
  56365. declare var WebGLTransformFeedback: {
  56366. prototype: WebGLTransformFeedback;
  56367. new(): WebGLTransformFeedback;
  56368. };
  56369. interface WebGLVertexArrayObject extends WebGLObject {
  56370. }
  56371. declare var WebGLVertexArrayObject: {
  56372. prototype: WebGLVertexArrayObject;
  56373. new(): WebGLVertexArrayObject;
  56374. };
  56375. // Type definitions for WebVR API
  56376. // Project: https://w3c.github.io/webvr/
  56377. // Definitions by: six a <https://github.com/lostfictions>
  56378. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56379. interface VRDisplay extends EventTarget {
  56380. /**
  56381. * Dictionary of capabilities describing the VRDisplay.
  56382. */
  56383. readonly capabilities: VRDisplayCapabilities;
  56384. /**
  56385. * z-depth defining the far plane of the eye view frustum
  56386. * enables mapping of values in the render target depth
  56387. * attachment to scene coordinates. Initially set to 10000.0.
  56388. */
  56389. depthFar: number;
  56390. /**
  56391. * z-depth defining the near plane of the eye view frustum
  56392. * enables mapping of values in the render target depth
  56393. * attachment to scene coordinates. Initially set to 0.01.
  56394. */
  56395. depthNear: number;
  56396. /**
  56397. * An identifier for this distinct VRDisplay. Used as an
  56398. * association point in the Gamepad API.
  56399. */
  56400. readonly displayId: number;
  56401. /**
  56402. * A display name, a user-readable name identifying it.
  56403. */
  56404. readonly displayName: string;
  56405. readonly isConnected: boolean;
  56406. readonly isPresenting: boolean;
  56407. /**
  56408. * If this VRDisplay supports room-scale experiences, the optional
  56409. * stage attribute contains details on the room-scale parameters.
  56410. */
  56411. readonly stageParameters: VRStageParameters | null;
  56412. /**
  56413. * Passing the value returned by `requestAnimationFrame` to
  56414. * `cancelAnimationFrame` will unregister the callback.
  56415. * @param handle Define the hanle of the request to cancel
  56416. */
  56417. cancelAnimationFrame(handle: number): void;
  56418. /**
  56419. * Stops presenting to the VRDisplay.
  56420. * @returns a promise to know when it stopped
  56421. */
  56422. exitPresent(): Promise<void>;
  56423. /**
  56424. * Return the current VREyeParameters for the given eye.
  56425. * @param whichEye Define the eye we want the parameter for
  56426. * @returns the eye parameters
  56427. */
  56428. getEyeParameters(whichEye: string): VREyeParameters;
  56429. /**
  56430. * Populates the passed VRFrameData with the information required to render
  56431. * the current frame.
  56432. * @param frameData Define the data structure to populate
  56433. * @returns true if ok otherwise false
  56434. */
  56435. getFrameData(frameData: VRFrameData): boolean;
  56436. /**
  56437. * Get the layers currently being presented.
  56438. * @returns the list of VR layers
  56439. */
  56440. getLayers(): VRLayer[];
  56441. /**
  56442. * Return a VRPose containing the future predicted pose of the VRDisplay
  56443. * when the current frame will be presented. The value returned will not
  56444. * change until JavaScript has returned control to the browser.
  56445. *
  56446. * The VRPose will contain the position, orientation, velocity,
  56447. * and acceleration of each of these properties.
  56448. * @returns the pose object
  56449. */
  56450. getPose(): VRPose;
  56451. /**
  56452. * Return the current instantaneous pose of the VRDisplay, with no
  56453. * prediction applied.
  56454. * @returns the current instantaneous pose
  56455. */
  56456. getImmediatePose(): VRPose;
  56457. /**
  56458. * The callback passed to `requestAnimationFrame` will be called
  56459. * any time a new frame should be rendered. When the VRDisplay is
  56460. * presenting the callback will be called at the native refresh
  56461. * rate of the HMD. When not presenting this function acts
  56462. * identically to how window.requestAnimationFrame acts. Content should
  56463. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56464. * asynchronously from other displays and at differing refresh rates.
  56465. * @param callback Define the eaction to run next frame
  56466. * @returns the request handle it
  56467. */
  56468. requestAnimationFrame(callback: FrameRequestCallback): number;
  56469. /**
  56470. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56471. * Repeat calls while already presenting will update the VRLayers being displayed.
  56472. * @param layers Define the list of layer to present
  56473. * @returns a promise to know when the request has been fulfilled
  56474. */
  56475. requestPresent(layers: VRLayer[]): Promise<void>;
  56476. /**
  56477. * Reset the pose for this display, treating its current position and
  56478. * orientation as the "origin/zero" values. VRPose.position,
  56479. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56480. * updated when calling resetPose(). This should be called in only
  56481. * sitting-space experiences.
  56482. */
  56483. resetPose(): void;
  56484. /**
  56485. * The VRLayer provided to the VRDisplay will be captured and presented
  56486. * in the HMD. Calling this function has the same effect on the source
  56487. * canvas as any other operation that uses its source image, and canvases
  56488. * created without preserveDrawingBuffer set to true will be cleared.
  56489. * @param pose Define the pose to submit
  56490. */
  56491. submitFrame(pose?: VRPose): void;
  56492. }
  56493. declare var VRDisplay: {
  56494. prototype: VRDisplay;
  56495. new(): VRDisplay;
  56496. };
  56497. interface VRLayer {
  56498. leftBounds?: number[] | Float32Array | null;
  56499. rightBounds?: number[] | Float32Array | null;
  56500. source?: HTMLCanvasElement | null;
  56501. }
  56502. interface VRDisplayCapabilities {
  56503. readonly canPresent: boolean;
  56504. readonly hasExternalDisplay: boolean;
  56505. readonly hasOrientation: boolean;
  56506. readonly hasPosition: boolean;
  56507. readonly maxLayers: number;
  56508. }
  56509. interface VREyeParameters {
  56510. /** @deprecated */
  56511. readonly fieldOfView: VRFieldOfView;
  56512. readonly offset: Float32Array;
  56513. readonly renderHeight: number;
  56514. readonly renderWidth: number;
  56515. }
  56516. interface VRFieldOfView {
  56517. readonly downDegrees: number;
  56518. readonly leftDegrees: number;
  56519. readonly rightDegrees: number;
  56520. readonly upDegrees: number;
  56521. }
  56522. interface VRFrameData {
  56523. readonly leftProjectionMatrix: Float32Array;
  56524. readonly leftViewMatrix: Float32Array;
  56525. readonly pose: VRPose;
  56526. readonly rightProjectionMatrix: Float32Array;
  56527. readonly rightViewMatrix: Float32Array;
  56528. readonly timestamp: number;
  56529. }
  56530. interface VRPose {
  56531. readonly angularAcceleration: Float32Array | null;
  56532. readonly angularVelocity: Float32Array | null;
  56533. readonly linearAcceleration: Float32Array | null;
  56534. readonly linearVelocity: Float32Array | null;
  56535. readonly orientation: Float32Array | null;
  56536. readonly position: Float32Array | null;
  56537. readonly timestamp: number;
  56538. }
  56539. interface VRStageParameters {
  56540. sittingToStandingTransform?: Float32Array;
  56541. sizeX?: number;
  56542. sizeY?: number;
  56543. }
  56544. interface Navigator {
  56545. getVRDisplays(): Promise<VRDisplay[]>;
  56546. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56547. }
  56548. interface Window {
  56549. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56550. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56551. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56552. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56553. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56554. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56555. }
  56556. interface Gamepad {
  56557. readonly displayId: number;
  56558. }
  56559. interface XRDevice {
  56560. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56561. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56562. }
  56563. interface XRSession {
  56564. getInputSources(): Array<any>;
  56565. baseLayer: XRWebGLLayer;
  56566. requestFrameOfReference(type: string): Promise<void>;
  56567. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56568. end(): Promise<void>;
  56569. requestAnimationFrame: Function;
  56570. addEventListener: Function;
  56571. }
  56572. interface XRSessionCreationOptions {
  56573. outputContext?: WebGLRenderingContext | null;
  56574. immersive?: boolean;
  56575. environmentIntegration?: boolean;
  56576. }
  56577. interface XRLayer {
  56578. getViewport: Function;
  56579. framebufferWidth: number;
  56580. framebufferHeight: number;
  56581. }
  56582. interface XRView {
  56583. projectionMatrix: Float32Array;
  56584. }
  56585. interface XRFrame {
  56586. getDevicePose: Function;
  56587. getInputPose: Function;
  56588. views: Array<XRView>;
  56589. baseLayer: XRLayer;
  56590. }
  56591. interface XRFrameOfReference {
  56592. }
  56593. interface XRWebGLLayer extends XRLayer {
  56594. framebuffer: WebGLFramebuffer;
  56595. }
  56596. declare var XRWebGLLayer: {
  56597. prototype: XRWebGLLayer;
  56598. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56599. };