babylon.d.ts 2.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078
  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. let Epsilon: number;
  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 Color3 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. * Adds the translation vector (using 3 floats) in the current matrix
  2943. * @param x defines the 1st component of the translation
  2944. * @param y defines the 2nd component of the translation
  2945. * @param z defines the 3rd component of the translation
  2946. * @returns the current updated matrix
  2947. */
  2948. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2949. /**
  2950. * Inserts the translation vector in the current matrix
  2951. * @param vector3 defines the translation to insert
  2952. * @returns the current updated matrix
  2953. */
  2954. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2955. /**
  2956. * Gets the translation value of the current matrix
  2957. * @returns a new Vector3 as the extracted translation from the matrix
  2958. */
  2959. getTranslation(): Vector3;
  2960. /**
  2961. * Fill a Vector3 with the extracted translation from the matrix
  2962. * @param result defines the Vector3 where to store the translation
  2963. * @returns the current matrix
  2964. */
  2965. getTranslationToRef(result: Vector3): Matrix;
  2966. /**
  2967. * Remove rotation and scaling part from the matrix
  2968. * @returns the updated matrix
  2969. */
  2970. removeRotationAndScaling(): Matrix;
  2971. /**
  2972. * Multiply two matrices
  2973. * @param other defines the second operand
  2974. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2975. */
  2976. multiply(other: DeepImmutable<Matrix>): Matrix;
  2977. /**
  2978. * Copy the current matrix from the given one
  2979. * @param other defines the source matrix
  2980. * @returns the current updated matrix
  2981. */
  2982. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2983. /**
  2984. * Populates the given array from the starting index with the current matrix values
  2985. * @param array defines the target array
  2986. * @param offset defines the offset in the target array where to start storing values
  2987. * @returns the current matrix
  2988. */
  2989. copyToArray(array: Float32Array, offset?: number): Matrix;
  2990. /**
  2991. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the matrix where to store the multiplication
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2997. /**
  2998. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2999. * @param other defines the second operand
  3000. * @param result defines the array where to store the multiplication
  3001. * @param offset defines the offset in the target array where to start storing values
  3002. * @returns the current matrix
  3003. */
  3004. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3005. /**
  3006. * Check equality between this matrix and a second one
  3007. * @param value defines the second matrix to compare
  3008. * @returns true is the current matrix and the given one values are strictly equal
  3009. */
  3010. equals(value: DeepImmutable<Matrix>): boolean;
  3011. /**
  3012. * Clone the current matrix
  3013. * @returns a new matrix from the current matrix
  3014. */
  3015. clone(): Matrix;
  3016. /**
  3017. * Returns the name of the current matrix class
  3018. * @returns the string "Matrix"
  3019. */
  3020. getClassName(): string;
  3021. /**
  3022. * Gets the hash code of the current matrix
  3023. * @returns the hash code
  3024. */
  3025. getHashCode(): number;
  3026. /**
  3027. * Decomposes the current Matrix into a translation, rotation and scaling components
  3028. * @param scale defines the scale vector3 given as a reference to update
  3029. * @param rotation defines the rotation quaternion given as a reference to update
  3030. * @param translation defines the translation vector3 given as a reference to update
  3031. * @returns true if operation was successful
  3032. */
  3033. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3034. /**
  3035. * Gets specific row of the matrix
  3036. * @param index defines the number of the row to get
  3037. * @returns the index-th row of the current matrix as a new Vector4
  3038. */
  3039. getRow(index: number): Nullable<Vector4>;
  3040. /**
  3041. * Sets the index-th row of the current matrix to the vector4 values
  3042. * @param index defines the number of the row to set
  3043. * @param row defines the target vector4
  3044. * @returns the updated current matrix
  3045. */
  3046. setRow(index: number, row: Vector4): Matrix;
  3047. /**
  3048. * Compute the transpose of the matrix
  3049. * @returns the new transposed matrix
  3050. */
  3051. transpose(): Matrix;
  3052. /**
  3053. * Compute the transpose of the matrix and store it in a given matrix
  3054. * @param result defines the target matrix
  3055. * @returns the current matrix
  3056. */
  3057. transposeToRef(result: Matrix): Matrix;
  3058. /**
  3059. * Sets the index-th row of the current matrix with the given 4 x float values
  3060. * @param index defines the row index
  3061. * @param x defines the x component to set
  3062. * @param y defines the y component to set
  3063. * @param z defines the z component to set
  3064. * @param w defines the w component to set
  3065. * @returns the updated current matrix
  3066. */
  3067. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3068. /**
  3069. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3070. * @param scale defines the scale factor
  3071. * @returns a new matrix
  3072. */
  3073. scale(scale: number): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor to a given result matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Scale the current matrix values by a factor and add the result to a given matrix
  3083. * @param scale defines the scale factor
  3084. * @param result defines the Matrix to store the result
  3085. * @returns the current matrix
  3086. */
  3087. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3088. /**
  3089. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3090. * @param ref matrix to store the result
  3091. */
  3092. toNormalMatrix(ref: Matrix): void;
  3093. /**
  3094. * Gets only rotation part of the current matrix
  3095. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3096. */
  3097. getRotationMatrix(): Matrix;
  3098. /**
  3099. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3100. * @param result defines the target matrix to store data to
  3101. * @returns the current matrix
  3102. */
  3103. getRotationMatrixToRef(result: Matrix): Matrix;
  3104. /**
  3105. * Toggles model matrix from being right handed to left handed in place and vice versa
  3106. */
  3107. toggleModelMatrixHandInPlace(): void;
  3108. /**
  3109. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3110. */
  3111. toggleProjectionMatrixHandInPlace(): void;
  3112. /**
  3113. * Creates a matrix from an array
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @returns a new Matrix set from the starting index of the given array
  3117. */
  3118. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3119. /**
  3120. * Copy the content of an array into a given matrix
  3121. * @param array defines the source array
  3122. * @param offset defines an offset in the source array
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3126. /**
  3127. * Stores an array into a matrix after having multiplied each component by a given factor
  3128. * @param array defines the source array
  3129. * @param offset defines the offset in the source array
  3130. * @param scale defines the scaling factor
  3131. * @param result defines the target matrix
  3132. */
  3133. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3134. /**
  3135. * Gets an identity matrix that must not be updated
  3136. */
  3137. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3138. /**
  3139. * Stores a list of values (16) inside a given matrix
  3140. * @param initialM11 defines 1st value of 1st row
  3141. * @param initialM12 defines 2nd value of 1st row
  3142. * @param initialM13 defines 3rd value of 1st row
  3143. * @param initialM14 defines 4th value of 1st row
  3144. * @param initialM21 defines 1st value of 2nd row
  3145. * @param initialM22 defines 2nd value of 2nd row
  3146. * @param initialM23 defines 3rd value of 2nd row
  3147. * @param initialM24 defines 4th value of 2nd row
  3148. * @param initialM31 defines 1st value of 3rd row
  3149. * @param initialM32 defines 2nd value of 3rd row
  3150. * @param initialM33 defines 3rd value of 3rd row
  3151. * @param initialM34 defines 4th value of 3rd row
  3152. * @param initialM41 defines 1st value of 4th row
  3153. * @param initialM42 defines 2nd value of 4th row
  3154. * @param initialM43 defines 3rd value of 4th row
  3155. * @param initialM44 defines 4th value of 4th row
  3156. * @param result defines the target matrix
  3157. */
  3158. 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;
  3159. /**
  3160. * Creates new matrix from a list of values (16)
  3161. * @param initialM11 defines 1st value of 1st row
  3162. * @param initialM12 defines 2nd value of 1st row
  3163. * @param initialM13 defines 3rd value of 1st row
  3164. * @param initialM14 defines 4th value of 1st row
  3165. * @param initialM21 defines 1st value of 2nd row
  3166. * @param initialM22 defines 2nd value of 2nd row
  3167. * @param initialM23 defines 3rd value of 2nd row
  3168. * @param initialM24 defines 4th value of 2nd row
  3169. * @param initialM31 defines 1st value of 3rd row
  3170. * @param initialM32 defines 2nd value of 3rd row
  3171. * @param initialM33 defines 3rd value of 3rd row
  3172. * @param initialM34 defines 4th value of 3rd row
  3173. * @param initialM41 defines 1st value of 4th row
  3174. * @param initialM42 defines 2nd value of 4th row
  3175. * @param initialM43 defines 3rd value of 4th row
  3176. * @param initialM44 defines 4th value of 4th row
  3177. * @returns the new matrix
  3178. */
  3179. 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;
  3180. /**
  3181. * Creates a new matrix 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. * @returns a new matrix
  3186. */
  3187. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3188. /**
  3189. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3190. * @param scale defines the scale vector3
  3191. * @param rotation defines the rotation quaternion
  3192. * @param translation defines the translation vector3
  3193. * @param result defines the target matrix
  3194. */
  3195. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3196. /**
  3197. * Creates a new identity matrix
  3198. * @returns a new identity matrix
  3199. */
  3200. static Identity(): Matrix;
  3201. /**
  3202. * Creates a new identity matrix and stores the result in a given matrix
  3203. * @param result defines the target matrix
  3204. */
  3205. static IdentityToRef(result: Matrix): void;
  3206. /**
  3207. * Creates a new zero matrix
  3208. * @returns a new zero matrix
  3209. */
  3210. static Zero(): Matrix;
  3211. /**
  3212. * Creates a new rotation matrix for "angle" radians around the X axis
  3213. * @param angle defines the angle (in radians) to use
  3214. * @return the new matrix
  3215. */
  3216. static RotationX(angle: number): Matrix;
  3217. /**
  3218. * Creates a new matrix as the invert of a given matrix
  3219. * @param source defines the source matrix
  3220. * @returns the new matrix
  3221. */
  3222. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3223. /**
  3224. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3225. * @param angle defines the angle (in radians) to use
  3226. * @param result defines the target matrix
  3227. */
  3228. static RotationXToRef(angle: number, result: Matrix): void;
  3229. /**
  3230. * Creates a new rotation matrix for "angle" radians around the Y axis
  3231. * @param angle defines the angle (in radians) to use
  3232. * @return the new matrix
  3233. */
  3234. static RotationY(angle: number): Matrix;
  3235. /**
  3236. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3237. * @param angle defines the angle (in radians) to use
  3238. * @param result defines the target matrix
  3239. */
  3240. static RotationYToRef(angle: number, result: Matrix): void;
  3241. /**
  3242. * Creates a new rotation matrix for "angle" radians around the Z axis
  3243. * @param angle defines the angle (in radians) to use
  3244. * @return the new matrix
  3245. */
  3246. static RotationZ(angle: number): Matrix;
  3247. /**
  3248. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3249. * @param angle defines the angle (in radians) to use
  3250. * @param result defines the target matrix
  3251. */
  3252. static RotationZToRef(angle: number, result: Matrix): void;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3262. * @param axis defines the axis to use
  3263. * @param angle defines the angle (in radians) to use
  3264. * @param result defines the target matrix
  3265. */
  3266. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3267. /**
  3268. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3269. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3270. * @param from defines the vector to align
  3271. * @param to defines the vector to align to
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3275. /**
  3276. * Creates a rotation matrix
  3277. * @param yaw defines the yaw angle in radians (Y axis)
  3278. * @param pitch defines the pitch angle in radians (X axis)
  3279. * @param roll defines the roll angle in radians (X axis)
  3280. * @returns the new rotation matrix
  3281. */
  3282. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3283. /**
  3284. * Creates a rotation matrix and stores it in a given matrix
  3285. * @param yaw defines the yaw angle in radians (Y axis)
  3286. * @param pitch defines the pitch angle in radians (X axis)
  3287. * @param roll defines the roll angle in radians (X axis)
  3288. * @param result defines the target matrix
  3289. */
  3290. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3291. /**
  3292. * Creates a scaling matrix
  3293. * @param x defines the scale factor on X axis
  3294. * @param y defines the scale factor on Y axis
  3295. * @param z defines the scale factor on Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Scaling(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a scaling matrix and stores it in a given matrix
  3301. * @param x defines the scale factor on X axis
  3302. * @param y defines the scale factor on Y axis
  3303. * @param z defines the scale factor on Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Creates a translation matrix
  3309. * @param x defines the translation on X axis
  3310. * @param y defines the translation on Y axis
  3311. * @param z defines the translationon Z axis
  3312. * @returns the new matrix
  3313. */
  3314. static Translation(x: number, y: number, z: number): Matrix;
  3315. /**
  3316. * Creates a translation matrix and stores it in a given matrix
  3317. * @param x defines the translation on X axis
  3318. * @param y defines the translation on Y axis
  3319. * @param z defines the translationon Z axis
  3320. * @param result defines the target matrix
  3321. */
  3322. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3323. /**
  3324. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3325. * @param startValue defines the start value
  3326. * @param endValue defines the end value
  3327. * @param gradient defines the gradient factor
  3328. * @returns the new matrix
  3329. */
  3330. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3331. /**
  3332. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3333. * @param startValue defines the start value
  3334. * @param endValue defines the end value
  3335. * @param gradient defines the gradient factor
  3336. * @param result defines the Matrix object where to store data
  3337. */
  3338. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3339. /**
  3340. * Builds a new matrix whose values are computed by:
  3341. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3342. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3343. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3344. * @param startValue defines the first matrix
  3345. * @param endValue defines the second matrix
  3346. * @param gradient defines the gradient between the two matrices
  3347. * @returns the new matrix
  3348. */
  3349. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3350. /**
  3351. * Update a matrix to values which are computed by:
  3352. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3353. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3354. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3355. * @param startValue defines the first matrix
  3356. * @param endValue defines the second matrix
  3357. * @param gradient defines the gradient between the two matrices
  3358. * @param result defines the target matrix
  3359. */
  3360. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3361. /**
  3362. * 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"
  3363. * This function works in left handed mode
  3364. * @param eye defines the final position of the entity
  3365. * @param target defines where the entity should look at
  3366. * @param up defines the up vector for the entity
  3367. * @returns the new matrix
  3368. */
  3369. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3370. /**
  3371. * 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".
  3372. * This function works in left handed mode
  3373. * @param eye defines the final position of the entity
  3374. * @param target defines where the entity should look at
  3375. * @param up defines the up vector for the entity
  3376. * @param result defines the target matrix
  3377. */
  3378. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3379. /**
  3380. * 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"
  3381. * This function works in right handed mode
  3382. * @param eye defines the final position of the entity
  3383. * @param target defines where the entity should look at
  3384. * @param up defines the up vector for the entity
  3385. * @returns the new matrix
  3386. */
  3387. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3388. /**
  3389. * 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".
  3390. * This function works in right handed mode
  3391. * @param eye defines the final position of the entity
  3392. * @param target defines where the entity should look at
  3393. * @param up defines the up vector for the entity
  3394. * @param result defines the target matrix
  3395. */
  3396. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3397. /**
  3398. * Create a left-handed orthographic projection matrix
  3399. * @param width defines the viewport width
  3400. * @param height defines the viewport height
  3401. * @param znear defines the near clip plane
  3402. * @param zfar defines the far clip plane
  3403. * @returns a new matrix as a left-handed orthographic projection matrix
  3404. */
  3405. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3406. /**
  3407. * Store a left-handed orthographic projection to a given matrix
  3408. * @param width defines the viewport width
  3409. * @param height defines the viewport height
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @param result defines the target matrix
  3413. */
  3414. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3415. /**
  3416. * Create a left-handed orthographic projection matrix
  3417. * @param left defines the viewport left coordinate
  3418. * @param right defines the viewport right coordinate
  3419. * @param bottom defines the viewport bottom coordinate
  3420. * @param top defines the viewport top coordinate
  3421. * @param znear defines the near clip plane
  3422. * @param zfar defines the far clip plane
  3423. * @returns a new matrix as a left-handed orthographic projection matrix
  3424. */
  3425. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3426. /**
  3427. * Stores a left-handed orthographic projection into a given matrix
  3428. * @param left defines the viewport left coordinate
  3429. * @param right defines the viewport right coordinate
  3430. * @param bottom defines the viewport bottom coordinate
  3431. * @param top defines the viewport top coordinate
  3432. * @param znear defines the near clip plane
  3433. * @param zfar defines the far clip plane
  3434. * @param result defines the target matrix
  3435. */
  3436. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3437. /**
  3438. * Creates a right-handed orthographic projection matrix
  3439. * @param left defines the viewport left coordinate
  3440. * @param right defines the viewport right coordinate
  3441. * @param bottom defines the viewport bottom coordinate
  3442. * @param top defines the viewport top coordinate
  3443. * @param znear defines the near clip plane
  3444. * @param zfar defines the far clip plane
  3445. * @returns a new matrix as a right-handed orthographic projection matrix
  3446. */
  3447. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3448. /**
  3449. * Stores a right-handed orthographic projection into a given matrix
  3450. * @param left defines the viewport left coordinate
  3451. * @param right defines the viewport right coordinate
  3452. * @param bottom defines the viewport bottom coordinate
  3453. * @param top defines the viewport top coordinate
  3454. * @param znear defines the near clip plane
  3455. * @param zfar defines the far clip plane
  3456. * @param result defines the target matrix
  3457. */
  3458. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3459. /**
  3460. * Creates a left-handed perspective projection matrix
  3461. * @param width defines the viewport width
  3462. * @param height defines the viewport height
  3463. * @param znear defines the near clip plane
  3464. * @param zfar defines the far clip plane
  3465. * @returns a new matrix as a left-handed perspective projection matrix
  3466. */
  3467. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3468. /**
  3469. * Creates a left-handed perspective projection matrix
  3470. * @param fov defines the horizontal field of view
  3471. * @param aspect defines the aspect ratio
  3472. * @param znear defines the near clip plane
  3473. * @param zfar defines the far clip plane
  3474. * @returns a new matrix as a left-handed perspective projection matrix
  3475. */
  3476. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3477. /**
  3478. * Stores a left-handed perspective projection into a given matrix
  3479. * @param fov defines the horizontal field of view
  3480. * @param aspect defines the aspect ratio
  3481. * @param znear defines the near clip plane
  3482. * @param zfar defines the far clip plane
  3483. * @param result defines the target matrix
  3484. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3485. */
  3486. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3487. /**
  3488. * Creates a right-handed perspective projection matrix
  3489. * @param fov defines the horizontal field of view
  3490. * @param aspect defines the aspect ratio
  3491. * @param znear defines the near clip plane
  3492. * @param zfar defines the far clip plane
  3493. * @returns a new matrix as a right-handed perspective projection matrix
  3494. */
  3495. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3496. /**
  3497. * Stores a right-handed perspective projection into a given matrix
  3498. * @param fov defines the horizontal field of view
  3499. * @param aspect defines the aspect ratio
  3500. * @param znear defines the near clip plane
  3501. * @param zfar defines the far clip plane
  3502. * @param result defines the target matrix
  3503. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3504. */
  3505. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3506. /**
  3507. * Stores a perspective projection for WebVR info a given matrix
  3508. * @param fov defines the field of view
  3509. * @param znear defines the near clip plane
  3510. * @param zfar defines the far clip plane
  3511. * @param result defines the target matrix
  3512. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3513. */
  3514. static PerspectiveFovWebVRToRef(fov: {
  3515. upDegrees: number;
  3516. downDegrees: number;
  3517. leftDegrees: number;
  3518. rightDegrees: number;
  3519. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3520. /**
  3521. * Computes a complete transformation matrix
  3522. * @param viewport defines the viewport to use
  3523. * @param world defines the world matrix
  3524. * @param view defines the view matrix
  3525. * @param projection defines the projection matrix
  3526. * @param zmin defines the near clip plane
  3527. * @param zmax defines the far clip plane
  3528. * @returns the transformation matrix
  3529. */
  3530. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3531. /**
  3532. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3533. * @param matrix defines the matrix to use
  3534. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3535. */
  3536. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3537. /**
  3538. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3539. * @param matrix defines the matrix to use
  3540. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3541. */
  3542. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3543. /**
  3544. * Compute the transpose of a given matrix
  3545. * @param matrix defines the matrix to transpose
  3546. * @returns the new matrix
  3547. */
  3548. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3549. /**
  3550. * Compute the transpose of a matrix and store it in a target matrix
  3551. * @param matrix defines the matrix to transpose
  3552. * @param result defines the target matrix
  3553. */
  3554. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3555. /**
  3556. * Computes a reflection matrix from a plane
  3557. * @param plane defines the reflection plane
  3558. * @returns a new matrix
  3559. */
  3560. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3561. /**
  3562. * Computes a reflection matrix from a plane
  3563. * @param plane defines the reflection plane
  3564. * @param result defines the target matrix
  3565. */
  3566. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3567. /**
  3568. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3569. * @param xaxis defines the value of the 1st axis
  3570. * @param yaxis defines the value of the 2nd axis
  3571. * @param zaxis defines the value of the 3rd axis
  3572. * @param result defines the target matrix
  3573. */
  3574. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3575. /**
  3576. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3577. * @param quat defines the quaternion to use
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3581. }
  3582. /**
  3583. * Represens a plane by the equation ax + by + cz + d = 0
  3584. */
  3585. export class Plane {
  3586. /**
  3587. * Normal of the plane (a,b,c)
  3588. */
  3589. normal: Vector3;
  3590. /**
  3591. * d component of the plane
  3592. */
  3593. d: number;
  3594. /**
  3595. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3596. * @param a a component of the plane
  3597. * @param b b component of the plane
  3598. * @param c c component of the plane
  3599. * @param d d component of the plane
  3600. */
  3601. constructor(a: number, b: number, c: number, d: number);
  3602. /**
  3603. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3604. */
  3605. asArray(): number[];
  3606. /**
  3607. * @returns a new plane copied from the current Plane.
  3608. */
  3609. clone(): Plane;
  3610. /**
  3611. * @returns the string "Plane".
  3612. */
  3613. getClassName(): string;
  3614. /**
  3615. * @returns the Plane hash code.
  3616. */
  3617. getHashCode(): number;
  3618. /**
  3619. * Normalize the current Plane in place.
  3620. * @returns the updated Plane.
  3621. */
  3622. normalize(): Plane;
  3623. /**
  3624. * Applies a transformation the plane and returns the result
  3625. * @param transformation the transformation matrix to be applied to the plane
  3626. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3627. */
  3628. transform(transformation: DeepImmutable<Matrix>): Plane;
  3629. /**
  3630. * Calcualtte the dot product between the point and the plane normal
  3631. * @param point point to calculate the dot product with
  3632. * @returns the dot product (float) of the point coordinates and the plane normal.
  3633. */
  3634. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3635. /**
  3636. * Updates the current Plane from the plane defined by the three given points.
  3637. * @param point1 one of the points used to contruct the plane
  3638. * @param point2 one of the points used to contruct the plane
  3639. * @param point3 one of the points used to contruct the plane
  3640. * @returns the updated Plane.
  3641. */
  3642. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3643. /**
  3644. * Checks if the plane is facing a given direction
  3645. * @param direction the direction to check if the plane is facing
  3646. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3647. * @returns True is the vector "direction" is the same side than the plane normal.
  3648. */
  3649. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3650. /**
  3651. * Calculates the distance to a point
  3652. * @param point point to calculate distance to
  3653. * @returns the signed distance (float) from the given point to the Plane.
  3654. */
  3655. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3656. /**
  3657. * Creates a plane from an array
  3658. * @param array the array to create a plane from
  3659. * @returns a new Plane from the given array.
  3660. */
  3661. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3662. /**
  3663. * Creates a plane from three points
  3664. * @param point1 point used to create the plane
  3665. * @param point2 point used to create the plane
  3666. * @param point3 point used to create the plane
  3667. * @returns a new Plane defined by the three given points.
  3668. */
  3669. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3670. /**
  3671. * Creates a plane from an origin point and a normal
  3672. * @param origin origin of the plane to be constructed
  3673. * @param normal normal of the plane to be constructed
  3674. * @returns a new Plane the normal vector to this plane at the given origin point.
  3675. * Note : the vector "normal" is updated because normalized.
  3676. */
  3677. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3678. /**
  3679. * Calculates the distance from a plane and a point
  3680. * @param origin origin of the plane to be constructed
  3681. * @param normal normal of the plane to be constructed
  3682. * @param point point to calculate distance to
  3683. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3684. */
  3685. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3686. }
  3687. /**
  3688. * Class used to represent a viewport on screen
  3689. */
  3690. export class Viewport {
  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 Viewport object located at (x, y) and sized (width, height)
  3701. * @param x defines viewport left coordinate
  3702. * @param y defines viewport top coordinate
  3703. * @param width defines the viewport width
  3704. * @param height defines the viewport height
  3705. */
  3706. constructor(
  3707. /** viewport left coordinate */
  3708. x: number,
  3709. /** viewport top coordinate */
  3710. y: number,
  3711. /**viewport width */
  3712. width: number,
  3713. /** viewport height */
  3714. height: number);
  3715. /**
  3716. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3717. * @param renderWidth defines the rendering width
  3718. * @param renderHeight defines the rendering height
  3719. * @returns a new Viewport
  3720. */
  3721. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3722. /**
  3723. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3724. * @param renderWidth defines the rendering width
  3725. * @param renderHeight defines the rendering height
  3726. * @param ref defines the target viewport
  3727. * @returns the current viewport
  3728. */
  3729. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3730. /**
  3731. * Returns a new Viewport copied from the current one
  3732. * @returns a new Viewport
  3733. */
  3734. clone(): Viewport;
  3735. }
  3736. /**
  3737. * Reprasents a camera frustum
  3738. */
  3739. export class Frustum {
  3740. /**
  3741. * Gets the planes representing the frustum
  3742. * @param transform matrix to be applied to the returned planes
  3743. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3744. */
  3745. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3746. /**
  3747. * Gets the near frustum plane transformed by the transform matrix
  3748. * @param transform transformation matrix to be applied to the resulting frustum plane
  3749. * @param frustumPlane the resuling frustum plane
  3750. */
  3751. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3752. /**
  3753. * Gets the far frustum plane transformed by the transform matrix
  3754. * @param transform transformation matrix to be applied to the resulting frustum plane
  3755. * @param frustumPlane the resuling frustum plane
  3756. */
  3757. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3758. /**
  3759. * Gets the left frustum plane transformed by the transform matrix
  3760. * @param transform transformation matrix to be applied to the resulting frustum plane
  3761. * @param frustumPlane the resuling frustum plane
  3762. */
  3763. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3764. /**
  3765. * Gets the right frustum plane transformed by the transform matrix
  3766. * @param transform transformation matrix to be applied to the resulting frustum plane
  3767. * @param frustumPlane the resuling frustum plane
  3768. */
  3769. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3770. /**
  3771. * Gets the top frustum plane transformed by the transform matrix
  3772. * @param transform transformation matrix to be applied to the resulting frustum plane
  3773. * @param frustumPlane the resuling frustum plane
  3774. */
  3775. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3776. /**
  3777. * Gets the bottom frustum plane transformed by the transform matrix
  3778. * @param transform transformation matrix to be applied to the resulting frustum plane
  3779. * @param frustumPlane the resuling frustum plane
  3780. */
  3781. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3782. /**
  3783. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3784. * @param transform transformation matrix to be applied to the resulting frustum planes
  3785. * @param frustumPlanes the resuling frustum planes
  3786. */
  3787. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3788. }
  3789. /** Defines supported spaces */
  3790. export enum Space {
  3791. /** Local (object) space */
  3792. LOCAL = 0,
  3793. /** World space */
  3794. WORLD = 1,
  3795. /** Bone space */
  3796. BONE = 2
  3797. }
  3798. /** Defines the 3 main axes */
  3799. export class Axis {
  3800. /** X axis */
  3801. static X: Vector3;
  3802. /** Y axis */
  3803. static Y: Vector3;
  3804. /** Z axis */
  3805. static Z: Vector3;
  3806. }
  3807. /** Class used to represent a Bezier curve */
  3808. export class BezierCurve {
  3809. /**
  3810. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3811. * @param t defines the time
  3812. * @param x1 defines the left coordinate on X axis
  3813. * @param y1 defines the left coordinate on Y axis
  3814. * @param x2 defines the right coordinate on X axis
  3815. * @param y2 defines the right coordinate on Y axis
  3816. * @returns the interpolated value
  3817. */
  3818. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3819. }
  3820. /**
  3821. * Defines potential orientation for back face culling
  3822. */
  3823. export enum Orientation {
  3824. /**
  3825. * Clockwise
  3826. */
  3827. CW = 0,
  3828. /** Counter clockwise */
  3829. CCW = 1
  3830. }
  3831. /**
  3832. * Defines angle representation
  3833. */
  3834. export class Angle {
  3835. private _radians;
  3836. /**
  3837. * Creates an Angle object of "radians" radians (float).
  3838. * @param radians the angle in radians
  3839. */
  3840. constructor(radians: number);
  3841. /**
  3842. * Get value in degrees
  3843. * @returns the Angle value in degrees (float)
  3844. */
  3845. degrees(): number;
  3846. /**
  3847. * Get value in radians
  3848. * @returns the Angle value in radians (float)
  3849. */
  3850. radians(): number;
  3851. /**
  3852. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3853. * @param a defines first vector
  3854. * @param b defines second vector
  3855. * @returns a new Angle
  3856. */
  3857. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3858. /**
  3859. * Gets a new Angle object from the given float in radians
  3860. * @param radians defines the angle value in radians
  3861. * @returns a new Angle
  3862. */
  3863. static FromRadians(radians: number): Angle;
  3864. /**
  3865. * Gets a new Angle object from the given float in degrees
  3866. * @param degrees defines the angle value in degrees
  3867. * @returns a new Angle
  3868. */
  3869. static FromDegrees(degrees: number): Angle;
  3870. }
  3871. /**
  3872. * This represents an arc in a 2d space.
  3873. */
  3874. export class Arc2 {
  3875. /** Defines the start point of the arc */
  3876. startPoint: Vector2;
  3877. /** Defines the mid point of the arc */
  3878. midPoint: Vector2;
  3879. /** Defines the end point of the arc */
  3880. endPoint: Vector2;
  3881. /**
  3882. * Defines the center point of the arc.
  3883. */
  3884. centerPoint: Vector2;
  3885. /**
  3886. * Defines the radius of the arc.
  3887. */
  3888. radius: number;
  3889. /**
  3890. * Defines the angle of the arc (from mid point to end point).
  3891. */
  3892. angle: Angle;
  3893. /**
  3894. * Defines the start angle of the arc (from start point to middle point).
  3895. */
  3896. startAngle: Angle;
  3897. /**
  3898. * Defines the orientation of the arc (clock wise/counter clock wise).
  3899. */
  3900. orientation: Orientation;
  3901. /**
  3902. * Creates an Arc object from the three given points : start, middle and end.
  3903. * @param startPoint Defines the start point of the arc
  3904. * @param midPoint Defines the midlle point of the arc
  3905. * @param endPoint Defines the end point of the arc
  3906. */
  3907. constructor(
  3908. /** Defines the start point of the arc */
  3909. startPoint: Vector2,
  3910. /** Defines the mid point of the arc */
  3911. midPoint: Vector2,
  3912. /** Defines the end point of the arc */
  3913. endPoint: Vector2);
  3914. }
  3915. /**
  3916. * Represents a 2D path made up of multiple 2D points
  3917. */
  3918. export class Path2 {
  3919. private _points;
  3920. private _length;
  3921. /**
  3922. * If the path start and end point are the same
  3923. */
  3924. closed: boolean;
  3925. /**
  3926. * Creates a Path2 object from the starting 2D coordinates x and y.
  3927. * @param x the starting points x value
  3928. * @param y the starting points y value
  3929. */
  3930. constructor(x: number, y: number);
  3931. /**
  3932. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3933. * @param x the added points x value
  3934. * @param y the added points y value
  3935. * @returns the updated Path2.
  3936. */
  3937. addLineTo(x: number, y: number): Path2;
  3938. /**
  3939. * 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.
  3940. * @param midX middle point x value
  3941. * @param midY middle point y value
  3942. * @param endX end point x value
  3943. * @param endY end point y value
  3944. * @param numberOfSegments (default: 36)
  3945. * @returns the updated Path2.
  3946. */
  3947. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3948. /**
  3949. * Closes the Path2.
  3950. * @returns the Path2.
  3951. */
  3952. close(): Path2;
  3953. /**
  3954. * Gets the sum of the distance between each sequential point in the path
  3955. * @returns the Path2 total length (float).
  3956. */
  3957. length(): number;
  3958. /**
  3959. * Gets the points which construct the path
  3960. * @returns the Path2 internal array of points.
  3961. */
  3962. getPoints(): Vector2[];
  3963. /**
  3964. * Retreives the point at the distance aways from the starting point
  3965. * @param normalizedLengthPosition the length along the path to retreive the point from
  3966. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3967. */
  3968. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3969. /**
  3970. * Creates a new path starting from an x and y position
  3971. * @param x starting x value
  3972. * @param y starting y value
  3973. * @returns a new Path2 starting at the coordinates (x, y).
  3974. */
  3975. static StartingAt(x: number, y: number): Path2;
  3976. }
  3977. /**
  3978. * Represents a 3D path made up of multiple 3D points
  3979. */
  3980. export class Path3D {
  3981. /**
  3982. * an array of Vector3, the curve axis of the Path3D
  3983. */
  3984. path: Vector3[];
  3985. private _curve;
  3986. private _distances;
  3987. private _tangents;
  3988. private _normals;
  3989. private _binormals;
  3990. private _raw;
  3991. /**
  3992. * new Path3D(path, normal, raw)
  3993. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3994. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3995. * @param path an array of Vector3, the curve axis of the Path3D
  3996. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3997. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3998. */
  3999. constructor(
  4000. /**
  4001. * an array of Vector3, the curve axis of the Path3D
  4002. */
  4003. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4004. /**
  4005. * Returns the Path3D array of successive Vector3 designing its curve.
  4006. * @returns the Path3D array of successive Vector3 designing its curve.
  4007. */
  4008. getCurve(): Vector3[];
  4009. /**
  4010. * Returns an array populated with tangent vectors on each Path3D curve point.
  4011. * @returns an array populated with tangent vectors on each Path3D curve point.
  4012. */
  4013. getTangents(): Vector3[];
  4014. /**
  4015. * Returns an array populated with normal vectors on each Path3D curve point.
  4016. * @returns an array populated with normal vectors on each Path3D curve point.
  4017. */
  4018. getNormals(): Vector3[];
  4019. /**
  4020. * Returns an array populated with binormal vectors on each Path3D curve point.
  4021. * @returns an array populated with binormal vectors on each Path3D curve point.
  4022. */
  4023. getBinormals(): Vector3[];
  4024. /**
  4025. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4026. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4027. */
  4028. getDistances(): number[];
  4029. /**
  4030. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4031. * @param path path which all values are copied into the curves points
  4032. * @param firstNormal which should be projected onto the curve
  4033. * @returns the same object updated.
  4034. */
  4035. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4036. private _compute;
  4037. private _getFirstNonNullVector;
  4038. private _getLastNonNullVector;
  4039. private _normalVector;
  4040. }
  4041. /**
  4042. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4043. * A Curve3 is designed from a series of successive Vector3.
  4044. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4045. */
  4046. export class Curve3 {
  4047. private _points;
  4048. private _length;
  4049. /**
  4050. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4051. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4052. * @param v1 (Vector3) the control point
  4053. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4054. * @param nbPoints (integer) the wanted number of points in the curve
  4055. * @returns the created Curve3
  4056. */
  4057. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4058. /**
  4059. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4060. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4061. * @param v1 (Vector3) the first control point
  4062. * @param v2 (Vector3) the second control point
  4063. * @param v3 (Vector3) the end point of the Cubic Bezier
  4064. * @param nbPoints (integer) the wanted number of points in the curve
  4065. * @returns the created Curve3
  4066. */
  4067. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4068. /**
  4069. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4070. * @param p1 (Vector3) the origin point of the Hermite Spline
  4071. * @param t1 (Vector3) the tangent vector at the origin point
  4072. * @param p2 (Vector3) the end point of the Hermite Spline
  4073. * @param t2 (Vector3) the tangent vector at the end point
  4074. * @param nbPoints (integer) the wanted number of points in the curve
  4075. * @returns the created Curve3
  4076. */
  4077. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4078. /**
  4079. * Returns a Curve3 object along a CatmullRom Spline curve :
  4080. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4081. * @param nbPoints (integer) the wanted number of points between each curve control points
  4082. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4083. * @returns the created Curve3
  4084. */
  4085. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4086. /**
  4087. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4088. * A Curve3 is designed from a series of successive Vector3.
  4089. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4090. * @param points points which make up the curve
  4091. */
  4092. constructor(points: Vector3[]);
  4093. /**
  4094. * @returns the Curve3 stored array of successive Vector3
  4095. */
  4096. getPoints(): Vector3[];
  4097. /**
  4098. * @returns the computed length (float) of the curve.
  4099. */
  4100. length(): number;
  4101. /**
  4102. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4103. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4104. * curveA and curveB keep unchanged.
  4105. * @param curve the curve to continue from this curve
  4106. * @returns the newly constructed curve
  4107. */
  4108. continue(curve: DeepImmutable<Curve3>): Curve3;
  4109. private _computeLength;
  4110. }
  4111. /**
  4112. * Contains position and normal vectors for a vertex
  4113. */
  4114. export class PositionNormalVertex {
  4115. /** the position of the vertex (defaut: 0,0,0) */
  4116. position: Vector3;
  4117. /** the normal of the vertex (defaut: 0,1,0) */
  4118. normal: Vector3;
  4119. /**
  4120. * Creates a PositionNormalVertex
  4121. * @param position the position of the vertex (defaut: 0,0,0)
  4122. * @param normal the normal of the vertex (defaut: 0,1,0)
  4123. */
  4124. constructor(
  4125. /** the position of the vertex (defaut: 0,0,0) */
  4126. position?: Vector3,
  4127. /** the normal of the vertex (defaut: 0,1,0) */
  4128. normal?: Vector3);
  4129. /**
  4130. * Clones the PositionNormalVertex
  4131. * @returns the cloned PositionNormalVertex
  4132. */
  4133. clone(): PositionNormalVertex;
  4134. }
  4135. /**
  4136. * Contains position, normal and uv vectors for a vertex
  4137. */
  4138. export class PositionNormalTextureVertex {
  4139. /** the position of the vertex (defaut: 0,0,0) */
  4140. position: Vector3;
  4141. /** the normal of the vertex (defaut: 0,1,0) */
  4142. normal: Vector3;
  4143. /** the uv of the vertex (default: 0,0) */
  4144. uv: Vector2;
  4145. /**
  4146. * Creates a PositionNormalTextureVertex
  4147. * @param position the position of the vertex (defaut: 0,0,0)
  4148. * @param normal the normal of the vertex (defaut: 0,1,0)
  4149. * @param uv the uv of the vertex (default: 0,0)
  4150. */
  4151. constructor(
  4152. /** the position of the vertex (defaut: 0,0,0) */
  4153. position?: Vector3,
  4154. /** the normal of the vertex (defaut: 0,1,0) */
  4155. normal?: Vector3,
  4156. /** the uv of the vertex (default: 0,0) */
  4157. uv?: Vector2);
  4158. /**
  4159. * Clones the PositionNormalTextureVertex
  4160. * @returns the cloned PositionNormalTextureVertex
  4161. */
  4162. clone(): PositionNormalTextureVertex;
  4163. }
  4164. /**
  4165. * @hidden
  4166. */
  4167. export class Tmp {
  4168. static Color3: Color3[];
  4169. static Color4: Color4[];
  4170. static Vector2: Vector2[];
  4171. static Vector3: Vector3[];
  4172. static Vector4: Vector4[];
  4173. static Quaternion: Quaternion[];
  4174. static Matrix: Matrix[];
  4175. }
  4176. }
  4177. declare module BABYLON {
  4178. /**
  4179. * Class used to enable access to offline support
  4180. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4181. */
  4182. export interface IOfflineProvider {
  4183. /**
  4184. * Gets a boolean indicating if scene must be saved in the database
  4185. */
  4186. enableSceneOffline: boolean;
  4187. /**
  4188. * Gets a boolean indicating if textures must be saved in the database
  4189. */
  4190. enableTexturesOffline: boolean;
  4191. /**
  4192. * Open the offline support and make it available
  4193. * @param successCallback defines the callback to call on success
  4194. * @param errorCallback defines the callback to call on error
  4195. */
  4196. open(successCallback: () => void, errorCallback: () => void): void;
  4197. /**
  4198. * Loads an image from the offline support
  4199. * @param url defines the url to load from
  4200. * @param image defines the target DOM image
  4201. */
  4202. loadImage(url: string, image: HTMLImageElement): void;
  4203. /**
  4204. * Loads a file from offline support
  4205. * @param url defines the URL to load from
  4206. * @param sceneLoaded defines a callback to call on success
  4207. * @param progressCallBack defines a callback to call when progress changed
  4208. * @param errorCallback defines a callback to call on error
  4209. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4210. */
  4211. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4212. }
  4213. }
  4214. declare module BABYLON {
  4215. /**
  4216. * A class serves as a medium between the observable and its observers
  4217. */
  4218. export class EventState {
  4219. /**
  4220. * Create a new EventState
  4221. * @param mask defines the mask associated with this state
  4222. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4223. * @param target defines the original target of the state
  4224. * @param currentTarget defines the current target of the state
  4225. */
  4226. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4227. /**
  4228. * Initialize the current event state
  4229. * @param mask defines the mask associated with this state
  4230. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4231. * @param target defines the original target of the state
  4232. * @param currentTarget defines the current target of the state
  4233. * @returns the current event state
  4234. */
  4235. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4236. /**
  4237. * An Observer can set this property to true to prevent subsequent observers of being notified
  4238. */
  4239. skipNextObservers: boolean;
  4240. /**
  4241. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4242. */
  4243. mask: number;
  4244. /**
  4245. * The object that originally notified the event
  4246. */
  4247. target?: any;
  4248. /**
  4249. * The current object in the bubbling phase
  4250. */
  4251. currentTarget?: any;
  4252. /**
  4253. * This will be populated with the return value of the last function that was executed.
  4254. * If it is the first function in the callback chain it will be the event data.
  4255. */
  4256. lastReturnValue?: any;
  4257. }
  4258. /**
  4259. * Represent an Observer registered to a given Observable object.
  4260. */
  4261. export class Observer<T> {
  4262. /**
  4263. * Defines the callback to call when the observer is notified
  4264. */
  4265. callback: (eventData: T, eventState: EventState) => void;
  4266. /**
  4267. * Defines the mask of the observer (used to filter notifications)
  4268. */
  4269. mask: number;
  4270. /**
  4271. * Defines the current scope used to restore the JS context
  4272. */
  4273. scope: any;
  4274. /** @hidden */
  4275. _willBeUnregistered: boolean;
  4276. /**
  4277. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4278. */
  4279. unregisterOnNextCall: boolean;
  4280. /**
  4281. * Creates a new observer
  4282. * @param callback defines the callback to call when the observer is notified
  4283. * @param mask defines the mask of the observer (used to filter notifications)
  4284. * @param scope defines the current scope used to restore the JS context
  4285. */
  4286. constructor(
  4287. /**
  4288. * Defines the callback to call when the observer is notified
  4289. */
  4290. callback: (eventData: T, eventState: EventState) => void,
  4291. /**
  4292. * Defines the mask of the observer (used to filter notifications)
  4293. */
  4294. mask: number,
  4295. /**
  4296. * Defines the current scope used to restore the JS context
  4297. */
  4298. scope?: any);
  4299. }
  4300. /**
  4301. * Represent a list of observers registered to multiple Observables object.
  4302. */
  4303. export class MultiObserver<T> {
  4304. private _observers;
  4305. private _observables;
  4306. /**
  4307. * Release associated resources
  4308. */
  4309. dispose(): void;
  4310. /**
  4311. * Raise a callback when one of the observable will notify
  4312. * @param observables defines a list of observables to watch
  4313. * @param callback defines the callback to call on notification
  4314. * @param mask defines the mask used to filter notifications
  4315. * @param scope defines the current scope used to restore the JS context
  4316. * @returns the new MultiObserver
  4317. */
  4318. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4319. }
  4320. /**
  4321. * The Observable class is a simple implementation of the Observable pattern.
  4322. *
  4323. * 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.
  4324. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4325. * 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).
  4326. * 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.
  4327. */
  4328. export class Observable<T> {
  4329. private _observers;
  4330. private _eventState;
  4331. private _onObserverAdded;
  4332. /**
  4333. * Creates a new observable
  4334. * @param onObserverAdded defines a callback to call when a new observer is added
  4335. */
  4336. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4337. /**
  4338. * Create a new Observer with the specified callback
  4339. * @param callback the callback that will be executed for that Observer
  4340. * @param mask the mask used to filter observers
  4341. * @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.
  4342. * @param scope optional scope for the callback to be called from
  4343. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4344. * @returns the new observer created for the callback
  4345. */
  4346. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4347. /**
  4348. * Create a new Observer with the specified callback and unregisters after the next notification
  4349. * @param callback the callback that will be executed for that Observer
  4350. * @returns the new observer created for the callback
  4351. */
  4352. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4353. /**
  4354. * Remove an Observer from the Observable object
  4355. * @param observer the instance of the Observer to remove
  4356. * @returns false if it doesn't belong to this Observable
  4357. */
  4358. remove(observer: Nullable<Observer<T>>): boolean;
  4359. /**
  4360. * Remove a callback from the Observable object
  4361. * @param callback the callback to remove
  4362. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4363. * @returns false if it doesn't belong to this Observable
  4364. */
  4365. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4366. private _deferUnregister;
  4367. private _remove;
  4368. /**
  4369. * Moves the observable to the top of the observer list making it get called first when notified
  4370. * @param observer the observer to move
  4371. */
  4372. makeObserverTopPriority(observer: Observer<T>): void;
  4373. /**
  4374. * Moves the observable to the bottom of the observer list making it get called last when notified
  4375. * @param observer the observer to move
  4376. */
  4377. makeObserverBottomPriority(observer: Observer<T>): void;
  4378. /**
  4379. * Notify all Observers by calling their respective callback with the given data
  4380. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4381. * @param eventData defines the data to send to all observers
  4382. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4383. * @param target defines the original target of the state
  4384. * @param currentTarget defines the current target of the state
  4385. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4386. */
  4387. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4388. /**
  4389. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4390. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4391. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4392. * and it is crucial that all callbacks will be executed.
  4393. * The order of the callbacks is kept, callbacks are not executed parallel.
  4394. *
  4395. * @param eventData The data to be sent to each callback
  4396. * @param mask is used to filter observers defaults to -1
  4397. * @param target defines the callback target (see EventState)
  4398. * @param currentTarget defines he current object in the bubbling phase
  4399. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4400. */
  4401. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4402. /**
  4403. * Notify a specific observer
  4404. * @param observer defines the observer to notify
  4405. * @param eventData defines the data to be sent to each callback
  4406. * @param mask is used to filter observers defaults to -1
  4407. */
  4408. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4409. /**
  4410. * Gets a boolean indicating if the observable has at least one observer
  4411. * @returns true is the Observable has at least one Observer registered
  4412. */
  4413. hasObservers(): boolean;
  4414. /**
  4415. * Clear the list of observers
  4416. */
  4417. clear(): void;
  4418. /**
  4419. * Clone the current observable
  4420. * @returns a new observable
  4421. */
  4422. clone(): Observable<T>;
  4423. /**
  4424. * Does this observable handles observer registered with a given mask
  4425. * @param mask defines the mask to be tested
  4426. * @return whether or not one observer registered with the given mask is handeled
  4427. **/
  4428. hasSpecificMask(mask?: number): boolean;
  4429. }
  4430. }
  4431. declare module BABYLON {
  4432. /**
  4433. * Class used to help managing file picking and drag'n'drop
  4434. * File Storage
  4435. */
  4436. export class FilesInputStore {
  4437. /**
  4438. * List of files ready to be loaded
  4439. */
  4440. static FilesToLoad: {
  4441. [key: string]: File;
  4442. };
  4443. }
  4444. }
  4445. declare module BABYLON {
  4446. /** Defines the cross module used constants to avoid circular dependncies */
  4447. export class Constants {
  4448. /** Defines that alpha blending is disabled */
  4449. static readonly ALPHA_DISABLE: number;
  4450. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4451. static readonly ALPHA_ADD: number;
  4452. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4453. static readonly ALPHA_COMBINE: number;
  4454. /** Defines that alpha blending to DEST - SRC * DEST */
  4455. static readonly ALPHA_SUBTRACT: number;
  4456. /** Defines that alpha blending to SRC * DEST */
  4457. static readonly ALPHA_MULTIPLY: number;
  4458. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4459. static readonly ALPHA_MAXIMIZED: number;
  4460. /** Defines that alpha blending to SRC + DEST */
  4461. static readonly ALPHA_ONEONE: number;
  4462. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4463. static readonly ALPHA_PREMULTIPLIED: number;
  4464. /**
  4465. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4466. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4467. */
  4468. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4469. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4470. static readonly ALPHA_INTERPOLATE: number;
  4471. /**
  4472. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4473. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4474. */
  4475. static readonly ALPHA_SCREENMODE: number;
  4476. /** Defines that the ressource is not delayed*/
  4477. static readonly DELAYLOADSTATE_NONE: number;
  4478. /** Defines that the ressource was successfully delay loaded */
  4479. static readonly DELAYLOADSTATE_LOADED: number;
  4480. /** Defines that the ressource is currently delay loading */
  4481. static readonly DELAYLOADSTATE_LOADING: number;
  4482. /** Defines that the ressource is delayed and has not started loading */
  4483. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4485. static readonly NEVER: number;
  4486. /** 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 */
  4487. static readonly ALWAYS: number;
  4488. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4489. static readonly LESS: number;
  4490. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4491. static readonly EQUAL: number;
  4492. /** 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 */
  4493. static readonly LEQUAL: number;
  4494. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4495. static readonly GREATER: number;
  4496. /** 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 */
  4497. static readonly GEQUAL: number;
  4498. /** 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 */
  4499. static readonly NOTEQUAL: number;
  4500. /** Passed to stencilOperation to specify that stencil value must be kept */
  4501. static readonly KEEP: number;
  4502. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4503. static readonly REPLACE: number;
  4504. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4505. static readonly INCR: number;
  4506. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4507. static readonly DECR: number;
  4508. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4509. static readonly INVERT: number;
  4510. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4511. static readonly INCR_WRAP: number;
  4512. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4513. static readonly DECR_WRAP: number;
  4514. /** Texture is not repeating outside of 0..1 UVs */
  4515. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4516. /** Texture is repeating outside of 0..1 UVs */
  4517. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4518. /** Texture is repeating and mirrored */
  4519. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4520. /** ALPHA */
  4521. static readonly TEXTUREFORMAT_ALPHA: number;
  4522. /** LUMINANCE */
  4523. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4524. /** LUMINANCE_ALPHA */
  4525. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4526. /** RGB */
  4527. static readonly TEXTUREFORMAT_RGB: number;
  4528. /** RGBA */
  4529. static readonly TEXTUREFORMAT_RGBA: number;
  4530. /** RED */
  4531. static readonly TEXTUREFORMAT_RED: number;
  4532. /** RED (2nd reference) */
  4533. static readonly TEXTUREFORMAT_R: number;
  4534. /** RG */
  4535. static readonly TEXTUREFORMAT_RG: number;
  4536. /** RED_INTEGER */
  4537. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4538. /** RED_INTEGER (2nd reference) */
  4539. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4540. /** RG_INTEGER */
  4541. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4542. /** RGB_INTEGER */
  4543. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4544. /** RGBA_INTEGER */
  4545. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4546. /** UNSIGNED_BYTE */
  4547. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4548. /** UNSIGNED_BYTE (2nd reference) */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4550. /** FLOAT */
  4551. static readonly TEXTURETYPE_FLOAT: number;
  4552. /** HALF_FLOAT */
  4553. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4554. /** BYTE */
  4555. static readonly TEXTURETYPE_BYTE: number;
  4556. /** SHORT */
  4557. static readonly TEXTURETYPE_SHORT: number;
  4558. /** UNSIGNED_SHORT */
  4559. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4560. /** INT */
  4561. static readonly TEXTURETYPE_INT: number;
  4562. /** UNSIGNED_INT */
  4563. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4564. /** UNSIGNED_SHORT_4_4_4_4 */
  4565. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4566. /** UNSIGNED_SHORT_5_5_5_1 */
  4567. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4568. /** UNSIGNED_SHORT_5_6_5 */
  4569. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4570. /** UNSIGNED_INT_2_10_10_10_REV */
  4571. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4572. /** UNSIGNED_INT_24_8 */
  4573. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4574. /** UNSIGNED_INT_10F_11F_11F_REV */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4576. /** UNSIGNED_INT_5_9_9_9_REV */
  4577. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4578. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4579. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4580. /** nearest is mag = nearest and min = nearest and mip = linear */
  4581. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4582. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4583. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4584. /** Trilinear is mag = linear and min = linear and mip = linear */
  4585. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4586. /** nearest is mag = nearest and min = nearest and mip = linear */
  4587. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4588. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4590. /** Trilinear is mag = linear and min = linear and mip = linear */
  4591. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4592. /** mag = nearest and min = nearest and mip = nearest */
  4593. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4594. /** mag = nearest and min = linear and mip = nearest */
  4595. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4596. /** mag = nearest and min = linear and mip = linear */
  4597. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4598. /** mag = nearest and min = linear and mip = none */
  4599. static readonly TEXTURE_NEAREST_LINEAR: number;
  4600. /** mag = nearest and min = nearest and mip = none */
  4601. static readonly TEXTURE_NEAREST_NEAREST: number;
  4602. /** mag = linear and min = nearest and mip = nearest */
  4603. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4604. /** mag = linear and min = nearest and mip = linear */
  4605. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4606. /** mag = linear and min = linear and mip = none */
  4607. static readonly TEXTURE_LINEAR_LINEAR: number;
  4608. /** mag = linear and min = nearest and mip = none */
  4609. static readonly TEXTURE_LINEAR_NEAREST: number;
  4610. /** Explicit coordinates mode */
  4611. static readonly TEXTURE_EXPLICIT_MODE: number;
  4612. /** Spherical coordinates mode */
  4613. static readonly TEXTURE_SPHERICAL_MODE: number;
  4614. /** Planar coordinates mode */
  4615. static readonly TEXTURE_PLANAR_MODE: number;
  4616. /** Cubic coordinates mode */
  4617. static readonly TEXTURE_CUBIC_MODE: number;
  4618. /** Projection coordinates mode */
  4619. static readonly TEXTURE_PROJECTION_MODE: number;
  4620. /** Skybox coordinates mode */
  4621. static readonly TEXTURE_SKYBOX_MODE: number;
  4622. /** Inverse Cubic coordinates mode */
  4623. static readonly TEXTURE_INVCUBIC_MODE: number;
  4624. /** Equirectangular coordinates mode */
  4625. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4626. /** Equirectangular Fixed coordinates mode */
  4627. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4628. /** Equirectangular Fixed Mirrored coordinates mode */
  4629. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4630. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4631. static readonly SCALEMODE_FLOOR: number;
  4632. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4633. static readonly SCALEMODE_NEAREST: number;
  4634. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4635. static readonly SCALEMODE_CEILING: number;
  4636. /**
  4637. * The dirty texture flag value
  4638. */
  4639. static readonly MATERIAL_TextureDirtyFlag: number;
  4640. /**
  4641. * The dirty light flag value
  4642. */
  4643. static readonly MATERIAL_LightDirtyFlag: number;
  4644. /**
  4645. * The dirty fresnel flag value
  4646. */
  4647. static readonly MATERIAL_FresnelDirtyFlag: number;
  4648. /**
  4649. * The dirty attribute flag value
  4650. */
  4651. static readonly MATERIAL_AttributesDirtyFlag: number;
  4652. /**
  4653. * The dirty misc flag value
  4654. */
  4655. static readonly MATERIAL_MiscDirtyFlag: number;
  4656. /**
  4657. * The all dirty flag value
  4658. */
  4659. static readonly MATERIAL_AllDirtyFlag: number;
  4660. /**
  4661. * Returns the triangle fill mode
  4662. */
  4663. static readonly MATERIAL_TriangleFillMode: number;
  4664. /**
  4665. * Returns the wireframe mode
  4666. */
  4667. static readonly MATERIAL_WireFrameFillMode: number;
  4668. /**
  4669. * Returns the point fill mode
  4670. */
  4671. static readonly MATERIAL_PointFillMode: number;
  4672. /**
  4673. * Returns the point list draw mode
  4674. */
  4675. static readonly MATERIAL_PointListDrawMode: number;
  4676. /**
  4677. * Returns the line list draw mode
  4678. */
  4679. static readonly MATERIAL_LineListDrawMode: number;
  4680. /**
  4681. * Returns the line loop draw mode
  4682. */
  4683. static readonly MATERIAL_LineLoopDrawMode: number;
  4684. /**
  4685. * Returns the line strip draw mode
  4686. */
  4687. static readonly MATERIAL_LineStripDrawMode: number;
  4688. /**
  4689. * Returns the triangle strip draw mode
  4690. */
  4691. static readonly MATERIAL_TriangleStripDrawMode: number;
  4692. /**
  4693. * Returns the triangle fan draw mode
  4694. */
  4695. static readonly MATERIAL_TriangleFanDrawMode: number;
  4696. /**
  4697. * Stores the clock-wise side orientation
  4698. */
  4699. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4700. /**
  4701. * Stores the counter clock-wise side orientation
  4702. */
  4703. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4704. /**
  4705. * Nothing
  4706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4707. */
  4708. static readonly ACTION_NothingTrigger: number;
  4709. /**
  4710. * On pick
  4711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4712. */
  4713. static readonly ACTION_OnPickTrigger: number;
  4714. /**
  4715. * On left pick
  4716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4717. */
  4718. static readonly ACTION_OnLeftPickTrigger: number;
  4719. /**
  4720. * On right pick
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnRightPickTrigger: number;
  4724. /**
  4725. * On center pick
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnCenterPickTrigger: number;
  4729. /**
  4730. * On pick down
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickDownTrigger: number;
  4734. /**
  4735. * On double pick
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnDoublePickTrigger: number;
  4739. /**
  4740. * On pick up
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickUpTrigger: number;
  4744. /**
  4745. * On pick out.
  4746. * This trigger will only be raised if you also declared a OnPickDown
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnPickOutTrigger: number;
  4750. /**
  4751. * On long press
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnLongPressTrigger: number;
  4755. /**
  4756. * On pointer over
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPointerOverTrigger: number;
  4760. /**
  4761. * On pointer out
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnPointerOutTrigger: number;
  4765. /**
  4766. * On every frame
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnEveryFrameTrigger: number;
  4770. /**
  4771. * On intersection enter
  4772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4773. */
  4774. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4775. /**
  4776. * On intersection exit
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnIntersectionExitTrigger: number;
  4780. /**
  4781. * On key down
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnKeyDownTrigger: number;
  4785. /**
  4786. * On key up
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnKeyUpTrigger: number;
  4790. /**
  4791. * Billboard mode will only apply to Y axis
  4792. */
  4793. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4794. /**
  4795. * Billboard mode will apply to all axes
  4796. */
  4797. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4798. /**
  4799. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4800. */
  4801. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4802. /**
  4803. * Gets or sets base Assets URL
  4804. */
  4805. static readonly PARTICLES_BaseAssetsUrl: string;
  4806. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4807. * Test order :
  4808. * Is the bounding sphere outside the frustum ?
  4809. * If not, are the bounding box vertices outside the frustum ?
  4810. * It not, then the cullable object is in the frustum.
  4811. */
  4812. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4813. /** Culling strategy : Bounding Sphere Only.
  4814. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4815. * It's also less accurate than the standard because some not visible objects can still be selected.
  4816. * Test : is the bounding sphere outside the frustum ?
  4817. * If not, then the cullable object is in the frustum.
  4818. */
  4819. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4820. /** Culling strategy : Optimistic Inclusion.
  4821. * This in an inclusion test first, then the standard exclusion test.
  4822. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4823. * 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.
  4824. * Anyway, it's as accurate as the standard strategy.
  4825. * Test :
  4826. * Is the cullable object bounding sphere center in the frustum ?
  4827. * If not, apply the default culling strategy.
  4828. */
  4829. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4830. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4831. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4832. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4833. * 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.
  4834. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4835. * Test :
  4836. * Is the cullable object bounding sphere center in the frustum ?
  4837. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4840. /**
  4841. * No logging while loading
  4842. */
  4843. static readonly SCENELOADER_NO_LOGGING: number;
  4844. /**
  4845. * Minimal logging while loading
  4846. */
  4847. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4848. /**
  4849. * Summary logging while loading
  4850. */
  4851. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4852. /**
  4853. * Detailled logging while loading
  4854. */
  4855. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4856. }
  4857. }
  4858. declare module BABYLON {
  4859. /**
  4860. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4861. * Babylon.js
  4862. */
  4863. export class DomManagement {
  4864. /**
  4865. * Checks if the window object exists
  4866. * @returns true if the window object exists
  4867. */
  4868. static IsWindowObjectExist(): boolean;
  4869. /**
  4870. * Extracts text content from a DOM element hierarchy
  4871. * @param element defines the root element
  4872. * @returns a string
  4873. */
  4874. static GetDOMTextContent(element: HTMLElement): string;
  4875. }
  4876. }
  4877. declare module BABYLON {
  4878. /**
  4879. * Logger used througouht the application to allow configuration of
  4880. * the log level required for the messages.
  4881. */
  4882. export class Logger {
  4883. /**
  4884. * No log
  4885. */
  4886. static readonly NoneLogLevel: number;
  4887. /**
  4888. * Only message logs
  4889. */
  4890. static readonly MessageLogLevel: number;
  4891. /**
  4892. * Only warning logs
  4893. */
  4894. static readonly WarningLogLevel: number;
  4895. /**
  4896. * Only error logs
  4897. */
  4898. static readonly ErrorLogLevel: number;
  4899. /**
  4900. * All logs
  4901. */
  4902. static readonly AllLogLevel: number;
  4903. private static _LogCache;
  4904. /**
  4905. * Gets a value indicating the number of loading errors
  4906. * @ignorenaming
  4907. */
  4908. static errorsCount: number;
  4909. /**
  4910. * Callback called when a new log is added
  4911. */
  4912. static OnNewCacheEntry: (entry: string) => void;
  4913. private static _AddLogEntry;
  4914. private static _FormatMessage;
  4915. private static _LogDisabled;
  4916. private static _LogEnabled;
  4917. private static _WarnDisabled;
  4918. private static _WarnEnabled;
  4919. private static _ErrorDisabled;
  4920. private static _ErrorEnabled;
  4921. /**
  4922. * Log a message to the console
  4923. */
  4924. static Log: (message: string) => void;
  4925. /**
  4926. * Write a warning message to the console
  4927. */
  4928. static Warn: (message: string) => void;
  4929. /**
  4930. * Write an error message to the console
  4931. */
  4932. static Error: (message: string) => void;
  4933. /**
  4934. * Gets current log cache (list of logs)
  4935. */
  4936. static readonly LogCache: string;
  4937. /**
  4938. * Clears the log cache
  4939. */
  4940. static ClearLogCache(): void;
  4941. /**
  4942. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4943. */
  4944. static LogLevels: number;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /** @hidden */
  4949. export class _TypeStore {
  4950. /** @hidden */
  4951. static RegisteredTypes: {
  4952. [key: string]: Object;
  4953. };
  4954. /** @hidden */
  4955. static GetClass(fqdn: string): any;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /**
  4960. * Class containing a set of static utilities functions for deep copy.
  4961. */
  4962. export class DeepCopier {
  4963. /**
  4964. * Tries to copy an object by duplicating every property
  4965. * @param source defines the source object
  4966. * @param destination defines the target object
  4967. * @param doNotCopyList defines a list of properties to avoid
  4968. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4969. */
  4970. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4971. }
  4972. }
  4973. declare module BABYLON {
  4974. /**
  4975. * Class containing a set of static utilities functions for precision date
  4976. */
  4977. export class PrecisionDate {
  4978. /**
  4979. * Gets either window.performance.now() if supported or Date.now() else
  4980. */
  4981. static readonly Now: number;
  4982. }
  4983. }
  4984. declare module BABYLON {
  4985. /** @hidden */
  4986. export class _DevTools {
  4987. static WarnImport(name: string): string;
  4988. }
  4989. }
  4990. declare module BABYLON {
  4991. /**
  4992. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4993. */
  4994. export class WebRequest {
  4995. private _xhr;
  4996. /**
  4997. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4998. * i.e. when loading files, where the server/service expects an Authorization header
  4999. */
  5000. static CustomRequestHeaders: {
  5001. [key: string]: string;
  5002. };
  5003. /**
  5004. * Add callback functions in this array to update all the requests before they get sent to the network
  5005. */
  5006. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5007. private _injectCustomRequestHeaders;
  5008. /**
  5009. * Gets or sets a function to be called when loading progress changes
  5010. */
  5011. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5012. /**
  5013. * Returns client's state
  5014. */
  5015. readonly readyState: number;
  5016. /**
  5017. * Returns client's status
  5018. */
  5019. readonly status: number;
  5020. /**
  5021. * Returns client's status as a text
  5022. */
  5023. readonly statusText: string;
  5024. /**
  5025. * Returns client's response
  5026. */
  5027. readonly response: any;
  5028. /**
  5029. * Returns client's response url
  5030. */
  5031. readonly responseURL: string;
  5032. /**
  5033. * Returns client's response as text
  5034. */
  5035. readonly responseText: string;
  5036. /**
  5037. * Gets or sets the expected response type
  5038. */
  5039. responseType: XMLHttpRequestResponseType;
  5040. /** @hidden */
  5041. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5042. /** @hidden */
  5043. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5044. /**
  5045. * Cancels any network activity
  5046. */
  5047. abort(): void;
  5048. /**
  5049. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5050. * @param body defines an optional request body
  5051. */
  5052. send(body?: Document | BodyInit | null): void;
  5053. /**
  5054. * Sets the request method, request URL
  5055. * @param method defines the method to use (GET, POST, etc..)
  5056. * @param url defines the url to connect with
  5057. */
  5058. open(method: string, url: string): void;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to evalaute queries containing `and` and `or` operators
  5064. */
  5065. export class AndOrNotEvaluator {
  5066. /**
  5067. * Evaluate a query
  5068. * @param query defines the query to evaluate
  5069. * @param evaluateCallback defines the callback used to filter result
  5070. * @returns true if the query matches
  5071. */
  5072. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5073. private static _HandleParenthesisContent;
  5074. private static _SimplifyNegation;
  5075. }
  5076. }
  5077. declare module BABYLON {
  5078. /**
  5079. * Class used to store custom tags
  5080. */
  5081. export class Tags {
  5082. /**
  5083. * Adds support for tags on the given object
  5084. * @param obj defines the object to use
  5085. */
  5086. static EnableFor(obj: any): void;
  5087. /**
  5088. * Removes tags support
  5089. * @param obj defines the object to use
  5090. */
  5091. static DisableFor(obj: any): void;
  5092. /**
  5093. * Gets a boolean indicating if the given object has tags
  5094. * @param obj defines the object to use
  5095. * @returns a boolean
  5096. */
  5097. static HasTags(obj: any): boolean;
  5098. /**
  5099. * Gets the tags available on a given object
  5100. * @param obj defines the object to use
  5101. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5102. * @returns the tags
  5103. */
  5104. static GetTags(obj: any, asString?: boolean): any;
  5105. /**
  5106. * Adds tags to an object
  5107. * @param obj defines the object to use
  5108. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5109. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5110. */
  5111. static AddTagsTo(obj: any, tagsString: string): void;
  5112. /**
  5113. * @hidden
  5114. */
  5115. static _AddTagTo(obj: any, tag: string): void;
  5116. /**
  5117. * Removes specific tags from a specific object
  5118. * @param obj defines the object to use
  5119. * @param tagsString defines the tags to remove
  5120. */
  5121. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5122. /**
  5123. * @hidden
  5124. */
  5125. static _RemoveTagFrom(obj: any, tag: string): void;
  5126. /**
  5127. * Defines if tags hosted on an object match a given query
  5128. * @param obj defines the object to use
  5129. * @param tagsQuery defines the tag query
  5130. * @returns a boolean
  5131. */
  5132. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5133. }
  5134. }
  5135. declare module BABYLON {
  5136. /**
  5137. * Manages the defines for the Material
  5138. */
  5139. export class MaterialDefines {
  5140. private _keys;
  5141. private _isDirty;
  5142. /** @hidden */
  5143. _renderId: number;
  5144. /** @hidden */
  5145. _areLightsDirty: boolean;
  5146. /** @hidden */
  5147. _areAttributesDirty: boolean;
  5148. /** @hidden */
  5149. _areTexturesDirty: boolean;
  5150. /** @hidden */
  5151. _areFresnelDirty: boolean;
  5152. /** @hidden */
  5153. _areMiscDirty: boolean;
  5154. /** @hidden */
  5155. _areImageProcessingDirty: boolean;
  5156. /** @hidden */
  5157. _normals: boolean;
  5158. /** @hidden */
  5159. _uvs: boolean;
  5160. /** @hidden */
  5161. _needNormals: boolean;
  5162. /** @hidden */
  5163. _needUVs: boolean;
  5164. /**
  5165. * Specifies if the material needs to be re-calculated
  5166. */
  5167. readonly isDirty: boolean;
  5168. /**
  5169. * Marks the material to indicate that it has been re-calculated
  5170. */
  5171. markAsProcessed(): void;
  5172. /**
  5173. * Marks the material to indicate that it needs to be re-calculated
  5174. */
  5175. markAsUnprocessed(): void;
  5176. /**
  5177. * Marks the material to indicate all of its defines need to be re-calculated
  5178. */
  5179. markAllAsDirty(): void;
  5180. /**
  5181. * Marks the material to indicate that image processing needs to be re-calculated
  5182. */
  5183. markAsImageProcessingDirty(): void;
  5184. /**
  5185. * Marks the material to indicate the lights need to be re-calculated
  5186. */
  5187. markAsLightDirty(): void;
  5188. /**
  5189. * Marks the attribute state as changed
  5190. */
  5191. markAsAttributesDirty(): void;
  5192. /**
  5193. * Marks the texture state as changed
  5194. */
  5195. markAsTexturesDirty(): void;
  5196. /**
  5197. * Marks the fresnel state as changed
  5198. */
  5199. markAsFresnelDirty(): void;
  5200. /**
  5201. * Marks the misc state as changed
  5202. */
  5203. markAsMiscDirty(): void;
  5204. /**
  5205. * Rebuilds the material defines
  5206. */
  5207. rebuild(): void;
  5208. /**
  5209. * Specifies if two material defines are equal
  5210. * @param other - A material define instance to compare to
  5211. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5212. */
  5213. isEqual(other: MaterialDefines): boolean;
  5214. /**
  5215. * Clones this instance's defines to another instance
  5216. * @param other - material defines to clone values to
  5217. */
  5218. cloneTo(other: MaterialDefines): void;
  5219. /**
  5220. * Resets the material define values
  5221. */
  5222. reset(): void;
  5223. /**
  5224. * Converts the material define values to a string
  5225. * @returns - String of material define information
  5226. */
  5227. toString(): string;
  5228. }
  5229. }
  5230. declare module BABYLON {
  5231. /**
  5232. * Class used to store and describe the pipeline context associated with an effect
  5233. */
  5234. export interface IPipelineContext {
  5235. /**
  5236. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5237. */
  5238. isAsync: boolean;
  5239. /**
  5240. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5241. */
  5242. isReady: boolean;
  5243. /** @hidden */
  5244. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5245. }
  5246. }
  5247. declare module BABYLON {
  5248. /**
  5249. * Class used to store gfx data (like WebGLBuffer)
  5250. */
  5251. export class DataBuffer {
  5252. /**
  5253. * Gets or sets the number of objects referencing this buffer
  5254. */
  5255. references: number;
  5256. /** Gets or sets the size of the underlying buffer */
  5257. capacity: number;
  5258. /**
  5259. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5260. */
  5261. is32Bits: boolean;
  5262. /**
  5263. * Gets the underlying buffer
  5264. */
  5265. readonly underlyingResource: any;
  5266. }
  5267. }
  5268. declare module BABYLON {
  5269. /**
  5270. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5271. */
  5272. export class PerformanceMonitor {
  5273. private _enabled;
  5274. private _rollingFrameTime;
  5275. private _lastFrameTimeMs;
  5276. /**
  5277. * constructor
  5278. * @param frameSampleSize The number of samples required to saturate the sliding window
  5279. */
  5280. constructor(frameSampleSize?: number);
  5281. /**
  5282. * Samples current frame
  5283. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5284. */
  5285. sampleFrame(timeMs?: number): void;
  5286. /**
  5287. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5288. */
  5289. readonly averageFrameTime: number;
  5290. /**
  5291. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5292. */
  5293. readonly averageFrameTimeVariance: number;
  5294. /**
  5295. * Returns the frame time of the most recent frame
  5296. */
  5297. readonly instantaneousFrameTime: number;
  5298. /**
  5299. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5300. */
  5301. readonly averageFPS: number;
  5302. /**
  5303. * Returns the average framerate in frames per second using the most recent frame time
  5304. */
  5305. readonly instantaneousFPS: number;
  5306. /**
  5307. * Returns true if enough samples have been taken to completely fill the sliding window
  5308. */
  5309. readonly isSaturated: boolean;
  5310. /**
  5311. * Enables contributions to the sliding window sample set
  5312. */
  5313. enable(): void;
  5314. /**
  5315. * Disables contributions to the sliding window sample set
  5316. * Samples will not be interpolated over the disabled period
  5317. */
  5318. disable(): void;
  5319. /**
  5320. * Returns true if sampling is enabled
  5321. */
  5322. readonly isEnabled: boolean;
  5323. /**
  5324. * Resets performance monitor
  5325. */
  5326. reset(): void;
  5327. }
  5328. /**
  5329. * RollingAverage
  5330. *
  5331. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5332. */
  5333. export class RollingAverage {
  5334. /**
  5335. * Current average
  5336. */
  5337. average: number;
  5338. /**
  5339. * Current variance
  5340. */
  5341. variance: number;
  5342. protected _samples: Array<number>;
  5343. protected _sampleCount: number;
  5344. protected _pos: number;
  5345. protected _m2: number;
  5346. /**
  5347. * constructor
  5348. * @param length The number of samples required to saturate the sliding window
  5349. */
  5350. constructor(length: number);
  5351. /**
  5352. * Adds a sample to the sample set
  5353. * @param v The sample value
  5354. */
  5355. add(v: number): void;
  5356. /**
  5357. * Returns previously added values or null if outside of history or outside the sliding window domain
  5358. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5359. * @return Value previously recorded with add() or null if outside of range
  5360. */
  5361. history(i: number): number;
  5362. /**
  5363. * Returns true if enough samples have been taken to completely fill the sliding window
  5364. * @return true if sample-set saturated
  5365. */
  5366. isSaturated(): boolean;
  5367. /**
  5368. * Resets the rolling average (equivalent to 0 samples taken so far)
  5369. */
  5370. reset(): void;
  5371. /**
  5372. * Wraps a value around the sample range boundaries
  5373. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5374. * @return Wrapped position in sample range
  5375. */
  5376. protected _wrapPosition(i: number): number;
  5377. }
  5378. }
  5379. declare module BABYLON {
  5380. /**
  5381. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5382. * The underlying implementation relies on an associative array to ensure the best performances.
  5383. * The value can be anything including 'null' but except 'undefined'
  5384. */
  5385. export class StringDictionary<T> {
  5386. /**
  5387. * This will clear this dictionary and copy the content from the 'source' one.
  5388. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5389. * @param source the dictionary to take the content from and copy to this dictionary
  5390. */
  5391. copyFrom(source: StringDictionary<T>): void;
  5392. /**
  5393. * Get a value based from its key
  5394. * @param key the given key to get the matching value from
  5395. * @return the value if found, otherwise undefined is returned
  5396. */
  5397. get(key: string): T | undefined;
  5398. /**
  5399. * Get a value from its key or add it if it doesn't exist.
  5400. * This method will ensure you that a given key/data will be present in the dictionary.
  5401. * @param key the given key to get the matching value from
  5402. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5403. * The factory will only be invoked if there's no data for the given key.
  5404. * @return the value corresponding to the key.
  5405. */
  5406. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5407. /**
  5408. * Get a value from its key if present in the dictionary otherwise add it
  5409. * @param key the key to get the value from
  5410. * @param val if there's no such key/value pair in the dictionary add it with this value
  5411. * @return the value corresponding to the key
  5412. */
  5413. getOrAdd(key: string, val: T): T;
  5414. /**
  5415. * Check if there's a given key in the dictionary
  5416. * @param key the key to check for
  5417. * @return true if the key is present, false otherwise
  5418. */
  5419. contains(key: string): boolean;
  5420. /**
  5421. * Add a new key and its corresponding value
  5422. * @param key the key to add
  5423. * @param value the value corresponding to the key
  5424. * @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
  5425. */
  5426. add(key: string, value: T): boolean;
  5427. /**
  5428. * Update a specific value associated to a key
  5429. * @param key defines the key to use
  5430. * @param value defines the value to store
  5431. * @returns true if the value was updated (or false if the key was not found)
  5432. */
  5433. set(key: string, value: T): boolean;
  5434. /**
  5435. * Get the element of the given key and remove it from the dictionary
  5436. * @param key defines the key to search
  5437. * @returns the value associated with the key or null if not found
  5438. */
  5439. getAndRemove(key: string): Nullable<T>;
  5440. /**
  5441. * Remove a key/value from the dictionary.
  5442. * @param key the key to remove
  5443. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5444. */
  5445. remove(key: string): boolean;
  5446. /**
  5447. * Clear the whole content of the dictionary
  5448. */
  5449. clear(): void;
  5450. /**
  5451. * Gets the current count
  5452. */
  5453. readonly count: number;
  5454. /**
  5455. * Execute a callback on each key/val of the dictionary.
  5456. * Note that you can remove any element in this dictionary in the callback implementation
  5457. * @param callback the callback to execute on a given key/value pair
  5458. */
  5459. forEach(callback: (key: string, val: T) => void): void;
  5460. /**
  5461. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5462. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5463. * Note that you can remove any element in this dictionary in the callback implementation
  5464. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5465. * @returns the first item
  5466. */
  5467. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5468. private _count;
  5469. private _data;
  5470. }
  5471. }
  5472. declare module BABYLON {
  5473. /**
  5474. * Helper class that provides a small promise polyfill
  5475. */
  5476. export class PromisePolyfill {
  5477. /**
  5478. * Static function used to check if the polyfill is required
  5479. * If this is the case then the function will inject the polyfill to window.Promise
  5480. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5481. */
  5482. static Apply(force?: boolean): void;
  5483. }
  5484. }
  5485. declare module BABYLON {
  5486. /**
  5487. * Class used to store data that will be store in GPU memory
  5488. */
  5489. export class Buffer {
  5490. private _engine;
  5491. private _buffer;
  5492. /** @hidden */
  5493. _data: Nullable<DataArray>;
  5494. private _updatable;
  5495. private _instanced;
  5496. /**
  5497. * Gets the byte stride.
  5498. */
  5499. readonly byteStride: number;
  5500. /**
  5501. * Constructor
  5502. * @param engine the engine
  5503. * @param data the data to use for this buffer
  5504. * @param updatable whether the data is updatable
  5505. * @param stride the stride (optional)
  5506. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5507. * @param instanced whether the buffer is instanced (optional)
  5508. * @param useBytes set to true if the stride in in bytes (optional)
  5509. */
  5510. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5511. /**
  5512. * Create a new VertexBuffer based on the current buffer
  5513. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5514. * @param offset defines offset in the buffer (0 by default)
  5515. * @param size defines the size in floats of attributes (position is 3 for instance)
  5516. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5517. * @param instanced defines if the vertex buffer contains indexed data
  5518. * @param useBytes defines if the offset and stride are in bytes
  5519. * @returns the new vertex buffer
  5520. */
  5521. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5522. /**
  5523. * Gets a boolean indicating if the Buffer is updatable?
  5524. * @returns true if the buffer is updatable
  5525. */
  5526. isUpdatable(): boolean;
  5527. /**
  5528. * Gets current buffer's data
  5529. * @returns a DataArray or null
  5530. */
  5531. getData(): Nullable<DataArray>;
  5532. /**
  5533. * Gets underlying native buffer
  5534. * @returns underlying native buffer
  5535. */
  5536. getBuffer(): Nullable<DataBuffer>;
  5537. /**
  5538. * Gets the stride in float32 units (i.e. byte stride / 4).
  5539. * May not be an integer if the byte stride is not divisible by 4.
  5540. * DEPRECATED. Use byteStride instead.
  5541. * @returns the stride in float32 units
  5542. */
  5543. getStrideSize(): number;
  5544. /**
  5545. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5546. * @param data defines the data to store
  5547. */
  5548. create(data?: Nullable<DataArray>): void;
  5549. /** @hidden */
  5550. _rebuild(): void;
  5551. /**
  5552. * Update current buffer data
  5553. * @param data defines the data to store
  5554. */
  5555. update(data: DataArray): void;
  5556. /**
  5557. * Updates the data directly.
  5558. * @param data the new data
  5559. * @param offset the new offset
  5560. * @param vertexCount the vertex count (optional)
  5561. * @param useBytes set to true if the offset is in bytes
  5562. */
  5563. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5564. /**
  5565. * Release all resources
  5566. */
  5567. dispose(): void;
  5568. }
  5569. /**
  5570. * Specialized buffer used to store vertex data
  5571. */
  5572. export class VertexBuffer {
  5573. /** @hidden */
  5574. _buffer: Buffer;
  5575. private _kind;
  5576. private _size;
  5577. private _ownsBuffer;
  5578. private _instanced;
  5579. private _instanceDivisor;
  5580. /**
  5581. * The byte type.
  5582. */
  5583. static readonly BYTE: number;
  5584. /**
  5585. * The unsigned byte type.
  5586. */
  5587. static readonly UNSIGNED_BYTE: number;
  5588. /**
  5589. * The short type.
  5590. */
  5591. static readonly SHORT: number;
  5592. /**
  5593. * The unsigned short type.
  5594. */
  5595. static readonly UNSIGNED_SHORT: number;
  5596. /**
  5597. * The integer type.
  5598. */
  5599. static readonly INT: number;
  5600. /**
  5601. * The unsigned integer type.
  5602. */
  5603. static readonly UNSIGNED_INT: number;
  5604. /**
  5605. * The float type.
  5606. */
  5607. static readonly FLOAT: number;
  5608. /**
  5609. * Gets or sets the instance divisor when in instanced mode
  5610. */
  5611. instanceDivisor: number;
  5612. /**
  5613. * Gets the byte stride.
  5614. */
  5615. readonly byteStride: number;
  5616. /**
  5617. * Gets the byte offset.
  5618. */
  5619. readonly byteOffset: number;
  5620. /**
  5621. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5622. */
  5623. readonly normalized: boolean;
  5624. /**
  5625. * Gets the data type of each component in the array.
  5626. */
  5627. readonly type: number;
  5628. /**
  5629. * Constructor
  5630. * @param engine the engine
  5631. * @param data the data to use for this vertex buffer
  5632. * @param kind the vertex buffer kind
  5633. * @param updatable whether the data is updatable
  5634. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5635. * @param stride the stride (optional)
  5636. * @param instanced whether the buffer is instanced (optional)
  5637. * @param offset the offset of the data (optional)
  5638. * @param size the number of components (optional)
  5639. * @param type the type of the component (optional)
  5640. * @param normalized whether the data contains normalized data (optional)
  5641. * @param useBytes set to true if stride and offset are in bytes (optional)
  5642. */
  5643. 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);
  5644. /** @hidden */
  5645. _rebuild(): void;
  5646. /**
  5647. * Returns the kind of the VertexBuffer (string)
  5648. * @returns a string
  5649. */
  5650. getKind(): string;
  5651. /**
  5652. * Gets a boolean indicating if the VertexBuffer is updatable?
  5653. * @returns true if the buffer is updatable
  5654. */
  5655. isUpdatable(): boolean;
  5656. /**
  5657. * Gets current buffer's data
  5658. * @returns a DataArray or null
  5659. */
  5660. getData(): Nullable<DataArray>;
  5661. /**
  5662. * Gets underlying native buffer
  5663. * @returns underlying native buffer
  5664. */
  5665. getBuffer(): Nullable<DataBuffer>;
  5666. /**
  5667. * Gets the stride in float32 units (i.e. byte stride / 4).
  5668. * May not be an integer if the byte stride is not divisible by 4.
  5669. * DEPRECATED. Use byteStride instead.
  5670. * @returns the stride in float32 units
  5671. */
  5672. getStrideSize(): number;
  5673. /**
  5674. * Returns the offset as a multiple of the type byte length.
  5675. * DEPRECATED. Use byteOffset instead.
  5676. * @returns the offset in bytes
  5677. */
  5678. getOffset(): number;
  5679. /**
  5680. * Returns the number of components per vertex attribute (integer)
  5681. * @returns the size in float
  5682. */
  5683. getSize(): number;
  5684. /**
  5685. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5686. * @returns true if this buffer is instanced
  5687. */
  5688. getIsInstanced(): boolean;
  5689. /**
  5690. * Returns the instancing divisor, zero for non-instanced (integer).
  5691. * @returns a number
  5692. */
  5693. getInstanceDivisor(): number;
  5694. /**
  5695. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5696. * @param data defines the data to store
  5697. */
  5698. create(data?: DataArray): void;
  5699. /**
  5700. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5701. * This function will create a new buffer if the current one is not updatable
  5702. * @param data defines the data to store
  5703. */
  5704. update(data: DataArray): void;
  5705. /**
  5706. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5707. * Returns the directly updated WebGLBuffer.
  5708. * @param data the new data
  5709. * @param offset the new offset
  5710. * @param useBytes set to true if the offset is in bytes
  5711. */
  5712. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5713. /**
  5714. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5715. */
  5716. dispose(): void;
  5717. /**
  5718. * Enumerates each value of this vertex buffer as numbers.
  5719. * @param count the number of values to enumerate
  5720. * @param callback the callback function called for each value
  5721. */
  5722. forEach(count: number, callback: (value: number, index: number) => void): void;
  5723. /**
  5724. * Positions
  5725. */
  5726. static readonly PositionKind: string;
  5727. /**
  5728. * Normals
  5729. */
  5730. static readonly NormalKind: string;
  5731. /**
  5732. * Tangents
  5733. */
  5734. static readonly TangentKind: string;
  5735. /**
  5736. * Texture coordinates
  5737. */
  5738. static readonly UVKind: string;
  5739. /**
  5740. * Texture coordinates 2
  5741. */
  5742. static readonly UV2Kind: string;
  5743. /**
  5744. * Texture coordinates 3
  5745. */
  5746. static readonly UV3Kind: string;
  5747. /**
  5748. * Texture coordinates 4
  5749. */
  5750. static readonly UV4Kind: string;
  5751. /**
  5752. * Texture coordinates 5
  5753. */
  5754. static readonly UV5Kind: string;
  5755. /**
  5756. * Texture coordinates 6
  5757. */
  5758. static readonly UV6Kind: string;
  5759. /**
  5760. * Colors
  5761. */
  5762. static readonly ColorKind: string;
  5763. /**
  5764. * Matrix indices (for bones)
  5765. */
  5766. static readonly MatricesIndicesKind: string;
  5767. /**
  5768. * Matrix weights (for bones)
  5769. */
  5770. static readonly MatricesWeightsKind: string;
  5771. /**
  5772. * Additional matrix indices (for bones)
  5773. */
  5774. static readonly MatricesIndicesExtraKind: string;
  5775. /**
  5776. * Additional matrix weights (for bones)
  5777. */
  5778. static readonly MatricesWeightsExtraKind: string;
  5779. /**
  5780. * Deduces the stride given a kind.
  5781. * @param kind The kind string to deduce
  5782. * @returns The deduced stride
  5783. */
  5784. static DeduceStride(kind: string): number;
  5785. /**
  5786. * Gets the byte length of the given type.
  5787. * @param type the type
  5788. * @returns the number of bytes
  5789. */
  5790. static GetTypeByteLength(type: number): number;
  5791. /**
  5792. * Enumerates each value of the given parameters as numbers.
  5793. * @param data the data to enumerate
  5794. * @param byteOffset the byte offset of the data
  5795. * @param byteStride the byte stride of the data
  5796. * @param componentCount the number of components per element
  5797. * @param componentType the type of the component
  5798. * @param count the total number of components
  5799. * @param normalized whether the data is normalized
  5800. * @param callback the callback function called for each value
  5801. */
  5802. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5803. private static _GetFloatValue;
  5804. }
  5805. }
  5806. declare module BABYLON {
  5807. /**
  5808. * Class representing spherical harmonics coefficients to the 3rd degree
  5809. */
  5810. export class SphericalHarmonics {
  5811. /**
  5812. * Defines whether or not the harmonics have been prescaled for rendering.
  5813. */
  5814. preScaled: boolean;
  5815. /**
  5816. * The l0,0 coefficients of the spherical harmonics
  5817. */
  5818. l00: Vector3;
  5819. /**
  5820. * The l1,-1 coefficients of the spherical harmonics
  5821. */
  5822. l1_1: Vector3;
  5823. /**
  5824. * The l1,0 coefficients of the spherical harmonics
  5825. */
  5826. l10: Vector3;
  5827. /**
  5828. * The l1,1 coefficients of the spherical harmonics
  5829. */
  5830. l11: Vector3;
  5831. /**
  5832. * The l2,-2 coefficients of the spherical harmonics
  5833. */
  5834. l2_2: Vector3;
  5835. /**
  5836. * The l2,-1 coefficients of the spherical harmonics
  5837. */
  5838. l2_1: Vector3;
  5839. /**
  5840. * The l2,0 coefficients of the spherical harmonics
  5841. */
  5842. l20: Vector3;
  5843. /**
  5844. * The l2,1 coefficients of the spherical harmonics
  5845. */
  5846. l21: Vector3;
  5847. /**
  5848. * The l2,2 coefficients of the spherical harmonics
  5849. */
  5850. l22: Vector3;
  5851. /**
  5852. * Adds a light to the spherical harmonics
  5853. * @param direction the direction of the light
  5854. * @param color the color of the light
  5855. * @param deltaSolidAngle the delta solid angle of the light
  5856. */
  5857. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5858. /**
  5859. * Scales the spherical harmonics by the given amount
  5860. * @param scale the amount to scale
  5861. */
  5862. scaleInPlace(scale: number): void;
  5863. /**
  5864. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5865. *
  5866. * ```
  5867. * E_lm = A_l * L_lm
  5868. * ```
  5869. *
  5870. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5871. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5872. * the scaling factors are given in equation 9.
  5873. */
  5874. convertIncidentRadianceToIrradiance(): void;
  5875. /**
  5876. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5877. *
  5878. * ```
  5879. * L = (1/pi) * E * rho
  5880. * ```
  5881. *
  5882. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5883. */
  5884. convertIrradianceToLambertianRadiance(): void;
  5885. /**
  5886. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5887. * required operations at run time.
  5888. *
  5889. * This is simply done by scaling back the SH with Ylm constants parameter.
  5890. * The trigonometric part being applied by the shader at run time.
  5891. */
  5892. preScaleForRendering(): void;
  5893. /**
  5894. * Constructs a spherical harmonics from an array.
  5895. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5896. * @returns the spherical harmonics
  5897. */
  5898. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5899. /**
  5900. * Gets the spherical harmonics from polynomial
  5901. * @param polynomial the spherical polynomial
  5902. * @returns the spherical harmonics
  5903. */
  5904. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5905. }
  5906. /**
  5907. * Class representing spherical polynomial coefficients to the 3rd degree
  5908. */
  5909. export class SphericalPolynomial {
  5910. private _harmonics;
  5911. /**
  5912. * The spherical harmonics used to create the polynomials.
  5913. */
  5914. readonly preScaledHarmonics: SphericalHarmonics;
  5915. /**
  5916. * The x coefficients of the spherical polynomial
  5917. */
  5918. x: Vector3;
  5919. /**
  5920. * The y coefficients of the spherical polynomial
  5921. */
  5922. y: Vector3;
  5923. /**
  5924. * The z coefficients of the spherical polynomial
  5925. */
  5926. z: Vector3;
  5927. /**
  5928. * The xx coefficients of the spherical polynomial
  5929. */
  5930. xx: Vector3;
  5931. /**
  5932. * The yy coefficients of the spherical polynomial
  5933. */
  5934. yy: Vector3;
  5935. /**
  5936. * The zz coefficients of the spherical polynomial
  5937. */
  5938. zz: Vector3;
  5939. /**
  5940. * The xy coefficients of the spherical polynomial
  5941. */
  5942. xy: Vector3;
  5943. /**
  5944. * The yz coefficients of the spherical polynomial
  5945. */
  5946. yz: Vector3;
  5947. /**
  5948. * The zx coefficients of the spherical polynomial
  5949. */
  5950. zx: Vector3;
  5951. /**
  5952. * Adds an ambient color to the spherical polynomial
  5953. * @param color the color to add
  5954. */
  5955. addAmbient(color: Color3): void;
  5956. /**
  5957. * Scales the spherical polynomial by the given amount
  5958. * @param scale the amount to scale
  5959. */
  5960. scaleInPlace(scale: number): void;
  5961. /**
  5962. * Gets the spherical polynomial from harmonics
  5963. * @param harmonics the spherical harmonics
  5964. * @returns the spherical polynomial
  5965. */
  5966. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5967. /**
  5968. * Constructs a spherical polynomial from an array.
  5969. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5970. * @returns the spherical polynomial
  5971. */
  5972. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5978. */
  5979. export interface CubeMapInfo {
  5980. /**
  5981. * The pixel array for the front face.
  5982. * This is stored in format, left to right, up to down format.
  5983. */
  5984. front: Nullable<ArrayBufferView>;
  5985. /**
  5986. * The pixel array for the back face.
  5987. * This is stored in format, left to right, up to down format.
  5988. */
  5989. back: Nullable<ArrayBufferView>;
  5990. /**
  5991. * The pixel array for the left face.
  5992. * This is stored in format, left to right, up to down format.
  5993. */
  5994. left: Nullable<ArrayBufferView>;
  5995. /**
  5996. * The pixel array for the right face.
  5997. * This is stored in format, left to right, up to down format.
  5998. */
  5999. right: Nullable<ArrayBufferView>;
  6000. /**
  6001. * The pixel array for the up face.
  6002. * This is stored in format, left to right, up to down format.
  6003. */
  6004. up: Nullable<ArrayBufferView>;
  6005. /**
  6006. * The pixel array for the down face.
  6007. * This is stored in format, left to right, up to down format.
  6008. */
  6009. down: Nullable<ArrayBufferView>;
  6010. /**
  6011. * The size of the cubemap stored.
  6012. *
  6013. * Each faces will be size * size pixels.
  6014. */
  6015. size: number;
  6016. /**
  6017. * The format of the texture.
  6018. *
  6019. * RGBA, RGB.
  6020. */
  6021. format: number;
  6022. /**
  6023. * The type of the texture data.
  6024. *
  6025. * UNSIGNED_INT, FLOAT.
  6026. */
  6027. type: number;
  6028. /**
  6029. * Specifies whether the texture is in gamma space.
  6030. */
  6031. gammaSpace: boolean;
  6032. }
  6033. /**
  6034. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6035. */
  6036. export class PanoramaToCubeMapTools {
  6037. private static FACE_FRONT;
  6038. private static FACE_BACK;
  6039. private static FACE_RIGHT;
  6040. private static FACE_LEFT;
  6041. private static FACE_DOWN;
  6042. private static FACE_UP;
  6043. /**
  6044. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6045. *
  6046. * @param float32Array The source data.
  6047. * @param inputWidth The width of the input panorama.
  6048. * @param inputHeight The height of the input panorama.
  6049. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6050. * @return The cubemap data
  6051. */
  6052. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6053. private static CreateCubemapTexture;
  6054. private static CalcProjectionSpherical;
  6055. }
  6056. }
  6057. declare module BABYLON {
  6058. /**
  6059. * Helper class dealing with the extraction of spherical polynomial dataArray
  6060. * from a cube map.
  6061. */
  6062. export class CubeMapToSphericalPolynomialTools {
  6063. private static FileFaces;
  6064. /**
  6065. * Converts a texture to the according Spherical Polynomial data.
  6066. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6067. *
  6068. * @param texture The texture to extract the information from.
  6069. * @return The Spherical Polynomial data.
  6070. */
  6071. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6072. /**
  6073. * Converts a cubemap to the according Spherical Polynomial data.
  6074. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6075. *
  6076. * @param cubeInfo The Cube map to extract the information from.
  6077. * @return The Spherical Polynomial data.
  6078. */
  6079. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. /**
  6084. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6085. * during the life time of the application.
  6086. */
  6087. export class EngineStore {
  6088. /** Gets the list of created engines */
  6089. static Instances: Engine[];
  6090. /**
  6091. * Gets the latest created engine
  6092. */
  6093. static readonly LastCreatedEngine: Nullable<Engine>;
  6094. /**
  6095. * Gets the latest created scene
  6096. */
  6097. static readonly LastCreatedScene: Nullable<Scene>;
  6098. }
  6099. }
  6100. declare module BABYLON {
  6101. /**
  6102. * Define options used to create a render target texture
  6103. */
  6104. export class RenderTargetCreationOptions {
  6105. /**
  6106. * Specifies is mipmaps must be generated
  6107. */
  6108. generateMipMaps?: boolean;
  6109. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6110. generateDepthBuffer?: boolean;
  6111. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6112. generateStencilBuffer?: boolean;
  6113. /** Defines texture type (int by default) */
  6114. type?: number;
  6115. /** Defines sampling mode (trilinear by default) */
  6116. samplingMode?: number;
  6117. /** Defines format (RGBA by default) */
  6118. format?: number;
  6119. }
  6120. }
  6121. declare module BABYLON {
  6122. /**
  6123. * @hidden
  6124. **/
  6125. export class _AlphaState {
  6126. private _isAlphaBlendDirty;
  6127. private _isBlendFunctionParametersDirty;
  6128. private _isBlendEquationParametersDirty;
  6129. private _isBlendConstantsDirty;
  6130. private _alphaBlend;
  6131. private _blendFunctionParameters;
  6132. private _blendEquationParameters;
  6133. private _blendConstants;
  6134. /**
  6135. * Initializes the state.
  6136. */
  6137. constructor();
  6138. readonly isDirty: boolean;
  6139. alphaBlend: boolean;
  6140. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6141. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6142. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6143. reset(): void;
  6144. apply(gl: WebGLRenderingContext): void;
  6145. }
  6146. }
  6147. declare module BABYLON {
  6148. /**
  6149. * @hidden
  6150. **/
  6151. export class _DepthCullingState {
  6152. private _isDepthTestDirty;
  6153. private _isDepthMaskDirty;
  6154. private _isDepthFuncDirty;
  6155. private _isCullFaceDirty;
  6156. private _isCullDirty;
  6157. private _isZOffsetDirty;
  6158. private _isFrontFaceDirty;
  6159. private _depthTest;
  6160. private _depthMask;
  6161. private _depthFunc;
  6162. private _cull;
  6163. private _cullFace;
  6164. private _zOffset;
  6165. private _frontFace;
  6166. /**
  6167. * Initializes the state.
  6168. */
  6169. constructor();
  6170. readonly isDirty: boolean;
  6171. zOffset: number;
  6172. cullFace: Nullable<number>;
  6173. cull: Nullable<boolean>;
  6174. depthFunc: Nullable<number>;
  6175. depthMask: boolean;
  6176. depthTest: boolean;
  6177. frontFace: Nullable<number>;
  6178. reset(): void;
  6179. apply(gl: WebGLRenderingContext): void;
  6180. }
  6181. }
  6182. declare module BABYLON {
  6183. /**
  6184. * @hidden
  6185. **/
  6186. export class _StencilState {
  6187. /** 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 */
  6188. static readonly ALWAYS: number;
  6189. /** Passed to stencilOperation to specify that stencil value must be kept */
  6190. static readonly KEEP: number;
  6191. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6192. static readonly REPLACE: number;
  6193. private _isStencilTestDirty;
  6194. private _isStencilMaskDirty;
  6195. private _isStencilFuncDirty;
  6196. private _isStencilOpDirty;
  6197. private _stencilTest;
  6198. private _stencilMask;
  6199. private _stencilFunc;
  6200. private _stencilFuncRef;
  6201. private _stencilFuncMask;
  6202. private _stencilOpStencilFail;
  6203. private _stencilOpDepthFail;
  6204. private _stencilOpStencilDepthPass;
  6205. readonly isDirty: boolean;
  6206. stencilFunc: number;
  6207. stencilFuncRef: number;
  6208. stencilFuncMask: number;
  6209. stencilOpStencilFail: number;
  6210. stencilOpDepthFail: number;
  6211. stencilOpStencilDepthPass: number;
  6212. stencilMask: number;
  6213. stencilTest: boolean;
  6214. constructor();
  6215. reset(): void;
  6216. apply(gl: WebGLRenderingContext): void;
  6217. }
  6218. }
  6219. declare module BABYLON {
  6220. /**
  6221. * @hidden
  6222. **/
  6223. export class _TimeToken {
  6224. _startTimeQuery: Nullable<WebGLQuery>;
  6225. _endTimeQuery: Nullable<WebGLQuery>;
  6226. _timeElapsedQuery: Nullable<WebGLQuery>;
  6227. _timeElapsedQueryEnded: boolean;
  6228. }
  6229. }
  6230. declare module BABYLON {
  6231. /**
  6232. * Class used to store data associated with WebGL texture data for the engine
  6233. * This class should not be used directly
  6234. */
  6235. export class InternalTexture {
  6236. /** hidden */
  6237. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6238. /**
  6239. * The source of the texture data is unknown
  6240. */
  6241. static DATASOURCE_UNKNOWN: number;
  6242. /**
  6243. * Texture data comes from an URL
  6244. */
  6245. static DATASOURCE_URL: number;
  6246. /**
  6247. * Texture data is only used for temporary storage
  6248. */
  6249. static DATASOURCE_TEMP: number;
  6250. /**
  6251. * Texture data comes from raw data (ArrayBuffer)
  6252. */
  6253. static DATASOURCE_RAW: number;
  6254. /**
  6255. * Texture content is dynamic (video or dynamic texture)
  6256. */
  6257. static DATASOURCE_DYNAMIC: number;
  6258. /**
  6259. * Texture content is generated by rendering to it
  6260. */
  6261. static DATASOURCE_RENDERTARGET: number;
  6262. /**
  6263. * Texture content is part of a multi render target process
  6264. */
  6265. static DATASOURCE_MULTIRENDERTARGET: number;
  6266. /**
  6267. * Texture data comes from a cube data file
  6268. */
  6269. static DATASOURCE_CUBE: number;
  6270. /**
  6271. * Texture data comes from a raw cube data
  6272. */
  6273. static DATASOURCE_CUBERAW: number;
  6274. /**
  6275. * Texture data come from a prefiltered cube data file
  6276. */
  6277. static DATASOURCE_CUBEPREFILTERED: number;
  6278. /**
  6279. * Texture content is raw 3D data
  6280. */
  6281. static DATASOURCE_RAW3D: number;
  6282. /**
  6283. * Texture content is a depth texture
  6284. */
  6285. static DATASOURCE_DEPTHTEXTURE: number;
  6286. /**
  6287. * Texture data comes from a raw cube data encoded with RGBD
  6288. */
  6289. static DATASOURCE_CUBERAW_RGBD: number;
  6290. /**
  6291. * Defines if the texture is ready
  6292. */
  6293. isReady: boolean;
  6294. /**
  6295. * Defines if the texture is a cube texture
  6296. */
  6297. isCube: boolean;
  6298. /**
  6299. * Defines if the texture contains 3D data
  6300. */
  6301. is3D: boolean;
  6302. /**
  6303. * Defines if the texture contains multiview data
  6304. */
  6305. isMultiview: boolean;
  6306. /**
  6307. * Gets the URL used to load this texture
  6308. */
  6309. url: string;
  6310. /**
  6311. * Gets the sampling mode of the texture
  6312. */
  6313. samplingMode: number;
  6314. /**
  6315. * Gets a boolean indicating if the texture needs mipmaps generation
  6316. */
  6317. generateMipMaps: boolean;
  6318. /**
  6319. * Gets the number of samples used by the texture (WebGL2+ only)
  6320. */
  6321. samples: number;
  6322. /**
  6323. * Gets the type of the texture (int, float...)
  6324. */
  6325. type: number;
  6326. /**
  6327. * Gets the format of the texture (RGB, RGBA...)
  6328. */
  6329. format: number;
  6330. /**
  6331. * Observable called when the texture is loaded
  6332. */
  6333. onLoadedObservable: Observable<InternalTexture>;
  6334. /**
  6335. * Gets the width of the texture
  6336. */
  6337. width: number;
  6338. /**
  6339. * Gets the height of the texture
  6340. */
  6341. height: number;
  6342. /**
  6343. * Gets the depth of the texture
  6344. */
  6345. depth: number;
  6346. /**
  6347. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6348. */
  6349. baseWidth: number;
  6350. /**
  6351. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6352. */
  6353. baseHeight: number;
  6354. /**
  6355. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6356. */
  6357. baseDepth: number;
  6358. /**
  6359. * Gets a boolean indicating if the texture is inverted on Y axis
  6360. */
  6361. invertY: boolean;
  6362. /** @hidden */
  6363. _invertVScale: boolean;
  6364. /** @hidden */
  6365. _associatedChannel: number;
  6366. /** @hidden */
  6367. _dataSource: number;
  6368. /** @hidden */
  6369. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6370. /** @hidden */
  6371. _bufferView: Nullable<ArrayBufferView>;
  6372. /** @hidden */
  6373. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6374. /** @hidden */
  6375. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6376. /** @hidden */
  6377. _size: number;
  6378. /** @hidden */
  6379. _extension: string;
  6380. /** @hidden */
  6381. _files: Nullable<string[]>;
  6382. /** @hidden */
  6383. _workingCanvas: Nullable<HTMLCanvasElement>;
  6384. /** @hidden */
  6385. _workingContext: Nullable<CanvasRenderingContext2D>;
  6386. /** @hidden */
  6387. _framebuffer: Nullable<WebGLFramebuffer>;
  6388. /** @hidden */
  6389. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6390. /** @hidden */
  6391. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6392. /** @hidden */
  6393. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6394. /** @hidden */
  6395. _attachments: Nullable<number[]>;
  6396. /** @hidden */
  6397. _cachedCoordinatesMode: Nullable<number>;
  6398. /** @hidden */
  6399. _cachedWrapU: Nullable<number>;
  6400. /** @hidden */
  6401. _cachedWrapV: Nullable<number>;
  6402. /** @hidden */
  6403. _cachedWrapR: Nullable<number>;
  6404. /** @hidden */
  6405. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6406. /** @hidden */
  6407. _isDisabled: boolean;
  6408. /** @hidden */
  6409. _compression: Nullable<string>;
  6410. /** @hidden */
  6411. _generateStencilBuffer: boolean;
  6412. /** @hidden */
  6413. _generateDepthBuffer: boolean;
  6414. /** @hidden */
  6415. _comparisonFunction: number;
  6416. /** @hidden */
  6417. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6418. /** @hidden */
  6419. _lodGenerationScale: number;
  6420. /** @hidden */
  6421. _lodGenerationOffset: number;
  6422. /** @hidden */
  6423. _colorTextureArray: Nullable<WebGLTexture>;
  6424. /** @hidden */
  6425. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6426. /** @hidden */
  6427. _lodTextureHigh: Nullable<BaseTexture>;
  6428. /** @hidden */
  6429. _lodTextureMid: Nullable<BaseTexture>;
  6430. /** @hidden */
  6431. _lodTextureLow: Nullable<BaseTexture>;
  6432. /** @hidden */
  6433. _isRGBD: boolean;
  6434. /** @hidden */
  6435. _webGLTexture: Nullable<WebGLTexture>;
  6436. /** @hidden */
  6437. _references: number;
  6438. private _engine;
  6439. /**
  6440. * Gets the Engine the texture belongs to.
  6441. * @returns The babylon engine
  6442. */
  6443. getEngine(): Engine;
  6444. /**
  6445. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6446. */
  6447. readonly dataSource: number;
  6448. /**
  6449. * Creates a new InternalTexture
  6450. * @param engine defines the engine to use
  6451. * @param dataSource defines the type of data that will be used
  6452. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6453. */
  6454. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6455. /**
  6456. * Increments the number of references (ie. the number of Texture that point to it)
  6457. */
  6458. incrementReferences(): void;
  6459. /**
  6460. * Change the size of the texture (not the size of the content)
  6461. * @param width defines the new width
  6462. * @param height defines the new height
  6463. * @param depth defines the new depth (1 by default)
  6464. */
  6465. updateSize(width: int, height: int, depth?: int): void;
  6466. /** @hidden */
  6467. _rebuild(): void;
  6468. /** @hidden */
  6469. _swapAndDie(target: InternalTexture): void;
  6470. /**
  6471. * Dispose the current allocated resources
  6472. */
  6473. dispose(): void;
  6474. }
  6475. }
  6476. declare module BABYLON {
  6477. /**
  6478. * This represents the main contract an easing function should follow.
  6479. * Easing functions are used throughout the animation system.
  6480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6481. */
  6482. export interface IEasingFunction {
  6483. /**
  6484. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6485. * of the easing function.
  6486. * The link below provides some of the most common examples of easing functions.
  6487. * @see https://easings.net/
  6488. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6489. * @returns the corresponding value on the curve defined by the easing function
  6490. */
  6491. ease(gradient: number): number;
  6492. }
  6493. /**
  6494. * Base class used for every default easing function.
  6495. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6496. */
  6497. export class EasingFunction implements IEasingFunction {
  6498. /**
  6499. * Interpolation follows the mathematical formula associated with the easing function.
  6500. */
  6501. static readonly EASINGMODE_EASEIN: number;
  6502. /**
  6503. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6504. */
  6505. static readonly EASINGMODE_EASEOUT: number;
  6506. /**
  6507. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6508. */
  6509. static readonly EASINGMODE_EASEINOUT: number;
  6510. private _easingMode;
  6511. /**
  6512. * Sets the easing mode of the current function.
  6513. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6514. */
  6515. setEasingMode(easingMode: number): void;
  6516. /**
  6517. * Gets the current easing mode.
  6518. * @returns the easing mode
  6519. */
  6520. getEasingMode(): number;
  6521. /**
  6522. * @hidden
  6523. */
  6524. easeInCore(gradient: number): number;
  6525. /**
  6526. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6527. * of the easing function.
  6528. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6529. * @returns the corresponding value on the curve defined by the easing function
  6530. */
  6531. ease(gradient: number): number;
  6532. }
  6533. /**
  6534. * Easing function with a circle shape (see link below).
  6535. * @see https://easings.net/#easeInCirc
  6536. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6537. */
  6538. export class CircleEase extends EasingFunction implements IEasingFunction {
  6539. /** @hidden */
  6540. easeInCore(gradient: number): number;
  6541. }
  6542. /**
  6543. * Easing function with a ease back shape (see link below).
  6544. * @see https://easings.net/#easeInBack
  6545. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6546. */
  6547. export class BackEase extends EasingFunction implements IEasingFunction {
  6548. /** Defines the amplitude of the function */
  6549. amplitude: number;
  6550. /**
  6551. * Instantiates a back ease easing
  6552. * @see https://easings.net/#easeInBack
  6553. * @param amplitude Defines the amplitude of the function
  6554. */
  6555. constructor(
  6556. /** Defines the amplitude of the function */
  6557. amplitude?: number);
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with a bouncing shape (see link below).
  6563. * @see https://easings.net/#easeInBounce
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class BounceEase extends EasingFunction implements IEasingFunction {
  6567. /** Defines the number of bounces */
  6568. bounces: number;
  6569. /** Defines the amplitude of the bounce */
  6570. bounciness: number;
  6571. /**
  6572. * Instantiates a bounce easing
  6573. * @see https://easings.net/#easeInBounce
  6574. * @param bounces Defines the number of bounces
  6575. * @param bounciness Defines the amplitude of the bounce
  6576. */
  6577. constructor(
  6578. /** Defines the number of bounces */
  6579. bounces?: number,
  6580. /** Defines the amplitude of the bounce */
  6581. bounciness?: number);
  6582. /** @hidden */
  6583. easeInCore(gradient: number): number;
  6584. }
  6585. /**
  6586. * Easing function with a power of 3 shape (see link below).
  6587. * @see https://easings.net/#easeInCubic
  6588. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6589. */
  6590. export class CubicEase extends EasingFunction implements IEasingFunction {
  6591. /** @hidden */
  6592. easeInCore(gradient: number): number;
  6593. }
  6594. /**
  6595. * Easing function with an elastic shape (see link below).
  6596. * @see https://easings.net/#easeInElastic
  6597. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6598. */
  6599. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6600. /** Defines the number of oscillations*/
  6601. oscillations: number;
  6602. /** Defines the amplitude of the oscillations*/
  6603. springiness: number;
  6604. /**
  6605. * Instantiates an elastic easing function
  6606. * @see https://easings.net/#easeInElastic
  6607. * @param oscillations Defines the number of oscillations
  6608. * @param springiness Defines the amplitude of the oscillations
  6609. */
  6610. constructor(
  6611. /** Defines the number of oscillations*/
  6612. oscillations?: number,
  6613. /** Defines the amplitude of the oscillations*/
  6614. springiness?: number);
  6615. /** @hidden */
  6616. easeInCore(gradient: number): number;
  6617. }
  6618. /**
  6619. * Easing function with an exponential shape (see link below).
  6620. * @see https://easings.net/#easeInExpo
  6621. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6622. */
  6623. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6624. /** Defines the exponent of the function */
  6625. exponent: number;
  6626. /**
  6627. * Instantiates an exponential easing function
  6628. * @see https://easings.net/#easeInExpo
  6629. * @param exponent Defines the exponent of the function
  6630. */
  6631. constructor(
  6632. /** Defines the exponent of the function */
  6633. exponent?: number);
  6634. /** @hidden */
  6635. easeInCore(gradient: number): number;
  6636. }
  6637. /**
  6638. * Easing function with a power shape (see link below).
  6639. * @see https://easings.net/#easeInQuad
  6640. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6641. */
  6642. export class PowerEase extends EasingFunction implements IEasingFunction {
  6643. /** Defines the power of the function */
  6644. power: number;
  6645. /**
  6646. * Instantiates an power base easing function
  6647. * @see https://easings.net/#easeInQuad
  6648. * @param power Defines the power of the function
  6649. */
  6650. constructor(
  6651. /** Defines the power of the function */
  6652. power?: number);
  6653. /** @hidden */
  6654. easeInCore(gradient: number): number;
  6655. }
  6656. /**
  6657. * Easing function with a power of 2 shape (see link below).
  6658. * @see https://easings.net/#easeInQuad
  6659. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6660. */
  6661. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6662. /** @hidden */
  6663. easeInCore(gradient: number): number;
  6664. }
  6665. /**
  6666. * Easing function with a power of 4 shape (see link below).
  6667. * @see https://easings.net/#easeInQuart
  6668. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6669. */
  6670. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6671. /** @hidden */
  6672. easeInCore(gradient: number): number;
  6673. }
  6674. /**
  6675. * Easing function with a power of 5 shape (see link below).
  6676. * @see https://easings.net/#easeInQuint
  6677. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6678. */
  6679. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6680. /** @hidden */
  6681. easeInCore(gradient: number): number;
  6682. }
  6683. /**
  6684. * Easing function with a sin shape (see link below).
  6685. * @see https://easings.net/#easeInSine
  6686. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6687. */
  6688. export class SineEase extends EasingFunction implements IEasingFunction {
  6689. /** @hidden */
  6690. easeInCore(gradient: number): number;
  6691. }
  6692. /**
  6693. * Easing function with a bezier shape (see link below).
  6694. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6695. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6696. */
  6697. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6698. /** Defines the x component of the start tangent in the bezier curve */
  6699. x1: number;
  6700. /** Defines the y component of the start tangent in the bezier curve */
  6701. y1: number;
  6702. /** Defines the x component of the end tangent in the bezier curve */
  6703. x2: number;
  6704. /** Defines the y component of the end tangent in the bezier curve */
  6705. y2: number;
  6706. /**
  6707. * Instantiates a bezier function
  6708. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6709. * @param x1 Defines the x component of the start tangent in the bezier curve
  6710. * @param y1 Defines the y component of the start tangent in the bezier curve
  6711. * @param x2 Defines the x component of the end tangent in the bezier curve
  6712. * @param y2 Defines the y component of the end tangent in the bezier curve
  6713. */
  6714. constructor(
  6715. /** Defines the x component of the start tangent in the bezier curve */
  6716. x1?: number,
  6717. /** Defines the y component of the start tangent in the bezier curve */
  6718. y1?: number,
  6719. /** Defines the x component of the end tangent in the bezier curve */
  6720. x2?: number,
  6721. /** Defines the y component of the end tangent in the bezier curve */
  6722. y2?: number);
  6723. /** @hidden */
  6724. easeInCore(gradient: number): number;
  6725. }
  6726. }
  6727. declare module BABYLON {
  6728. /**
  6729. * Defines an interface which represents an animation key frame
  6730. */
  6731. export interface IAnimationKey {
  6732. /**
  6733. * Frame of the key frame
  6734. */
  6735. frame: number;
  6736. /**
  6737. * Value at the specifies key frame
  6738. */
  6739. value: any;
  6740. /**
  6741. * The input tangent for the cubic hermite spline
  6742. */
  6743. inTangent?: any;
  6744. /**
  6745. * The output tangent for the cubic hermite spline
  6746. */
  6747. outTangent?: any;
  6748. /**
  6749. * The animation interpolation type
  6750. */
  6751. interpolation?: AnimationKeyInterpolation;
  6752. }
  6753. /**
  6754. * Enum for the animation key frame interpolation type
  6755. */
  6756. export enum AnimationKeyInterpolation {
  6757. /**
  6758. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6759. */
  6760. STEP = 1
  6761. }
  6762. }
  6763. declare module BABYLON {
  6764. /**
  6765. * Represents the range of an animation
  6766. */
  6767. export class AnimationRange {
  6768. /**The name of the animation range**/
  6769. name: string;
  6770. /**The starting frame of the animation */
  6771. from: number;
  6772. /**The ending frame of the animation*/
  6773. to: number;
  6774. /**
  6775. * Initializes the range of an animation
  6776. * @param name The name of the animation range
  6777. * @param from The starting frame of the animation
  6778. * @param to The ending frame of the animation
  6779. */
  6780. constructor(
  6781. /**The name of the animation range**/
  6782. name: string,
  6783. /**The starting frame of the animation */
  6784. from: number,
  6785. /**The ending frame of the animation*/
  6786. to: number);
  6787. /**
  6788. * Makes a copy of the animation range
  6789. * @returns A copy of the animation range
  6790. */
  6791. clone(): AnimationRange;
  6792. }
  6793. }
  6794. declare module BABYLON {
  6795. /**
  6796. * Composed of a frame, and an action function
  6797. */
  6798. export class AnimationEvent {
  6799. /** The frame for which the event is triggered **/
  6800. frame: number;
  6801. /** The event to perform when triggered **/
  6802. action: (currentFrame: number) => void;
  6803. /** Specifies if the event should be triggered only once**/
  6804. onlyOnce?: boolean | undefined;
  6805. /**
  6806. * Specifies if the animation event is done
  6807. */
  6808. isDone: boolean;
  6809. /**
  6810. * Initializes the animation event
  6811. * @param frame The frame for which the event is triggered
  6812. * @param action The event to perform when triggered
  6813. * @param onlyOnce Specifies if the event should be triggered only once
  6814. */
  6815. constructor(
  6816. /** The frame for which the event is triggered **/
  6817. frame: number,
  6818. /** The event to perform when triggered **/
  6819. action: (currentFrame: number) => void,
  6820. /** Specifies if the event should be triggered only once**/
  6821. onlyOnce?: boolean | undefined);
  6822. /** @hidden */
  6823. _clone(): AnimationEvent;
  6824. }
  6825. }
  6826. declare module BABYLON {
  6827. /**
  6828. * Interface used to define a behavior
  6829. */
  6830. export interface Behavior<T> {
  6831. /** gets or sets behavior's name */
  6832. name: string;
  6833. /**
  6834. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6835. */
  6836. init(): void;
  6837. /**
  6838. * Called when the behavior is attached to a target
  6839. * @param target defines the target where the behavior is attached to
  6840. */
  6841. attach(target: T): void;
  6842. /**
  6843. * Called when the behavior is detached from its target
  6844. */
  6845. detach(): void;
  6846. }
  6847. /**
  6848. * Interface implemented by classes supporting behaviors
  6849. */
  6850. export interface IBehaviorAware<T> {
  6851. /**
  6852. * Attach a behavior
  6853. * @param behavior defines the behavior to attach
  6854. * @returns the current host
  6855. */
  6856. addBehavior(behavior: Behavior<T>): T;
  6857. /**
  6858. * Remove a behavior from the current object
  6859. * @param behavior defines the behavior to detach
  6860. * @returns the current host
  6861. */
  6862. removeBehavior(behavior: Behavior<T>): T;
  6863. /**
  6864. * Gets a behavior using its name to search
  6865. * @param name defines the name to search
  6866. * @returns the behavior or null if not found
  6867. */
  6868. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6869. }
  6870. }
  6871. declare module BABYLON {
  6872. /**
  6873. * @hidden
  6874. */
  6875. export class IntersectionInfo {
  6876. bu: Nullable<number>;
  6877. bv: Nullable<number>;
  6878. distance: number;
  6879. faceId: number;
  6880. subMeshId: number;
  6881. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6882. }
  6883. }
  6884. declare module BABYLON {
  6885. /**
  6886. * Class used to store bounding sphere information
  6887. */
  6888. export class BoundingSphere {
  6889. /**
  6890. * Gets the center of the bounding sphere in local space
  6891. */
  6892. readonly center: Vector3;
  6893. /**
  6894. * Radius of the bounding sphere in local space
  6895. */
  6896. radius: number;
  6897. /**
  6898. * Gets the center of the bounding sphere in world space
  6899. */
  6900. readonly centerWorld: Vector3;
  6901. /**
  6902. * Radius of the bounding sphere in world space
  6903. */
  6904. radiusWorld: number;
  6905. /**
  6906. * Gets the minimum vector in local space
  6907. */
  6908. readonly minimum: Vector3;
  6909. /**
  6910. * Gets the maximum vector in local space
  6911. */
  6912. readonly maximum: Vector3;
  6913. private _worldMatrix;
  6914. private static readonly TmpVector3;
  6915. /**
  6916. * Creates a new bounding sphere
  6917. * @param min defines the minimum vector (in local space)
  6918. * @param max defines the maximum vector (in local space)
  6919. * @param worldMatrix defines the new world matrix
  6920. */
  6921. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6922. /**
  6923. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6924. * @param min defines the new minimum vector (in local space)
  6925. * @param max defines the new maximum vector (in local space)
  6926. * @param worldMatrix defines the new world matrix
  6927. */
  6928. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6929. /**
  6930. * Scale the current bounding sphere by applying a scale factor
  6931. * @param factor defines the scale factor to apply
  6932. * @returns the current bounding box
  6933. */
  6934. scale(factor: number): BoundingSphere;
  6935. /**
  6936. * Gets the world matrix of the bounding box
  6937. * @returns a matrix
  6938. */
  6939. getWorldMatrix(): DeepImmutable<Matrix>;
  6940. /** @hidden */
  6941. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6942. /**
  6943. * Tests if the bounding sphere is intersecting the frustum planes
  6944. * @param frustumPlanes defines the frustum planes to test
  6945. * @returns true if there is an intersection
  6946. */
  6947. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6948. /**
  6949. * Tests if the bounding sphere center is in between the frustum planes.
  6950. * Used for optimistic fast inclusion.
  6951. * @param frustumPlanes defines the frustum planes to test
  6952. * @returns true if the sphere center is in between the frustum planes
  6953. */
  6954. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6955. /**
  6956. * Tests if a point is inside the bounding sphere
  6957. * @param point defines the point to test
  6958. * @returns true if the point is inside the bounding sphere
  6959. */
  6960. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6961. /**
  6962. * Checks if two sphere intersct
  6963. * @param sphere0 sphere 0
  6964. * @param sphere1 sphere 1
  6965. * @returns true if the speres intersect
  6966. */
  6967. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6968. }
  6969. }
  6970. declare module BABYLON {
  6971. /**
  6972. * Class used to store bounding box information
  6973. */
  6974. export class BoundingBox implements ICullable {
  6975. /**
  6976. * Gets the 8 vectors representing the bounding box in local space
  6977. */
  6978. readonly vectors: Vector3[];
  6979. /**
  6980. * Gets the center of the bounding box in local space
  6981. */
  6982. readonly center: Vector3;
  6983. /**
  6984. * Gets the center of the bounding box in world space
  6985. */
  6986. readonly centerWorld: Vector3;
  6987. /**
  6988. * Gets the extend size in local space
  6989. */
  6990. readonly extendSize: Vector3;
  6991. /**
  6992. * Gets the extend size in world space
  6993. */
  6994. readonly extendSizeWorld: Vector3;
  6995. /**
  6996. * Gets the OBB (object bounding box) directions
  6997. */
  6998. readonly directions: Vector3[];
  6999. /**
  7000. * Gets the 8 vectors representing the bounding box in world space
  7001. */
  7002. readonly vectorsWorld: Vector3[];
  7003. /**
  7004. * Gets the minimum vector in world space
  7005. */
  7006. readonly minimumWorld: Vector3;
  7007. /**
  7008. * Gets the maximum vector in world space
  7009. */
  7010. readonly maximumWorld: Vector3;
  7011. /**
  7012. * Gets the minimum vector in local space
  7013. */
  7014. readonly minimum: Vector3;
  7015. /**
  7016. * Gets the maximum vector in local space
  7017. */
  7018. readonly maximum: Vector3;
  7019. private _worldMatrix;
  7020. private static readonly TmpVector3;
  7021. /**
  7022. * @hidden
  7023. */
  7024. _tag: number;
  7025. /**
  7026. * Creates a new bounding box
  7027. * @param min defines the minimum vector (in local space)
  7028. * @param max defines the maximum vector (in local space)
  7029. * @param worldMatrix defines the new world matrix
  7030. */
  7031. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7032. /**
  7033. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7034. * @param min defines the new minimum vector (in local space)
  7035. * @param max defines the new maximum vector (in local space)
  7036. * @param worldMatrix defines the new world matrix
  7037. */
  7038. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7039. /**
  7040. * Scale the current bounding box by applying a scale factor
  7041. * @param factor defines the scale factor to apply
  7042. * @returns the current bounding box
  7043. */
  7044. scale(factor: number): BoundingBox;
  7045. /**
  7046. * Gets the world matrix of the bounding box
  7047. * @returns a matrix
  7048. */
  7049. getWorldMatrix(): DeepImmutable<Matrix>;
  7050. /** @hidden */
  7051. _update(world: DeepImmutable<Matrix>): void;
  7052. /**
  7053. * Tests if the bounding box is intersecting the frustum planes
  7054. * @param frustumPlanes defines the frustum planes to test
  7055. * @returns true if there is an intersection
  7056. */
  7057. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7058. /**
  7059. * Tests if the bounding box is entirely inside the frustum planes
  7060. * @param frustumPlanes defines the frustum planes to test
  7061. * @returns true if there is an inclusion
  7062. */
  7063. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7064. /**
  7065. * Tests if a point is inside the bounding box
  7066. * @param point defines the point to test
  7067. * @returns true if the point is inside the bounding box
  7068. */
  7069. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7070. /**
  7071. * Tests if the bounding box intersects with a bounding sphere
  7072. * @param sphere defines the sphere to test
  7073. * @returns true if there is an intersection
  7074. */
  7075. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7076. /**
  7077. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7078. * @param min defines the min vector to use
  7079. * @param max defines the max vector to use
  7080. * @returns true if there is an intersection
  7081. */
  7082. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7083. /**
  7084. * Tests if two bounding boxes are intersections
  7085. * @param box0 defines the first box to test
  7086. * @param box1 defines the second box to test
  7087. * @returns true if there is an intersection
  7088. */
  7089. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7090. /**
  7091. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7092. * @param minPoint defines the minimum vector of the bounding box
  7093. * @param maxPoint defines the maximum vector of the bounding box
  7094. * @param sphereCenter defines the sphere center
  7095. * @param sphereRadius defines the sphere radius
  7096. * @returns true if there is an intersection
  7097. */
  7098. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7099. /**
  7100. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7101. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7102. * @param frustumPlanes defines the frustum planes to test
  7103. * @return true if there is an inclusion
  7104. */
  7105. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7106. /**
  7107. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7108. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7109. * @param frustumPlanes defines the frustum planes to test
  7110. * @return true if there is an intersection
  7111. */
  7112. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. }
  7114. }
  7115. declare module BABYLON {
  7116. /** @hidden */
  7117. export class Collider {
  7118. /** Define if a collision was found */
  7119. collisionFound: boolean;
  7120. /**
  7121. * Define last intersection point in local space
  7122. */
  7123. intersectionPoint: Vector3;
  7124. /**
  7125. * Define last collided mesh
  7126. */
  7127. collidedMesh: Nullable<AbstractMesh>;
  7128. private _collisionPoint;
  7129. private _planeIntersectionPoint;
  7130. private _tempVector;
  7131. private _tempVector2;
  7132. private _tempVector3;
  7133. private _tempVector4;
  7134. private _edge;
  7135. private _baseToVertex;
  7136. private _destinationPoint;
  7137. private _slidePlaneNormal;
  7138. private _displacementVector;
  7139. /** @hidden */
  7140. _radius: Vector3;
  7141. /** @hidden */
  7142. _retry: number;
  7143. private _velocity;
  7144. private _basePoint;
  7145. private _epsilon;
  7146. /** @hidden */
  7147. _velocityWorldLength: number;
  7148. /** @hidden */
  7149. _basePointWorld: Vector3;
  7150. private _velocityWorld;
  7151. private _normalizedVelocity;
  7152. /** @hidden */
  7153. _initialVelocity: Vector3;
  7154. /** @hidden */
  7155. _initialPosition: Vector3;
  7156. private _nearestDistance;
  7157. private _collisionMask;
  7158. collisionMask: number;
  7159. /**
  7160. * Gets the plane normal used to compute the sliding response (in local space)
  7161. */
  7162. readonly slidePlaneNormal: Vector3;
  7163. /** @hidden */
  7164. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7165. /** @hidden */
  7166. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7167. /** @hidden */
  7168. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7169. /** @hidden */
  7170. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7171. /** @hidden */
  7172. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7173. /** @hidden */
  7174. _getResponse(pos: Vector3, vel: Vector3): void;
  7175. }
  7176. }
  7177. declare module BABYLON {
  7178. /**
  7179. * Interface for cullable objects
  7180. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7181. */
  7182. export interface ICullable {
  7183. /**
  7184. * Checks if the object or part of the object is in the frustum
  7185. * @param frustumPlanes Camera near/planes
  7186. * @returns true if the object is in frustum otherwise false
  7187. */
  7188. isInFrustum(frustumPlanes: Plane[]): boolean;
  7189. /**
  7190. * Checks if a cullable object (mesh...) is in the camera frustum
  7191. * Unlike isInFrustum this cheks the full bounding box
  7192. * @param frustumPlanes Camera near/planes
  7193. * @returns true if the object is in frustum otherwise false
  7194. */
  7195. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7196. }
  7197. /**
  7198. * Info for a bounding data of a mesh
  7199. */
  7200. export class BoundingInfo implements ICullable {
  7201. /**
  7202. * Bounding box for the mesh
  7203. */
  7204. readonly boundingBox: BoundingBox;
  7205. /**
  7206. * Bounding sphere for the mesh
  7207. */
  7208. readonly boundingSphere: BoundingSphere;
  7209. private _isLocked;
  7210. private static readonly TmpVector3;
  7211. /**
  7212. * Constructs bounding info
  7213. * @param minimum min vector of the bounding box/sphere
  7214. * @param maximum max vector of the bounding box/sphere
  7215. * @param worldMatrix defines the new world matrix
  7216. */
  7217. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7218. /**
  7219. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7220. * @param min defines the new minimum vector (in local space)
  7221. * @param max defines the new maximum vector (in local space)
  7222. * @param worldMatrix defines the new world matrix
  7223. */
  7224. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7225. /**
  7226. * min vector of the bounding box/sphere
  7227. */
  7228. readonly minimum: Vector3;
  7229. /**
  7230. * max vector of the bounding box/sphere
  7231. */
  7232. readonly maximum: Vector3;
  7233. /**
  7234. * If the info is locked and won't be updated to avoid perf overhead
  7235. */
  7236. isLocked: boolean;
  7237. /**
  7238. * Updates the bounding sphere and box
  7239. * @param world world matrix to be used to update
  7240. */
  7241. update(world: DeepImmutable<Matrix>): void;
  7242. /**
  7243. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7244. * @param center New center of the bounding info
  7245. * @param extend New extend of the bounding info
  7246. * @returns the current bounding info
  7247. */
  7248. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7249. /**
  7250. * Scale the current bounding info by applying a scale factor
  7251. * @param factor defines the scale factor to apply
  7252. * @returns the current bounding info
  7253. */
  7254. scale(factor: number): BoundingInfo;
  7255. /**
  7256. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7257. * @param frustumPlanes defines the frustum to test
  7258. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7259. * @returns true if the bounding info is in the frustum planes
  7260. */
  7261. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7262. /**
  7263. * Gets the world distance between the min and max points of the bounding box
  7264. */
  7265. readonly diagonalLength: number;
  7266. /**
  7267. * Checks if a cullable object (mesh...) is in the camera frustum
  7268. * Unlike isInFrustum this cheks the full bounding box
  7269. * @param frustumPlanes Camera near/planes
  7270. * @returns true if the object is in frustum otherwise false
  7271. */
  7272. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7273. /** @hidden */
  7274. _checkCollision(collider: Collider): boolean;
  7275. /**
  7276. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7277. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7278. * @param point the point to check intersection with
  7279. * @returns if the point intersects
  7280. */
  7281. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7282. /**
  7283. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7284. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7285. * @param boundingInfo the bounding info to check intersection with
  7286. * @param precise if the intersection should be done using OBB
  7287. * @returns if the bounding info intersects
  7288. */
  7289. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7290. }
  7291. }
  7292. declare module BABYLON {
  7293. /**
  7294. * Defines an array and its length.
  7295. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7296. */
  7297. export interface ISmartArrayLike<T> {
  7298. /**
  7299. * The data of the array.
  7300. */
  7301. data: Array<T>;
  7302. /**
  7303. * The active length of the array.
  7304. */
  7305. length: number;
  7306. }
  7307. /**
  7308. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7309. */
  7310. export class SmartArray<T> implements ISmartArrayLike<T> {
  7311. /**
  7312. * The full set of data from the array.
  7313. */
  7314. data: Array<T>;
  7315. /**
  7316. * The active length of the array.
  7317. */
  7318. length: number;
  7319. protected _id: number;
  7320. /**
  7321. * Instantiates a Smart Array.
  7322. * @param capacity defines the default capacity of the array.
  7323. */
  7324. constructor(capacity: number);
  7325. /**
  7326. * Pushes a value at the end of the active data.
  7327. * @param value defines the object to push in the array.
  7328. */
  7329. push(value: T): void;
  7330. /**
  7331. * Iterates over the active data and apply the lambda to them.
  7332. * @param func defines the action to apply on each value.
  7333. */
  7334. forEach(func: (content: T) => void): void;
  7335. /**
  7336. * Sorts the full sets of data.
  7337. * @param compareFn defines the comparison function to apply.
  7338. */
  7339. sort(compareFn: (a: T, b: T) => number): void;
  7340. /**
  7341. * Resets the active data to an empty array.
  7342. */
  7343. reset(): void;
  7344. /**
  7345. * Releases all the data from the array as well as the array.
  7346. */
  7347. dispose(): void;
  7348. /**
  7349. * Concats the active data with a given array.
  7350. * @param array defines the data to concatenate with.
  7351. */
  7352. concat(array: any): void;
  7353. /**
  7354. * Returns the position of a value in the active data.
  7355. * @param value defines the value to find the index for
  7356. * @returns the index if found in the active data otherwise -1
  7357. */
  7358. indexOf(value: T): number;
  7359. /**
  7360. * Returns whether an element is part of the active data.
  7361. * @param value defines the value to look for
  7362. * @returns true if found in the active data otherwise false
  7363. */
  7364. contains(value: T): boolean;
  7365. private static _GlobalId;
  7366. }
  7367. /**
  7368. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7369. * The data in this array can only be present once
  7370. */
  7371. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7372. private _duplicateId;
  7373. /**
  7374. * Pushes a value at the end of the active data.
  7375. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7376. * @param value defines the object to push in the array.
  7377. */
  7378. push(value: T): void;
  7379. /**
  7380. * Pushes a value at the end of the active data.
  7381. * If the data is already present, it won t be added again
  7382. * @param value defines the object to push in the array.
  7383. * @returns true if added false if it was already present
  7384. */
  7385. pushNoDuplicate(value: T): boolean;
  7386. /**
  7387. * Resets the active data to an empty array.
  7388. */
  7389. reset(): void;
  7390. /**
  7391. * Concats the active data with a given array.
  7392. * This ensures no dupplicate will be present in the result.
  7393. * @param array defines the data to concatenate with.
  7394. */
  7395. concatWithNoDuplicate(array: any): void;
  7396. }
  7397. }
  7398. declare module BABYLON {
  7399. /**
  7400. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7401. * separate meshes. This can be use to improve performances.
  7402. * @see http://doc.babylonjs.com/how_to/multi_materials
  7403. */
  7404. export class MultiMaterial extends Material {
  7405. private _subMaterials;
  7406. /**
  7407. * Gets or Sets the list of Materials used within the multi material.
  7408. * They need to be ordered according to the submeshes order in the associated mesh
  7409. */
  7410. subMaterials: Nullable<Material>[];
  7411. /**
  7412. * Function used to align with Node.getChildren()
  7413. * @returns the list of Materials used within the multi material
  7414. */
  7415. getChildren(): Nullable<Material>[];
  7416. /**
  7417. * Instantiates a new Multi Material
  7418. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7419. * separate meshes. This can be use to improve performances.
  7420. * @see http://doc.babylonjs.com/how_to/multi_materials
  7421. * @param name Define the name in the scene
  7422. * @param scene Define the scene the material belongs to
  7423. */
  7424. constructor(name: string, scene: Scene);
  7425. private _hookArray;
  7426. /**
  7427. * Get one of the submaterial by its index in the submaterials array
  7428. * @param index The index to look the sub material at
  7429. * @returns The Material if the index has been defined
  7430. */
  7431. getSubMaterial(index: number): Nullable<Material>;
  7432. /**
  7433. * Get the list of active textures for the whole sub materials list.
  7434. * @returns All the textures that will be used during the rendering
  7435. */
  7436. getActiveTextures(): BaseTexture[];
  7437. /**
  7438. * Gets the current class name of the material e.g. "MultiMaterial"
  7439. * Mainly use in serialization.
  7440. * @returns the class name
  7441. */
  7442. getClassName(): string;
  7443. /**
  7444. * Checks if the material is ready to render the requested sub mesh
  7445. * @param mesh Define the mesh the submesh belongs to
  7446. * @param subMesh Define the sub mesh to look readyness for
  7447. * @param useInstances Define whether or not the material is used with instances
  7448. * @returns true if ready, otherwise false
  7449. */
  7450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7451. /**
  7452. * Clones the current material and its related sub materials
  7453. * @param name Define the name of the newly cloned material
  7454. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7455. * @returns the cloned material
  7456. */
  7457. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7458. /**
  7459. * Serializes the materials into a JSON representation.
  7460. * @returns the JSON representation
  7461. */
  7462. serialize(): any;
  7463. /**
  7464. * Dispose the material and release its associated resources
  7465. * @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)
  7466. * @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)
  7467. * @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)
  7468. */
  7469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7470. /**
  7471. * Creates a MultiMaterial from parsed MultiMaterial data.
  7472. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7473. * @param scene defines the hosting scene
  7474. * @returns a new MultiMaterial
  7475. */
  7476. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7477. }
  7478. }
  7479. declare module BABYLON {
  7480. /**
  7481. * Class used to represent data loading progression
  7482. */
  7483. export class SceneLoaderFlags {
  7484. private static _ForceFullSceneLoadingForIncremental;
  7485. private static _ShowLoadingScreen;
  7486. private static _CleanBoneMatrixWeights;
  7487. private static _loggingLevel;
  7488. /**
  7489. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7490. */
  7491. static ForceFullSceneLoadingForIncremental: boolean;
  7492. /**
  7493. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7494. */
  7495. static ShowLoadingScreen: boolean;
  7496. /**
  7497. * Defines the current logging level (while loading the scene)
  7498. * @ignorenaming
  7499. */
  7500. static loggingLevel: number;
  7501. /**
  7502. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7503. */
  7504. static CleanBoneMatrixWeights: boolean;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * 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.
  7510. * @see https://doc.babylonjs.com/how_to/transformnode
  7511. */
  7512. export class TransformNode extends Node {
  7513. /**
  7514. * Object will not rotate to face the camera
  7515. */
  7516. static BILLBOARDMODE_NONE: number;
  7517. /**
  7518. * Object will rotate to face the camera but only on the x axis
  7519. */
  7520. static BILLBOARDMODE_X: number;
  7521. /**
  7522. * Object will rotate to face the camera but only on the y axis
  7523. */
  7524. static BILLBOARDMODE_Y: number;
  7525. /**
  7526. * Object will rotate to face the camera but only on the z axis
  7527. */
  7528. static BILLBOARDMODE_Z: number;
  7529. /**
  7530. * Object will rotate to face the camera
  7531. */
  7532. static BILLBOARDMODE_ALL: number;
  7533. private _forward;
  7534. private _forwardInverted;
  7535. private _up;
  7536. private _right;
  7537. private _rightInverted;
  7538. private _position;
  7539. private _rotation;
  7540. private _rotationQuaternion;
  7541. protected _scaling: Vector3;
  7542. protected _isDirty: boolean;
  7543. private _transformToBoneReferal;
  7544. private _billboardMode;
  7545. /**
  7546. * Gets or sets the billboard mode. Default is 0.
  7547. *
  7548. * | Value | Type | Description |
  7549. * | --- | --- | --- |
  7550. * | 0 | BILLBOARDMODE_NONE | |
  7551. * | 1 | BILLBOARDMODE_X | |
  7552. * | 2 | BILLBOARDMODE_Y | |
  7553. * | 4 | BILLBOARDMODE_Z | |
  7554. * | 7 | BILLBOARDMODE_ALL | |
  7555. *
  7556. */
  7557. billboardMode: number;
  7558. private _preserveParentRotationForBillboard;
  7559. /**
  7560. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7561. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7562. */
  7563. preserveParentRotationForBillboard: boolean;
  7564. /**
  7565. * 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
  7566. */
  7567. scalingDeterminant: number;
  7568. private _infiniteDistance;
  7569. /**
  7570. * Gets or sets the distance of the object to max, often used by skybox
  7571. */
  7572. infiniteDistance: boolean;
  7573. /**
  7574. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7575. * By default the system will update normals to compensate
  7576. */
  7577. ignoreNonUniformScaling: boolean;
  7578. /**
  7579. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7580. */
  7581. reIntegrateRotationIntoRotationQuaternion: boolean;
  7582. /** @hidden */
  7583. _poseMatrix: Nullable<Matrix>;
  7584. /** @hidden */
  7585. _localMatrix: Matrix;
  7586. private _usePivotMatrix;
  7587. private _absolutePosition;
  7588. private _pivotMatrix;
  7589. private _pivotMatrixInverse;
  7590. protected _postMultiplyPivotMatrix: boolean;
  7591. protected _isWorldMatrixFrozen: boolean;
  7592. /** @hidden */
  7593. _indexInSceneTransformNodesArray: number;
  7594. /**
  7595. * An event triggered after the world matrix is updated
  7596. */
  7597. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7598. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7599. /**
  7600. * Gets a string identifying the name of the class
  7601. * @returns "TransformNode" string
  7602. */
  7603. getClassName(): string;
  7604. /**
  7605. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7606. */
  7607. position: Vector3;
  7608. /**
  7609. * 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)).
  7610. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7611. */
  7612. rotation: Vector3;
  7613. /**
  7614. * 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)).
  7615. */
  7616. scaling: Vector3;
  7617. /**
  7618. * 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).
  7619. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7620. */
  7621. rotationQuaternion: Nullable<Quaternion>;
  7622. /**
  7623. * The forward direction of that transform in world space.
  7624. */
  7625. readonly forward: Vector3;
  7626. /**
  7627. * The up direction of that transform in world space.
  7628. */
  7629. readonly up: Vector3;
  7630. /**
  7631. * The right direction of that transform in world space.
  7632. */
  7633. readonly right: Vector3;
  7634. /**
  7635. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7636. * @param matrix the matrix to copy the pose from
  7637. * @returns this TransformNode.
  7638. */
  7639. updatePoseMatrix(matrix: Matrix): TransformNode;
  7640. /**
  7641. * Returns the mesh Pose matrix.
  7642. * @returns the pose matrix
  7643. */
  7644. getPoseMatrix(): Matrix;
  7645. /** @hidden */
  7646. _isSynchronized(): boolean;
  7647. /** @hidden */
  7648. _initCache(): void;
  7649. /**
  7650. * Flag the transform node as dirty (Forcing it to update everything)
  7651. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7652. * @returns this transform node
  7653. */
  7654. markAsDirty(property: string): TransformNode;
  7655. /**
  7656. * Returns the current mesh absolute position.
  7657. * Returns a Vector3.
  7658. */
  7659. readonly absolutePosition: Vector3;
  7660. /**
  7661. * Sets a new matrix to apply before all other transformation
  7662. * @param matrix defines the transform matrix
  7663. * @returns the current TransformNode
  7664. */
  7665. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7666. /**
  7667. * Sets a new pivot matrix to the current node
  7668. * @param matrix defines the new pivot matrix to use
  7669. * @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
  7670. * @returns the current TransformNode
  7671. */
  7672. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7673. /**
  7674. * Returns the mesh pivot matrix.
  7675. * Default : Identity.
  7676. * @returns the matrix
  7677. */
  7678. getPivotMatrix(): Matrix;
  7679. /**
  7680. * Prevents the World matrix to be computed any longer.
  7681. * @returns the TransformNode.
  7682. */
  7683. freezeWorldMatrix(): TransformNode;
  7684. /**
  7685. * Allows back the World matrix computation.
  7686. * @returns the TransformNode.
  7687. */
  7688. unfreezeWorldMatrix(): this;
  7689. /**
  7690. * True if the World matrix has been frozen.
  7691. */
  7692. readonly isWorldMatrixFrozen: boolean;
  7693. /**
  7694. * Retuns the mesh absolute position in the World.
  7695. * @returns a Vector3.
  7696. */
  7697. getAbsolutePosition(): Vector3;
  7698. /**
  7699. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7700. * @param absolutePosition the absolute position to set
  7701. * @returns the TransformNode.
  7702. */
  7703. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7704. /**
  7705. * Sets the mesh position in its local space.
  7706. * @param vector3 the position to set in localspace
  7707. * @returns the TransformNode.
  7708. */
  7709. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7710. /**
  7711. * Returns the mesh position in the local space from the current World matrix values.
  7712. * @returns a new Vector3.
  7713. */
  7714. getPositionExpressedInLocalSpace(): Vector3;
  7715. /**
  7716. * Translates the mesh along the passed Vector3 in its local space.
  7717. * @param vector3 the distance to translate in localspace
  7718. * @returns the TransformNode.
  7719. */
  7720. locallyTranslate(vector3: Vector3): TransformNode;
  7721. private static _lookAtVectorCache;
  7722. /**
  7723. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7724. * @param targetPoint the position (must be in same space as current mesh) to look at
  7725. * @param yawCor optional yaw (y-axis) correction in radians
  7726. * @param pitchCor optional pitch (x-axis) correction in radians
  7727. * @param rollCor optional roll (z-axis) correction in radians
  7728. * @param space the choosen space of the target
  7729. * @returns the TransformNode.
  7730. */
  7731. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7732. /**
  7733. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7734. * This Vector3 is expressed in the World space.
  7735. * @param localAxis axis to rotate
  7736. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7737. */
  7738. getDirection(localAxis: Vector3): Vector3;
  7739. /**
  7740. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7741. * localAxis is expressed in the mesh local space.
  7742. * result is computed in the Wordl space from the mesh World matrix.
  7743. * @param localAxis axis to rotate
  7744. * @param result the resulting transformnode
  7745. * @returns this TransformNode.
  7746. */
  7747. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7748. /**
  7749. * Sets this transform node rotation to the given local axis.
  7750. * @param localAxis the axis in local space
  7751. * @param yawCor optional yaw (y-axis) correction in radians
  7752. * @param pitchCor optional pitch (x-axis) correction in radians
  7753. * @param rollCor optional roll (z-axis) correction in radians
  7754. * @returns this TransformNode
  7755. */
  7756. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7757. /**
  7758. * Sets a new pivot point to the current node
  7759. * @param point defines the new pivot point to use
  7760. * @param space defines if the point is in world or local space (local by default)
  7761. * @returns the current TransformNode
  7762. */
  7763. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7764. /**
  7765. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7766. * @returns the pivot point
  7767. */
  7768. getPivotPoint(): Vector3;
  7769. /**
  7770. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7771. * @param result the vector3 to store the result
  7772. * @returns this TransformNode.
  7773. */
  7774. getPivotPointToRef(result: Vector3): TransformNode;
  7775. /**
  7776. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7777. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7778. */
  7779. getAbsolutePivotPoint(): Vector3;
  7780. /**
  7781. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7782. * @param result vector3 to store the result
  7783. * @returns this TransformNode.
  7784. */
  7785. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7786. /**
  7787. * Defines the passed node as the parent of the current node.
  7788. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7789. * @see https://doc.babylonjs.com/how_to/parenting
  7790. * @param node the node ot set as the parent
  7791. * @returns this TransformNode.
  7792. */
  7793. setParent(node: Nullable<Node>): TransformNode;
  7794. private _nonUniformScaling;
  7795. /**
  7796. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7797. */
  7798. readonly nonUniformScaling: boolean;
  7799. /** @hidden */
  7800. _updateNonUniformScalingState(value: boolean): boolean;
  7801. /**
  7802. * Attach the current TransformNode to another TransformNode associated with a bone
  7803. * @param bone Bone affecting the TransformNode
  7804. * @param affectedTransformNode TransformNode associated with the bone
  7805. * @returns this object
  7806. */
  7807. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7808. /**
  7809. * Detach the transform node if its associated with a bone
  7810. * @returns this object
  7811. */
  7812. detachFromBone(): TransformNode;
  7813. private static _rotationAxisCache;
  7814. /**
  7815. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7816. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7817. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7818. * The passed axis is also normalized.
  7819. * @param axis the axis to rotate around
  7820. * @param amount the amount to rotate in radians
  7821. * @param space Space to rotate in (Default: local)
  7822. * @returns the TransformNode.
  7823. */
  7824. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7825. /**
  7826. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7827. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7828. * The passed axis is also normalized. .
  7829. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7830. * @param point the point to rotate around
  7831. * @param axis the axis to rotate around
  7832. * @param amount the amount to rotate in radians
  7833. * @returns the TransformNode
  7834. */
  7835. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7836. /**
  7837. * Translates the mesh along the axis vector for the passed distance in the given space.
  7838. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7839. * @param axis the axis to translate in
  7840. * @param distance the distance to translate
  7841. * @param space Space to rotate in (Default: local)
  7842. * @returns the TransformNode.
  7843. */
  7844. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7845. /**
  7846. * Adds a rotation step to the mesh current rotation.
  7847. * x, y, z are Euler angles expressed in radians.
  7848. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7849. * This means this rotation is made in the mesh local space only.
  7850. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7851. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7852. * ```javascript
  7853. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7854. * ```
  7855. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7856. * 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.
  7857. * @param x Rotation to add
  7858. * @param y Rotation to add
  7859. * @param z Rotation to add
  7860. * @returns the TransformNode.
  7861. */
  7862. addRotation(x: number, y: number, z: number): TransformNode;
  7863. /**
  7864. * @hidden
  7865. */
  7866. protected _getEffectiveParent(): Nullable<Node>;
  7867. /**
  7868. * Computes the world matrix of the node
  7869. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7870. * @returns the world matrix
  7871. */
  7872. computeWorldMatrix(force?: boolean): Matrix;
  7873. protected _afterComputeWorldMatrix(): void;
  7874. /**
  7875. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7876. * @param func callback function to add
  7877. *
  7878. * @returns the TransformNode.
  7879. */
  7880. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7881. /**
  7882. * Removes a registered callback function.
  7883. * @param func callback function to remove
  7884. * @returns the TransformNode.
  7885. */
  7886. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7887. /**
  7888. * Gets the position of the current mesh in camera space
  7889. * @param camera defines the camera to use
  7890. * @returns a position
  7891. */
  7892. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7893. /**
  7894. * Returns the distance from the mesh to the active camera
  7895. * @param camera defines the camera to use
  7896. * @returns the distance
  7897. */
  7898. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7899. /**
  7900. * Clone the current transform node
  7901. * @param name Name of the new clone
  7902. * @param newParent New parent for the clone
  7903. * @param doNotCloneChildren Do not clone children hierarchy
  7904. * @returns the new transform node
  7905. */
  7906. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7907. /**
  7908. * Serializes the objects information.
  7909. * @param currentSerializationObject defines the object to serialize in
  7910. * @returns the serialized object
  7911. */
  7912. serialize(currentSerializationObject?: any): any;
  7913. /**
  7914. * Returns a new TransformNode object parsed from the source provided.
  7915. * @param parsedTransformNode is the source.
  7916. * @param scene the scne the object belongs to
  7917. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7918. * @returns a new TransformNode object parsed from the source provided.
  7919. */
  7920. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7921. /**
  7922. * Get all child-transformNodes of this node
  7923. * @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
  7924. * @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
  7925. * @returns an array of TransformNode
  7926. */
  7927. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7928. /**
  7929. * Releases resources associated with this transform node.
  7930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7932. */
  7933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7934. }
  7935. }
  7936. declare module BABYLON {
  7937. /**
  7938. * Class used to override all child animations of a given target
  7939. */
  7940. export class AnimationPropertiesOverride {
  7941. /**
  7942. * Gets or sets a value indicating if animation blending must be used
  7943. */
  7944. enableBlending: boolean;
  7945. /**
  7946. * Gets or sets the blending speed to use when enableBlending is true
  7947. */
  7948. blendingSpeed: number;
  7949. /**
  7950. * Gets or sets the default loop mode to use
  7951. */
  7952. loopMode: number;
  7953. }
  7954. }
  7955. declare module BABYLON {
  7956. /**
  7957. * Class used to store bone information
  7958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7959. */
  7960. export class Bone extends Node {
  7961. /**
  7962. * defines the bone name
  7963. */
  7964. name: string;
  7965. private static _tmpVecs;
  7966. private static _tmpQuat;
  7967. private static _tmpMats;
  7968. /**
  7969. * Gets the list of child bones
  7970. */
  7971. children: Bone[];
  7972. /** Gets the animations associated with this bone */
  7973. animations: Animation[];
  7974. /**
  7975. * Gets or sets bone length
  7976. */
  7977. length: number;
  7978. /**
  7979. * @hidden Internal only
  7980. * Set this value to map this bone to a different index in the transform matrices
  7981. * Set this value to -1 to exclude the bone from the transform matrices
  7982. */
  7983. _index: Nullable<number>;
  7984. private _skeleton;
  7985. private _localMatrix;
  7986. private _restPose;
  7987. private _baseMatrix;
  7988. private _absoluteTransform;
  7989. private _invertedAbsoluteTransform;
  7990. private _parent;
  7991. private _scalingDeterminant;
  7992. private _worldTransform;
  7993. private _localScaling;
  7994. private _localRotation;
  7995. private _localPosition;
  7996. private _needToDecompose;
  7997. private _needToCompose;
  7998. /** @hidden */
  7999. _linkedTransformNode: Nullable<TransformNode>;
  8000. /** @hidden */
  8001. /** @hidden */
  8002. _matrix: Matrix;
  8003. /**
  8004. * Create a new bone
  8005. * @param name defines the bone name
  8006. * @param skeleton defines the parent skeleton
  8007. * @param parentBone defines the parent (can be null if the bone is the root)
  8008. * @param localMatrix defines the local matrix
  8009. * @param restPose defines the rest pose matrix
  8010. * @param baseMatrix defines the base matrix
  8011. * @param index defines index of the bone in the hiearchy
  8012. */
  8013. constructor(
  8014. /**
  8015. * defines the bone name
  8016. */
  8017. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8018. /**
  8019. * Gets the current object class name.
  8020. * @return the class name
  8021. */
  8022. getClassName(): string;
  8023. /**
  8024. * Gets the parent skeleton
  8025. * @returns a skeleton
  8026. */
  8027. getSkeleton(): Skeleton;
  8028. /**
  8029. * Gets parent bone
  8030. * @returns a bone or null if the bone is the root of the bone hierarchy
  8031. */
  8032. getParent(): Nullable<Bone>;
  8033. /**
  8034. * Returns an array containing the root bones
  8035. * @returns an array containing the root bones
  8036. */
  8037. getChildren(): Array<Bone>;
  8038. /**
  8039. * Sets the parent bone
  8040. * @param parent defines the parent (can be null if the bone is the root)
  8041. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8042. */
  8043. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8044. /**
  8045. * Gets the local matrix
  8046. * @returns a matrix
  8047. */
  8048. getLocalMatrix(): Matrix;
  8049. /**
  8050. * Gets the base matrix (initial matrix which remains unchanged)
  8051. * @returns a matrix
  8052. */
  8053. getBaseMatrix(): Matrix;
  8054. /**
  8055. * Gets the rest pose matrix
  8056. * @returns a matrix
  8057. */
  8058. getRestPose(): Matrix;
  8059. /**
  8060. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8061. */
  8062. getWorldMatrix(): Matrix;
  8063. /**
  8064. * Sets the local matrix to rest pose matrix
  8065. */
  8066. returnToRest(): void;
  8067. /**
  8068. * Gets the inverse of the absolute transform matrix.
  8069. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8070. * @returns a matrix
  8071. */
  8072. getInvertedAbsoluteTransform(): Matrix;
  8073. /**
  8074. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8075. * @returns a matrix
  8076. */
  8077. getAbsoluteTransform(): Matrix;
  8078. /**
  8079. * Links with the given transform node.
  8080. * The local matrix of this bone is copied from the transform node every frame.
  8081. * @param transformNode defines the transform node to link to
  8082. */
  8083. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8084. /** Gets or sets current position (in local space) */
  8085. position: Vector3;
  8086. /** Gets or sets current rotation (in local space) */
  8087. rotation: Vector3;
  8088. /** Gets or sets current rotation quaternion (in local space) */
  8089. rotationQuaternion: Quaternion;
  8090. /** Gets or sets current scaling (in local space) */
  8091. scaling: Vector3;
  8092. /**
  8093. * Gets the animation properties override
  8094. */
  8095. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8096. private _decompose;
  8097. private _compose;
  8098. /**
  8099. * Update the base and local matrices
  8100. * @param matrix defines the new base or local matrix
  8101. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8102. * @param updateLocalMatrix defines if the local matrix should be updated
  8103. */
  8104. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8105. /** @hidden */
  8106. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8107. /**
  8108. * Flag the bone as dirty (Forcing it to update everything)
  8109. */
  8110. markAsDirty(): void;
  8111. private _markAsDirtyAndCompose;
  8112. private _markAsDirtyAndDecompose;
  8113. /**
  8114. * Translate the bone in local or world space
  8115. * @param vec The amount to translate the bone
  8116. * @param space The space that the translation is in
  8117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8118. */
  8119. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8120. /**
  8121. * Set the postion of the bone in local or world space
  8122. * @param position The position to set the bone
  8123. * @param space The space that the position is in
  8124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8125. */
  8126. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8127. /**
  8128. * Set the absolute position of the bone (world space)
  8129. * @param position The position to set the bone
  8130. * @param mesh The mesh that this bone is attached to
  8131. */
  8132. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8133. /**
  8134. * Scale the bone on the x, y and z axes (in local space)
  8135. * @param x The amount to scale the bone on the x axis
  8136. * @param y The amount to scale the bone on the y axis
  8137. * @param z The amount to scale the bone on the z axis
  8138. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8139. */
  8140. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8141. /**
  8142. * Set the bone scaling in local space
  8143. * @param scale defines the scaling vector
  8144. */
  8145. setScale(scale: Vector3): void;
  8146. /**
  8147. * Gets the current scaling in local space
  8148. * @returns the current scaling vector
  8149. */
  8150. getScale(): Vector3;
  8151. /**
  8152. * Gets the current scaling in local space and stores it in a target vector
  8153. * @param result defines the target vector
  8154. */
  8155. getScaleToRef(result: Vector3): void;
  8156. /**
  8157. * Set the yaw, pitch, and roll of the bone in local or world space
  8158. * @param yaw The rotation of the bone on the y axis
  8159. * @param pitch The rotation of the bone on the x axis
  8160. * @param roll The rotation of the bone on the z axis
  8161. * @param space The space that the axes of rotation are in
  8162. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8163. */
  8164. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8165. /**
  8166. * Add a rotation to the bone on an axis in local or world space
  8167. * @param axis The axis to rotate the bone on
  8168. * @param amount The amount to rotate the bone
  8169. * @param space The space that the axis is in
  8170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8171. */
  8172. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8173. /**
  8174. * Set the rotation of the bone to a particular axis angle in local or world space
  8175. * @param axis The axis to rotate the bone on
  8176. * @param angle The angle that the bone should be rotated to
  8177. * @param space The space that the axis is in
  8178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8179. */
  8180. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8181. /**
  8182. * Set the euler rotation of the bone in local of world space
  8183. * @param rotation The euler rotation that the bone should be set to
  8184. * @param space The space that the rotation is in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. */
  8187. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the quaternion rotation of the bone in local of world space
  8190. * @param quat The quaternion rotation that the bone should be set to
  8191. * @param space The space that the rotation is in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. */
  8194. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8195. /**
  8196. * Set the rotation matrix of the bone in local of world space
  8197. * @param rotMat The rotation matrix that the bone should be set to
  8198. * @param space The space that the rotation is in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. */
  8201. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8202. private _rotateWithMatrix;
  8203. private _getNegativeRotationToRef;
  8204. /**
  8205. * Get the position of the bone in local or world space
  8206. * @param space The space that the returned position is in
  8207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8208. * @returns The position of the bone
  8209. */
  8210. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8211. /**
  8212. * Copy the position of the bone to a vector3 in local or world space
  8213. * @param space The space that the returned position is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. * @param result The vector3 to copy the position to
  8216. */
  8217. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8218. /**
  8219. * Get the absolute position of the bone (world space)
  8220. * @param mesh The mesh that this bone is attached to
  8221. * @returns The absolute position of the bone
  8222. */
  8223. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8224. /**
  8225. * Copy the absolute position of the bone (world space) to the result param
  8226. * @param mesh The mesh that this bone is attached to
  8227. * @param result The vector3 to copy the absolute position to
  8228. */
  8229. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8230. /**
  8231. * Compute the absolute transforms of this bone and its children
  8232. */
  8233. computeAbsoluteTransforms(): void;
  8234. /**
  8235. * Get the world direction from an axis that is in the local space of the bone
  8236. * @param localAxis The local direction that is used to compute the world direction
  8237. * @param mesh The mesh that this bone is attached to
  8238. * @returns The world direction
  8239. */
  8240. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8241. /**
  8242. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8243. * @param localAxis The local direction that is used to compute the world direction
  8244. * @param mesh The mesh that this bone is attached to
  8245. * @param result The vector3 that the world direction will be copied to
  8246. */
  8247. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8248. /**
  8249. * Get the euler rotation of the bone in local or world space
  8250. * @param space The space that the rotation should be in
  8251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8252. * @returns The euler rotation
  8253. */
  8254. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8255. /**
  8256. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8257. * @param space The space that the rotation should be in
  8258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8259. * @param result The vector3 that the rotation should be copied to
  8260. */
  8261. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8262. /**
  8263. * Get the quaternion rotation of the bone in either local or world space
  8264. * @param space The space that the rotation should be in
  8265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8266. * @returns The quaternion rotation
  8267. */
  8268. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8269. /**
  8270. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8271. * @param space The space that the rotation should be in
  8272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8273. * @param result The quaternion that the rotation should be copied to
  8274. */
  8275. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8276. /**
  8277. * Get the rotation matrix of the bone in local or world space
  8278. * @param space The space that the rotation should be in
  8279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8280. * @returns The rotation matrix
  8281. */
  8282. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8283. /**
  8284. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8285. * @param space The space that the rotation should be in
  8286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8287. * @param result The quaternion that the rotation should be copied to
  8288. */
  8289. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8290. /**
  8291. * Get the world position of a point that is in the local space of the bone
  8292. * @param position The local position
  8293. * @param mesh The mesh that this bone is attached to
  8294. * @returns The world position
  8295. */
  8296. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8297. /**
  8298. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8299. * @param position The local position
  8300. * @param mesh The mesh that this bone is attached to
  8301. * @param result The vector3 that the world position should be copied to
  8302. */
  8303. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8304. /**
  8305. * Get the local position of a point that is in world space
  8306. * @param position The world position
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @returns The local position
  8309. */
  8310. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8311. /**
  8312. * Get the local position of a point that is in world space and copy it to the result param
  8313. * @param position The world position
  8314. * @param mesh The mesh that this bone is attached to
  8315. * @param result The vector3 that the local position should be copied to
  8316. */
  8317. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8318. }
  8319. }
  8320. declare module BABYLON {
  8321. /**
  8322. * Enum that determines the text-wrapping mode to use.
  8323. */
  8324. export enum InspectableType {
  8325. /**
  8326. * Checkbox for booleans
  8327. */
  8328. Checkbox = 0,
  8329. /**
  8330. * Sliders for numbers
  8331. */
  8332. Slider = 1,
  8333. /**
  8334. * Vector3
  8335. */
  8336. Vector3 = 2,
  8337. /**
  8338. * Quaternions
  8339. */
  8340. Quaternion = 3,
  8341. /**
  8342. * Color3
  8343. */
  8344. Color3 = 4
  8345. }
  8346. /**
  8347. * Interface used to define custom inspectable properties.
  8348. * This interface is used by the inspector to display custom property grids
  8349. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8350. */
  8351. export interface IInspectable {
  8352. /**
  8353. * Gets the label to display
  8354. */
  8355. label: string;
  8356. /**
  8357. * Gets the name of the property to edit
  8358. */
  8359. propertyName: string;
  8360. /**
  8361. * Gets the type of the editor to use
  8362. */
  8363. type: InspectableType;
  8364. /**
  8365. * Gets the minimum value of the property when using in "slider" mode
  8366. */
  8367. min?: number;
  8368. /**
  8369. * Gets the maximum value of the property when using in "slider" mode
  8370. */
  8371. max?: number;
  8372. /**
  8373. * Gets the setp to use when using in "slider" mode
  8374. */
  8375. step?: number;
  8376. }
  8377. }
  8378. declare module BABYLON {
  8379. /**
  8380. * This represents the required contract to create a new type of texture loader.
  8381. */
  8382. export interface IInternalTextureLoader {
  8383. /**
  8384. * Defines wether the loader supports cascade loading the different faces.
  8385. */
  8386. supportCascades: boolean;
  8387. /**
  8388. * This returns if the loader support the current file information.
  8389. * @param extension defines the file extension of the file being loaded
  8390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8391. * @param fallback defines the fallback internal texture if any
  8392. * @param isBase64 defines whether the texture is encoded as a base64
  8393. * @param isBuffer defines whether the texture data are stored as a buffer
  8394. * @returns true if the loader can load the specified file
  8395. */
  8396. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8397. /**
  8398. * Transform the url before loading if required.
  8399. * @param rootUrl the url of the texture
  8400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8401. * @returns the transformed texture
  8402. */
  8403. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8404. /**
  8405. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8406. * @param rootUrl the url of the texture
  8407. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8408. * @returns the fallback texture
  8409. */
  8410. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8411. /**
  8412. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8413. * @param data contains the texture data
  8414. * @param texture defines the BabylonJS internal texture
  8415. * @param createPolynomials will be true if polynomials have been requested
  8416. * @param onLoad defines the callback to trigger once the texture is ready
  8417. * @param onError defines the callback to trigger in case of error
  8418. */
  8419. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8420. /**
  8421. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8422. * @param data contains the texture data
  8423. * @param texture defines the BabylonJS internal texture
  8424. * @param callback defines the method to call once ready to upload
  8425. */
  8426. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8427. }
  8428. }
  8429. declare module BABYLON {
  8430. interface Engine {
  8431. /**
  8432. * Creates a depth stencil cube texture.
  8433. * This is only available in WebGL 2.
  8434. * @param size The size of face edge in the cube texture.
  8435. * @param options The options defining the cube texture.
  8436. * @returns The cube texture
  8437. */
  8438. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8439. /**
  8440. * Creates a cube texture
  8441. * @param rootUrl defines the url where the files to load is located
  8442. * @param scene defines the current scene
  8443. * @param files defines the list of files to load (1 per face)
  8444. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8445. * @param onLoad defines an optional callback raised when the texture is loaded
  8446. * @param onError defines an optional callback raised if there is an issue to load the texture
  8447. * @param format defines the format of the data
  8448. * @param forcedExtension defines the extension to use to pick the right loader
  8449. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8450. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8451. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8452. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8453. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8454. * @returns the cube texture as an InternalTexture
  8455. */
  8456. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8457. /**
  8458. * Creates a cube texture
  8459. * @param rootUrl defines the url where the files to load is located
  8460. * @param scene defines the current scene
  8461. * @param files defines the list of files to load (1 per face)
  8462. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8463. * @param onLoad defines an optional callback raised when the texture is loaded
  8464. * @param onError defines an optional callback raised if there is an issue to load the texture
  8465. * @param format defines the format of the data
  8466. * @param forcedExtension defines the extension to use to pick the right loader
  8467. * @returns the cube texture as an InternalTexture
  8468. */
  8469. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8470. /**
  8471. * Creates a cube texture
  8472. * @param rootUrl defines the url where the files to load is located
  8473. * @param scene defines the current scene
  8474. * @param files defines the list of files to load (1 per face)
  8475. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8476. * @param onLoad defines an optional callback raised when the texture is loaded
  8477. * @param onError defines an optional callback raised if there is an issue to load the texture
  8478. * @param format defines the format of the data
  8479. * @param forcedExtension defines the extension to use to pick the right loader
  8480. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8481. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8482. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8483. * @returns the cube texture as an InternalTexture
  8484. */
  8485. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8486. /** @hidden */
  8487. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8488. /** @hidden */
  8489. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8490. /** @hidden */
  8491. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8492. /** @hidden */
  8493. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8494. }
  8495. }
  8496. declare module BABYLON {
  8497. /**
  8498. * Class for creating a cube texture
  8499. */
  8500. export class CubeTexture extends BaseTexture {
  8501. private _delayedOnLoad;
  8502. /**
  8503. * The url of the texture
  8504. */
  8505. url: string;
  8506. /**
  8507. * Gets or sets the center of the bounding box associated with the cube texture.
  8508. * It must define where the camera used to render the texture was set
  8509. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8510. */
  8511. boundingBoxPosition: Vector3;
  8512. private _boundingBoxSize;
  8513. /**
  8514. * Gets or sets the size of the bounding box associated with the cube texture
  8515. * When defined, the cubemap will switch to local mode
  8516. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8517. * @example https://www.babylonjs-playground.com/#RNASML
  8518. */
  8519. /**
  8520. * Returns the bounding box size
  8521. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8522. */
  8523. boundingBoxSize: Vector3;
  8524. protected _rotationY: number;
  8525. /**
  8526. * Sets texture matrix rotation angle around Y axis in radians.
  8527. */
  8528. /**
  8529. * Gets texture matrix rotation angle around Y axis radians.
  8530. */
  8531. rotationY: number;
  8532. /**
  8533. * Are mip maps generated for this texture or not.
  8534. */
  8535. readonly noMipmap: boolean;
  8536. private _noMipmap;
  8537. private _files;
  8538. private _extensions;
  8539. private _textureMatrix;
  8540. private _format;
  8541. private _createPolynomials;
  8542. /** @hidden */
  8543. _prefiltered: boolean;
  8544. /**
  8545. * Creates a cube texture from an array of image urls
  8546. * @param files defines an array of image urls
  8547. * @param scene defines the hosting scene
  8548. * @param noMipmap specifies if mip maps are not used
  8549. * @returns a cube texture
  8550. */
  8551. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8552. /**
  8553. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8554. * @param url defines the url of the prefiltered texture
  8555. * @param scene defines the scene the texture is attached to
  8556. * @param forcedExtension defines the extension of the file if different from the url
  8557. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8558. * @return the prefiltered texture
  8559. */
  8560. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8561. /**
  8562. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8563. * as prefiltered data.
  8564. * @param rootUrl defines the url of the texture or the root name of the six images
  8565. * @param scene defines the scene the texture is attached to
  8566. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8567. * @param noMipmap defines if mipmaps should be created or not
  8568. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8569. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8570. * @param onError defines a callback triggered in case of error during load
  8571. * @param format defines the internal format to use for the texture once loaded
  8572. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8573. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8574. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8575. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8576. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8577. * @return the cube texture
  8578. */
  8579. 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);
  8580. /**
  8581. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8582. */
  8583. readonly isPrefiltered: boolean;
  8584. /**
  8585. * Get the current class name of the texture useful for serialization or dynamic coding.
  8586. * @returns "CubeTexture"
  8587. */
  8588. getClassName(): string;
  8589. /**
  8590. * Update the url (and optional buffer) of this texture if url was null during construction.
  8591. * @param url the url of the texture
  8592. * @param forcedExtension defines the extension to use
  8593. * @param onLoad callback called when the texture is loaded (defaults to null)
  8594. */
  8595. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8596. /**
  8597. * Delays loading of the cube texture
  8598. * @param forcedExtension defines the extension to use
  8599. */
  8600. delayLoad(forcedExtension?: string): void;
  8601. /**
  8602. * Returns the reflection texture matrix
  8603. * @returns the reflection texture matrix
  8604. */
  8605. getReflectionTextureMatrix(): Matrix;
  8606. /**
  8607. * Sets the reflection texture matrix
  8608. * @param value Reflection texture matrix
  8609. */
  8610. setReflectionTextureMatrix(value: Matrix): void;
  8611. /**
  8612. * Parses text to create a cube texture
  8613. * @param parsedTexture define the serialized text to read from
  8614. * @param scene defines the hosting scene
  8615. * @param rootUrl defines the root url of the cube texture
  8616. * @returns a cube texture
  8617. */
  8618. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8619. /**
  8620. * Makes a clone, or deep copy, of the cube texture
  8621. * @returns a new cube texture
  8622. */
  8623. clone(): CubeTexture;
  8624. }
  8625. }
  8626. declare module BABYLON {
  8627. /** @hidden */
  8628. export var postprocessVertexShader: {
  8629. name: string;
  8630. shader: string;
  8631. };
  8632. }
  8633. declare module BABYLON {
  8634. /**
  8635. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8636. * This is the base of the follow, arc rotate cameras and Free camera
  8637. * @see http://doc.babylonjs.com/features/cameras
  8638. */
  8639. export class TargetCamera extends Camera {
  8640. private static _RigCamTransformMatrix;
  8641. private static _TargetTransformMatrix;
  8642. private static _TargetFocalPoint;
  8643. /**
  8644. * Define the current direction the camera is moving to
  8645. */
  8646. cameraDirection: Vector3;
  8647. /**
  8648. * Define the current rotation the camera is rotating to
  8649. */
  8650. cameraRotation: Vector2;
  8651. /**
  8652. * When set, the up vector of the camera will be updated by the rotation of the camera
  8653. */
  8654. updateUpVectorFromRotation: boolean;
  8655. private _tmpQuaternion;
  8656. /**
  8657. * Define the current rotation of the camera
  8658. */
  8659. rotation: Vector3;
  8660. /**
  8661. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8662. */
  8663. rotationQuaternion: Quaternion;
  8664. /**
  8665. * Define the current speed of the camera
  8666. */
  8667. speed: number;
  8668. /**
  8669. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8670. * around all axis.
  8671. */
  8672. noRotationConstraint: boolean;
  8673. /**
  8674. * Define the current target of the camera as an object or a position.
  8675. */
  8676. lockedTarget: any;
  8677. /** @hidden */
  8678. _currentTarget: Vector3;
  8679. /** @hidden */
  8680. _initialFocalDistance: number;
  8681. /** @hidden */
  8682. _viewMatrix: Matrix;
  8683. /** @hidden */
  8684. _camMatrix: Matrix;
  8685. /** @hidden */
  8686. _cameraTransformMatrix: Matrix;
  8687. /** @hidden */
  8688. _cameraRotationMatrix: Matrix;
  8689. /** @hidden */
  8690. _referencePoint: Vector3;
  8691. /** @hidden */
  8692. _transformedReferencePoint: Vector3;
  8693. protected _globalCurrentTarget: Vector3;
  8694. protected _globalCurrentUpVector: Vector3;
  8695. /** @hidden */
  8696. _reset: () => void;
  8697. private _defaultUp;
  8698. /**
  8699. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8700. * This is the base of the follow, arc rotate cameras and Free camera
  8701. * @see http://doc.babylonjs.com/features/cameras
  8702. * @param name Defines the name of the camera in the scene
  8703. * @param position Defines the start position of the camera in the scene
  8704. * @param scene Defines the scene the camera belongs to
  8705. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8706. */
  8707. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8708. /**
  8709. * Gets the position in front of the camera at a given distance.
  8710. * @param distance The distance from the camera we want the position to be
  8711. * @returns the position
  8712. */
  8713. getFrontPosition(distance: number): Vector3;
  8714. /** @hidden */
  8715. _getLockedTargetPosition(): Nullable<Vector3>;
  8716. private _storedPosition;
  8717. private _storedRotation;
  8718. private _storedRotationQuaternion;
  8719. /**
  8720. * Store current camera state of the camera (fov, position, rotation, etc..)
  8721. * @returns the camera
  8722. */
  8723. storeState(): Camera;
  8724. /**
  8725. * Restored camera state. You must call storeState() first
  8726. * @returns whether it was successful or not
  8727. * @hidden
  8728. */
  8729. _restoreStateValues(): boolean;
  8730. /** @hidden */
  8731. _initCache(): void;
  8732. /** @hidden */
  8733. _updateCache(ignoreParentClass?: boolean): void;
  8734. /** @hidden */
  8735. _isSynchronizedViewMatrix(): boolean;
  8736. /** @hidden */
  8737. _computeLocalCameraSpeed(): number;
  8738. /**
  8739. * Defines the target the camera should look at.
  8740. * This will automatically adapt alpha beta and radius to fit within the new target.
  8741. * @param target Defines the new target as a Vector or a mesh
  8742. */
  8743. setTarget(target: Vector3): void;
  8744. /**
  8745. * Return the current target position of the camera. This value is expressed in local space.
  8746. * @returns the target position
  8747. */
  8748. getTarget(): Vector3;
  8749. /** @hidden */
  8750. _decideIfNeedsToMove(): boolean;
  8751. /** @hidden */
  8752. _updatePosition(): void;
  8753. /** @hidden */
  8754. _checkInputs(): void;
  8755. protected _updateCameraRotationMatrix(): void;
  8756. /**
  8757. * 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)
  8758. * @returns the current camera
  8759. */
  8760. private _rotateUpVectorWithCameraRotationMatrix;
  8761. private _cachedRotationZ;
  8762. private _cachedQuaternionRotationZ;
  8763. /** @hidden */
  8764. _getViewMatrix(): Matrix;
  8765. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8766. /**
  8767. * @hidden
  8768. */
  8769. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8770. /**
  8771. * @hidden
  8772. */
  8773. _updateRigCameras(): void;
  8774. private _getRigCamPositionAndTarget;
  8775. /**
  8776. * Gets the current object class name.
  8777. * @return the class name
  8778. */
  8779. getClassName(): string;
  8780. }
  8781. }
  8782. declare module BABYLON {
  8783. /**
  8784. * @ignore
  8785. * This is a list of all the different input types that are available in the application.
  8786. * Fo instance: ArcRotateCameraGamepadInput...
  8787. */
  8788. export var CameraInputTypes: {};
  8789. /**
  8790. * This is the contract to implement in order to create a new input class.
  8791. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8792. */
  8793. export interface ICameraInput<TCamera extends Camera> {
  8794. /**
  8795. * Defines the camera the input is attached to.
  8796. */
  8797. camera: Nullable<TCamera>;
  8798. /**
  8799. * Gets the class name of the current intput.
  8800. * @returns the class name
  8801. */
  8802. getClassName(): string;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. /**
  8809. * Attach the input controls to a specific dom element to get the input from.
  8810. * @param element Defines the element the controls should be listened from
  8811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8812. */
  8813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8814. /**
  8815. * Detach the current controls from the specified dom element.
  8816. * @param element Defines the element to stop listening the inputs from
  8817. */
  8818. detachControl(element: Nullable<HTMLElement>): void;
  8819. /**
  8820. * Update the current camera state depending on the inputs that have been used this frame.
  8821. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8822. */
  8823. checkInputs?: () => void;
  8824. }
  8825. /**
  8826. * Represents a map of input types to input instance or input index to input instance.
  8827. */
  8828. export interface CameraInputsMap<TCamera extends Camera> {
  8829. /**
  8830. * Accessor to the input by input type.
  8831. */
  8832. [name: string]: ICameraInput<TCamera>;
  8833. /**
  8834. * Accessor to the input by input index.
  8835. */
  8836. [idx: number]: ICameraInput<TCamera>;
  8837. }
  8838. /**
  8839. * This represents the input manager used within a camera.
  8840. * It helps dealing with all the different kind of input attached to a camera.
  8841. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8842. */
  8843. export class CameraInputsManager<TCamera extends Camera> {
  8844. /**
  8845. * Defines the list of inputs attahed to the camera.
  8846. */
  8847. attached: CameraInputsMap<TCamera>;
  8848. /**
  8849. * Defines the dom element the camera is collecting inputs from.
  8850. * This is null if the controls have not been attached.
  8851. */
  8852. attachedElement: Nullable<HTMLElement>;
  8853. /**
  8854. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8855. */
  8856. noPreventDefault: boolean;
  8857. /**
  8858. * Defined the camera the input manager belongs to.
  8859. */
  8860. camera: TCamera;
  8861. /**
  8862. * Update the current camera state depending on the inputs that have been used this frame.
  8863. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8864. */
  8865. checkInputs: () => void;
  8866. /**
  8867. * Instantiate a new Camera Input Manager.
  8868. * @param camera Defines the camera the input manager blongs to
  8869. */
  8870. constructor(camera: TCamera);
  8871. /**
  8872. * Add an input method to a camera
  8873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8874. * @param input camera input method
  8875. */
  8876. add(input: ICameraInput<TCamera>): void;
  8877. /**
  8878. * Remove a specific input method from a camera
  8879. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8880. * @param inputToRemove camera input method
  8881. */
  8882. remove(inputToRemove: ICameraInput<TCamera>): void;
  8883. /**
  8884. * Remove a specific input type from a camera
  8885. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8886. * @param inputType the type of the input to remove
  8887. */
  8888. removeByType(inputType: string): void;
  8889. private _addCheckInputs;
  8890. /**
  8891. * Attach the input controls to the currently attached dom element to listen the events from.
  8892. * @param input Defines the input to attach
  8893. */
  8894. attachInput(input: ICameraInput<TCamera>): void;
  8895. /**
  8896. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8897. * @param element Defines the dom element to collect the events from
  8898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8899. */
  8900. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8901. /**
  8902. * Detach the current manager inputs controls from a specific dom element.
  8903. * @param element Defines the dom element to collect the events from
  8904. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8905. */
  8906. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8907. /**
  8908. * Rebuild the dynamic inputCheck function from the current list of
  8909. * defined inputs in the manager.
  8910. */
  8911. rebuildInputCheck(): void;
  8912. /**
  8913. * Remove all attached input methods from a camera
  8914. */
  8915. clear(): void;
  8916. /**
  8917. * Serialize the current input manager attached to a camera.
  8918. * This ensures than once parsed,
  8919. * the input associated to the camera will be identical to the current ones
  8920. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8921. */
  8922. serialize(serializedCamera: any): void;
  8923. /**
  8924. * Parses an input manager serialized JSON to restore the previous list of inputs
  8925. * and states associated to a camera.
  8926. * @param parsedCamera Defines the JSON to parse
  8927. */
  8928. parse(parsedCamera: any): void;
  8929. }
  8930. }
  8931. declare module BABYLON {
  8932. /**
  8933. * Gather the list of keyboard event types as constants.
  8934. */
  8935. export class KeyboardEventTypes {
  8936. /**
  8937. * The keydown event is fired when a key becomes active (pressed).
  8938. */
  8939. static readonly KEYDOWN: number;
  8940. /**
  8941. * The keyup event is fired when a key has been released.
  8942. */
  8943. static readonly KEYUP: number;
  8944. }
  8945. /**
  8946. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8947. */
  8948. export class KeyboardInfo {
  8949. /**
  8950. * Defines the type of event (KeyboardEventTypes)
  8951. */
  8952. type: number;
  8953. /**
  8954. * Defines the related dom event
  8955. */
  8956. event: KeyboardEvent;
  8957. /**
  8958. * Instantiates a new keyboard info.
  8959. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8960. * @param type Defines the type of event (KeyboardEventTypes)
  8961. * @param event Defines the related dom event
  8962. */
  8963. constructor(
  8964. /**
  8965. * Defines the type of event (KeyboardEventTypes)
  8966. */
  8967. type: number,
  8968. /**
  8969. * Defines the related dom event
  8970. */
  8971. event: KeyboardEvent);
  8972. }
  8973. /**
  8974. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8975. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8976. */
  8977. export class KeyboardInfoPre extends KeyboardInfo {
  8978. /**
  8979. * Defines the type of event (KeyboardEventTypes)
  8980. */
  8981. type: number;
  8982. /**
  8983. * Defines the related dom event
  8984. */
  8985. event: KeyboardEvent;
  8986. /**
  8987. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8988. */
  8989. skipOnPointerObservable: boolean;
  8990. /**
  8991. * Instantiates a new keyboard pre info.
  8992. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8993. * @param type Defines the type of event (KeyboardEventTypes)
  8994. * @param event Defines the related dom event
  8995. */
  8996. constructor(
  8997. /**
  8998. * Defines the type of event (KeyboardEventTypes)
  8999. */
  9000. type: number,
  9001. /**
  9002. * Defines the related dom event
  9003. */
  9004. event: KeyboardEvent);
  9005. }
  9006. }
  9007. declare module BABYLON {
  9008. /**
  9009. * Manage the keyboard inputs to control the movement of a free camera.
  9010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9011. */
  9012. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9013. /**
  9014. * Defines the camera the input is attached to.
  9015. */
  9016. camera: FreeCamera;
  9017. /**
  9018. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9019. */
  9020. keysUp: number[];
  9021. /**
  9022. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9023. */
  9024. keysDown: number[];
  9025. /**
  9026. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9027. */
  9028. keysLeft: number[];
  9029. /**
  9030. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9031. */
  9032. keysRight: number[];
  9033. private _keys;
  9034. private _onCanvasBlurObserver;
  9035. private _onKeyboardObserver;
  9036. private _engine;
  9037. private _scene;
  9038. /**
  9039. * Attach the input controls to a specific dom element to get the input from.
  9040. * @param element Defines the element the controls should be listened from
  9041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9042. */
  9043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9044. /**
  9045. * Detach the current controls from the specified dom element.
  9046. * @param element Defines the element to stop listening the inputs from
  9047. */
  9048. detachControl(element: Nullable<HTMLElement>): void;
  9049. /**
  9050. * Update the current camera state depending on the inputs that have been used this frame.
  9051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9052. */
  9053. checkInputs(): void;
  9054. /**
  9055. * Gets the class name of the current intput.
  9056. * @returns the class name
  9057. */
  9058. getClassName(): string;
  9059. /** @hidden */
  9060. _onLostFocus(): void;
  9061. /**
  9062. * Get the friendly name associated with the input class.
  9063. * @returns the input friendly name
  9064. */
  9065. getSimpleName(): string;
  9066. }
  9067. }
  9068. declare module BABYLON {
  9069. /**
  9070. * Interface describing all the common properties and methods a shadow light needs to implement.
  9071. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9072. * as well as binding the different shadow properties to the effects.
  9073. */
  9074. export interface IShadowLight extends Light {
  9075. /**
  9076. * The light id in the scene (used in scene.findLighById for instance)
  9077. */
  9078. id: string;
  9079. /**
  9080. * The position the shdow will be casted from.
  9081. */
  9082. position: Vector3;
  9083. /**
  9084. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9085. */
  9086. direction: Vector3;
  9087. /**
  9088. * The transformed position. Position of the light in world space taking parenting in account.
  9089. */
  9090. transformedPosition: Vector3;
  9091. /**
  9092. * The transformed direction. Direction of the light in world space taking parenting in account.
  9093. */
  9094. transformedDirection: Vector3;
  9095. /**
  9096. * The friendly name of the light in the scene.
  9097. */
  9098. name: string;
  9099. /**
  9100. * Defines the shadow projection clipping minimum z value.
  9101. */
  9102. shadowMinZ: number;
  9103. /**
  9104. * Defines the shadow projection clipping maximum z value.
  9105. */
  9106. shadowMaxZ: number;
  9107. /**
  9108. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9109. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9110. */
  9111. computeTransformedInformation(): boolean;
  9112. /**
  9113. * Gets the scene the light belongs to.
  9114. * @returns The scene
  9115. */
  9116. getScene(): Scene;
  9117. /**
  9118. * Callback defining a custom Projection Matrix Builder.
  9119. * This can be used to override the default projection matrix computation.
  9120. */
  9121. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9122. /**
  9123. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9124. * @param matrix The materix to updated with the projection information
  9125. * @param viewMatrix The transform matrix of the light
  9126. * @param renderList The list of mesh to render in the map
  9127. * @returns The current light
  9128. */
  9129. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9130. /**
  9131. * Gets the current depth scale used in ESM.
  9132. * @returns The scale
  9133. */
  9134. getDepthScale(): number;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /**
  9150. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9151. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9152. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9153. */
  9154. getShadowDirection(faceIndex?: number): Vector3;
  9155. /**
  9156. * Gets the minZ used for shadow according to both the scene and the light.
  9157. * @param activeCamera The camera we are returning the min for
  9158. * @returns the depth min z
  9159. */
  9160. getDepthMinZ(activeCamera: Camera): number;
  9161. /**
  9162. * Gets the maxZ used for shadow according to both the scene and the light.
  9163. * @param activeCamera The camera we are returning the max for
  9164. * @returns the depth max z
  9165. */
  9166. getDepthMaxZ(activeCamera: Camera): number;
  9167. }
  9168. /**
  9169. * Base implementation IShadowLight
  9170. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9171. */
  9172. export abstract class ShadowLight extends Light implements IShadowLight {
  9173. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9174. protected _position: Vector3;
  9175. protected _setPosition(value: Vector3): void;
  9176. /**
  9177. * Sets the position the shadow will be casted from. Also use as the light position for both
  9178. * point and spot lights.
  9179. */
  9180. /**
  9181. * Sets the position the shadow will be casted from. Also use as the light position for both
  9182. * point and spot lights.
  9183. */
  9184. position: Vector3;
  9185. protected _direction: Vector3;
  9186. protected _setDirection(value: Vector3): void;
  9187. /**
  9188. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9189. * Also use as the light direction on spot and directional lights.
  9190. */
  9191. /**
  9192. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. direction: Vector3;
  9196. private _shadowMinZ;
  9197. /**
  9198. * Gets the shadow projection clipping minimum z value.
  9199. */
  9200. /**
  9201. * Sets the shadow projection clipping minimum z value.
  9202. */
  9203. shadowMinZ: number;
  9204. private _shadowMaxZ;
  9205. /**
  9206. * Sets the shadow projection clipping maximum z value.
  9207. */
  9208. /**
  9209. * Gets the shadow projection clipping maximum z value.
  9210. */
  9211. shadowMaxZ: number;
  9212. /**
  9213. * Callback defining a custom Projection Matrix Builder.
  9214. * This can be used to override the default projection matrix computation.
  9215. */
  9216. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9217. /**
  9218. * The transformed position. Position of the light in world space taking parenting in account.
  9219. */
  9220. transformedPosition: Vector3;
  9221. /**
  9222. * The transformed direction. Direction of the light in world space taking parenting in account.
  9223. */
  9224. transformedDirection: Vector3;
  9225. private _needProjectionMatrixCompute;
  9226. /**
  9227. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9228. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9229. */
  9230. computeTransformedInformation(): boolean;
  9231. /**
  9232. * Return the depth scale used for the shadow map.
  9233. * @returns the depth scale.
  9234. */
  9235. getDepthScale(): number;
  9236. /**
  9237. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9238. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9239. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9240. */
  9241. getShadowDirection(faceIndex?: number): Vector3;
  9242. /**
  9243. * Returns the ShadowLight absolute position in the World.
  9244. * @returns the position vector in world space
  9245. */
  9246. getAbsolutePosition(): Vector3;
  9247. /**
  9248. * Sets the ShadowLight direction toward the passed target.
  9249. * @param target The point to target in local space
  9250. * @returns the updated ShadowLight direction
  9251. */
  9252. setDirectionToTarget(target: Vector3): Vector3;
  9253. /**
  9254. * Returns the light rotation in euler definition.
  9255. * @returns the x y z rotation in local space.
  9256. */
  9257. getRotation(): Vector3;
  9258. /**
  9259. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9260. * @returns true if a cube texture needs to be use
  9261. */
  9262. needCube(): boolean;
  9263. /**
  9264. * Detects if the projection matrix requires to be recomputed this frame.
  9265. * @returns true if it requires to be recomputed otherwise, false.
  9266. */
  9267. needProjectionMatrixCompute(): boolean;
  9268. /**
  9269. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9270. */
  9271. forceProjectionMatrixCompute(): void;
  9272. /** @hidden */
  9273. _initCache(): void;
  9274. /** @hidden */
  9275. _isSynchronized(): boolean;
  9276. /**
  9277. * Computes the world matrix of the node
  9278. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9279. * @returns the world matrix
  9280. */
  9281. computeWorldMatrix(force?: boolean): Matrix;
  9282. /**
  9283. * Gets the minZ used for shadow according to both the scene and the light.
  9284. * @param activeCamera The camera we are returning the min for
  9285. * @returns the depth min z
  9286. */
  9287. getDepthMinZ(activeCamera: Camera): number;
  9288. /**
  9289. * Gets the maxZ used for shadow according to both the scene and the light.
  9290. * @param activeCamera The camera we are returning the max for
  9291. * @returns the depth max z
  9292. */
  9293. getDepthMaxZ(activeCamera: Camera): number;
  9294. /**
  9295. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9296. * @param matrix The materix to updated with the projection information
  9297. * @param viewMatrix The transform matrix of the light
  9298. * @param renderList The list of mesh to render in the map
  9299. * @returns The current light
  9300. */
  9301. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9302. }
  9303. }
  9304. declare module BABYLON {
  9305. /**
  9306. * "Static Class" containing the most commonly used helper while dealing with material for
  9307. * rendering purpose.
  9308. *
  9309. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9310. *
  9311. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9312. */
  9313. export class MaterialHelper {
  9314. /**
  9315. * Bind the current view position to an effect.
  9316. * @param effect The effect to be bound
  9317. * @param scene The scene the eyes position is used from
  9318. */
  9319. static BindEyePosition(effect: Effect, scene: Scene): void;
  9320. /**
  9321. * Helps preparing the defines values about the UVs in used in the effect.
  9322. * UVs are shared as much as we can accross channels in the shaders.
  9323. * @param texture The texture we are preparing the UVs for
  9324. * @param defines The defines to update
  9325. * @param key The channel key "diffuse", "specular"... used in the shader
  9326. */
  9327. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9328. /**
  9329. * Binds a texture matrix value to its corrsponding uniform
  9330. * @param texture The texture to bind the matrix for
  9331. * @param uniformBuffer The uniform buffer receivin the data
  9332. * @param key The channel key "diffuse", "specular"... used in the shader
  9333. */
  9334. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9335. /**
  9336. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9337. * @param mesh defines the current mesh
  9338. * @param scene defines the current scene
  9339. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9340. * @param pointsCloud defines if point cloud rendering has to be turned on
  9341. * @param fogEnabled defines if fog has to be turned on
  9342. * @param alphaTest defines if alpha testing has to be turned on
  9343. * @param defines defines the current list of defines
  9344. */
  9345. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9346. /**
  9347. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9348. * @param scene defines the current scene
  9349. * @param engine defines the current engine
  9350. * @param defines specifies the list of active defines
  9351. * @param useInstances defines if instances have to be turned on
  9352. * @param useClipPlane defines if clip plane have to be turned on
  9353. */
  9354. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9355. /**
  9356. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9357. * @param mesh The mesh containing the geometry data we will draw
  9358. * @param defines The defines to update
  9359. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9360. * @param useBones Precise whether bones should be used or not (override mesh info)
  9361. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9362. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9363. * @returns false if defines are considered not dirty and have not been checked
  9364. */
  9365. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9366. /**
  9367. * Prepares the defines related to multiview
  9368. * @param scene The scene we are intending to draw
  9369. * @param defines The defines to update
  9370. */
  9371. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9372. /**
  9373. * Prepares the defines related to the light information passed in parameter
  9374. * @param scene The scene we are intending to draw
  9375. * @param mesh The mesh the effect is compiling for
  9376. * @param defines The defines to update
  9377. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9378. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9379. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9380. * @returns true if normals will be required for the rest of the effect
  9381. */
  9382. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9383. /**
  9384. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9385. * that won t be acctive due to defines being turned off.
  9386. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9387. * @param samplersList The samplers list
  9388. * @param defines The defines helping in the list generation
  9389. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9390. */
  9391. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9392. /**
  9393. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9394. * @param defines The defines to update while falling back
  9395. * @param fallbacks The authorized effect fallbacks
  9396. * @param maxSimultaneousLights The maximum number of lights allowed
  9397. * @param rank the current rank of the Effect
  9398. * @returns The newly affected rank
  9399. */
  9400. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9401. /**
  9402. * Prepares the list of attributes required for morph targets according to the effect defines.
  9403. * @param attribs The current list of supported attribs
  9404. * @param mesh The mesh to prepare the morph targets attributes for
  9405. * @param defines The current Defines of the effect
  9406. */
  9407. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9408. /**
  9409. * Prepares the list of attributes required for bones according to the effect defines.
  9410. * @param attribs The current list of supported attribs
  9411. * @param mesh The mesh to prepare the bones attributes for
  9412. * @param defines The current Defines of the effect
  9413. * @param fallbacks The current efffect fallback strategy
  9414. */
  9415. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9416. /**
  9417. * Prepares the list of attributes required for instances according to the effect defines.
  9418. * @param attribs The current list of supported attribs
  9419. * @param defines The current Defines of the effect
  9420. */
  9421. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9422. /**
  9423. * Binds the light shadow information to the effect for the given mesh.
  9424. * @param light The light containing the generator
  9425. * @param scene The scene the lights belongs to
  9426. * @param mesh The mesh we are binding the information to render
  9427. * @param lightIndex The light index in the effect used to render the mesh
  9428. * @param effect The effect we are binding the data to
  9429. */
  9430. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9431. /**
  9432. * Binds the light information to the effect.
  9433. * @param light The light containing the generator
  9434. * @param effect The effect we are binding the data to
  9435. * @param lightIndex The light index in the effect used to render
  9436. */
  9437. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9438. /**
  9439. * Binds the lights information from the scene to the effect for the given mesh.
  9440. * @param scene The scene the lights belongs to
  9441. * @param mesh The mesh we are binding the information to render
  9442. * @param effect The effect we are binding the data to
  9443. * @param defines The generated defines for the effect
  9444. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9445. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9446. */
  9447. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9448. private static _tempFogColor;
  9449. /**
  9450. * Binds the fog information from the scene to the effect for the given mesh.
  9451. * @param scene The scene the lights belongs to
  9452. * @param mesh The mesh we are binding the information to render
  9453. * @param effect The effect we are binding the data to
  9454. * @param linearSpace Defines if the fog effect is applied in linear space
  9455. */
  9456. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9457. /**
  9458. * Binds the bones information from the mesh to the effect.
  9459. * @param mesh The mesh we are binding the information to render
  9460. * @param effect The effect we are binding the data to
  9461. */
  9462. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9463. /**
  9464. * Binds the morph targets information from the mesh to the effect.
  9465. * @param abstractMesh The mesh we are binding the information to render
  9466. * @param effect The effect we are binding the data to
  9467. */
  9468. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9469. /**
  9470. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9471. * @param defines The generated defines used in the effect
  9472. * @param effect The effect we are binding the data to
  9473. * @param scene The scene we are willing to render with logarithmic scale for
  9474. */
  9475. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9476. /**
  9477. * Binds the clip plane information from the scene to the effect.
  9478. * @param scene The scene the clip plane information are extracted from
  9479. * @param effect The effect we are binding the data to
  9480. */
  9481. static BindClipPlane(effect: Effect, scene: Scene): void;
  9482. }
  9483. }
  9484. declare module BABYLON {
  9485. /** @hidden */
  9486. export var kernelBlurVaryingDeclaration: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module BABYLON {
  9492. /** @hidden */
  9493. export var kernelBlurFragment: {
  9494. name: string;
  9495. shader: string;
  9496. };
  9497. }
  9498. declare module BABYLON {
  9499. /** @hidden */
  9500. export var kernelBlurFragment2: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module BABYLON {
  9506. /** @hidden */
  9507. export var kernelBlurPixelShader: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module BABYLON {
  9513. /** @hidden */
  9514. export var kernelBlurVertex: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module BABYLON {
  9520. /** @hidden */
  9521. export var kernelBlurVertexShader: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * The Blur Post Process which blurs an image based on a kernel and direction.
  9529. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9530. */
  9531. export class BlurPostProcess extends PostProcess {
  9532. /** The direction in which to blur the image. */
  9533. direction: Vector2;
  9534. private blockCompilation;
  9535. protected _kernel: number;
  9536. protected _idealKernel: number;
  9537. protected _packedFloat: boolean;
  9538. private _staticDefines;
  9539. /**
  9540. * Sets the length in pixels of the blur sample region
  9541. */
  9542. /**
  9543. * Gets the length in pixels of the blur sample region
  9544. */
  9545. kernel: number;
  9546. /**
  9547. * Sets wether or not the blur needs to unpack/repack floats
  9548. */
  9549. /**
  9550. * Gets wether or not the blur is unpacking/repacking floats
  9551. */
  9552. packedFloat: boolean;
  9553. /**
  9554. * Creates a new instance BlurPostProcess
  9555. * @param name The name of the effect.
  9556. * @param direction The direction in which to blur the image.
  9557. * @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.
  9558. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9559. * @param camera The camera to apply the render pass to.
  9560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9561. * @param engine The engine which the post process will be applied. (default: current engine)
  9562. * @param reusable If the post process can be reused on the same frame. (default: false)
  9563. * @param textureType Type of textures used when performing the post process. (default: 0)
  9564. * @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)
  9565. */
  9566. constructor(name: string,
  9567. /** The direction in which to blur the image. */
  9568. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9569. /**
  9570. * Updates the effect with the current post process compile time values and recompiles the shader.
  9571. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9572. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9573. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9574. * @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
  9575. * @param onCompiled Called when the shader has been compiled.
  9576. * @param onError Called if there is an error when compiling a shader.
  9577. */
  9578. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9579. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9580. /**
  9581. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9582. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9583. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9584. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9585. * The gaps between physical kernels are compensated for in the weighting of the samples
  9586. * @param idealKernel Ideal blur kernel.
  9587. * @return Nearest best kernel.
  9588. */
  9589. protected _nearestBestKernel(idealKernel: number): number;
  9590. /**
  9591. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9592. * @param x The point on the Gaussian distribution to sample.
  9593. * @return the value of the Gaussian function at x.
  9594. */
  9595. protected _gaussianWeight(x: number): number;
  9596. /**
  9597. * Generates a string that can be used as a floating point number in GLSL.
  9598. * @param x Value to print.
  9599. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9600. * @return GLSL float string.
  9601. */
  9602. protected _glslFloat(x: number, decimalFigures?: number): string;
  9603. }
  9604. }
  9605. declare module BABYLON {
  9606. /** @hidden */
  9607. export var shadowMapPixelShader: {
  9608. name: string;
  9609. shader: string;
  9610. };
  9611. }
  9612. declare module BABYLON {
  9613. /** @hidden */
  9614. export var bonesDeclaration: {
  9615. name: string;
  9616. shader: string;
  9617. };
  9618. }
  9619. declare module BABYLON {
  9620. /** @hidden */
  9621. export var morphTargetsVertexGlobalDeclaration: {
  9622. name: string;
  9623. shader: string;
  9624. };
  9625. }
  9626. declare module BABYLON {
  9627. /** @hidden */
  9628. export var morphTargetsVertexDeclaration: {
  9629. name: string;
  9630. shader: string;
  9631. };
  9632. }
  9633. declare module BABYLON {
  9634. /** @hidden */
  9635. export var instancesDeclaration: {
  9636. name: string;
  9637. shader: string;
  9638. };
  9639. }
  9640. declare module BABYLON {
  9641. /** @hidden */
  9642. export var helperFunctions: {
  9643. name: string;
  9644. shader: string;
  9645. };
  9646. }
  9647. declare module BABYLON {
  9648. /** @hidden */
  9649. export var morphTargetsVertex: {
  9650. name: string;
  9651. shader: string;
  9652. };
  9653. }
  9654. declare module BABYLON {
  9655. /** @hidden */
  9656. export var instancesVertex: {
  9657. name: string;
  9658. shader: string;
  9659. };
  9660. }
  9661. declare module BABYLON {
  9662. /** @hidden */
  9663. export var bonesVertex: {
  9664. name: string;
  9665. shader: string;
  9666. };
  9667. }
  9668. declare module BABYLON {
  9669. /** @hidden */
  9670. export var shadowMapVertexShader: {
  9671. name: string;
  9672. shader: string;
  9673. };
  9674. }
  9675. declare module BABYLON {
  9676. /** @hidden */
  9677. export var depthBoxBlurPixelShader: {
  9678. name: string;
  9679. shader: string;
  9680. };
  9681. }
  9682. declare module BABYLON {
  9683. /**
  9684. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9685. */
  9686. export interface ICustomShaderOptions {
  9687. /**
  9688. * Gets or sets the custom shader name to use
  9689. */
  9690. shaderName: string;
  9691. /**
  9692. * The list of attribute names used in the shader
  9693. */
  9694. attributes?: string[];
  9695. /**
  9696. * The list of unifrom names used in the shader
  9697. */
  9698. uniforms?: string[];
  9699. /**
  9700. * The list of sampler names used in the shader
  9701. */
  9702. samplers?: string[];
  9703. /**
  9704. * The list of defines used in the shader
  9705. */
  9706. defines?: string[];
  9707. }
  9708. /**
  9709. * Interface to implement to create a shadow generator compatible with BJS.
  9710. */
  9711. export interface IShadowGenerator {
  9712. /**
  9713. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9714. * @returns The render target texture if present otherwise, null
  9715. */
  9716. getShadowMap(): Nullable<RenderTargetTexture>;
  9717. /**
  9718. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9719. * @returns The render target texture if the shadow map is present otherwise, null
  9720. */
  9721. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9722. /**
  9723. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9724. * @param subMesh The submesh we want to render in the shadow map
  9725. * @param useInstances Defines wether will draw in the map using instances
  9726. * @returns true if ready otherwise, false
  9727. */
  9728. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9729. /**
  9730. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9731. * @param defines Defines of the material we want to update
  9732. * @param lightIndex Index of the light in the enabled light list of the material
  9733. */
  9734. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9735. /**
  9736. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9737. * defined in the generator but impacting the effect).
  9738. * It implies the unifroms available on the materials are the standard BJS ones.
  9739. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9740. * @param effect The effect we are binfing the information for
  9741. */
  9742. bindShadowLight(lightIndex: string, effect: Effect): void;
  9743. /**
  9744. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9745. * (eq to shadow prjection matrix * light transform matrix)
  9746. * @returns The transform matrix used to create the shadow map
  9747. */
  9748. getTransformMatrix(): Matrix;
  9749. /**
  9750. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9751. * Cube and 2D textures for instance.
  9752. */
  9753. recreateShadowMap(): void;
  9754. /**
  9755. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9756. * @param onCompiled Callback triggered at the and of the effects compilation
  9757. * @param options Sets of optional options forcing the compilation with different modes
  9758. */
  9759. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9760. useInstances: boolean;
  9761. }>): void;
  9762. /**
  9763. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9764. * @param options Sets of optional options forcing the compilation with different modes
  9765. * @returns A promise that resolves when the compilation completes
  9766. */
  9767. forceCompilationAsync(options?: Partial<{
  9768. useInstances: boolean;
  9769. }>): Promise<void>;
  9770. /**
  9771. * Serializes the shadow generator setup to a json object.
  9772. * @returns The serialized JSON object
  9773. */
  9774. serialize(): any;
  9775. /**
  9776. * Disposes the Shadow map and related Textures and effects.
  9777. */
  9778. dispose(): void;
  9779. }
  9780. /**
  9781. * Default implementation IShadowGenerator.
  9782. * This is the main object responsible of generating shadows in the framework.
  9783. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9784. */
  9785. export class ShadowGenerator implements IShadowGenerator {
  9786. /**
  9787. * Shadow generator mode None: no filtering applied.
  9788. */
  9789. static readonly FILTER_NONE: number;
  9790. /**
  9791. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9792. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9793. */
  9794. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9795. /**
  9796. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9797. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9798. */
  9799. static readonly FILTER_POISSONSAMPLING: number;
  9800. /**
  9801. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9802. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9803. */
  9804. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9805. /**
  9806. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9807. * edge artifacts on steep falloff.
  9808. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9809. */
  9810. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9811. /**
  9812. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9813. * edge artifacts on steep falloff.
  9814. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9815. */
  9816. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9817. /**
  9818. * Shadow generator mode PCF: Percentage Closer Filtering
  9819. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9820. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9821. */
  9822. static readonly FILTER_PCF: number;
  9823. /**
  9824. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9825. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9826. * Contact Hardening
  9827. */
  9828. static readonly FILTER_PCSS: number;
  9829. /**
  9830. * Reserved for PCF and PCSS
  9831. * Highest Quality.
  9832. *
  9833. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9834. *
  9835. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9836. */
  9837. static readonly QUALITY_HIGH: number;
  9838. /**
  9839. * Reserved for PCF and PCSS
  9840. * Good tradeoff for quality/perf cross devices
  9841. *
  9842. * Execute PCF on a 3*3 kernel.
  9843. *
  9844. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9845. */
  9846. static readonly QUALITY_MEDIUM: number;
  9847. /**
  9848. * Reserved for PCF and PCSS
  9849. * The lowest quality but the fastest.
  9850. *
  9851. * Execute PCF on a 1*1 kernel.
  9852. *
  9853. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9854. */
  9855. static readonly QUALITY_LOW: number;
  9856. /** Gets or sets the custom shader name to use */
  9857. customShaderOptions: ICustomShaderOptions;
  9858. /**
  9859. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9860. */
  9861. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9862. /**
  9863. * Observable triggered before a mesh is rendered in the shadow map.
  9864. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9865. */
  9866. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9867. private _bias;
  9868. /**
  9869. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9870. */
  9871. /**
  9872. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9873. */
  9874. bias: number;
  9875. private _normalBias;
  9876. /**
  9877. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9878. */
  9879. /**
  9880. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9881. */
  9882. normalBias: number;
  9883. private _blurBoxOffset;
  9884. /**
  9885. * Gets the blur box offset: offset applied during the blur pass.
  9886. * Only useful if useKernelBlur = false
  9887. */
  9888. /**
  9889. * Sets the blur box offset: offset applied during the blur pass.
  9890. * Only useful if useKernelBlur = false
  9891. */
  9892. blurBoxOffset: number;
  9893. private _blurScale;
  9894. /**
  9895. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9896. * 2 means half of the size.
  9897. */
  9898. /**
  9899. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9900. * 2 means half of the size.
  9901. */
  9902. blurScale: number;
  9903. private _blurKernel;
  9904. /**
  9905. * Gets the blur kernel: kernel size of the blur pass.
  9906. * Only useful if useKernelBlur = true
  9907. */
  9908. /**
  9909. * Sets the blur kernel: kernel size of the blur pass.
  9910. * Only useful if useKernelBlur = true
  9911. */
  9912. blurKernel: number;
  9913. private _useKernelBlur;
  9914. /**
  9915. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9916. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9917. */
  9918. /**
  9919. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9920. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9921. */
  9922. useKernelBlur: boolean;
  9923. private _depthScale;
  9924. /**
  9925. * Gets the depth scale used in ESM mode.
  9926. */
  9927. /**
  9928. * Sets the depth scale used in ESM mode.
  9929. * This can override the scale stored on the light.
  9930. */
  9931. depthScale: number;
  9932. private _filter;
  9933. /**
  9934. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9935. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9936. */
  9937. /**
  9938. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9939. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9940. */
  9941. filter: number;
  9942. /**
  9943. * Gets if the current filter is set to Poisson Sampling.
  9944. */
  9945. /**
  9946. * Sets the current filter to Poisson Sampling.
  9947. */
  9948. usePoissonSampling: boolean;
  9949. /**
  9950. * Gets if the current filter is set to ESM.
  9951. */
  9952. /**
  9953. * Sets the current filter is to ESM.
  9954. */
  9955. useExponentialShadowMap: boolean;
  9956. /**
  9957. * Gets if the current filter is set to filtered ESM.
  9958. */
  9959. /**
  9960. * Gets if the current filter is set to filtered ESM.
  9961. */
  9962. useBlurExponentialShadowMap: boolean;
  9963. /**
  9964. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9965. * exponential to prevent steep falloff artifacts).
  9966. */
  9967. /**
  9968. * Sets the current filter to "close ESM" (using the inverse of the
  9969. * exponential to prevent steep falloff artifacts).
  9970. */
  9971. useCloseExponentialShadowMap: boolean;
  9972. /**
  9973. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9974. * exponential to prevent steep falloff artifacts).
  9975. */
  9976. /**
  9977. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9978. * exponential to prevent steep falloff artifacts).
  9979. */
  9980. useBlurCloseExponentialShadowMap: boolean;
  9981. /**
  9982. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9983. */
  9984. /**
  9985. * Sets the current filter to "PCF" (percentage closer filtering).
  9986. */
  9987. usePercentageCloserFiltering: boolean;
  9988. private _filteringQuality;
  9989. /**
  9990. * Gets the PCF or PCSS Quality.
  9991. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9992. */
  9993. /**
  9994. * Sets the PCF or PCSS Quality.
  9995. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9996. */
  9997. filteringQuality: number;
  9998. /**
  9999. * Gets if the current filter is set to "PCSS" (contact hardening).
  10000. */
  10001. /**
  10002. * Sets the current filter to "PCSS" (contact hardening).
  10003. */
  10004. useContactHardeningShadow: boolean;
  10005. private _contactHardeningLightSizeUVRatio;
  10006. /**
  10007. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10008. * Using a ratio helps keeping shape stability independently of the map size.
  10009. *
  10010. * It does not account for the light projection as it was having too much
  10011. * instability during the light setup or during light position changes.
  10012. *
  10013. * Only valid if useContactHardeningShadow is true.
  10014. */
  10015. /**
  10016. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10017. * Using a ratio helps keeping shape stability independently of the map size.
  10018. *
  10019. * It does not account for the light projection as it was having too much
  10020. * instability during the light setup or during light position changes.
  10021. *
  10022. * Only valid if useContactHardeningShadow is true.
  10023. */
  10024. contactHardeningLightSizeUVRatio: number;
  10025. private _darkness;
  10026. /**
  10027. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10028. * 0 means strongest and 1 would means no shadow.
  10029. * @returns the darkness.
  10030. */
  10031. getDarkness(): number;
  10032. /**
  10033. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10034. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10035. * @returns the shadow generator allowing fluent coding.
  10036. */
  10037. setDarkness(darkness: number): ShadowGenerator;
  10038. private _transparencyShadow;
  10039. /**
  10040. * Sets the ability to have transparent shadow (boolean).
  10041. * @param transparent True if transparent else False
  10042. * @returns the shadow generator allowing fluent coding
  10043. */
  10044. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10045. private _shadowMap;
  10046. private _shadowMap2;
  10047. /**
  10048. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10049. * @returns The render target texture if present otherwise, null
  10050. */
  10051. getShadowMap(): Nullable<RenderTargetTexture>;
  10052. /**
  10053. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10054. * @returns The render target texture if the shadow map is present otherwise, null
  10055. */
  10056. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10057. /**
  10058. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10059. * @param mesh Mesh to add
  10060. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10061. * @returns the Shadow Generator itself
  10062. */
  10063. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10064. /**
  10065. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10066. * @param mesh Mesh to remove
  10067. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10068. * @returns the Shadow Generator itself
  10069. */
  10070. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10071. /**
  10072. * Controls the extent to which the shadows fade out at the edge of the frustum
  10073. * Used only by directionals and spots
  10074. */
  10075. frustumEdgeFalloff: number;
  10076. private _light;
  10077. /**
  10078. * Returns the associated light object.
  10079. * @returns the light generating the shadow
  10080. */
  10081. getLight(): IShadowLight;
  10082. /**
  10083. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10084. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10085. * It might on the other hand introduce peter panning.
  10086. */
  10087. forceBackFacesOnly: boolean;
  10088. private _scene;
  10089. private _lightDirection;
  10090. private _effect;
  10091. private _viewMatrix;
  10092. private _projectionMatrix;
  10093. private _transformMatrix;
  10094. private _cachedPosition;
  10095. private _cachedDirection;
  10096. private _cachedDefines;
  10097. private _currentRenderID;
  10098. private _boxBlurPostprocess;
  10099. private _kernelBlurXPostprocess;
  10100. private _kernelBlurYPostprocess;
  10101. private _blurPostProcesses;
  10102. private _mapSize;
  10103. private _currentFaceIndex;
  10104. private _currentFaceIndexCache;
  10105. private _textureType;
  10106. private _defaultTextureMatrix;
  10107. /** @hidden */
  10108. static _SceneComponentInitialization: (scene: Scene) => void;
  10109. /**
  10110. * Creates a ShadowGenerator object.
  10111. * A ShadowGenerator is the required tool to use the shadows.
  10112. * Each light casting shadows needs to use its own ShadowGenerator.
  10113. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10114. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10115. * @param light The light object generating the shadows.
  10116. * @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.
  10117. */
  10118. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10119. private _initializeGenerator;
  10120. private _initializeShadowMap;
  10121. private _initializeBlurRTTAndPostProcesses;
  10122. private _renderForShadowMap;
  10123. private _renderSubMeshForShadowMap;
  10124. private _applyFilterValues;
  10125. /**
  10126. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10127. * @param onCompiled Callback triggered at the and of the effects compilation
  10128. * @param options Sets of optional options forcing the compilation with different modes
  10129. */
  10130. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10131. useInstances: boolean;
  10132. }>): void;
  10133. /**
  10134. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10135. * @param options Sets of optional options forcing the compilation with different modes
  10136. * @returns A promise that resolves when the compilation completes
  10137. */
  10138. forceCompilationAsync(options?: Partial<{
  10139. useInstances: boolean;
  10140. }>): Promise<void>;
  10141. /**
  10142. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10143. * @param subMesh The submesh we want to render in the shadow map
  10144. * @param useInstances Defines wether will draw in the map using instances
  10145. * @returns true if ready otherwise, false
  10146. */
  10147. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10148. /**
  10149. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10150. * @param defines Defines of the material we want to update
  10151. * @param lightIndex Index of the light in the enabled light list of the material
  10152. */
  10153. prepareDefines(defines: any, lightIndex: number): void;
  10154. /**
  10155. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10156. * defined in the generator but impacting the effect).
  10157. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10158. * @param effect The effect we are binfing the information for
  10159. */
  10160. bindShadowLight(lightIndex: string, effect: Effect): void;
  10161. /**
  10162. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10163. * (eq to shadow prjection matrix * light transform matrix)
  10164. * @returns The transform matrix used to create the shadow map
  10165. */
  10166. getTransformMatrix(): Matrix;
  10167. /**
  10168. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10169. * Cube and 2D textures for instance.
  10170. */
  10171. recreateShadowMap(): void;
  10172. private _disposeBlurPostProcesses;
  10173. private _disposeRTTandPostProcesses;
  10174. /**
  10175. * Disposes the ShadowGenerator.
  10176. * Returns nothing.
  10177. */
  10178. dispose(): void;
  10179. /**
  10180. * Serializes the shadow generator setup to a json object.
  10181. * @returns The serialized JSON object
  10182. */
  10183. serialize(): any;
  10184. /**
  10185. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10186. * @param parsedShadowGenerator The JSON object to parse
  10187. * @param scene The scene to create the shadow map for
  10188. * @returns The parsed shadow generator
  10189. */
  10190. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10191. }
  10192. }
  10193. declare module BABYLON {
  10194. /**
  10195. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10196. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10197. * 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.
  10198. */
  10199. export abstract class Light extends Node {
  10200. /**
  10201. * Falloff Default: light is falling off following the material specification:
  10202. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10203. */
  10204. static readonly FALLOFF_DEFAULT: number;
  10205. /**
  10206. * Falloff Physical: light is falling off following the inverse squared distance law.
  10207. */
  10208. static readonly FALLOFF_PHYSICAL: number;
  10209. /**
  10210. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10211. * to enhance interoperability with other engines.
  10212. */
  10213. static readonly FALLOFF_GLTF: number;
  10214. /**
  10215. * Falloff Standard: light is falling off like in the standard material
  10216. * to enhance interoperability with other materials.
  10217. */
  10218. static readonly FALLOFF_STANDARD: number;
  10219. /**
  10220. * If every light affecting the material is in this lightmapMode,
  10221. * material.lightmapTexture adds or multiplies
  10222. * (depends on material.useLightmapAsShadowmap)
  10223. * after every other light calculations.
  10224. */
  10225. static readonly LIGHTMAP_DEFAULT: number;
  10226. /**
  10227. * material.lightmapTexture as only diffuse lighting from this light
  10228. * adds only specular lighting from this light
  10229. * adds dynamic shadows
  10230. */
  10231. static readonly LIGHTMAP_SPECULAR: number;
  10232. /**
  10233. * material.lightmapTexture as only lighting
  10234. * no light calculation from this light
  10235. * only adds dynamic shadows from this light
  10236. */
  10237. static readonly LIGHTMAP_SHADOWSONLY: number;
  10238. /**
  10239. * Each light type uses the default quantity according to its type:
  10240. * point/spot lights use luminous intensity
  10241. * directional lights use illuminance
  10242. */
  10243. static readonly INTENSITYMODE_AUTOMATIC: number;
  10244. /**
  10245. * lumen (lm)
  10246. */
  10247. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10248. /**
  10249. * candela (lm/sr)
  10250. */
  10251. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10252. /**
  10253. * lux (lm/m^2)
  10254. */
  10255. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10256. /**
  10257. * nit (cd/m^2)
  10258. */
  10259. static readonly INTENSITYMODE_LUMINANCE: number;
  10260. /**
  10261. * Light type const id of the point light.
  10262. */
  10263. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10264. /**
  10265. * Light type const id of the directional light.
  10266. */
  10267. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10268. /**
  10269. * Light type const id of the spot light.
  10270. */
  10271. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10272. /**
  10273. * Light type const id of the hemispheric light.
  10274. */
  10275. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10276. /**
  10277. * Diffuse gives the basic color to an object.
  10278. */
  10279. diffuse: Color3;
  10280. /**
  10281. * Specular produces a highlight color on an object.
  10282. * Note: This is note affecting PBR materials.
  10283. */
  10284. specular: Color3;
  10285. /**
  10286. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10287. * falling off base on range or angle.
  10288. * This can be set to any values in Light.FALLOFF_x.
  10289. *
  10290. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10291. * other types of materials.
  10292. */
  10293. falloffType: number;
  10294. /**
  10295. * Strength of the light.
  10296. * Note: By default it is define in the framework own unit.
  10297. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10298. */
  10299. intensity: number;
  10300. private _range;
  10301. protected _inverseSquaredRange: number;
  10302. /**
  10303. * Defines how far from the source the light is impacting in scene units.
  10304. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10305. */
  10306. /**
  10307. * Defines how far from the source the light is impacting in scene units.
  10308. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10309. */
  10310. range: number;
  10311. /**
  10312. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10313. * of light.
  10314. */
  10315. private _photometricScale;
  10316. private _intensityMode;
  10317. /**
  10318. * Gets the photometric scale used to interpret the intensity.
  10319. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10320. */
  10321. /**
  10322. * Sets the photometric scale used to interpret the intensity.
  10323. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10324. */
  10325. intensityMode: number;
  10326. private _radius;
  10327. /**
  10328. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10329. */
  10330. /**
  10331. * sets the light radius used by PBR Materials to simulate soft area lights.
  10332. */
  10333. radius: number;
  10334. private _renderPriority;
  10335. /**
  10336. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10337. * exceeding the number allowed of the materials.
  10338. */
  10339. renderPriority: number;
  10340. private _shadowEnabled;
  10341. /**
  10342. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10343. * the current shadow generator.
  10344. */
  10345. /**
  10346. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10347. * the current shadow generator.
  10348. */
  10349. shadowEnabled: boolean;
  10350. private _includedOnlyMeshes;
  10351. /**
  10352. * Gets the only meshes impacted by this light.
  10353. */
  10354. /**
  10355. * Sets the only meshes impacted by this light.
  10356. */
  10357. includedOnlyMeshes: AbstractMesh[];
  10358. private _excludedMeshes;
  10359. /**
  10360. * Gets the meshes not impacted by this light.
  10361. */
  10362. /**
  10363. * Sets the meshes not impacted by this light.
  10364. */
  10365. excludedMeshes: AbstractMesh[];
  10366. private _excludeWithLayerMask;
  10367. /**
  10368. * Gets the layer id use to find what meshes are not impacted by the light.
  10369. * Inactive if 0
  10370. */
  10371. /**
  10372. * Sets the layer id use to find what meshes are not impacted by the light.
  10373. * Inactive if 0
  10374. */
  10375. excludeWithLayerMask: number;
  10376. private _includeOnlyWithLayerMask;
  10377. /**
  10378. * Gets the layer id use to find what meshes are impacted by the light.
  10379. * Inactive if 0
  10380. */
  10381. /**
  10382. * Sets the layer id use to find what meshes are impacted by the light.
  10383. * Inactive if 0
  10384. */
  10385. includeOnlyWithLayerMask: number;
  10386. private _lightmapMode;
  10387. /**
  10388. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10389. */
  10390. /**
  10391. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10392. */
  10393. lightmapMode: number;
  10394. /**
  10395. * Shadow generator associted to the light.
  10396. * @hidden Internal use only.
  10397. */
  10398. _shadowGenerator: Nullable<IShadowGenerator>;
  10399. /**
  10400. * @hidden Internal use only.
  10401. */
  10402. _excludedMeshesIds: string[];
  10403. /**
  10404. * @hidden Internal use only.
  10405. */
  10406. _includedOnlyMeshesIds: string[];
  10407. /**
  10408. * The current light unifom buffer.
  10409. * @hidden Internal use only.
  10410. */
  10411. _uniformBuffer: UniformBuffer;
  10412. /**
  10413. * Creates a Light object in the scene.
  10414. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10415. * @param name The firendly name of the light
  10416. * @param scene The scene the light belongs too
  10417. */
  10418. constructor(name: string, scene: Scene);
  10419. protected abstract _buildUniformLayout(): void;
  10420. /**
  10421. * Sets the passed Effect "effect" with the Light information.
  10422. * @param effect The effect to update
  10423. * @param lightIndex The index of the light in the effect to update
  10424. * @returns The light
  10425. */
  10426. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10427. /**
  10428. * Returns the string "Light".
  10429. * @returns the class name
  10430. */
  10431. getClassName(): string;
  10432. /** @hidden */
  10433. readonly _isLight: boolean;
  10434. /**
  10435. * Converts the light information to a readable string for debug purpose.
  10436. * @param fullDetails Supports for multiple levels of logging within scene loading
  10437. * @returns the human readable light info
  10438. */
  10439. toString(fullDetails?: boolean): string;
  10440. /** @hidden */
  10441. protected _syncParentEnabledState(): void;
  10442. /**
  10443. * Set the enabled state of this node.
  10444. * @param value - the new enabled state
  10445. */
  10446. setEnabled(value: boolean): void;
  10447. /**
  10448. * Returns the Light associated shadow generator if any.
  10449. * @return the associated shadow generator.
  10450. */
  10451. getShadowGenerator(): Nullable<IShadowGenerator>;
  10452. /**
  10453. * Returns a Vector3, the absolute light position in the World.
  10454. * @returns the world space position of the light
  10455. */
  10456. getAbsolutePosition(): Vector3;
  10457. /**
  10458. * Specifies if the light will affect the passed mesh.
  10459. * @param mesh The mesh to test against the light
  10460. * @return true the mesh is affected otherwise, false.
  10461. */
  10462. canAffectMesh(mesh: AbstractMesh): boolean;
  10463. /**
  10464. * Sort function to order lights for rendering.
  10465. * @param a First Light object to compare to second.
  10466. * @param b Second Light object to compare first.
  10467. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10468. */
  10469. static CompareLightsPriority(a: Light, b: Light): number;
  10470. /**
  10471. * Releases resources associated with this node.
  10472. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10473. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10474. */
  10475. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10476. /**
  10477. * Returns the light type ID (integer).
  10478. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10479. */
  10480. getTypeID(): number;
  10481. /**
  10482. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10483. * @returns the scaled intensity in intensity mode unit
  10484. */
  10485. getScaledIntensity(): number;
  10486. /**
  10487. * Returns a new Light object, named "name", from the current one.
  10488. * @param name The name of the cloned light
  10489. * @returns the new created light
  10490. */
  10491. clone(name: string): Nullable<Light>;
  10492. /**
  10493. * Serializes the current light into a Serialization object.
  10494. * @returns the serialized object.
  10495. */
  10496. serialize(): any;
  10497. /**
  10498. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10499. * This new light is named "name" and added to the passed scene.
  10500. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10501. * @param name The friendly name of the light
  10502. * @param scene The scene the new light will belong to
  10503. * @returns the constructor function
  10504. */
  10505. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10506. /**
  10507. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10508. * @param parsedLight The JSON representation of the light
  10509. * @param scene The scene to create the parsed light in
  10510. * @returns the created light after parsing
  10511. */
  10512. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10513. private _hookArrayForExcluded;
  10514. private _hookArrayForIncludedOnly;
  10515. private _resyncMeshes;
  10516. /**
  10517. * Forces the meshes to update their light related information in their rendering used effects
  10518. * @hidden Internal Use Only
  10519. */
  10520. _markMeshesAsLightDirty(): void;
  10521. /**
  10522. * Recomputes the cached photometric scale if needed.
  10523. */
  10524. private _computePhotometricScale;
  10525. /**
  10526. * Returns the Photometric Scale according to the light type and intensity mode.
  10527. */
  10528. private _getPhotometricScale;
  10529. /**
  10530. * Reorder the light in the scene according to their defined priority.
  10531. * @hidden Internal Use Only
  10532. */
  10533. _reorderLightsInScene(): void;
  10534. /**
  10535. * Prepares the list of defines specific to the light type.
  10536. * @param defines the list of defines
  10537. * @param lightIndex defines the index of the light for the effect
  10538. */
  10539. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10540. }
  10541. }
  10542. declare module BABYLON {
  10543. /**
  10544. * Interface used to define Action
  10545. */
  10546. export interface IAction {
  10547. /**
  10548. * Trigger for the action
  10549. */
  10550. trigger: number;
  10551. /** Options of the trigger */
  10552. triggerOptions: any;
  10553. /**
  10554. * Gets the trigger parameters
  10555. * @returns the trigger parameters
  10556. */
  10557. getTriggerParameter(): any;
  10558. /**
  10559. * Internal only - executes current action event
  10560. * @hidden
  10561. */
  10562. _executeCurrent(evt?: ActionEvent): void;
  10563. /**
  10564. * Serialize placeholder for child classes
  10565. * @param parent of child
  10566. * @returns the serialized object
  10567. */
  10568. serialize(parent: any): any;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. _prepare(): void;
  10574. /**
  10575. * Internal only - manager for action
  10576. * @hidden
  10577. */
  10578. _actionManager: AbstractActionManager;
  10579. }
  10580. /**
  10581. * The action to be carried out following a trigger
  10582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10583. */
  10584. export class Action implements IAction {
  10585. /** the trigger, with or without parameters, for the action */
  10586. triggerOptions: any;
  10587. /**
  10588. * Trigger for the action
  10589. */
  10590. trigger: number;
  10591. /**
  10592. * Internal only - manager for action
  10593. * @hidden
  10594. */
  10595. _actionManager: ActionManager;
  10596. private _nextActiveAction;
  10597. private _child;
  10598. private _condition?;
  10599. private _triggerParameter;
  10600. /**
  10601. * An event triggered prior to action being executed.
  10602. */
  10603. onBeforeExecuteObservable: Observable<Action>;
  10604. /**
  10605. * Creates a new Action
  10606. * @param triggerOptions the trigger, with or without parameters, for the action
  10607. * @param condition an optional determinant of action
  10608. */
  10609. constructor(
  10610. /** the trigger, with or without parameters, for the action */
  10611. triggerOptions: any, condition?: Condition);
  10612. /**
  10613. * Internal only
  10614. * @hidden
  10615. */
  10616. _prepare(): void;
  10617. /**
  10618. * Gets the trigger parameters
  10619. * @returns the trigger parameters
  10620. */
  10621. getTriggerParameter(): any;
  10622. /**
  10623. * Internal only - executes current action event
  10624. * @hidden
  10625. */
  10626. _executeCurrent(evt?: ActionEvent): void;
  10627. /**
  10628. * Execute placeholder for child classes
  10629. * @param evt optional action event
  10630. */
  10631. execute(evt?: ActionEvent): void;
  10632. /**
  10633. * Skips to next active action
  10634. */
  10635. skipToNextActiveAction(): void;
  10636. /**
  10637. * Adds action to chain of actions, may be a DoNothingAction
  10638. * @param action defines the next action to execute
  10639. * @returns The action passed in
  10640. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10641. */
  10642. then(action: Action): Action;
  10643. /**
  10644. * Internal only
  10645. * @hidden
  10646. */
  10647. _getProperty(propertyPath: string): string;
  10648. /**
  10649. * Internal only
  10650. * @hidden
  10651. */
  10652. _getEffectiveTarget(target: any, propertyPath: string): any;
  10653. /**
  10654. * Serialize placeholder for child classes
  10655. * @param parent of child
  10656. * @returns the serialized object
  10657. */
  10658. serialize(parent: any): any;
  10659. /**
  10660. * Internal only called by serialize
  10661. * @hidden
  10662. */
  10663. protected _serialize(serializedAction: any, parent?: any): any;
  10664. /**
  10665. * Internal only
  10666. * @hidden
  10667. */
  10668. static _SerializeValueAsString: (value: any) => string;
  10669. /**
  10670. * Internal only
  10671. * @hidden
  10672. */
  10673. static _GetTargetProperty: (target: Scene | Node) => {
  10674. name: string;
  10675. targetType: string;
  10676. value: string;
  10677. };
  10678. }
  10679. }
  10680. declare module BABYLON {
  10681. /**
  10682. * A Condition applied to an Action
  10683. */
  10684. export class Condition {
  10685. /**
  10686. * Internal only - manager for action
  10687. * @hidden
  10688. */
  10689. _actionManager: ActionManager;
  10690. /**
  10691. * Internal only
  10692. * @hidden
  10693. */
  10694. _evaluationId: number;
  10695. /**
  10696. * Internal only
  10697. * @hidden
  10698. */
  10699. _currentResult: boolean;
  10700. /**
  10701. * Creates a new Condition
  10702. * @param actionManager the manager of the action the condition is applied to
  10703. */
  10704. constructor(actionManager: ActionManager);
  10705. /**
  10706. * Check if the current condition is valid
  10707. * @returns a boolean
  10708. */
  10709. isValid(): boolean;
  10710. /**
  10711. * Internal only
  10712. * @hidden
  10713. */
  10714. _getProperty(propertyPath: string): string;
  10715. /**
  10716. * Internal only
  10717. * @hidden
  10718. */
  10719. _getEffectiveTarget(target: any, propertyPath: string): any;
  10720. /**
  10721. * Serialize placeholder for child classes
  10722. * @returns the serialized object
  10723. */
  10724. serialize(): any;
  10725. /**
  10726. * Internal only
  10727. * @hidden
  10728. */
  10729. protected _serialize(serializedCondition: any): any;
  10730. }
  10731. /**
  10732. * Defines specific conditional operators as extensions of Condition
  10733. */
  10734. export class ValueCondition extends Condition {
  10735. /** path to specify the property of the target the conditional operator uses */
  10736. propertyPath: string;
  10737. /** the value compared by the conditional operator against the current value of the property */
  10738. value: any;
  10739. /** the conditional operator, default ValueCondition.IsEqual */
  10740. operator: number;
  10741. /**
  10742. * Internal only
  10743. * @hidden
  10744. */
  10745. private static _IsEqual;
  10746. /**
  10747. * Internal only
  10748. * @hidden
  10749. */
  10750. private static _IsDifferent;
  10751. /**
  10752. * Internal only
  10753. * @hidden
  10754. */
  10755. private static _IsGreater;
  10756. /**
  10757. * Internal only
  10758. * @hidden
  10759. */
  10760. private static _IsLesser;
  10761. /**
  10762. * returns the number for IsEqual
  10763. */
  10764. static readonly IsEqual: number;
  10765. /**
  10766. * Returns the number for IsDifferent
  10767. */
  10768. static readonly IsDifferent: number;
  10769. /**
  10770. * Returns the number for IsGreater
  10771. */
  10772. static readonly IsGreater: number;
  10773. /**
  10774. * Returns the number for IsLesser
  10775. */
  10776. static readonly IsLesser: number;
  10777. /**
  10778. * Internal only The action manager for the condition
  10779. * @hidden
  10780. */
  10781. _actionManager: ActionManager;
  10782. /**
  10783. * Internal only
  10784. * @hidden
  10785. */
  10786. private _target;
  10787. /**
  10788. * Internal only
  10789. * @hidden
  10790. */
  10791. private _effectiveTarget;
  10792. /**
  10793. * Internal only
  10794. * @hidden
  10795. */
  10796. private _property;
  10797. /**
  10798. * Creates a new ValueCondition
  10799. * @param actionManager manager for the action the condition applies to
  10800. * @param target for the action
  10801. * @param propertyPath path to specify the property of the target the conditional operator uses
  10802. * @param value the value compared by the conditional operator against the current value of the property
  10803. * @param operator the conditional operator, default ValueCondition.IsEqual
  10804. */
  10805. constructor(actionManager: ActionManager, target: any,
  10806. /** path to specify the property of the target the conditional operator uses */
  10807. propertyPath: string,
  10808. /** the value compared by the conditional operator against the current value of the property */
  10809. value: any,
  10810. /** the conditional operator, default ValueCondition.IsEqual */
  10811. operator?: number);
  10812. /**
  10813. * Compares the given value with the property value for the specified conditional operator
  10814. * @returns the result of the comparison
  10815. */
  10816. isValid(): boolean;
  10817. /**
  10818. * Serialize the ValueCondition into a JSON compatible object
  10819. * @returns serialization object
  10820. */
  10821. serialize(): any;
  10822. /**
  10823. * Gets the name of the conditional operator for the ValueCondition
  10824. * @param operator the conditional operator
  10825. * @returns the name
  10826. */
  10827. static GetOperatorName(operator: number): string;
  10828. }
  10829. /**
  10830. * Defines a predicate condition as an extension of Condition
  10831. */
  10832. export class PredicateCondition extends Condition {
  10833. /** defines the predicate function used to validate the condition */
  10834. predicate: () => boolean;
  10835. /**
  10836. * Internal only - manager for action
  10837. * @hidden
  10838. */
  10839. _actionManager: ActionManager;
  10840. /**
  10841. * Creates a new PredicateCondition
  10842. * @param actionManager manager for the action the condition applies to
  10843. * @param predicate defines the predicate function used to validate the condition
  10844. */
  10845. constructor(actionManager: ActionManager,
  10846. /** defines the predicate function used to validate the condition */
  10847. predicate: () => boolean);
  10848. /**
  10849. * @returns the validity of the predicate condition
  10850. */
  10851. isValid(): boolean;
  10852. }
  10853. /**
  10854. * Defines a state condition as an extension of Condition
  10855. */
  10856. export class StateCondition extends Condition {
  10857. /** Value to compare with target state */
  10858. value: string;
  10859. /**
  10860. * Internal only - manager for action
  10861. * @hidden
  10862. */
  10863. _actionManager: ActionManager;
  10864. /**
  10865. * Internal only
  10866. * @hidden
  10867. */
  10868. private _target;
  10869. /**
  10870. * Creates a new StateCondition
  10871. * @param actionManager manager for the action the condition applies to
  10872. * @param target of the condition
  10873. * @param value to compare with target state
  10874. */
  10875. constructor(actionManager: ActionManager, target: any,
  10876. /** Value to compare with target state */
  10877. value: string);
  10878. /**
  10879. * Gets a boolean indicating if the current condition is met
  10880. * @returns the validity of the state
  10881. */
  10882. isValid(): boolean;
  10883. /**
  10884. * Serialize the StateCondition into a JSON compatible object
  10885. * @returns serialization object
  10886. */
  10887. serialize(): any;
  10888. }
  10889. }
  10890. declare module BABYLON {
  10891. /**
  10892. * This defines an action responsible to toggle a boolean once triggered.
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10894. */
  10895. export class SwitchBooleanAction extends Action {
  10896. /**
  10897. * The path to the boolean property in the target object
  10898. */
  10899. propertyPath: string;
  10900. private _target;
  10901. private _effectiveTarget;
  10902. private _property;
  10903. /**
  10904. * Instantiate the action
  10905. * @param triggerOptions defines the trigger options
  10906. * @param target defines the object containing the boolean
  10907. * @param propertyPath defines the path to the boolean property in the target object
  10908. * @param condition defines the trigger related conditions
  10909. */
  10910. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10911. /** @hidden */
  10912. _prepare(): void;
  10913. /**
  10914. * Execute the action toggle the boolean value.
  10915. */
  10916. execute(): void;
  10917. /**
  10918. * Serializes the actions and its related information.
  10919. * @param parent defines the object to serialize in
  10920. * @returns the serialized object
  10921. */
  10922. serialize(parent: any): any;
  10923. }
  10924. /**
  10925. * This defines an action responsible to set a the state field of the target
  10926. * to a desired value once triggered.
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10928. */
  10929. export class SetStateAction extends Action {
  10930. /**
  10931. * The value to store in the state field.
  10932. */
  10933. value: string;
  10934. private _target;
  10935. /**
  10936. * Instantiate the action
  10937. * @param triggerOptions defines the trigger options
  10938. * @param target defines the object containing the state property
  10939. * @param value defines the value to store in the state field
  10940. * @param condition defines the trigger related conditions
  10941. */
  10942. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10943. /**
  10944. * Execute the action and store the value on the target state property.
  10945. */
  10946. execute(): void;
  10947. /**
  10948. * Serializes the actions and its related information.
  10949. * @param parent defines the object to serialize in
  10950. * @returns the serialized object
  10951. */
  10952. serialize(parent: any): any;
  10953. }
  10954. /**
  10955. * This defines an action responsible to set a property of the target
  10956. * to a desired value once triggered.
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10958. */
  10959. export class SetValueAction extends Action {
  10960. /**
  10961. * The path of the property to set in the target.
  10962. */
  10963. propertyPath: string;
  10964. /**
  10965. * The value to set in the property
  10966. */
  10967. value: any;
  10968. private _target;
  10969. private _effectiveTarget;
  10970. private _property;
  10971. /**
  10972. * Instantiate the action
  10973. * @param triggerOptions defines the trigger options
  10974. * @param target defines the object containing the property
  10975. * @param propertyPath defines the path of the property to set in the target
  10976. * @param value defines the value to set in the property
  10977. * @param condition defines the trigger related conditions
  10978. */
  10979. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10980. /** @hidden */
  10981. _prepare(): void;
  10982. /**
  10983. * Execute the action and set the targetted property to the desired value.
  10984. */
  10985. execute(): void;
  10986. /**
  10987. * Serializes the actions and its related information.
  10988. * @param parent defines the object to serialize in
  10989. * @returns the serialized object
  10990. */
  10991. serialize(parent: any): any;
  10992. }
  10993. /**
  10994. * This defines an action responsible to increment the target value
  10995. * to a desired value once triggered.
  10996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10997. */
  10998. export class IncrementValueAction extends Action {
  10999. /**
  11000. * The path of the property to increment in the target.
  11001. */
  11002. propertyPath: string;
  11003. /**
  11004. * The value we should increment the property by.
  11005. */
  11006. value: any;
  11007. private _target;
  11008. private _effectiveTarget;
  11009. private _property;
  11010. /**
  11011. * Instantiate the action
  11012. * @param triggerOptions defines the trigger options
  11013. * @param target defines the object containing the property
  11014. * @param propertyPath defines the path of the property to increment in the target
  11015. * @param value defines the value value we should increment the property by
  11016. * @param condition defines the trigger related conditions
  11017. */
  11018. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11019. /** @hidden */
  11020. _prepare(): void;
  11021. /**
  11022. * Execute the action and increment the target of the value amount.
  11023. */
  11024. execute(): void;
  11025. /**
  11026. * Serializes the actions and its related information.
  11027. * @param parent defines the object to serialize in
  11028. * @returns the serialized object
  11029. */
  11030. serialize(parent: any): any;
  11031. }
  11032. /**
  11033. * This defines an action responsible to start an animation once triggered.
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11035. */
  11036. export class PlayAnimationAction extends Action {
  11037. /**
  11038. * Where the animation should start (animation frame)
  11039. */
  11040. from: number;
  11041. /**
  11042. * Where the animation should stop (animation frame)
  11043. */
  11044. to: number;
  11045. /**
  11046. * Define if the animation should loop or stop after the first play.
  11047. */
  11048. loop?: boolean;
  11049. private _target;
  11050. /**
  11051. * Instantiate the action
  11052. * @param triggerOptions defines the trigger options
  11053. * @param target defines the target animation or animation name
  11054. * @param from defines from where the animation should start (animation frame)
  11055. * @param end defines where the animation should stop (animation frame)
  11056. * @param loop defines if the animation should loop or stop after the first play
  11057. * @param condition defines the trigger related conditions
  11058. */
  11059. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11060. /** @hidden */
  11061. _prepare(): void;
  11062. /**
  11063. * Execute the action and play the animation.
  11064. */
  11065. execute(): void;
  11066. /**
  11067. * Serializes the actions and its related information.
  11068. * @param parent defines the object to serialize in
  11069. * @returns the serialized object
  11070. */
  11071. serialize(parent: any): any;
  11072. }
  11073. /**
  11074. * This defines an action responsible to stop an animation once triggered.
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11076. */
  11077. export class StopAnimationAction extends Action {
  11078. private _target;
  11079. /**
  11080. * Instantiate the action
  11081. * @param triggerOptions defines the trigger options
  11082. * @param target defines the target animation or animation name
  11083. * @param condition defines the trigger related conditions
  11084. */
  11085. constructor(triggerOptions: any, target: any, condition?: Condition);
  11086. /** @hidden */
  11087. _prepare(): void;
  11088. /**
  11089. * Execute the action and stop the animation.
  11090. */
  11091. execute(): void;
  11092. /**
  11093. * Serializes the actions and its related information.
  11094. * @param parent defines the object to serialize in
  11095. * @returns the serialized object
  11096. */
  11097. serialize(parent: any): any;
  11098. }
  11099. /**
  11100. * This defines an action responsible that does nothing once triggered.
  11101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11102. */
  11103. export class DoNothingAction extends Action {
  11104. /**
  11105. * Instantiate the action
  11106. * @param triggerOptions defines the trigger options
  11107. * @param condition defines the trigger related conditions
  11108. */
  11109. constructor(triggerOptions?: any, condition?: Condition);
  11110. /**
  11111. * Execute the action and do nothing.
  11112. */
  11113. execute(): void;
  11114. /**
  11115. * Serializes the actions and its related information.
  11116. * @param parent defines the object to serialize in
  11117. * @returns the serialized object
  11118. */
  11119. serialize(parent: any): any;
  11120. }
  11121. /**
  11122. * This defines an action responsible to trigger several actions once triggered.
  11123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11124. */
  11125. export class CombineAction extends Action {
  11126. /**
  11127. * The list of aggregated animations to run.
  11128. */
  11129. children: Action[];
  11130. /**
  11131. * Instantiate the action
  11132. * @param triggerOptions defines the trigger options
  11133. * @param children defines the list of aggregated animations to run
  11134. * @param condition defines the trigger related conditions
  11135. */
  11136. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11137. /** @hidden */
  11138. _prepare(): void;
  11139. /**
  11140. * Execute the action and executes all the aggregated actions.
  11141. */
  11142. execute(evt: ActionEvent): void;
  11143. /**
  11144. * Serializes the actions and its related information.
  11145. * @param parent defines the object to serialize in
  11146. * @returns the serialized object
  11147. */
  11148. serialize(parent: any): any;
  11149. }
  11150. /**
  11151. * This defines an action responsible to run code (external event) once triggered.
  11152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11153. */
  11154. export class ExecuteCodeAction extends Action {
  11155. /**
  11156. * The callback function to run.
  11157. */
  11158. func: (evt: ActionEvent) => void;
  11159. /**
  11160. * Instantiate the action
  11161. * @param triggerOptions defines the trigger options
  11162. * @param func defines the callback function to run
  11163. * @param condition defines the trigger related conditions
  11164. */
  11165. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11166. /**
  11167. * Execute the action and run the attached code.
  11168. */
  11169. execute(evt: ActionEvent): void;
  11170. }
  11171. /**
  11172. * This defines an action responsible to set the parent property of the target once triggered.
  11173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11174. */
  11175. export class SetParentAction extends Action {
  11176. private _parent;
  11177. private _target;
  11178. /**
  11179. * Instantiate the action
  11180. * @param triggerOptions defines the trigger options
  11181. * @param target defines the target containing the parent property
  11182. * @param parent defines from where the animation should start (animation frame)
  11183. * @param condition defines the trigger related conditions
  11184. */
  11185. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11186. /** @hidden */
  11187. _prepare(): void;
  11188. /**
  11189. * Execute the action and set the parent property.
  11190. */
  11191. execute(): void;
  11192. /**
  11193. * Serializes the actions and its related information.
  11194. * @param parent defines the object to serialize in
  11195. * @returns the serialized object
  11196. */
  11197. serialize(parent: any): any;
  11198. }
  11199. }
  11200. declare module BABYLON {
  11201. /**
  11202. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11203. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11205. */
  11206. export class ActionManager extends AbstractActionManager {
  11207. /**
  11208. * Nothing
  11209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11210. */
  11211. static readonly NothingTrigger: number;
  11212. /**
  11213. * On pick
  11214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11215. */
  11216. static readonly OnPickTrigger: number;
  11217. /**
  11218. * On left pick
  11219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11220. */
  11221. static readonly OnLeftPickTrigger: number;
  11222. /**
  11223. * On right pick
  11224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11225. */
  11226. static readonly OnRightPickTrigger: number;
  11227. /**
  11228. * On center pick
  11229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11230. */
  11231. static readonly OnCenterPickTrigger: number;
  11232. /**
  11233. * On pick down
  11234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11235. */
  11236. static readonly OnPickDownTrigger: number;
  11237. /**
  11238. * On double pick
  11239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11240. */
  11241. static readonly OnDoublePickTrigger: number;
  11242. /**
  11243. * On pick up
  11244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11245. */
  11246. static readonly OnPickUpTrigger: number;
  11247. /**
  11248. * On pick out.
  11249. * This trigger will only be raised if you also declared a OnPickDown
  11250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11251. */
  11252. static readonly OnPickOutTrigger: number;
  11253. /**
  11254. * On long press
  11255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11256. */
  11257. static readonly OnLongPressTrigger: number;
  11258. /**
  11259. * On pointer over
  11260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11261. */
  11262. static readonly OnPointerOverTrigger: number;
  11263. /**
  11264. * On pointer out
  11265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11266. */
  11267. static readonly OnPointerOutTrigger: number;
  11268. /**
  11269. * On every frame
  11270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11271. */
  11272. static readonly OnEveryFrameTrigger: number;
  11273. /**
  11274. * On intersection enter
  11275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11276. */
  11277. static readonly OnIntersectionEnterTrigger: number;
  11278. /**
  11279. * On intersection exit
  11280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11281. */
  11282. static readonly OnIntersectionExitTrigger: number;
  11283. /**
  11284. * On key down
  11285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11286. */
  11287. static readonly OnKeyDownTrigger: number;
  11288. /**
  11289. * On key up
  11290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11291. */
  11292. static readonly OnKeyUpTrigger: number;
  11293. private _scene;
  11294. /**
  11295. * Creates a new action manager
  11296. * @param scene defines the hosting scene
  11297. */
  11298. constructor(scene: Scene);
  11299. /**
  11300. * Releases all associated resources
  11301. */
  11302. dispose(): void;
  11303. /**
  11304. * Gets hosting scene
  11305. * @returns the hosting scene
  11306. */
  11307. getScene(): Scene;
  11308. /**
  11309. * Does this action manager handles actions of any of the given triggers
  11310. * @param triggers defines the triggers to be tested
  11311. * @return a boolean indicating whether one (or more) of the triggers is handled
  11312. */
  11313. hasSpecificTriggers(triggers: number[]): boolean;
  11314. /**
  11315. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11316. * speed.
  11317. * @param triggerA defines the trigger to be tested
  11318. * @param triggerB defines the trigger to be tested
  11319. * @return a boolean indicating whether one (or more) of the triggers is handled
  11320. */
  11321. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11322. /**
  11323. * Does this action manager handles actions of a given trigger
  11324. * @param trigger defines the trigger to be tested
  11325. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11326. * @return whether the trigger is handled
  11327. */
  11328. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11329. /**
  11330. * Does this action manager has pointer triggers
  11331. */
  11332. readonly hasPointerTriggers: boolean;
  11333. /**
  11334. * Does this action manager has pick triggers
  11335. */
  11336. readonly hasPickTriggers: boolean;
  11337. /**
  11338. * Registers an action to this action manager
  11339. * @param action defines the action to be registered
  11340. * @return the action amended (prepared) after registration
  11341. */
  11342. registerAction(action: IAction): Nullable<IAction>;
  11343. /**
  11344. * Unregisters an action to this action manager
  11345. * @param action defines the action to be unregistered
  11346. * @return a boolean indicating whether the action has been unregistered
  11347. */
  11348. unregisterAction(action: IAction): Boolean;
  11349. /**
  11350. * Process a specific trigger
  11351. * @param trigger defines the trigger to process
  11352. * @param evt defines the event details to be processed
  11353. */
  11354. processTrigger(trigger: number, evt?: IActionEvent): void;
  11355. /** @hidden */
  11356. _getEffectiveTarget(target: any, propertyPath: string): any;
  11357. /** @hidden */
  11358. _getProperty(propertyPath: string): string;
  11359. /**
  11360. * Serialize this manager to a JSON object
  11361. * @param name defines the property name to store this manager
  11362. * @returns a JSON representation of this manager
  11363. */
  11364. serialize(name: string): any;
  11365. /**
  11366. * Creates a new ActionManager from a JSON data
  11367. * @param parsedActions defines the JSON data to read from
  11368. * @param object defines the hosting mesh
  11369. * @param scene defines the hosting scene
  11370. */
  11371. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11372. /**
  11373. * Get a trigger name by index
  11374. * @param trigger defines the trigger index
  11375. * @returns a trigger name
  11376. */
  11377. static GetTriggerName(trigger: number): string;
  11378. }
  11379. }
  11380. declare module BABYLON {
  11381. /**
  11382. * Class representing a ray with position and direction
  11383. */
  11384. export class Ray {
  11385. /** origin point */
  11386. origin: Vector3;
  11387. /** direction */
  11388. direction: Vector3;
  11389. /** length of the ray */
  11390. length: number;
  11391. private static readonly TmpVector3;
  11392. private _tmpRay;
  11393. /**
  11394. * Creates a new ray
  11395. * @param origin origin point
  11396. * @param direction direction
  11397. * @param length length of the ray
  11398. */
  11399. constructor(
  11400. /** origin point */
  11401. origin: Vector3,
  11402. /** direction */
  11403. direction: Vector3,
  11404. /** length of the ray */
  11405. length?: number);
  11406. /**
  11407. * Checks if the ray intersects a box
  11408. * @param minimum bound of the box
  11409. * @param maximum bound of the box
  11410. * @param intersectionTreshold extra extend to be added to the box in all direction
  11411. * @returns if the box was hit
  11412. */
  11413. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11414. /**
  11415. * Checks if the ray intersects a box
  11416. * @param box the bounding box to check
  11417. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11418. * @returns if the box was hit
  11419. */
  11420. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11421. /**
  11422. * If the ray hits a sphere
  11423. * @param sphere the bounding sphere to check
  11424. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11425. * @returns true if it hits the sphere
  11426. */
  11427. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11428. /**
  11429. * If the ray hits a triange
  11430. * @param vertex0 triangle vertex
  11431. * @param vertex1 triangle vertex
  11432. * @param vertex2 triangle vertex
  11433. * @returns intersection information if hit
  11434. */
  11435. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11436. /**
  11437. * Checks if ray intersects a plane
  11438. * @param plane the plane to check
  11439. * @returns the distance away it was hit
  11440. */
  11441. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11442. /**
  11443. * Checks if ray intersects a mesh
  11444. * @param mesh the mesh to check
  11445. * @param fastCheck if only the bounding box should checked
  11446. * @returns picking info of the intersecton
  11447. */
  11448. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11449. /**
  11450. * Checks if ray intersects a mesh
  11451. * @param meshes the meshes to check
  11452. * @param fastCheck if only the bounding box should checked
  11453. * @param results array to store result in
  11454. * @returns Array of picking infos
  11455. */
  11456. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11457. private _comparePickingInfo;
  11458. private static smallnum;
  11459. private static rayl;
  11460. /**
  11461. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11462. * @param sega the first point of the segment to test the intersection against
  11463. * @param segb the second point of the segment to test the intersection against
  11464. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11465. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11466. */
  11467. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11468. /**
  11469. * Update the ray from viewport position
  11470. * @param x position
  11471. * @param y y position
  11472. * @param viewportWidth viewport width
  11473. * @param viewportHeight viewport height
  11474. * @param world world matrix
  11475. * @param view view matrix
  11476. * @param projection projection matrix
  11477. * @returns this ray updated
  11478. */
  11479. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11480. /**
  11481. * Creates a ray with origin and direction of 0,0,0
  11482. * @returns the new ray
  11483. */
  11484. static Zero(): Ray;
  11485. /**
  11486. * Creates a new ray from screen space and viewport
  11487. * @param x position
  11488. * @param y y position
  11489. * @param viewportWidth viewport width
  11490. * @param viewportHeight viewport height
  11491. * @param world world matrix
  11492. * @param view view matrix
  11493. * @param projection projection matrix
  11494. * @returns new ray
  11495. */
  11496. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11497. /**
  11498. * 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
  11499. * transformed to the given world matrix.
  11500. * @param origin The origin point
  11501. * @param end The end point
  11502. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11503. * @returns the new ray
  11504. */
  11505. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11506. /**
  11507. * Transforms a ray by a matrix
  11508. * @param ray ray to transform
  11509. * @param matrix matrix to apply
  11510. * @returns the resulting new ray
  11511. */
  11512. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11513. /**
  11514. * Transforms a ray by a matrix
  11515. * @param ray ray to transform
  11516. * @param matrix matrix to apply
  11517. * @param result ray to store result in
  11518. */
  11519. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11520. /**
  11521. * Unproject a ray from screen space to object space
  11522. * @param sourceX defines the screen space x coordinate to use
  11523. * @param sourceY defines the screen space y coordinate to use
  11524. * @param viewportWidth defines the current width of the viewport
  11525. * @param viewportHeight defines the current height of the viewport
  11526. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11527. * @param view defines the view matrix to use
  11528. * @param projection defines the projection matrix to use
  11529. */
  11530. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11531. }
  11532. /**
  11533. * Type used to define predicate used to select faces when a mesh intersection is detected
  11534. */
  11535. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11536. interface Scene {
  11537. /** @hidden */
  11538. _tempPickingRay: Nullable<Ray>;
  11539. /** @hidden */
  11540. _cachedRayForTransform: Ray;
  11541. /** @hidden */
  11542. _pickWithRayInverseMatrix: Matrix;
  11543. /** @hidden */
  11544. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11545. /** @hidden */
  11546. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11547. }
  11548. }
  11549. declare module BABYLON {
  11550. /**
  11551. * Groups all the scene component constants in one place to ease maintenance.
  11552. * @hidden
  11553. */
  11554. export class SceneComponentConstants {
  11555. static readonly NAME_EFFECTLAYER: string;
  11556. static readonly NAME_LAYER: string;
  11557. static readonly NAME_LENSFLARESYSTEM: string;
  11558. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11559. static readonly NAME_PARTICLESYSTEM: string;
  11560. static readonly NAME_GAMEPAD: string;
  11561. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11562. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11563. static readonly NAME_DEPTHRENDERER: string;
  11564. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11565. static readonly NAME_SPRITE: string;
  11566. static readonly NAME_OUTLINERENDERER: string;
  11567. static readonly NAME_PROCEDURALTEXTURE: string;
  11568. static readonly NAME_SHADOWGENERATOR: string;
  11569. static readonly NAME_OCTREE: string;
  11570. static readonly NAME_PHYSICSENGINE: string;
  11571. static readonly NAME_AUDIO: string;
  11572. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11573. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11574. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11575. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11576. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11577. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11578. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11579. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11580. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11581. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11582. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11583. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11584. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11585. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11586. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11587. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11588. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11589. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11590. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11591. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11592. static readonly STEP_AFTERRENDER_AUDIO: number;
  11593. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11594. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11595. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11596. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11597. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11598. static readonly STEP_POINTERMOVE_SPRITE: number;
  11599. static readonly STEP_POINTERDOWN_SPRITE: number;
  11600. static readonly STEP_POINTERUP_SPRITE: number;
  11601. }
  11602. /**
  11603. * This represents a scene component.
  11604. *
  11605. * This is used to decouple the dependency the scene is having on the different workloads like
  11606. * layers, post processes...
  11607. */
  11608. export interface ISceneComponent {
  11609. /**
  11610. * The name of the component. Each component must have a unique name.
  11611. */
  11612. name: string;
  11613. /**
  11614. * The scene the component belongs to.
  11615. */
  11616. scene: Scene;
  11617. /**
  11618. * Register the component to one instance of a scene.
  11619. */
  11620. register(): void;
  11621. /**
  11622. * Rebuilds the elements related to this component in case of
  11623. * context lost for instance.
  11624. */
  11625. rebuild(): void;
  11626. /**
  11627. * Disposes the component and the associated ressources.
  11628. */
  11629. dispose(): void;
  11630. }
  11631. /**
  11632. * This represents a SERIALIZABLE scene component.
  11633. *
  11634. * This extends Scene Component to add Serialization methods on top.
  11635. */
  11636. export interface ISceneSerializableComponent extends ISceneComponent {
  11637. /**
  11638. * Adds all the element from the container to the scene
  11639. * @param container the container holding the elements
  11640. */
  11641. addFromContainer(container: AbstractScene): void;
  11642. /**
  11643. * Removes all the elements in the container from the scene
  11644. * @param container contains the elements to remove
  11645. * @param dispose if the removed element should be disposed (default: false)
  11646. */
  11647. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11648. /**
  11649. * Serializes the component data to the specified json object
  11650. * @param serializationObject The object to serialize to
  11651. */
  11652. serialize(serializationObject: any): void;
  11653. }
  11654. /**
  11655. * Strong typing of a Mesh related stage step action
  11656. */
  11657. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11658. /**
  11659. * Strong typing of a Evaluate Sub Mesh related stage step action
  11660. */
  11661. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11662. /**
  11663. * Strong typing of a Active Mesh related stage step action
  11664. */
  11665. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11666. /**
  11667. * Strong typing of a Camera related stage step action
  11668. */
  11669. export type CameraStageAction = (camera: Camera) => void;
  11670. /**
  11671. * Strong typing of a Camera Frame buffer related stage step action
  11672. */
  11673. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11674. /**
  11675. * Strong typing of a Render Target related stage step action
  11676. */
  11677. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11678. /**
  11679. * Strong typing of a RenderingGroup related stage step action
  11680. */
  11681. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11682. /**
  11683. * Strong typing of a Mesh Render related stage step action
  11684. */
  11685. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11686. /**
  11687. * Strong typing of a simple stage step action
  11688. */
  11689. export type SimpleStageAction = () => void;
  11690. /**
  11691. * Strong typing of a render target action.
  11692. */
  11693. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11694. /**
  11695. * Strong typing of a pointer move action.
  11696. */
  11697. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11698. /**
  11699. * Strong typing of a pointer up/down action.
  11700. */
  11701. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11702. /**
  11703. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11704. * @hidden
  11705. */
  11706. export class Stage<T extends Function> extends Array<{
  11707. index: number;
  11708. component: ISceneComponent;
  11709. action: T;
  11710. }> {
  11711. /**
  11712. * Hide ctor from the rest of the world.
  11713. * @param items The items to add.
  11714. */
  11715. private constructor();
  11716. /**
  11717. * Creates a new Stage.
  11718. * @returns A new instance of a Stage
  11719. */
  11720. static Create<T extends Function>(): Stage<T>;
  11721. /**
  11722. * Registers a step in an ordered way in the targeted stage.
  11723. * @param index Defines the position to register the step in
  11724. * @param component Defines the component attached to the step
  11725. * @param action Defines the action to launch during the step
  11726. */
  11727. registerStep(index: number, component: ISceneComponent, action: T): void;
  11728. /**
  11729. * Clears all the steps from the stage.
  11730. */
  11731. clear(): void;
  11732. }
  11733. }
  11734. declare module BABYLON {
  11735. interface Scene {
  11736. /** @hidden */
  11737. _pointerOverSprite: Nullable<Sprite>;
  11738. /** @hidden */
  11739. _pickedDownSprite: Nullable<Sprite>;
  11740. /** @hidden */
  11741. _tempSpritePickingRay: Nullable<Ray>;
  11742. /**
  11743. * All of the sprite managers added to this scene
  11744. * @see http://doc.babylonjs.com/babylon101/sprites
  11745. */
  11746. spriteManagers: Array<ISpriteManager>;
  11747. /**
  11748. * An event triggered when sprites rendering is about to start
  11749. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11750. */
  11751. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11752. /**
  11753. * An event triggered when sprites rendering is done
  11754. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11755. */
  11756. onAfterSpritesRenderingObservable: Observable<Scene>;
  11757. /** @hidden */
  11758. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11759. /** Launch a ray to try to pick a sprite in the scene
  11760. * @param x position on screen
  11761. * @param y position on screen
  11762. * @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
  11763. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11764. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11765. * @returns a PickingInfo
  11766. */
  11767. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11768. /** Use the given ray to pick a sprite in the scene
  11769. * @param ray The ray (in world space) to use to pick meshes
  11770. * @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
  11771. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11772. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11773. * @returns a PickingInfo
  11774. */
  11775. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11776. /**
  11777. * Force the sprite under the pointer
  11778. * @param sprite defines the sprite to use
  11779. */
  11780. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11781. /**
  11782. * Gets the sprite under the pointer
  11783. * @returns a Sprite or null if no sprite is under the pointer
  11784. */
  11785. getPointerOverSprite(): Nullable<Sprite>;
  11786. }
  11787. /**
  11788. * Defines the sprite scene component responsible to manage sprites
  11789. * in a given scene.
  11790. */
  11791. export class SpriteSceneComponent implements ISceneComponent {
  11792. /**
  11793. * The component name helpfull to identify the component in the list of scene components.
  11794. */
  11795. readonly name: string;
  11796. /**
  11797. * The scene the component belongs to.
  11798. */
  11799. scene: Scene;
  11800. /** @hidden */
  11801. private _spritePredicate;
  11802. /**
  11803. * Creates a new instance of the component for the given scene
  11804. * @param scene Defines the scene to register the component in
  11805. */
  11806. constructor(scene: Scene);
  11807. /**
  11808. * Registers the component in a given scene
  11809. */
  11810. register(): void;
  11811. /**
  11812. * Rebuilds the elements related to this component in case of
  11813. * context lost for instance.
  11814. */
  11815. rebuild(): void;
  11816. /**
  11817. * Disposes the component and the associated ressources.
  11818. */
  11819. dispose(): void;
  11820. private _pickSpriteButKeepRay;
  11821. private _pointerMove;
  11822. private _pointerDown;
  11823. private _pointerUp;
  11824. }
  11825. }
  11826. declare module BABYLON {
  11827. /** @hidden */
  11828. export var fogFragmentDeclaration: {
  11829. name: string;
  11830. shader: string;
  11831. };
  11832. }
  11833. declare module BABYLON {
  11834. /** @hidden */
  11835. export var fogFragment: {
  11836. name: string;
  11837. shader: string;
  11838. };
  11839. }
  11840. declare module BABYLON {
  11841. /** @hidden */
  11842. export var spritesPixelShader: {
  11843. name: string;
  11844. shader: string;
  11845. };
  11846. }
  11847. declare module BABYLON {
  11848. /** @hidden */
  11849. export var fogVertexDeclaration: {
  11850. name: string;
  11851. shader: string;
  11852. };
  11853. }
  11854. declare module BABYLON {
  11855. /** @hidden */
  11856. export var spritesVertexShader: {
  11857. name: string;
  11858. shader: string;
  11859. };
  11860. }
  11861. declare module BABYLON {
  11862. /**
  11863. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11864. */
  11865. export interface ISpriteManager extends IDisposable {
  11866. /**
  11867. * Restricts the camera to viewing objects with the same layerMask.
  11868. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11869. */
  11870. layerMask: number;
  11871. /**
  11872. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11873. */
  11874. isPickable: boolean;
  11875. /**
  11876. * Specifies the rendering group id for this mesh (0 by default)
  11877. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11878. */
  11879. renderingGroupId: number;
  11880. /**
  11881. * Defines the list of sprites managed by the manager.
  11882. */
  11883. sprites: Array<Sprite>;
  11884. /**
  11885. * Tests the intersection of a sprite with a specific ray.
  11886. * @param ray The ray we are sending to test the collision
  11887. * @param camera The camera space we are sending rays in
  11888. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11889. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11890. * @returns picking info or null.
  11891. */
  11892. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11893. /**
  11894. * Renders the list of sprites on screen.
  11895. */
  11896. render(): void;
  11897. }
  11898. /**
  11899. * Class used to manage multiple sprites on the same spritesheet
  11900. * @see http://doc.babylonjs.com/babylon101/sprites
  11901. */
  11902. export class SpriteManager implements ISpriteManager {
  11903. /** defines the manager's name */
  11904. name: string;
  11905. /** Gets the list of sprites */
  11906. sprites: Sprite[];
  11907. /** Gets or sets the rendering group id (0 by default) */
  11908. renderingGroupId: number;
  11909. /** Gets or sets camera layer mask */
  11910. layerMask: number;
  11911. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11912. fogEnabled: boolean;
  11913. /** Gets or sets a boolean indicating if the sprites are pickable */
  11914. isPickable: boolean;
  11915. /** Defines the default width of a cell in the spritesheet */
  11916. cellWidth: number;
  11917. /** Defines the default height of a cell in the spritesheet */
  11918. cellHeight: number;
  11919. /**
  11920. * An event triggered when the manager is disposed.
  11921. */
  11922. onDisposeObservable: Observable<SpriteManager>;
  11923. private _onDisposeObserver;
  11924. /**
  11925. * Callback called when the manager is disposed
  11926. */
  11927. onDispose: () => void;
  11928. private _capacity;
  11929. private _spriteTexture;
  11930. private _epsilon;
  11931. private _scene;
  11932. private _vertexData;
  11933. private _buffer;
  11934. private _vertexBuffers;
  11935. private _indexBuffer;
  11936. private _effectBase;
  11937. private _effectFog;
  11938. /**
  11939. * Gets or sets the spritesheet texture
  11940. */
  11941. texture: Texture;
  11942. /**
  11943. * Creates a new sprite manager
  11944. * @param name defines the manager's name
  11945. * @param imgUrl defines the sprite sheet url
  11946. * @param capacity defines the maximum allowed number of sprites
  11947. * @param cellSize defines the size of a sprite cell
  11948. * @param scene defines the hosting scene
  11949. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11950. * @param samplingMode defines the smapling mode to use with spritesheet
  11951. */
  11952. constructor(
  11953. /** defines the manager's name */
  11954. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11955. private _appendSpriteVertex;
  11956. /**
  11957. * Intersects the sprites with a ray
  11958. * @param ray defines the ray to intersect with
  11959. * @param camera defines the current active camera
  11960. * @param predicate defines a predicate used to select candidate sprites
  11961. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11962. * @returns null if no hit or a PickingInfo
  11963. */
  11964. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11965. /**
  11966. * Render all child sprites
  11967. */
  11968. render(): void;
  11969. /**
  11970. * Release associated resources
  11971. */
  11972. dispose(): void;
  11973. }
  11974. }
  11975. declare module BABYLON {
  11976. /**
  11977. * Class used to represent a sprite
  11978. * @see http://doc.babylonjs.com/babylon101/sprites
  11979. */
  11980. export class Sprite {
  11981. /** defines the name */
  11982. name: string;
  11983. /** Gets or sets the current world position */
  11984. position: Vector3;
  11985. /** Gets or sets the main color */
  11986. color: Color4;
  11987. /** Gets or sets the width */
  11988. width: number;
  11989. /** Gets or sets the height */
  11990. height: number;
  11991. /** Gets or sets rotation angle */
  11992. angle: number;
  11993. /** Gets or sets the cell index in the sprite sheet */
  11994. cellIndex: number;
  11995. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11996. invertU: number;
  11997. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11998. invertV: number;
  11999. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12000. disposeWhenFinishedAnimating: boolean;
  12001. /** Gets the list of attached animations */
  12002. animations: Animation[];
  12003. /** Gets or sets a boolean indicating if the sprite can be picked */
  12004. isPickable: boolean;
  12005. /**
  12006. * Gets or sets the associated action manager
  12007. */
  12008. actionManager: Nullable<ActionManager>;
  12009. private _animationStarted;
  12010. private _loopAnimation;
  12011. private _fromIndex;
  12012. private _toIndex;
  12013. private _delay;
  12014. private _direction;
  12015. private _manager;
  12016. private _time;
  12017. private _onAnimationEnd;
  12018. /**
  12019. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12020. */
  12021. isVisible: boolean;
  12022. /**
  12023. * Gets or sets the sprite size
  12024. */
  12025. size: number;
  12026. /**
  12027. * Creates a new Sprite
  12028. * @param name defines the name
  12029. * @param manager defines the manager
  12030. */
  12031. constructor(
  12032. /** defines the name */
  12033. name: string, manager: ISpriteManager);
  12034. /**
  12035. * Starts an animation
  12036. * @param from defines the initial key
  12037. * @param to defines the end key
  12038. * @param loop defines if the animation must loop
  12039. * @param delay defines the start delay (in ms)
  12040. * @param onAnimationEnd defines a callback to call when animation ends
  12041. */
  12042. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12043. /** Stops current animation (if any) */
  12044. stopAnimation(): void;
  12045. /** @hidden */
  12046. _animate(deltaTime: number): void;
  12047. /** Release associated resources */
  12048. dispose(): void;
  12049. }
  12050. }
  12051. declare module BABYLON {
  12052. /**
  12053. * Information about the result of picking within a scene
  12054. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12055. */
  12056. export class PickingInfo {
  12057. /** @hidden */
  12058. _pickingUnavailable: boolean;
  12059. /**
  12060. * If the pick collided with an object
  12061. */
  12062. hit: boolean;
  12063. /**
  12064. * Distance away where the pick collided
  12065. */
  12066. distance: number;
  12067. /**
  12068. * The location of pick collision
  12069. */
  12070. pickedPoint: Nullable<Vector3>;
  12071. /**
  12072. * The mesh corresponding the the pick collision
  12073. */
  12074. pickedMesh: Nullable<AbstractMesh>;
  12075. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12076. bu: number;
  12077. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12078. bv: number;
  12079. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12080. faceId: number;
  12081. /** Id of the the submesh that was picked */
  12082. subMeshId: number;
  12083. /** If a sprite was picked, this will be the sprite the pick collided with */
  12084. pickedSprite: Nullable<Sprite>;
  12085. /**
  12086. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12087. */
  12088. originMesh: Nullable<AbstractMesh>;
  12089. /**
  12090. * The ray that was used to perform the picking.
  12091. */
  12092. ray: Nullable<Ray>;
  12093. /**
  12094. * Gets the normal correspodning to the face the pick collided with
  12095. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12096. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12097. * @returns The normal correspodning to the face the pick collided with
  12098. */
  12099. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12100. /**
  12101. * Gets the texture coordinates of where the pick occured
  12102. * @returns the vector containing the coordnates of the texture
  12103. */
  12104. getTextureCoordinates(): Nullable<Vector2>;
  12105. }
  12106. }
  12107. declare module BABYLON {
  12108. /**
  12109. * Gather the list of pointer event types as constants.
  12110. */
  12111. export class PointerEventTypes {
  12112. /**
  12113. * 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.
  12114. */
  12115. static readonly POINTERDOWN: number;
  12116. /**
  12117. * The pointerup event is fired when a pointer is no longer active.
  12118. */
  12119. static readonly POINTERUP: number;
  12120. /**
  12121. * The pointermove event is fired when a pointer changes coordinates.
  12122. */
  12123. static readonly POINTERMOVE: number;
  12124. /**
  12125. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12126. */
  12127. static readonly POINTERWHEEL: number;
  12128. /**
  12129. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12130. */
  12131. static readonly POINTERPICK: number;
  12132. /**
  12133. * The pointertap event is fired when a the object has been touched and released without drag.
  12134. */
  12135. static readonly POINTERTAP: number;
  12136. /**
  12137. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12138. */
  12139. static readonly POINTERDOUBLETAP: number;
  12140. }
  12141. /**
  12142. * Base class of pointer info types.
  12143. */
  12144. export class PointerInfoBase {
  12145. /**
  12146. * Defines the type of event (PointerEventTypes)
  12147. */
  12148. type: number;
  12149. /**
  12150. * Defines the related dom event
  12151. */
  12152. event: PointerEvent | MouseWheelEvent;
  12153. /**
  12154. * Instantiates the base class of pointers info.
  12155. * @param type Defines the type of event (PointerEventTypes)
  12156. * @param event Defines the related dom event
  12157. */
  12158. constructor(
  12159. /**
  12160. * Defines the type of event (PointerEventTypes)
  12161. */
  12162. type: number,
  12163. /**
  12164. * Defines the related dom event
  12165. */
  12166. event: PointerEvent | MouseWheelEvent);
  12167. }
  12168. /**
  12169. * This class is used to store pointer related info for the onPrePointerObservable event.
  12170. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12171. */
  12172. export class PointerInfoPre extends PointerInfoBase {
  12173. /**
  12174. * Ray from a pointer if availible (eg. 6dof controller)
  12175. */
  12176. ray: Nullable<Ray>;
  12177. /**
  12178. * Defines the local position of the pointer on the canvas.
  12179. */
  12180. localPosition: Vector2;
  12181. /**
  12182. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12183. */
  12184. skipOnPointerObservable: boolean;
  12185. /**
  12186. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12187. * @param type Defines the type of event (PointerEventTypes)
  12188. * @param event Defines the related dom event
  12189. * @param localX Defines the local x coordinates of the pointer when the event occured
  12190. * @param localY Defines the local y coordinates of the pointer when the event occured
  12191. */
  12192. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12193. }
  12194. /**
  12195. * This type contains all the data related to a pointer event in Babylon.js.
  12196. * 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.
  12197. */
  12198. export class PointerInfo extends PointerInfoBase {
  12199. /**
  12200. * Defines the picking info associated to the info (if any)\
  12201. */
  12202. pickInfo: Nullable<PickingInfo>;
  12203. /**
  12204. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12205. * @param type Defines the type of event (PointerEventTypes)
  12206. * @param event Defines the related dom event
  12207. * @param pickInfo Defines the picking info associated to the info (if any)\
  12208. */
  12209. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12210. /**
  12211. * Defines the picking info associated to the info (if any)\
  12212. */
  12213. pickInfo: Nullable<PickingInfo>);
  12214. }
  12215. /**
  12216. * Data relating to a touch event on the screen.
  12217. */
  12218. export interface PointerTouch {
  12219. /**
  12220. * X coordinate of touch.
  12221. */
  12222. x: number;
  12223. /**
  12224. * Y coordinate of touch.
  12225. */
  12226. y: number;
  12227. /**
  12228. * Id of touch. Unique for each finger.
  12229. */
  12230. pointerId: number;
  12231. /**
  12232. * Event type passed from DOM.
  12233. */
  12234. type: any;
  12235. }
  12236. }
  12237. declare module BABYLON {
  12238. /**
  12239. * Manage the mouse inputs to control the movement of a free camera.
  12240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12241. */
  12242. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12243. /**
  12244. * Define if touch is enabled in the mouse input
  12245. */
  12246. touchEnabled: boolean;
  12247. /**
  12248. * Defines the camera the input is attached to.
  12249. */
  12250. camera: FreeCamera;
  12251. /**
  12252. * Defines the buttons associated with the input to handle camera move.
  12253. */
  12254. buttons: number[];
  12255. /**
  12256. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12257. */
  12258. angularSensibility: number;
  12259. private _pointerInput;
  12260. private _onMouseMove;
  12261. private _observer;
  12262. private previousPosition;
  12263. /**
  12264. * Observable for when a pointer move event occurs containing the move offset
  12265. */
  12266. onPointerMovedObservable: Observable<{
  12267. offsetX: number;
  12268. offsetY: number;
  12269. }>;
  12270. /**
  12271. * @hidden
  12272. * If the camera should be rotated automatically based on pointer movement
  12273. */
  12274. _allowCameraRotation: boolean;
  12275. /**
  12276. * Manage the mouse inputs to control the movement of a free camera.
  12277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12278. * @param touchEnabled Defines if touch is enabled or not
  12279. */
  12280. constructor(
  12281. /**
  12282. * Define if touch is enabled in the mouse input
  12283. */
  12284. touchEnabled?: boolean);
  12285. /**
  12286. * Attach the input controls to a specific dom element to get the input from.
  12287. * @param element Defines the element the controls should be listened from
  12288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12289. */
  12290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12291. /**
  12292. * Called on JS contextmenu event.
  12293. * Override this method to provide functionality.
  12294. */
  12295. protected onContextMenu(evt: PointerEvent): void;
  12296. /**
  12297. * Detach the current controls from the specified dom element.
  12298. * @param element Defines the element to stop listening the inputs from
  12299. */
  12300. detachControl(element: Nullable<HTMLElement>): void;
  12301. /**
  12302. * Gets the class name of the current intput.
  12303. * @returns the class name
  12304. */
  12305. getClassName(): string;
  12306. /**
  12307. * Get the friendly name associated with the input class.
  12308. * @returns the input friendly name
  12309. */
  12310. getSimpleName(): string;
  12311. }
  12312. }
  12313. declare module BABYLON {
  12314. /**
  12315. * Manage the touch inputs to control the movement of a free camera.
  12316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12317. */
  12318. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12319. /**
  12320. * Defines the camera the input is attached to.
  12321. */
  12322. camera: FreeCamera;
  12323. /**
  12324. * Defines the touch sensibility for rotation.
  12325. * The higher the faster.
  12326. */
  12327. touchAngularSensibility: number;
  12328. /**
  12329. * Defines the touch sensibility for move.
  12330. * The higher the faster.
  12331. */
  12332. touchMoveSensibility: number;
  12333. private _offsetX;
  12334. private _offsetY;
  12335. private _pointerPressed;
  12336. private _pointerInput;
  12337. private _observer;
  12338. private _onLostFocus;
  12339. /**
  12340. * Attach the input controls to a specific dom element to get the input from.
  12341. * @param element Defines the element the controls should be listened from
  12342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12343. */
  12344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12345. /**
  12346. * Detach the current controls from the specified dom element.
  12347. * @param element Defines the element to stop listening the inputs from
  12348. */
  12349. detachControl(element: Nullable<HTMLElement>): void;
  12350. /**
  12351. * Update the current camera state depending on the inputs that have been used this frame.
  12352. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12353. */
  12354. checkInputs(): void;
  12355. /**
  12356. * Gets the class name of the current intput.
  12357. * @returns the class name
  12358. */
  12359. getClassName(): string;
  12360. /**
  12361. * Get the friendly name associated with the input class.
  12362. * @returns the input friendly name
  12363. */
  12364. getSimpleName(): string;
  12365. }
  12366. }
  12367. declare module BABYLON {
  12368. /**
  12369. * Default Inputs manager for the FreeCamera.
  12370. * It groups all the default supported inputs for ease of use.
  12371. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12372. */
  12373. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12374. /**
  12375. * @hidden
  12376. */
  12377. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12378. /**
  12379. * @hidden
  12380. */
  12381. _mouseInput: Nullable<FreeCameraMouseInput>;
  12382. /**
  12383. * Instantiates a new FreeCameraInputsManager.
  12384. * @param camera Defines the camera the inputs belong to
  12385. */
  12386. constructor(camera: FreeCamera);
  12387. /**
  12388. * Add keyboard input support to the input manager.
  12389. * @returns the current input manager
  12390. */
  12391. addKeyboard(): FreeCameraInputsManager;
  12392. /**
  12393. * Add mouse input support to the input manager.
  12394. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12395. * @returns the current input manager
  12396. */
  12397. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12398. /**
  12399. * Removes the mouse input support from the manager
  12400. * @returns the current input manager
  12401. */
  12402. removeMouse(): FreeCameraInputsManager;
  12403. /**
  12404. * Add touch input support to the input manager.
  12405. * @returns the current input manager
  12406. */
  12407. addTouch(): FreeCameraInputsManager;
  12408. }
  12409. }
  12410. declare module BABYLON {
  12411. /**
  12412. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12413. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12414. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12415. */
  12416. export class FreeCamera extends TargetCamera {
  12417. /**
  12418. * Define the collision ellipsoid of the camera.
  12419. * This is helpful to simulate a camera body like the player body around the camera
  12420. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12421. */
  12422. ellipsoid: Vector3;
  12423. /**
  12424. * Define an offset for the position of the ellipsoid around the camera.
  12425. * This can be helpful to determine the center of the body near the gravity center of the body
  12426. * instead of its head.
  12427. */
  12428. ellipsoidOffset: Vector3;
  12429. /**
  12430. * Enable or disable collisions of the camera with the rest of the scene objects.
  12431. */
  12432. checkCollisions: boolean;
  12433. /**
  12434. * Enable or disable gravity on the camera.
  12435. */
  12436. applyGravity: boolean;
  12437. /**
  12438. * Define the input manager associated to the camera.
  12439. */
  12440. inputs: FreeCameraInputsManager;
  12441. /**
  12442. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12443. * Higher values reduce sensitivity.
  12444. */
  12445. /**
  12446. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12447. * Higher values reduce sensitivity.
  12448. */
  12449. angularSensibility: number;
  12450. /**
  12451. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12452. */
  12453. keysUp: number[];
  12454. /**
  12455. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12456. */
  12457. keysDown: number[];
  12458. /**
  12459. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12460. */
  12461. keysLeft: number[];
  12462. /**
  12463. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12464. */
  12465. keysRight: number[];
  12466. /**
  12467. * Event raised when the camera collide with a mesh in the scene.
  12468. */
  12469. onCollide: (collidedMesh: AbstractMesh) => void;
  12470. private _collider;
  12471. private _needMoveForGravity;
  12472. private _oldPosition;
  12473. private _diffPosition;
  12474. private _newPosition;
  12475. /** @hidden */
  12476. _localDirection: Vector3;
  12477. /** @hidden */
  12478. _transformedDirection: Vector3;
  12479. /**
  12480. * Instantiates a Free Camera.
  12481. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12482. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12483. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12484. * @param name Define the name of the camera in the scene
  12485. * @param position Define the start position of the camera in the scene
  12486. * @param scene Define the scene the camera belongs to
  12487. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12488. */
  12489. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12490. /**
  12491. * Attached controls to the current camera.
  12492. * @param element Defines the element the controls should be listened from
  12493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12494. */
  12495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12496. /**
  12497. * Detach the current controls from the camera.
  12498. * The camera will stop reacting to inputs.
  12499. * @param element Defines the element to stop listening the inputs from
  12500. */
  12501. detachControl(element: HTMLElement): void;
  12502. private _collisionMask;
  12503. /**
  12504. * Define a collision mask to limit the list of object the camera can collide with
  12505. */
  12506. collisionMask: number;
  12507. /** @hidden */
  12508. _collideWithWorld(displacement: Vector3): void;
  12509. private _onCollisionPositionChange;
  12510. /** @hidden */
  12511. _checkInputs(): void;
  12512. /** @hidden */
  12513. _decideIfNeedsToMove(): boolean;
  12514. /** @hidden */
  12515. _updatePosition(): void;
  12516. /**
  12517. * Destroy the camera and release the current resources hold by it.
  12518. */
  12519. dispose(): void;
  12520. /**
  12521. * Gets the current object class name.
  12522. * @return the class name
  12523. */
  12524. getClassName(): string;
  12525. }
  12526. }
  12527. declare module BABYLON {
  12528. /**
  12529. * Represents a gamepad control stick position
  12530. */
  12531. export class StickValues {
  12532. /**
  12533. * The x component of the control stick
  12534. */
  12535. x: number;
  12536. /**
  12537. * The y component of the control stick
  12538. */
  12539. y: number;
  12540. /**
  12541. * Initializes the gamepad x and y control stick values
  12542. * @param x The x component of the gamepad control stick value
  12543. * @param y The y component of the gamepad control stick value
  12544. */
  12545. constructor(
  12546. /**
  12547. * The x component of the control stick
  12548. */
  12549. x: number,
  12550. /**
  12551. * The y component of the control stick
  12552. */
  12553. y: number);
  12554. }
  12555. /**
  12556. * An interface which manages callbacks for gamepad button changes
  12557. */
  12558. export interface GamepadButtonChanges {
  12559. /**
  12560. * Called when a gamepad has been changed
  12561. */
  12562. changed: boolean;
  12563. /**
  12564. * Called when a gamepad press event has been triggered
  12565. */
  12566. pressChanged: boolean;
  12567. /**
  12568. * Called when a touch event has been triggered
  12569. */
  12570. touchChanged: boolean;
  12571. /**
  12572. * Called when a value has changed
  12573. */
  12574. valueChanged: boolean;
  12575. }
  12576. /**
  12577. * Represents a gamepad
  12578. */
  12579. export class Gamepad {
  12580. /**
  12581. * The id of the gamepad
  12582. */
  12583. id: string;
  12584. /**
  12585. * The index of the gamepad
  12586. */
  12587. index: number;
  12588. /**
  12589. * The browser gamepad
  12590. */
  12591. browserGamepad: any;
  12592. /**
  12593. * Specifies what type of gamepad this represents
  12594. */
  12595. type: number;
  12596. private _leftStick;
  12597. private _rightStick;
  12598. /** @hidden */
  12599. _isConnected: boolean;
  12600. private _leftStickAxisX;
  12601. private _leftStickAxisY;
  12602. private _rightStickAxisX;
  12603. private _rightStickAxisY;
  12604. /**
  12605. * Triggered when the left control stick has been changed
  12606. */
  12607. private _onleftstickchanged;
  12608. /**
  12609. * Triggered when the right control stick has been changed
  12610. */
  12611. private _onrightstickchanged;
  12612. /**
  12613. * Represents a gamepad controller
  12614. */
  12615. static GAMEPAD: number;
  12616. /**
  12617. * Represents a generic controller
  12618. */
  12619. static GENERIC: number;
  12620. /**
  12621. * Represents an XBox controller
  12622. */
  12623. static XBOX: number;
  12624. /**
  12625. * Represents a pose-enabled controller
  12626. */
  12627. static POSE_ENABLED: number;
  12628. /**
  12629. * Specifies whether the left control stick should be Y-inverted
  12630. */
  12631. protected _invertLeftStickY: boolean;
  12632. /**
  12633. * Specifies if the gamepad has been connected
  12634. */
  12635. readonly isConnected: boolean;
  12636. /**
  12637. * Initializes the gamepad
  12638. * @param id The id of the gamepad
  12639. * @param index The index of the gamepad
  12640. * @param browserGamepad The browser gamepad
  12641. * @param leftStickX The x component of the left joystick
  12642. * @param leftStickY The y component of the left joystick
  12643. * @param rightStickX The x component of the right joystick
  12644. * @param rightStickY The y component of the right joystick
  12645. */
  12646. constructor(
  12647. /**
  12648. * The id of the gamepad
  12649. */
  12650. id: string,
  12651. /**
  12652. * The index of the gamepad
  12653. */
  12654. index: number,
  12655. /**
  12656. * The browser gamepad
  12657. */
  12658. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12659. /**
  12660. * Callback triggered when the left joystick has changed
  12661. * @param callback
  12662. */
  12663. onleftstickchanged(callback: (values: StickValues) => void): void;
  12664. /**
  12665. * Callback triggered when the right joystick has changed
  12666. * @param callback
  12667. */
  12668. onrightstickchanged(callback: (values: StickValues) => void): void;
  12669. /**
  12670. * Gets the left joystick
  12671. */
  12672. /**
  12673. * Sets the left joystick values
  12674. */
  12675. leftStick: StickValues;
  12676. /**
  12677. * Gets the right joystick
  12678. */
  12679. /**
  12680. * Sets the right joystick value
  12681. */
  12682. rightStick: StickValues;
  12683. /**
  12684. * Updates the gamepad joystick positions
  12685. */
  12686. update(): void;
  12687. /**
  12688. * Disposes the gamepad
  12689. */
  12690. dispose(): void;
  12691. }
  12692. /**
  12693. * Represents a generic gamepad
  12694. */
  12695. export class GenericPad extends Gamepad {
  12696. private _buttons;
  12697. private _onbuttondown;
  12698. private _onbuttonup;
  12699. /**
  12700. * Observable triggered when a button has been pressed
  12701. */
  12702. onButtonDownObservable: Observable<number>;
  12703. /**
  12704. * Observable triggered when a button has been released
  12705. */
  12706. onButtonUpObservable: Observable<number>;
  12707. /**
  12708. * Callback triggered when a button has been pressed
  12709. * @param callback Called when a button has been pressed
  12710. */
  12711. onbuttondown(callback: (buttonPressed: number) => void): void;
  12712. /**
  12713. * Callback triggered when a button has been released
  12714. * @param callback Called when a button has been released
  12715. */
  12716. onbuttonup(callback: (buttonReleased: number) => void): void;
  12717. /**
  12718. * Initializes the generic gamepad
  12719. * @param id The id of the generic gamepad
  12720. * @param index The index of the generic gamepad
  12721. * @param browserGamepad The browser gamepad
  12722. */
  12723. constructor(id: string, index: number, browserGamepad: any);
  12724. private _setButtonValue;
  12725. /**
  12726. * Updates the generic gamepad
  12727. */
  12728. update(): void;
  12729. /**
  12730. * Disposes the generic gamepad
  12731. */
  12732. dispose(): void;
  12733. }
  12734. }
  12735. declare module BABYLON {
  12736. /**
  12737. * Defines the types of pose enabled controllers that are supported
  12738. */
  12739. export enum PoseEnabledControllerType {
  12740. /**
  12741. * HTC Vive
  12742. */
  12743. VIVE = 0,
  12744. /**
  12745. * Oculus Rift
  12746. */
  12747. OCULUS = 1,
  12748. /**
  12749. * Windows mixed reality
  12750. */
  12751. WINDOWS = 2,
  12752. /**
  12753. * Samsung gear VR
  12754. */
  12755. GEAR_VR = 3,
  12756. /**
  12757. * Google Daydream
  12758. */
  12759. DAYDREAM = 4,
  12760. /**
  12761. * Generic
  12762. */
  12763. GENERIC = 5
  12764. }
  12765. /**
  12766. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12767. */
  12768. export interface MutableGamepadButton {
  12769. /**
  12770. * Value of the button/trigger
  12771. */
  12772. value: number;
  12773. /**
  12774. * If the button/trigger is currently touched
  12775. */
  12776. touched: boolean;
  12777. /**
  12778. * If the button/trigger is currently pressed
  12779. */
  12780. pressed: boolean;
  12781. }
  12782. /**
  12783. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12784. * @hidden
  12785. */
  12786. export interface ExtendedGamepadButton extends GamepadButton {
  12787. /**
  12788. * If the button/trigger is currently pressed
  12789. */
  12790. readonly pressed: boolean;
  12791. /**
  12792. * If the button/trigger is currently touched
  12793. */
  12794. readonly touched: boolean;
  12795. /**
  12796. * Value of the button/trigger
  12797. */
  12798. readonly value: number;
  12799. }
  12800. /** @hidden */
  12801. export interface _GamePadFactory {
  12802. /**
  12803. * Returns wether or not the current gamepad can be created for this type of controller.
  12804. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12805. * @returns true if it can be created, otherwise false
  12806. */
  12807. canCreate(gamepadInfo: any): boolean;
  12808. /**
  12809. * Creates a new instance of the Gamepad.
  12810. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12811. * @returns the new gamepad instance
  12812. */
  12813. create(gamepadInfo: any): Gamepad;
  12814. }
  12815. /**
  12816. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12817. */
  12818. export class PoseEnabledControllerHelper {
  12819. /** @hidden */
  12820. static _ControllerFactories: _GamePadFactory[];
  12821. /** @hidden */
  12822. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12823. /**
  12824. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12825. * @param vrGamepad the gamepad to initialized
  12826. * @returns a vr controller of the type the gamepad identified as
  12827. */
  12828. static InitiateController(vrGamepad: any): Gamepad;
  12829. }
  12830. /**
  12831. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12832. */
  12833. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12834. private _deviceRoomPosition;
  12835. private _deviceRoomRotationQuaternion;
  12836. /**
  12837. * The device position in babylon space
  12838. */
  12839. devicePosition: Vector3;
  12840. /**
  12841. * The device rotation in babylon space
  12842. */
  12843. deviceRotationQuaternion: Quaternion;
  12844. /**
  12845. * The scale factor of the device in babylon space
  12846. */
  12847. deviceScaleFactor: number;
  12848. /**
  12849. * (Likely devicePosition should be used instead) The device position in its room space
  12850. */
  12851. position: Vector3;
  12852. /**
  12853. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12854. */
  12855. rotationQuaternion: Quaternion;
  12856. /**
  12857. * The type of controller (Eg. Windows mixed reality)
  12858. */
  12859. controllerType: PoseEnabledControllerType;
  12860. protected _calculatedPosition: Vector3;
  12861. private _calculatedRotation;
  12862. /**
  12863. * The raw pose from the device
  12864. */
  12865. rawPose: DevicePose;
  12866. private _trackPosition;
  12867. private _maxRotationDistFromHeadset;
  12868. private _draggedRoomRotation;
  12869. /**
  12870. * @hidden
  12871. */
  12872. _disableTrackPosition(fixedPosition: Vector3): void;
  12873. /**
  12874. * Internal, the mesh attached to the controller
  12875. * @hidden
  12876. */
  12877. _mesh: Nullable<AbstractMesh>;
  12878. private _poseControlledCamera;
  12879. private _leftHandSystemQuaternion;
  12880. /**
  12881. * Internal, matrix used to convert room space to babylon space
  12882. * @hidden
  12883. */
  12884. _deviceToWorld: Matrix;
  12885. /**
  12886. * Node to be used when casting a ray from the controller
  12887. * @hidden
  12888. */
  12889. _pointingPoseNode: Nullable<TransformNode>;
  12890. /**
  12891. * Name of the child mesh that can be used to cast a ray from the controller
  12892. */
  12893. static readonly POINTING_POSE: string;
  12894. /**
  12895. * Creates a new PoseEnabledController from a gamepad
  12896. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12897. */
  12898. constructor(browserGamepad: any);
  12899. private _workingMatrix;
  12900. /**
  12901. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12902. */
  12903. update(): void;
  12904. /**
  12905. * Updates only the pose device and mesh without doing any button event checking
  12906. */
  12907. protected _updatePoseAndMesh(): void;
  12908. /**
  12909. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12910. * @param poseData raw pose fromthe device
  12911. */
  12912. updateFromDevice(poseData: DevicePose): void;
  12913. /**
  12914. * @hidden
  12915. */
  12916. _meshAttachedObservable: Observable<AbstractMesh>;
  12917. /**
  12918. * Attaches a mesh to the controller
  12919. * @param mesh the mesh to be attached
  12920. */
  12921. attachToMesh(mesh: AbstractMesh): void;
  12922. /**
  12923. * Attaches the controllers mesh to a camera
  12924. * @param camera the camera the mesh should be attached to
  12925. */
  12926. attachToPoseControlledCamera(camera: TargetCamera): void;
  12927. /**
  12928. * Disposes of the controller
  12929. */
  12930. dispose(): void;
  12931. /**
  12932. * The mesh that is attached to the controller
  12933. */
  12934. readonly mesh: Nullable<AbstractMesh>;
  12935. /**
  12936. * Gets the ray of the controller in the direction the controller is pointing
  12937. * @param length the length the resulting ray should be
  12938. * @returns a ray in the direction the controller is pointing
  12939. */
  12940. getForwardRay(length?: number): Ray;
  12941. }
  12942. }
  12943. declare module BABYLON {
  12944. /**
  12945. * Defines the WebVRController object that represents controllers tracked in 3D space
  12946. */
  12947. export abstract class WebVRController extends PoseEnabledController {
  12948. /**
  12949. * Internal, the default controller model for the controller
  12950. */
  12951. protected _defaultModel: AbstractMesh;
  12952. /**
  12953. * Fired when the trigger state has changed
  12954. */
  12955. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12956. /**
  12957. * Fired when the main button state has changed
  12958. */
  12959. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12960. /**
  12961. * Fired when the secondary button state has changed
  12962. */
  12963. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12964. /**
  12965. * Fired when the pad state has changed
  12966. */
  12967. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12968. /**
  12969. * Fired when controllers stick values have changed
  12970. */
  12971. onPadValuesChangedObservable: Observable<StickValues>;
  12972. /**
  12973. * Array of button availible on the controller
  12974. */
  12975. protected _buttons: Array<MutableGamepadButton>;
  12976. private _onButtonStateChange;
  12977. /**
  12978. * Fired when a controller button's state has changed
  12979. * @param callback the callback containing the button that was modified
  12980. */
  12981. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12982. /**
  12983. * X and Y axis corrisponding to the controllers joystick
  12984. */
  12985. pad: StickValues;
  12986. /**
  12987. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12988. */
  12989. hand: string;
  12990. /**
  12991. * The default controller model for the controller
  12992. */
  12993. readonly defaultModel: AbstractMesh;
  12994. /**
  12995. * Creates a new WebVRController from a gamepad
  12996. * @param vrGamepad the gamepad that the WebVRController should be created from
  12997. */
  12998. constructor(vrGamepad: any);
  12999. /**
  13000. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13001. */
  13002. update(): void;
  13003. /**
  13004. * Function to be called when a button is modified
  13005. */
  13006. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13007. /**
  13008. * Loads a mesh and attaches it to the controller
  13009. * @param scene the scene the mesh should be added to
  13010. * @param meshLoaded callback for when the mesh has been loaded
  13011. */
  13012. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13013. private _setButtonValue;
  13014. private _changes;
  13015. private _checkChanges;
  13016. /**
  13017. * Disposes of th webVRCOntroller
  13018. */
  13019. dispose(): void;
  13020. }
  13021. }
  13022. declare module BABYLON {
  13023. /**
  13024. * The HemisphericLight simulates the ambient environment light,
  13025. * so the passed direction is the light reflection direction, not the incoming direction.
  13026. */
  13027. export class HemisphericLight extends Light {
  13028. /**
  13029. * The groundColor is the light in the opposite direction to the one specified during creation.
  13030. * 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.
  13031. */
  13032. groundColor: Color3;
  13033. /**
  13034. * The light reflection direction, not the incoming direction.
  13035. */
  13036. direction: Vector3;
  13037. /**
  13038. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13039. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13040. * The HemisphericLight can't cast shadows.
  13041. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13042. * @param name The friendly name of the light
  13043. * @param direction The direction of the light reflection
  13044. * @param scene The scene the light belongs to
  13045. */
  13046. constructor(name: string, direction: Vector3, scene: Scene);
  13047. protected _buildUniformLayout(): void;
  13048. /**
  13049. * Returns the string "HemisphericLight".
  13050. * @return The class name
  13051. */
  13052. getClassName(): string;
  13053. /**
  13054. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13055. * Returns the updated direction.
  13056. * @param target The target the direction should point to
  13057. * @return The computed direction
  13058. */
  13059. setDirectionToTarget(target: Vector3): Vector3;
  13060. /**
  13061. * Returns the shadow generator associated to the light.
  13062. * @returns Always null for hemispheric lights because it does not support shadows.
  13063. */
  13064. getShadowGenerator(): Nullable<IShadowGenerator>;
  13065. /**
  13066. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13067. * @param effect The effect to update
  13068. * @param lightIndex The index of the light in the effect to update
  13069. * @returns The hemispheric light
  13070. */
  13071. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13072. /**
  13073. * Computes the world matrix of the node
  13074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13075. * @param useWasUpdatedFlag defines a reserved property
  13076. * @returns the world matrix
  13077. */
  13078. computeWorldMatrix(): Matrix;
  13079. /**
  13080. * Returns the integer 3.
  13081. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13082. */
  13083. getTypeID(): number;
  13084. /**
  13085. * Prepares the list of defines specific to the light type.
  13086. * @param defines the list of defines
  13087. * @param lightIndex defines the index of the light for the effect
  13088. */
  13089. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13090. }
  13091. }
  13092. declare module BABYLON {
  13093. /** @hidden */
  13094. export var vrMultiviewToSingleviewPixelShader: {
  13095. name: string;
  13096. shader: string;
  13097. };
  13098. }
  13099. declare module BABYLON {
  13100. /**
  13101. * Renders to multiple views with a single draw call
  13102. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13103. */
  13104. export class MultiviewRenderTarget extends RenderTargetTexture {
  13105. /**
  13106. * Creates a multiview render target
  13107. * @param scene scene used with the render target
  13108. * @param size the size of the render target (used for each view)
  13109. */
  13110. constructor(scene: Scene, size?: number | {
  13111. width: number;
  13112. height: number;
  13113. } | {
  13114. ratio: number;
  13115. });
  13116. /**
  13117. * @hidden
  13118. * @param faceIndex the face index, if its a cube texture
  13119. */
  13120. _bindFrameBuffer(faceIndex?: number): void;
  13121. /**
  13122. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13123. * @returns the view count
  13124. */
  13125. getViewCount(): number;
  13126. }
  13127. }
  13128. declare module BABYLON {
  13129. interface Engine {
  13130. /**
  13131. * Creates a new multiview render target
  13132. * @param width defines the width of the texture
  13133. * @param height defines the height of the texture
  13134. * @returns the created multiview texture
  13135. */
  13136. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13137. /**
  13138. * Binds a multiview framebuffer to be drawn to
  13139. * @param multiviewTexture texture to bind
  13140. */
  13141. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13142. }
  13143. interface Camera {
  13144. /**
  13145. * @hidden
  13146. * 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)
  13147. */
  13148. _useMultiviewToSingleView: boolean;
  13149. /**
  13150. * @hidden
  13151. * 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)
  13152. */
  13153. _multiviewTexture: Nullable<RenderTargetTexture>;
  13154. /**
  13155. * @hidden
  13156. * ensures the multiview texture of the camera exists and has the specified width/height
  13157. * @param width height to set on the multiview texture
  13158. * @param height width to set on the multiview texture
  13159. */
  13160. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13161. }
  13162. interface Scene {
  13163. /** @hidden */
  13164. _transformMatrixR: Matrix;
  13165. /** @hidden */
  13166. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13167. /** @hidden */
  13168. _createMultiviewUbo(): void;
  13169. /** @hidden */
  13170. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13171. /** @hidden */
  13172. _renderMultiviewToSingleView(camera: Camera): void;
  13173. }
  13174. }
  13175. declare module BABYLON {
  13176. /**
  13177. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13178. * This will not be used for webXR as it supports displaying texture arrays directly
  13179. */
  13180. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13181. /**
  13182. * Initializes a VRMultiviewToSingleview
  13183. * @param name name of the post process
  13184. * @param camera camera to be applied to
  13185. * @param scaleFactor scaling factor to the size of the output texture
  13186. */
  13187. constructor(name: string, camera: Camera, scaleFactor: number);
  13188. }
  13189. }
  13190. declare module BABYLON {
  13191. /**
  13192. * Defines the interface used by display changed events
  13193. */
  13194. interface IDisplayChangedEventArgs {
  13195. /** Gets the vrDisplay object (if any) */
  13196. vrDisplay: Nullable<any>;
  13197. /** Gets a boolean indicating if webVR is supported */
  13198. vrSupported: boolean;
  13199. }
  13200. interface Engine {
  13201. /** @hidden */
  13202. _vrDisplay: any;
  13203. /** @hidden */
  13204. _vrSupported: boolean;
  13205. /** @hidden */
  13206. _oldSize: Size;
  13207. /** @hidden */
  13208. _oldHardwareScaleFactor: number;
  13209. /** @hidden */
  13210. _vrExclusivePointerMode: boolean;
  13211. /** @hidden */
  13212. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13213. /** @hidden */
  13214. _onVRDisplayPointerRestricted: () => void;
  13215. /** @hidden */
  13216. _onVRDisplayPointerUnrestricted: () => void;
  13217. /** @hidden */
  13218. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13219. /** @hidden */
  13220. _onVrDisplayDisconnect: Nullable<() => void>;
  13221. /** @hidden */
  13222. _onVrDisplayPresentChange: Nullable<() => void>;
  13223. /**
  13224. * Observable signaled when VR display mode changes
  13225. */
  13226. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13227. /**
  13228. * Observable signaled when VR request present is complete
  13229. */
  13230. onVRRequestPresentComplete: Observable<boolean>;
  13231. /**
  13232. * Observable signaled when VR request present starts
  13233. */
  13234. onVRRequestPresentStart: Observable<Engine>;
  13235. /**
  13236. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13237. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13238. */
  13239. isInVRExclusivePointerMode: boolean;
  13240. /**
  13241. * Gets a boolean indicating if a webVR device was detected
  13242. * @returns true if a webVR device was detected
  13243. */
  13244. isVRDevicePresent(): boolean;
  13245. /**
  13246. * Gets the current webVR device
  13247. * @returns the current webVR device (or null)
  13248. */
  13249. getVRDevice(): any;
  13250. /**
  13251. * Initializes a webVR display and starts listening to display change events
  13252. * The onVRDisplayChangedObservable will be notified upon these changes
  13253. * @returns A promise containing a VRDisplay and if vr is supported
  13254. */
  13255. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13256. /** @hidden */
  13257. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13258. /**
  13259. * Call this function to switch to webVR mode
  13260. * Will do nothing if webVR is not supported or if there is no webVR device
  13261. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13262. */
  13263. enableVR(): void;
  13264. /** @hidden */
  13265. _onVRFullScreenTriggered(): void;
  13266. }
  13267. }
  13268. declare module BABYLON {
  13269. /**
  13270. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13271. * IMPORTANT!! The data is right-hand data.
  13272. * @export
  13273. * @interface DevicePose
  13274. */
  13275. export interface DevicePose {
  13276. /**
  13277. * The position of the device, values in array are [x,y,z].
  13278. */
  13279. readonly position: Nullable<Float32Array>;
  13280. /**
  13281. * The linearVelocity of the device, values in array are [x,y,z].
  13282. */
  13283. readonly linearVelocity: Nullable<Float32Array>;
  13284. /**
  13285. * The linearAcceleration of the device, values in array are [x,y,z].
  13286. */
  13287. readonly linearAcceleration: Nullable<Float32Array>;
  13288. /**
  13289. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13290. */
  13291. readonly orientation: Nullable<Float32Array>;
  13292. /**
  13293. * The angularVelocity of the device, values in array are [x,y,z].
  13294. */
  13295. readonly angularVelocity: Nullable<Float32Array>;
  13296. /**
  13297. * The angularAcceleration of the device, values in array are [x,y,z].
  13298. */
  13299. readonly angularAcceleration: Nullable<Float32Array>;
  13300. }
  13301. /**
  13302. * Interface representing a pose controlled object in Babylon.
  13303. * A pose controlled object has both regular pose values as well as pose values
  13304. * from an external device such as a VR head mounted display
  13305. */
  13306. export interface PoseControlled {
  13307. /**
  13308. * The position of the object in babylon space.
  13309. */
  13310. position: Vector3;
  13311. /**
  13312. * The rotation quaternion of the object in babylon space.
  13313. */
  13314. rotationQuaternion: Quaternion;
  13315. /**
  13316. * The position of the device in babylon space.
  13317. */
  13318. devicePosition?: Vector3;
  13319. /**
  13320. * The rotation quaternion of the device in babylon space.
  13321. */
  13322. deviceRotationQuaternion: Quaternion;
  13323. /**
  13324. * The raw pose coming from the device.
  13325. */
  13326. rawPose: Nullable<DevicePose>;
  13327. /**
  13328. * The scale of the device to be used when translating from device space to babylon space.
  13329. */
  13330. deviceScaleFactor: number;
  13331. /**
  13332. * Updates the poseControlled values based on the input device pose.
  13333. * @param poseData the pose data to update the object with
  13334. */
  13335. updateFromDevice(poseData: DevicePose): void;
  13336. }
  13337. /**
  13338. * Set of options to customize the webVRCamera
  13339. */
  13340. export interface WebVROptions {
  13341. /**
  13342. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13343. */
  13344. trackPosition?: boolean;
  13345. /**
  13346. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13347. */
  13348. positionScale?: number;
  13349. /**
  13350. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13351. */
  13352. displayName?: string;
  13353. /**
  13354. * Should the native controller meshes be initialized. (default: true)
  13355. */
  13356. controllerMeshes?: boolean;
  13357. /**
  13358. * Creating a default HemiLight only on controllers. (default: true)
  13359. */
  13360. defaultLightingOnControllers?: boolean;
  13361. /**
  13362. * If you don't want to use the default VR button of the helper. (default: false)
  13363. */
  13364. useCustomVRButton?: boolean;
  13365. /**
  13366. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13367. */
  13368. customVRButton?: HTMLButtonElement;
  13369. /**
  13370. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13371. */
  13372. rayLength?: number;
  13373. /**
  13374. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13375. */
  13376. defaultHeight?: number;
  13377. /**
  13378. * If multiview should be used if availible (default: false)
  13379. */
  13380. useMultiview?: boolean;
  13381. }
  13382. /**
  13383. * This represents a WebVR camera.
  13384. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13385. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13386. */
  13387. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13388. private webVROptions;
  13389. /**
  13390. * @hidden
  13391. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13392. */
  13393. _vrDevice: any;
  13394. /**
  13395. * The rawPose of the vrDevice.
  13396. */
  13397. rawPose: Nullable<DevicePose>;
  13398. private _onVREnabled;
  13399. private _specsVersion;
  13400. private _attached;
  13401. private _frameData;
  13402. protected _descendants: Array<Node>;
  13403. private _deviceRoomPosition;
  13404. /** @hidden */
  13405. _deviceRoomRotationQuaternion: Quaternion;
  13406. private _standingMatrix;
  13407. /**
  13408. * Represents device position in babylon space.
  13409. */
  13410. devicePosition: Vector3;
  13411. /**
  13412. * Represents device rotation in babylon space.
  13413. */
  13414. deviceRotationQuaternion: Quaternion;
  13415. /**
  13416. * The scale of the device to be used when translating from device space to babylon space.
  13417. */
  13418. deviceScaleFactor: number;
  13419. private _deviceToWorld;
  13420. private _worldToDevice;
  13421. /**
  13422. * References to the webVR controllers for the vrDevice.
  13423. */
  13424. controllers: Array<WebVRController>;
  13425. /**
  13426. * Emits an event when a controller is attached.
  13427. */
  13428. onControllersAttachedObservable: Observable<WebVRController[]>;
  13429. /**
  13430. * Emits an event when a controller's mesh has been loaded;
  13431. */
  13432. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13433. /**
  13434. * Emits an event when the HMD's pose has been updated.
  13435. */
  13436. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13437. private _poseSet;
  13438. /**
  13439. * If the rig cameras be used as parent instead of this camera.
  13440. */
  13441. rigParenting: boolean;
  13442. private _lightOnControllers;
  13443. private _defaultHeight?;
  13444. /**
  13445. * Instantiates a WebVRFreeCamera.
  13446. * @param name The name of the WebVRFreeCamera
  13447. * @param position The starting anchor position for the camera
  13448. * @param scene The scene the camera belongs to
  13449. * @param webVROptions a set of customizable options for the webVRCamera
  13450. */
  13451. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13452. /**
  13453. * Gets the device distance from the ground in meters.
  13454. * @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.
  13455. */
  13456. deviceDistanceToRoomGround(): number;
  13457. /**
  13458. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13459. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13460. */
  13461. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13462. /**
  13463. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13464. * @returns A promise with a boolean set to if the standing matrix is supported.
  13465. */
  13466. useStandingMatrixAsync(): Promise<boolean>;
  13467. /**
  13468. * Disposes the camera
  13469. */
  13470. dispose(): void;
  13471. /**
  13472. * Gets a vrController by name.
  13473. * @param name The name of the controller to retreive
  13474. * @returns the controller matching the name specified or null if not found
  13475. */
  13476. getControllerByName(name: string): Nullable<WebVRController>;
  13477. private _leftController;
  13478. /**
  13479. * The controller corrisponding to the users left hand.
  13480. */
  13481. readonly leftController: Nullable<WebVRController>;
  13482. private _rightController;
  13483. /**
  13484. * The controller corrisponding to the users right hand.
  13485. */
  13486. readonly rightController: Nullable<WebVRController>;
  13487. /**
  13488. * Casts a ray forward from the vrCamera's gaze.
  13489. * @param length Length of the ray (default: 100)
  13490. * @returns the ray corrisponding to the gaze
  13491. */
  13492. getForwardRay(length?: number): Ray;
  13493. /**
  13494. * @hidden
  13495. * Updates the camera based on device's frame data
  13496. */
  13497. _checkInputs(): void;
  13498. /**
  13499. * Updates the poseControlled values based on the input device pose.
  13500. * @param poseData Pose coming from the device
  13501. */
  13502. updateFromDevice(poseData: DevicePose): void;
  13503. private _htmlElementAttached;
  13504. private _detachIfAttached;
  13505. /**
  13506. * WebVR's attach control will start broadcasting frames to the device.
  13507. * Note that in certain browsers (chrome for example) this function must be called
  13508. * within a user-interaction callback. Example:
  13509. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13510. *
  13511. * @param element html element to attach the vrDevice to
  13512. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13513. */
  13514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13515. /**
  13516. * Detaches the camera from the html element and disables VR
  13517. *
  13518. * @param element html element to detach from
  13519. */
  13520. detachControl(element: HTMLElement): void;
  13521. /**
  13522. * @returns the name of this class
  13523. */
  13524. getClassName(): string;
  13525. /**
  13526. * Calls resetPose on the vrDisplay
  13527. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13528. */
  13529. resetToCurrentRotation(): void;
  13530. /**
  13531. * @hidden
  13532. * Updates the rig cameras (left and right eye)
  13533. */
  13534. _updateRigCameras(): void;
  13535. private _workingVector;
  13536. private _oneVector;
  13537. private _workingMatrix;
  13538. private updateCacheCalled;
  13539. private _correctPositionIfNotTrackPosition;
  13540. /**
  13541. * @hidden
  13542. * Updates the cached values of the camera
  13543. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13544. */
  13545. _updateCache(ignoreParentClass?: boolean): void;
  13546. /**
  13547. * @hidden
  13548. * Get current device position in babylon world
  13549. */
  13550. _computeDevicePosition(): void;
  13551. /**
  13552. * Updates the current device position and rotation in the babylon world
  13553. */
  13554. update(): void;
  13555. /**
  13556. * @hidden
  13557. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13558. * @returns an identity matrix
  13559. */
  13560. _getViewMatrix(): Matrix;
  13561. private _tmpMatrix;
  13562. /**
  13563. * This function is called by the two RIG cameras.
  13564. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13565. * @hidden
  13566. */
  13567. _getWebVRViewMatrix(): Matrix;
  13568. /** @hidden */
  13569. _getWebVRProjectionMatrix(): Matrix;
  13570. private _onGamepadConnectedObserver;
  13571. private _onGamepadDisconnectedObserver;
  13572. private _updateCacheWhenTrackingDisabledObserver;
  13573. /**
  13574. * Initializes the controllers and their meshes
  13575. */
  13576. initControllers(): void;
  13577. }
  13578. }
  13579. declare module BABYLON {
  13580. /**
  13581. * Size options for a post process
  13582. */
  13583. export type PostProcessOptions = {
  13584. width: number;
  13585. height: number;
  13586. };
  13587. /**
  13588. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13589. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13590. */
  13591. export class PostProcess {
  13592. /** Name of the PostProcess. */
  13593. name: string;
  13594. /**
  13595. * Gets or sets the unique id of the post process
  13596. */
  13597. uniqueId: number;
  13598. /**
  13599. * Width of the texture to apply the post process on
  13600. */
  13601. width: number;
  13602. /**
  13603. * Height of the texture to apply the post process on
  13604. */
  13605. height: number;
  13606. /**
  13607. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13608. * @hidden
  13609. */
  13610. _outputTexture: Nullable<InternalTexture>;
  13611. /**
  13612. * Sampling mode used by the shader
  13613. * See https://doc.babylonjs.com/classes/3.1/texture
  13614. */
  13615. renderTargetSamplingMode: number;
  13616. /**
  13617. * Clear color to use when screen clearing
  13618. */
  13619. clearColor: Color4;
  13620. /**
  13621. * If the buffer needs to be cleared before applying the post process. (default: true)
  13622. * Should be set to false if shader will overwrite all previous pixels.
  13623. */
  13624. autoClear: boolean;
  13625. /**
  13626. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13627. */
  13628. alphaMode: number;
  13629. /**
  13630. * Sets the setAlphaBlendConstants of the babylon engine
  13631. */
  13632. alphaConstants: Color4;
  13633. /**
  13634. * Animations to be used for the post processing
  13635. */
  13636. animations: Animation[];
  13637. /**
  13638. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13639. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13640. */
  13641. enablePixelPerfectMode: boolean;
  13642. /**
  13643. * Force the postprocess to be applied without taking in account viewport
  13644. */
  13645. forceFullscreenViewport: boolean;
  13646. /**
  13647. * List of inspectable custom properties (used by the Inspector)
  13648. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13649. */
  13650. inspectableCustomProperties: IInspectable[];
  13651. /**
  13652. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13653. *
  13654. * | Value | Type | Description |
  13655. * | ----- | ----------------------------------- | ----------- |
  13656. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13657. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13658. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13659. *
  13660. */
  13661. scaleMode: number;
  13662. /**
  13663. * Force textures to be a power of two (default: false)
  13664. */
  13665. alwaysForcePOT: boolean;
  13666. private _samples;
  13667. /**
  13668. * Number of sample textures (default: 1)
  13669. */
  13670. samples: number;
  13671. /**
  13672. * Modify the scale of the post process to be the same as the viewport (default: false)
  13673. */
  13674. adaptScaleToCurrentViewport: boolean;
  13675. private _camera;
  13676. private _scene;
  13677. private _engine;
  13678. private _options;
  13679. private _reusable;
  13680. private _textureType;
  13681. /**
  13682. * Smart array of input and output textures for the post process.
  13683. * @hidden
  13684. */
  13685. _textures: SmartArray<InternalTexture>;
  13686. /**
  13687. * The index in _textures that corresponds to the output texture.
  13688. * @hidden
  13689. */
  13690. _currentRenderTextureInd: number;
  13691. private _effect;
  13692. private _samplers;
  13693. private _fragmentUrl;
  13694. private _vertexUrl;
  13695. private _parameters;
  13696. private _scaleRatio;
  13697. protected _indexParameters: any;
  13698. private _shareOutputWithPostProcess;
  13699. private _texelSize;
  13700. private _forcedOutputTexture;
  13701. /**
  13702. * Returns the fragment url or shader name used in the post process.
  13703. * @returns the fragment url or name in the shader store.
  13704. */
  13705. getEffectName(): string;
  13706. /**
  13707. * An event triggered when the postprocess is activated.
  13708. */
  13709. onActivateObservable: Observable<Camera>;
  13710. private _onActivateObserver;
  13711. /**
  13712. * A function that is added to the onActivateObservable
  13713. */
  13714. onActivate: Nullable<(camera: Camera) => void>;
  13715. /**
  13716. * An event triggered when the postprocess changes its size.
  13717. */
  13718. onSizeChangedObservable: Observable<PostProcess>;
  13719. private _onSizeChangedObserver;
  13720. /**
  13721. * A function that is added to the onSizeChangedObservable
  13722. */
  13723. onSizeChanged: (postProcess: PostProcess) => void;
  13724. /**
  13725. * An event triggered when the postprocess applies its effect.
  13726. */
  13727. onApplyObservable: Observable<Effect>;
  13728. private _onApplyObserver;
  13729. /**
  13730. * A function that is added to the onApplyObservable
  13731. */
  13732. onApply: (effect: Effect) => void;
  13733. /**
  13734. * An event triggered before rendering the postprocess
  13735. */
  13736. onBeforeRenderObservable: Observable<Effect>;
  13737. private _onBeforeRenderObserver;
  13738. /**
  13739. * A function that is added to the onBeforeRenderObservable
  13740. */
  13741. onBeforeRender: (effect: Effect) => void;
  13742. /**
  13743. * An event triggered after rendering the postprocess
  13744. */
  13745. onAfterRenderObservable: Observable<Effect>;
  13746. private _onAfterRenderObserver;
  13747. /**
  13748. * A function that is added to the onAfterRenderObservable
  13749. */
  13750. onAfterRender: (efect: Effect) => void;
  13751. /**
  13752. * 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
  13753. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13754. */
  13755. inputTexture: InternalTexture;
  13756. /**
  13757. * Gets the camera which post process is applied to.
  13758. * @returns The camera the post process is applied to.
  13759. */
  13760. getCamera(): Camera;
  13761. /**
  13762. * Gets the texel size of the postprocess.
  13763. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13764. */
  13765. readonly texelSize: Vector2;
  13766. /**
  13767. * Creates a new instance PostProcess
  13768. * @param name The name of the PostProcess.
  13769. * @param fragmentUrl The url of the fragment shader to be used.
  13770. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13771. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13772. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13773. * @param camera The camera to apply the render pass to.
  13774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13775. * @param engine The engine which the post process will be applied. (default: current engine)
  13776. * @param reusable If the post process can be reused on the same frame. (default: false)
  13777. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13778. * @param textureType Type of textures used when performing the post process. (default: 0)
  13779. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13780. * @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
  13781. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13782. */
  13783. constructor(
  13784. /** Name of the PostProcess. */
  13785. 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);
  13786. /**
  13787. * Gets a string idenfifying the name of the class
  13788. * @returns "PostProcess" string
  13789. */
  13790. getClassName(): string;
  13791. /**
  13792. * Gets the engine which this post process belongs to.
  13793. * @returns The engine the post process was enabled with.
  13794. */
  13795. getEngine(): Engine;
  13796. /**
  13797. * The effect that is created when initializing the post process.
  13798. * @returns The created effect corrisponding the the postprocess.
  13799. */
  13800. getEffect(): Effect;
  13801. /**
  13802. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13803. * @param postProcess The post process to share the output with.
  13804. * @returns This post process.
  13805. */
  13806. shareOutputWith(postProcess: PostProcess): PostProcess;
  13807. /**
  13808. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13809. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13810. */
  13811. useOwnOutput(): void;
  13812. /**
  13813. * Updates the effect with the current post process compile time values and recompiles the shader.
  13814. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13815. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13816. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13817. * @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
  13818. * @param onCompiled Called when the shader has been compiled.
  13819. * @param onError Called if there is an error when compiling a shader.
  13820. */
  13821. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13822. /**
  13823. * The post process is reusable if it can be used multiple times within one frame.
  13824. * @returns If the post process is reusable
  13825. */
  13826. isReusable(): boolean;
  13827. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13828. markTextureDirty(): void;
  13829. /**
  13830. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13831. * 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.
  13832. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13833. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13834. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13835. * @returns The target texture that was bound to be written to.
  13836. */
  13837. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13838. /**
  13839. * If the post process is supported.
  13840. */
  13841. readonly isSupported: boolean;
  13842. /**
  13843. * The aspect ratio of the output texture.
  13844. */
  13845. readonly aspectRatio: number;
  13846. /**
  13847. * Get a value indicating if the post-process is ready to be used
  13848. * @returns true if the post-process is ready (shader is compiled)
  13849. */
  13850. isReady(): boolean;
  13851. /**
  13852. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13853. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13854. */
  13855. apply(): Nullable<Effect>;
  13856. private _disposeTextures;
  13857. /**
  13858. * Disposes the post process.
  13859. * @param camera The camera to dispose the post process on.
  13860. */
  13861. dispose(camera?: Camera): void;
  13862. }
  13863. }
  13864. declare module BABYLON {
  13865. /**
  13866. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13867. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13868. */
  13869. export class PostProcessManager {
  13870. private _scene;
  13871. private _indexBuffer;
  13872. private _vertexBuffers;
  13873. /**
  13874. * Creates a new instance PostProcess
  13875. * @param scene The scene that the post process is associated with.
  13876. */
  13877. constructor(scene: Scene);
  13878. private _prepareBuffers;
  13879. private _buildIndexBuffer;
  13880. /**
  13881. * Rebuilds the vertex buffers of the manager.
  13882. * @hidden
  13883. */
  13884. _rebuild(): void;
  13885. /**
  13886. * Prepares a frame to be run through a post process.
  13887. * @param sourceTexture The input texture to the post procesess. (default: null)
  13888. * @param postProcesses An array of post processes to be run. (default: null)
  13889. * @returns True if the post processes were able to be run.
  13890. * @hidden
  13891. */
  13892. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13893. /**
  13894. * Manually render a set of post processes to a texture.
  13895. * @param postProcesses An array of post processes to be run.
  13896. * @param targetTexture The target texture to render to.
  13897. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13898. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13899. * @param lodLevel defines which lod of the texture to render to
  13900. */
  13901. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13902. /**
  13903. * Finalize the result of the output of the postprocesses.
  13904. * @param doNotPresent If true the result will not be displayed to the screen.
  13905. * @param targetTexture The target texture to render to.
  13906. * @param faceIndex The index of the face to bind the target texture to.
  13907. * @param postProcesses The array of post processes to render.
  13908. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13909. * @hidden
  13910. */
  13911. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13912. /**
  13913. * Disposes of the post process manager.
  13914. */
  13915. dispose(): void;
  13916. }
  13917. }
  13918. declare module BABYLON {
  13919. interface AbstractScene {
  13920. /**
  13921. * The list of layers (background and foreground) of the scene
  13922. */
  13923. layers: Array<Layer>;
  13924. }
  13925. /**
  13926. * Defines the layer scene component responsible to manage any layers
  13927. * in a given scene.
  13928. */
  13929. export class LayerSceneComponent implements ISceneComponent {
  13930. /**
  13931. * The component name helpfull to identify the component in the list of scene components.
  13932. */
  13933. readonly name: string;
  13934. /**
  13935. * The scene the component belongs to.
  13936. */
  13937. scene: Scene;
  13938. private _engine;
  13939. /**
  13940. * Creates a new instance of the component for the given scene
  13941. * @param scene Defines the scene to register the component in
  13942. */
  13943. constructor(scene: Scene);
  13944. /**
  13945. * Registers the component in a given scene
  13946. */
  13947. register(): void;
  13948. /**
  13949. * Rebuilds the elements related to this component in case of
  13950. * context lost for instance.
  13951. */
  13952. rebuild(): void;
  13953. /**
  13954. * Disposes the component and the associated ressources.
  13955. */
  13956. dispose(): void;
  13957. private _draw;
  13958. private _drawCameraPredicate;
  13959. private _drawCameraBackground;
  13960. private _drawCameraForeground;
  13961. private _drawRenderTargetPredicate;
  13962. private _drawRenderTargetBackground;
  13963. private _drawRenderTargetForeground;
  13964. }
  13965. }
  13966. declare module BABYLON {
  13967. /** @hidden */
  13968. export var layerPixelShader: {
  13969. name: string;
  13970. shader: string;
  13971. };
  13972. }
  13973. declare module BABYLON {
  13974. /** @hidden */
  13975. export var layerVertexShader: {
  13976. name: string;
  13977. shader: string;
  13978. };
  13979. }
  13980. declare module BABYLON {
  13981. /**
  13982. * This represents a full screen 2d layer.
  13983. * This can be useful to display a picture in the background of your scene for instance.
  13984. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13985. */
  13986. export class Layer {
  13987. /**
  13988. * Define the name of the layer.
  13989. */
  13990. name: string;
  13991. /**
  13992. * Define the texture the layer should display.
  13993. */
  13994. texture: Nullable<Texture>;
  13995. /**
  13996. * Is the layer in background or foreground.
  13997. */
  13998. isBackground: boolean;
  13999. /**
  14000. * Define the color of the layer (instead of texture).
  14001. */
  14002. color: Color4;
  14003. /**
  14004. * Define the scale of the layer in order to zoom in out of the texture.
  14005. */
  14006. scale: Vector2;
  14007. /**
  14008. * Define an offset for the layer in order to shift the texture.
  14009. */
  14010. offset: Vector2;
  14011. /**
  14012. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14013. */
  14014. alphaBlendingMode: number;
  14015. /**
  14016. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14017. * Alpha test will not mix with the background color in case of transparency.
  14018. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14019. */
  14020. alphaTest: boolean;
  14021. /**
  14022. * Define a mask to restrict the layer to only some of the scene cameras.
  14023. */
  14024. layerMask: number;
  14025. /**
  14026. * Define the list of render target the layer is visible into.
  14027. */
  14028. renderTargetTextures: RenderTargetTexture[];
  14029. /**
  14030. * Define if the layer is only used in renderTarget or if it also
  14031. * renders in the main frame buffer of the canvas.
  14032. */
  14033. renderOnlyInRenderTargetTextures: boolean;
  14034. private _scene;
  14035. private _vertexBuffers;
  14036. private _indexBuffer;
  14037. private _effect;
  14038. private _alphaTestEffect;
  14039. /**
  14040. * An event triggered when the layer is disposed.
  14041. */
  14042. onDisposeObservable: Observable<Layer>;
  14043. private _onDisposeObserver;
  14044. /**
  14045. * Back compatibility with callback before the onDisposeObservable existed.
  14046. * The set callback will be triggered when the layer has been disposed.
  14047. */
  14048. onDispose: () => void;
  14049. /**
  14050. * An event triggered before rendering the scene
  14051. */
  14052. onBeforeRenderObservable: Observable<Layer>;
  14053. private _onBeforeRenderObserver;
  14054. /**
  14055. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14056. * The set callback will be triggered just before rendering the layer.
  14057. */
  14058. onBeforeRender: () => void;
  14059. /**
  14060. * An event triggered after rendering the scene
  14061. */
  14062. onAfterRenderObservable: Observable<Layer>;
  14063. private _onAfterRenderObserver;
  14064. /**
  14065. * Back compatibility with callback before the onAfterRenderObservable existed.
  14066. * The set callback will be triggered just after rendering the layer.
  14067. */
  14068. onAfterRender: () => void;
  14069. /**
  14070. * Instantiates a new layer.
  14071. * This represents a full screen 2d layer.
  14072. * This can be useful to display a picture in the background of your scene for instance.
  14073. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14074. * @param name Define the name of the layer in the scene
  14075. * @param imgUrl Define the url of the texture to display in the layer
  14076. * @param scene Define the scene the layer belongs to
  14077. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14078. * @param color Defines a color for the layer
  14079. */
  14080. constructor(
  14081. /**
  14082. * Define the name of the layer.
  14083. */
  14084. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14085. private _createIndexBuffer;
  14086. /** @hidden */
  14087. _rebuild(): void;
  14088. /**
  14089. * Renders the layer in the scene.
  14090. */
  14091. render(): void;
  14092. /**
  14093. * Disposes and releases the associated ressources.
  14094. */
  14095. dispose(): void;
  14096. }
  14097. }
  14098. declare module BABYLON {
  14099. interface AbstractScene {
  14100. /**
  14101. * The list of procedural textures added to the scene
  14102. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14103. */
  14104. proceduralTextures: Array<ProceduralTexture>;
  14105. }
  14106. /**
  14107. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14108. * in a given scene.
  14109. */
  14110. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14111. /**
  14112. * The component name helpfull to identify the component in the list of scene components.
  14113. */
  14114. readonly name: string;
  14115. /**
  14116. * The scene the component belongs to.
  14117. */
  14118. scene: Scene;
  14119. /**
  14120. * Creates a new instance of the component for the given scene
  14121. * @param scene Defines the scene to register the component in
  14122. */
  14123. constructor(scene: Scene);
  14124. /**
  14125. * Registers the component in a given scene
  14126. */
  14127. register(): void;
  14128. /**
  14129. * Rebuilds the elements related to this component in case of
  14130. * context lost for instance.
  14131. */
  14132. rebuild(): void;
  14133. /**
  14134. * Disposes the component and the associated ressources.
  14135. */
  14136. dispose(): void;
  14137. private _beforeClear;
  14138. }
  14139. }
  14140. declare module BABYLON {
  14141. interface Engine {
  14142. /**
  14143. * Creates a new render target cube texture
  14144. * @param size defines the size of the texture
  14145. * @param options defines the options used to create the texture
  14146. * @returns a new render target cube texture stored in an InternalTexture
  14147. */
  14148. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14149. }
  14150. }
  14151. declare module BABYLON {
  14152. /** @hidden */
  14153. export var proceduralVertexShader: {
  14154. name: string;
  14155. shader: string;
  14156. };
  14157. }
  14158. declare module BABYLON {
  14159. /**
  14160. * 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.
  14161. * This is the base class of any Procedural texture and contains most of the shareable code.
  14162. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14163. */
  14164. export class ProceduralTexture extends Texture {
  14165. isCube: boolean;
  14166. /**
  14167. * Define if the texture is enabled or not (disabled texture will not render)
  14168. */
  14169. isEnabled: boolean;
  14170. /**
  14171. * Define if the texture must be cleared before rendering (default is true)
  14172. */
  14173. autoClear: boolean;
  14174. /**
  14175. * Callback called when the texture is generated
  14176. */
  14177. onGenerated: () => void;
  14178. /**
  14179. * Event raised when the texture is generated
  14180. */
  14181. onGeneratedObservable: Observable<ProceduralTexture>;
  14182. /** @hidden */
  14183. _generateMipMaps: boolean;
  14184. /** @hidden **/
  14185. _effect: Effect;
  14186. /** @hidden */
  14187. _textures: {
  14188. [key: string]: Texture;
  14189. };
  14190. private _size;
  14191. private _currentRefreshId;
  14192. private _refreshRate;
  14193. private _vertexBuffers;
  14194. private _indexBuffer;
  14195. private _uniforms;
  14196. private _samplers;
  14197. private _fragment;
  14198. private _floats;
  14199. private _ints;
  14200. private _floatsArrays;
  14201. private _colors3;
  14202. private _colors4;
  14203. private _vectors2;
  14204. private _vectors3;
  14205. private _matrices;
  14206. private _fallbackTexture;
  14207. private _fallbackTextureUsed;
  14208. private _engine;
  14209. private _cachedDefines;
  14210. private _contentUpdateId;
  14211. private _contentData;
  14212. /**
  14213. * Instantiates a new procedural texture.
  14214. * 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.
  14215. * This is the base class of any Procedural texture and contains most of the shareable code.
  14216. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14217. * @param name Define the name of the texture
  14218. * @param size Define the size of the texture to create
  14219. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14220. * @param scene Define the scene the texture belongs to
  14221. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14222. * @param generateMipMaps Define if the texture should creates mip maps or not
  14223. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14224. */
  14225. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14226. /**
  14227. * The effect that is created when initializing the post process.
  14228. * @returns The created effect corrisponding the the postprocess.
  14229. */
  14230. getEffect(): Effect;
  14231. /**
  14232. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14233. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14234. */
  14235. getContent(): Nullable<ArrayBufferView>;
  14236. private _createIndexBuffer;
  14237. /** @hidden */
  14238. _rebuild(): void;
  14239. /**
  14240. * Resets the texture in order to recreate its associated resources.
  14241. * This can be called in case of context loss
  14242. */
  14243. reset(): void;
  14244. protected _getDefines(): string;
  14245. /**
  14246. * Is the texture ready to be used ? (rendered at least once)
  14247. * @returns true if ready, otherwise, false.
  14248. */
  14249. isReady(): boolean;
  14250. /**
  14251. * Resets the refresh counter of the texture and start bak from scratch.
  14252. * Could be useful to regenerate the texture if it is setup to render only once.
  14253. */
  14254. resetRefreshCounter(): void;
  14255. /**
  14256. * Set the fragment shader to use in order to render the texture.
  14257. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14258. */
  14259. setFragment(fragment: any): void;
  14260. /**
  14261. * Define the refresh rate of the texture or the rendering frequency.
  14262. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14263. */
  14264. refreshRate: number;
  14265. /** @hidden */
  14266. _shouldRender(): boolean;
  14267. /**
  14268. * Get the size the texture is rendering at.
  14269. * @returns the size (texture is always squared)
  14270. */
  14271. getRenderSize(): number;
  14272. /**
  14273. * Resize the texture to new value.
  14274. * @param size Define the new size the texture should have
  14275. * @param generateMipMaps Define whether the new texture should create mip maps
  14276. */
  14277. resize(size: number, generateMipMaps: boolean): void;
  14278. private _checkUniform;
  14279. /**
  14280. * Set a texture in the shader program used to render.
  14281. * @param name Define the name of the uniform samplers as defined in the shader
  14282. * @param texture Define the texture to bind to this sampler
  14283. * @return the texture itself allowing "fluent" like uniform updates
  14284. */
  14285. setTexture(name: string, texture: Texture): ProceduralTexture;
  14286. /**
  14287. * Set a float in the shader.
  14288. * @param name Define the name of the uniform as defined in the shader
  14289. * @param value Define the value to give to the uniform
  14290. * @return the texture itself allowing "fluent" like uniform updates
  14291. */
  14292. setFloat(name: string, value: number): ProceduralTexture;
  14293. /**
  14294. * Set a int in the shader.
  14295. * @param name Define the name of the uniform as defined in the shader
  14296. * @param value Define the value to give to the uniform
  14297. * @return the texture itself allowing "fluent" like uniform updates
  14298. */
  14299. setInt(name: string, value: number): ProceduralTexture;
  14300. /**
  14301. * Set an array of floats in the shader.
  14302. * @param name Define the name of the uniform as defined in the shader
  14303. * @param value Define the value to give to the uniform
  14304. * @return the texture itself allowing "fluent" like uniform updates
  14305. */
  14306. setFloats(name: string, value: number[]): ProceduralTexture;
  14307. /**
  14308. * Set a vec3 in the shader from a Color3.
  14309. * @param name Define the name of the uniform as defined in the shader
  14310. * @param value Define the value to give to the uniform
  14311. * @return the texture itself allowing "fluent" like uniform updates
  14312. */
  14313. setColor3(name: string, value: Color3): ProceduralTexture;
  14314. /**
  14315. * Set a vec4 in the shader from a Color4.
  14316. * @param name Define the name of the uniform as defined in the shader
  14317. * @param value Define the value to give to the uniform
  14318. * @return the texture itself allowing "fluent" like uniform updates
  14319. */
  14320. setColor4(name: string, value: Color4): ProceduralTexture;
  14321. /**
  14322. * Set a vec2 in the shader from a Vector2.
  14323. * @param name Define the name of the uniform as defined in the shader
  14324. * @param value Define the value to give to the uniform
  14325. * @return the texture itself allowing "fluent" like uniform updates
  14326. */
  14327. setVector2(name: string, value: Vector2): ProceduralTexture;
  14328. /**
  14329. * Set a vec3 in the shader from a Vector3.
  14330. * @param name Define the name of the uniform as defined in the shader
  14331. * @param value Define the value to give to the uniform
  14332. * @return the texture itself allowing "fluent" like uniform updates
  14333. */
  14334. setVector3(name: string, value: Vector3): ProceduralTexture;
  14335. /**
  14336. * Set a mat4 in the shader from a MAtrix.
  14337. * @param name Define the name of the uniform as defined in the shader
  14338. * @param value Define the value to give to the uniform
  14339. * @return the texture itself allowing "fluent" like uniform updates
  14340. */
  14341. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14342. /**
  14343. * Render the texture to its associated render target.
  14344. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14345. */
  14346. render(useCameraPostProcess?: boolean): void;
  14347. /**
  14348. * Clone the texture.
  14349. * @returns the cloned texture
  14350. */
  14351. clone(): ProceduralTexture;
  14352. /**
  14353. * Dispose the texture and release its asoociated resources.
  14354. */
  14355. dispose(): void;
  14356. }
  14357. }
  14358. declare module BABYLON {
  14359. /**
  14360. * This represents the base class for particle system in Babylon.
  14361. * 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.
  14362. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14363. * @example https://doc.babylonjs.com/babylon101/particles
  14364. */
  14365. export class BaseParticleSystem {
  14366. /**
  14367. * Source color is added to the destination color without alpha affecting the result
  14368. */
  14369. static BLENDMODE_ONEONE: number;
  14370. /**
  14371. * Blend current color and particle color using particle’s alpha
  14372. */
  14373. static BLENDMODE_STANDARD: number;
  14374. /**
  14375. * Add current color and particle color multiplied by particle’s alpha
  14376. */
  14377. static BLENDMODE_ADD: number;
  14378. /**
  14379. * Multiply current color with particle color
  14380. */
  14381. static BLENDMODE_MULTIPLY: number;
  14382. /**
  14383. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14384. */
  14385. static BLENDMODE_MULTIPLYADD: number;
  14386. /**
  14387. * List of animations used by the particle system.
  14388. */
  14389. animations: Animation[];
  14390. /**
  14391. * The id of the Particle system.
  14392. */
  14393. id: string;
  14394. /**
  14395. * The friendly name of the Particle system.
  14396. */
  14397. name: string;
  14398. /**
  14399. * The rendering group used by the Particle system to chose when to render.
  14400. */
  14401. renderingGroupId: number;
  14402. /**
  14403. * The emitter represents the Mesh or position we are attaching the particle system to.
  14404. */
  14405. emitter: Nullable<AbstractMesh | Vector3>;
  14406. /**
  14407. * The maximum number of particles to emit per frame
  14408. */
  14409. emitRate: number;
  14410. /**
  14411. * If you want to launch only a few particles at once, that can be done, as well.
  14412. */
  14413. manualEmitCount: number;
  14414. /**
  14415. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14416. */
  14417. updateSpeed: number;
  14418. /**
  14419. * The amount of time the particle system is running (depends of the overall update speed).
  14420. */
  14421. targetStopDuration: number;
  14422. /**
  14423. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14424. */
  14425. disposeOnStop: boolean;
  14426. /**
  14427. * Minimum power of emitting particles.
  14428. */
  14429. minEmitPower: number;
  14430. /**
  14431. * Maximum power of emitting particles.
  14432. */
  14433. maxEmitPower: number;
  14434. /**
  14435. * Minimum life time of emitting particles.
  14436. */
  14437. minLifeTime: number;
  14438. /**
  14439. * Maximum life time of emitting particles.
  14440. */
  14441. maxLifeTime: number;
  14442. /**
  14443. * Minimum Size of emitting particles.
  14444. */
  14445. minSize: number;
  14446. /**
  14447. * Maximum Size of emitting particles.
  14448. */
  14449. maxSize: number;
  14450. /**
  14451. * Minimum scale of emitting particles on X axis.
  14452. */
  14453. minScaleX: number;
  14454. /**
  14455. * Maximum scale of emitting particles on X axis.
  14456. */
  14457. maxScaleX: number;
  14458. /**
  14459. * Minimum scale of emitting particles on Y axis.
  14460. */
  14461. minScaleY: number;
  14462. /**
  14463. * Maximum scale of emitting particles on Y axis.
  14464. */
  14465. maxScaleY: number;
  14466. /**
  14467. * Gets or sets the minimal initial rotation in radians.
  14468. */
  14469. minInitialRotation: number;
  14470. /**
  14471. * Gets or sets the maximal initial rotation in radians.
  14472. */
  14473. maxInitialRotation: number;
  14474. /**
  14475. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14476. */
  14477. minAngularSpeed: number;
  14478. /**
  14479. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14480. */
  14481. maxAngularSpeed: number;
  14482. /**
  14483. * The texture used to render each particle. (this can be a spritesheet)
  14484. */
  14485. particleTexture: Nullable<Texture>;
  14486. /**
  14487. * The layer mask we are rendering the particles through.
  14488. */
  14489. layerMask: number;
  14490. /**
  14491. * This can help using your own shader to render the particle system.
  14492. * The according effect will be created
  14493. */
  14494. customShader: any;
  14495. /**
  14496. * By default particle system starts as soon as they are created. This prevents the
  14497. * automatic start to happen and let you decide when to start emitting particles.
  14498. */
  14499. preventAutoStart: boolean;
  14500. private _noiseTexture;
  14501. /**
  14502. * Gets or sets a texture used to add random noise to particle positions
  14503. */
  14504. noiseTexture: Nullable<ProceduralTexture>;
  14505. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14506. noiseStrength: Vector3;
  14507. /**
  14508. * Callback triggered when the particle animation is ending.
  14509. */
  14510. onAnimationEnd: Nullable<() => void>;
  14511. /**
  14512. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14513. */
  14514. blendMode: number;
  14515. /**
  14516. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14517. * to override the particles.
  14518. */
  14519. forceDepthWrite: boolean;
  14520. /** 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 */
  14521. preWarmCycles: number;
  14522. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14523. preWarmStepOffset: number;
  14524. /**
  14525. * 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)
  14526. */
  14527. spriteCellChangeSpeed: number;
  14528. /**
  14529. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14530. */
  14531. startSpriteCellID: number;
  14532. /**
  14533. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14534. */
  14535. endSpriteCellID: number;
  14536. /**
  14537. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14538. */
  14539. spriteCellWidth: number;
  14540. /**
  14541. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14542. */
  14543. spriteCellHeight: number;
  14544. /**
  14545. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14546. */
  14547. spriteRandomStartCell: boolean;
  14548. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14549. translationPivot: Vector2;
  14550. /** @hidden */
  14551. protected _isAnimationSheetEnabled: boolean;
  14552. /**
  14553. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14554. */
  14555. beginAnimationOnStart: boolean;
  14556. /**
  14557. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14558. */
  14559. beginAnimationFrom: number;
  14560. /**
  14561. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14562. */
  14563. beginAnimationTo: number;
  14564. /**
  14565. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14566. */
  14567. beginAnimationLoop: boolean;
  14568. /**
  14569. * Gets or sets a world offset applied to all particles
  14570. */
  14571. worldOffset: Vector3;
  14572. /**
  14573. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14574. */
  14575. isAnimationSheetEnabled: boolean;
  14576. /**
  14577. * Get hosting scene
  14578. * @returns the scene
  14579. */
  14580. getScene(): Scene;
  14581. /**
  14582. * You can use gravity if you want to give an orientation to your particles.
  14583. */
  14584. gravity: Vector3;
  14585. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14586. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14587. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14588. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14589. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14590. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14591. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14592. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14593. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14594. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14595. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14596. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14597. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14598. /**
  14599. * Defines the delay in milliseconds before starting the system (0 by default)
  14600. */
  14601. startDelay: number;
  14602. /**
  14603. * Gets the current list of drag gradients.
  14604. * You must use addDragGradient and removeDragGradient to udpate this list
  14605. * @returns the list of drag gradients
  14606. */
  14607. getDragGradients(): Nullable<Array<FactorGradient>>;
  14608. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14609. limitVelocityDamping: number;
  14610. /**
  14611. * Gets the current list of limit velocity gradients.
  14612. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14613. * @returns the list of limit velocity gradients
  14614. */
  14615. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14616. /**
  14617. * Gets the current list of color gradients.
  14618. * You must use addColorGradient and removeColorGradient to udpate this list
  14619. * @returns the list of color gradients
  14620. */
  14621. getColorGradients(): Nullable<Array<ColorGradient>>;
  14622. /**
  14623. * Gets the current list of size gradients.
  14624. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14625. * @returns the list of size gradients
  14626. */
  14627. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14628. /**
  14629. * Gets the current list of color remap gradients.
  14630. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14631. * @returns the list of color remap gradients
  14632. */
  14633. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14634. /**
  14635. * Gets the current list of alpha remap gradients.
  14636. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14637. * @returns the list of alpha remap gradients
  14638. */
  14639. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14640. /**
  14641. * Gets the current list of life time gradients.
  14642. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14643. * @returns the list of life time gradients
  14644. */
  14645. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14646. /**
  14647. * Gets the current list of angular speed gradients.
  14648. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14649. * @returns the list of angular speed gradients
  14650. */
  14651. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14652. /**
  14653. * Gets the current list of velocity gradients.
  14654. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14655. * @returns the list of velocity gradients
  14656. */
  14657. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14658. /**
  14659. * Gets the current list of start size gradients.
  14660. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14661. * @returns the list of start size gradients
  14662. */
  14663. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14664. /**
  14665. * Gets the current list of emit rate gradients.
  14666. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14667. * @returns the list of emit rate gradients
  14668. */
  14669. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14670. /**
  14671. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14672. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14673. */
  14674. direction1: Vector3;
  14675. /**
  14676. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14677. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14678. */
  14679. direction2: Vector3;
  14680. /**
  14681. * 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.
  14682. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14683. */
  14684. minEmitBox: Vector3;
  14685. /**
  14686. * 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.
  14687. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14688. */
  14689. maxEmitBox: Vector3;
  14690. /**
  14691. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14692. */
  14693. color1: Color4;
  14694. /**
  14695. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14696. */
  14697. color2: Color4;
  14698. /**
  14699. * Color the particle will have at the end of its lifetime
  14700. */
  14701. colorDead: Color4;
  14702. /**
  14703. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14704. */
  14705. textureMask: Color4;
  14706. /**
  14707. * The particle emitter type defines the emitter used by the particle system.
  14708. * It can be for example box, sphere, or cone...
  14709. */
  14710. particleEmitterType: IParticleEmitterType;
  14711. /** @hidden */
  14712. _isSubEmitter: boolean;
  14713. /**
  14714. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14715. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14716. */
  14717. billboardMode: number;
  14718. protected _isBillboardBased: boolean;
  14719. /**
  14720. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14721. */
  14722. isBillboardBased: boolean;
  14723. /**
  14724. * The scene the particle system belongs to.
  14725. */
  14726. protected _scene: Scene;
  14727. /**
  14728. * Local cache of defines for image processing.
  14729. */
  14730. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14731. /**
  14732. * Default configuration related to image processing available in the standard Material.
  14733. */
  14734. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14735. /**
  14736. * Gets the image processing configuration used either in this material.
  14737. */
  14738. /**
  14739. * Sets the Default image processing configuration used either in the this material.
  14740. *
  14741. * If sets to null, the scene one is in use.
  14742. */
  14743. imageProcessingConfiguration: ImageProcessingConfiguration;
  14744. /**
  14745. * Attaches a new image processing configuration to the Standard Material.
  14746. * @param configuration
  14747. */
  14748. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14749. /** @hidden */
  14750. protected _reset(): void;
  14751. /** @hidden */
  14752. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14753. /**
  14754. * Instantiates a particle system.
  14755. * 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.
  14756. * @param name The name of the particle system
  14757. */
  14758. constructor(name: string);
  14759. /**
  14760. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14761. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14762. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14763. * @returns the emitter
  14764. */
  14765. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14766. /**
  14767. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14768. * @param radius The radius of the hemisphere to emit from
  14769. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14770. * @returns the emitter
  14771. */
  14772. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14773. /**
  14774. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14775. * @param radius The radius of the sphere to emit from
  14776. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14777. * @returns the emitter
  14778. */
  14779. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14780. /**
  14781. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14782. * @param radius The radius of the sphere to emit from
  14783. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14784. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14785. * @returns the emitter
  14786. */
  14787. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14788. /**
  14789. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14790. * @param radius The radius of the emission cylinder
  14791. * @param height The height of the emission cylinder
  14792. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14793. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14794. * @returns the emitter
  14795. */
  14796. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14797. /**
  14798. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14799. * @param radius The radius of the cylinder to emit from
  14800. * @param height The height of the emission cylinder
  14801. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14802. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14803. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14804. * @returns the emitter
  14805. */
  14806. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14807. /**
  14808. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14809. * @param radius The radius of the cone to emit from
  14810. * @param angle The base angle of the cone
  14811. * @returns the emitter
  14812. */
  14813. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14814. /**
  14815. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14816. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14817. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14818. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14819. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14820. * @returns the emitter
  14821. */
  14822. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14823. }
  14824. }
  14825. declare module BABYLON {
  14826. /**
  14827. * Type of sub emitter
  14828. */
  14829. export enum SubEmitterType {
  14830. /**
  14831. * Attached to the particle over it's lifetime
  14832. */
  14833. ATTACHED = 0,
  14834. /**
  14835. * Created when the particle dies
  14836. */
  14837. END = 1
  14838. }
  14839. /**
  14840. * Sub emitter class used to emit particles from an existing particle
  14841. */
  14842. export class SubEmitter {
  14843. /**
  14844. * the particle system to be used by the sub emitter
  14845. */
  14846. particleSystem: ParticleSystem;
  14847. /**
  14848. * Type of the submitter (Default: END)
  14849. */
  14850. type: SubEmitterType;
  14851. /**
  14852. * 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)
  14853. * Note: This only is supported when using an emitter of type Mesh
  14854. */
  14855. inheritDirection: boolean;
  14856. /**
  14857. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14858. */
  14859. inheritedVelocityAmount: number;
  14860. /**
  14861. * Creates a sub emitter
  14862. * @param particleSystem the particle system to be used by the sub emitter
  14863. */
  14864. constructor(
  14865. /**
  14866. * the particle system to be used by the sub emitter
  14867. */
  14868. particleSystem: ParticleSystem);
  14869. /**
  14870. * Clones the sub emitter
  14871. * @returns the cloned sub emitter
  14872. */
  14873. clone(): SubEmitter;
  14874. /**
  14875. * Serialize current object to a JSON object
  14876. * @returns the serialized object
  14877. */
  14878. serialize(): any;
  14879. /** @hidden */
  14880. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14881. /**
  14882. * Creates a new SubEmitter from a serialized JSON version
  14883. * @param serializationObject defines the JSON object to read from
  14884. * @param scene defines the hosting scene
  14885. * @param rootUrl defines the rootUrl for data loading
  14886. * @returns a new SubEmitter
  14887. */
  14888. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14889. /** Release associated resources */
  14890. dispose(): void;
  14891. }
  14892. }
  14893. declare module BABYLON {
  14894. /** @hidden */
  14895. export var clipPlaneFragmentDeclaration: {
  14896. name: string;
  14897. shader: string;
  14898. };
  14899. }
  14900. declare module BABYLON {
  14901. /** @hidden */
  14902. export var imageProcessingDeclaration: {
  14903. name: string;
  14904. shader: string;
  14905. };
  14906. }
  14907. declare module BABYLON {
  14908. /** @hidden */
  14909. export var imageProcessingFunctions: {
  14910. name: string;
  14911. shader: string;
  14912. };
  14913. }
  14914. declare module BABYLON {
  14915. /** @hidden */
  14916. export var clipPlaneFragment: {
  14917. name: string;
  14918. shader: string;
  14919. };
  14920. }
  14921. declare module BABYLON {
  14922. /** @hidden */
  14923. export var particlesPixelShader: {
  14924. name: string;
  14925. shader: string;
  14926. };
  14927. }
  14928. declare module BABYLON {
  14929. /** @hidden */
  14930. export var clipPlaneVertexDeclaration: {
  14931. name: string;
  14932. shader: string;
  14933. };
  14934. }
  14935. declare module BABYLON {
  14936. /** @hidden */
  14937. export var clipPlaneVertex: {
  14938. name: string;
  14939. shader: string;
  14940. };
  14941. }
  14942. declare module BABYLON {
  14943. /** @hidden */
  14944. export var particlesVertexShader: {
  14945. name: string;
  14946. shader: string;
  14947. };
  14948. }
  14949. declare module BABYLON {
  14950. /**
  14951. * This represents a particle system in Babylon.
  14952. * 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.
  14953. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14954. * @example https://doc.babylonjs.com/babylon101/particles
  14955. */
  14956. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14957. /**
  14958. * Billboard mode will only apply to Y axis
  14959. */
  14960. static readonly BILLBOARDMODE_Y: number;
  14961. /**
  14962. * Billboard mode will apply to all axes
  14963. */
  14964. static readonly BILLBOARDMODE_ALL: number;
  14965. /**
  14966. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14967. */
  14968. static readonly BILLBOARDMODE_STRETCHED: number;
  14969. /**
  14970. * This function can be defined to provide custom update for active particles.
  14971. * This function will be called instead of regular update (age, position, color, etc.).
  14972. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14973. */
  14974. updateFunction: (particles: Particle[]) => void;
  14975. private _emitterWorldMatrix;
  14976. /**
  14977. * This function can be defined to specify initial direction for every new particle.
  14978. * It by default use the emitterType defined function
  14979. */
  14980. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14981. /**
  14982. * This function can be defined to specify initial position for every new particle.
  14983. * It by default use the emitterType defined function
  14984. */
  14985. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14986. /**
  14987. * @hidden
  14988. */
  14989. _inheritedVelocityOffset: Vector3;
  14990. /**
  14991. * An event triggered when the system is disposed
  14992. */
  14993. onDisposeObservable: Observable<ParticleSystem>;
  14994. private _onDisposeObserver;
  14995. /**
  14996. * Sets a callback that will be triggered when the system is disposed
  14997. */
  14998. onDispose: () => void;
  14999. private _particles;
  15000. private _epsilon;
  15001. private _capacity;
  15002. private _stockParticles;
  15003. private _newPartsExcess;
  15004. private _vertexData;
  15005. private _vertexBuffer;
  15006. private _vertexBuffers;
  15007. private _spriteBuffer;
  15008. private _indexBuffer;
  15009. private _effect;
  15010. private _customEffect;
  15011. private _cachedDefines;
  15012. private _scaledColorStep;
  15013. private _colorDiff;
  15014. private _scaledDirection;
  15015. private _scaledGravity;
  15016. private _currentRenderId;
  15017. private _alive;
  15018. private _useInstancing;
  15019. private _started;
  15020. private _stopped;
  15021. private _actualFrame;
  15022. private _scaledUpdateSpeed;
  15023. private _vertexBufferSize;
  15024. /** @hidden */
  15025. _currentEmitRateGradient: Nullable<FactorGradient>;
  15026. /** @hidden */
  15027. _currentEmitRate1: number;
  15028. /** @hidden */
  15029. _currentEmitRate2: number;
  15030. /** @hidden */
  15031. _currentStartSizeGradient: Nullable<FactorGradient>;
  15032. /** @hidden */
  15033. _currentStartSize1: number;
  15034. /** @hidden */
  15035. _currentStartSize2: number;
  15036. private readonly _rawTextureWidth;
  15037. private _rampGradientsTexture;
  15038. private _useRampGradients;
  15039. /** Gets or sets a boolean indicating that ramp gradients must be used
  15040. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15041. */
  15042. useRampGradients: boolean;
  15043. /**
  15044. * 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.
  15045. * 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: [])
  15046. */
  15047. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15048. private _subEmitters;
  15049. /**
  15050. * @hidden
  15051. * If the particle systems emitter should be disposed when the particle system is disposed
  15052. */
  15053. _disposeEmitterOnDispose: boolean;
  15054. /**
  15055. * The current active Sub-systems, this property is used by the root particle system only.
  15056. */
  15057. activeSubSystems: Array<ParticleSystem>;
  15058. private _rootParticleSystem;
  15059. /**
  15060. * Gets the current list of active particles
  15061. */
  15062. readonly particles: Particle[];
  15063. /**
  15064. * Returns the string "ParticleSystem"
  15065. * @returns a string containing the class name
  15066. */
  15067. getClassName(): string;
  15068. /**
  15069. * Instantiates a particle system.
  15070. * 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.
  15071. * @param name The name of the particle system
  15072. * @param capacity The max number of particles alive at the same time
  15073. * @param scene The scene the particle system belongs to
  15074. * @param customEffect a custom effect used to change the way particles are rendered by default
  15075. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15076. * @param epsilon Offset used to render the particles
  15077. */
  15078. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15079. private _addFactorGradient;
  15080. private _removeFactorGradient;
  15081. /**
  15082. * Adds a new life time gradient
  15083. * @param gradient defines the gradient to use (between 0 and 1)
  15084. * @param factor defines the life time factor to affect to the specified gradient
  15085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15086. * @returns the current particle system
  15087. */
  15088. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15089. /**
  15090. * Remove a specific life time gradient
  15091. * @param gradient defines the gradient to remove
  15092. * @returns the current particle system
  15093. */
  15094. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15095. /**
  15096. * Adds a new size gradient
  15097. * @param gradient defines the gradient to use (between 0 and 1)
  15098. * @param factor defines the size factor to affect to the specified gradient
  15099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15100. * @returns the current particle system
  15101. */
  15102. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15103. /**
  15104. * Remove a specific size gradient
  15105. * @param gradient defines the gradient to remove
  15106. * @returns the current particle system
  15107. */
  15108. removeSizeGradient(gradient: number): IParticleSystem;
  15109. /**
  15110. * Adds a new color remap gradient
  15111. * @param gradient defines the gradient to use (between 0 and 1)
  15112. * @param min defines the color remap minimal range
  15113. * @param max defines the color remap maximal range
  15114. * @returns the current particle system
  15115. */
  15116. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15117. /**
  15118. * Remove a specific color remap gradient
  15119. * @param gradient defines the gradient to remove
  15120. * @returns the current particle system
  15121. */
  15122. removeColorRemapGradient(gradient: number): IParticleSystem;
  15123. /**
  15124. * Adds a new alpha remap gradient
  15125. * @param gradient defines the gradient to use (between 0 and 1)
  15126. * @param min defines the alpha remap minimal range
  15127. * @param max defines the alpha remap maximal range
  15128. * @returns the current particle system
  15129. */
  15130. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15131. /**
  15132. * Remove a specific alpha remap gradient
  15133. * @param gradient defines the gradient to remove
  15134. * @returns the current particle system
  15135. */
  15136. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15137. /**
  15138. * Adds a new angular speed gradient
  15139. * @param gradient defines the gradient to use (between 0 and 1)
  15140. * @param factor defines the angular speed to affect to the specified gradient
  15141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15142. * @returns the current particle system
  15143. */
  15144. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15145. /**
  15146. * Remove a specific angular speed gradient
  15147. * @param gradient defines the gradient to remove
  15148. * @returns the current particle system
  15149. */
  15150. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15151. /**
  15152. * Adds a new velocity gradient
  15153. * @param gradient defines the gradient to use (between 0 and 1)
  15154. * @param factor defines the velocity to affect to the specified gradient
  15155. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15156. * @returns the current particle system
  15157. */
  15158. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15159. /**
  15160. * Remove a specific velocity gradient
  15161. * @param gradient defines the gradient to remove
  15162. * @returns the current particle system
  15163. */
  15164. removeVelocityGradient(gradient: number): IParticleSystem;
  15165. /**
  15166. * Adds a new limit velocity gradient
  15167. * @param gradient defines the gradient to use (between 0 and 1)
  15168. * @param factor defines the limit velocity value to affect to the specified gradient
  15169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15170. * @returns the current particle system
  15171. */
  15172. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15173. /**
  15174. * Remove a specific limit velocity gradient
  15175. * @param gradient defines the gradient to remove
  15176. * @returns the current particle system
  15177. */
  15178. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15179. /**
  15180. * Adds a new drag gradient
  15181. * @param gradient defines the gradient to use (between 0 and 1)
  15182. * @param factor defines the drag value to affect to the specified gradient
  15183. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15184. * @returns the current particle system
  15185. */
  15186. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15187. /**
  15188. * Remove a specific drag gradient
  15189. * @param gradient defines the gradient to remove
  15190. * @returns the current particle system
  15191. */
  15192. removeDragGradient(gradient: number): IParticleSystem;
  15193. /**
  15194. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15195. * @param gradient defines the gradient to use (between 0 and 1)
  15196. * @param factor defines the emit rate value to affect to the specified gradient
  15197. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15198. * @returns the current particle system
  15199. */
  15200. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15201. /**
  15202. * Remove a specific emit rate gradient
  15203. * @param gradient defines the gradient to remove
  15204. * @returns the current particle system
  15205. */
  15206. removeEmitRateGradient(gradient: number): IParticleSystem;
  15207. /**
  15208. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15209. * @param gradient defines the gradient to use (between 0 and 1)
  15210. * @param factor defines the start size value to affect to the specified gradient
  15211. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15212. * @returns the current particle system
  15213. */
  15214. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15215. /**
  15216. * Remove a specific start size gradient
  15217. * @param gradient defines the gradient to remove
  15218. * @returns the current particle system
  15219. */
  15220. removeStartSizeGradient(gradient: number): IParticleSystem;
  15221. private _createRampGradientTexture;
  15222. /**
  15223. * Gets the current list of ramp gradients.
  15224. * You must use addRampGradient and removeRampGradient to udpate this list
  15225. * @returns the list of ramp gradients
  15226. */
  15227. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15228. /**
  15229. * Adds a new ramp gradient used to remap particle colors
  15230. * @param gradient defines the gradient to use (between 0 and 1)
  15231. * @param color defines the color to affect to the specified gradient
  15232. * @returns the current particle system
  15233. */
  15234. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15235. /**
  15236. * Remove a specific ramp gradient
  15237. * @param gradient defines the gradient to remove
  15238. * @returns the current particle system
  15239. */
  15240. removeRampGradient(gradient: number): ParticleSystem;
  15241. /**
  15242. * Adds a new color gradient
  15243. * @param gradient defines the gradient to use (between 0 and 1)
  15244. * @param color1 defines the color to affect to the specified gradient
  15245. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15246. * @returns this particle system
  15247. */
  15248. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15249. /**
  15250. * Remove a specific color gradient
  15251. * @param gradient defines the gradient to remove
  15252. * @returns this particle system
  15253. */
  15254. removeColorGradient(gradient: number): IParticleSystem;
  15255. private _fetchR;
  15256. protected _reset(): void;
  15257. private _resetEffect;
  15258. private _createVertexBuffers;
  15259. private _createIndexBuffer;
  15260. /**
  15261. * Gets the maximum number of particles active at the same time.
  15262. * @returns The max number of active particles.
  15263. */
  15264. getCapacity(): number;
  15265. /**
  15266. * Gets whether there are still active particles in the system.
  15267. * @returns True if it is alive, otherwise false.
  15268. */
  15269. isAlive(): boolean;
  15270. /**
  15271. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15272. * @returns True if it has been started, otherwise false.
  15273. */
  15274. isStarted(): boolean;
  15275. private _prepareSubEmitterInternalArray;
  15276. /**
  15277. * Starts the particle system and begins to emit
  15278. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15279. */
  15280. start(delay?: number): void;
  15281. /**
  15282. * Stops the particle system.
  15283. * @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.
  15284. */
  15285. stop(stopSubEmitters?: boolean): void;
  15286. /**
  15287. * Remove all active particles
  15288. */
  15289. reset(): void;
  15290. /**
  15291. * @hidden (for internal use only)
  15292. */
  15293. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15294. /**
  15295. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15296. * Its lifetime will start back at 0.
  15297. */
  15298. recycleParticle: (particle: Particle) => void;
  15299. private _stopSubEmitters;
  15300. private _createParticle;
  15301. private _removeFromRoot;
  15302. private _emitFromParticle;
  15303. private _update;
  15304. /** @hidden */
  15305. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15306. /** @hidden */
  15307. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15308. /** @hidden */
  15309. private _getEffect;
  15310. /**
  15311. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15312. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15313. */
  15314. animate(preWarmOnly?: boolean): void;
  15315. private _appendParticleVertices;
  15316. /**
  15317. * Rebuilds the particle system.
  15318. */
  15319. rebuild(): void;
  15320. /**
  15321. * Is this system ready to be used/rendered
  15322. * @return true if the system is ready
  15323. */
  15324. isReady(): boolean;
  15325. private _render;
  15326. /**
  15327. * Renders the particle system in its current state.
  15328. * @returns the current number of particles
  15329. */
  15330. render(): number;
  15331. /**
  15332. * Disposes the particle system and free the associated resources
  15333. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15334. */
  15335. dispose(disposeTexture?: boolean): void;
  15336. /**
  15337. * Clones the particle system.
  15338. * @param name The name of the cloned object
  15339. * @param newEmitter The new emitter to use
  15340. * @returns the cloned particle system
  15341. */
  15342. clone(name: string, newEmitter: any): ParticleSystem;
  15343. /**
  15344. * Serializes the particle system to a JSON object.
  15345. * @returns the JSON object
  15346. */
  15347. serialize(): any;
  15348. /** @hidden */
  15349. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15350. /** @hidden */
  15351. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15352. /**
  15353. * Parses a JSON object to create a particle system.
  15354. * @param parsedParticleSystem The JSON object to parse
  15355. * @param scene The scene to create the particle system in
  15356. * @param rootUrl The root url to use to load external dependencies like texture
  15357. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15358. * @returns the Parsed particle system
  15359. */
  15360. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15361. }
  15362. }
  15363. declare module BABYLON {
  15364. /**
  15365. * A particle represents one of the element emitted by a particle system.
  15366. * This is mainly define by its coordinates, direction, velocity and age.
  15367. */
  15368. export class Particle {
  15369. /**
  15370. * The particle system the particle belongs to.
  15371. */
  15372. particleSystem: ParticleSystem;
  15373. private static _Count;
  15374. /**
  15375. * Unique ID of the particle
  15376. */
  15377. id: number;
  15378. /**
  15379. * The world position of the particle in the scene.
  15380. */
  15381. position: Vector3;
  15382. /**
  15383. * The world direction of the particle in the scene.
  15384. */
  15385. direction: Vector3;
  15386. /**
  15387. * The color of the particle.
  15388. */
  15389. color: Color4;
  15390. /**
  15391. * The color change of the particle per step.
  15392. */
  15393. colorStep: Color4;
  15394. /**
  15395. * Defines how long will the life of the particle be.
  15396. */
  15397. lifeTime: number;
  15398. /**
  15399. * The current age of the particle.
  15400. */
  15401. age: number;
  15402. /**
  15403. * The current size of the particle.
  15404. */
  15405. size: number;
  15406. /**
  15407. * The current scale of the particle.
  15408. */
  15409. scale: Vector2;
  15410. /**
  15411. * The current angle of the particle.
  15412. */
  15413. angle: number;
  15414. /**
  15415. * Defines how fast is the angle changing.
  15416. */
  15417. angularSpeed: number;
  15418. /**
  15419. * Defines the cell index used by the particle to be rendered from a sprite.
  15420. */
  15421. cellIndex: number;
  15422. /**
  15423. * The information required to support color remapping
  15424. */
  15425. remapData: Vector4;
  15426. /** @hidden */
  15427. _randomCellOffset?: number;
  15428. /** @hidden */
  15429. _initialDirection: Nullable<Vector3>;
  15430. /** @hidden */
  15431. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15432. /** @hidden */
  15433. _initialStartSpriteCellID: number;
  15434. /** @hidden */
  15435. _initialEndSpriteCellID: number;
  15436. /** @hidden */
  15437. _currentColorGradient: Nullable<ColorGradient>;
  15438. /** @hidden */
  15439. _currentColor1: Color4;
  15440. /** @hidden */
  15441. _currentColor2: Color4;
  15442. /** @hidden */
  15443. _currentSizeGradient: Nullable<FactorGradient>;
  15444. /** @hidden */
  15445. _currentSize1: number;
  15446. /** @hidden */
  15447. _currentSize2: number;
  15448. /** @hidden */
  15449. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15450. /** @hidden */
  15451. _currentAngularSpeed1: number;
  15452. /** @hidden */
  15453. _currentAngularSpeed2: number;
  15454. /** @hidden */
  15455. _currentVelocityGradient: Nullable<FactorGradient>;
  15456. /** @hidden */
  15457. _currentVelocity1: number;
  15458. /** @hidden */
  15459. _currentVelocity2: number;
  15460. /** @hidden */
  15461. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15462. /** @hidden */
  15463. _currentLimitVelocity1: number;
  15464. /** @hidden */
  15465. _currentLimitVelocity2: number;
  15466. /** @hidden */
  15467. _currentDragGradient: Nullable<FactorGradient>;
  15468. /** @hidden */
  15469. _currentDrag1: number;
  15470. /** @hidden */
  15471. _currentDrag2: number;
  15472. /** @hidden */
  15473. _randomNoiseCoordinates1: Vector3;
  15474. /** @hidden */
  15475. _randomNoiseCoordinates2: Vector3;
  15476. /**
  15477. * Creates a new instance Particle
  15478. * @param particleSystem the particle system the particle belongs to
  15479. */
  15480. constructor(
  15481. /**
  15482. * The particle system the particle belongs to.
  15483. */
  15484. particleSystem: ParticleSystem);
  15485. private updateCellInfoFromSystem;
  15486. /**
  15487. * Defines how the sprite cell index is updated for the particle
  15488. */
  15489. updateCellIndex(): void;
  15490. /** @hidden */
  15491. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15492. /** @hidden */
  15493. _inheritParticleInfoToSubEmitters(): void;
  15494. /** @hidden */
  15495. _reset(): void;
  15496. /**
  15497. * Copy the properties of particle to another one.
  15498. * @param other the particle to copy the information to.
  15499. */
  15500. copyTo(other: Particle): void;
  15501. }
  15502. }
  15503. declare module BABYLON {
  15504. /**
  15505. * Particle emitter represents a volume emitting particles.
  15506. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15507. */
  15508. export interface IParticleEmitterType {
  15509. /**
  15510. * Called by the particle System when the direction is computed for the created particle.
  15511. * @param worldMatrix is the world matrix of the particle system
  15512. * @param directionToUpdate is the direction vector to update with the result
  15513. * @param particle is the particle we are computed the direction for
  15514. */
  15515. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15516. /**
  15517. * Called by the particle System when the position is computed for the created particle.
  15518. * @param worldMatrix is the world matrix of the particle system
  15519. * @param positionToUpdate is the position vector to update with the result
  15520. * @param particle is the particle we are computed the position for
  15521. */
  15522. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15523. /**
  15524. * Clones the current emitter and returns a copy of it
  15525. * @returns the new emitter
  15526. */
  15527. clone(): IParticleEmitterType;
  15528. /**
  15529. * Called by the GPUParticleSystem to setup the update shader
  15530. * @param effect defines the update shader
  15531. */
  15532. applyToShader(effect: Effect): void;
  15533. /**
  15534. * Returns a string to use to update the GPU particles update shader
  15535. * @returns the effect defines string
  15536. */
  15537. getEffectDefines(): string;
  15538. /**
  15539. * Returns a string representing the class name
  15540. * @returns a string containing the class name
  15541. */
  15542. getClassName(): string;
  15543. /**
  15544. * Serializes the particle system to a JSON object.
  15545. * @returns the JSON object
  15546. */
  15547. serialize(): any;
  15548. /**
  15549. * Parse properties from a JSON object
  15550. * @param serializationObject defines the JSON object
  15551. */
  15552. parse(serializationObject: any): void;
  15553. }
  15554. }
  15555. declare module BABYLON {
  15556. /**
  15557. * Particle emitter emitting particles from the inside of a box.
  15558. * It emits the particles randomly between 2 given directions.
  15559. */
  15560. export class BoxParticleEmitter implements IParticleEmitterType {
  15561. /**
  15562. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15563. */
  15564. direction1: Vector3;
  15565. /**
  15566. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15567. */
  15568. direction2: Vector3;
  15569. /**
  15570. * 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.
  15571. */
  15572. minEmitBox: Vector3;
  15573. /**
  15574. * 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.
  15575. */
  15576. maxEmitBox: Vector3;
  15577. /**
  15578. * Creates a new instance BoxParticleEmitter
  15579. */
  15580. constructor();
  15581. /**
  15582. * Called by the particle System when the direction is computed for the created particle.
  15583. * @param worldMatrix is the world matrix of the particle system
  15584. * @param directionToUpdate is the direction vector to update with the result
  15585. * @param particle is the particle we are computed the direction for
  15586. */
  15587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15588. /**
  15589. * Called by the particle System when the position is computed for the created particle.
  15590. * @param worldMatrix is the world matrix of the particle system
  15591. * @param positionToUpdate is the position vector to update with the result
  15592. * @param particle is the particle we are computed the position for
  15593. */
  15594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15595. /**
  15596. * Clones the current emitter and returns a copy of it
  15597. * @returns the new emitter
  15598. */
  15599. clone(): BoxParticleEmitter;
  15600. /**
  15601. * Called by the GPUParticleSystem to setup the update shader
  15602. * @param effect defines the update shader
  15603. */
  15604. applyToShader(effect: Effect): void;
  15605. /**
  15606. * Returns a string to use to update the GPU particles update shader
  15607. * @returns a string containng the defines string
  15608. */
  15609. getEffectDefines(): string;
  15610. /**
  15611. * Returns the string "BoxParticleEmitter"
  15612. * @returns a string containing the class name
  15613. */
  15614. getClassName(): string;
  15615. /**
  15616. * Serializes the particle system to a JSON object.
  15617. * @returns the JSON object
  15618. */
  15619. serialize(): any;
  15620. /**
  15621. * Parse properties from a JSON object
  15622. * @param serializationObject defines the JSON object
  15623. */
  15624. parse(serializationObject: any): void;
  15625. }
  15626. }
  15627. declare module BABYLON {
  15628. /**
  15629. * Particle emitter emitting particles from the inside of a cone.
  15630. * It emits the particles alongside the cone volume from the base to the particle.
  15631. * The emission direction might be randomized.
  15632. */
  15633. export class ConeParticleEmitter implements IParticleEmitterType {
  15634. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15635. directionRandomizer: number;
  15636. private _radius;
  15637. private _angle;
  15638. private _height;
  15639. /**
  15640. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15641. */
  15642. radiusRange: number;
  15643. /**
  15644. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15645. */
  15646. heightRange: number;
  15647. /**
  15648. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15649. */
  15650. emitFromSpawnPointOnly: boolean;
  15651. /**
  15652. * Gets or sets the radius of the emission cone
  15653. */
  15654. radius: number;
  15655. /**
  15656. * Gets or sets the angle of the emission cone
  15657. */
  15658. angle: number;
  15659. private _buildHeight;
  15660. /**
  15661. * Creates a new instance ConeParticleEmitter
  15662. * @param radius the radius of the emission cone (1 by default)
  15663. * @param angle the cone base angle (PI by default)
  15664. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15665. */
  15666. constructor(radius?: number, angle?: number,
  15667. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15668. directionRandomizer?: number);
  15669. /**
  15670. * Called by the particle System when the direction is computed for the created particle.
  15671. * @param worldMatrix is the world matrix of the particle system
  15672. * @param directionToUpdate is the direction vector to update with the result
  15673. * @param particle is the particle we are computed the direction for
  15674. */
  15675. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15676. /**
  15677. * Called by the particle System when the position is computed for the created particle.
  15678. * @param worldMatrix is the world matrix of the particle system
  15679. * @param positionToUpdate is the position vector to update with the result
  15680. * @param particle is the particle we are computed the position for
  15681. */
  15682. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15683. /**
  15684. * Clones the current emitter and returns a copy of it
  15685. * @returns the new emitter
  15686. */
  15687. clone(): ConeParticleEmitter;
  15688. /**
  15689. * Called by the GPUParticleSystem to setup the update shader
  15690. * @param effect defines the update shader
  15691. */
  15692. applyToShader(effect: Effect): void;
  15693. /**
  15694. * Returns a string to use to update the GPU particles update shader
  15695. * @returns a string containng the defines string
  15696. */
  15697. getEffectDefines(): string;
  15698. /**
  15699. * Returns the string "ConeParticleEmitter"
  15700. * @returns a string containing the class name
  15701. */
  15702. getClassName(): string;
  15703. /**
  15704. * Serializes the particle system to a JSON object.
  15705. * @returns the JSON object
  15706. */
  15707. serialize(): any;
  15708. /**
  15709. * Parse properties from a JSON object
  15710. * @param serializationObject defines the JSON object
  15711. */
  15712. parse(serializationObject: any): void;
  15713. }
  15714. }
  15715. declare module BABYLON {
  15716. /**
  15717. * Particle emitter emitting particles from the inside of a cylinder.
  15718. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15719. */
  15720. export class CylinderParticleEmitter implements IParticleEmitterType {
  15721. /**
  15722. * The radius of the emission cylinder.
  15723. */
  15724. radius: number;
  15725. /**
  15726. * The height of the emission cylinder.
  15727. */
  15728. height: number;
  15729. /**
  15730. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15731. */
  15732. radiusRange: number;
  15733. /**
  15734. * How much to randomize the particle direction [0-1].
  15735. */
  15736. directionRandomizer: number;
  15737. /**
  15738. * Creates a new instance CylinderParticleEmitter
  15739. * @param radius the radius of the emission cylinder (1 by default)
  15740. * @param height the height of the emission cylinder (1 by default)
  15741. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15742. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15743. */
  15744. constructor(
  15745. /**
  15746. * The radius of the emission cylinder.
  15747. */
  15748. radius?: number,
  15749. /**
  15750. * The height of the emission cylinder.
  15751. */
  15752. height?: number,
  15753. /**
  15754. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15755. */
  15756. radiusRange?: number,
  15757. /**
  15758. * How much to randomize the particle direction [0-1].
  15759. */
  15760. directionRandomizer?: number);
  15761. /**
  15762. * Called by the particle System when the direction is computed for the created particle.
  15763. * @param worldMatrix is the world matrix of the particle system
  15764. * @param directionToUpdate is the direction vector to update with the result
  15765. * @param particle is the particle we are computed the direction for
  15766. */
  15767. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15768. /**
  15769. * Called by the particle System when the position is computed for the created particle.
  15770. * @param worldMatrix is the world matrix of the particle system
  15771. * @param positionToUpdate is the position vector to update with the result
  15772. * @param particle is the particle we are computed the position for
  15773. */
  15774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15775. /**
  15776. * Clones the current emitter and returns a copy of it
  15777. * @returns the new emitter
  15778. */
  15779. clone(): CylinderParticleEmitter;
  15780. /**
  15781. * Called by the GPUParticleSystem to setup the update shader
  15782. * @param effect defines the update shader
  15783. */
  15784. applyToShader(effect: Effect): void;
  15785. /**
  15786. * Returns a string to use to update the GPU particles update shader
  15787. * @returns a string containng the defines string
  15788. */
  15789. getEffectDefines(): string;
  15790. /**
  15791. * Returns the string "CylinderParticleEmitter"
  15792. * @returns a string containing the class name
  15793. */
  15794. getClassName(): string;
  15795. /**
  15796. * Serializes the particle system to a JSON object.
  15797. * @returns the JSON object
  15798. */
  15799. serialize(): any;
  15800. /**
  15801. * Parse properties from a JSON object
  15802. * @param serializationObject defines the JSON object
  15803. */
  15804. parse(serializationObject: any): void;
  15805. }
  15806. /**
  15807. * Particle emitter emitting particles from the inside of a cylinder.
  15808. * It emits the particles randomly between two vectors.
  15809. */
  15810. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15811. /**
  15812. * The min limit of the emission direction.
  15813. */
  15814. direction1: Vector3;
  15815. /**
  15816. * The max limit of the emission direction.
  15817. */
  15818. direction2: Vector3;
  15819. /**
  15820. * Creates a new instance CylinderDirectedParticleEmitter
  15821. * @param radius the radius of the emission cylinder (1 by default)
  15822. * @param height the height of the emission cylinder (1 by default)
  15823. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15824. * @param direction1 the min limit of the emission direction (up vector by default)
  15825. * @param direction2 the max limit of the emission direction (up vector by default)
  15826. */
  15827. constructor(radius?: number, height?: number, radiusRange?: number,
  15828. /**
  15829. * The min limit of the emission direction.
  15830. */
  15831. direction1?: Vector3,
  15832. /**
  15833. * The max limit of the emission direction.
  15834. */
  15835. direction2?: Vector3);
  15836. /**
  15837. * Called by the particle System when the direction is computed for the created particle.
  15838. * @param worldMatrix is the world matrix of the particle system
  15839. * @param directionToUpdate is the direction vector to update with the result
  15840. * @param particle is the particle we are computed the direction for
  15841. */
  15842. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15843. /**
  15844. * Clones the current emitter and returns a copy of it
  15845. * @returns the new emitter
  15846. */
  15847. clone(): CylinderDirectedParticleEmitter;
  15848. /**
  15849. * Called by the GPUParticleSystem to setup the update shader
  15850. * @param effect defines the update shader
  15851. */
  15852. applyToShader(effect: Effect): void;
  15853. /**
  15854. * Returns a string to use to update the GPU particles update shader
  15855. * @returns a string containng the defines string
  15856. */
  15857. getEffectDefines(): string;
  15858. /**
  15859. * Returns the string "CylinderDirectedParticleEmitter"
  15860. * @returns a string containing the class name
  15861. */
  15862. getClassName(): string;
  15863. /**
  15864. * Serializes the particle system to a JSON object.
  15865. * @returns the JSON object
  15866. */
  15867. serialize(): any;
  15868. /**
  15869. * Parse properties from a JSON object
  15870. * @param serializationObject defines the JSON object
  15871. */
  15872. parse(serializationObject: any): void;
  15873. }
  15874. }
  15875. declare module BABYLON {
  15876. /**
  15877. * Particle emitter emitting particles from the inside of a hemisphere.
  15878. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15879. */
  15880. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15881. /**
  15882. * The radius of the emission hemisphere.
  15883. */
  15884. radius: number;
  15885. /**
  15886. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15887. */
  15888. radiusRange: number;
  15889. /**
  15890. * How much to randomize the particle direction [0-1].
  15891. */
  15892. directionRandomizer: number;
  15893. /**
  15894. * Creates a new instance HemisphericParticleEmitter
  15895. * @param radius the radius of the emission hemisphere (1 by default)
  15896. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15897. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15898. */
  15899. constructor(
  15900. /**
  15901. * The radius of the emission hemisphere.
  15902. */
  15903. radius?: number,
  15904. /**
  15905. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15906. */
  15907. radiusRange?: number,
  15908. /**
  15909. * How much to randomize the particle direction [0-1].
  15910. */
  15911. directionRandomizer?: number);
  15912. /**
  15913. * Called by the particle System when the direction is computed for the created particle.
  15914. * @param worldMatrix is the world matrix of the particle system
  15915. * @param directionToUpdate is the direction vector to update with the result
  15916. * @param particle is the particle we are computed the direction for
  15917. */
  15918. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15919. /**
  15920. * Called by the particle System when the position is computed for the created particle.
  15921. * @param worldMatrix is the world matrix of the particle system
  15922. * @param positionToUpdate is the position vector to update with the result
  15923. * @param particle is the particle we are computed the position for
  15924. */
  15925. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15926. /**
  15927. * Clones the current emitter and returns a copy of it
  15928. * @returns the new emitter
  15929. */
  15930. clone(): HemisphericParticleEmitter;
  15931. /**
  15932. * Called by the GPUParticleSystem to setup the update shader
  15933. * @param effect defines the update shader
  15934. */
  15935. applyToShader(effect: Effect): void;
  15936. /**
  15937. * Returns a string to use to update the GPU particles update shader
  15938. * @returns a string containng the defines string
  15939. */
  15940. getEffectDefines(): string;
  15941. /**
  15942. * Returns the string "HemisphericParticleEmitter"
  15943. * @returns a string containing the class name
  15944. */
  15945. getClassName(): string;
  15946. /**
  15947. * Serializes the particle system to a JSON object.
  15948. * @returns the JSON object
  15949. */
  15950. serialize(): any;
  15951. /**
  15952. * Parse properties from a JSON object
  15953. * @param serializationObject defines the JSON object
  15954. */
  15955. parse(serializationObject: any): void;
  15956. }
  15957. }
  15958. declare module BABYLON {
  15959. /**
  15960. * Particle emitter emitting particles from a point.
  15961. * It emits the particles randomly between 2 given directions.
  15962. */
  15963. export class PointParticleEmitter implements IParticleEmitterType {
  15964. /**
  15965. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15966. */
  15967. direction1: Vector3;
  15968. /**
  15969. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15970. */
  15971. direction2: Vector3;
  15972. /**
  15973. * Creates a new instance PointParticleEmitter
  15974. */
  15975. constructor();
  15976. /**
  15977. * Called by the particle System when the direction is computed for the created particle.
  15978. * @param worldMatrix is the world matrix of the particle system
  15979. * @param directionToUpdate is the direction vector to update with the result
  15980. * @param particle is the particle we are computed the direction for
  15981. */
  15982. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15983. /**
  15984. * Called by the particle System when the position is computed for the created particle.
  15985. * @param worldMatrix is the world matrix of the particle system
  15986. * @param positionToUpdate is the position vector to update with the result
  15987. * @param particle is the particle we are computed the position for
  15988. */
  15989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15990. /**
  15991. * Clones the current emitter and returns a copy of it
  15992. * @returns the new emitter
  15993. */
  15994. clone(): PointParticleEmitter;
  15995. /**
  15996. * Called by the GPUParticleSystem to setup the update shader
  15997. * @param effect defines the update shader
  15998. */
  15999. applyToShader(effect: Effect): void;
  16000. /**
  16001. * Returns a string to use to update the GPU particles update shader
  16002. * @returns a string containng the defines string
  16003. */
  16004. getEffectDefines(): string;
  16005. /**
  16006. * Returns the string "PointParticleEmitter"
  16007. * @returns a string containing the class name
  16008. */
  16009. getClassName(): string;
  16010. /**
  16011. * Serializes the particle system to a JSON object.
  16012. * @returns the JSON object
  16013. */
  16014. serialize(): any;
  16015. /**
  16016. * Parse properties from a JSON object
  16017. * @param serializationObject defines the JSON object
  16018. */
  16019. parse(serializationObject: any): void;
  16020. }
  16021. }
  16022. declare module BABYLON {
  16023. /**
  16024. * Particle emitter emitting particles from the inside of a sphere.
  16025. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16026. */
  16027. export class SphereParticleEmitter implements IParticleEmitterType {
  16028. /**
  16029. * The radius of the emission sphere.
  16030. */
  16031. radius: number;
  16032. /**
  16033. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16034. */
  16035. radiusRange: number;
  16036. /**
  16037. * How much to randomize the particle direction [0-1].
  16038. */
  16039. directionRandomizer: number;
  16040. /**
  16041. * Creates a new instance SphereParticleEmitter
  16042. * @param radius the radius of the emission sphere (1 by default)
  16043. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16044. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16045. */
  16046. constructor(
  16047. /**
  16048. * The radius of the emission sphere.
  16049. */
  16050. radius?: number,
  16051. /**
  16052. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16053. */
  16054. radiusRange?: number,
  16055. /**
  16056. * How much to randomize the particle direction [0-1].
  16057. */
  16058. directionRandomizer?: number);
  16059. /**
  16060. * Called by the particle System when the direction is computed for the created particle.
  16061. * @param worldMatrix is the world matrix of the particle system
  16062. * @param directionToUpdate is the direction vector to update with the result
  16063. * @param particle is the particle we are computed the direction for
  16064. */
  16065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16066. /**
  16067. * Called by the particle System when the position is computed for the created particle.
  16068. * @param worldMatrix is the world matrix of the particle system
  16069. * @param positionToUpdate is the position vector to update with the result
  16070. * @param particle is the particle we are computed the position for
  16071. */
  16072. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16073. /**
  16074. * Clones the current emitter and returns a copy of it
  16075. * @returns the new emitter
  16076. */
  16077. clone(): SphereParticleEmitter;
  16078. /**
  16079. * Called by the GPUParticleSystem to setup the update shader
  16080. * @param effect defines the update shader
  16081. */
  16082. applyToShader(effect: Effect): void;
  16083. /**
  16084. * Returns a string to use to update the GPU particles update shader
  16085. * @returns a string containng the defines string
  16086. */
  16087. getEffectDefines(): string;
  16088. /**
  16089. * Returns the string "SphereParticleEmitter"
  16090. * @returns a string containing the class name
  16091. */
  16092. getClassName(): string;
  16093. /**
  16094. * Serializes the particle system to a JSON object.
  16095. * @returns the JSON object
  16096. */
  16097. serialize(): any;
  16098. /**
  16099. * Parse properties from a JSON object
  16100. * @param serializationObject defines the JSON object
  16101. */
  16102. parse(serializationObject: any): void;
  16103. }
  16104. /**
  16105. * Particle emitter emitting particles from the inside of a sphere.
  16106. * It emits the particles randomly between two vectors.
  16107. */
  16108. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16109. /**
  16110. * The min limit of the emission direction.
  16111. */
  16112. direction1: Vector3;
  16113. /**
  16114. * The max limit of the emission direction.
  16115. */
  16116. direction2: Vector3;
  16117. /**
  16118. * Creates a new instance SphereDirectedParticleEmitter
  16119. * @param radius the radius of the emission sphere (1 by default)
  16120. * @param direction1 the min limit of the emission direction (up vector by default)
  16121. * @param direction2 the max limit of the emission direction (up vector by default)
  16122. */
  16123. constructor(radius?: number,
  16124. /**
  16125. * The min limit of the emission direction.
  16126. */
  16127. direction1?: Vector3,
  16128. /**
  16129. * The max limit of the emission direction.
  16130. */
  16131. direction2?: Vector3);
  16132. /**
  16133. * Called by the particle System when the direction is computed for the created particle.
  16134. * @param worldMatrix is the world matrix of the particle system
  16135. * @param directionToUpdate is the direction vector to update with the result
  16136. * @param particle is the particle we are computed the direction for
  16137. */
  16138. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16139. /**
  16140. * Clones the current emitter and returns a copy of it
  16141. * @returns the new emitter
  16142. */
  16143. clone(): SphereDirectedParticleEmitter;
  16144. /**
  16145. * Called by the GPUParticleSystem to setup the update shader
  16146. * @param effect defines the update shader
  16147. */
  16148. applyToShader(effect: Effect): void;
  16149. /**
  16150. * Returns a string to use to update the GPU particles update shader
  16151. * @returns a string containng the defines string
  16152. */
  16153. getEffectDefines(): string;
  16154. /**
  16155. * Returns the string "SphereDirectedParticleEmitter"
  16156. * @returns a string containing the class name
  16157. */
  16158. getClassName(): string;
  16159. /**
  16160. * Serializes the particle system to a JSON object.
  16161. * @returns the JSON object
  16162. */
  16163. serialize(): any;
  16164. /**
  16165. * Parse properties from a JSON object
  16166. * @param serializationObject defines the JSON object
  16167. */
  16168. parse(serializationObject: any): void;
  16169. }
  16170. }
  16171. declare module BABYLON {
  16172. /**
  16173. * Interface representing a particle system in Babylon.js.
  16174. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16175. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16176. */
  16177. export interface IParticleSystem {
  16178. /**
  16179. * List of animations used by the particle system.
  16180. */
  16181. animations: Animation[];
  16182. /**
  16183. * The id of the Particle system.
  16184. */
  16185. id: string;
  16186. /**
  16187. * The name of the Particle system.
  16188. */
  16189. name: string;
  16190. /**
  16191. * The emitter represents the Mesh or position we are attaching the particle system to.
  16192. */
  16193. emitter: Nullable<AbstractMesh | Vector3>;
  16194. /**
  16195. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16196. */
  16197. isBillboardBased: boolean;
  16198. /**
  16199. * The rendering group used by the Particle system to chose when to render.
  16200. */
  16201. renderingGroupId: number;
  16202. /**
  16203. * The layer mask we are rendering the particles through.
  16204. */
  16205. layerMask: number;
  16206. /**
  16207. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16208. */
  16209. updateSpeed: number;
  16210. /**
  16211. * The amount of time the particle system is running (depends of the overall update speed).
  16212. */
  16213. targetStopDuration: number;
  16214. /**
  16215. * The texture used to render each particle. (this can be a spritesheet)
  16216. */
  16217. particleTexture: Nullable<Texture>;
  16218. /**
  16219. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16220. */
  16221. blendMode: number;
  16222. /**
  16223. * Minimum life time of emitting particles.
  16224. */
  16225. minLifeTime: number;
  16226. /**
  16227. * Maximum life time of emitting particles.
  16228. */
  16229. maxLifeTime: number;
  16230. /**
  16231. * Minimum Size of emitting particles.
  16232. */
  16233. minSize: number;
  16234. /**
  16235. * Maximum Size of emitting particles.
  16236. */
  16237. maxSize: number;
  16238. /**
  16239. * Minimum scale of emitting particles on X axis.
  16240. */
  16241. minScaleX: number;
  16242. /**
  16243. * Maximum scale of emitting particles on X axis.
  16244. */
  16245. maxScaleX: number;
  16246. /**
  16247. * Minimum scale of emitting particles on Y axis.
  16248. */
  16249. minScaleY: number;
  16250. /**
  16251. * Maximum scale of emitting particles on Y axis.
  16252. */
  16253. maxScaleY: number;
  16254. /**
  16255. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16256. */
  16257. color1: Color4;
  16258. /**
  16259. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16260. */
  16261. color2: Color4;
  16262. /**
  16263. * Color the particle will have at the end of its lifetime.
  16264. */
  16265. colorDead: Color4;
  16266. /**
  16267. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16268. */
  16269. emitRate: number;
  16270. /**
  16271. * You can use gravity if you want to give an orientation to your particles.
  16272. */
  16273. gravity: Vector3;
  16274. /**
  16275. * Minimum power of emitting particles.
  16276. */
  16277. minEmitPower: number;
  16278. /**
  16279. * Maximum power of emitting particles.
  16280. */
  16281. maxEmitPower: number;
  16282. /**
  16283. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16284. */
  16285. minAngularSpeed: number;
  16286. /**
  16287. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16288. */
  16289. maxAngularSpeed: number;
  16290. /**
  16291. * Gets or sets the minimal initial rotation in radians.
  16292. */
  16293. minInitialRotation: number;
  16294. /**
  16295. * Gets or sets the maximal initial rotation in radians.
  16296. */
  16297. maxInitialRotation: number;
  16298. /**
  16299. * The particle emitter type defines the emitter used by the particle system.
  16300. * It can be for example box, sphere, or cone...
  16301. */
  16302. particleEmitterType: Nullable<IParticleEmitterType>;
  16303. /**
  16304. * Defines the delay in milliseconds before starting the system (0 by default)
  16305. */
  16306. startDelay: number;
  16307. /**
  16308. * 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
  16309. */
  16310. preWarmCycles: number;
  16311. /**
  16312. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16313. */
  16314. preWarmStepOffset: number;
  16315. /**
  16316. * 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)
  16317. */
  16318. spriteCellChangeSpeed: number;
  16319. /**
  16320. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16321. */
  16322. startSpriteCellID: number;
  16323. /**
  16324. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16325. */
  16326. endSpriteCellID: number;
  16327. /**
  16328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16329. */
  16330. spriteCellWidth: number;
  16331. /**
  16332. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16333. */
  16334. spriteCellHeight: number;
  16335. /**
  16336. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16337. */
  16338. spriteRandomStartCell: boolean;
  16339. /**
  16340. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16341. */
  16342. isAnimationSheetEnabled: boolean;
  16343. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16344. translationPivot: Vector2;
  16345. /**
  16346. * Gets or sets a texture used to add random noise to particle positions
  16347. */
  16348. noiseTexture: Nullable<BaseTexture>;
  16349. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16350. noiseStrength: Vector3;
  16351. /**
  16352. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16353. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16354. */
  16355. billboardMode: number;
  16356. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16357. limitVelocityDamping: number;
  16358. /**
  16359. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16360. */
  16361. beginAnimationOnStart: boolean;
  16362. /**
  16363. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16364. */
  16365. beginAnimationFrom: number;
  16366. /**
  16367. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16368. */
  16369. beginAnimationTo: number;
  16370. /**
  16371. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16372. */
  16373. beginAnimationLoop: boolean;
  16374. /**
  16375. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16376. */
  16377. disposeOnStop: boolean;
  16378. /**
  16379. * Gets the maximum number of particles active at the same time.
  16380. * @returns The max number of active particles.
  16381. */
  16382. getCapacity(): number;
  16383. /**
  16384. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16385. * @returns True if it has been started, otherwise false.
  16386. */
  16387. isStarted(): boolean;
  16388. /**
  16389. * Animates the particle system for this frame.
  16390. */
  16391. animate(): void;
  16392. /**
  16393. * Renders the particle system in its current state.
  16394. * @returns the current number of particles
  16395. */
  16396. render(): number;
  16397. /**
  16398. * Dispose the particle system and frees its associated resources.
  16399. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16400. */
  16401. dispose(disposeTexture?: boolean): void;
  16402. /**
  16403. * Clones the particle system.
  16404. * @param name The name of the cloned object
  16405. * @param newEmitter The new emitter to use
  16406. * @returns the cloned particle system
  16407. */
  16408. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16409. /**
  16410. * Serializes the particle system to a JSON object.
  16411. * @returns the JSON object
  16412. */
  16413. serialize(): any;
  16414. /**
  16415. * Rebuild the particle system
  16416. */
  16417. rebuild(): void;
  16418. /**
  16419. * Starts the particle system and begins to emit
  16420. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16421. */
  16422. start(delay?: number): void;
  16423. /**
  16424. * Stops the particle system.
  16425. */
  16426. stop(): void;
  16427. /**
  16428. * Remove all active particles
  16429. */
  16430. reset(): void;
  16431. /**
  16432. * Is this system ready to be used/rendered
  16433. * @return true if the system is ready
  16434. */
  16435. isReady(): boolean;
  16436. /**
  16437. * Adds a new color gradient
  16438. * @param gradient defines the gradient to use (between 0 and 1)
  16439. * @param color1 defines the color to affect to the specified gradient
  16440. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16441. * @returns the current particle system
  16442. */
  16443. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16444. /**
  16445. * Remove a specific color gradient
  16446. * @param gradient defines the gradient to remove
  16447. * @returns the current particle system
  16448. */
  16449. removeColorGradient(gradient: number): IParticleSystem;
  16450. /**
  16451. * Adds a new size gradient
  16452. * @param gradient defines the gradient to use (between 0 and 1)
  16453. * @param factor defines the size factor to affect to the specified gradient
  16454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16455. * @returns the current particle system
  16456. */
  16457. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16458. /**
  16459. * Remove a specific size gradient
  16460. * @param gradient defines the gradient to remove
  16461. * @returns the current particle system
  16462. */
  16463. removeSizeGradient(gradient: number): IParticleSystem;
  16464. /**
  16465. * Gets the current list of color gradients.
  16466. * You must use addColorGradient and removeColorGradient to udpate this list
  16467. * @returns the list of color gradients
  16468. */
  16469. getColorGradients(): Nullable<Array<ColorGradient>>;
  16470. /**
  16471. * Gets the current list of size gradients.
  16472. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16473. * @returns the list of size gradients
  16474. */
  16475. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16476. /**
  16477. * Gets the current list of angular speed gradients.
  16478. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16479. * @returns the list of angular speed gradients
  16480. */
  16481. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16482. /**
  16483. * Adds a new angular speed gradient
  16484. * @param gradient defines the gradient to use (between 0 and 1)
  16485. * @param factor defines the angular speed to affect to the specified gradient
  16486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16487. * @returns the current particle system
  16488. */
  16489. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16490. /**
  16491. * Remove a specific angular speed gradient
  16492. * @param gradient defines the gradient to remove
  16493. * @returns the current particle system
  16494. */
  16495. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16496. /**
  16497. * Gets the current list of velocity gradients.
  16498. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16499. * @returns the list of velocity gradients
  16500. */
  16501. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16502. /**
  16503. * Adds a new velocity gradient
  16504. * @param gradient defines the gradient to use (between 0 and 1)
  16505. * @param factor defines the velocity to affect to the specified gradient
  16506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16507. * @returns the current particle system
  16508. */
  16509. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16510. /**
  16511. * Remove a specific velocity gradient
  16512. * @param gradient defines the gradient to remove
  16513. * @returns the current particle system
  16514. */
  16515. removeVelocityGradient(gradient: number): IParticleSystem;
  16516. /**
  16517. * Gets the current list of limit velocity gradients.
  16518. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16519. * @returns the list of limit velocity gradients
  16520. */
  16521. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16522. /**
  16523. * Adds a new limit velocity gradient
  16524. * @param gradient defines the gradient to use (between 0 and 1)
  16525. * @param factor defines the limit velocity to affect to the specified gradient
  16526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16527. * @returns the current particle system
  16528. */
  16529. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16530. /**
  16531. * Remove a specific limit velocity gradient
  16532. * @param gradient defines the gradient to remove
  16533. * @returns the current particle system
  16534. */
  16535. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16536. /**
  16537. * Adds a new drag gradient
  16538. * @param gradient defines the gradient to use (between 0 and 1)
  16539. * @param factor defines the drag to affect to the specified gradient
  16540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16541. * @returns the current particle system
  16542. */
  16543. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16544. /**
  16545. * Remove a specific drag gradient
  16546. * @param gradient defines the gradient to remove
  16547. * @returns the current particle system
  16548. */
  16549. removeDragGradient(gradient: number): IParticleSystem;
  16550. /**
  16551. * Gets the current list of drag gradients.
  16552. * You must use addDragGradient and removeDragGradient to udpate this list
  16553. * @returns the list of drag gradients
  16554. */
  16555. getDragGradients(): Nullable<Array<FactorGradient>>;
  16556. /**
  16557. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16558. * @param gradient defines the gradient to use (between 0 and 1)
  16559. * @param factor defines the emit rate to affect to the specified gradient
  16560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16561. * @returns the current particle system
  16562. */
  16563. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16564. /**
  16565. * Remove a specific emit rate gradient
  16566. * @param gradient defines the gradient to remove
  16567. * @returns the current particle system
  16568. */
  16569. removeEmitRateGradient(gradient: number): IParticleSystem;
  16570. /**
  16571. * Gets the current list of emit rate gradients.
  16572. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16573. * @returns the list of emit rate gradients
  16574. */
  16575. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16576. /**
  16577. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16578. * @param gradient defines the gradient to use (between 0 and 1)
  16579. * @param factor defines the start size to affect to the specified gradient
  16580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16581. * @returns the current particle system
  16582. */
  16583. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16584. /**
  16585. * Remove a specific start size gradient
  16586. * @param gradient defines the gradient to remove
  16587. * @returns the current particle system
  16588. */
  16589. removeStartSizeGradient(gradient: number): IParticleSystem;
  16590. /**
  16591. * Gets the current list of start size gradients.
  16592. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16593. * @returns the list of start size gradients
  16594. */
  16595. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16596. /**
  16597. * Adds a new life time gradient
  16598. * @param gradient defines the gradient to use (between 0 and 1)
  16599. * @param factor defines the life time factor to affect to the specified gradient
  16600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16601. * @returns the current particle system
  16602. */
  16603. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16604. /**
  16605. * Remove a specific life time gradient
  16606. * @param gradient defines the gradient to remove
  16607. * @returns the current particle system
  16608. */
  16609. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16610. /**
  16611. * Gets the current list of life time gradients.
  16612. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16613. * @returns the list of life time gradients
  16614. */
  16615. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16616. /**
  16617. * Gets the current list of color gradients.
  16618. * You must use addColorGradient and removeColorGradient to udpate this list
  16619. * @returns the list of color gradients
  16620. */
  16621. getColorGradients(): Nullable<Array<ColorGradient>>;
  16622. /**
  16623. * Adds a new ramp gradient used to remap particle colors
  16624. * @param gradient defines the gradient to use (between 0 and 1)
  16625. * @param color defines the color to affect to the specified gradient
  16626. * @returns the current particle system
  16627. */
  16628. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16629. /**
  16630. * Gets the current list of ramp gradients.
  16631. * You must use addRampGradient and removeRampGradient to udpate this list
  16632. * @returns the list of ramp gradients
  16633. */
  16634. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16635. /** Gets or sets a boolean indicating that ramp gradients must be used
  16636. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16637. */
  16638. useRampGradients: boolean;
  16639. /**
  16640. * Adds a new color remap gradient
  16641. * @param gradient defines the gradient to use (between 0 and 1)
  16642. * @param min defines the color remap minimal range
  16643. * @param max defines the color remap maximal range
  16644. * @returns the current particle system
  16645. */
  16646. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16647. /**
  16648. * Gets the current list of color remap gradients.
  16649. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16650. * @returns the list of color remap gradients
  16651. */
  16652. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16653. /**
  16654. * Adds a new alpha remap gradient
  16655. * @param gradient defines the gradient to use (between 0 and 1)
  16656. * @param min defines the alpha remap minimal range
  16657. * @param max defines the alpha remap maximal range
  16658. * @returns the current particle system
  16659. */
  16660. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16661. /**
  16662. * Gets the current list of alpha remap gradients.
  16663. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16664. * @returns the list of alpha remap gradients
  16665. */
  16666. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16667. /**
  16668. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16671. * @returns the emitter
  16672. */
  16673. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16674. /**
  16675. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16676. * @param radius The radius of the hemisphere to emit from
  16677. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16678. * @returns the emitter
  16679. */
  16680. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16681. /**
  16682. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16683. * @param radius The radius of the sphere to emit from
  16684. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16685. * @returns the emitter
  16686. */
  16687. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16688. /**
  16689. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16690. * @param radius The radius of the sphere to emit from
  16691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16693. * @returns the emitter
  16694. */
  16695. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16696. /**
  16697. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16698. * @param radius The radius of the emission cylinder
  16699. * @param height The height of the emission cylinder
  16700. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16701. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16702. * @returns the emitter
  16703. */
  16704. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16705. /**
  16706. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16707. * @param radius The radius of the cylinder to emit from
  16708. * @param height The height of the emission cylinder
  16709. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16712. * @returns the emitter
  16713. */
  16714. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16715. /**
  16716. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16717. * @param radius The radius of the cone to emit from
  16718. * @param angle The base angle of the cone
  16719. * @returns the emitter
  16720. */
  16721. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16722. /**
  16723. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16726. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16727. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16728. * @returns the emitter
  16729. */
  16730. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16731. /**
  16732. * Get hosting scene
  16733. * @returns the scene
  16734. */
  16735. getScene(): Scene;
  16736. }
  16737. }
  16738. declare module BABYLON {
  16739. /**
  16740. * Creates an instance based on a source mesh.
  16741. */
  16742. export class InstancedMesh extends AbstractMesh {
  16743. private _sourceMesh;
  16744. private _currentLOD;
  16745. /** @hidden */
  16746. _indexInSourceMeshInstanceArray: number;
  16747. constructor(name: string, source: Mesh);
  16748. /**
  16749. * Returns the string "InstancedMesh".
  16750. */
  16751. getClassName(): string;
  16752. /** Gets the list of lights affecting that mesh */
  16753. readonly lightSources: Light[];
  16754. _resyncLightSources(): void;
  16755. _resyncLighSource(light: Light): void;
  16756. _removeLightSource(light: Light): void;
  16757. /**
  16758. * If the source mesh receives shadows
  16759. */
  16760. readonly receiveShadows: boolean;
  16761. /**
  16762. * The material of the source mesh
  16763. */
  16764. readonly material: Nullable<Material>;
  16765. /**
  16766. * Visibility of the source mesh
  16767. */
  16768. readonly visibility: number;
  16769. /**
  16770. * Skeleton of the source mesh
  16771. */
  16772. readonly skeleton: Nullable<Skeleton>;
  16773. /**
  16774. * Rendering ground id of the source mesh
  16775. */
  16776. renderingGroupId: number;
  16777. /**
  16778. * Returns the total number of vertices (integer).
  16779. */
  16780. getTotalVertices(): number;
  16781. /**
  16782. * Returns a positive integer : the total number of indices in this mesh geometry.
  16783. * @returns the numner of indices or zero if the mesh has no geometry.
  16784. */
  16785. getTotalIndices(): number;
  16786. /**
  16787. * The source mesh of the instance
  16788. */
  16789. readonly sourceMesh: Mesh;
  16790. /**
  16791. * Is this node ready to be used/rendered
  16792. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16793. * @return {boolean} is it ready
  16794. */
  16795. isReady(completeCheck?: boolean): boolean;
  16796. /**
  16797. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16798. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16799. * @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.
  16800. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16801. */
  16802. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16803. /**
  16804. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16805. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16806. * The `data` are either a numeric array either a Float32Array.
  16807. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16808. * 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).
  16809. * Note that a new underlying VertexBuffer object is created each call.
  16810. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16811. *
  16812. * Possible `kind` values :
  16813. * - VertexBuffer.PositionKind
  16814. * - VertexBuffer.UVKind
  16815. * - VertexBuffer.UV2Kind
  16816. * - VertexBuffer.UV3Kind
  16817. * - VertexBuffer.UV4Kind
  16818. * - VertexBuffer.UV5Kind
  16819. * - VertexBuffer.UV6Kind
  16820. * - VertexBuffer.ColorKind
  16821. * - VertexBuffer.MatricesIndicesKind
  16822. * - VertexBuffer.MatricesIndicesExtraKind
  16823. * - VertexBuffer.MatricesWeightsKind
  16824. * - VertexBuffer.MatricesWeightsExtraKind
  16825. *
  16826. * Returns the Mesh.
  16827. */
  16828. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16829. /**
  16830. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16831. * If the mesh has no geometry, it is simply returned as it is.
  16832. * The `data` are either a numeric array either a Float32Array.
  16833. * No new underlying VertexBuffer object is created.
  16834. * 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.
  16835. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16836. *
  16837. * Possible `kind` values :
  16838. * - VertexBuffer.PositionKind
  16839. * - VertexBuffer.UVKind
  16840. * - VertexBuffer.UV2Kind
  16841. * - VertexBuffer.UV3Kind
  16842. * - VertexBuffer.UV4Kind
  16843. * - VertexBuffer.UV5Kind
  16844. * - VertexBuffer.UV6Kind
  16845. * - VertexBuffer.ColorKind
  16846. * - VertexBuffer.MatricesIndicesKind
  16847. * - VertexBuffer.MatricesIndicesExtraKind
  16848. * - VertexBuffer.MatricesWeightsKind
  16849. * - VertexBuffer.MatricesWeightsExtraKind
  16850. *
  16851. * Returns the Mesh.
  16852. */
  16853. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16854. /**
  16855. * Sets the mesh indices.
  16856. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16857. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16858. * This method creates a new index buffer each call.
  16859. * Returns the Mesh.
  16860. */
  16861. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16862. /**
  16863. * Boolean : True if the mesh owns the requested kind of data.
  16864. */
  16865. isVerticesDataPresent(kind: string): boolean;
  16866. /**
  16867. * Returns an array of indices (IndicesArray).
  16868. */
  16869. getIndices(): Nullable<IndicesArray>;
  16870. readonly _positions: Nullable<Vector3[]>;
  16871. /**
  16872. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16873. * This means the mesh underlying bounding box and sphere are recomputed.
  16874. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16875. * @returns the current mesh
  16876. */
  16877. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16878. /** @hidden */
  16879. _preActivate(): InstancedMesh;
  16880. /** @hidden */
  16881. _activate(renderId: number): boolean;
  16882. /** @hidden */
  16883. _postActivate(): void;
  16884. getWorldMatrix(): Matrix;
  16885. readonly isAnInstance: boolean;
  16886. /**
  16887. * Returns the current associated LOD AbstractMesh.
  16888. */
  16889. getLOD(camera: Camera): AbstractMesh;
  16890. /** @hidden */
  16891. _syncSubMeshes(): InstancedMesh;
  16892. /** @hidden */
  16893. _generatePointsArray(): boolean;
  16894. /**
  16895. * Creates a new InstancedMesh from the current mesh.
  16896. * - name (string) : the cloned mesh name
  16897. * - newParent (optional Node) : the optional Node to parent the clone to.
  16898. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16899. *
  16900. * Returns the clone.
  16901. */
  16902. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16903. /**
  16904. * Disposes the InstancedMesh.
  16905. * Returns nothing.
  16906. */
  16907. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16908. }
  16909. }
  16910. declare module BABYLON {
  16911. /**
  16912. * Defines the options associated with the creation of a shader material.
  16913. */
  16914. export interface IShaderMaterialOptions {
  16915. /**
  16916. * Does the material work in alpha blend mode
  16917. */
  16918. needAlphaBlending: boolean;
  16919. /**
  16920. * Does the material work in alpha test mode
  16921. */
  16922. needAlphaTesting: boolean;
  16923. /**
  16924. * The list of attribute names used in the shader
  16925. */
  16926. attributes: string[];
  16927. /**
  16928. * The list of unifrom names used in the shader
  16929. */
  16930. uniforms: string[];
  16931. /**
  16932. * The list of UBO names used in the shader
  16933. */
  16934. uniformBuffers: string[];
  16935. /**
  16936. * The list of sampler names used in the shader
  16937. */
  16938. samplers: string[];
  16939. /**
  16940. * The list of defines used in the shader
  16941. */
  16942. defines: string[];
  16943. }
  16944. /**
  16945. * 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.
  16946. *
  16947. * This returned material effects how the mesh will look based on the code in the shaders.
  16948. *
  16949. * @see http://doc.babylonjs.com/how_to/shader_material
  16950. */
  16951. export class ShaderMaterial extends Material {
  16952. private _shaderPath;
  16953. private _options;
  16954. private _textures;
  16955. private _textureArrays;
  16956. private _floats;
  16957. private _ints;
  16958. private _floatsArrays;
  16959. private _colors3;
  16960. private _colors3Arrays;
  16961. private _colors4;
  16962. private _vectors2;
  16963. private _vectors3;
  16964. private _vectors4;
  16965. private _matrices;
  16966. private _matrices3x3;
  16967. private _matrices2x2;
  16968. private _vectors2Arrays;
  16969. private _vectors3Arrays;
  16970. private _cachedWorldViewMatrix;
  16971. private _renderId;
  16972. /**
  16973. * Instantiate a new shader material.
  16974. * 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.
  16975. * This returned material effects how the mesh will look based on the code in the shaders.
  16976. * @see http://doc.babylonjs.com/how_to/shader_material
  16977. * @param name Define the name of the material in the scene
  16978. * @param scene Define the scene the material belongs to
  16979. * @param shaderPath Defines the route to the shader code in one of three ways:
  16980. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16981. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16982. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16983. * @param options Define the options used to create the shader
  16984. */
  16985. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16986. /**
  16987. * Gets the options used to compile the shader.
  16988. * They can be modified to trigger a new compilation
  16989. */
  16990. readonly options: IShaderMaterialOptions;
  16991. /**
  16992. * Gets the current class name of the material e.g. "ShaderMaterial"
  16993. * Mainly use in serialization.
  16994. * @returns the class name
  16995. */
  16996. getClassName(): string;
  16997. /**
  16998. * Specifies if the material will require alpha blending
  16999. * @returns a boolean specifying if alpha blending is needed
  17000. */
  17001. needAlphaBlending(): boolean;
  17002. /**
  17003. * Specifies if this material should be rendered in alpha test mode
  17004. * @returns a boolean specifying if an alpha test is needed.
  17005. */
  17006. needAlphaTesting(): boolean;
  17007. private _checkUniform;
  17008. /**
  17009. * Set a texture in the shader.
  17010. * @param name Define the name of the uniform samplers as defined in the shader
  17011. * @param texture Define the texture to bind to this sampler
  17012. * @return the material itself allowing "fluent" like uniform updates
  17013. */
  17014. setTexture(name: string, texture: Texture): ShaderMaterial;
  17015. /**
  17016. * Set a texture array in the shader.
  17017. * @param name Define the name of the uniform sampler array as defined in the shader
  17018. * @param textures Define the list of textures to bind to this sampler
  17019. * @return the material itself allowing "fluent" like uniform updates
  17020. */
  17021. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17022. /**
  17023. * Set a float in the shader.
  17024. * @param name Define the name of the uniform as defined in the shader
  17025. * @param value Define the value to give to the uniform
  17026. * @return the material itself allowing "fluent" like uniform updates
  17027. */
  17028. setFloat(name: string, value: number): ShaderMaterial;
  17029. /**
  17030. * Set a int in the shader.
  17031. * @param name Define the name of the uniform as defined in the shader
  17032. * @param value Define the value to give to the uniform
  17033. * @return the material itself allowing "fluent" like uniform updates
  17034. */
  17035. setInt(name: string, value: number): ShaderMaterial;
  17036. /**
  17037. * Set an array of floats in the shader.
  17038. * @param name Define the name of the uniform as defined in the shader
  17039. * @param value Define the value to give to the uniform
  17040. * @return the material itself allowing "fluent" like uniform updates
  17041. */
  17042. setFloats(name: string, value: number[]): ShaderMaterial;
  17043. /**
  17044. * Set a vec3 in the shader from a Color3.
  17045. * @param name Define the name of the uniform as defined in the shader
  17046. * @param value Define the value to give to the uniform
  17047. * @return the material itself allowing "fluent" like uniform updates
  17048. */
  17049. setColor3(name: string, value: Color3): ShaderMaterial;
  17050. /**
  17051. * Set a vec3 array in the shader from a Color3 array.
  17052. * @param name Define the name of the uniform as defined in the shader
  17053. * @param value Define the value to give to the uniform
  17054. * @return the material itself allowing "fluent" like uniform updates
  17055. */
  17056. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17057. /**
  17058. * Set a vec4 in the shader from a Color4.
  17059. * @param name Define the name of the uniform as defined in the shader
  17060. * @param value Define the value to give to the uniform
  17061. * @return the material itself allowing "fluent" like uniform updates
  17062. */
  17063. setColor4(name: string, value: Color4): ShaderMaterial;
  17064. /**
  17065. * Set a vec2 in the shader from a Vector2.
  17066. * @param name Define the name of the uniform as defined in the shader
  17067. * @param value Define the value to give to the uniform
  17068. * @return the material itself allowing "fluent" like uniform updates
  17069. */
  17070. setVector2(name: string, value: Vector2): ShaderMaterial;
  17071. /**
  17072. * Set a vec3 in the shader from a Vector3.
  17073. * @param name Define the name of the uniform as defined in the shader
  17074. * @param value Define the value to give to the uniform
  17075. * @return the material itself allowing "fluent" like uniform updates
  17076. */
  17077. setVector3(name: string, value: Vector3): ShaderMaterial;
  17078. /**
  17079. * Set a vec4 in the shader from a Vector4.
  17080. * @param name Define the name of the uniform as defined in the shader
  17081. * @param value Define the value to give to the uniform
  17082. * @return the material itself allowing "fluent" like uniform updates
  17083. */
  17084. setVector4(name: string, value: Vector4): ShaderMaterial;
  17085. /**
  17086. * Set a mat4 in the shader from a Matrix.
  17087. * @param name Define the name of the uniform as defined in the shader
  17088. * @param value Define the value to give to the uniform
  17089. * @return the material itself allowing "fluent" like uniform updates
  17090. */
  17091. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17092. /**
  17093. * Set a mat3 in the shader from a Float32Array.
  17094. * @param name Define the name of the uniform as defined in the shader
  17095. * @param value Define the value to give to the uniform
  17096. * @return the material itself allowing "fluent" like uniform updates
  17097. */
  17098. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17099. /**
  17100. * Set a mat2 in the shader from a Float32Array.
  17101. * @param name Define the name of the uniform as defined in the shader
  17102. * @param value Define the value to give to the uniform
  17103. * @return the material itself allowing "fluent" like uniform updates
  17104. */
  17105. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17106. /**
  17107. * Set a vec2 array in the shader from a number array.
  17108. * @param name Define the name of the uniform as defined in the shader
  17109. * @param value Define the value to give to the uniform
  17110. * @return the material itself allowing "fluent" like uniform updates
  17111. */
  17112. setArray2(name: string, value: number[]): ShaderMaterial;
  17113. /**
  17114. * Set a vec3 array in the shader from a number array.
  17115. * @param name Define the name of the uniform as defined in the shader
  17116. * @param value Define the value to give to the uniform
  17117. * @return the material itself allowing "fluent" like uniform updates
  17118. */
  17119. setArray3(name: string, value: number[]): ShaderMaterial;
  17120. private _checkCache;
  17121. /**
  17122. * Specifies that the submesh is ready to be used
  17123. * @param mesh defines the mesh to check
  17124. * @param subMesh defines which submesh to check
  17125. * @param useInstances specifies that instances should be used
  17126. * @returns a boolean indicating that the submesh is ready or not
  17127. */
  17128. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17129. /**
  17130. * Checks if the material is ready to render the requested mesh
  17131. * @param mesh Define the mesh to render
  17132. * @param useInstances Define whether or not the material is used with instances
  17133. * @returns true if ready, otherwise false
  17134. */
  17135. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17136. /**
  17137. * Binds the world matrix to the material
  17138. * @param world defines the world transformation matrix
  17139. */
  17140. bindOnlyWorldMatrix(world: Matrix): void;
  17141. /**
  17142. * Binds the material to the mesh
  17143. * @param world defines the world transformation matrix
  17144. * @param mesh defines the mesh to bind the material to
  17145. */
  17146. bind(world: Matrix, mesh?: Mesh): void;
  17147. /**
  17148. * Gets the active textures from the material
  17149. * @returns an array of textures
  17150. */
  17151. getActiveTextures(): BaseTexture[];
  17152. /**
  17153. * Specifies if the material uses a texture
  17154. * @param texture defines the texture to check against the material
  17155. * @returns a boolean specifying if the material uses the texture
  17156. */
  17157. hasTexture(texture: BaseTexture): boolean;
  17158. /**
  17159. * Makes a duplicate of the material, and gives it a new name
  17160. * @param name defines the new name for the duplicated material
  17161. * @returns the cloned material
  17162. */
  17163. clone(name: string): ShaderMaterial;
  17164. /**
  17165. * Disposes the material
  17166. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17167. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17168. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17169. */
  17170. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17171. /**
  17172. * Serializes this material in a JSON representation
  17173. * @returns the serialized material object
  17174. */
  17175. serialize(): any;
  17176. /**
  17177. * Creates a shader material from parsed shader material data
  17178. * @param source defines the JSON represnetation of the material
  17179. * @param scene defines the hosting scene
  17180. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17181. * @returns a new material
  17182. */
  17183. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17184. }
  17185. }
  17186. declare module BABYLON {
  17187. /** @hidden */
  17188. export var colorPixelShader: {
  17189. name: string;
  17190. shader: string;
  17191. };
  17192. }
  17193. declare module BABYLON {
  17194. /** @hidden */
  17195. export var colorVertexShader: {
  17196. name: string;
  17197. shader: string;
  17198. };
  17199. }
  17200. declare module BABYLON {
  17201. /**
  17202. * Line mesh
  17203. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17204. */
  17205. export class LinesMesh extends Mesh {
  17206. /**
  17207. * If vertex color should be applied to the mesh
  17208. */
  17209. useVertexColor?: boolean | undefined;
  17210. /**
  17211. * If vertex alpha should be applied to the mesh
  17212. */
  17213. useVertexAlpha?: boolean | undefined;
  17214. /**
  17215. * Color of the line (Default: White)
  17216. */
  17217. color: Color3;
  17218. /**
  17219. * Alpha of the line (Default: 1)
  17220. */
  17221. alpha: number;
  17222. /**
  17223. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17224. * This margin is expressed in world space coordinates, so its value may vary.
  17225. * Default value is 0.1
  17226. */
  17227. intersectionThreshold: number;
  17228. private _colorShader;
  17229. /**
  17230. * Creates a new LinesMesh
  17231. * @param name defines the name
  17232. * @param scene defines the hosting scene
  17233. * @param parent defines the parent mesh if any
  17234. * @param source defines the optional source LinesMesh used to clone data from
  17235. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17236. * When false, achieved by calling a clone(), also passing False.
  17237. * This will make creation of children, recursive.
  17238. * @param useVertexColor defines if this LinesMesh supports vertex color
  17239. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17240. */
  17241. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17242. /**
  17243. * If vertex color should be applied to the mesh
  17244. */
  17245. useVertexColor?: boolean | undefined,
  17246. /**
  17247. * If vertex alpha should be applied to the mesh
  17248. */
  17249. useVertexAlpha?: boolean | undefined);
  17250. private _addClipPlaneDefine;
  17251. private _removeClipPlaneDefine;
  17252. isReady(): boolean;
  17253. /**
  17254. * Returns the string "LineMesh"
  17255. */
  17256. getClassName(): string;
  17257. /**
  17258. * @hidden
  17259. */
  17260. /**
  17261. * @hidden
  17262. */
  17263. material: Material;
  17264. /**
  17265. * @hidden
  17266. */
  17267. readonly checkCollisions: boolean;
  17268. /** @hidden */
  17269. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17270. /** @hidden */
  17271. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17272. /**
  17273. * Disposes of the line mesh
  17274. * @param doNotRecurse If children should be disposed
  17275. */
  17276. dispose(doNotRecurse?: boolean): void;
  17277. /**
  17278. * Returns a new LineMesh object cloned from the current one.
  17279. */
  17280. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17281. /**
  17282. * Creates a new InstancedLinesMesh object from the mesh model.
  17283. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17284. * @param name defines the name of the new instance
  17285. * @returns a new InstancedLinesMesh
  17286. */
  17287. createInstance(name: string): InstancedLinesMesh;
  17288. }
  17289. /**
  17290. * Creates an instance based on a source LinesMesh
  17291. */
  17292. export class InstancedLinesMesh extends InstancedMesh {
  17293. /**
  17294. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17295. * This margin is expressed in world space coordinates, so its value may vary.
  17296. * Initilized with the intersectionThreshold value of the source LinesMesh
  17297. */
  17298. intersectionThreshold: number;
  17299. constructor(name: string, source: LinesMesh);
  17300. /**
  17301. * Returns the string "InstancedLinesMesh".
  17302. */
  17303. getClassName(): string;
  17304. }
  17305. }
  17306. declare module BABYLON {
  17307. /** @hidden */
  17308. export var linePixelShader: {
  17309. name: string;
  17310. shader: string;
  17311. };
  17312. }
  17313. declare module BABYLON {
  17314. /** @hidden */
  17315. export var lineVertexShader: {
  17316. name: string;
  17317. shader: string;
  17318. };
  17319. }
  17320. declare module BABYLON {
  17321. interface AbstractMesh {
  17322. /**
  17323. * Disables the mesh edge rendering mode
  17324. * @returns the currentAbstractMesh
  17325. */
  17326. disableEdgesRendering(): AbstractMesh;
  17327. /**
  17328. * Enables the edge rendering mode on the mesh.
  17329. * This mode makes the mesh edges visible
  17330. * @param epsilon defines the maximal distance between two angles to detect a face
  17331. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17332. * @returns the currentAbstractMesh
  17333. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17334. */
  17335. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17336. /**
  17337. * Gets the edgesRenderer associated with the mesh
  17338. */
  17339. edgesRenderer: Nullable<EdgesRenderer>;
  17340. }
  17341. interface LinesMesh {
  17342. /**
  17343. * Enables the edge rendering mode on the mesh.
  17344. * This mode makes the mesh edges visible
  17345. * @param epsilon defines the maximal distance between two angles to detect a face
  17346. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17347. * @returns the currentAbstractMesh
  17348. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17349. */
  17350. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17351. }
  17352. interface InstancedLinesMesh {
  17353. /**
  17354. * Enables the edge rendering mode on the mesh.
  17355. * This mode makes the mesh edges visible
  17356. * @param epsilon defines the maximal distance between two angles to detect a face
  17357. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17358. * @returns the current InstancedLinesMesh
  17359. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17360. */
  17361. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17362. }
  17363. /**
  17364. * Defines the minimum contract an Edges renderer should follow.
  17365. */
  17366. export interface IEdgesRenderer extends IDisposable {
  17367. /**
  17368. * Gets or sets a boolean indicating if the edgesRenderer is active
  17369. */
  17370. isEnabled: boolean;
  17371. /**
  17372. * Renders the edges of the attached mesh,
  17373. */
  17374. render(): void;
  17375. /**
  17376. * Checks wether or not the edges renderer is ready to render.
  17377. * @return true if ready, otherwise false.
  17378. */
  17379. isReady(): boolean;
  17380. }
  17381. /**
  17382. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17383. */
  17384. export class EdgesRenderer implements IEdgesRenderer {
  17385. /**
  17386. * Define the size of the edges with an orthographic camera
  17387. */
  17388. edgesWidthScalerForOrthographic: number;
  17389. /**
  17390. * Define the size of the edges with a perspective camera
  17391. */
  17392. edgesWidthScalerForPerspective: number;
  17393. protected _source: AbstractMesh;
  17394. protected _linesPositions: number[];
  17395. protected _linesNormals: number[];
  17396. protected _linesIndices: number[];
  17397. protected _epsilon: number;
  17398. protected _indicesCount: number;
  17399. protected _lineShader: ShaderMaterial;
  17400. protected _ib: DataBuffer;
  17401. protected _buffers: {
  17402. [key: string]: Nullable<VertexBuffer>;
  17403. };
  17404. protected _checkVerticesInsteadOfIndices: boolean;
  17405. private _meshRebuildObserver;
  17406. private _meshDisposeObserver;
  17407. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17408. isEnabled: boolean;
  17409. /**
  17410. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17411. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17412. * @param source Mesh used to create edges
  17413. * @param epsilon sum of angles in adjacency to check for edge
  17414. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17415. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17416. */
  17417. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17418. protected _prepareRessources(): void;
  17419. /** @hidden */
  17420. _rebuild(): void;
  17421. /**
  17422. * Releases the required resources for the edges renderer
  17423. */
  17424. dispose(): void;
  17425. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17426. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17427. /**
  17428. * Checks if the pair of p0 and p1 is en edge
  17429. * @param faceIndex
  17430. * @param edge
  17431. * @param faceNormals
  17432. * @param p0
  17433. * @param p1
  17434. * @private
  17435. */
  17436. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17437. /**
  17438. * push line into the position, normal and index buffer
  17439. * @protected
  17440. */
  17441. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17442. /**
  17443. * Generates lines edges from adjacencjes
  17444. * @private
  17445. */
  17446. _generateEdgesLines(): void;
  17447. /**
  17448. * Checks wether or not the edges renderer is ready to render.
  17449. * @return true if ready, otherwise false.
  17450. */
  17451. isReady(): boolean;
  17452. /**
  17453. * Renders the edges of the attached mesh,
  17454. */
  17455. render(): void;
  17456. }
  17457. /**
  17458. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17459. */
  17460. export class LineEdgesRenderer extends EdgesRenderer {
  17461. /**
  17462. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17463. * @param source LineMesh used to generate edges
  17464. * @param epsilon not important (specified angle for edge detection)
  17465. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17466. */
  17467. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17468. /**
  17469. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17470. */
  17471. _generateEdgesLines(): void;
  17472. }
  17473. }
  17474. declare module BABYLON {
  17475. /**
  17476. * This represents the object necessary to create a rendering group.
  17477. * This is exclusively used and created by the rendering manager.
  17478. * To modify the behavior, you use the available helpers in your scene or meshes.
  17479. * @hidden
  17480. */
  17481. export class RenderingGroup {
  17482. index: number;
  17483. private _scene;
  17484. private _opaqueSubMeshes;
  17485. private _transparentSubMeshes;
  17486. private _alphaTestSubMeshes;
  17487. private _depthOnlySubMeshes;
  17488. private _particleSystems;
  17489. private _spriteManagers;
  17490. private _opaqueSortCompareFn;
  17491. private _alphaTestSortCompareFn;
  17492. private _transparentSortCompareFn;
  17493. private _renderOpaque;
  17494. private _renderAlphaTest;
  17495. private _renderTransparent;
  17496. /** @hidden */
  17497. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17498. onBeforeTransparentRendering: () => void;
  17499. /**
  17500. * Set the opaque sort comparison function.
  17501. * If null the sub meshes will be render in the order they were created
  17502. */
  17503. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17504. /**
  17505. * Set the alpha test sort comparison function.
  17506. * If null the sub meshes will be render in the order they were created
  17507. */
  17508. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17509. /**
  17510. * Set the transparent sort comparison function.
  17511. * If null the sub meshes will be render in the order they were created
  17512. */
  17513. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17514. /**
  17515. * Creates a new rendering group.
  17516. * @param index The rendering group index
  17517. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17518. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17519. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17520. */
  17521. 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>);
  17522. /**
  17523. * Render all the sub meshes contained in the group.
  17524. * @param customRenderFunction Used to override the default render behaviour of the group.
  17525. * @returns true if rendered some submeshes.
  17526. */
  17527. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17528. /**
  17529. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17530. * @param subMeshes The submeshes to render
  17531. */
  17532. private renderOpaqueSorted;
  17533. /**
  17534. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17535. * @param subMeshes The submeshes to render
  17536. */
  17537. private renderAlphaTestSorted;
  17538. /**
  17539. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17540. * @param subMeshes The submeshes to render
  17541. */
  17542. private renderTransparentSorted;
  17543. /**
  17544. * Renders the submeshes in a specified order.
  17545. * @param subMeshes The submeshes to sort before render
  17546. * @param sortCompareFn The comparison function use to sort
  17547. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17548. * @param transparent Specifies to activate blending if true
  17549. */
  17550. private static renderSorted;
  17551. /**
  17552. * Renders the submeshes in the order they were dispatched (no sort applied).
  17553. * @param subMeshes The submeshes to render
  17554. */
  17555. private static renderUnsorted;
  17556. /**
  17557. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17558. * are rendered back to front if in the same alpha index.
  17559. *
  17560. * @param a The first submesh
  17561. * @param b The second submesh
  17562. * @returns The result of the comparison
  17563. */
  17564. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17565. /**
  17566. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17567. * are rendered back to front.
  17568. *
  17569. * @param a The first submesh
  17570. * @param b The second submesh
  17571. * @returns The result of the comparison
  17572. */
  17573. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17574. /**
  17575. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17576. * are rendered front to back (prevent overdraw).
  17577. *
  17578. * @param a The first submesh
  17579. * @param b The second submesh
  17580. * @returns The result of the comparison
  17581. */
  17582. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17583. /**
  17584. * Resets the different lists of submeshes to prepare a new frame.
  17585. */
  17586. prepare(): void;
  17587. dispose(): void;
  17588. /**
  17589. * Inserts the submesh in its correct queue depending on its material.
  17590. * @param subMesh The submesh to dispatch
  17591. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17592. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17593. */
  17594. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17595. dispatchSprites(spriteManager: ISpriteManager): void;
  17596. dispatchParticles(particleSystem: IParticleSystem): void;
  17597. private _renderParticles;
  17598. private _renderSprites;
  17599. }
  17600. }
  17601. declare module BABYLON {
  17602. /**
  17603. * Interface describing the different options available in the rendering manager
  17604. * regarding Auto Clear between groups.
  17605. */
  17606. export interface IRenderingManagerAutoClearSetup {
  17607. /**
  17608. * Defines whether or not autoclear is enable.
  17609. */
  17610. autoClear: boolean;
  17611. /**
  17612. * Defines whether or not to autoclear the depth buffer.
  17613. */
  17614. depth: boolean;
  17615. /**
  17616. * Defines whether or not to autoclear the stencil buffer.
  17617. */
  17618. stencil: boolean;
  17619. }
  17620. /**
  17621. * This class is used by the onRenderingGroupObservable
  17622. */
  17623. export class RenderingGroupInfo {
  17624. /**
  17625. * The Scene that being rendered
  17626. */
  17627. scene: Scene;
  17628. /**
  17629. * The camera currently used for the rendering pass
  17630. */
  17631. camera: Nullable<Camera>;
  17632. /**
  17633. * The ID of the renderingGroup being processed
  17634. */
  17635. renderingGroupId: number;
  17636. }
  17637. /**
  17638. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17639. * It is enable to manage the different groups as well as the different necessary sort functions.
  17640. * This should not be used directly aside of the few static configurations
  17641. */
  17642. export class RenderingManager {
  17643. /**
  17644. * The max id used for rendering groups (not included)
  17645. */
  17646. static MAX_RENDERINGGROUPS: number;
  17647. /**
  17648. * The min id used for rendering groups (included)
  17649. */
  17650. static MIN_RENDERINGGROUPS: number;
  17651. /**
  17652. * Used to globally prevent autoclearing scenes.
  17653. */
  17654. static AUTOCLEAR: boolean;
  17655. /**
  17656. * @hidden
  17657. */
  17658. _useSceneAutoClearSetup: boolean;
  17659. private _scene;
  17660. private _renderingGroups;
  17661. private _depthStencilBufferAlreadyCleaned;
  17662. private _autoClearDepthStencil;
  17663. private _customOpaqueSortCompareFn;
  17664. private _customAlphaTestSortCompareFn;
  17665. private _customTransparentSortCompareFn;
  17666. private _renderingGroupInfo;
  17667. /**
  17668. * Instantiates a new rendering group for a particular scene
  17669. * @param scene Defines the scene the groups belongs to
  17670. */
  17671. constructor(scene: Scene);
  17672. private _clearDepthStencilBuffer;
  17673. /**
  17674. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17675. * @hidden
  17676. */
  17677. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17678. /**
  17679. * Resets the different information of the group to prepare a new frame
  17680. * @hidden
  17681. */
  17682. reset(): void;
  17683. /**
  17684. * Dispose and release the group and its associated resources.
  17685. * @hidden
  17686. */
  17687. dispose(): void;
  17688. /**
  17689. * Clear the info related to rendering groups preventing retention points during dispose.
  17690. */
  17691. freeRenderingGroups(): void;
  17692. private _prepareRenderingGroup;
  17693. /**
  17694. * Add a sprite manager to the rendering manager in order to render it this frame.
  17695. * @param spriteManager Define the sprite manager to render
  17696. */
  17697. dispatchSprites(spriteManager: ISpriteManager): void;
  17698. /**
  17699. * Add a particle system to the rendering manager in order to render it this frame.
  17700. * @param particleSystem Define the particle system to render
  17701. */
  17702. dispatchParticles(particleSystem: IParticleSystem): void;
  17703. /**
  17704. * Add a submesh to the manager in order to render it this frame
  17705. * @param subMesh The submesh to dispatch
  17706. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17707. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17708. */
  17709. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17710. /**
  17711. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17712. * This allowed control for front to back rendering or reversly depending of the special needs.
  17713. *
  17714. * @param renderingGroupId The rendering group id corresponding to its index
  17715. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17716. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17717. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17718. */
  17719. 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;
  17720. /**
  17721. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17722. *
  17723. * @param renderingGroupId The rendering group id corresponding to its index
  17724. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17725. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17726. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17727. */
  17728. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17729. /**
  17730. * Gets the current auto clear configuration for one rendering group of the rendering
  17731. * manager.
  17732. * @param index the rendering group index to get the information for
  17733. * @returns The auto clear setup for the requested rendering group
  17734. */
  17735. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17736. }
  17737. }
  17738. declare module BABYLON {
  17739. /**
  17740. * This Helps creating a texture that will be created from a camera in your scene.
  17741. * It is basically a dynamic texture that could be used to create special effects for instance.
  17742. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17743. */
  17744. export class RenderTargetTexture extends Texture {
  17745. isCube: boolean;
  17746. /**
  17747. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17748. */
  17749. static readonly REFRESHRATE_RENDER_ONCE: number;
  17750. /**
  17751. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17752. */
  17753. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17754. /**
  17755. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17756. * the central point of your effect and can save a lot of performances.
  17757. */
  17758. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17759. /**
  17760. * Use this predicate to dynamically define the list of mesh you want to render.
  17761. * If set, the renderList property will be overwritten.
  17762. */
  17763. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17764. private _renderList;
  17765. /**
  17766. * Use this list to define the list of mesh you want to render.
  17767. */
  17768. renderList: Nullable<Array<AbstractMesh>>;
  17769. private _hookArray;
  17770. /**
  17771. * Define if particles should be rendered in your texture.
  17772. */
  17773. renderParticles: boolean;
  17774. /**
  17775. * Define if sprites should be rendered in your texture.
  17776. */
  17777. renderSprites: boolean;
  17778. /**
  17779. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17780. */
  17781. coordinatesMode: number;
  17782. /**
  17783. * Define the camera used to render the texture.
  17784. */
  17785. activeCamera: Nullable<Camera>;
  17786. /**
  17787. * Override the render function of the texture with your own one.
  17788. */
  17789. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17790. /**
  17791. * Define if camera post processes should be use while rendering the texture.
  17792. */
  17793. useCameraPostProcesses: boolean;
  17794. /**
  17795. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17796. */
  17797. ignoreCameraViewport: boolean;
  17798. private _postProcessManager;
  17799. private _postProcesses;
  17800. private _resizeObserver;
  17801. /**
  17802. * An event triggered when the texture is unbind.
  17803. */
  17804. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17805. /**
  17806. * An event triggered when the texture is unbind.
  17807. */
  17808. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17809. private _onAfterUnbindObserver;
  17810. /**
  17811. * Set a after unbind callback in the texture.
  17812. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17813. */
  17814. onAfterUnbind: () => void;
  17815. /**
  17816. * An event triggered before rendering the texture
  17817. */
  17818. onBeforeRenderObservable: Observable<number>;
  17819. private _onBeforeRenderObserver;
  17820. /**
  17821. * Set a before render callback in the texture.
  17822. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17823. */
  17824. onBeforeRender: (faceIndex: number) => void;
  17825. /**
  17826. * An event triggered after rendering the texture
  17827. */
  17828. onAfterRenderObservable: Observable<number>;
  17829. private _onAfterRenderObserver;
  17830. /**
  17831. * Set a after render callback in the texture.
  17832. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17833. */
  17834. onAfterRender: (faceIndex: number) => void;
  17835. /**
  17836. * An event triggered after the texture clear
  17837. */
  17838. onClearObservable: Observable<Engine>;
  17839. private _onClearObserver;
  17840. /**
  17841. * Set a clear callback in the texture.
  17842. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17843. */
  17844. onClear: (Engine: Engine) => void;
  17845. /**
  17846. * Define the clear color of the Render Target if it should be different from the scene.
  17847. */
  17848. clearColor: Color4;
  17849. protected _size: number | {
  17850. width: number;
  17851. height: number;
  17852. };
  17853. protected _initialSizeParameter: number | {
  17854. width: number;
  17855. height: number;
  17856. } | {
  17857. ratio: number;
  17858. };
  17859. protected _sizeRatio: Nullable<number>;
  17860. /** @hidden */
  17861. _generateMipMaps: boolean;
  17862. protected _renderingManager: RenderingManager;
  17863. /** @hidden */
  17864. _waitingRenderList: string[];
  17865. protected _doNotChangeAspectRatio: boolean;
  17866. protected _currentRefreshId: number;
  17867. protected _refreshRate: number;
  17868. protected _textureMatrix: Matrix;
  17869. protected _samples: number;
  17870. protected _renderTargetOptions: RenderTargetCreationOptions;
  17871. /**
  17872. * Gets render target creation options that were used.
  17873. */
  17874. readonly renderTargetOptions: RenderTargetCreationOptions;
  17875. protected _engine: Engine;
  17876. protected _onRatioRescale(): void;
  17877. /**
  17878. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17879. * It must define where the camera used to render the texture is set
  17880. */
  17881. boundingBoxPosition: Vector3;
  17882. private _boundingBoxSize;
  17883. /**
  17884. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17885. * When defined, the cubemap will switch to local mode
  17886. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17887. * @example https://www.babylonjs-playground.com/#RNASML
  17888. */
  17889. boundingBoxSize: Vector3;
  17890. /**
  17891. * In case the RTT has been created with a depth texture, get the associated
  17892. * depth texture.
  17893. * Otherwise, return null.
  17894. */
  17895. depthStencilTexture: Nullable<InternalTexture>;
  17896. /**
  17897. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17898. * or used a shadow, depth texture...
  17899. * @param name The friendly name of the texture
  17900. * @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)
  17901. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17902. * @param generateMipMaps True if mip maps need to be generated after render.
  17903. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17904. * @param type The type of the buffer in the RTT (int, half float, float...)
  17905. * @param isCube True if a cube texture needs to be created
  17906. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17907. * @param generateDepthBuffer True to generate a depth buffer
  17908. * @param generateStencilBuffer True to generate a stencil buffer
  17909. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17910. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17911. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17912. */
  17913. constructor(name: string, size: number | {
  17914. width: number;
  17915. height: number;
  17916. } | {
  17917. ratio: number;
  17918. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17919. /**
  17920. * Creates a depth stencil texture.
  17921. * This is only available in WebGL 2 or with the depth texture extension available.
  17922. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17923. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17924. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17925. */
  17926. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17927. private _processSizeParameter;
  17928. /**
  17929. * Define the number of samples to use in case of MSAA.
  17930. * It defaults to one meaning no MSAA has been enabled.
  17931. */
  17932. samples: number;
  17933. /**
  17934. * Resets the refresh counter of the texture and start bak from scratch.
  17935. * Could be useful to regenerate the texture if it is setup to render only once.
  17936. */
  17937. resetRefreshCounter(): void;
  17938. /**
  17939. * Define the refresh rate of the texture or the rendering frequency.
  17940. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17941. */
  17942. refreshRate: number;
  17943. /**
  17944. * Adds a post process to the render target rendering passes.
  17945. * @param postProcess define the post process to add
  17946. */
  17947. addPostProcess(postProcess: PostProcess): void;
  17948. /**
  17949. * Clear all the post processes attached to the render target
  17950. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17951. */
  17952. clearPostProcesses(dispose?: boolean): void;
  17953. /**
  17954. * Remove one of the post process from the list of attached post processes to the texture
  17955. * @param postProcess define the post process to remove from the list
  17956. */
  17957. removePostProcess(postProcess: PostProcess): void;
  17958. /** @hidden */
  17959. _shouldRender(): boolean;
  17960. /**
  17961. * Gets the actual render size of the texture.
  17962. * @returns the width of the render size
  17963. */
  17964. getRenderSize(): number;
  17965. /**
  17966. * Gets the actual render width of the texture.
  17967. * @returns the width of the render size
  17968. */
  17969. getRenderWidth(): number;
  17970. /**
  17971. * Gets the actual render height of the texture.
  17972. * @returns the height of the render size
  17973. */
  17974. getRenderHeight(): number;
  17975. /**
  17976. * Get if the texture can be rescaled or not.
  17977. */
  17978. readonly canRescale: boolean;
  17979. /**
  17980. * Resize the texture using a ratio.
  17981. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17982. */
  17983. scale(ratio: number): void;
  17984. /**
  17985. * Get the texture reflection matrix used to rotate/transform the reflection.
  17986. * @returns the reflection matrix
  17987. */
  17988. getReflectionTextureMatrix(): Matrix;
  17989. /**
  17990. * Resize the texture to a new desired size.
  17991. * Be carrefull as it will recreate all the data in the new texture.
  17992. * @param size Define the new size. It can be:
  17993. * - a number for squared texture,
  17994. * - an object containing { width: number, height: number }
  17995. * - or an object containing a ratio { ratio: number }
  17996. */
  17997. resize(size: number | {
  17998. width: number;
  17999. height: number;
  18000. } | {
  18001. ratio: number;
  18002. }): void;
  18003. /**
  18004. * Renders all the objects from the render list into the texture.
  18005. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18006. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18007. */
  18008. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18009. private _bestReflectionRenderTargetDimension;
  18010. /**
  18011. * @hidden
  18012. * @param faceIndex face index to bind to if this is a cubetexture
  18013. */
  18014. _bindFrameBuffer(faceIndex?: number): void;
  18015. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18016. private renderToTarget;
  18017. /**
  18018. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18019. * This allowed control for front to back rendering or reversly depending of the special needs.
  18020. *
  18021. * @param renderingGroupId The rendering group id corresponding to its index
  18022. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18023. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18024. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18025. */
  18026. 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;
  18027. /**
  18028. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18029. *
  18030. * @param renderingGroupId The rendering group id corresponding to its index
  18031. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18032. */
  18033. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18034. /**
  18035. * Clones the texture.
  18036. * @returns the cloned texture
  18037. */
  18038. clone(): RenderTargetTexture;
  18039. /**
  18040. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18041. * @returns The JSON representation of the texture
  18042. */
  18043. serialize(): any;
  18044. /**
  18045. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18046. */
  18047. disposeFramebufferObjects(): void;
  18048. /**
  18049. * Dispose the texture and release its associated resources.
  18050. */
  18051. dispose(): void;
  18052. /** @hidden */
  18053. _rebuild(): void;
  18054. /**
  18055. * Clear the info related to rendering groups preventing retention point in material dispose.
  18056. */
  18057. freeRenderingGroups(): void;
  18058. /**
  18059. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18060. * @returns the view count
  18061. */
  18062. getViewCount(): number;
  18063. }
  18064. }
  18065. declare module BABYLON {
  18066. /**
  18067. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18068. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18069. * You can then easily use it as a reflectionTexture on a flat surface.
  18070. * In case the surface is not a plane, please consider relying on reflection probes.
  18071. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18072. */
  18073. export class MirrorTexture extends RenderTargetTexture {
  18074. private scene;
  18075. /**
  18076. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18077. * 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.
  18078. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18079. */
  18080. mirrorPlane: Plane;
  18081. /**
  18082. * Define the blur ratio used to blur the reflection if needed.
  18083. */
  18084. blurRatio: number;
  18085. /**
  18086. * Define the adaptive blur kernel used to blur the reflection if needed.
  18087. * This will autocompute the closest best match for the `blurKernel`
  18088. */
  18089. adaptiveBlurKernel: number;
  18090. /**
  18091. * Define the blur kernel used to blur the reflection if needed.
  18092. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18093. */
  18094. blurKernel: number;
  18095. /**
  18096. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18097. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18098. */
  18099. blurKernelX: number;
  18100. /**
  18101. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18102. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18103. */
  18104. blurKernelY: number;
  18105. private _autoComputeBlurKernel;
  18106. protected _onRatioRescale(): void;
  18107. private _updateGammaSpace;
  18108. private _imageProcessingConfigChangeObserver;
  18109. private _transformMatrix;
  18110. private _mirrorMatrix;
  18111. private _savedViewMatrix;
  18112. private _blurX;
  18113. private _blurY;
  18114. private _adaptiveBlurKernel;
  18115. private _blurKernelX;
  18116. private _blurKernelY;
  18117. private _blurRatio;
  18118. /**
  18119. * Instantiates a Mirror Texture.
  18120. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18121. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18122. * You can then easily use it as a reflectionTexture on a flat surface.
  18123. * In case the surface is not a plane, please consider relying on reflection probes.
  18124. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18125. * @param name
  18126. * @param size
  18127. * @param scene
  18128. * @param generateMipMaps
  18129. * @param type
  18130. * @param samplingMode
  18131. * @param generateDepthBuffer
  18132. */
  18133. constructor(name: string, size: number | {
  18134. width: number;
  18135. height: number;
  18136. } | {
  18137. ratio: number;
  18138. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18139. private _preparePostProcesses;
  18140. /**
  18141. * Clone the mirror texture.
  18142. * @returns the cloned texture
  18143. */
  18144. clone(): MirrorTexture;
  18145. /**
  18146. * Serialize the texture to a JSON representation you could use in Parse later on
  18147. * @returns the serialized JSON representation
  18148. */
  18149. serialize(): any;
  18150. /**
  18151. * Dispose the texture and release its associated resources.
  18152. */
  18153. dispose(): void;
  18154. }
  18155. }
  18156. declare module BABYLON {
  18157. /**
  18158. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18159. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18160. */
  18161. export class Texture extends BaseTexture {
  18162. /** @hidden */
  18163. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18164. /** @hidden */
  18165. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18166. /** @hidden */
  18167. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18168. /** nearest is mag = nearest and min = nearest and mip = linear */
  18169. static readonly NEAREST_SAMPLINGMODE: number;
  18170. /** nearest is mag = nearest and min = nearest and mip = linear */
  18171. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18172. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18173. static readonly BILINEAR_SAMPLINGMODE: number;
  18174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18175. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18176. /** Trilinear is mag = linear and min = linear and mip = linear */
  18177. static readonly TRILINEAR_SAMPLINGMODE: number;
  18178. /** Trilinear is mag = linear and min = linear and mip = linear */
  18179. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18180. /** mag = nearest and min = nearest and mip = nearest */
  18181. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18182. /** mag = nearest and min = linear and mip = nearest */
  18183. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18184. /** mag = nearest and min = linear and mip = linear */
  18185. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18186. /** mag = nearest and min = linear and mip = none */
  18187. static readonly NEAREST_LINEAR: number;
  18188. /** mag = nearest and min = nearest and mip = none */
  18189. static readonly NEAREST_NEAREST: number;
  18190. /** mag = linear and min = nearest and mip = nearest */
  18191. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18192. /** mag = linear and min = nearest and mip = linear */
  18193. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18194. /** mag = linear and min = linear and mip = none */
  18195. static readonly LINEAR_LINEAR: number;
  18196. /** mag = linear and min = nearest and mip = none */
  18197. static readonly LINEAR_NEAREST: number;
  18198. /** Explicit coordinates mode */
  18199. static readonly EXPLICIT_MODE: number;
  18200. /** Spherical coordinates mode */
  18201. static readonly SPHERICAL_MODE: number;
  18202. /** Planar coordinates mode */
  18203. static readonly PLANAR_MODE: number;
  18204. /** Cubic coordinates mode */
  18205. static readonly CUBIC_MODE: number;
  18206. /** Projection coordinates mode */
  18207. static readonly PROJECTION_MODE: number;
  18208. /** Inverse Cubic coordinates mode */
  18209. static readonly SKYBOX_MODE: number;
  18210. /** Inverse Cubic coordinates mode */
  18211. static readonly INVCUBIC_MODE: number;
  18212. /** Equirectangular coordinates mode */
  18213. static readonly EQUIRECTANGULAR_MODE: number;
  18214. /** Equirectangular Fixed coordinates mode */
  18215. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18216. /** Equirectangular Fixed Mirrored coordinates mode */
  18217. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18218. /** Texture is not repeating outside of 0..1 UVs */
  18219. static readonly CLAMP_ADDRESSMODE: number;
  18220. /** Texture is repeating outside of 0..1 UVs */
  18221. static readonly WRAP_ADDRESSMODE: number;
  18222. /** Texture is repeating and mirrored */
  18223. static readonly MIRROR_ADDRESSMODE: number;
  18224. /**
  18225. * 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
  18226. */
  18227. static UseSerializedUrlIfAny: boolean;
  18228. /**
  18229. * Define the url of the texture.
  18230. */
  18231. url: Nullable<string>;
  18232. /**
  18233. * Define an offset on the texture to offset the u coordinates of the UVs
  18234. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18235. */
  18236. uOffset: number;
  18237. /**
  18238. * Define an offset on the texture to offset the v coordinates of the UVs
  18239. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18240. */
  18241. vOffset: number;
  18242. /**
  18243. * Define an offset on the texture to scale the u coordinates of the UVs
  18244. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18245. */
  18246. uScale: number;
  18247. /**
  18248. * Define an offset on the texture to scale the v coordinates of the UVs
  18249. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18250. */
  18251. vScale: number;
  18252. /**
  18253. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18254. * @see http://doc.babylonjs.com/how_to/more_materials
  18255. */
  18256. uAng: number;
  18257. /**
  18258. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18259. * @see http://doc.babylonjs.com/how_to/more_materials
  18260. */
  18261. vAng: number;
  18262. /**
  18263. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18264. * @see http://doc.babylonjs.com/how_to/more_materials
  18265. */
  18266. wAng: number;
  18267. /**
  18268. * Defines the center of rotation (U)
  18269. */
  18270. uRotationCenter: number;
  18271. /**
  18272. * Defines the center of rotation (V)
  18273. */
  18274. vRotationCenter: number;
  18275. /**
  18276. * Defines the center of rotation (W)
  18277. */
  18278. wRotationCenter: number;
  18279. /**
  18280. * Are mip maps generated for this texture or not.
  18281. */
  18282. readonly noMipmap: boolean;
  18283. /**
  18284. * List of inspectable custom properties (used by the Inspector)
  18285. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18286. */
  18287. inspectableCustomProperties: Nullable<IInspectable[]>;
  18288. private _noMipmap;
  18289. /** @hidden */
  18290. _invertY: boolean;
  18291. private _rowGenerationMatrix;
  18292. private _cachedTextureMatrix;
  18293. private _projectionModeMatrix;
  18294. private _t0;
  18295. private _t1;
  18296. private _t2;
  18297. private _cachedUOffset;
  18298. private _cachedVOffset;
  18299. private _cachedUScale;
  18300. private _cachedVScale;
  18301. private _cachedUAng;
  18302. private _cachedVAng;
  18303. private _cachedWAng;
  18304. private _cachedProjectionMatrixId;
  18305. private _cachedCoordinatesMode;
  18306. /** @hidden */
  18307. protected _initialSamplingMode: number;
  18308. /** @hidden */
  18309. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18310. private _deleteBuffer;
  18311. protected _format: Nullable<number>;
  18312. private _delayedOnLoad;
  18313. private _delayedOnError;
  18314. /**
  18315. * Observable triggered once the texture has been loaded.
  18316. */
  18317. onLoadObservable: Observable<Texture>;
  18318. protected _isBlocking: boolean;
  18319. /**
  18320. * Is the texture preventing material to render while loading.
  18321. * If false, a default texture will be used instead of the loading one during the preparation step.
  18322. */
  18323. isBlocking: boolean;
  18324. /**
  18325. * Get the current sampling mode associated with the texture.
  18326. */
  18327. readonly samplingMode: number;
  18328. /**
  18329. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18330. */
  18331. readonly invertY: boolean;
  18332. /**
  18333. * Instantiates a new texture.
  18334. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18335. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18336. * @param url define the url of the picture to load as a texture
  18337. * @param scene define the scene the texture will belong to
  18338. * @param noMipmap define if the texture will require mip maps or not
  18339. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18340. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18341. * @param onLoad define a callback triggered when the texture has been loaded
  18342. * @param onError define a callback triggered when an error occurred during the loading session
  18343. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18344. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18345. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18346. */
  18347. 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);
  18348. /**
  18349. * Update the url (and optional buffer) of this texture if url was null during construction.
  18350. * @param url the url of the texture
  18351. * @param buffer the buffer of the texture (defaults to null)
  18352. * @param onLoad callback called when the texture is loaded (defaults to null)
  18353. */
  18354. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18355. /**
  18356. * Finish the loading sequence of a texture flagged as delayed load.
  18357. * @hidden
  18358. */
  18359. delayLoad(): void;
  18360. private _prepareRowForTextureGeneration;
  18361. /**
  18362. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18363. * @returns the transform matrix of the texture.
  18364. */
  18365. getTextureMatrix(): Matrix;
  18366. /**
  18367. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18368. * @returns The reflection texture transform
  18369. */
  18370. getReflectionTextureMatrix(): Matrix;
  18371. /**
  18372. * Clones the texture.
  18373. * @returns the cloned texture
  18374. */
  18375. clone(): Texture;
  18376. /**
  18377. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18378. * @returns The JSON representation of the texture
  18379. */
  18380. serialize(): any;
  18381. /**
  18382. * Get the current class name of the texture useful for serialization or dynamic coding.
  18383. * @returns "Texture"
  18384. */
  18385. getClassName(): string;
  18386. /**
  18387. * Dispose the texture and release its associated resources.
  18388. */
  18389. dispose(): void;
  18390. /**
  18391. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18392. * @param parsedTexture Define the JSON representation of the texture
  18393. * @param scene Define the scene the parsed texture should be instantiated in
  18394. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18395. * @returns The parsed texture if successful
  18396. */
  18397. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18398. /**
  18399. * Creates a texture from its base 64 representation.
  18400. * @param data Define the base64 payload without the data: prefix
  18401. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18402. * @param scene Define the scene the texture should belong to
  18403. * @param noMipmap Forces the texture to not create mip map information if true
  18404. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18405. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18406. * @param onLoad define a callback triggered when the texture has been loaded
  18407. * @param onError define a callback triggered when an error occurred during the loading session
  18408. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18409. * @returns the created texture
  18410. */
  18411. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18412. /**
  18413. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18414. * @param data Define the base64 payload without the data: prefix
  18415. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18416. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18417. * @param scene Define the scene the texture should belong to
  18418. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18419. * @param noMipmap Forces the texture to not create mip map information if true
  18420. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18421. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18422. * @param onLoad define a callback triggered when the texture has been loaded
  18423. * @param onError define a callback triggered when an error occurred during the loading session
  18424. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18425. * @returns the created texture
  18426. */
  18427. 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;
  18428. }
  18429. }
  18430. declare module BABYLON {
  18431. interface Engine {
  18432. /**
  18433. * Creates a raw texture
  18434. * @param data defines the data to store in the texture
  18435. * @param width defines the width of the texture
  18436. * @param height defines the height of the texture
  18437. * @param format defines the format of the data
  18438. * @param generateMipMaps defines if the engine should generate the mip levels
  18439. * @param invertY defines if data must be stored with Y axis inverted
  18440. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18441. * @param compression defines the compression used (null by default)
  18442. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18443. * @returns the raw texture inside an InternalTexture
  18444. */
  18445. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18446. /**
  18447. * Update a raw texture
  18448. * @param texture defines the texture to update
  18449. * @param data defines the data to store in the texture
  18450. * @param format defines the format of the data
  18451. * @param invertY defines if data must be stored with Y axis inverted
  18452. */
  18453. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18454. /**
  18455. * Update a raw texture
  18456. * @param texture defines the texture to update
  18457. * @param data defines the data to store in the texture
  18458. * @param format defines the format of the data
  18459. * @param invertY defines if data must be stored with Y axis inverted
  18460. * @param compression defines the compression used (null by default)
  18461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18462. */
  18463. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18464. /**
  18465. * Creates a new raw cube texture
  18466. * @param data defines the array of data to use to create each face
  18467. * @param size defines the size of the textures
  18468. * @param format defines the format of the data
  18469. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18470. * @param generateMipMaps defines if the engine should generate the mip levels
  18471. * @param invertY defines if data must be stored with Y axis inverted
  18472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18473. * @param compression defines the compression used (null by default)
  18474. * @returns the cube texture as an InternalTexture
  18475. */
  18476. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18477. /**
  18478. * Update a raw cube texture
  18479. * @param texture defines the texture to udpdate
  18480. * @param data defines the data to store
  18481. * @param format defines the data format
  18482. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18483. * @param invertY defines if data must be stored with Y axis inverted
  18484. */
  18485. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18486. /**
  18487. * Update a raw cube texture
  18488. * @param texture defines the texture to udpdate
  18489. * @param data defines the data to store
  18490. * @param format defines the data format
  18491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18492. * @param invertY defines if data must be stored with Y axis inverted
  18493. * @param compression defines the compression used (null by default)
  18494. */
  18495. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18496. /**
  18497. * Update a raw cube texture
  18498. * @param texture defines the texture to udpdate
  18499. * @param data defines the data to store
  18500. * @param format defines the data format
  18501. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18502. * @param invertY defines if data must be stored with Y axis inverted
  18503. * @param compression defines the compression used (null by default)
  18504. * @param level defines which level of the texture to update
  18505. */
  18506. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18507. /**
  18508. * Creates a new raw cube texture from a specified url
  18509. * @param url defines the url where the data is located
  18510. * @param scene defines the current scene
  18511. * @param size defines the size of the textures
  18512. * @param format defines the format of the data
  18513. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18514. * @param noMipmap defines if the engine should avoid generating the mip levels
  18515. * @param callback defines a callback used to extract texture data from loaded data
  18516. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18517. * @param onLoad defines a callback called when texture is loaded
  18518. * @param onError defines a callback called if there is an error
  18519. * @returns the cube texture as an InternalTexture
  18520. */
  18521. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  18522. /**
  18523. * Creates a new raw cube texture from a specified url
  18524. * @param url defines the url where the data is located
  18525. * @param scene defines the current scene
  18526. * @param size defines the size of the textures
  18527. * @param format defines the format of the data
  18528. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18529. * @param noMipmap defines if the engine should avoid generating the mip levels
  18530. * @param callback defines a callback used to extract texture data from loaded data
  18531. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18532. * @param onLoad defines a callback called when texture is loaded
  18533. * @param onError defines a callback called if there is an error
  18534. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18535. * @param invertY defines if data must be stored with Y axis inverted
  18536. * @returns the cube texture as an InternalTexture
  18537. */
  18538. 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;
  18539. /**
  18540. * Creates a new raw 3D texture
  18541. * @param data defines the data used to create the texture
  18542. * @param width defines the width of the texture
  18543. * @param height defines the height of the texture
  18544. * @param depth defines the depth of the texture
  18545. * @param format defines the format of the texture
  18546. * @param generateMipMaps defines if the engine must generate mip levels
  18547. * @param invertY defines if data must be stored with Y axis inverted
  18548. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18549. * @param compression defines the compressed used (can be null)
  18550. * @param textureType defines the compressed used (can be null)
  18551. * @returns a new raw 3D texture (stored in an InternalTexture)
  18552. */
  18553. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18554. /**
  18555. * Update a raw 3D texture
  18556. * @param texture defines the texture to update
  18557. * @param data defines the data to store
  18558. * @param format defines the data format
  18559. * @param invertY defines if data must be stored with Y axis inverted
  18560. */
  18561. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18562. /**
  18563. * Update a raw 3D texture
  18564. * @param texture defines the texture to update
  18565. * @param data defines the data to store
  18566. * @param format defines the data format
  18567. * @param invertY defines if data must be stored with Y axis inverted
  18568. * @param compression defines the used compression (can be null)
  18569. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18570. */
  18571. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18572. }
  18573. }
  18574. declare module BABYLON {
  18575. /**
  18576. * Raw texture can help creating a texture directly from an array of data.
  18577. * This can be super useful if you either get the data from an uncompressed source or
  18578. * if you wish to create your texture pixel by pixel.
  18579. */
  18580. export class RawTexture extends Texture {
  18581. /**
  18582. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18583. */
  18584. format: number;
  18585. private _engine;
  18586. /**
  18587. * Instantiates a new RawTexture.
  18588. * Raw texture can help creating a texture directly from an array of data.
  18589. * This can be super useful if you either get the data from an uncompressed source or
  18590. * if you wish to create your texture pixel by pixel.
  18591. * @param data define the array of data to use to create the texture
  18592. * @param width define the width of the texture
  18593. * @param height define the height of the texture
  18594. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18595. * @param scene define the scene the texture belongs to
  18596. * @param generateMipMaps define whether mip maps should be generated or not
  18597. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18598. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18599. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18600. */
  18601. constructor(data: ArrayBufferView, width: number, height: number,
  18602. /**
  18603. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18604. */
  18605. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18606. /**
  18607. * Updates the texture underlying data.
  18608. * @param data Define the new data of the texture
  18609. */
  18610. update(data: ArrayBufferView): void;
  18611. /**
  18612. * Creates a luminance texture from some data.
  18613. * @param data Define the texture data
  18614. * @param width Define the width of the texture
  18615. * @param height Define the height of the texture
  18616. * @param scene Define the scene the texture belongs to
  18617. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18618. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18619. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18620. * @returns the luminance texture
  18621. */
  18622. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18623. /**
  18624. * Creates a luminance alpha texture from some data.
  18625. * @param data Define the texture data
  18626. * @param width Define the width of the texture
  18627. * @param height Define the height of the texture
  18628. * @param scene Define the scene the texture belongs to
  18629. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18630. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18631. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18632. * @returns the luminance alpha texture
  18633. */
  18634. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18635. /**
  18636. * Creates an alpha texture from some data.
  18637. * @param data Define the texture data
  18638. * @param width Define the width of the texture
  18639. * @param height Define the height of the texture
  18640. * @param scene Define the scene the texture belongs to
  18641. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18642. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18643. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18644. * @returns the alpha texture
  18645. */
  18646. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18647. /**
  18648. * Creates a RGB texture from some data.
  18649. * @param data Define the texture data
  18650. * @param width Define the width of the texture
  18651. * @param height Define the height of the texture
  18652. * @param scene Define the scene the texture belongs to
  18653. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18656. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18657. * @returns the RGB alpha texture
  18658. */
  18659. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18660. /**
  18661. * Creates a RGBA texture from some data.
  18662. * @param data Define the texture data
  18663. * @param width Define the width of the texture
  18664. * @param height Define the height of the texture
  18665. * @param scene Define the scene the texture belongs to
  18666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18669. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18670. * @returns the RGBA texture
  18671. */
  18672. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18673. /**
  18674. * Creates a R texture from some data.
  18675. * @param data Define the texture data
  18676. * @param width Define the width of the texture
  18677. * @param height Define the height of the texture
  18678. * @param scene Define the scene the texture belongs to
  18679. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18680. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18681. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18682. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18683. * @returns the R texture
  18684. */
  18685. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18686. }
  18687. }
  18688. declare module BABYLON {
  18689. /**
  18690. * Defines a runtime animation
  18691. */
  18692. export class RuntimeAnimation {
  18693. private _events;
  18694. /**
  18695. * The current frame of the runtime animation
  18696. */
  18697. private _currentFrame;
  18698. /**
  18699. * The animation used by the runtime animation
  18700. */
  18701. private _animation;
  18702. /**
  18703. * The target of the runtime animation
  18704. */
  18705. private _target;
  18706. /**
  18707. * The initiating animatable
  18708. */
  18709. private _host;
  18710. /**
  18711. * The original value of the runtime animation
  18712. */
  18713. private _originalValue;
  18714. /**
  18715. * The original blend value of the runtime animation
  18716. */
  18717. private _originalBlendValue;
  18718. /**
  18719. * The offsets cache of the runtime animation
  18720. */
  18721. private _offsetsCache;
  18722. /**
  18723. * The high limits cache of the runtime animation
  18724. */
  18725. private _highLimitsCache;
  18726. /**
  18727. * Specifies if the runtime animation has been stopped
  18728. */
  18729. private _stopped;
  18730. /**
  18731. * The blending factor of the runtime animation
  18732. */
  18733. private _blendingFactor;
  18734. /**
  18735. * The BabylonJS scene
  18736. */
  18737. private _scene;
  18738. /**
  18739. * The current value of the runtime animation
  18740. */
  18741. private _currentValue;
  18742. /** @hidden */
  18743. _animationState: _IAnimationState;
  18744. /**
  18745. * The active target of the runtime animation
  18746. */
  18747. private _activeTargets;
  18748. private _currentActiveTarget;
  18749. private _directTarget;
  18750. /**
  18751. * The target path of the runtime animation
  18752. */
  18753. private _targetPath;
  18754. /**
  18755. * The weight of the runtime animation
  18756. */
  18757. private _weight;
  18758. /**
  18759. * The ratio offset of the runtime animation
  18760. */
  18761. private _ratioOffset;
  18762. /**
  18763. * The previous delay of the runtime animation
  18764. */
  18765. private _previousDelay;
  18766. /**
  18767. * The previous ratio of the runtime animation
  18768. */
  18769. private _previousRatio;
  18770. private _enableBlending;
  18771. private _keys;
  18772. private _minFrame;
  18773. private _maxFrame;
  18774. private _minValue;
  18775. private _maxValue;
  18776. private _targetIsArray;
  18777. /**
  18778. * Gets the current frame of the runtime animation
  18779. */
  18780. readonly currentFrame: number;
  18781. /**
  18782. * Gets the weight of the runtime animation
  18783. */
  18784. readonly weight: number;
  18785. /**
  18786. * Gets the current value of the runtime animation
  18787. */
  18788. readonly currentValue: any;
  18789. /**
  18790. * Gets the target path of the runtime animation
  18791. */
  18792. readonly targetPath: string;
  18793. /**
  18794. * Gets the actual target of the runtime animation
  18795. */
  18796. readonly target: any;
  18797. /** @hidden */
  18798. _onLoop: () => void;
  18799. /**
  18800. * Create a new RuntimeAnimation object
  18801. * @param target defines the target of the animation
  18802. * @param animation defines the source animation object
  18803. * @param scene defines the hosting scene
  18804. * @param host defines the initiating Animatable
  18805. */
  18806. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18807. private _preparePath;
  18808. /**
  18809. * Gets the animation from the runtime animation
  18810. */
  18811. readonly animation: Animation;
  18812. /**
  18813. * Resets the runtime animation to the beginning
  18814. * @param restoreOriginal defines whether to restore the target property to the original value
  18815. */
  18816. reset(restoreOriginal?: boolean): void;
  18817. /**
  18818. * Specifies if the runtime animation is stopped
  18819. * @returns Boolean specifying if the runtime animation is stopped
  18820. */
  18821. isStopped(): boolean;
  18822. /**
  18823. * Disposes of the runtime animation
  18824. */
  18825. dispose(): void;
  18826. /**
  18827. * Apply the interpolated value to the target
  18828. * @param currentValue defines the value computed by the animation
  18829. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18830. */
  18831. setValue(currentValue: any, weight: number): void;
  18832. private _getOriginalValues;
  18833. private _setValue;
  18834. /**
  18835. * Gets the loop pmode of the runtime animation
  18836. * @returns Loop Mode
  18837. */
  18838. private _getCorrectLoopMode;
  18839. /**
  18840. * Move the current animation to a given frame
  18841. * @param frame defines the frame to move to
  18842. */
  18843. goToFrame(frame: number): void;
  18844. /**
  18845. * @hidden Internal use only
  18846. */
  18847. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18848. /**
  18849. * Execute the current animation
  18850. * @param delay defines the delay to add to the current frame
  18851. * @param from defines the lower bound of the animation range
  18852. * @param to defines the upper bound of the animation range
  18853. * @param loop defines if the current animation must loop
  18854. * @param speedRatio defines the current speed ratio
  18855. * @param weight defines the weight of the animation (default is -1 so no weight)
  18856. * @param onLoop optional callback called when animation loops
  18857. * @returns a boolean indicating if the animation is running
  18858. */
  18859. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18860. }
  18861. }
  18862. declare module BABYLON {
  18863. /**
  18864. * Class used to store an actual running animation
  18865. */
  18866. export class Animatable {
  18867. /** defines the target object */
  18868. target: any;
  18869. /** defines the starting frame number (default is 0) */
  18870. fromFrame: number;
  18871. /** defines the ending frame number (default is 100) */
  18872. toFrame: number;
  18873. /** defines if the animation must loop (default is false) */
  18874. loopAnimation: boolean;
  18875. /** defines a callback to call when animation ends if it is not looping */
  18876. onAnimationEnd?: (() => void) | null | undefined;
  18877. /** defines a callback to call when animation loops */
  18878. onAnimationLoop?: (() => void) | null | undefined;
  18879. private _localDelayOffset;
  18880. private _pausedDelay;
  18881. private _runtimeAnimations;
  18882. private _paused;
  18883. private _scene;
  18884. private _speedRatio;
  18885. private _weight;
  18886. private _syncRoot;
  18887. /**
  18888. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18889. * This will only apply for non looping animation (default is true)
  18890. */
  18891. disposeOnEnd: boolean;
  18892. /**
  18893. * Gets a boolean indicating if the animation has started
  18894. */
  18895. animationStarted: boolean;
  18896. /**
  18897. * Observer raised when the animation ends
  18898. */
  18899. onAnimationEndObservable: Observable<Animatable>;
  18900. /**
  18901. * Observer raised when the animation loops
  18902. */
  18903. onAnimationLoopObservable: Observable<Animatable>;
  18904. /**
  18905. * Gets the root Animatable used to synchronize and normalize animations
  18906. */
  18907. readonly syncRoot: Nullable<Animatable>;
  18908. /**
  18909. * Gets the current frame of the first RuntimeAnimation
  18910. * Used to synchronize Animatables
  18911. */
  18912. readonly masterFrame: number;
  18913. /**
  18914. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18915. */
  18916. weight: number;
  18917. /**
  18918. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18919. */
  18920. speedRatio: number;
  18921. /**
  18922. * Creates a new Animatable
  18923. * @param scene defines the hosting scene
  18924. * @param target defines the target object
  18925. * @param fromFrame defines the starting frame number (default is 0)
  18926. * @param toFrame defines the ending frame number (default is 100)
  18927. * @param loopAnimation defines if the animation must loop (default is false)
  18928. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18929. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18930. * @param animations defines a group of animation to add to the new Animatable
  18931. * @param onAnimationLoop defines a callback to call when animation loops
  18932. */
  18933. constructor(scene: Scene,
  18934. /** defines the target object */
  18935. target: any,
  18936. /** defines the starting frame number (default is 0) */
  18937. fromFrame?: number,
  18938. /** defines the ending frame number (default is 100) */
  18939. toFrame?: number,
  18940. /** defines if the animation must loop (default is false) */
  18941. loopAnimation?: boolean, speedRatio?: number,
  18942. /** defines a callback to call when animation ends if it is not looping */
  18943. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18944. /** defines a callback to call when animation loops */
  18945. onAnimationLoop?: (() => void) | null | undefined);
  18946. /**
  18947. * Synchronize and normalize current Animatable with a source Animatable
  18948. * This is useful when using animation weights and when animations are not of the same length
  18949. * @param root defines the root Animatable to synchronize with
  18950. * @returns the current Animatable
  18951. */
  18952. syncWith(root: Animatable): Animatable;
  18953. /**
  18954. * Gets the list of runtime animations
  18955. * @returns an array of RuntimeAnimation
  18956. */
  18957. getAnimations(): RuntimeAnimation[];
  18958. /**
  18959. * Adds more animations to the current animatable
  18960. * @param target defines the target of the animations
  18961. * @param animations defines the new animations to add
  18962. */
  18963. appendAnimations(target: any, animations: Animation[]): void;
  18964. /**
  18965. * Gets the source animation for a specific property
  18966. * @param property defines the propertyu to look for
  18967. * @returns null or the source animation for the given property
  18968. */
  18969. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18970. /**
  18971. * Gets the runtime animation for a specific property
  18972. * @param property defines the propertyu to look for
  18973. * @returns null or the runtime animation for the given property
  18974. */
  18975. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18976. /**
  18977. * Resets the animatable to its original state
  18978. */
  18979. reset(): void;
  18980. /**
  18981. * Allows the animatable to blend with current running animations
  18982. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18983. * @param blendingSpeed defines the blending speed to use
  18984. */
  18985. enableBlending(blendingSpeed: number): void;
  18986. /**
  18987. * Disable animation blending
  18988. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18989. */
  18990. disableBlending(): void;
  18991. /**
  18992. * Jump directly to a given frame
  18993. * @param frame defines the frame to jump to
  18994. */
  18995. goToFrame(frame: number): void;
  18996. /**
  18997. * Pause the animation
  18998. */
  18999. pause(): void;
  19000. /**
  19001. * Restart the animation
  19002. */
  19003. restart(): void;
  19004. private _raiseOnAnimationEnd;
  19005. /**
  19006. * Stop and delete the current animation
  19007. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19008. * @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)
  19009. */
  19010. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19011. /**
  19012. * Wait asynchronously for the animation to end
  19013. * @returns a promise which will be fullfilled when the animation ends
  19014. */
  19015. waitAsync(): Promise<Animatable>;
  19016. /** @hidden */
  19017. _animate(delay: number): boolean;
  19018. }
  19019. interface Scene {
  19020. /** @hidden */
  19021. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19022. /** @hidden */
  19023. _processLateAnimationBindingsForMatrices(holder: {
  19024. totalWeight: number;
  19025. animations: RuntimeAnimation[];
  19026. originalValue: Matrix;
  19027. }): any;
  19028. /** @hidden */
  19029. _processLateAnimationBindingsForQuaternions(holder: {
  19030. totalWeight: number;
  19031. animations: RuntimeAnimation[];
  19032. originalValue: Quaternion;
  19033. }, refQuaternion: Quaternion): Quaternion;
  19034. /** @hidden */
  19035. _processLateAnimationBindings(): void;
  19036. /**
  19037. * Will start the animation sequence of a given target
  19038. * @param target defines the target
  19039. * @param from defines from which frame should animation start
  19040. * @param to defines until which frame should animation run.
  19041. * @param weight defines the weight to apply to the animation (1.0 by default)
  19042. * @param loop defines if the animation loops
  19043. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19044. * @param onAnimationEnd defines the function to be executed when the animation ends
  19045. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19046. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19047. * @param onAnimationLoop defines the callback to call when an animation loops
  19048. * @returns the animatable object created for this animation
  19049. */
  19050. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19051. /**
  19052. * Will start the animation sequence of a given target
  19053. * @param target defines the target
  19054. * @param from defines from which frame should animation start
  19055. * @param to defines until which frame should animation run.
  19056. * @param loop defines if the animation loops
  19057. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19058. * @param onAnimationEnd defines the function to be executed when the animation ends
  19059. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19060. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19061. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19062. * @param onAnimationLoop defines the callback to call when an animation loops
  19063. * @returns the animatable object created for this animation
  19064. */
  19065. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19066. /**
  19067. * Will start the animation sequence of a given target and its hierarchy
  19068. * @param target defines the target
  19069. * @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.
  19070. * @param from defines from which frame should animation start
  19071. * @param to defines until which frame should animation run.
  19072. * @param loop defines if the animation loops
  19073. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19074. * @param onAnimationEnd defines the function to be executed when the animation ends
  19075. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19076. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19077. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19078. * @param onAnimationLoop defines the callback to call when an animation loops
  19079. * @returns the list of created animatables
  19080. */
  19081. 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[];
  19082. /**
  19083. * Begin a new animation on a given node
  19084. * @param target defines the target where the animation will take place
  19085. * @param animations defines the list of animations to start
  19086. * @param from defines the initial value
  19087. * @param to defines the final value
  19088. * @param loop defines if you want animation to loop (off by default)
  19089. * @param speedRatio defines the speed ratio to apply to all animations
  19090. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19091. * @param onAnimationLoop defines the callback to call when an animation loops
  19092. * @returns the list of created animatables
  19093. */
  19094. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19095. /**
  19096. * Begin a new animation on a given node and its hierarchy
  19097. * @param target defines the root node where the animation will take place
  19098. * @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.
  19099. * @param animations defines the list of animations to start
  19100. * @param from defines the initial value
  19101. * @param to defines the final value
  19102. * @param loop defines if you want animation to loop (off by default)
  19103. * @param speedRatio defines the speed ratio to apply to all animations
  19104. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19105. * @param onAnimationLoop defines the callback to call when an animation loops
  19106. * @returns the list of animatables created for all nodes
  19107. */
  19108. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19109. /**
  19110. * Gets the animatable associated with a specific target
  19111. * @param target defines the target of the animatable
  19112. * @returns the required animatable if found
  19113. */
  19114. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19115. /**
  19116. * Gets all animatables associated with a given target
  19117. * @param target defines the target to look animatables for
  19118. * @returns an array of Animatables
  19119. */
  19120. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19121. /**
  19122. * Stops and removes all animations that have been applied to the scene
  19123. */
  19124. stopAllAnimations(): void;
  19125. }
  19126. interface Bone {
  19127. /**
  19128. * Copy an animation range from another bone
  19129. * @param source defines the source bone
  19130. * @param rangeName defines the range name to copy
  19131. * @param frameOffset defines the frame offset
  19132. * @param rescaleAsRequired defines if rescaling must be applied if required
  19133. * @param skelDimensionsRatio defines the scaling ratio
  19134. * @returns true if operation was successful
  19135. */
  19136. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19137. }
  19138. }
  19139. declare module BABYLON {
  19140. /**
  19141. * Class used to handle skinning animations
  19142. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19143. */
  19144. export class Skeleton implements IAnimatable {
  19145. /** defines the skeleton name */
  19146. name: string;
  19147. /** defines the skeleton Id */
  19148. id: string;
  19149. /**
  19150. * Defines the list of child bones
  19151. */
  19152. bones: Bone[];
  19153. /**
  19154. * Defines an estimate of the dimension of the skeleton at rest
  19155. */
  19156. dimensionsAtRest: Vector3;
  19157. /**
  19158. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19159. */
  19160. needInitialSkinMatrix: boolean;
  19161. /**
  19162. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19163. */
  19164. overrideMesh: Nullable<AbstractMesh>;
  19165. /**
  19166. * Gets the list of animations attached to this skeleton
  19167. */
  19168. animations: Array<Animation>;
  19169. private _scene;
  19170. private _isDirty;
  19171. private _transformMatrices;
  19172. private _transformMatrixTexture;
  19173. private _meshesWithPoseMatrix;
  19174. private _animatables;
  19175. private _identity;
  19176. private _synchronizedWithMesh;
  19177. private _ranges;
  19178. private _lastAbsoluteTransformsUpdateId;
  19179. private _canUseTextureForBones;
  19180. private _uniqueId;
  19181. /** @hidden */
  19182. _numBonesWithLinkedTransformNode: number;
  19183. /**
  19184. * Specifies if the skeleton should be serialized
  19185. */
  19186. doNotSerialize: boolean;
  19187. private _useTextureToStoreBoneMatrices;
  19188. /**
  19189. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19190. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19191. */
  19192. useTextureToStoreBoneMatrices: boolean;
  19193. private _animationPropertiesOverride;
  19194. /**
  19195. * Gets or sets the animation properties override
  19196. */
  19197. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19198. /**
  19199. * List of inspectable custom properties (used by the Inspector)
  19200. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19201. */
  19202. inspectableCustomProperties: IInspectable[];
  19203. /**
  19204. * An observable triggered before computing the skeleton's matrices
  19205. */
  19206. onBeforeComputeObservable: Observable<Skeleton>;
  19207. /**
  19208. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19209. */
  19210. readonly isUsingTextureForMatrices: boolean;
  19211. /**
  19212. * Gets the unique ID of this skeleton
  19213. */
  19214. readonly uniqueId: number;
  19215. /**
  19216. * Creates a new skeleton
  19217. * @param name defines the skeleton name
  19218. * @param id defines the skeleton Id
  19219. * @param scene defines the hosting scene
  19220. */
  19221. constructor(
  19222. /** defines the skeleton name */
  19223. name: string,
  19224. /** defines the skeleton Id */
  19225. id: string, scene: Scene);
  19226. /**
  19227. * Gets the current object class name.
  19228. * @return the class name
  19229. */
  19230. getClassName(): string;
  19231. /**
  19232. * Returns an array containing the root bones
  19233. * @returns an array containing the root bones
  19234. */
  19235. getChildren(): Array<Bone>;
  19236. /**
  19237. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19238. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19239. * @returns a Float32Array containing matrices data
  19240. */
  19241. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19242. /**
  19243. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19244. * @returns a raw texture containing the data
  19245. */
  19246. getTransformMatrixTexture(): Nullable<RawTexture>;
  19247. /**
  19248. * Gets the current hosting scene
  19249. * @returns a scene object
  19250. */
  19251. getScene(): Scene;
  19252. /**
  19253. * Gets a string representing the current skeleton data
  19254. * @param fullDetails defines a boolean indicating if we want a verbose version
  19255. * @returns a string representing the current skeleton data
  19256. */
  19257. toString(fullDetails?: boolean): string;
  19258. /**
  19259. * Get bone's index searching by name
  19260. * @param name defines bone's name to search for
  19261. * @return the indice of the bone. Returns -1 if not found
  19262. */
  19263. getBoneIndexByName(name: string): number;
  19264. /**
  19265. * Creater a new animation range
  19266. * @param name defines the name of the range
  19267. * @param from defines the start key
  19268. * @param to defines the end key
  19269. */
  19270. createAnimationRange(name: string, from: number, to: number): void;
  19271. /**
  19272. * Delete a specific animation range
  19273. * @param name defines the name of the range
  19274. * @param deleteFrames defines if frames must be removed as well
  19275. */
  19276. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19277. /**
  19278. * Gets a specific animation range
  19279. * @param name defines the name of the range to look for
  19280. * @returns the requested animation range or null if not found
  19281. */
  19282. getAnimationRange(name: string): Nullable<AnimationRange>;
  19283. /**
  19284. * Gets the list of all animation ranges defined on this skeleton
  19285. * @returns an array
  19286. */
  19287. getAnimationRanges(): Nullable<AnimationRange>[];
  19288. /**
  19289. * Copy animation range from a source skeleton.
  19290. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19291. * @param source defines the source skeleton
  19292. * @param name defines the name of the range to copy
  19293. * @param rescaleAsRequired defines if rescaling must be applied if required
  19294. * @returns true if operation was successful
  19295. */
  19296. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19297. /**
  19298. * Forces the skeleton to go to rest pose
  19299. */
  19300. returnToRest(): void;
  19301. private _getHighestAnimationFrame;
  19302. /**
  19303. * Begin a specific animation range
  19304. * @param name defines the name of the range to start
  19305. * @param loop defines if looping must be turned on (false by default)
  19306. * @param speedRatio defines the speed ratio to apply (1 by default)
  19307. * @param onAnimationEnd defines a callback which will be called when animation will end
  19308. * @returns a new animatable
  19309. */
  19310. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19311. /** @hidden */
  19312. _markAsDirty(): void;
  19313. /** @hidden */
  19314. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19315. /** @hidden */
  19316. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19317. private _computeTransformMatrices;
  19318. /**
  19319. * Build all resources required to render a skeleton
  19320. */
  19321. prepare(): void;
  19322. /**
  19323. * Gets the list of animatables currently running for this skeleton
  19324. * @returns an array of animatables
  19325. */
  19326. getAnimatables(): IAnimatable[];
  19327. /**
  19328. * Clone the current skeleton
  19329. * @param name defines the name of the new skeleton
  19330. * @param id defines the id of the new skeleton
  19331. * @returns the new skeleton
  19332. */
  19333. clone(name: string, id: string): Skeleton;
  19334. /**
  19335. * Enable animation blending for this skeleton
  19336. * @param blendingSpeed defines the blending speed to apply
  19337. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19338. */
  19339. enableBlending(blendingSpeed?: number): void;
  19340. /**
  19341. * Releases all resources associated with the current skeleton
  19342. */
  19343. dispose(): void;
  19344. /**
  19345. * Serialize the skeleton in a JSON object
  19346. * @returns a JSON object
  19347. */
  19348. serialize(): any;
  19349. /**
  19350. * Creates a new skeleton from serialized data
  19351. * @param parsedSkeleton defines the serialized data
  19352. * @param scene defines the hosting scene
  19353. * @returns a new skeleton
  19354. */
  19355. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19356. /**
  19357. * Compute all node absolute transforms
  19358. * @param forceUpdate defines if computation must be done even if cache is up to date
  19359. */
  19360. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19361. /**
  19362. * Gets the root pose matrix
  19363. * @returns a matrix
  19364. */
  19365. getPoseMatrix(): Nullable<Matrix>;
  19366. /**
  19367. * Sorts bones per internal index
  19368. */
  19369. sortBones(): void;
  19370. private _sortBones;
  19371. }
  19372. }
  19373. declare module BABYLON {
  19374. /**
  19375. * Defines a target to use with MorphTargetManager
  19376. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19377. */
  19378. export class MorphTarget implements IAnimatable {
  19379. /** defines the name of the target */
  19380. name: string;
  19381. /**
  19382. * Gets or sets the list of animations
  19383. */
  19384. animations: Animation[];
  19385. private _scene;
  19386. private _positions;
  19387. private _normals;
  19388. private _tangents;
  19389. private _influence;
  19390. /**
  19391. * Observable raised when the influence changes
  19392. */
  19393. onInfluenceChanged: Observable<boolean>;
  19394. /** @hidden */
  19395. _onDataLayoutChanged: Observable<void>;
  19396. /**
  19397. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19398. */
  19399. influence: number;
  19400. /**
  19401. * Gets or sets the id of the morph Target
  19402. */
  19403. id: string;
  19404. private _animationPropertiesOverride;
  19405. /**
  19406. * Gets or sets the animation properties override
  19407. */
  19408. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19409. /**
  19410. * Creates a new MorphTarget
  19411. * @param name defines the name of the target
  19412. * @param influence defines the influence to use
  19413. * @param scene defines the scene the morphtarget belongs to
  19414. */
  19415. constructor(
  19416. /** defines the name of the target */
  19417. name: string, influence?: number, scene?: Nullable<Scene>);
  19418. /**
  19419. * Gets a boolean defining if the target contains position data
  19420. */
  19421. readonly hasPositions: boolean;
  19422. /**
  19423. * Gets a boolean defining if the target contains normal data
  19424. */
  19425. readonly hasNormals: boolean;
  19426. /**
  19427. * Gets a boolean defining if the target contains tangent data
  19428. */
  19429. readonly hasTangents: boolean;
  19430. /**
  19431. * Affects position data to this target
  19432. * @param data defines the position data to use
  19433. */
  19434. setPositions(data: Nullable<FloatArray>): void;
  19435. /**
  19436. * Gets the position data stored in this target
  19437. * @returns a FloatArray containing the position data (or null if not present)
  19438. */
  19439. getPositions(): Nullable<FloatArray>;
  19440. /**
  19441. * Affects normal data to this target
  19442. * @param data defines the normal data to use
  19443. */
  19444. setNormals(data: Nullable<FloatArray>): void;
  19445. /**
  19446. * Gets the normal data stored in this target
  19447. * @returns a FloatArray containing the normal data (or null if not present)
  19448. */
  19449. getNormals(): Nullable<FloatArray>;
  19450. /**
  19451. * Affects tangent data to this target
  19452. * @param data defines the tangent data to use
  19453. */
  19454. setTangents(data: Nullable<FloatArray>): void;
  19455. /**
  19456. * Gets the tangent data stored in this target
  19457. * @returns a FloatArray containing the tangent data (or null if not present)
  19458. */
  19459. getTangents(): Nullable<FloatArray>;
  19460. /**
  19461. * Serializes the current target into a Serialization object
  19462. * @returns the serialized object
  19463. */
  19464. serialize(): any;
  19465. /**
  19466. * Returns the string "MorphTarget"
  19467. * @returns "MorphTarget"
  19468. */
  19469. getClassName(): string;
  19470. /**
  19471. * Creates a new target from serialized data
  19472. * @param serializationObject defines the serialized data to use
  19473. * @returns a new MorphTarget
  19474. */
  19475. static Parse(serializationObject: any): MorphTarget;
  19476. /**
  19477. * Creates a MorphTarget from mesh data
  19478. * @param mesh defines the source mesh
  19479. * @param name defines the name to use for the new target
  19480. * @param influence defines the influence to attach to the target
  19481. * @returns a new MorphTarget
  19482. */
  19483. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19484. }
  19485. }
  19486. declare module BABYLON {
  19487. /**
  19488. * This class is used to deform meshes using morphing between different targets
  19489. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19490. */
  19491. export class MorphTargetManager {
  19492. private _targets;
  19493. private _targetInfluenceChangedObservers;
  19494. private _targetDataLayoutChangedObservers;
  19495. private _activeTargets;
  19496. private _scene;
  19497. private _influences;
  19498. private _supportsNormals;
  19499. private _supportsTangents;
  19500. private _vertexCount;
  19501. private _uniqueId;
  19502. private _tempInfluences;
  19503. /**
  19504. * Creates a new MorphTargetManager
  19505. * @param scene defines the current scene
  19506. */
  19507. constructor(scene?: Nullable<Scene>);
  19508. /**
  19509. * Gets the unique ID of this manager
  19510. */
  19511. readonly uniqueId: number;
  19512. /**
  19513. * Gets the number of vertices handled by this manager
  19514. */
  19515. readonly vertexCount: number;
  19516. /**
  19517. * Gets a boolean indicating if this manager supports morphing of normals
  19518. */
  19519. readonly supportsNormals: boolean;
  19520. /**
  19521. * Gets a boolean indicating if this manager supports morphing of tangents
  19522. */
  19523. readonly supportsTangents: boolean;
  19524. /**
  19525. * Gets the number of targets stored in this manager
  19526. */
  19527. readonly numTargets: number;
  19528. /**
  19529. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19530. */
  19531. readonly numInfluencers: number;
  19532. /**
  19533. * Gets the list of influences (one per target)
  19534. */
  19535. readonly influences: Float32Array;
  19536. /**
  19537. * Gets the active target at specified index. An active target is a target with an influence > 0
  19538. * @param index defines the index to check
  19539. * @returns the requested target
  19540. */
  19541. getActiveTarget(index: number): MorphTarget;
  19542. /**
  19543. * Gets the target at specified index
  19544. * @param index defines the index to check
  19545. * @returns the requested target
  19546. */
  19547. getTarget(index: number): MorphTarget;
  19548. /**
  19549. * Add a new target to this manager
  19550. * @param target defines the target to add
  19551. */
  19552. addTarget(target: MorphTarget): void;
  19553. /**
  19554. * Removes a target from the manager
  19555. * @param target defines the target to remove
  19556. */
  19557. removeTarget(target: MorphTarget): void;
  19558. /**
  19559. * Serializes the current manager into a Serialization object
  19560. * @returns the serialized object
  19561. */
  19562. serialize(): any;
  19563. private _syncActiveTargets;
  19564. /**
  19565. * Syncrhonize the targets with all the meshes using this morph target manager
  19566. */
  19567. synchronize(): void;
  19568. /**
  19569. * Creates a new MorphTargetManager from serialized data
  19570. * @param serializationObject defines the serialized data
  19571. * @param scene defines the hosting scene
  19572. * @returns the new MorphTargetManager
  19573. */
  19574. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19575. }
  19576. }
  19577. declare module BABYLON {
  19578. /**
  19579. * Class used to represent a specific level of detail of a mesh
  19580. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19581. */
  19582. export class MeshLODLevel {
  19583. /** Defines the distance where this level should star being displayed */
  19584. distance: number;
  19585. /** Defines the mesh to use to render this level */
  19586. mesh: Nullable<Mesh>;
  19587. /**
  19588. * Creates a new LOD level
  19589. * @param distance defines the distance where this level should star being displayed
  19590. * @param mesh defines the mesh to use to render this level
  19591. */
  19592. constructor(
  19593. /** Defines the distance where this level should star being displayed */
  19594. distance: number,
  19595. /** Defines the mesh to use to render this level */
  19596. mesh: Nullable<Mesh>);
  19597. }
  19598. }
  19599. declare module BABYLON {
  19600. /**
  19601. * Mesh representing the gorund
  19602. */
  19603. export class GroundMesh extends Mesh {
  19604. /** If octree should be generated */
  19605. generateOctree: boolean;
  19606. private _heightQuads;
  19607. /** @hidden */
  19608. _subdivisionsX: number;
  19609. /** @hidden */
  19610. _subdivisionsY: number;
  19611. /** @hidden */
  19612. _width: number;
  19613. /** @hidden */
  19614. _height: number;
  19615. /** @hidden */
  19616. _minX: number;
  19617. /** @hidden */
  19618. _maxX: number;
  19619. /** @hidden */
  19620. _minZ: number;
  19621. /** @hidden */
  19622. _maxZ: number;
  19623. constructor(name: string, scene: Scene);
  19624. /**
  19625. * "GroundMesh"
  19626. * @returns "GroundMesh"
  19627. */
  19628. getClassName(): string;
  19629. /**
  19630. * The minimum of x and y subdivisions
  19631. */
  19632. readonly subdivisions: number;
  19633. /**
  19634. * X subdivisions
  19635. */
  19636. readonly subdivisionsX: number;
  19637. /**
  19638. * Y subdivisions
  19639. */
  19640. readonly subdivisionsY: number;
  19641. /**
  19642. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19643. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19644. * @param chunksCount the number of subdivisions for x and y
  19645. * @param octreeBlocksSize (Default: 32)
  19646. */
  19647. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19648. /**
  19649. * Returns a height (y) value in the Worl system :
  19650. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19651. * @param x x coordinate
  19652. * @param z z coordinate
  19653. * @returns the ground y position if (x, z) are outside the ground surface.
  19654. */
  19655. getHeightAtCoordinates(x: number, z: number): number;
  19656. /**
  19657. * Returns a normalized vector (Vector3) orthogonal to the ground
  19658. * at the ground coordinates (x, z) expressed in the World system.
  19659. * @param x x coordinate
  19660. * @param z z coordinate
  19661. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19662. */
  19663. getNormalAtCoordinates(x: number, z: number): Vector3;
  19664. /**
  19665. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19666. * at the ground coordinates (x, z) expressed in the World system.
  19667. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19668. * @param x x coordinate
  19669. * @param z z coordinate
  19670. * @param ref vector to store the result
  19671. * @returns the GroundMesh.
  19672. */
  19673. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19674. /**
  19675. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19676. * if the ground has been updated.
  19677. * This can be used in the render loop.
  19678. * @returns the GroundMesh.
  19679. */
  19680. updateCoordinateHeights(): GroundMesh;
  19681. private _getFacetAt;
  19682. private _initHeightQuads;
  19683. private _computeHeightQuads;
  19684. /**
  19685. * Serializes this ground mesh
  19686. * @param serializationObject object to write serialization to
  19687. */
  19688. serialize(serializationObject: any): void;
  19689. /**
  19690. * Parses a serialized ground mesh
  19691. * @param parsedMesh the serialized mesh
  19692. * @param scene the scene to create the ground mesh in
  19693. * @returns the created ground mesh
  19694. */
  19695. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19696. }
  19697. }
  19698. declare module BABYLON {
  19699. /**
  19700. * Interface for Physics-Joint data
  19701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19702. */
  19703. export interface PhysicsJointData {
  19704. /**
  19705. * The main pivot of the joint
  19706. */
  19707. mainPivot?: Vector3;
  19708. /**
  19709. * The connected pivot of the joint
  19710. */
  19711. connectedPivot?: Vector3;
  19712. /**
  19713. * The main axis of the joint
  19714. */
  19715. mainAxis?: Vector3;
  19716. /**
  19717. * The connected axis of the joint
  19718. */
  19719. connectedAxis?: Vector3;
  19720. /**
  19721. * The collision of the joint
  19722. */
  19723. collision?: boolean;
  19724. /**
  19725. * Native Oimo/Cannon/Energy data
  19726. */
  19727. nativeParams?: any;
  19728. }
  19729. /**
  19730. * This is a holder class for the physics joint created by the physics plugin
  19731. * It holds a set of functions to control the underlying joint
  19732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19733. */
  19734. export class PhysicsJoint {
  19735. /**
  19736. * The type of the physics joint
  19737. */
  19738. type: number;
  19739. /**
  19740. * The data for the physics joint
  19741. */
  19742. jointData: PhysicsJointData;
  19743. private _physicsJoint;
  19744. protected _physicsPlugin: IPhysicsEnginePlugin;
  19745. /**
  19746. * Initializes the physics joint
  19747. * @param type The type of the physics joint
  19748. * @param jointData The data for the physics joint
  19749. */
  19750. constructor(
  19751. /**
  19752. * The type of the physics joint
  19753. */
  19754. type: number,
  19755. /**
  19756. * The data for the physics joint
  19757. */
  19758. jointData: PhysicsJointData);
  19759. /**
  19760. * Gets the physics joint
  19761. */
  19762. /**
  19763. * Sets the physics joint
  19764. */
  19765. physicsJoint: any;
  19766. /**
  19767. * Sets the physics plugin
  19768. */
  19769. physicsPlugin: IPhysicsEnginePlugin;
  19770. /**
  19771. * Execute a function that is physics-plugin specific.
  19772. * @param {Function} func the function that will be executed.
  19773. * It accepts two parameters: the physics world and the physics joint
  19774. */
  19775. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19776. /**
  19777. * Distance-Joint type
  19778. */
  19779. static DistanceJoint: number;
  19780. /**
  19781. * Hinge-Joint type
  19782. */
  19783. static HingeJoint: number;
  19784. /**
  19785. * Ball-and-Socket joint type
  19786. */
  19787. static BallAndSocketJoint: number;
  19788. /**
  19789. * Wheel-Joint type
  19790. */
  19791. static WheelJoint: number;
  19792. /**
  19793. * Slider-Joint type
  19794. */
  19795. static SliderJoint: number;
  19796. /**
  19797. * Prismatic-Joint type
  19798. */
  19799. static PrismaticJoint: number;
  19800. /**
  19801. * Universal-Joint type
  19802. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19803. */
  19804. static UniversalJoint: number;
  19805. /**
  19806. * Hinge-Joint 2 type
  19807. */
  19808. static Hinge2Joint: number;
  19809. /**
  19810. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19811. */
  19812. static PointToPointJoint: number;
  19813. /**
  19814. * Spring-Joint type
  19815. */
  19816. static SpringJoint: number;
  19817. /**
  19818. * Lock-Joint type
  19819. */
  19820. static LockJoint: number;
  19821. }
  19822. /**
  19823. * A class representing a physics distance joint
  19824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19825. */
  19826. export class DistanceJoint extends PhysicsJoint {
  19827. /**
  19828. *
  19829. * @param jointData The data for the Distance-Joint
  19830. */
  19831. constructor(jointData: DistanceJointData);
  19832. /**
  19833. * Update the predefined distance.
  19834. * @param maxDistance The maximum preferred distance
  19835. * @param minDistance The minimum preferred distance
  19836. */
  19837. updateDistance(maxDistance: number, minDistance?: number): void;
  19838. }
  19839. /**
  19840. * Represents a Motor-Enabled Joint
  19841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19842. */
  19843. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19844. /**
  19845. * Initializes the Motor-Enabled Joint
  19846. * @param type The type of the joint
  19847. * @param jointData The physica joint data for the joint
  19848. */
  19849. constructor(type: number, jointData: PhysicsJointData);
  19850. /**
  19851. * Set the motor values.
  19852. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19853. * @param force the force to apply
  19854. * @param maxForce max force for this motor.
  19855. */
  19856. setMotor(force?: number, maxForce?: number): void;
  19857. /**
  19858. * Set the motor's limits.
  19859. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19860. * @param upperLimit The upper limit of the motor
  19861. * @param lowerLimit The lower limit of the motor
  19862. */
  19863. setLimit(upperLimit: number, lowerLimit?: number): void;
  19864. }
  19865. /**
  19866. * This class represents a single physics Hinge-Joint
  19867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19868. */
  19869. export class HingeJoint extends MotorEnabledJoint {
  19870. /**
  19871. * Initializes the Hinge-Joint
  19872. * @param jointData The joint data for the Hinge-Joint
  19873. */
  19874. constructor(jointData: PhysicsJointData);
  19875. /**
  19876. * Set the motor values.
  19877. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19878. * @param {number} force the force to apply
  19879. * @param {number} maxForce max force for this motor.
  19880. */
  19881. setMotor(force?: number, maxForce?: number): void;
  19882. /**
  19883. * Set the motor's limits.
  19884. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19885. * @param upperLimit The upper limit of the motor
  19886. * @param lowerLimit The lower limit of the motor
  19887. */
  19888. setLimit(upperLimit: number, lowerLimit?: number): void;
  19889. }
  19890. /**
  19891. * This class represents a dual hinge physics joint (same as wheel joint)
  19892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19893. */
  19894. export class Hinge2Joint extends MotorEnabledJoint {
  19895. /**
  19896. * Initializes the Hinge2-Joint
  19897. * @param jointData The joint data for the Hinge2-Joint
  19898. */
  19899. constructor(jointData: PhysicsJointData);
  19900. /**
  19901. * Set the motor values.
  19902. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19903. * @param {number} targetSpeed the speed the motor is to reach
  19904. * @param {number} maxForce max force for this motor.
  19905. * @param {motorIndex} the motor's index, 0 or 1.
  19906. */
  19907. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19908. /**
  19909. * Set the motor limits.
  19910. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19911. * @param {number} upperLimit the upper limit
  19912. * @param {number} lowerLimit lower limit
  19913. * @param {motorIndex} the motor's index, 0 or 1.
  19914. */
  19915. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19916. }
  19917. /**
  19918. * Interface for a motor enabled joint
  19919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19920. */
  19921. export interface IMotorEnabledJoint {
  19922. /**
  19923. * Physics joint
  19924. */
  19925. physicsJoint: any;
  19926. /**
  19927. * Sets the motor of the motor-enabled joint
  19928. * @param force The force of the motor
  19929. * @param maxForce The maximum force of the motor
  19930. * @param motorIndex The index of the motor
  19931. */
  19932. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19933. /**
  19934. * Sets the limit of the motor
  19935. * @param upperLimit The upper limit of the motor
  19936. * @param lowerLimit The lower limit of the motor
  19937. * @param motorIndex The index of the motor
  19938. */
  19939. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19940. }
  19941. /**
  19942. * Joint data for a Distance-Joint
  19943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19944. */
  19945. export interface DistanceJointData extends PhysicsJointData {
  19946. /**
  19947. * Max distance the 2 joint objects can be apart
  19948. */
  19949. maxDistance: number;
  19950. }
  19951. /**
  19952. * Joint data from a spring joint
  19953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19954. */
  19955. export interface SpringJointData extends PhysicsJointData {
  19956. /**
  19957. * Length of the spring
  19958. */
  19959. length: number;
  19960. /**
  19961. * Stiffness of the spring
  19962. */
  19963. stiffness: number;
  19964. /**
  19965. * Damping of the spring
  19966. */
  19967. damping: number;
  19968. /** this callback will be called when applying the force to the impostors. */
  19969. forceApplicationCallback: () => void;
  19970. }
  19971. }
  19972. declare module BABYLON {
  19973. /**
  19974. * Holds the data for the raycast result
  19975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19976. */
  19977. export class PhysicsRaycastResult {
  19978. private _hasHit;
  19979. private _hitDistance;
  19980. private _hitNormalWorld;
  19981. private _hitPointWorld;
  19982. private _rayFromWorld;
  19983. private _rayToWorld;
  19984. /**
  19985. * Gets if there was a hit
  19986. */
  19987. readonly hasHit: boolean;
  19988. /**
  19989. * Gets the distance from the hit
  19990. */
  19991. readonly hitDistance: number;
  19992. /**
  19993. * Gets the hit normal/direction in the world
  19994. */
  19995. readonly hitNormalWorld: Vector3;
  19996. /**
  19997. * Gets the hit point in the world
  19998. */
  19999. readonly hitPointWorld: Vector3;
  20000. /**
  20001. * Gets the ray "start point" of the ray in the world
  20002. */
  20003. readonly rayFromWorld: Vector3;
  20004. /**
  20005. * Gets the ray "end point" of the ray in the world
  20006. */
  20007. readonly rayToWorld: Vector3;
  20008. /**
  20009. * Sets the hit data (normal & point in world space)
  20010. * @param hitNormalWorld defines the normal in world space
  20011. * @param hitPointWorld defines the point in world space
  20012. */
  20013. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20014. /**
  20015. * Sets the distance from the start point to the hit point
  20016. * @param distance
  20017. */
  20018. setHitDistance(distance: number): void;
  20019. /**
  20020. * Calculates the distance manually
  20021. */
  20022. calculateHitDistance(): void;
  20023. /**
  20024. * Resets all the values to default
  20025. * @param from The from point on world space
  20026. * @param to The to point on world space
  20027. */
  20028. reset(from?: Vector3, to?: Vector3): void;
  20029. }
  20030. /**
  20031. * Interface for the size containing width and height
  20032. */
  20033. interface IXYZ {
  20034. /**
  20035. * X
  20036. */
  20037. x: number;
  20038. /**
  20039. * Y
  20040. */
  20041. y: number;
  20042. /**
  20043. * Z
  20044. */
  20045. z: number;
  20046. }
  20047. }
  20048. declare module BABYLON {
  20049. /**
  20050. * Interface used to describe a physics joint
  20051. */
  20052. export interface PhysicsImpostorJoint {
  20053. /** Defines the main impostor to which the joint is linked */
  20054. mainImpostor: PhysicsImpostor;
  20055. /** Defines the impostor that is connected to the main impostor using this joint */
  20056. connectedImpostor: PhysicsImpostor;
  20057. /** Defines the joint itself */
  20058. joint: PhysicsJoint;
  20059. }
  20060. /** @hidden */
  20061. export interface IPhysicsEnginePlugin {
  20062. world: any;
  20063. name: string;
  20064. setGravity(gravity: Vector3): void;
  20065. setTimeStep(timeStep: number): void;
  20066. getTimeStep(): number;
  20067. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20068. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20069. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20070. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20071. removePhysicsBody(impostor: PhysicsImpostor): void;
  20072. generateJoint(joint: PhysicsImpostorJoint): void;
  20073. removeJoint(joint: PhysicsImpostorJoint): void;
  20074. isSupported(): boolean;
  20075. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20076. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20077. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20078. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20079. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20080. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20081. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20082. getBodyMass(impostor: PhysicsImpostor): number;
  20083. getBodyFriction(impostor: PhysicsImpostor): number;
  20084. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20085. getBodyRestitution(impostor: PhysicsImpostor): number;
  20086. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20087. getBodyPressure?(impostor: PhysicsImpostor): number;
  20088. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20089. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20090. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20091. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20092. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20093. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20094. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20095. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20096. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20097. sleepBody(impostor: PhysicsImpostor): void;
  20098. wakeUpBody(impostor: PhysicsImpostor): void;
  20099. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20100. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20101. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20102. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20103. getRadius(impostor: PhysicsImpostor): number;
  20104. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20105. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20106. dispose(): void;
  20107. }
  20108. /**
  20109. * Interface used to define a physics engine
  20110. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20111. */
  20112. export interface IPhysicsEngine {
  20113. /**
  20114. * Gets the gravity vector used by the simulation
  20115. */
  20116. gravity: Vector3;
  20117. /**
  20118. * Sets the gravity vector used by the simulation
  20119. * @param gravity defines the gravity vector to use
  20120. */
  20121. setGravity(gravity: Vector3): void;
  20122. /**
  20123. * Set the time step of the physics engine.
  20124. * Default is 1/60.
  20125. * To slow it down, enter 1/600 for example.
  20126. * To speed it up, 1/30
  20127. * @param newTimeStep the new timestep to apply to this world.
  20128. */
  20129. setTimeStep(newTimeStep: number): void;
  20130. /**
  20131. * Get the time step of the physics engine.
  20132. * @returns the current time step
  20133. */
  20134. getTimeStep(): number;
  20135. /**
  20136. * Release all resources
  20137. */
  20138. dispose(): void;
  20139. /**
  20140. * Gets the name of the current physics plugin
  20141. * @returns the name of the plugin
  20142. */
  20143. getPhysicsPluginName(): string;
  20144. /**
  20145. * Adding a new impostor for the impostor tracking.
  20146. * This will be done by the impostor itself.
  20147. * @param impostor the impostor to add
  20148. */
  20149. addImpostor(impostor: PhysicsImpostor): void;
  20150. /**
  20151. * Remove an impostor from the engine.
  20152. * This impostor and its mesh will not longer be updated by the physics engine.
  20153. * @param impostor the impostor to remove
  20154. */
  20155. removeImpostor(impostor: PhysicsImpostor): void;
  20156. /**
  20157. * Add a joint to the physics engine
  20158. * @param mainImpostor defines the main impostor to which the joint is added.
  20159. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20160. * @param joint defines the joint that will connect both impostors.
  20161. */
  20162. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20163. /**
  20164. * Removes a joint from the simulation
  20165. * @param mainImpostor defines the impostor used with the joint
  20166. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20167. * @param joint defines the joint to remove
  20168. */
  20169. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20170. /**
  20171. * Gets the current plugin used to run the simulation
  20172. * @returns current plugin
  20173. */
  20174. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20175. /**
  20176. * Gets the list of physic impostors
  20177. * @returns an array of PhysicsImpostor
  20178. */
  20179. getImpostors(): Array<PhysicsImpostor>;
  20180. /**
  20181. * Gets the impostor for a physics enabled object
  20182. * @param object defines the object impersonated by the impostor
  20183. * @returns the PhysicsImpostor or null if not found
  20184. */
  20185. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20186. /**
  20187. * Gets the impostor for a physics body object
  20188. * @param body defines physics body used by the impostor
  20189. * @returns the PhysicsImpostor or null if not found
  20190. */
  20191. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20192. /**
  20193. * Does a raycast in the physics world
  20194. * @param from when should the ray start?
  20195. * @param to when should the ray end?
  20196. * @returns PhysicsRaycastResult
  20197. */
  20198. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20199. /**
  20200. * Called by the scene. No need to call it.
  20201. * @param delta defines the timespam between frames
  20202. */
  20203. _step(delta: number): void;
  20204. }
  20205. }
  20206. declare module BABYLON {
  20207. /**
  20208. * The interface for the physics imposter parameters
  20209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20210. */
  20211. export interface PhysicsImpostorParameters {
  20212. /**
  20213. * The mass of the physics imposter
  20214. */
  20215. mass: number;
  20216. /**
  20217. * The friction of the physics imposter
  20218. */
  20219. friction?: number;
  20220. /**
  20221. * The coefficient of restitution of the physics imposter
  20222. */
  20223. restitution?: number;
  20224. /**
  20225. * The native options of the physics imposter
  20226. */
  20227. nativeOptions?: any;
  20228. /**
  20229. * Specifies if the parent should be ignored
  20230. */
  20231. ignoreParent?: boolean;
  20232. /**
  20233. * Specifies if bi-directional transformations should be disabled
  20234. */
  20235. disableBidirectionalTransformation?: boolean;
  20236. /**
  20237. * The pressure inside the physics imposter, soft object only
  20238. */
  20239. pressure?: number;
  20240. /**
  20241. * The stiffness the physics imposter, soft object only
  20242. */
  20243. stiffness?: number;
  20244. /**
  20245. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20246. */
  20247. velocityIterations?: number;
  20248. /**
  20249. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20250. */
  20251. positionIterations?: number;
  20252. /**
  20253. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20254. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20255. * Add to fix multiple points
  20256. */
  20257. fixedPoints?: number;
  20258. /**
  20259. * The collision margin around a soft object
  20260. */
  20261. margin?: number;
  20262. /**
  20263. * The collision margin around a soft object
  20264. */
  20265. damping?: number;
  20266. /**
  20267. * The path for a rope based on an extrusion
  20268. */
  20269. path?: any;
  20270. /**
  20271. * The shape of an extrusion used for a rope based on an extrusion
  20272. */
  20273. shape?: any;
  20274. }
  20275. /**
  20276. * Interface for a physics-enabled object
  20277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20278. */
  20279. export interface IPhysicsEnabledObject {
  20280. /**
  20281. * The position of the physics-enabled object
  20282. */
  20283. position: Vector3;
  20284. /**
  20285. * The rotation of the physics-enabled object
  20286. */
  20287. rotationQuaternion: Nullable<Quaternion>;
  20288. /**
  20289. * The scale of the physics-enabled object
  20290. */
  20291. scaling: Vector3;
  20292. /**
  20293. * The rotation of the physics-enabled object
  20294. */
  20295. rotation?: Vector3;
  20296. /**
  20297. * The parent of the physics-enabled object
  20298. */
  20299. parent?: any;
  20300. /**
  20301. * The bounding info of the physics-enabled object
  20302. * @returns The bounding info of the physics-enabled object
  20303. */
  20304. getBoundingInfo(): BoundingInfo;
  20305. /**
  20306. * Computes the world matrix
  20307. * @param force Specifies if the world matrix should be computed by force
  20308. * @returns A world matrix
  20309. */
  20310. computeWorldMatrix(force: boolean): Matrix;
  20311. /**
  20312. * Gets the world matrix
  20313. * @returns A world matrix
  20314. */
  20315. getWorldMatrix?(): Matrix;
  20316. /**
  20317. * Gets the child meshes
  20318. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20319. * @returns An array of abstract meshes
  20320. */
  20321. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20322. /**
  20323. * Gets the vertex data
  20324. * @param kind The type of vertex data
  20325. * @returns A nullable array of numbers, or a float32 array
  20326. */
  20327. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20328. /**
  20329. * Gets the indices from the mesh
  20330. * @returns A nullable array of index arrays
  20331. */
  20332. getIndices?(): Nullable<IndicesArray>;
  20333. /**
  20334. * Gets the scene from the mesh
  20335. * @returns the indices array or null
  20336. */
  20337. getScene?(): Scene;
  20338. /**
  20339. * Gets the absolute position from the mesh
  20340. * @returns the absolute position
  20341. */
  20342. getAbsolutePosition(): Vector3;
  20343. /**
  20344. * Gets the absolute pivot point from the mesh
  20345. * @returns the absolute pivot point
  20346. */
  20347. getAbsolutePivotPoint(): Vector3;
  20348. /**
  20349. * Rotates the mesh
  20350. * @param axis The axis of rotation
  20351. * @param amount The amount of rotation
  20352. * @param space The space of the rotation
  20353. * @returns The rotation transform node
  20354. */
  20355. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20356. /**
  20357. * Translates the mesh
  20358. * @param axis The axis of translation
  20359. * @param distance The distance of translation
  20360. * @param space The space of the translation
  20361. * @returns The transform node
  20362. */
  20363. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20364. /**
  20365. * Sets the absolute position of the mesh
  20366. * @param absolutePosition The absolute position of the mesh
  20367. * @returns The transform node
  20368. */
  20369. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20370. /**
  20371. * Gets the class name of the mesh
  20372. * @returns The class name
  20373. */
  20374. getClassName(): string;
  20375. }
  20376. /**
  20377. * Represents a physics imposter
  20378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20379. */
  20380. export class PhysicsImpostor {
  20381. /**
  20382. * The physics-enabled object used as the physics imposter
  20383. */
  20384. object: IPhysicsEnabledObject;
  20385. /**
  20386. * The type of the physics imposter
  20387. */
  20388. type: number;
  20389. private _options;
  20390. private _scene?;
  20391. /**
  20392. * The default object size of the imposter
  20393. */
  20394. static DEFAULT_OBJECT_SIZE: Vector3;
  20395. /**
  20396. * The identity quaternion of the imposter
  20397. */
  20398. static IDENTITY_QUATERNION: Quaternion;
  20399. /** @hidden */
  20400. _pluginData: any;
  20401. private _physicsEngine;
  20402. private _physicsBody;
  20403. private _bodyUpdateRequired;
  20404. private _onBeforePhysicsStepCallbacks;
  20405. private _onAfterPhysicsStepCallbacks;
  20406. /** @hidden */
  20407. _onPhysicsCollideCallbacks: Array<{
  20408. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20409. otherImpostors: Array<PhysicsImpostor>;
  20410. }>;
  20411. private _deltaPosition;
  20412. private _deltaRotation;
  20413. private _deltaRotationConjugated;
  20414. /** hidden */
  20415. _isFromLine: boolean;
  20416. private _parent;
  20417. private _isDisposed;
  20418. private static _tmpVecs;
  20419. private static _tmpQuat;
  20420. /**
  20421. * Specifies if the physics imposter is disposed
  20422. */
  20423. readonly isDisposed: boolean;
  20424. /**
  20425. * Gets the mass of the physics imposter
  20426. */
  20427. mass: number;
  20428. /**
  20429. * Gets the coefficient of friction
  20430. */
  20431. /**
  20432. * Sets the coefficient of friction
  20433. */
  20434. friction: number;
  20435. /**
  20436. * Gets the coefficient of restitution
  20437. */
  20438. /**
  20439. * Sets the coefficient of restitution
  20440. */
  20441. restitution: number;
  20442. /**
  20443. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20444. */
  20445. /**
  20446. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20447. */
  20448. pressure: number;
  20449. /**
  20450. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20451. */
  20452. /**
  20453. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20454. */
  20455. stiffness: number;
  20456. /**
  20457. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20458. */
  20459. /**
  20460. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20461. */
  20462. velocityIterations: number;
  20463. /**
  20464. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20465. */
  20466. /**
  20467. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20468. */
  20469. positionIterations: number;
  20470. /**
  20471. * The unique id of the physics imposter
  20472. * set by the physics engine when adding this impostor to the array
  20473. */
  20474. uniqueId: number;
  20475. /**
  20476. * @hidden
  20477. */
  20478. soft: boolean;
  20479. /**
  20480. * @hidden
  20481. */
  20482. segments: number;
  20483. private _joints;
  20484. /**
  20485. * Initializes the physics imposter
  20486. * @param object The physics-enabled object used as the physics imposter
  20487. * @param type The type of the physics imposter
  20488. * @param _options The options for the physics imposter
  20489. * @param _scene The Babylon scene
  20490. */
  20491. constructor(
  20492. /**
  20493. * The physics-enabled object used as the physics imposter
  20494. */
  20495. object: IPhysicsEnabledObject,
  20496. /**
  20497. * The type of the physics imposter
  20498. */
  20499. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20500. /**
  20501. * This function will completly initialize this impostor.
  20502. * It will create a new body - but only if this mesh has no parent.
  20503. * If it has, this impostor will not be used other than to define the impostor
  20504. * of the child mesh.
  20505. * @hidden
  20506. */
  20507. _init(): void;
  20508. private _getPhysicsParent;
  20509. /**
  20510. * Should a new body be generated.
  20511. * @returns boolean specifying if body initialization is required
  20512. */
  20513. isBodyInitRequired(): boolean;
  20514. /**
  20515. * Sets the updated scaling
  20516. * @param updated Specifies if the scaling is updated
  20517. */
  20518. setScalingUpdated(): void;
  20519. /**
  20520. * Force a regeneration of this or the parent's impostor's body.
  20521. * Use under cautious - This will remove all joints already implemented.
  20522. */
  20523. forceUpdate(): void;
  20524. /**
  20525. * Gets the body that holds this impostor. Either its own, or its parent.
  20526. */
  20527. /**
  20528. * Set the physics body. Used mainly by the physics engine/plugin
  20529. */
  20530. physicsBody: any;
  20531. /**
  20532. * Get the parent of the physics imposter
  20533. * @returns Physics imposter or null
  20534. */
  20535. /**
  20536. * Sets the parent of the physics imposter
  20537. */
  20538. parent: Nullable<PhysicsImpostor>;
  20539. /**
  20540. * Resets the update flags
  20541. */
  20542. resetUpdateFlags(): void;
  20543. /**
  20544. * Gets the object extend size
  20545. * @returns the object extend size
  20546. */
  20547. getObjectExtendSize(): Vector3;
  20548. /**
  20549. * Gets the object center
  20550. * @returns The object center
  20551. */
  20552. getObjectCenter(): Vector3;
  20553. /**
  20554. * Get a specific parametes from the options parameter
  20555. * @param paramName The object parameter name
  20556. * @returns The object parameter
  20557. */
  20558. getParam(paramName: string): any;
  20559. /**
  20560. * Sets a specific parameter in the options given to the physics plugin
  20561. * @param paramName The parameter name
  20562. * @param value The value of the parameter
  20563. */
  20564. setParam(paramName: string, value: number): void;
  20565. /**
  20566. * Specifically change the body's mass option. Won't recreate the physics body object
  20567. * @param mass The mass of the physics imposter
  20568. */
  20569. setMass(mass: number): void;
  20570. /**
  20571. * Gets the linear velocity
  20572. * @returns linear velocity or null
  20573. */
  20574. getLinearVelocity(): Nullable<Vector3>;
  20575. /**
  20576. * Sets the linear velocity
  20577. * @param velocity linear velocity or null
  20578. */
  20579. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20580. /**
  20581. * Gets the angular velocity
  20582. * @returns angular velocity or null
  20583. */
  20584. getAngularVelocity(): Nullable<Vector3>;
  20585. /**
  20586. * Sets the angular velocity
  20587. * @param velocity The velocity or null
  20588. */
  20589. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20590. /**
  20591. * Execute a function with the physics plugin native code
  20592. * Provide a function the will have two variables - the world object and the physics body object
  20593. * @param func The function to execute with the physics plugin native code
  20594. */
  20595. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20596. /**
  20597. * Register a function that will be executed before the physics world is stepping forward
  20598. * @param func The function to execute before the physics world is stepped forward
  20599. */
  20600. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20601. /**
  20602. * Unregister a function that will be executed before the physics world is stepping forward
  20603. * @param func The function to execute before the physics world is stepped forward
  20604. */
  20605. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20606. /**
  20607. * Register a function that will be executed after the physics step
  20608. * @param func The function to execute after physics step
  20609. */
  20610. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20611. /**
  20612. * Unregisters a function that will be executed after the physics step
  20613. * @param func The function to execute after physics step
  20614. */
  20615. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20616. /**
  20617. * register a function that will be executed when this impostor collides against a different body
  20618. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20619. * @param func Callback that is executed on collision
  20620. */
  20621. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20622. /**
  20623. * Unregisters the physics imposter on contact
  20624. * @param collideAgainst The physics object to collide against
  20625. * @param func Callback to execute on collision
  20626. */
  20627. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20628. private _tmpQuat;
  20629. private _tmpQuat2;
  20630. /**
  20631. * Get the parent rotation
  20632. * @returns The parent rotation
  20633. */
  20634. getParentsRotation(): Quaternion;
  20635. /**
  20636. * this function is executed by the physics engine.
  20637. */
  20638. beforeStep: () => void;
  20639. /**
  20640. * this function is executed by the physics engine
  20641. */
  20642. afterStep: () => void;
  20643. /**
  20644. * Legacy collision detection event support
  20645. */
  20646. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20647. /**
  20648. * event and body object due to cannon's event-based architecture.
  20649. */
  20650. onCollide: (e: {
  20651. body: any;
  20652. }) => void;
  20653. /**
  20654. * Apply a force
  20655. * @param force The force to apply
  20656. * @param contactPoint The contact point for the force
  20657. * @returns The physics imposter
  20658. */
  20659. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20660. /**
  20661. * Apply an impulse
  20662. * @param force The impulse force
  20663. * @param contactPoint The contact point for the impulse force
  20664. * @returns The physics imposter
  20665. */
  20666. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20667. /**
  20668. * A help function to create a joint
  20669. * @param otherImpostor A physics imposter used to create a joint
  20670. * @param jointType The type of joint
  20671. * @param jointData The data for the joint
  20672. * @returns The physics imposter
  20673. */
  20674. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20675. /**
  20676. * Add a joint to this impostor with a different impostor
  20677. * @param otherImpostor A physics imposter used to add a joint
  20678. * @param joint The joint to add
  20679. * @returns The physics imposter
  20680. */
  20681. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20682. /**
  20683. * Add an anchor to a cloth impostor
  20684. * @param otherImpostor rigid impostor to anchor to
  20685. * @param width ratio across width from 0 to 1
  20686. * @param height ratio up height from 0 to 1
  20687. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20688. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20689. * @returns impostor the soft imposter
  20690. */
  20691. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20692. /**
  20693. * Add a hook to a rope impostor
  20694. * @param otherImpostor rigid impostor to anchor to
  20695. * @param length ratio across rope from 0 to 1
  20696. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20697. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20698. * @returns impostor the rope imposter
  20699. */
  20700. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20701. /**
  20702. * Will keep this body still, in a sleep mode.
  20703. * @returns the physics imposter
  20704. */
  20705. sleep(): PhysicsImpostor;
  20706. /**
  20707. * Wake the body up.
  20708. * @returns The physics imposter
  20709. */
  20710. wakeUp(): PhysicsImpostor;
  20711. /**
  20712. * Clones the physics imposter
  20713. * @param newObject The physics imposter clones to this physics-enabled object
  20714. * @returns A nullable physics imposter
  20715. */
  20716. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20717. /**
  20718. * Disposes the physics imposter
  20719. */
  20720. dispose(): void;
  20721. /**
  20722. * Sets the delta position
  20723. * @param position The delta position amount
  20724. */
  20725. setDeltaPosition(position: Vector3): void;
  20726. /**
  20727. * Sets the delta rotation
  20728. * @param rotation The delta rotation amount
  20729. */
  20730. setDeltaRotation(rotation: Quaternion): void;
  20731. /**
  20732. * Gets the box size of the physics imposter and stores the result in the input parameter
  20733. * @param result Stores the box size
  20734. * @returns The physics imposter
  20735. */
  20736. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20737. /**
  20738. * Gets the radius of the physics imposter
  20739. * @returns Radius of the physics imposter
  20740. */
  20741. getRadius(): number;
  20742. /**
  20743. * Sync a bone with this impostor
  20744. * @param bone The bone to sync to the impostor.
  20745. * @param boneMesh The mesh that the bone is influencing.
  20746. * @param jointPivot The pivot of the joint / bone in local space.
  20747. * @param distToJoint Optional distance from the impostor to the joint.
  20748. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20749. */
  20750. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20751. /**
  20752. * Sync impostor to a bone
  20753. * @param bone The bone that the impostor will be synced to.
  20754. * @param boneMesh The mesh that the bone is influencing.
  20755. * @param jointPivot The pivot of the joint / bone in local space.
  20756. * @param distToJoint Optional distance from the impostor to the joint.
  20757. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20758. * @param boneAxis Optional vector3 axis the bone is aligned with
  20759. */
  20760. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20761. /**
  20762. * No-Imposter type
  20763. */
  20764. static NoImpostor: number;
  20765. /**
  20766. * Sphere-Imposter type
  20767. */
  20768. static SphereImpostor: number;
  20769. /**
  20770. * Box-Imposter type
  20771. */
  20772. static BoxImpostor: number;
  20773. /**
  20774. * Plane-Imposter type
  20775. */
  20776. static PlaneImpostor: number;
  20777. /**
  20778. * Mesh-imposter type
  20779. */
  20780. static MeshImpostor: number;
  20781. /**
  20782. * Cylinder-Imposter type
  20783. */
  20784. static CylinderImpostor: number;
  20785. /**
  20786. * Particle-Imposter type
  20787. */
  20788. static ParticleImpostor: number;
  20789. /**
  20790. * Heightmap-Imposter type
  20791. */
  20792. static HeightmapImpostor: number;
  20793. /**
  20794. * ConvexHull-Impostor type (Ammo.js plugin only)
  20795. */
  20796. static ConvexHullImpostor: number;
  20797. /**
  20798. * Rope-Imposter type
  20799. */
  20800. static RopeImpostor: number;
  20801. /**
  20802. * Cloth-Imposter type
  20803. */
  20804. static ClothImpostor: number;
  20805. /**
  20806. * Softbody-Imposter type
  20807. */
  20808. static SoftbodyImpostor: number;
  20809. }
  20810. }
  20811. declare module BABYLON {
  20812. /**
  20813. * @hidden
  20814. **/
  20815. export class _CreationDataStorage {
  20816. closePath?: boolean;
  20817. closeArray?: boolean;
  20818. idx: number[];
  20819. dashSize: number;
  20820. gapSize: number;
  20821. path3D: Path3D;
  20822. pathArray: Vector3[][];
  20823. arc: number;
  20824. radius: number;
  20825. cap: number;
  20826. tessellation: number;
  20827. }
  20828. /**
  20829. * @hidden
  20830. **/
  20831. class _InstanceDataStorage {
  20832. visibleInstances: any;
  20833. batchCache: _InstancesBatch;
  20834. instancesBufferSize: number;
  20835. instancesBuffer: Nullable<Buffer>;
  20836. instancesData: Float32Array;
  20837. overridenInstanceCount: number;
  20838. isFrozen: boolean;
  20839. previousBatch: _InstancesBatch;
  20840. hardwareInstancedRendering: boolean;
  20841. sideOrientation: number;
  20842. }
  20843. /**
  20844. * @hidden
  20845. **/
  20846. export class _InstancesBatch {
  20847. mustReturn: boolean;
  20848. visibleInstances: Nullable<InstancedMesh[]>[];
  20849. renderSelf: boolean[];
  20850. hardwareInstancedRendering: boolean[];
  20851. }
  20852. /**
  20853. * Class used to represent renderable models
  20854. */
  20855. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20856. /**
  20857. * Mesh side orientation : usually the external or front surface
  20858. */
  20859. static readonly FRONTSIDE: number;
  20860. /**
  20861. * Mesh side orientation : usually the internal or back surface
  20862. */
  20863. static readonly BACKSIDE: number;
  20864. /**
  20865. * Mesh side orientation : both internal and external or front and back surfaces
  20866. */
  20867. static readonly DOUBLESIDE: number;
  20868. /**
  20869. * Mesh side orientation : by default, `FRONTSIDE`
  20870. */
  20871. static readonly DEFAULTSIDE: number;
  20872. /**
  20873. * Mesh cap setting : no cap
  20874. */
  20875. static readonly NO_CAP: number;
  20876. /**
  20877. * Mesh cap setting : one cap at the beginning of the mesh
  20878. */
  20879. static readonly CAP_START: number;
  20880. /**
  20881. * Mesh cap setting : one cap at the end of the mesh
  20882. */
  20883. static readonly CAP_END: number;
  20884. /**
  20885. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20886. */
  20887. static readonly CAP_ALL: number;
  20888. /**
  20889. * Gets the default side orientation.
  20890. * @param orientation the orientation to value to attempt to get
  20891. * @returns the default orientation
  20892. * @hidden
  20893. */
  20894. static _GetDefaultSideOrientation(orientation?: number): number;
  20895. private _onBeforeRenderObservable;
  20896. private _onBeforeBindObservable;
  20897. private _onAfterRenderObservable;
  20898. private _onBeforeDrawObservable;
  20899. /**
  20900. * An event triggered before rendering the mesh
  20901. */
  20902. readonly onBeforeRenderObservable: Observable<Mesh>;
  20903. /**
  20904. * An event triggered before binding the mesh
  20905. */
  20906. readonly onBeforeBindObservable: Observable<Mesh>;
  20907. /**
  20908. * An event triggered after rendering the mesh
  20909. */
  20910. readonly onAfterRenderObservable: Observable<Mesh>;
  20911. /**
  20912. * An event triggered before drawing the mesh
  20913. */
  20914. readonly onBeforeDrawObservable: Observable<Mesh>;
  20915. private _onBeforeDrawObserver;
  20916. /**
  20917. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20918. */
  20919. onBeforeDraw: () => void;
  20920. /**
  20921. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20922. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20923. */
  20924. delayLoadState: number;
  20925. /**
  20926. * Gets the list of instances created from this mesh
  20927. * it is not supposed to be modified manually.
  20928. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20929. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20930. */
  20931. instances: InstancedMesh[];
  20932. /**
  20933. * Gets the file containing delay loading data for this mesh
  20934. */
  20935. delayLoadingFile: string;
  20936. /** @hidden */
  20937. _binaryInfo: any;
  20938. private _LODLevels;
  20939. /**
  20940. * User defined function used to change how LOD level selection is done
  20941. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20942. */
  20943. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20944. private _morphTargetManager;
  20945. /**
  20946. * Gets or sets the morph target manager
  20947. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20948. */
  20949. morphTargetManager: Nullable<MorphTargetManager>;
  20950. /** @hidden */
  20951. _creationDataStorage: Nullable<_CreationDataStorage>;
  20952. /** @hidden */
  20953. _geometry: Nullable<Geometry>;
  20954. /** @hidden */
  20955. _delayInfo: Array<string>;
  20956. /** @hidden */
  20957. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20958. /** @hidden */
  20959. _instanceDataStorage: _InstanceDataStorage;
  20960. private _effectiveMaterial;
  20961. /** @hidden */
  20962. _shouldGenerateFlatShading: boolean;
  20963. private _preActivateId;
  20964. /** @hidden */
  20965. _originalBuilderSideOrientation: number;
  20966. /**
  20967. * Use this property to change the original side orientation defined at construction time
  20968. */
  20969. overrideMaterialSideOrientation: Nullable<number>;
  20970. private _areNormalsFrozen;
  20971. private _sourcePositions;
  20972. private _sourceNormals;
  20973. private _source;
  20974. private meshMap;
  20975. /**
  20976. * Gets the source mesh (the one used to clone this one from)
  20977. */
  20978. readonly source: Nullable<Mesh>;
  20979. /**
  20980. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20981. */
  20982. isUnIndexed: boolean;
  20983. /**
  20984. * @constructor
  20985. * @param name The value used by scene.getMeshByName() to do a lookup.
  20986. * @param scene The scene to add this mesh to.
  20987. * @param parent The parent of this mesh, if it has one
  20988. * @param source An optional Mesh from which geometry is shared, cloned.
  20989. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20990. * When false, achieved by calling a clone(), also passing False.
  20991. * This will make creation of children, recursive.
  20992. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20993. */
  20994. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20995. /**
  20996. * Gets the class name
  20997. * @returns the string "Mesh".
  20998. */
  20999. getClassName(): string;
  21000. /** @hidden */
  21001. readonly _isMesh: boolean;
  21002. /**
  21003. * Returns a description of this mesh
  21004. * @param fullDetails define if full details about this mesh must be used
  21005. * @returns a descriptive string representing this mesh
  21006. */
  21007. toString(fullDetails?: boolean): string;
  21008. /** @hidden */
  21009. _unBindEffect(): void;
  21010. /**
  21011. * Gets a boolean indicating if this mesh has LOD
  21012. */
  21013. readonly hasLODLevels: boolean;
  21014. /**
  21015. * Gets the list of MeshLODLevel associated with the current mesh
  21016. * @returns an array of MeshLODLevel
  21017. */
  21018. getLODLevels(): MeshLODLevel[];
  21019. private _sortLODLevels;
  21020. /**
  21021. * Add a mesh as LOD level triggered at the given distance.
  21022. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21023. * @param distance The distance from the center of the object to show this level
  21024. * @param mesh The mesh to be added as LOD level (can be null)
  21025. * @return This mesh (for chaining)
  21026. */
  21027. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21028. /**
  21029. * Returns the LOD level mesh at the passed distance or null if not found.
  21030. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21031. * @param distance The distance from the center of the object to show this level
  21032. * @returns a Mesh or `null`
  21033. */
  21034. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21035. /**
  21036. * Remove a mesh from the LOD array
  21037. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21038. * @param mesh defines the mesh to be removed
  21039. * @return This mesh (for chaining)
  21040. */
  21041. removeLODLevel(mesh: Mesh): Mesh;
  21042. /**
  21043. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21044. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21045. * @param camera defines the camera to use to compute distance
  21046. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21047. * @return This mesh (for chaining)
  21048. */
  21049. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21050. /**
  21051. * Gets the mesh internal Geometry object
  21052. */
  21053. readonly geometry: Nullable<Geometry>;
  21054. /**
  21055. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21056. * @returns the total number of vertices
  21057. */
  21058. getTotalVertices(): number;
  21059. /**
  21060. * Returns the content of an associated vertex buffer
  21061. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21062. * - VertexBuffer.PositionKind
  21063. * - VertexBuffer.UVKind
  21064. * - VertexBuffer.UV2Kind
  21065. * - VertexBuffer.UV3Kind
  21066. * - VertexBuffer.UV4Kind
  21067. * - VertexBuffer.UV5Kind
  21068. * - VertexBuffer.UV6Kind
  21069. * - VertexBuffer.ColorKind
  21070. * - VertexBuffer.MatricesIndicesKind
  21071. * - VertexBuffer.MatricesIndicesExtraKind
  21072. * - VertexBuffer.MatricesWeightsKind
  21073. * - VertexBuffer.MatricesWeightsExtraKind
  21074. * @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
  21075. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21076. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21077. */
  21078. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21079. /**
  21080. * Returns the mesh VertexBuffer object from the requested `kind`
  21081. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21082. * - VertexBuffer.PositionKind
  21083. * - VertexBuffer.UVKind
  21084. * - VertexBuffer.UV2Kind
  21085. * - VertexBuffer.UV3Kind
  21086. * - VertexBuffer.UV4Kind
  21087. * - VertexBuffer.UV5Kind
  21088. * - VertexBuffer.UV6Kind
  21089. * - VertexBuffer.ColorKind
  21090. * - VertexBuffer.MatricesIndicesKind
  21091. * - VertexBuffer.MatricesIndicesExtraKind
  21092. * - VertexBuffer.MatricesWeightsKind
  21093. * - VertexBuffer.MatricesWeightsExtraKind
  21094. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21095. */
  21096. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21097. /**
  21098. * Tests if a specific vertex buffer is associated with this mesh
  21099. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21100. * - VertexBuffer.PositionKind
  21101. * - VertexBuffer.UVKind
  21102. * - VertexBuffer.UV2Kind
  21103. * - VertexBuffer.UV3Kind
  21104. * - VertexBuffer.UV4Kind
  21105. * - VertexBuffer.UV5Kind
  21106. * - VertexBuffer.UV6Kind
  21107. * - VertexBuffer.ColorKind
  21108. * - VertexBuffer.MatricesIndicesKind
  21109. * - VertexBuffer.MatricesIndicesExtraKind
  21110. * - VertexBuffer.MatricesWeightsKind
  21111. * - VertexBuffer.MatricesWeightsExtraKind
  21112. * @returns a boolean
  21113. */
  21114. isVerticesDataPresent(kind: string): boolean;
  21115. /**
  21116. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21117. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21118. * - VertexBuffer.PositionKind
  21119. * - VertexBuffer.UVKind
  21120. * - VertexBuffer.UV2Kind
  21121. * - VertexBuffer.UV3Kind
  21122. * - VertexBuffer.UV4Kind
  21123. * - VertexBuffer.UV5Kind
  21124. * - VertexBuffer.UV6Kind
  21125. * - VertexBuffer.ColorKind
  21126. * - VertexBuffer.MatricesIndicesKind
  21127. * - VertexBuffer.MatricesIndicesExtraKind
  21128. * - VertexBuffer.MatricesWeightsKind
  21129. * - VertexBuffer.MatricesWeightsExtraKind
  21130. * @returns a boolean
  21131. */
  21132. isVertexBufferUpdatable(kind: string): boolean;
  21133. /**
  21134. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21135. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21136. * - VertexBuffer.PositionKind
  21137. * - VertexBuffer.UVKind
  21138. * - VertexBuffer.UV2Kind
  21139. * - VertexBuffer.UV3Kind
  21140. * - VertexBuffer.UV4Kind
  21141. * - VertexBuffer.UV5Kind
  21142. * - VertexBuffer.UV6Kind
  21143. * - VertexBuffer.ColorKind
  21144. * - VertexBuffer.MatricesIndicesKind
  21145. * - VertexBuffer.MatricesIndicesExtraKind
  21146. * - VertexBuffer.MatricesWeightsKind
  21147. * - VertexBuffer.MatricesWeightsExtraKind
  21148. * @returns an array of strings
  21149. */
  21150. getVerticesDataKinds(): string[];
  21151. /**
  21152. * Returns a positive integer : the total number of indices in this mesh geometry.
  21153. * @returns the numner of indices or zero if the mesh has no geometry.
  21154. */
  21155. getTotalIndices(): number;
  21156. /**
  21157. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21158. * @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.
  21159. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21160. * @returns the indices array or an empty array if the mesh has no geometry
  21161. */
  21162. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21163. readonly isBlocked: boolean;
  21164. /**
  21165. * Determine if the current mesh is ready to be rendered
  21166. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21167. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21168. * @returns true if all associated assets are ready (material, textures, shaders)
  21169. */
  21170. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21171. /**
  21172. * 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.
  21173. */
  21174. readonly areNormalsFrozen: boolean;
  21175. /**
  21176. * 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.
  21177. * @returns the current mesh
  21178. */
  21179. freezeNormals(): Mesh;
  21180. /**
  21181. * 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
  21182. * @returns the current mesh
  21183. */
  21184. unfreezeNormals(): Mesh;
  21185. /**
  21186. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21187. */
  21188. overridenInstanceCount: number;
  21189. /** @hidden */
  21190. _preActivate(): Mesh;
  21191. /** @hidden */
  21192. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21193. /** @hidden */
  21194. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21195. /**
  21196. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21197. * This means the mesh underlying bounding box and sphere are recomputed.
  21198. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21199. * @returns the current mesh
  21200. */
  21201. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21202. /** @hidden */
  21203. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21204. /**
  21205. * This function will subdivide the mesh into multiple submeshes
  21206. * @param count defines the expected number of submeshes
  21207. */
  21208. subdivide(count: number): void;
  21209. /**
  21210. * Copy a FloatArray into a specific associated vertex buffer
  21211. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21212. * - VertexBuffer.PositionKind
  21213. * - VertexBuffer.UVKind
  21214. * - VertexBuffer.UV2Kind
  21215. * - VertexBuffer.UV3Kind
  21216. * - VertexBuffer.UV4Kind
  21217. * - VertexBuffer.UV5Kind
  21218. * - VertexBuffer.UV6Kind
  21219. * - VertexBuffer.ColorKind
  21220. * - VertexBuffer.MatricesIndicesKind
  21221. * - VertexBuffer.MatricesIndicesExtraKind
  21222. * - VertexBuffer.MatricesWeightsKind
  21223. * - VertexBuffer.MatricesWeightsExtraKind
  21224. * @param data defines the data source
  21225. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21226. * @param stride defines the data stride size (can be null)
  21227. * @returns the current mesh
  21228. */
  21229. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21230. /**
  21231. * Flags an associated vertex buffer as updatable
  21232. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21233. * - VertexBuffer.PositionKind
  21234. * - VertexBuffer.UVKind
  21235. * - VertexBuffer.UV2Kind
  21236. * - VertexBuffer.UV3Kind
  21237. * - VertexBuffer.UV4Kind
  21238. * - VertexBuffer.UV5Kind
  21239. * - VertexBuffer.UV6Kind
  21240. * - VertexBuffer.ColorKind
  21241. * - VertexBuffer.MatricesIndicesKind
  21242. * - VertexBuffer.MatricesIndicesExtraKind
  21243. * - VertexBuffer.MatricesWeightsKind
  21244. * - VertexBuffer.MatricesWeightsExtraKind
  21245. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21246. */
  21247. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21248. /**
  21249. * Sets the mesh global Vertex Buffer
  21250. * @param buffer defines the buffer to use
  21251. * @returns the current mesh
  21252. */
  21253. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21254. /**
  21255. * Update a specific associated vertex buffer
  21256. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21257. * - VertexBuffer.PositionKind
  21258. * - VertexBuffer.UVKind
  21259. * - VertexBuffer.UV2Kind
  21260. * - VertexBuffer.UV3Kind
  21261. * - VertexBuffer.UV4Kind
  21262. * - VertexBuffer.UV5Kind
  21263. * - VertexBuffer.UV6Kind
  21264. * - VertexBuffer.ColorKind
  21265. * - VertexBuffer.MatricesIndicesKind
  21266. * - VertexBuffer.MatricesIndicesExtraKind
  21267. * - VertexBuffer.MatricesWeightsKind
  21268. * - VertexBuffer.MatricesWeightsExtraKind
  21269. * @param data defines the data source
  21270. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21271. * @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)
  21272. * @returns the current mesh
  21273. */
  21274. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21275. /**
  21276. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21277. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21278. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21279. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21280. * @returns the current mesh
  21281. */
  21282. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21283. /**
  21284. * Creates a un-shared specific occurence of the geometry for the mesh.
  21285. * @returns the current mesh
  21286. */
  21287. makeGeometryUnique(): Mesh;
  21288. /**
  21289. * Set the index buffer of this mesh
  21290. * @param indices defines the source data
  21291. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21292. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21293. * @returns the current mesh
  21294. */
  21295. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21296. /**
  21297. * Update the current index buffer
  21298. * @param indices defines the source data
  21299. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21300. * @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)
  21301. * @returns the current mesh
  21302. */
  21303. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21304. /**
  21305. * Invert the geometry to move from a right handed system to a left handed one.
  21306. * @returns the current mesh
  21307. */
  21308. toLeftHanded(): Mesh;
  21309. /** @hidden */
  21310. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21311. /** @hidden */
  21312. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21313. /**
  21314. * Registers for this mesh a javascript function called just before the rendering process
  21315. * @param func defines the function to call before rendering this mesh
  21316. * @returns the current mesh
  21317. */
  21318. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21319. /**
  21320. * Disposes a previously registered javascript function called before the rendering
  21321. * @param func defines the function to remove
  21322. * @returns the current mesh
  21323. */
  21324. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21325. /**
  21326. * Registers for this mesh a javascript function called just after the rendering is complete
  21327. * @param func defines the function to call after rendering this mesh
  21328. * @returns the current mesh
  21329. */
  21330. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21331. /**
  21332. * Disposes a previously registered javascript function called after the rendering.
  21333. * @param func defines the function to remove
  21334. * @returns the current mesh
  21335. */
  21336. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21337. /** @hidden */
  21338. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21339. /** @hidden */
  21340. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21341. /** @hidden */
  21342. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21343. /** @hidden */
  21344. _freeze(): void;
  21345. /** @hidden */
  21346. _unFreeze(): void;
  21347. /**
  21348. * 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
  21349. * @param subMesh defines the subMesh to render
  21350. * @param enableAlphaMode defines if alpha mode can be changed
  21351. * @returns the current mesh
  21352. */
  21353. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21354. private _onBeforeDraw;
  21355. /**
  21356. * Renormalize the mesh and patch it up if there are no weights
  21357. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21358. * However in the case of zero weights then we set just a single influence to 1.
  21359. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21360. */
  21361. cleanMatrixWeights(): void;
  21362. private normalizeSkinFourWeights;
  21363. private normalizeSkinWeightsAndExtra;
  21364. /**
  21365. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21366. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21367. * the user know there was an issue with importing the mesh
  21368. * @returns a validation object with skinned, valid and report string
  21369. */
  21370. validateSkinning(): {
  21371. skinned: boolean;
  21372. valid: boolean;
  21373. report: string;
  21374. };
  21375. /** @hidden */
  21376. _checkDelayState(): Mesh;
  21377. private _queueLoad;
  21378. /**
  21379. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21380. * A mesh is in the frustum if its bounding box intersects the frustum
  21381. * @param frustumPlanes defines the frustum to test
  21382. * @returns true if the mesh is in the frustum planes
  21383. */
  21384. isInFrustum(frustumPlanes: Plane[]): boolean;
  21385. /**
  21386. * Sets the mesh material by the material or multiMaterial `id` property
  21387. * @param id is a string identifying the material or the multiMaterial
  21388. * @returns the current mesh
  21389. */
  21390. setMaterialByID(id: string): Mesh;
  21391. /**
  21392. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21393. * @returns an array of IAnimatable
  21394. */
  21395. getAnimatables(): IAnimatable[];
  21396. /**
  21397. * Modifies the mesh geometry according to the passed transformation matrix.
  21398. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21399. * The mesh normals are modified using the same transformation.
  21400. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21401. * @param transform defines the transform matrix to use
  21402. * @see http://doc.babylonjs.com/resources/baking_transformations
  21403. * @returns the current mesh
  21404. */
  21405. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21406. /**
  21407. * Modifies the mesh geometry according to its own current World Matrix.
  21408. * The mesh World Matrix is then reset.
  21409. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21410. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21411. * @see http://doc.babylonjs.com/resources/baking_transformations
  21412. * @returns the current mesh
  21413. */
  21414. bakeCurrentTransformIntoVertices(): Mesh;
  21415. /** @hidden */
  21416. readonly _positions: Nullable<Vector3[]>;
  21417. /** @hidden */
  21418. _resetPointsArrayCache(): Mesh;
  21419. /** @hidden */
  21420. _generatePointsArray(): boolean;
  21421. /**
  21422. * Returns a new Mesh object generated from the current mesh properties.
  21423. * This method must not get confused with createInstance()
  21424. * @param name is a string, the name given to the new mesh
  21425. * @param newParent can be any Node object (default `null`)
  21426. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21427. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21428. * @returns a new mesh
  21429. */
  21430. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21431. /**
  21432. * Releases resources associated with this mesh.
  21433. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21434. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21435. */
  21436. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21437. /**
  21438. * Modifies the mesh geometry according to a displacement map.
  21439. * 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.
  21440. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21441. * @param url is a string, the URL from the image file is to be downloaded.
  21442. * @param minHeight is the lower limit of the displacement.
  21443. * @param maxHeight is the upper limit of the displacement.
  21444. * @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.
  21445. * @param uvOffset is an optional vector2 used to offset UV.
  21446. * @param uvScale is an optional vector2 used to scale UV.
  21447. * @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.
  21448. * @returns the Mesh.
  21449. */
  21450. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21451. /**
  21452. * Modifies the mesh geometry according to a displacementMap buffer.
  21453. * 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.
  21454. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21455. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21456. * @param heightMapWidth is the width of the buffer image.
  21457. * @param heightMapHeight is the height of the buffer image.
  21458. * @param minHeight is the lower limit of the displacement.
  21459. * @param maxHeight is the upper limit of the displacement.
  21460. * @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.
  21461. * @param uvOffset is an optional vector2 used to offset UV.
  21462. * @param uvScale is an optional vector2 used to scale UV.
  21463. * @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.
  21464. * @returns the Mesh.
  21465. */
  21466. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21467. /**
  21468. * Modify the mesh to get a flat shading rendering.
  21469. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21470. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21471. * @returns current mesh
  21472. */
  21473. convertToFlatShadedMesh(): Mesh;
  21474. /**
  21475. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21476. * In other words, more vertices, no more indices and a single bigger VBO.
  21477. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21478. * @returns current mesh
  21479. */
  21480. convertToUnIndexedMesh(): Mesh;
  21481. /**
  21482. * Inverses facet orientations.
  21483. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21484. * @param flipNormals will also inverts the normals
  21485. * @returns current mesh
  21486. */
  21487. flipFaces(flipNormals?: boolean): Mesh;
  21488. /**
  21489. * Increase the number of facets and hence vertices in a mesh
  21490. * Vertex normals are interpolated from existing vertex normals
  21491. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21492. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21493. */
  21494. increaseVertices(numberPerEdge: number): void;
  21495. /**
  21496. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21497. * This will undo any application of covertToFlatShadedMesh
  21498. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21499. */
  21500. forceSharedVertices(): void;
  21501. /** @hidden */
  21502. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21503. /** @hidden */
  21504. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21505. /**
  21506. * Creates a new InstancedMesh object from the mesh model.
  21507. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21508. * @param name defines the name of the new instance
  21509. * @returns a new InstancedMesh
  21510. */
  21511. createInstance(name: string): InstancedMesh;
  21512. /**
  21513. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21514. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21515. * @returns the current mesh
  21516. */
  21517. synchronizeInstances(): Mesh;
  21518. /**
  21519. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21520. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21521. * This should be used together with the simplification to avoid disappearing triangles.
  21522. * @param successCallback an optional success callback to be called after the optimization finished.
  21523. * @returns the current mesh
  21524. */
  21525. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21526. /**
  21527. * Serialize current mesh
  21528. * @param serializationObject defines the object which will receive the serialization data
  21529. */
  21530. serialize(serializationObject: any): void;
  21531. /** @hidden */
  21532. _syncGeometryWithMorphTargetManager(): void;
  21533. /** @hidden */
  21534. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21535. /**
  21536. * Returns a new Mesh object parsed from the source provided.
  21537. * @param parsedMesh is the source
  21538. * @param scene defines the hosting scene
  21539. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21540. * @returns a new Mesh
  21541. */
  21542. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21543. /**
  21544. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21545. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21546. * @param name defines the name of the mesh to create
  21547. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21548. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21549. * @param closePath creates a seam between the first and the last points of each path of the path array
  21550. * @param offset is taken in account only if the `pathArray` is containing a single path
  21551. * @param scene defines the hosting scene
  21552. * @param updatable defines if the mesh must be flagged as updatable
  21553. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21554. * @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)
  21555. * @returns a new Mesh
  21556. */
  21557. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21558. /**
  21559. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21560. * @param name defines the name of the mesh to create
  21561. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21562. * @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
  21563. * @param scene defines the hosting scene
  21564. * @param updatable defines if the mesh must be flagged as updatable
  21565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21566. * @returns a new Mesh
  21567. */
  21568. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21569. /**
  21570. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21571. * @param name defines the name of the mesh to create
  21572. * @param size sets the size (float) of each box side (default 1)
  21573. * @param scene defines the hosting scene
  21574. * @param updatable defines if the mesh must be flagged as updatable
  21575. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21576. * @returns a new Mesh
  21577. */
  21578. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21579. /**
  21580. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21581. * @param name defines the name of the mesh to create
  21582. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21583. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21584. * @param scene defines the hosting scene
  21585. * @param updatable defines if the mesh must be flagged as updatable
  21586. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21587. * @returns a new Mesh
  21588. */
  21589. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21590. /**
  21591. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21592. * @param name defines the name of the mesh to create
  21593. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21594. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21595. * @param scene defines the hosting scene
  21596. * @returns a new Mesh
  21597. */
  21598. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21599. /**
  21600. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21601. * @param name defines the name of the mesh to create
  21602. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21603. * @param diameterTop set the top cap diameter (floats, default 1)
  21604. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21605. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21606. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21607. * @param scene defines the hosting scene
  21608. * @param updatable defines if the mesh must be flagged as updatable
  21609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21610. * @returns a new Mesh
  21611. */
  21612. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21613. /**
  21614. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21615. * @param name defines the name of the mesh to create
  21616. * @param diameter sets the diameter size (float) of the torus (default 1)
  21617. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21618. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21619. * @param scene defines the hosting scene
  21620. * @param updatable defines if the mesh must be flagged as updatable
  21621. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21622. * @returns a new Mesh
  21623. */
  21624. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21625. /**
  21626. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21627. * @param name defines the name of the mesh to create
  21628. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21629. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21630. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21631. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21632. * @param p the number of windings on X axis (positive integers, default 2)
  21633. * @param q the number of windings on Y axis (positive integers, default 3)
  21634. * @param scene defines the hosting scene
  21635. * @param updatable defines if the mesh must be flagged as updatable
  21636. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21637. * @returns a new Mesh
  21638. */
  21639. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21640. /**
  21641. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21642. * @param name defines the name of the mesh to create
  21643. * @param points is an array successive Vector3
  21644. * @param scene defines the hosting scene
  21645. * @param updatable defines if the mesh must be flagged as updatable
  21646. * @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).
  21647. * @returns a new Mesh
  21648. */
  21649. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21650. /**
  21651. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21652. * @param name defines the name of the mesh to create
  21653. * @param points is an array successive Vector3
  21654. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21655. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21656. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21657. * @param scene defines the hosting scene
  21658. * @param updatable defines if the mesh must be flagged as updatable
  21659. * @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)
  21660. * @returns a new Mesh
  21661. */
  21662. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21663. /**
  21664. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21665. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21666. * 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.
  21667. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21668. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21669. * Remember you can only change the shape positions, not their number when updating a polygon.
  21670. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21671. * @param name defines the name of the mesh to create
  21672. * @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
  21673. * @param scene defines the hosting scene
  21674. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21675. * @param updatable defines if the mesh must be flagged as updatable
  21676. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21677. * @param earcutInjection can be used to inject your own earcut reference
  21678. * @returns a new Mesh
  21679. */
  21680. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21681. /**
  21682. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21683. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21684. * @param name defines the name of the mesh to create
  21685. * @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
  21686. * @param depth defines the height of extrusion
  21687. * @param scene defines the hosting scene
  21688. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21689. * @param updatable defines if the mesh must be flagged as updatable
  21690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21691. * @param earcutInjection can be used to inject your own earcut reference
  21692. * @returns a new Mesh
  21693. */
  21694. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21695. /**
  21696. * Creates an extruded shape mesh.
  21697. * 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
  21698. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21699. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21700. * @param name defines the name of the mesh to create
  21701. * @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
  21702. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21703. * @param scale is the value to scale the shape
  21704. * @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
  21705. * @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
  21706. * @param scene defines the hosting scene
  21707. * @param updatable defines if the mesh must be flagged as updatable
  21708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21709. * @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)
  21710. * @returns a new Mesh
  21711. */
  21712. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21713. /**
  21714. * Creates an custom extruded shape mesh.
  21715. * The custom extrusion is a parametric shape.
  21716. * It has no predefined shape. Its final shape will depend on the input parameters.
  21717. * Please consider using the same method from the MeshBuilder class instead
  21718. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21719. * @param name defines the name of the mesh to create
  21720. * @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
  21721. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21722. * @param scaleFunction is a custom Javascript function called on each path point
  21723. * @param rotationFunction is a custom Javascript function called on each path point
  21724. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21725. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21726. * @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
  21727. * @param scene defines the hosting scene
  21728. * @param updatable defines if the mesh must be flagged as updatable
  21729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21730. * @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)
  21731. * @returns a new Mesh
  21732. */
  21733. 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;
  21734. /**
  21735. * Creates lathe mesh.
  21736. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21737. * Please consider using the same method from the MeshBuilder class instead
  21738. * @param name defines the name of the mesh to create
  21739. * @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
  21740. * @param radius is the radius value of the lathe
  21741. * @param tessellation is the side number of the lathe.
  21742. * @param scene defines the hosting scene
  21743. * @param updatable defines if the mesh must be flagged as updatable
  21744. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21745. * @returns a new Mesh
  21746. */
  21747. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21748. /**
  21749. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21750. * @param name defines the name of the mesh to create
  21751. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21752. * @param scene defines the hosting scene
  21753. * @param updatable defines if the mesh must be flagged as updatable
  21754. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21755. * @returns a new Mesh
  21756. */
  21757. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21758. /**
  21759. * Creates a ground mesh.
  21760. * Please consider using the same method from the MeshBuilder class instead
  21761. * @param name defines the name of the mesh to create
  21762. * @param width set the width of the ground
  21763. * @param height set the height of the ground
  21764. * @param subdivisions sets the number of subdivisions per side
  21765. * @param scene defines the hosting scene
  21766. * @param updatable defines if the mesh must be flagged as updatable
  21767. * @returns a new Mesh
  21768. */
  21769. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21770. /**
  21771. * Creates a tiled ground mesh.
  21772. * Please consider using the same method from the MeshBuilder class instead
  21773. * @param name defines the name of the mesh to create
  21774. * @param xmin set the ground minimum X coordinate
  21775. * @param zmin set the ground minimum Y coordinate
  21776. * @param xmax set the ground maximum X coordinate
  21777. * @param zmax set the ground maximum Z coordinate
  21778. * @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
  21779. * @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
  21780. * @param scene defines the hosting scene
  21781. * @param updatable defines if the mesh must be flagged as updatable
  21782. * @returns a new Mesh
  21783. */
  21784. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21785. w: number;
  21786. h: number;
  21787. }, precision: {
  21788. w: number;
  21789. h: number;
  21790. }, scene: Scene, updatable?: boolean): Mesh;
  21791. /**
  21792. * Creates a ground mesh from a height map.
  21793. * Please consider using the same method from the MeshBuilder class instead
  21794. * @see http://doc.babylonjs.com/babylon101/height_map
  21795. * @param name defines the name of the mesh to create
  21796. * @param url sets the URL of the height map image resource
  21797. * @param width set the ground width size
  21798. * @param height set the ground height size
  21799. * @param subdivisions sets the number of subdivision per side
  21800. * @param minHeight is the minimum altitude on the ground
  21801. * @param maxHeight is the maximum altitude on the ground
  21802. * @param scene defines the hosting scene
  21803. * @param updatable defines if the mesh must be flagged as updatable
  21804. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21805. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21806. * @returns a new Mesh
  21807. */
  21808. 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;
  21809. /**
  21810. * Creates a tube mesh.
  21811. * The tube is a parametric shape.
  21812. * It has no predefined shape. Its final shape will depend on the input parameters.
  21813. * Please consider using the same method from the MeshBuilder class instead
  21814. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21815. * @param name defines the name of the mesh to create
  21816. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21817. * @param radius sets the tube radius size
  21818. * @param tessellation is the number of sides on the tubular surface
  21819. * @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
  21820. * @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
  21821. * @param scene defines the hosting scene
  21822. * @param updatable defines if the mesh must be flagged as updatable
  21823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21824. * @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)
  21825. * @returns a new Mesh
  21826. */
  21827. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21828. (i: number, distance: number): number;
  21829. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21830. /**
  21831. * Creates a polyhedron mesh.
  21832. * Please consider using the same method from the MeshBuilder class instead.
  21833. * * 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
  21834. * * The parameter `size` (positive float, default 1) sets the polygon size
  21835. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21836. * * 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`
  21837. * * 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
  21838. * * 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)`)
  21839. * * 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
  21840. * * 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
  21841. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21842. * * 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
  21843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21844. * @param name defines the name of the mesh to create
  21845. * @param options defines the options used to create the mesh
  21846. * @param scene defines the hosting scene
  21847. * @returns a new Mesh
  21848. */
  21849. static CreatePolyhedron(name: string, options: {
  21850. type?: number;
  21851. size?: number;
  21852. sizeX?: number;
  21853. sizeY?: number;
  21854. sizeZ?: number;
  21855. custom?: any;
  21856. faceUV?: Vector4[];
  21857. faceColors?: Color4[];
  21858. updatable?: boolean;
  21859. sideOrientation?: number;
  21860. }, scene: Scene): Mesh;
  21861. /**
  21862. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21863. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21864. * * 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`)
  21865. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21866. * * 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
  21867. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21868. * * 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
  21869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21870. * @param name defines the name of the mesh
  21871. * @param options defines the options used to create the mesh
  21872. * @param scene defines the hosting scene
  21873. * @returns a new Mesh
  21874. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21875. */
  21876. static CreateIcoSphere(name: string, options: {
  21877. radius?: number;
  21878. flat?: boolean;
  21879. subdivisions?: number;
  21880. sideOrientation?: number;
  21881. updatable?: boolean;
  21882. }, scene: Scene): Mesh;
  21883. /**
  21884. * Creates a decal mesh.
  21885. * Please consider using the same method from the MeshBuilder class instead.
  21886. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21887. * @param name defines the name of the mesh
  21888. * @param sourceMesh defines the mesh receiving the decal
  21889. * @param position sets the position of the decal in world coordinates
  21890. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21891. * @param size sets the decal scaling
  21892. * @param angle sets the angle to rotate the decal
  21893. * @returns a new Mesh
  21894. */
  21895. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21896. /**
  21897. * Prepare internal position array for software CPU skinning
  21898. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21899. */
  21900. setPositionsForCPUSkinning(): Float32Array;
  21901. /**
  21902. * Prepare internal normal array for software CPU skinning
  21903. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21904. */
  21905. setNormalsForCPUSkinning(): Float32Array;
  21906. /**
  21907. * Updates the vertex buffer by applying transformation from the bones
  21908. * @param skeleton defines the skeleton to apply to current mesh
  21909. * @returns the current mesh
  21910. */
  21911. applySkeleton(skeleton: Skeleton): Mesh;
  21912. /**
  21913. * 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
  21914. * @param meshes defines the list of meshes to scan
  21915. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21916. */
  21917. static MinMax(meshes: AbstractMesh[]): {
  21918. min: Vector3;
  21919. max: Vector3;
  21920. };
  21921. /**
  21922. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21923. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21924. * @returns a vector3
  21925. */
  21926. static Center(meshesOrMinMaxVector: {
  21927. min: Vector3;
  21928. max: Vector3;
  21929. } | AbstractMesh[]): Vector3;
  21930. /**
  21931. * Merge the array of meshes into a single mesh for performance reasons.
  21932. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21933. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21934. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21935. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21936. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21937. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21938. * @returns a new mesh
  21939. */
  21940. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21941. /** @hidden */
  21942. addInstance(instance: InstancedMesh): void;
  21943. /** @hidden */
  21944. removeInstance(instance: InstancedMesh): void;
  21945. }
  21946. }
  21947. declare module BABYLON {
  21948. /**
  21949. * Base class for the main features of a material in Babylon.js
  21950. */
  21951. export class Material implements IAnimatable {
  21952. /**
  21953. * Returns the triangle fill mode
  21954. */
  21955. static readonly TriangleFillMode: number;
  21956. /**
  21957. * Returns the wireframe mode
  21958. */
  21959. static readonly WireFrameFillMode: number;
  21960. /**
  21961. * Returns the point fill mode
  21962. */
  21963. static readonly PointFillMode: number;
  21964. /**
  21965. * Returns the point list draw mode
  21966. */
  21967. static readonly PointListDrawMode: number;
  21968. /**
  21969. * Returns the line list draw mode
  21970. */
  21971. static readonly LineListDrawMode: number;
  21972. /**
  21973. * Returns the line loop draw mode
  21974. */
  21975. static readonly LineLoopDrawMode: number;
  21976. /**
  21977. * Returns the line strip draw mode
  21978. */
  21979. static readonly LineStripDrawMode: number;
  21980. /**
  21981. * Returns the triangle strip draw mode
  21982. */
  21983. static readonly TriangleStripDrawMode: number;
  21984. /**
  21985. * Returns the triangle fan draw mode
  21986. */
  21987. static readonly TriangleFanDrawMode: number;
  21988. /**
  21989. * Stores the clock-wise side orientation
  21990. */
  21991. static readonly ClockWiseSideOrientation: number;
  21992. /**
  21993. * Stores the counter clock-wise side orientation
  21994. */
  21995. static readonly CounterClockWiseSideOrientation: number;
  21996. /**
  21997. * The dirty texture flag value
  21998. */
  21999. static readonly TextureDirtyFlag: number;
  22000. /**
  22001. * The dirty light flag value
  22002. */
  22003. static readonly LightDirtyFlag: number;
  22004. /**
  22005. * The dirty fresnel flag value
  22006. */
  22007. static readonly FresnelDirtyFlag: number;
  22008. /**
  22009. * The dirty attribute flag value
  22010. */
  22011. static readonly AttributesDirtyFlag: number;
  22012. /**
  22013. * The dirty misc flag value
  22014. */
  22015. static readonly MiscDirtyFlag: number;
  22016. /**
  22017. * The all dirty flag value
  22018. */
  22019. static readonly AllDirtyFlag: number;
  22020. /**
  22021. * The ID of the material
  22022. */
  22023. id: string;
  22024. /**
  22025. * Gets or sets the unique id of the material
  22026. */
  22027. uniqueId: number;
  22028. /**
  22029. * The name of the material
  22030. */
  22031. name: string;
  22032. /**
  22033. * Gets or sets user defined metadata
  22034. */
  22035. metadata: any;
  22036. /**
  22037. * For internal use only. Please do not use.
  22038. */
  22039. reservedDataStore: any;
  22040. /**
  22041. * Specifies if the ready state should be checked on each call
  22042. */
  22043. checkReadyOnEveryCall: boolean;
  22044. /**
  22045. * Specifies if the ready state should be checked once
  22046. */
  22047. checkReadyOnlyOnce: boolean;
  22048. /**
  22049. * The state of the material
  22050. */
  22051. state: string;
  22052. /**
  22053. * The alpha value of the material
  22054. */
  22055. protected _alpha: number;
  22056. /**
  22057. * List of inspectable custom properties (used by the Inspector)
  22058. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22059. */
  22060. inspectableCustomProperties: IInspectable[];
  22061. /**
  22062. * Sets the alpha value of the material
  22063. */
  22064. /**
  22065. * Gets the alpha value of the material
  22066. */
  22067. alpha: number;
  22068. /**
  22069. * Specifies if back face culling is enabled
  22070. */
  22071. protected _backFaceCulling: boolean;
  22072. /**
  22073. * Sets the back-face culling state
  22074. */
  22075. /**
  22076. * Gets the back-face culling state
  22077. */
  22078. backFaceCulling: boolean;
  22079. /**
  22080. * Stores the value for side orientation
  22081. */
  22082. sideOrientation: number;
  22083. /**
  22084. * Callback triggered when the material is compiled
  22085. */
  22086. onCompiled: Nullable<(effect: Effect) => void>;
  22087. /**
  22088. * Callback triggered when an error occurs
  22089. */
  22090. onError: Nullable<(effect: Effect, errors: string) => void>;
  22091. /**
  22092. * Callback triggered to get the render target textures
  22093. */
  22094. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22095. /**
  22096. * Gets a boolean indicating that current material needs to register RTT
  22097. */
  22098. readonly hasRenderTargetTextures: boolean;
  22099. /**
  22100. * Specifies if the material should be serialized
  22101. */
  22102. doNotSerialize: boolean;
  22103. /**
  22104. * @hidden
  22105. */
  22106. _storeEffectOnSubMeshes: boolean;
  22107. /**
  22108. * Stores the animations for the material
  22109. */
  22110. animations: Nullable<Array<Animation>>;
  22111. /**
  22112. * An event triggered when the material is disposed
  22113. */
  22114. onDisposeObservable: Observable<Material>;
  22115. /**
  22116. * An observer which watches for dispose events
  22117. */
  22118. private _onDisposeObserver;
  22119. private _onUnBindObservable;
  22120. /**
  22121. * Called during a dispose event
  22122. */
  22123. onDispose: () => void;
  22124. private _onBindObservable;
  22125. /**
  22126. * An event triggered when the material is bound
  22127. */
  22128. readonly onBindObservable: Observable<AbstractMesh>;
  22129. /**
  22130. * An observer which watches for bind events
  22131. */
  22132. private _onBindObserver;
  22133. /**
  22134. * Called during a bind event
  22135. */
  22136. onBind: (Mesh: AbstractMesh) => void;
  22137. /**
  22138. * An event triggered when the material is unbound
  22139. */
  22140. readonly onUnBindObservable: Observable<Material>;
  22141. /**
  22142. * Stores the value of the alpha mode
  22143. */
  22144. private _alphaMode;
  22145. /**
  22146. * Sets the value of the alpha mode.
  22147. *
  22148. * | Value | Type | Description |
  22149. * | --- | --- | --- |
  22150. * | 0 | ALPHA_DISABLE | |
  22151. * | 1 | ALPHA_ADD | |
  22152. * | 2 | ALPHA_COMBINE | |
  22153. * | 3 | ALPHA_SUBTRACT | |
  22154. * | 4 | ALPHA_MULTIPLY | |
  22155. * | 5 | ALPHA_MAXIMIZED | |
  22156. * | 6 | ALPHA_ONEONE | |
  22157. * | 7 | ALPHA_PREMULTIPLIED | |
  22158. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22159. * | 9 | ALPHA_INTERPOLATE | |
  22160. * | 10 | ALPHA_SCREENMODE | |
  22161. *
  22162. */
  22163. /**
  22164. * Gets the value of the alpha mode
  22165. */
  22166. alphaMode: number;
  22167. /**
  22168. * Stores the state of the need depth pre-pass value
  22169. */
  22170. private _needDepthPrePass;
  22171. /**
  22172. * Sets the need depth pre-pass value
  22173. */
  22174. /**
  22175. * Gets the depth pre-pass value
  22176. */
  22177. needDepthPrePass: boolean;
  22178. /**
  22179. * Specifies if depth writing should be disabled
  22180. */
  22181. disableDepthWrite: boolean;
  22182. /**
  22183. * Specifies if depth writing should be forced
  22184. */
  22185. forceDepthWrite: boolean;
  22186. /**
  22187. * Specifies if there should be a separate pass for culling
  22188. */
  22189. separateCullingPass: boolean;
  22190. /**
  22191. * Stores the state specifing if fog should be enabled
  22192. */
  22193. private _fogEnabled;
  22194. /**
  22195. * Sets the state for enabling fog
  22196. */
  22197. /**
  22198. * Gets the value of the fog enabled state
  22199. */
  22200. fogEnabled: boolean;
  22201. /**
  22202. * Stores the size of points
  22203. */
  22204. pointSize: number;
  22205. /**
  22206. * Stores the z offset value
  22207. */
  22208. zOffset: number;
  22209. /**
  22210. * Gets a value specifying if wireframe mode is enabled
  22211. */
  22212. /**
  22213. * Sets the state of wireframe mode
  22214. */
  22215. wireframe: boolean;
  22216. /**
  22217. * Gets the value specifying if point clouds are enabled
  22218. */
  22219. /**
  22220. * Sets the state of point cloud mode
  22221. */
  22222. pointsCloud: boolean;
  22223. /**
  22224. * Gets the material fill mode
  22225. */
  22226. /**
  22227. * Sets the material fill mode
  22228. */
  22229. fillMode: number;
  22230. /**
  22231. * @hidden
  22232. * Stores the effects for the material
  22233. */
  22234. _effect: Nullable<Effect>;
  22235. /**
  22236. * @hidden
  22237. * Specifies if the material was previously ready
  22238. */
  22239. _wasPreviouslyReady: boolean;
  22240. /**
  22241. * Specifies if uniform buffers should be used
  22242. */
  22243. private _useUBO;
  22244. /**
  22245. * Stores a reference to the scene
  22246. */
  22247. private _scene;
  22248. /**
  22249. * Stores the fill mode state
  22250. */
  22251. private _fillMode;
  22252. /**
  22253. * Specifies if the depth write state should be cached
  22254. */
  22255. private _cachedDepthWriteState;
  22256. /**
  22257. * Stores the uniform buffer
  22258. */
  22259. protected _uniformBuffer: UniformBuffer;
  22260. /** @hidden */
  22261. _indexInSceneMaterialArray: number;
  22262. /** @hidden */
  22263. meshMap: Nullable<{
  22264. [id: string]: AbstractMesh | undefined;
  22265. }>;
  22266. /**
  22267. * Creates a material instance
  22268. * @param name defines the name of the material
  22269. * @param scene defines the scene to reference
  22270. * @param doNotAdd specifies if the material should be added to the scene
  22271. */
  22272. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22273. /**
  22274. * Returns a string representation of the current material
  22275. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22276. * @returns a string with material information
  22277. */
  22278. toString(fullDetails?: boolean): string;
  22279. /**
  22280. * Gets the class name of the material
  22281. * @returns a string with the class name of the material
  22282. */
  22283. getClassName(): string;
  22284. /**
  22285. * Specifies if updates for the material been locked
  22286. */
  22287. readonly isFrozen: boolean;
  22288. /**
  22289. * Locks updates for the material
  22290. */
  22291. freeze(): void;
  22292. /**
  22293. * Unlocks updates for the material
  22294. */
  22295. unfreeze(): void;
  22296. /**
  22297. * Specifies if the material is ready to be used
  22298. * @param mesh defines the mesh to check
  22299. * @param useInstances specifies if instances should be used
  22300. * @returns a boolean indicating if the material is ready to be used
  22301. */
  22302. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22303. /**
  22304. * Specifies that the submesh is ready to be used
  22305. * @param mesh defines the mesh to check
  22306. * @param subMesh defines which submesh to check
  22307. * @param useInstances specifies that instances should be used
  22308. * @returns a boolean indicating that the submesh is ready or not
  22309. */
  22310. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22311. /**
  22312. * Returns the material effect
  22313. * @returns the effect associated with the material
  22314. */
  22315. getEffect(): Nullable<Effect>;
  22316. /**
  22317. * Returns the current scene
  22318. * @returns a Scene
  22319. */
  22320. getScene(): Scene;
  22321. /**
  22322. * Specifies if the material will require alpha blending
  22323. * @returns a boolean specifying if alpha blending is needed
  22324. */
  22325. needAlphaBlending(): boolean;
  22326. /**
  22327. * Specifies if the mesh will require alpha blending
  22328. * @param mesh defines the mesh to check
  22329. * @returns a boolean specifying if alpha blending is needed for the mesh
  22330. */
  22331. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22332. /**
  22333. * Specifies if this material should be rendered in alpha test mode
  22334. * @returns a boolean specifying if an alpha test is needed.
  22335. */
  22336. needAlphaTesting(): boolean;
  22337. /**
  22338. * Gets the texture used for the alpha test
  22339. * @returns the texture to use for alpha testing
  22340. */
  22341. getAlphaTestTexture(): Nullable<BaseTexture>;
  22342. /**
  22343. * Marks the material to indicate that it needs to be re-calculated
  22344. */
  22345. markDirty(): void;
  22346. /** @hidden */
  22347. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22348. /**
  22349. * Binds the material to the mesh
  22350. * @param world defines the world transformation matrix
  22351. * @param mesh defines the mesh to bind the material to
  22352. */
  22353. bind(world: Matrix, mesh?: Mesh): void;
  22354. /**
  22355. * Binds the submesh to the material
  22356. * @param world defines the world transformation matrix
  22357. * @param mesh defines the mesh containing the submesh
  22358. * @param subMesh defines the submesh to bind the material to
  22359. */
  22360. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22361. /**
  22362. * Binds the world matrix to the material
  22363. * @param world defines the world transformation matrix
  22364. */
  22365. bindOnlyWorldMatrix(world: Matrix): void;
  22366. /**
  22367. * Binds the scene's uniform buffer to the effect.
  22368. * @param effect defines the effect to bind to the scene uniform buffer
  22369. * @param sceneUbo defines the uniform buffer storing scene data
  22370. */
  22371. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22372. /**
  22373. * Binds the view matrix to the effect
  22374. * @param effect defines the effect to bind the view matrix to
  22375. */
  22376. bindView(effect: Effect): void;
  22377. /**
  22378. * Binds the view projection matrix to the effect
  22379. * @param effect defines the effect to bind the view projection matrix to
  22380. */
  22381. bindViewProjection(effect: Effect): void;
  22382. /**
  22383. * Specifies if material alpha testing should be turned on for the mesh
  22384. * @param mesh defines the mesh to check
  22385. */
  22386. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22387. /**
  22388. * Processes to execute after binding the material to a mesh
  22389. * @param mesh defines the rendered mesh
  22390. */
  22391. protected _afterBind(mesh?: Mesh): void;
  22392. /**
  22393. * Unbinds the material from the mesh
  22394. */
  22395. unbind(): void;
  22396. /**
  22397. * Gets the active textures from the material
  22398. * @returns an array of textures
  22399. */
  22400. getActiveTextures(): BaseTexture[];
  22401. /**
  22402. * Specifies if the material uses a texture
  22403. * @param texture defines the texture to check against the material
  22404. * @returns a boolean specifying if the material uses the texture
  22405. */
  22406. hasTexture(texture: BaseTexture): boolean;
  22407. /**
  22408. * Makes a duplicate of the material, and gives it a new name
  22409. * @param name defines the new name for the duplicated material
  22410. * @returns the cloned material
  22411. */
  22412. clone(name: string): Nullable<Material>;
  22413. /**
  22414. * Gets the meshes bound to the material
  22415. * @returns an array of meshes bound to the material
  22416. */
  22417. getBindedMeshes(): AbstractMesh[];
  22418. /**
  22419. * Force shader compilation
  22420. * @param mesh defines the mesh associated with this material
  22421. * @param onCompiled defines a function to execute once the material is compiled
  22422. * @param options defines the options to configure the compilation
  22423. */
  22424. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22425. clipPlane: boolean;
  22426. }>): void;
  22427. /**
  22428. * Force shader compilation
  22429. * @param mesh defines the mesh that will use this material
  22430. * @param options defines additional options for compiling the shaders
  22431. * @returns a promise that resolves when the compilation completes
  22432. */
  22433. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22434. clipPlane: boolean;
  22435. }>): Promise<void>;
  22436. private static readonly _ImageProcessingDirtyCallBack;
  22437. private static readonly _TextureDirtyCallBack;
  22438. private static readonly _FresnelDirtyCallBack;
  22439. private static readonly _MiscDirtyCallBack;
  22440. private static readonly _LightsDirtyCallBack;
  22441. private static readonly _AttributeDirtyCallBack;
  22442. private static _FresnelAndMiscDirtyCallBack;
  22443. private static _TextureAndMiscDirtyCallBack;
  22444. private static readonly _DirtyCallbackArray;
  22445. private static readonly _RunDirtyCallBacks;
  22446. /**
  22447. * Marks a define in the material to indicate that it needs to be re-computed
  22448. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22449. */
  22450. markAsDirty(flag: number): void;
  22451. /**
  22452. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22453. * @param func defines a function which checks material defines against the submeshes
  22454. */
  22455. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22456. /**
  22457. * Indicates that image processing needs to be re-calculated for all submeshes
  22458. */
  22459. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22460. /**
  22461. * Indicates that textures need to be re-calculated for all submeshes
  22462. */
  22463. protected _markAllSubMeshesAsTexturesDirty(): void;
  22464. /**
  22465. * Indicates that fresnel needs to be re-calculated for all submeshes
  22466. */
  22467. protected _markAllSubMeshesAsFresnelDirty(): void;
  22468. /**
  22469. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22470. */
  22471. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22472. /**
  22473. * Indicates that lights need to be re-calculated for all submeshes
  22474. */
  22475. protected _markAllSubMeshesAsLightsDirty(): void;
  22476. /**
  22477. * Indicates that attributes need to be re-calculated for all submeshes
  22478. */
  22479. protected _markAllSubMeshesAsAttributesDirty(): void;
  22480. /**
  22481. * Indicates that misc needs to be re-calculated for all submeshes
  22482. */
  22483. protected _markAllSubMeshesAsMiscDirty(): void;
  22484. /**
  22485. * Indicates that textures and misc need to be re-calculated for all submeshes
  22486. */
  22487. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22488. /**
  22489. * Disposes the material
  22490. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22491. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22492. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22493. */
  22494. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22495. /** @hidden */
  22496. private releaseVertexArrayObject;
  22497. /**
  22498. * Serializes this material
  22499. * @returns the serialized material object
  22500. */
  22501. serialize(): any;
  22502. /**
  22503. * Creates a material from parsed material data
  22504. * @param parsedMaterial defines parsed material data
  22505. * @param scene defines the hosting scene
  22506. * @param rootUrl defines the root URL to use to load textures
  22507. * @returns a new material
  22508. */
  22509. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22510. }
  22511. }
  22512. declare module BABYLON {
  22513. /**
  22514. * Base class for submeshes
  22515. */
  22516. export class BaseSubMesh {
  22517. /** @hidden */
  22518. _materialDefines: Nullable<MaterialDefines>;
  22519. /** @hidden */
  22520. _materialEffect: Nullable<Effect>;
  22521. /**
  22522. * Gets associated effect
  22523. */
  22524. readonly effect: Nullable<Effect>;
  22525. /**
  22526. * Sets associated effect (effect used to render this submesh)
  22527. * @param effect defines the effect to associate with
  22528. * @param defines defines the set of defines used to compile this effect
  22529. */
  22530. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22531. }
  22532. /**
  22533. * Defines a subdivision inside a mesh
  22534. */
  22535. export class SubMesh extends BaseSubMesh implements ICullable {
  22536. /** the material index to use */
  22537. materialIndex: number;
  22538. /** vertex index start */
  22539. verticesStart: number;
  22540. /** vertices count */
  22541. verticesCount: number;
  22542. /** index start */
  22543. indexStart: number;
  22544. /** indices count */
  22545. indexCount: number;
  22546. /** @hidden */
  22547. _linesIndexCount: number;
  22548. private _mesh;
  22549. private _renderingMesh;
  22550. private _boundingInfo;
  22551. private _linesIndexBuffer;
  22552. /** @hidden */
  22553. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22554. /** @hidden */
  22555. _trianglePlanes: Plane[];
  22556. /** @hidden */
  22557. _lastColliderTransformMatrix: Nullable<Matrix>;
  22558. /** @hidden */
  22559. _renderId: number;
  22560. /** @hidden */
  22561. _alphaIndex: number;
  22562. /** @hidden */
  22563. _distanceToCamera: number;
  22564. /** @hidden */
  22565. _id: number;
  22566. private _currentMaterial;
  22567. /**
  22568. * Add a new submesh to a mesh
  22569. * @param materialIndex defines the material index to use
  22570. * @param verticesStart defines vertex index start
  22571. * @param verticesCount defines vertices count
  22572. * @param indexStart defines index start
  22573. * @param indexCount defines indices count
  22574. * @param mesh defines the parent mesh
  22575. * @param renderingMesh defines an optional rendering mesh
  22576. * @param createBoundingBox defines if bounding box should be created for this submesh
  22577. * @returns the new submesh
  22578. */
  22579. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22580. /**
  22581. * Creates a new submesh
  22582. * @param materialIndex defines the material index to use
  22583. * @param verticesStart defines vertex index start
  22584. * @param verticesCount defines vertices count
  22585. * @param indexStart defines index start
  22586. * @param indexCount defines indices count
  22587. * @param mesh defines the parent mesh
  22588. * @param renderingMesh defines an optional rendering mesh
  22589. * @param createBoundingBox defines if bounding box should be created for this submesh
  22590. */
  22591. constructor(
  22592. /** the material index to use */
  22593. materialIndex: number,
  22594. /** vertex index start */
  22595. verticesStart: number,
  22596. /** vertices count */
  22597. verticesCount: number,
  22598. /** index start */
  22599. indexStart: number,
  22600. /** indices count */
  22601. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22602. /**
  22603. * Returns true if this submesh covers the entire parent mesh
  22604. * @ignorenaming
  22605. */
  22606. readonly IsGlobal: boolean;
  22607. /**
  22608. * Returns the submesh BoudingInfo object
  22609. * @returns current bounding info (or mesh's one if the submesh is global)
  22610. */
  22611. getBoundingInfo(): BoundingInfo;
  22612. /**
  22613. * Sets the submesh BoundingInfo
  22614. * @param boundingInfo defines the new bounding info to use
  22615. * @returns the SubMesh
  22616. */
  22617. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22618. /**
  22619. * Returns the mesh of the current submesh
  22620. * @return the parent mesh
  22621. */
  22622. getMesh(): AbstractMesh;
  22623. /**
  22624. * Returns the rendering mesh of the submesh
  22625. * @returns the rendering mesh (could be different from parent mesh)
  22626. */
  22627. getRenderingMesh(): Mesh;
  22628. /**
  22629. * Returns the submesh material
  22630. * @returns null or the current material
  22631. */
  22632. getMaterial(): Nullable<Material>;
  22633. /**
  22634. * Sets a new updated BoundingInfo object to the submesh
  22635. * @param data defines an optional position array to use to determine the bounding info
  22636. * @returns the SubMesh
  22637. */
  22638. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22639. /** @hidden */
  22640. _checkCollision(collider: Collider): boolean;
  22641. /**
  22642. * Updates the submesh BoundingInfo
  22643. * @param world defines the world matrix to use to update the bounding info
  22644. * @returns the submesh
  22645. */
  22646. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22647. /**
  22648. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22649. * @param frustumPlanes defines the frustum planes
  22650. * @returns true if the submesh is intersecting with the frustum
  22651. */
  22652. isInFrustum(frustumPlanes: Plane[]): boolean;
  22653. /**
  22654. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22655. * @param frustumPlanes defines the frustum planes
  22656. * @returns true if the submesh is inside the frustum
  22657. */
  22658. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22659. /**
  22660. * Renders the submesh
  22661. * @param enableAlphaMode defines if alpha needs to be used
  22662. * @returns the submesh
  22663. */
  22664. render(enableAlphaMode: boolean): SubMesh;
  22665. /**
  22666. * @hidden
  22667. */
  22668. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22669. /**
  22670. * Checks if the submesh intersects with a ray
  22671. * @param ray defines the ray to test
  22672. * @returns true is the passed ray intersects the submesh bounding box
  22673. */
  22674. canIntersects(ray: Ray): boolean;
  22675. /**
  22676. * Intersects current submesh with a ray
  22677. * @param ray defines the ray to test
  22678. * @param positions defines mesh's positions array
  22679. * @param indices defines mesh's indices array
  22680. * @param fastCheck defines if only bounding info should be used
  22681. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22682. * @returns intersection info or null if no intersection
  22683. */
  22684. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22685. /** @hidden */
  22686. private _intersectLines;
  22687. /** @hidden */
  22688. private _intersectTriangles;
  22689. /** @hidden */
  22690. _rebuild(): void;
  22691. /**
  22692. * Creates a new submesh from the passed mesh
  22693. * @param newMesh defines the new hosting mesh
  22694. * @param newRenderingMesh defines an optional rendering mesh
  22695. * @returns the new submesh
  22696. */
  22697. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22698. /**
  22699. * Release associated resources
  22700. */
  22701. dispose(): void;
  22702. /**
  22703. * Gets the class name
  22704. * @returns the string "SubMesh".
  22705. */
  22706. getClassName(): string;
  22707. /**
  22708. * Creates a new submesh from indices data
  22709. * @param materialIndex the index of the main mesh material
  22710. * @param startIndex the index where to start the copy in the mesh indices array
  22711. * @param indexCount the number of indices to copy then from the startIndex
  22712. * @param mesh the main mesh to create the submesh from
  22713. * @param renderingMesh the optional rendering mesh
  22714. * @returns a new submesh
  22715. */
  22716. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22717. }
  22718. }
  22719. declare module BABYLON {
  22720. /**
  22721. * Class used to store geometry data (vertex buffers + index buffer)
  22722. */
  22723. export class Geometry implements IGetSetVerticesData {
  22724. /**
  22725. * Gets or sets the ID of the geometry
  22726. */
  22727. id: string;
  22728. /**
  22729. * Gets or sets the unique ID of the geometry
  22730. */
  22731. uniqueId: number;
  22732. /**
  22733. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22734. */
  22735. delayLoadState: number;
  22736. /**
  22737. * Gets the file containing the data to load when running in delay load state
  22738. */
  22739. delayLoadingFile: Nullable<string>;
  22740. /**
  22741. * Callback called when the geometry is updated
  22742. */
  22743. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22744. private _scene;
  22745. private _engine;
  22746. private _meshes;
  22747. private _totalVertices;
  22748. /** @hidden */
  22749. _indices: IndicesArray;
  22750. /** @hidden */
  22751. _vertexBuffers: {
  22752. [key: string]: VertexBuffer;
  22753. };
  22754. private _isDisposed;
  22755. private _extend;
  22756. private _boundingBias;
  22757. /** @hidden */
  22758. _delayInfo: Array<string>;
  22759. private _indexBuffer;
  22760. private _indexBufferIsUpdatable;
  22761. /** @hidden */
  22762. _boundingInfo: Nullable<BoundingInfo>;
  22763. /** @hidden */
  22764. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22765. /** @hidden */
  22766. _softwareSkinningFrameId: number;
  22767. private _vertexArrayObjects;
  22768. private _updatable;
  22769. /** @hidden */
  22770. _positions: Nullable<Vector3[]>;
  22771. /**
  22772. * 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
  22773. */
  22774. /**
  22775. * 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
  22776. */
  22777. boundingBias: Vector2;
  22778. /**
  22779. * Static function used to attach a new empty geometry to a mesh
  22780. * @param mesh defines the mesh to attach the geometry to
  22781. * @returns the new Geometry
  22782. */
  22783. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22784. /**
  22785. * Creates a new geometry
  22786. * @param id defines the unique ID
  22787. * @param scene defines the hosting scene
  22788. * @param vertexData defines the VertexData used to get geometry data
  22789. * @param updatable defines if geometry must be updatable (false by default)
  22790. * @param mesh defines the mesh that will be associated with the geometry
  22791. */
  22792. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22793. /**
  22794. * Gets the current extend of the geometry
  22795. */
  22796. readonly extend: {
  22797. minimum: Vector3;
  22798. maximum: Vector3;
  22799. };
  22800. /**
  22801. * Gets the hosting scene
  22802. * @returns the hosting Scene
  22803. */
  22804. getScene(): Scene;
  22805. /**
  22806. * Gets the hosting engine
  22807. * @returns the hosting Engine
  22808. */
  22809. getEngine(): Engine;
  22810. /**
  22811. * Defines if the geometry is ready to use
  22812. * @returns true if the geometry is ready to be used
  22813. */
  22814. isReady(): boolean;
  22815. /**
  22816. * Gets a value indicating that the geometry should not be serialized
  22817. */
  22818. readonly doNotSerialize: boolean;
  22819. /** @hidden */
  22820. _rebuild(): void;
  22821. /**
  22822. * Affects all geometry data in one call
  22823. * @param vertexData defines the geometry data
  22824. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22825. */
  22826. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22827. /**
  22828. * Set specific vertex data
  22829. * @param kind defines the data kind (Position, normal, etc...)
  22830. * @param data defines the vertex data to use
  22831. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22832. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22833. */
  22834. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22835. /**
  22836. * Removes a specific vertex data
  22837. * @param kind defines the data kind (Position, normal, etc...)
  22838. */
  22839. removeVerticesData(kind: string): void;
  22840. /**
  22841. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22842. * @param buffer defines the vertex buffer to use
  22843. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22844. */
  22845. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22846. /**
  22847. * Update a specific vertex buffer
  22848. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22849. * It will do nothing if the buffer is not updatable
  22850. * @param kind defines the data kind (Position, normal, etc...)
  22851. * @param data defines the data to use
  22852. * @param offset defines the offset in the target buffer where to store the data
  22853. * @param useBytes set to true if the offset is in bytes
  22854. */
  22855. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22856. /**
  22857. * Update a specific vertex buffer
  22858. * This function will create a new buffer if the current one is not updatable
  22859. * @param kind defines the data kind (Position, normal, etc...)
  22860. * @param data defines the data to use
  22861. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22862. */
  22863. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22864. private _updateBoundingInfo;
  22865. /** @hidden */
  22866. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22867. /**
  22868. * Gets total number of vertices
  22869. * @returns the total number of vertices
  22870. */
  22871. getTotalVertices(): number;
  22872. /**
  22873. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22874. * @param kind defines the data kind (Position, normal, etc...)
  22875. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22876. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22877. * @returns a float array containing vertex data
  22878. */
  22879. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22880. /**
  22881. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22882. * @param kind defines the data kind (Position, normal, etc...)
  22883. * @returns true if the vertex buffer with the specified kind is updatable
  22884. */
  22885. isVertexBufferUpdatable(kind: string): boolean;
  22886. /**
  22887. * Gets a specific vertex buffer
  22888. * @param kind defines the data kind (Position, normal, etc...)
  22889. * @returns a VertexBuffer
  22890. */
  22891. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22892. /**
  22893. * Returns all vertex buffers
  22894. * @return an object holding all vertex buffers indexed by kind
  22895. */
  22896. getVertexBuffers(): Nullable<{
  22897. [key: string]: VertexBuffer;
  22898. }>;
  22899. /**
  22900. * Gets a boolean indicating if specific vertex buffer is present
  22901. * @param kind defines the data kind (Position, normal, etc...)
  22902. * @returns true if data is present
  22903. */
  22904. isVerticesDataPresent(kind: string): boolean;
  22905. /**
  22906. * Gets a list of all attached data kinds (Position, normal, etc...)
  22907. * @returns a list of string containing all kinds
  22908. */
  22909. getVerticesDataKinds(): string[];
  22910. /**
  22911. * Update index buffer
  22912. * @param indices defines the indices to store in the index buffer
  22913. * @param offset defines the offset in the target buffer where to store the data
  22914. * @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)
  22915. */
  22916. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22917. /**
  22918. * Creates a new index buffer
  22919. * @param indices defines the indices to store in the index buffer
  22920. * @param totalVertices defines the total number of vertices (could be null)
  22921. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22922. */
  22923. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22924. /**
  22925. * Return the total number of indices
  22926. * @returns the total number of indices
  22927. */
  22928. getTotalIndices(): number;
  22929. /**
  22930. * Gets the index buffer array
  22931. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22932. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22933. * @returns the index buffer array
  22934. */
  22935. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22936. /**
  22937. * Gets the index buffer
  22938. * @return the index buffer
  22939. */
  22940. getIndexBuffer(): Nullable<DataBuffer>;
  22941. /** @hidden */
  22942. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22943. /**
  22944. * Release the associated resources for a specific mesh
  22945. * @param mesh defines the source mesh
  22946. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22947. */
  22948. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22949. /**
  22950. * Apply current geometry to a given mesh
  22951. * @param mesh defines the mesh to apply geometry to
  22952. */
  22953. applyToMesh(mesh: Mesh): void;
  22954. private _updateExtend;
  22955. private _applyToMesh;
  22956. private notifyUpdate;
  22957. /**
  22958. * Load the geometry if it was flagged as delay loaded
  22959. * @param scene defines the hosting scene
  22960. * @param onLoaded defines a callback called when the geometry is loaded
  22961. */
  22962. load(scene: Scene, onLoaded?: () => void): void;
  22963. private _queueLoad;
  22964. /**
  22965. * Invert the geometry to move from a right handed system to a left handed one.
  22966. */
  22967. toLeftHanded(): void;
  22968. /** @hidden */
  22969. _resetPointsArrayCache(): void;
  22970. /** @hidden */
  22971. _generatePointsArray(): boolean;
  22972. /**
  22973. * Gets a value indicating if the geometry is disposed
  22974. * @returns true if the geometry was disposed
  22975. */
  22976. isDisposed(): boolean;
  22977. private _disposeVertexArrayObjects;
  22978. /**
  22979. * Free all associated resources
  22980. */
  22981. dispose(): void;
  22982. /**
  22983. * Clone the current geometry into a new geometry
  22984. * @param id defines the unique ID of the new geometry
  22985. * @returns a new geometry object
  22986. */
  22987. copy(id: string): Geometry;
  22988. /**
  22989. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22990. * @return a JSON representation of the current geometry data (without the vertices data)
  22991. */
  22992. serialize(): any;
  22993. private toNumberArray;
  22994. /**
  22995. * Serialize all vertices data into a JSON oject
  22996. * @returns a JSON representation of the current geometry data
  22997. */
  22998. serializeVerticeData(): any;
  22999. /**
  23000. * Extracts a clone of a mesh geometry
  23001. * @param mesh defines the source mesh
  23002. * @param id defines the unique ID of the new geometry object
  23003. * @returns the new geometry object
  23004. */
  23005. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23006. /**
  23007. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23008. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23009. * Be aware Math.random() could cause collisions, but:
  23010. * "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"
  23011. * @returns a string containing a new GUID
  23012. */
  23013. static RandomId(): string;
  23014. /** @hidden */
  23015. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23016. private static _CleanMatricesWeights;
  23017. /**
  23018. * Create a new geometry from persisted data (Using .babylon file format)
  23019. * @param parsedVertexData defines the persisted data
  23020. * @param scene defines the hosting scene
  23021. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23022. * @returns the new geometry object
  23023. */
  23024. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23025. }
  23026. }
  23027. declare module BABYLON {
  23028. /**
  23029. * Define an interface for all classes that will get and set the data on vertices
  23030. */
  23031. export interface IGetSetVerticesData {
  23032. /**
  23033. * Gets a boolean indicating if specific vertex data is present
  23034. * @param kind defines the vertex data kind to use
  23035. * @returns true is data kind is present
  23036. */
  23037. isVerticesDataPresent(kind: string): boolean;
  23038. /**
  23039. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23040. * @param kind defines the data kind (Position, normal, etc...)
  23041. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23042. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23043. * @returns a float array containing vertex data
  23044. */
  23045. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23046. /**
  23047. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23048. * @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.
  23049. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23050. * @returns the indices array or an empty array if the mesh has no geometry
  23051. */
  23052. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23053. /**
  23054. * Set specific vertex data
  23055. * @param kind defines the data kind (Position, normal, etc...)
  23056. * @param data defines the vertex data to use
  23057. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23058. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23059. */
  23060. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23061. /**
  23062. * Update a specific associated vertex buffer
  23063. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23064. * - VertexBuffer.PositionKind
  23065. * - VertexBuffer.UVKind
  23066. * - VertexBuffer.UV2Kind
  23067. * - VertexBuffer.UV3Kind
  23068. * - VertexBuffer.UV4Kind
  23069. * - VertexBuffer.UV5Kind
  23070. * - VertexBuffer.UV6Kind
  23071. * - VertexBuffer.ColorKind
  23072. * - VertexBuffer.MatricesIndicesKind
  23073. * - VertexBuffer.MatricesIndicesExtraKind
  23074. * - VertexBuffer.MatricesWeightsKind
  23075. * - VertexBuffer.MatricesWeightsExtraKind
  23076. * @param data defines the data source
  23077. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23078. * @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)
  23079. */
  23080. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23081. /**
  23082. * Creates a new index buffer
  23083. * @param indices defines the indices to store in the index buffer
  23084. * @param totalVertices defines the total number of vertices (could be null)
  23085. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23086. */
  23087. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23088. }
  23089. /**
  23090. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23091. */
  23092. export class VertexData {
  23093. /**
  23094. * Mesh side orientation : usually the external or front surface
  23095. */
  23096. static readonly FRONTSIDE: number;
  23097. /**
  23098. * Mesh side orientation : usually the internal or back surface
  23099. */
  23100. static readonly BACKSIDE: number;
  23101. /**
  23102. * Mesh side orientation : both internal and external or front and back surfaces
  23103. */
  23104. static readonly DOUBLESIDE: number;
  23105. /**
  23106. * Mesh side orientation : by default, `FRONTSIDE`
  23107. */
  23108. static readonly DEFAULTSIDE: number;
  23109. /**
  23110. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23111. */
  23112. positions: Nullable<FloatArray>;
  23113. /**
  23114. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23115. */
  23116. normals: Nullable<FloatArray>;
  23117. /**
  23118. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23119. */
  23120. tangents: Nullable<FloatArray>;
  23121. /**
  23122. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23123. */
  23124. uvs: Nullable<FloatArray>;
  23125. /**
  23126. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23127. */
  23128. uvs2: Nullable<FloatArray>;
  23129. /**
  23130. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23131. */
  23132. uvs3: Nullable<FloatArray>;
  23133. /**
  23134. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23135. */
  23136. uvs4: Nullable<FloatArray>;
  23137. /**
  23138. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23139. */
  23140. uvs5: Nullable<FloatArray>;
  23141. /**
  23142. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23143. */
  23144. uvs6: Nullable<FloatArray>;
  23145. /**
  23146. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23147. */
  23148. colors: Nullable<FloatArray>;
  23149. /**
  23150. * 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).
  23151. */
  23152. matricesIndices: Nullable<FloatArray>;
  23153. /**
  23154. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23155. */
  23156. matricesWeights: Nullable<FloatArray>;
  23157. /**
  23158. * An array extending the number of possible indices
  23159. */
  23160. matricesIndicesExtra: Nullable<FloatArray>;
  23161. /**
  23162. * An array extending the number of possible weights when the number of indices is extended
  23163. */
  23164. matricesWeightsExtra: Nullable<FloatArray>;
  23165. /**
  23166. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23167. */
  23168. indices: Nullable<IndicesArray>;
  23169. /**
  23170. * Uses the passed data array to set the set the values for the specified kind of data
  23171. * @param data a linear array of floating numbers
  23172. * @param kind the type of data that is being set, eg positions, colors etc
  23173. */
  23174. set(data: FloatArray, kind: string): void;
  23175. /**
  23176. * Associates the vertexData to the passed Mesh.
  23177. * Sets it as updatable or not (default `false`)
  23178. * @param mesh the mesh the vertexData is applied to
  23179. * @param updatable when used and having the value true allows new data to update the vertexData
  23180. * @returns the VertexData
  23181. */
  23182. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23183. /**
  23184. * Associates the vertexData to the passed Geometry.
  23185. * Sets it as updatable or not (default `false`)
  23186. * @param geometry the geometry the vertexData is applied to
  23187. * @param updatable when used and having the value true allows new data to update the vertexData
  23188. * @returns VertexData
  23189. */
  23190. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23191. /**
  23192. * Updates the associated mesh
  23193. * @param mesh the mesh to be updated
  23194. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23195. * @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
  23196. * @returns VertexData
  23197. */
  23198. updateMesh(mesh: Mesh): VertexData;
  23199. /**
  23200. * Updates the associated geometry
  23201. * @param geometry the geometry to be updated
  23202. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23203. * @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
  23204. * @returns VertexData.
  23205. */
  23206. updateGeometry(geometry: Geometry): VertexData;
  23207. private _applyTo;
  23208. private _update;
  23209. /**
  23210. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23211. * @param matrix the transforming matrix
  23212. * @returns the VertexData
  23213. */
  23214. transform(matrix: Matrix): VertexData;
  23215. /**
  23216. * Merges the passed VertexData into the current one
  23217. * @param other the VertexData to be merged into the current one
  23218. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23219. * @returns the modified VertexData
  23220. */
  23221. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23222. private _mergeElement;
  23223. private _validate;
  23224. /**
  23225. * Serializes the VertexData
  23226. * @returns a serialized object
  23227. */
  23228. serialize(): any;
  23229. /**
  23230. * Extracts the vertexData from a mesh
  23231. * @param mesh the mesh from which to extract the VertexData
  23232. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23233. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23234. * @returns the object VertexData associated to the passed mesh
  23235. */
  23236. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23237. /**
  23238. * Extracts the vertexData from the geometry
  23239. * @param geometry the geometry from which to extract the VertexData
  23240. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23241. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23242. * @returns the object VertexData associated to the passed mesh
  23243. */
  23244. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23245. private static _ExtractFrom;
  23246. /**
  23247. * Creates the VertexData for a Ribbon
  23248. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23249. * * pathArray array of paths, each of which an array of successive Vector3
  23250. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23251. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23252. * * 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
  23253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23254. * * 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)
  23255. * * 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)
  23256. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23257. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23258. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23259. * @returns the VertexData of the ribbon
  23260. */
  23261. static CreateRibbon(options: {
  23262. pathArray: Vector3[][];
  23263. closeArray?: boolean;
  23264. closePath?: boolean;
  23265. offset?: number;
  23266. sideOrientation?: number;
  23267. frontUVs?: Vector4;
  23268. backUVs?: Vector4;
  23269. invertUV?: boolean;
  23270. uvs?: Vector2[];
  23271. colors?: Color4[];
  23272. }): VertexData;
  23273. /**
  23274. * Creates the VertexData for a box
  23275. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23276. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23277. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23278. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23279. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23280. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23281. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23282. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23283. * * 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)
  23284. * * 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)
  23285. * @returns the VertexData of the box
  23286. */
  23287. static CreateBox(options: {
  23288. size?: number;
  23289. width?: number;
  23290. height?: number;
  23291. depth?: number;
  23292. faceUV?: Vector4[];
  23293. faceColors?: Color4[];
  23294. sideOrientation?: number;
  23295. frontUVs?: Vector4;
  23296. backUVs?: Vector4;
  23297. }): VertexData;
  23298. /**
  23299. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23300. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23301. * * segments sets the number of horizontal strips optional, default 32
  23302. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23303. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23304. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23305. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23306. * * 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
  23307. * * 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
  23308. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23309. * * 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)
  23310. * * 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)
  23311. * @returns the VertexData of the ellipsoid
  23312. */
  23313. static CreateSphere(options: {
  23314. segments?: number;
  23315. diameter?: number;
  23316. diameterX?: number;
  23317. diameterY?: number;
  23318. diameterZ?: number;
  23319. arc?: number;
  23320. slice?: number;
  23321. sideOrientation?: number;
  23322. frontUVs?: Vector4;
  23323. backUVs?: Vector4;
  23324. }): VertexData;
  23325. /**
  23326. * Creates the VertexData for a cylinder, cone or prism
  23327. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23328. * * height sets the height (y direction) of the cylinder, optional, default 2
  23329. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23330. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23331. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23332. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23333. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23334. * * 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
  23335. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23336. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23337. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23338. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23340. * * 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)
  23341. * * 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)
  23342. * @returns the VertexData of the cylinder, cone or prism
  23343. */
  23344. static CreateCylinder(options: {
  23345. height?: number;
  23346. diameterTop?: number;
  23347. diameterBottom?: number;
  23348. diameter?: number;
  23349. tessellation?: number;
  23350. subdivisions?: number;
  23351. arc?: number;
  23352. faceColors?: Color4[];
  23353. faceUV?: Vector4[];
  23354. hasRings?: boolean;
  23355. enclose?: boolean;
  23356. sideOrientation?: number;
  23357. frontUVs?: Vector4;
  23358. backUVs?: Vector4;
  23359. }): VertexData;
  23360. /**
  23361. * Creates the VertexData for a torus
  23362. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23363. * * diameter the diameter of the torus, optional default 1
  23364. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23365. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23367. * * 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)
  23368. * * 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)
  23369. * @returns the VertexData of the torus
  23370. */
  23371. static CreateTorus(options: {
  23372. diameter?: number;
  23373. thickness?: number;
  23374. tessellation?: number;
  23375. sideOrientation?: number;
  23376. frontUVs?: Vector4;
  23377. backUVs?: Vector4;
  23378. }): VertexData;
  23379. /**
  23380. * Creates the VertexData of the LineSystem
  23381. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23382. * - lines an array of lines, each line being an array of successive Vector3
  23383. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23384. * @returns the VertexData of the LineSystem
  23385. */
  23386. static CreateLineSystem(options: {
  23387. lines: Vector3[][];
  23388. colors?: Nullable<Color4[][]>;
  23389. }): VertexData;
  23390. /**
  23391. * Create the VertexData for a DashedLines
  23392. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23393. * - points an array successive Vector3
  23394. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23395. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23396. * - dashNb the intended total number of dashes, optional, default 200
  23397. * @returns the VertexData for the DashedLines
  23398. */
  23399. static CreateDashedLines(options: {
  23400. points: Vector3[];
  23401. dashSize?: number;
  23402. gapSize?: number;
  23403. dashNb?: number;
  23404. }): VertexData;
  23405. /**
  23406. * Creates the VertexData for a Ground
  23407. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23408. * - width the width (x direction) of the ground, optional, default 1
  23409. * - height the height (z direction) of the ground, optional, default 1
  23410. * - subdivisions the number of subdivisions per side, optional, default 1
  23411. * @returns the VertexData of the Ground
  23412. */
  23413. static CreateGround(options: {
  23414. width?: number;
  23415. height?: number;
  23416. subdivisions?: number;
  23417. subdivisionsX?: number;
  23418. subdivisionsY?: number;
  23419. }): VertexData;
  23420. /**
  23421. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23422. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23423. * * xmin the ground minimum X coordinate, optional, default -1
  23424. * * zmin the ground minimum Z coordinate, optional, default -1
  23425. * * xmax the ground maximum X coordinate, optional, default 1
  23426. * * zmax the ground maximum Z coordinate, optional, default 1
  23427. * * 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}
  23428. * * 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}
  23429. * @returns the VertexData of the TiledGround
  23430. */
  23431. static CreateTiledGround(options: {
  23432. xmin: number;
  23433. zmin: number;
  23434. xmax: number;
  23435. zmax: number;
  23436. subdivisions?: {
  23437. w: number;
  23438. h: number;
  23439. };
  23440. precision?: {
  23441. w: number;
  23442. h: number;
  23443. };
  23444. }): VertexData;
  23445. /**
  23446. * Creates the VertexData of the Ground designed from a heightmap
  23447. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23448. * * width the width (x direction) of the ground
  23449. * * height the height (z direction) of the ground
  23450. * * subdivisions the number of subdivisions per side
  23451. * * minHeight the minimum altitude on the ground, optional, default 0
  23452. * * maxHeight the maximum altitude on the ground, optional default 1
  23453. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23454. * * buffer the array holding the image color data
  23455. * * bufferWidth the width of image
  23456. * * bufferHeight the height of image
  23457. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23458. * @returns the VertexData of the Ground designed from a heightmap
  23459. */
  23460. static CreateGroundFromHeightMap(options: {
  23461. width: number;
  23462. height: number;
  23463. subdivisions: number;
  23464. minHeight: number;
  23465. maxHeight: number;
  23466. colorFilter: Color3;
  23467. buffer: Uint8Array;
  23468. bufferWidth: number;
  23469. bufferHeight: number;
  23470. alphaFilter: number;
  23471. }): VertexData;
  23472. /**
  23473. * Creates the VertexData for a Plane
  23474. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23475. * * size sets the width and height of the plane to the value of size, optional default 1
  23476. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23477. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23478. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23479. * * 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)
  23480. * * 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)
  23481. * @returns the VertexData of the box
  23482. */
  23483. static CreatePlane(options: {
  23484. size?: number;
  23485. width?: number;
  23486. height?: number;
  23487. sideOrientation?: number;
  23488. frontUVs?: Vector4;
  23489. backUVs?: Vector4;
  23490. }): VertexData;
  23491. /**
  23492. * Creates the VertexData of the Disc or regular Polygon
  23493. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23494. * * radius the radius of the disc, optional default 0.5
  23495. * * tessellation the number of polygon sides, optional, default 64
  23496. * * 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
  23497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23498. * * 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)
  23499. * * 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)
  23500. * @returns the VertexData of the box
  23501. */
  23502. static CreateDisc(options: {
  23503. radius?: number;
  23504. tessellation?: number;
  23505. arc?: number;
  23506. sideOrientation?: number;
  23507. frontUVs?: Vector4;
  23508. backUVs?: Vector4;
  23509. }): VertexData;
  23510. /**
  23511. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23512. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23513. * @param polygon a mesh built from polygonTriangulation.build()
  23514. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23515. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23516. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23517. * @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)
  23518. * @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)
  23519. * @returns the VertexData of the Polygon
  23520. */
  23521. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23522. /**
  23523. * Creates the VertexData of the IcoSphere
  23524. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23525. * * radius the radius of the IcoSphere, optional default 1
  23526. * * radiusX allows stretching in the x direction, optional, default radius
  23527. * * radiusY allows stretching in the y direction, optional, default radius
  23528. * * radiusZ allows stretching in the z direction, optional, default radius
  23529. * * flat when true creates a flat shaded mesh, optional, default true
  23530. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23531. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23532. * * 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)
  23533. * * 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)
  23534. * @returns the VertexData of the IcoSphere
  23535. */
  23536. static CreateIcoSphere(options: {
  23537. radius?: number;
  23538. radiusX?: number;
  23539. radiusY?: number;
  23540. radiusZ?: number;
  23541. flat?: boolean;
  23542. subdivisions?: number;
  23543. sideOrientation?: number;
  23544. frontUVs?: Vector4;
  23545. backUVs?: Vector4;
  23546. }): VertexData;
  23547. /**
  23548. * Creates the VertexData for a Polyhedron
  23549. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23550. * * type provided types are:
  23551. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23552. * * 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)
  23553. * * size the size of the IcoSphere, optional default 1
  23554. * * sizeX allows stretching in the x direction, optional, default size
  23555. * * sizeY allows stretching in the y direction, optional, default size
  23556. * * sizeZ allows stretching in the z direction, optional, default size
  23557. * * 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
  23558. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23559. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23560. * * flat when true creates a flat shaded mesh, optional, default true
  23561. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23562. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23563. * * 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)
  23564. * * 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)
  23565. * @returns the VertexData of the Polyhedron
  23566. */
  23567. static CreatePolyhedron(options: {
  23568. type?: number;
  23569. size?: number;
  23570. sizeX?: number;
  23571. sizeY?: number;
  23572. sizeZ?: number;
  23573. custom?: any;
  23574. faceUV?: Vector4[];
  23575. faceColors?: Color4[];
  23576. flat?: boolean;
  23577. sideOrientation?: number;
  23578. frontUVs?: Vector4;
  23579. backUVs?: Vector4;
  23580. }): VertexData;
  23581. /**
  23582. * Creates the VertexData for a TorusKnot
  23583. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23584. * * radius the radius of the torus knot, optional, default 2
  23585. * * tube the thickness of the tube, optional, default 0.5
  23586. * * radialSegments the number of sides on each tube segments, optional, default 32
  23587. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23588. * * p the number of windings around the z axis, optional, default 2
  23589. * * q the number of windings around the x axis, optional, default 3
  23590. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23591. * * 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)
  23592. * * 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)
  23593. * @returns the VertexData of the Torus Knot
  23594. */
  23595. static CreateTorusKnot(options: {
  23596. radius?: number;
  23597. tube?: number;
  23598. radialSegments?: number;
  23599. tubularSegments?: number;
  23600. p?: number;
  23601. q?: number;
  23602. sideOrientation?: number;
  23603. frontUVs?: Vector4;
  23604. backUVs?: Vector4;
  23605. }): VertexData;
  23606. /**
  23607. * Compute normals for given positions and indices
  23608. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23609. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23610. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23611. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23612. * * facetNormals : optional array of facet normals (vector3)
  23613. * * facetPositions : optional array of facet positions (vector3)
  23614. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23615. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23616. * * bInfo : optional bounding info, required for facetPartitioning computation
  23617. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23618. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23619. * * useRightHandedSystem: optional boolean to for right handed system computation
  23620. * * depthSort : optional boolean to enable the facet depth sort computation
  23621. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23622. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23623. */
  23624. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23625. facetNormals?: any;
  23626. facetPositions?: any;
  23627. facetPartitioning?: any;
  23628. ratio?: number;
  23629. bInfo?: any;
  23630. bbSize?: Vector3;
  23631. subDiv?: any;
  23632. useRightHandedSystem?: boolean;
  23633. depthSort?: boolean;
  23634. distanceTo?: Vector3;
  23635. depthSortedFacets?: any;
  23636. }): void;
  23637. /** @hidden */
  23638. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23639. /**
  23640. * Applies VertexData created from the imported parameters to the geometry
  23641. * @param parsedVertexData the parsed data from an imported file
  23642. * @param geometry the geometry to apply the VertexData to
  23643. */
  23644. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23645. }
  23646. }
  23647. declare module BABYLON {
  23648. /**
  23649. * Class containing static functions to help procedurally build meshes
  23650. */
  23651. export class DiscBuilder {
  23652. /**
  23653. * Creates a plane polygonal mesh. By default, this is a disc
  23654. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23655. * * 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
  23656. * * 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
  23657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23658. * * 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
  23659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23660. * @param name defines the name of the mesh
  23661. * @param options defines the options used to create the mesh
  23662. * @param scene defines the hosting scene
  23663. * @returns the plane polygonal mesh
  23664. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23665. */
  23666. static CreateDisc(name: string, options: {
  23667. radius?: number;
  23668. tessellation?: number;
  23669. arc?: number;
  23670. updatable?: boolean;
  23671. sideOrientation?: number;
  23672. frontUVs?: Vector4;
  23673. backUVs?: Vector4;
  23674. }, scene?: Nullable<Scene>): Mesh;
  23675. }
  23676. }
  23677. declare module BABYLON {
  23678. /**
  23679. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23680. *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.
  23681. * The SPS is also a particle system. It provides some methods to manage the particles.
  23682. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23683. *
  23684. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23685. */
  23686. export class SolidParticleSystem implements IDisposable {
  23687. /**
  23688. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23689. * Example : var p = SPS.particles[i];
  23690. */
  23691. particles: SolidParticle[];
  23692. /**
  23693. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23694. */
  23695. nbParticles: number;
  23696. /**
  23697. * If the particles must ever face the camera (default false). Useful for planar particles.
  23698. */
  23699. billboard: boolean;
  23700. /**
  23701. * Recompute normals when adding a shape
  23702. */
  23703. recomputeNormals: boolean;
  23704. /**
  23705. * This a counter ofr your own usage. It's not set by any SPS functions.
  23706. */
  23707. counter: number;
  23708. /**
  23709. * The SPS name. This name is also given to the underlying mesh.
  23710. */
  23711. name: string;
  23712. /**
  23713. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23714. */
  23715. mesh: Mesh;
  23716. /**
  23717. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23718. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23719. */
  23720. vars: any;
  23721. /**
  23722. * This array is populated when the SPS is set as 'pickable'.
  23723. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23724. * Each element of this array is an object `{idx: int, faceId: int}`.
  23725. * `idx` is the picked particle index in the `SPS.particles` array
  23726. * `faceId` is the picked face index counted within this particle.
  23727. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23728. */
  23729. pickedParticles: {
  23730. idx: number;
  23731. faceId: number;
  23732. }[];
  23733. /**
  23734. * This array is populated when `enableDepthSort` is set to true.
  23735. * Each element of this array is an instance of the class DepthSortedParticle.
  23736. */
  23737. depthSortedParticles: DepthSortedParticle[];
  23738. /**
  23739. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23740. * @hidden
  23741. */
  23742. _bSphereOnly: boolean;
  23743. /**
  23744. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23745. * @hidden
  23746. */
  23747. _bSphereRadiusFactor: number;
  23748. private _scene;
  23749. private _positions;
  23750. private _indices;
  23751. private _normals;
  23752. private _colors;
  23753. private _uvs;
  23754. private _indices32;
  23755. private _positions32;
  23756. private _normals32;
  23757. private _fixedNormal32;
  23758. private _colors32;
  23759. private _uvs32;
  23760. private _index;
  23761. private _updatable;
  23762. private _pickable;
  23763. private _isVisibilityBoxLocked;
  23764. private _alwaysVisible;
  23765. private _depthSort;
  23766. private _shapeCounter;
  23767. private _copy;
  23768. private _color;
  23769. private _computeParticleColor;
  23770. private _computeParticleTexture;
  23771. private _computeParticleRotation;
  23772. private _computeParticleVertex;
  23773. private _computeBoundingBox;
  23774. private _depthSortParticles;
  23775. private _camera;
  23776. private _mustUnrotateFixedNormals;
  23777. private _particlesIntersect;
  23778. private _needs32Bits;
  23779. /**
  23780. * Creates a SPS (Solid Particle System) object.
  23781. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23782. * @param scene (Scene) is the scene in which the SPS is added.
  23783. * @param options defines the options of the sps e.g.
  23784. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23785. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23786. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23787. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23788. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23789. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23790. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23791. */
  23792. constructor(name: string, scene: Scene, options?: {
  23793. updatable?: boolean;
  23794. isPickable?: boolean;
  23795. enableDepthSort?: boolean;
  23796. particleIntersection?: boolean;
  23797. boundingSphereOnly?: boolean;
  23798. bSphereRadiusFactor?: number;
  23799. });
  23800. /**
  23801. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23802. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23803. * @returns the created mesh
  23804. */
  23805. buildMesh(): Mesh;
  23806. /**
  23807. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23808. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23809. * Thus the particles generated from `digest()` have their property `position` set yet.
  23810. * @param mesh ( Mesh ) is the mesh to be digested
  23811. * @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
  23812. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23813. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23814. * @returns the current SPS
  23815. */
  23816. digest(mesh: Mesh, options?: {
  23817. facetNb?: number;
  23818. number?: number;
  23819. delta?: number;
  23820. }): SolidParticleSystem;
  23821. private _unrotateFixedNormals;
  23822. private _resetCopy;
  23823. private _meshBuilder;
  23824. private _posToShape;
  23825. private _uvsToShapeUV;
  23826. private _addParticle;
  23827. /**
  23828. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23829. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23830. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23831. * @param nb (positive integer) the number of particles to be created from this model
  23832. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23833. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23834. * @returns the number of shapes in the system
  23835. */
  23836. addShape(mesh: Mesh, nb: number, options?: {
  23837. positionFunction?: any;
  23838. vertexFunction?: any;
  23839. }): number;
  23840. private _rebuildParticle;
  23841. /**
  23842. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23843. * @returns the SPS.
  23844. */
  23845. rebuildMesh(): SolidParticleSystem;
  23846. /**
  23847. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23848. * This method calls `updateParticle()` for each particle of the SPS.
  23849. * For an animated SPS, it is usually called within the render loop.
  23850. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23851. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23852. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23853. * @returns the SPS.
  23854. */
  23855. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23856. /**
  23857. * Disposes the SPS.
  23858. */
  23859. dispose(): void;
  23860. /**
  23861. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23862. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23863. * @returns the SPS.
  23864. */
  23865. refreshVisibleSize(): SolidParticleSystem;
  23866. /**
  23867. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23868. * @param size the size (float) of the visibility box
  23869. * note : this doesn't lock the SPS mesh bounding box.
  23870. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23871. */
  23872. setVisibilityBox(size: number): void;
  23873. /**
  23874. * Gets whether the SPS as always visible or not
  23875. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23876. */
  23877. /**
  23878. * Sets the SPS as always visible or not
  23879. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23880. */
  23881. isAlwaysVisible: boolean;
  23882. /**
  23883. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23884. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23885. */
  23886. /**
  23887. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23889. */
  23890. isVisibilityBoxLocked: boolean;
  23891. /**
  23892. * Tells to `setParticles()` to compute the particle rotations or not.
  23893. * Default value : true. The SPS is faster when it's set to false.
  23894. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23895. */
  23896. /**
  23897. * Gets if `setParticles()` computes the particle rotations or not.
  23898. * Default value : true. The SPS is faster when it's set to false.
  23899. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23900. */
  23901. computeParticleRotation: boolean;
  23902. /**
  23903. * Tells to `setParticles()` to compute the particle colors or not.
  23904. * Default value : true. The SPS is faster when it's set to false.
  23905. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23906. */
  23907. /**
  23908. * Gets if `setParticles()` computes the particle colors or not.
  23909. * Default value : true. The SPS is faster when it's set to false.
  23910. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23911. */
  23912. computeParticleColor: boolean;
  23913. /**
  23914. * Gets if `setParticles()` computes the particle textures or not.
  23915. * Default value : true. The SPS is faster when it's set to false.
  23916. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23917. */
  23918. computeParticleTexture: boolean;
  23919. /**
  23920. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23921. * Default value : false. The SPS is faster when it's set to false.
  23922. * Note : the particle custom vertex positions aren't stored values.
  23923. */
  23924. /**
  23925. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23926. * Default value : false. The SPS is faster when it's set to false.
  23927. * Note : the particle custom vertex positions aren't stored values.
  23928. */
  23929. computeParticleVertex: boolean;
  23930. /**
  23931. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23932. */
  23933. /**
  23934. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23935. */
  23936. computeBoundingBox: boolean;
  23937. /**
  23938. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23939. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23940. * Default : `true`
  23941. */
  23942. /**
  23943. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23944. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23945. * Default : `true`
  23946. */
  23947. depthSortParticles: boolean;
  23948. /**
  23949. * This function does nothing. It may be overwritten to set all the particle first values.
  23950. * The SPS doesn't call this function, you may have to call it by your own.
  23951. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23952. */
  23953. initParticles(): void;
  23954. /**
  23955. * This function does nothing. It may be overwritten to recycle a particle.
  23956. * The SPS doesn't call this function, you may have to call it by your own.
  23957. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23958. * @param particle The particle to recycle
  23959. * @returns the recycled particle
  23960. */
  23961. recycleParticle(particle: SolidParticle): SolidParticle;
  23962. /**
  23963. * Updates a particle : this function should be overwritten by the user.
  23964. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23965. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23966. * @example : just set a particle position or velocity and recycle conditions
  23967. * @param particle The particle to update
  23968. * @returns the updated particle
  23969. */
  23970. updateParticle(particle: SolidParticle): SolidParticle;
  23971. /**
  23972. * Updates a vertex of a particle : it can be overwritten by the user.
  23973. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23974. * @param particle the current particle
  23975. * @param vertex the current index of the current particle
  23976. * @param pt the index of the current vertex in the particle shape
  23977. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23978. * @example : just set a vertex particle position
  23979. * @returns the updated vertex
  23980. */
  23981. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23982. /**
  23983. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23984. * This does nothing and may be overwritten by the user.
  23985. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23986. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23987. * @param update the boolean update value actually passed to setParticles()
  23988. */
  23989. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23990. /**
  23991. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23992. * This will be passed three parameters.
  23993. * This does nothing and may be overwritten by the user.
  23994. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23995. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23996. * @param update the boolean update value actually passed to setParticles()
  23997. */
  23998. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23999. }
  24000. }
  24001. declare module BABYLON {
  24002. /**
  24003. * Represents one particle of a solid particle system.
  24004. */
  24005. export class SolidParticle {
  24006. /**
  24007. * particle global index
  24008. */
  24009. idx: number;
  24010. /**
  24011. * The color of the particle
  24012. */
  24013. color: Nullable<Color4>;
  24014. /**
  24015. * The world space position of the particle.
  24016. */
  24017. position: Vector3;
  24018. /**
  24019. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24020. */
  24021. rotation: Vector3;
  24022. /**
  24023. * The world space rotation quaternion of the particle.
  24024. */
  24025. rotationQuaternion: Nullable<Quaternion>;
  24026. /**
  24027. * The scaling of the particle.
  24028. */
  24029. scaling: Vector3;
  24030. /**
  24031. * The uvs of the particle.
  24032. */
  24033. uvs: Vector4;
  24034. /**
  24035. * The current speed of the particle.
  24036. */
  24037. velocity: Vector3;
  24038. /**
  24039. * The pivot point in the particle local space.
  24040. */
  24041. pivot: Vector3;
  24042. /**
  24043. * Must the particle be translated from its pivot point in its local space ?
  24044. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24045. * Default : false
  24046. */
  24047. translateFromPivot: boolean;
  24048. /**
  24049. * Is the particle active or not ?
  24050. */
  24051. alive: boolean;
  24052. /**
  24053. * Is the particle visible or not ?
  24054. */
  24055. isVisible: boolean;
  24056. /**
  24057. * Index of this particle in the global "positions" array (Internal use)
  24058. * @hidden
  24059. */
  24060. _pos: number;
  24061. /**
  24062. * @hidden Index of this particle in the global "indices" array (Internal use)
  24063. */
  24064. _ind: number;
  24065. /**
  24066. * @hidden ModelShape of this particle (Internal use)
  24067. */
  24068. _model: ModelShape;
  24069. /**
  24070. * ModelShape id of this particle
  24071. */
  24072. shapeId: number;
  24073. /**
  24074. * Index of the particle in its shape id (Internal use)
  24075. */
  24076. idxInShape: number;
  24077. /**
  24078. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24079. */
  24080. _modelBoundingInfo: BoundingInfo;
  24081. /**
  24082. * @hidden Particle BoundingInfo object (Internal use)
  24083. */
  24084. _boundingInfo: BoundingInfo;
  24085. /**
  24086. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24087. */
  24088. _sps: SolidParticleSystem;
  24089. /**
  24090. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24091. */
  24092. _stillInvisible: boolean;
  24093. /**
  24094. * @hidden Last computed particle rotation matrix
  24095. */
  24096. _rotationMatrix: number[];
  24097. /**
  24098. * Parent particle Id, if any.
  24099. * Default null.
  24100. */
  24101. parentId: Nullable<number>;
  24102. /**
  24103. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24104. * The possible values are :
  24105. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24106. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24107. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24108. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24109. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24110. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24111. * */
  24112. cullingStrategy: number;
  24113. /**
  24114. * @hidden Internal global position in the SPS.
  24115. */
  24116. _globalPosition: Vector3;
  24117. /**
  24118. * Creates a Solid Particle object.
  24119. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24120. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24121. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24122. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24123. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24124. * @param shapeId (integer) is the model shape identifier in the SPS.
  24125. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24126. * @param sps defines the sps it is associated to
  24127. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24128. */
  24129. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24130. /**
  24131. * Legacy support, changed scale to scaling
  24132. */
  24133. /**
  24134. * Legacy support, changed scale to scaling
  24135. */
  24136. scale: Vector3;
  24137. /**
  24138. * Legacy support, changed quaternion to rotationQuaternion
  24139. */
  24140. /**
  24141. * Legacy support, changed quaternion to rotationQuaternion
  24142. */
  24143. quaternion: Nullable<Quaternion>;
  24144. /**
  24145. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24146. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24147. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24148. * @returns true if it intersects
  24149. */
  24150. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24151. /**
  24152. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24153. * A particle is in the frustum if its bounding box intersects the frustum
  24154. * @param frustumPlanes defines the frustum to test
  24155. * @returns true if the particle is in the frustum planes
  24156. */
  24157. isInFrustum(frustumPlanes: Plane[]): boolean;
  24158. /**
  24159. * get the rotation matrix of the particle
  24160. * @hidden
  24161. */
  24162. getRotationMatrix(m: Matrix): void;
  24163. }
  24164. /**
  24165. * Represents the shape of the model used by one particle of a solid particle system.
  24166. * SPS internal tool, don't use it manually.
  24167. */
  24168. export class ModelShape {
  24169. /**
  24170. * The shape id
  24171. * @hidden
  24172. */
  24173. shapeID: number;
  24174. /**
  24175. * flat array of model positions (internal use)
  24176. * @hidden
  24177. */
  24178. _shape: Vector3[];
  24179. /**
  24180. * flat array of model UVs (internal use)
  24181. * @hidden
  24182. */
  24183. _shapeUV: number[];
  24184. /**
  24185. * length of the shape in the model indices array (internal use)
  24186. * @hidden
  24187. */
  24188. _indicesLength: number;
  24189. /**
  24190. * Custom position function (internal use)
  24191. * @hidden
  24192. */
  24193. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24194. /**
  24195. * Custom vertex function (internal use)
  24196. * @hidden
  24197. */
  24198. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24199. /**
  24200. * 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.
  24201. * SPS internal tool, don't use it manually.
  24202. * @hidden
  24203. */
  24204. 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>);
  24205. }
  24206. /**
  24207. * Represents a Depth Sorted Particle in the solid particle system.
  24208. */
  24209. export class DepthSortedParticle {
  24210. /**
  24211. * Index of the particle in the "indices" array
  24212. */
  24213. ind: number;
  24214. /**
  24215. * Length of the particle shape in the "indices" array
  24216. */
  24217. indicesLength: number;
  24218. /**
  24219. * Squared distance from the particle to the camera
  24220. */
  24221. sqDistance: number;
  24222. }
  24223. }
  24224. declare module BABYLON {
  24225. /**
  24226. * Class used to store all common mesh properties
  24227. */
  24228. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24229. /** No occlusion */
  24230. static OCCLUSION_TYPE_NONE: number;
  24231. /** Occlusion set to optimisitic */
  24232. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24233. /** Occlusion set to strict */
  24234. static OCCLUSION_TYPE_STRICT: number;
  24235. /** Use an accurante occlusion algorithm */
  24236. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24237. /** Use a conservative occlusion algorithm */
  24238. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24239. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24240. * Test order :
  24241. * Is the bounding sphere outside the frustum ?
  24242. * If not, are the bounding box vertices outside the frustum ?
  24243. * It not, then the cullable object is in the frustum.
  24244. */
  24245. static readonly CULLINGSTRATEGY_STANDARD: number;
  24246. /** Culling strategy : Bounding Sphere Only.
  24247. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24248. * It's also less accurate than the standard because some not visible objects can still be selected.
  24249. * Test : is the bounding sphere outside the frustum ?
  24250. * If not, then the cullable object is in the frustum.
  24251. */
  24252. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24253. /** Culling strategy : Optimistic Inclusion.
  24254. * This in an inclusion test first, then the standard exclusion test.
  24255. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24256. * 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.
  24257. * Anyway, it's as accurate as the standard strategy.
  24258. * Test :
  24259. * Is the cullable object bounding sphere center in the frustum ?
  24260. * If not, apply the default culling strategy.
  24261. */
  24262. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24263. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24264. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24265. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24266. * 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.
  24267. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24268. * Test :
  24269. * Is the cullable object bounding sphere center in the frustum ?
  24270. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24271. */
  24272. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24273. /**
  24274. * No billboard
  24275. */
  24276. static readonly BILLBOARDMODE_NONE: number;
  24277. /** Billboard on X axis */
  24278. static readonly BILLBOARDMODE_X: number;
  24279. /** Billboard on Y axis */
  24280. static readonly BILLBOARDMODE_Y: number;
  24281. /** Billboard on Z axis */
  24282. static readonly BILLBOARDMODE_Z: number;
  24283. /** Billboard on all axes */
  24284. static readonly BILLBOARDMODE_ALL: number;
  24285. private _facetData;
  24286. /**
  24287. * The culling strategy to use to check whether the mesh must be rendered or not.
  24288. * This value can be changed at any time and will be used on the next render mesh selection.
  24289. * The possible values are :
  24290. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24291. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24292. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24293. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24294. * Please read each static variable documentation to get details about the culling process.
  24295. * */
  24296. cullingStrategy: number;
  24297. /**
  24298. * Gets the number of facets in the mesh
  24299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24300. */
  24301. readonly facetNb: number;
  24302. /**
  24303. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24305. */
  24306. partitioningSubdivisions: number;
  24307. /**
  24308. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24309. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24311. */
  24312. partitioningBBoxRatio: number;
  24313. /**
  24314. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24315. * Works only for updatable meshes.
  24316. * Doesn't work with multi-materials
  24317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24318. */
  24319. mustDepthSortFacets: boolean;
  24320. /**
  24321. * The location (Vector3) where the facet depth sort must be computed from.
  24322. * By default, the active camera position.
  24323. * Used only when facet depth sort is enabled
  24324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24325. */
  24326. facetDepthSortFrom: Vector3;
  24327. /**
  24328. * gets a boolean indicating if facetData is enabled
  24329. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24330. */
  24331. readonly isFacetDataEnabled: boolean;
  24332. /** @hidden */
  24333. _updateNonUniformScalingState(value: boolean): boolean;
  24334. /**
  24335. * An event triggered when this mesh collides with another one
  24336. */
  24337. onCollideObservable: Observable<AbstractMesh>;
  24338. private _onCollideObserver;
  24339. /** Set a function to call when this mesh collides with another one */
  24340. onCollide: () => void;
  24341. /**
  24342. * An event triggered when the collision's position changes
  24343. */
  24344. onCollisionPositionChangeObservable: Observable<Vector3>;
  24345. private _onCollisionPositionChangeObserver;
  24346. /** Set a function to call when the collision's position changes */
  24347. onCollisionPositionChange: () => void;
  24348. /**
  24349. * An event triggered when material is changed
  24350. */
  24351. onMaterialChangedObservable: Observable<AbstractMesh>;
  24352. /**
  24353. * Gets or sets the orientation for POV movement & rotation
  24354. */
  24355. definedFacingForward: boolean;
  24356. /** @hidden */
  24357. _occlusionQuery: Nullable<WebGLQuery>;
  24358. private _visibility;
  24359. /** @hidden */
  24360. _isActive: boolean;
  24361. /** @hidden */
  24362. _onlyForInstances: boolean;
  24363. /** @hidden */
  24364. _renderingGroup: Nullable<RenderingGroup>;
  24365. /**
  24366. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24367. */
  24368. /**
  24369. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24370. */
  24371. visibility: number;
  24372. /** Gets or sets the alpha index used to sort transparent meshes
  24373. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24374. */
  24375. alphaIndex: number;
  24376. /**
  24377. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24378. */
  24379. isVisible: boolean;
  24380. /**
  24381. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24382. */
  24383. isPickable: boolean;
  24384. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24385. showSubMeshesBoundingBox: boolean;
  24386. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24387. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24388. */
  24389. isBlocker: boolean;
  24390. /**
  24391. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24392. */
  24393. enablePointerMoveEvents: boolean;
  24394. /**
  24395. * Specifies the rendering group id for this mesh (0 by default)
  24396. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24397. */
  24398. renderingGroupId: number;
  24399. private _material;
  24400. /** Gets or sets current material */
  24401. material: Nullable<Material>;
  24402. private _receiveShadows;
  24403. /**
  24404. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24405. * @see http://doc.babylonjs.com/babylon101/shadows
  24406. */
  24407. receiveShadows: boolean;
  24408. /** Defines color to use when rendering outline */
  24409. outlineColor: Color3;
  24410. /** Define width to use when rendering outline */
  24411. outlineWidth: number;
  24412. /** Defines color to use when rendering overlay */
  24413. overlayColor: Color3;
  24414. /** Defines alpha to use when rendering overlay */
  24415. overlayAlpha: number;
  24416. private _hasVertexAlpha;
  24417. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24418. hasVertexAlpha: boolean;
  24419. private _useVertexColors;
  24420. /** 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) */
  24421. useVertexColors: boolean;
  24422. private _computeBonesUsingShaders;
  24423. /**
  24424. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24425. */
  24426. computeBonesUsingShaders: boolean;
  24427. private _numBoneInfluencers;
  24428. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24429. numBoneInfluencers: number;
  24430. private _applyFog;
  24431. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24432. applyFog: boolean;
  24433. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24434. useOctreeForRenderingSelection: boolean;
  24435. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24436. useOctreeForPicking: boolean;
  24437. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24438. useOctreeForCollisions: boolean;
  24439. private _layerMask;
  24440. /**
  24441. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24442. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24443. */
  24444. layerMask: number;
  24445. /**
  24446. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24447. */
  24448. alwaysSelectAsActiveMesh: boolean;
  24449. /**
  24450. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24451. */
  24452. doNotSyncBoundingInfo: boolean;
  24453. /**
  24454. * Gets or sets the current action manager
  24455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24456. */
  24457. actionManager: Nullable<AbstractActionManager>;
  24458. private _checkCollisions;
  24459. private _collisionMask;
  24460. private _collisionGroup;
  24461. /**
  24462. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24463. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24464. */
  24465. ellipsoid: Vector3;
  24466. /**
  24467. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24468. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24469. */
  24470. ellipsoidOffset: Vector3;
  24471. private _collider;
  24472. private _oldPositionForCollisions;
  24473. private _diffPositionForCollisions;
  24474. /**
  24475. * Gets or sets a collision mask used to mask collisions (default is -1).
  24476. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24477. */
  24478. collisionMask: number;
  24479. /**
  24480. * Gets or sets the current collision group mask (-1 by default).
  24481. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24482. */
  24483. collisionGroup: number;
  24484. /**
  24485. * Defines edge width used when edgesRenderer is enabled
  24486. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24487. */
  24488. edgesWidth: number;
  24489. /**
  24490. * Defines edge color used when edgesRenderer is enabled
  24491. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24492. */
  24493. edgesColor: Color4;
  24494. /** @hidden */
  24495. _edgesRenderer: Nullable<IEdgesRenderer>;
  24496. /** @hidden */
  24497. _masterMesh: Nullable<AbstractMesh>;
  24498. /** @hidden */
  24499. _boundingInfo: Nullable<BoundingInfo>;
  24500. /** @hidden */
  24501. _renderId: number;
  24502. /**
  24503. * Gets or sets the list of subMeshes
  24504. * @see http://doc.babylonjs.com/how_to/multi_materials
  24505. */
  24506. subMeshes: SubMesh[];
  24507. /** @hidden */
  24508. _intersectionsInProgress: AbstractMesh[];
  24509. /** @hidden */
  24510. _unIndexed: boolean;
  24511. /** @hidden */
  24512. _lightSources: Light[];
  24513. /** Gets the list of lights affecting that mesh */
  24514. readonly lightSources: Light[];
  24515. /** @hidden */
  24516. readonly _positions: Nullable<Vector3[]>;
  24517. /** @hidden */
  24518. _waitingData: {
  24519. lods: Nullable<any>;
  24520. actions: Nullable<any>;
  24521. freezeWorldMatrix: Nullable<boolean>;
  24522. };
  24523. private _skeleton;
  24524. /** @hidden */
  24525. _bonesTransformMatrices: Nullable<Float32Array>;
  24526. /**
  24527. * Gets or sets a skeleton to apply skining transformations
  24528. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24529. */
  24530. skeleton: Nullable<Skeleton>;
  24531. /**
  24532. * An event triggered when the mesh is rebuilt.
  24533. */
  24534. onRebuildObservable: Observable<AbstractMesh>;
  24535. /**
  24536. * Creates a new AbstractMesh
  24537. * @param name defines the name of the mesh
  24538. * @param scene defines the hosting scene
  24539. */
  24540. constructor(name: string, scene?: Nullable<Scene>);
  24541. /**
  24542. * Returns the string "AbstractMesh"
  24543. * @returns "AbstractMesh"
  24544. */
  24545. getClassName(): string;
  24546. /**
  24547. * Gets a string representation of the current mesh
  24548. * @param fullDetails defines a boolean indicating if full details must be included
  24549. * @returns a string representation of the current mesh
  24550. */
  24551. toString(fullDetails?: boolean): string;
  24552. /**
  24553. * @hidden
  24554. */
  24555. protected _getEffectiveParent(): Nullable<Node>;
  24556. /** @hidden */
  24557. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24558. /** @hidden */
  24559. _rebuild(): void;
  24560. /** @hidden */
  24561. _resyncLightSources(): void;
  24562. /** @hidden */
  24563. _resyncLighSource(light: Light): void;
  24564. /** @hidden */
  24565. _unBindEffect(): void;
  24566. /** @hidden */
  24567. _removeLightSource(light: Light): void;
  24568. private _markSubMeshesAsDirty;
  24569. /** @hidden */
  24570. _markSubMeshesAsLightDirty(): void;
  24571. /** @hidden */
  24572. _markSubMeshesAsAttributesDirty(): void;
  24573. /** @hidden */
  24574. _markSubMeshesAsMiscDirty(): void;
  24575. /**
  24576. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24577. */
  24578. scaling: Vector3;
  24579. /**
  24580. * Returns true if the mesh is blocked. Implemented by child classes
  24581. */
  24582. readonly isBlocked: boolean;
  24583. /**
  24584. * Returns the mesh itself by default. Implemented by child classes
  24585. * @param camera defines the camera to use to pick the right LOD level
  24586. * @returns the currentAbstractMesh
  24587. */
  24588. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24589. /**
  24590. * Returns 0 by default. Implemented by child classes
  24591. * @returns an integer
  24592. */
  24593. getTotalVertices(): number;
  24594. /**
  24595. * Returns a positive integer : the total number of indices in this mesh geometry.
  24596. * @returns the numner of indices or zero if the mesh has no geometry.
  24597. */
  24598. getTotalIndices(): number;
  24599. /**
  24600. * Returns null by default. Implemented by child classes
  24601. * @returns null
  24602. */
  24603. getIndices(): Nullable<IndicesArray>;
  24604. /**
  24605. * Returns the array of the requested vertex data kind. Implemented by child classes
  24606. * @param kind defines the vertex data kind to use
  24607. * @returns null
  24608. */
  24609. getVerticesData(kind: string): Nullable<FloatArray>;
  24610. /**
  24611. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24612. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24613. * Note that a new underlying VertexBuffer object is created each call.
  24614. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24615. * @param kind defines vertex data kind:
  24616. * * VertexBuffer.PositionKind
  24617. * * VertexBuffer.UVKind
  24618. * * VertexBuffer.UV2Kind
  24619. * * VertexBuffer.UV3Kind
  24620. * * VertexBuffer.UV4Kind
  24621. * * VertexBuffer.UV5Kind
  24622. * * VertexBuffer.UV6Kind
  24623. * * VertexBuffer.ColorKind
  24624. * * VertexBuffer.MatricesIndicesKind
  24625. * * VertexBuffer.MatricesIndicesExtraKind
  24626. * * VertexBuffer.MatricesWeightsKind
  24627. * * VertexBuffer.MatricesWeightsExtraKind
  24628. * @param data defines the data source
  24629. * @param updatable defines if the data must be flagged as updatable (or static)
  24630. * @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
  24631. * @returns the current mesh
  24632. */
  24633. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24634. /**
  24635. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24636. * If the mesh has no geometry, it is simply returned as it is.
  24637. * @param kind defines vertex data kind:
  24638. * * VertexBuffer.PositionKind
  24639. * * VertexBuffer.UVKind
  24640. * * VertexBuffer.UV2Kind
  24641. * * VertexBuffer.UV3Kind
  24642. * * VertexBuffer.UV4Kind
  24643. * * VertexBuffer.UV5Kind
  24644. * * VertexBuffer.UV6Kind
  24645. * * VertexBuffer.ColorKind
  24646. * * VertexBuffer.MatricesIndicesKind
  24647. * * VertexBuffer.MatricesIndicesExtraKind
  24648. * * VertexBuffer.MatricesWeightsKind
  24649. * * VertexBuffer.MatricesWeightsExtraKind
  24650. * @param data defines the data source
  24651. * @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
  24652. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24653. * @returns the current mesh
  24654. */
  24655. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24656. /**
  24657. * Sets the mesh indices,
  24658. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24659. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24660. * @param totalVertices Defines the total number of vertices
  24661. * @returns the current mesh
  24662. */
  24663. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24664. /**
  24665. * Gets a boolean indicating if specific vertex data is present
  24666. * @param kind defines the vertex data kind to use
  24667. * @returns true is data kind is present
  24668. */
  24669. isVerticesDataPresent(kind: string): boolean;
  24670. /**
  24671. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24672. * @returns a BoundingInfo
  24673. */
  24674. getBoundingInfo(): BoundingInfo;
  24675. /**
  24676. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24677. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24678. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24679. * @returns the current mesh
  24680. */
  24681. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24682. /**
  24683. * Overwrite the current bounding info
  24684. * @param boundingInfo defines the new bounding info
  24685. * @returns the current mesh
  24686. */
  24687. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24688. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24689. readonly useBones: boolean;
  24690. /** @hidden */
  24691. _preActivate(): void;
  24692. /** @hidden */
  24693. _preActivateForIntermediateRendering(renderId: number): void;
  24694. /** @hidden */
  24695. _activate(renderId: number): boolean;
  24696. /** @hidden */
  24697. _postActivate(): void;
  24698. /** @hidden */
  24699. _freeze(): void;
  24700. /** @hidden */
  24701. _unFreeze(): void;
  24702. /**
  24703. * Gets the current world matrix
  24704. * @returns a Matrix
  24705. */
  24706. getWorldMatrix(): Matrix;
  24707. /** @hidden */
  24708. _getWorldMatrixDeterminant(): number;
  24709. /**
  24710. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24711. */
  24712. readonly isAnInstance: boolean;
  24713. /**
  24714. * Perform relative position change from the point of view of behind the front of the mesh.
  24715. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24716. * Supports definition of mesh facing forward or backward
  24717. * @param amountRight defines the distance on the right axis
  24718. * @param amountUp defines the distance on the up axis
  24719. * @param amountForward defines the distance on the forward axis
  24720. * @returns the current mesh
  24721. */
  24722. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24723. /**
  24724. * Calculate relative position change from the point of view of behind the front of the mesh.
  24725. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24726. * Supports definition of mesh facing forward or backward
  24727. * @param amountRight defines the distance on the right axis
  24728. * @param amountUp defines the distance on the up axis
  24729. * @param amountForward defines the distance on the forward axis
  24730. * @returns the new displacement vector
  24731. */
  24732. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24733. /**
  24734. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24735. * Supports definition of mesh facing forward or backward
  24736. * @param flipBack defines the flip
  24737. * @param twirlClockwise defines the twirl
  24738. * @param tiltRight defines the tilt
  24739. * @returns the current mesh
  24740. */
  24741. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24742. /**
  24743. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24744. * Supports definition of mesh facing forward or backward.
  24745. * @param flipBack defines the flip
  24746. * @param twirlClockwise defines the twirl
  24747. * @param tiltRight defines the tilt
  24748. * @returns the new rotation vector
  24749. */
  24750. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24751. /**
  24752. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24753. * This means the mesh underlying bounding box and sphere are recomputed.
  24754. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24755. * @returns the current mesh
  24756. */
  24757. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24758. /** @hidden */
  24759. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24760. /** @hidden */
  24761. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24762. /** @hidden */
  24763. _updateBoundingInfo(): AbstractMesh;
  24764. /** @hidden */
  24765. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24766. /** @hidden */
  24767. protected _afterComputeWorldMatrix(): void;
  24768. /** @hidden */
  24769. readonly _effectiveMesh: AbstractMesh;
  24770. /**
  24771. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24772. * A mesh is in the frustum if its bounding box intersects the frustum
  24773. * @param frustumPlanes defines the frustum to test
  24774. * @returns true if the mesh is in the frustum planes
  24775. */
  24776. isInFrustum(frustumPlanes: Plane[]): boolean;
  24777. /**
  24778. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24779. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24780. * @param frustumPlanes defines the frustum to test
  24781. * @returns true if the mesh is completely in the frustum planes
  24782. */
  24783. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24784. /**
  24785. * True if the mesh intersects another mesh or a SolidParticle object
  24786. * @param mesh defines a target mesh or SolidParticle to test
  24787. * @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)
  24788. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24789. * @returns true if there is an intersection
  24790. */
  24791. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24792. /**
  24793. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24794. * @param point defines the point to test
  24795. * @returns true if there is an intersection
  24796. */
  24797. intersectsPoint(point: Vector3): boolean;
  24798. /**
  24799. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24801. */
  24802. checkCollisions: boolean;
  24803. /**
  24804. * Gets Collider object used to compute collisions (not physics)
  24805. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24806. */
  24807. readonly collider: Nullable<Collider>;
  24808. /**
  24809. * Move the mesh using collision engine
  24810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24811. * @param displacement defines the requested displacement vector
  24812. * @returns the current mesh
  24813. */
  24814. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24815. private _onCollisionPositionChange;
  24816. /** @hidden */
  24817. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24818. /** @hidden */
  24819. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24820. /** @hidden */
  24821. _checkCollision(collider: Collider): AbstractMesh;
  24822. /** @hidden */
  24823. _generatePointsArray(): boolean;
  24824. /**
  24825. * Checks if the passed Ray intersects with the mesh
  24826. * @param ray defines the ray to use
  24827. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24828. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24829. * @returns the picking info
  24830. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24831. */
  24832. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24833. /**
  24834. * Clones the current mesh
  24835. * @param name defines the mesh name
  24836. * @param newParent defines the new mesh parent
  24837. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24838. * @returns the new mesh
  24839. */
  24840. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24841. /**
  24842. * Disposes all the submeshes of the current meshnp
  24843. * @returns the current mesh
  24844. */
  24845. releaseSubMeshes(): AbstractMesh;
  24846. /**
  24847. * Releases resources associated with this abstract mesh.
  24848. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24849. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24850. */
  24851. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24852. /**
  24853. * Adds the passed mesh as a child to the current mesh
  24854. * @param mesh defines the child mesh
  24855. * @returns the current mesh
  24856. */
  24857. addChild(mesh: AbstractMesh): AbstractMesh;
  24858. /**
  24859. * Removes the passed mesh from the current mesh children list
  24860. * @param mesh defines the child mesh
  24861. * @returns the current mesh
  24862. */
  24863. removeChild(mesh: AbstractMesh): AbstractMesh;
  24864. /** @hidden */
  24865. private _initFacetData;
  24866. /**
  24867. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24868. * This method can be called within the render loop.
  24869. * 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
  24870. * @returns the current mesh
  24871. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24872. */
  24873. updateFacetData(): AbstractMesh;
  24874. /**
  24875. * Returns the facetLocalNormals array.
  24876. * The normals are expressed in the mesh local spac
  24877. * @returns an array of Vector3
  24878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24879. */
  24880. getFacetLocalNormals(): Vector3[];
  24881. /**
  24882. * Returns the facetLocalPositions array.
  24883. * The facet positions are expressed in the mesh local space
  24884. * @returns an array of Vector3
  24885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24886. */
  24887. getFacetLocalPositions(): Vector3[];
  24888. /**
  24889. * Returns the facetLocalPartioning array
  24890. * @returns an array of array of numbers
  24891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24892. */
  24893. getFacetLocalPartitioning(): number[][];
  24894. /**
  24895. * Returns the i-th facet position in the world system.
  24896. * This method allocates a new Vector3 per call
  24897. * @param i defines the facet index
  24898. * @returns a new Vector3
  24899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24900. */
  24901. getFacetPosition(i: number): Vector3;
  24902. /**
  24903. * Sets the reference Vector3 with the i-th facet position in the world system
  24904. * @param i defines the facet index
  24905. * @param ref defines the target vector
  24906. * @returns the current mesh
  24907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24908. */
  24909. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24910. /**
  24911. * Returns the i-th facet normal in the world system.
  24912. * This method allocates a new Vector3 per call
  24913. * @param i defines the facet index
  24914. * @returns a new Vector3
  24915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24916. */
  24917. getFacetNormal(i: number): Vector3;
  24918. /**
  24919. * Sets the reference Vector3 with the i-th facet normal in the world system
  24920. * @param i defines the facet index
  24921. * @param ref defines the target vector
  24922. * @returns the current mesh
  24923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24924. */
  24925. getFacetNormalToRef(i: number, ref: Vector3): this;
  24926. /**
  24927. * 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)
  24928. * @param x defines x coordinate
  24929. * @param y defines y coordinate
  24930. * @param z defines z coordinate
  24931. * @returns the array of facet indexes
  24932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24933. */
  24934. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24935. /**
  24936. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24937. * @param projected sets as the (x,y,z) world projection on the facet
  24938. * @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
  24939. * @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
  24940. * @param x defines x coordinate
  24941. * @param y defines y coordinate
  24942. * @param z defines z coordinate
  24943. * @returns the face index if found (or null instead)
  24944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24945. */
  24946. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24947. /**
  24948. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24949. * @param projected sets as the (x,y,z) local projection on the facet
  24950. * @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
  24951. * @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
  24952. * @param x defines x coordinate
  24953. * @param y defines y coordinate
  24954. * @param z defines z coordinate
  24955. * @returns the face index if found (or null instead)
  24956. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24957. */
  24958. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24959. /**
  24960. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24961. * @returns the parameters
  24962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24963. */
  24964. getFacetDataParameters(): any;
  24965. /**
  24966. * Disables the feature FacetData and frees the related memory
  24967. * @returns the current mesh
  24968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24969. */
  24970. disableFacetData(): AbstractMesh;
  24971. /**
  24972. * Updates the AbstractMesh indices array
  24973. * @param indices defines the data source
  24974. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24975. * @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)
  24976. * @returns the current mesh
  24977. */
  24978. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24979. /**
  24980. * Creates new normals data for the mesh
  24981. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24982. * @returns the current mesh
  24983. */
  24984. createNormals(updatable: boolean): AbstractMesh;
  24985. /**
  24986. * Align the mesh with a normal
  24987. * @param normal defines the normal to use
  24988. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24989. * @returns the current mesh
  24990. */
  24991. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24992. /** @hidden */
  24993. _checkOcclusionQuery(): boolean;
  24994. }
  24995. }
  24996. declare module BABYLON {
  24997. /**
  24998. * Interface used to define ActionEvent
  24999. */
  25000. export interface IActionEvent {
  25001. /** The mesh or sprite that triggered the action */
  25002. source: any;
  25003. /** The X mouse cursor position at the time of the event */
  25004. pointerX: number;
  25005. /** The Y mouse cursor position at the time of the event */
  25006. pointerY: number;
  25007. /** The mesh that is currently pointed at (can be null) */
  25008. meshUnderPointer: Nullable<AbstractMesh>;
  25009. /** the original (browser) event that triggered the ActionEvent */
  25010. sourceEvent?: any;
  25011. /** additional data for the event */
  25012. additionalData?: any;
  25013. }
  25014. /**
  25015. * ActionEvent is the event being sent when an action is triggered.
  25016. */
  25017. export class ActionEvent implements IActionEvent {
  25018. /** The mesh or sprite that triggered the action */
  25019. source: any;
  25020. /** The X mouse cursor position at the time of the event */
  25021. pointerX: number;
  25022. /** The Y mouse cursor position at the time of the event */
  25023. pointerY: number;
  25024. /** The mesh that is currently pointed at (can be null) */
  25025. meshUnderPointer: Nullable<AbstractMesh>;
  25026. /** the original (browser) event that triggered the ActionEvent */
  25027. sourceEvent?: any;
  25028. /** additional data for the event */
  25029. additionalData?: any;
  25030. /**
  25031. * Creates a new ActionEvent
  25032. * @param source The mesh or sprite that triggered the action
  25033. * @param pointerX The X mouse cursor position at the time of the event
  25034. * @param pointerY The Y mouse cursor position at the time of the event
  25035. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25036. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25037. * @param additionalData additional data for the event
  25038. */
  25039. constructor(
  25040. /** The mesh or sprite that triggered the action */
  25041. source: any,
  25042. /** The X mouse cursor position at the time of the event */
  25043. pointerX: number,
  25044. /** The Y mouse cursor position at the time of the event */
  25045. pointerY: number,
  25046. /** The mesh that is currently pointed at (can be null) */
  25047. meshUnderPointer: Nullable<AbstractMesh>,
  25048. /** the original (browser) event that triggered the ActionEvent */
  25049. sourceEvent?: any,
  25050. /** additional data for the event */
  25051. additionalData?: any);
  25052. /**
  25053. * Helper function to auto-create an ActionEvent from a source mesh.
  25054. * @param source The source mesh that triggered the event
  25055. * @param evt The original (browser) event
  25056. * @param additionalData additional data for the event
  25057. * @returns the new ActionEvent
  25058. */
  25059. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25060. /**
  25061. * Helper function to auto-create an ActionEvent from a source sprite
  25062. * @param source The source sprite that triggered the event
  25063. * @param scene Scene associated with the sprite
  25064. * @param evt The original (browser) event
  25065. * @param additionalData additional data for the event
  25066. * @returns the new ActionEvent
  25067. */
  25068. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25069. /**
  25070. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25071. * @param scene the scene where the event occurred
  25072. * @param evt The original (browser) event
  25073. * @returns the new ActionEvent
  25074. */
  25075. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25076. /**
  25077. * Helper function to auto-create an ActionEvent from a primitive
  25078. * @param prim defines the target primitive
  25079. * @param pointerPos defines the pointer position
  25080. * @param evt The original (browser) event
  25081. * @param additionalData additional data for the event
  25082. * @returns the new ActionEvent
  25083. */
  25084. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25085. }
  25086. }
  25087. declare module BABYLON {
  25088. /**
  25089. * Abstract class used to decouple action Manager from scene and meshes.
  25090. * Do not instantiate.
  25091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25092. */
  25093. export abstract class AbstractActionManager implements IDisposable {
  25094. /** Gets the list of active triggers */
  25095. static Triggers: {
  25096. [key: string]: number;
  25097. };
  25098. /** Gets the cursor to use when hovering items */
  25099. hoverCursor: string;
  25100. /** Gets the list of actions */
  25101. actions: IAction[];
  25102. /**
  25103. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25104. */
  25105. isRecursive: boolean;
  25106. /**
  25107. * Releases all associated resources
  25108. */
  25109. abstract dispose(): void;
  25110. /**
  25111. * Does this action manager has pointer triggers
  25112. */
  25113. abstract readonly hasPointerTriggers: boolean;
  25114. /**
  25115. * Does this action manager has pick triggers
  25116. */
  25117. abstract readonly hasPickTriggers: boolean;
  25118. /**
  25119. * Process a specific trigger
  25120. * @param trigger defines the trigger to process
  25121. * @param evt defines the event details to be processed
  25122. */
  25123. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25124. /**
  25125. * Does this action manager handles actions of any of the given triggers
  25126. * @param triggers defines the triggers to be tested
  25127. * @return a boolean indicating whether one (or more) of the triggers is handled
  25128. */
  25129. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25130. /**
  25131. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25132. * speed.
  25133. * @param triggerA defines the trigger to be tested
  25134. * @param triggerB defines the trigger to be tested
  25135. * @return a boolean indicating whether one (or more) of the triggers is handled
  25136. */
  25137. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25138. /**
  25139. * Does this action manager handles actions of a given trigger
  25140. * @param trigger defines the trigger to be tested
  25141. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25142. * @return whether the trigger is handled
  25143. */
  25144. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25145. /**
  25146. * Serialize this manager to a JSON object
  25147. * @param name defines the property name to store this manager
  25148. * @returns a JSON representation of this manager
  25149. */
  25150. abstract serialize(name: string): any;
  25151. /**
  25152. * Registers an action to this action manager
  25153. * @param action defines the action to be registered
  25154. * @return the action amended (prepared) after registration
  25155. */
  25156. abstract registerAction(action: IAction): Nullable<IAction>;
  25157. /**
  25158. * Unregisters an action to this action manager
  25159. * @param action defines the action to be unregistered
  25160. * @return a boolean indicating whether the action has been unregistered
  25161. */
  25162. abstract unregisterAction(action: IAction): Boolean;
  25163. /**
  25164. * Does exist one action manager with at least one trigger
  25165. **/
  25166. static readonly HasTriggers: boolean;
  25167. /**
  25168. * Does exist one action manager with at least one pick trigger
  25169. **/
  25170. static readonly HasPickTriggers: boolean;
  25171. /**
  25172. * Does exist one action manager that handles actions of a given trigger
  25173. * @param trigger defines the trigger to be tested
  25174. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25175. **/
  25176. static HasSpecificTrigger(trigger: number): boolean;
  25177. }
  25178. }
  25179. declare module BABYLON {
  25180. /**
  25181. * Defines how a node can be built from a string name.
  25182. */
  25183. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25184. /**
  25185. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25186. */
  25187. export class Node implements IBehaviorAware<Node> {
  25188. /** @hidden */
  25189. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25190. private static _NodeConstructors;
  25191. /**
  25192. * Add a new node constructor
  25193. * @param type defines the type name of the node to construct
  25194. * @param constructorFunc defines the constructor function
  25195. */
  25196. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25197. /**
  25198. * Returns a node constructor based on type name
  25199. * @param type defines the type name
  25200. * @param name defines the new node name
  25201. * @param scene defines the hosting scene
  25202. * @param options defines optional options to transmit to constructors
  25203. * @returns the new constructor or null
  25204. */
  25205. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25206. /**
  25207. * Gets or sets the name of the node
  25208. */
  25209. name: string;
  25210. /**
  25211. * Gets or sets the id of the node
  25212. */
  25213. id: string;
  25214. /**
  25215. * Gets or sets the unique id of the node
  25216. */
  25217. uniqueId: number;
  25218. /**
  25219. * Gets or sets a string used to store user defined state for the node
  25220. */
  25221. state: string;
  25222. /**
  25223. * Gets or sets an object used to store user defined information for the node
  25224. */
  25225. metadata: any;
  25226. /**
  25227. * For internal use only. Please do not use.
  25228. */
  25229. reservedDataStore: any;
  25230. /**
  25231. * List of inspectable custom properties (used by the Inspector)
  25232. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25233. */
  25234. inspectableCustomProperties: IInspectable[];
  25235. /**
  25236. * Gets or sets a boolean used to define if the node must be serialized
  25237. */
  25238. doNotSerialize: boolean;
  25239. /** @hidden */
  25240. _isDisposed: boolean;
  25241. /**
  25242. * Gets a list of Animations associated with the node
  25243. */
  25244. animations: Animation[];
  25245. protected _ranges: {
  25246. [name: string]: Nullable<AnimationRange>;
  25247. };
  25248. /**
  25249. * Callback raised when the node is ready to be used
  25250. */
  25251. onReady: Nullable<(node: Node) => void>;
  25252. private _isEnabled;
  25253. private _isParentEnabled;
  25254. private _isReady;
  25255. /** @hidden */
  25256. _currentRenderId: number;
  25257. private _parentUpdateId;
  25258. /** @hidden */
  25259. _childUpdateId: number;
  25260. /** @hidden */
  25261. _waitingParentId: Nullable<string>;
  25262. /** @hidden */
  25263. _scene: Scene;
  25264. /** @hidden */
  25265. _cache: any;
  25266. private _parentNode;
  25267. private _children;
  25268. /** @hidden */
  25269. _worldMatrix: Matrix;
  25270. /** @hidden */
  25271. _worldMatrixDeterminant: number;
  25272. /** @hidden */
  25273. _worldMatrixDeterminantIsDirty: boolean;
  25274. /** @hidden */
  25275. private _sceneRootNodesIndex;
  25276. /**
  25277. * Gets a boolean indicating if the node has been disposed
  25278. * @returns true if the node was disposed
  25279. */
  25280. isDisposed(): boolean;
  25281. /**
  25282. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25283. * @see https://doc.babylonjs.com/how_to/parenting
  25284. */
  25285. parent: Nullable<Node>;
  25286. private addToSceneRootNodes;
  25287. private removeFromSceneRootNodes;
  25288. private _animationPropertiesOverride;
  25289. /**
  25290. * Gets or sets the animation properties override
  25291. */
  25292. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25293. /**
  25294. * Gets a string idenfifying the name of the class
  25295. * @returns "Node" string
  25296. */
  25297. getClassName(): string;
  25298. /** @hidden */
  25299. readonly _isNode: boolean;
  25300. /**
  25301. * An event triggered when the mesh is disposed
  25302. */
  25303. onDisposeObservable: Observable<Node>;
  25304. private _onDisposeObserver;
  25305. /**
  25306. * Sets a callback that will be raised when the node will be disposed
  25307. */
  25308. onDispose: () => void;
  25309. /**
  25310. * Creates a new Node
  25311. * @param name the name and id to be given to this node
  25312. * @param scene the scene this node will be added to
  25313. * @param addToRootNodes the node will be added to scene.rootNodes
  25314. */
  25315. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25316. /**
  25317. * Gets the scene of the node
  25318. * @returns a scene
  25319. */
  25320. getScene(): Scene;
  25321. /**
  25322. * Gets the engine of the node
  25323. * @returns a Engine
  25324. */
  25325. getEngine(): Engine;
  25326. private _behaviors;
  25327. /**
  25328. * Attach a behavior to the node
  25329. * @see http://doc.babylonjs.com/features/behaviour
  25330. * @param behavior defines the behavior to attach
  25331. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25332. * @returns the current Node
  25333. */
  25334. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25335. /**
  25336. * Remove an attached behavior
  25337. * @see http://doc.babylonjs.com/features/behaviour
  25338. * @param behavior defines the behavior to attach
  25339. * @returns the current Node
  25340. */
  25341. removeBehavior(behavior: Behavior<Node>): Node;
  25342. /**
  25343. * Gets the list of attached behaviors
  25344. * @see http://doc.babylonjs.com/features/behaviour
  25345. */
  25346. readonly behaviors: Behavior<Node>[];
  25347. /**
  25348. * Gets an attached behavior by name
  25349. * @param name defines the name of the behavior to look for
  25350. * @see http://doc.babylonjs.com/features/behaviour
  25351. * @returns null if behavior was not found else the requested behavior
  25352. */
  25353. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25354. /**
  25355. * Returns the latest update of the World matrix
  25356. * @returns a Matrix
  25357. */
  25358. getWorldMatrix(): Matrix;
  25359. /** @hidden */
  25360. _getWorldMatrixDeterminant(): number;
  25361. /**
  25362. * Returns directly the latest state of the mesh World matrix.
  25363. * A Matrix is returned.
  25364. */
  25365. readonly worldMatrixFromCache: Matrix;
  25366. /** @hidden */
  25367. _initCache(): void;
  25368. /** @hidden */
  25369. updateCache(force?: boolean): void;
  25370. /** @hidden */
  25371. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25372. /** @hidden */
  25373. _updateCache(ignoreParentClass?: boolean): void;
  25374. /** @hidden */
  25375. _isSynchronized(): boolean;
  25376. /** @hidden */
  25377. _markSyncedWithParent(): void;
  25378. /** @hidden */
  25379. isSynchronizedWithParent(): boolean;
  25380. /** @hidden */
  25381. isSynchronized(): boolean;
  25382. /**
  25383. * Is this node ready to be used/rendered
  25384. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25385. * @return true if the node is ready
  25386. */
  25387. isReady(completeCheck?: boolean): boolean;
  25388. /**
  25389. * Is this node enabled?
  25390. * 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
  25391. * @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
  25392. * @return whether this node (and its parent) is enabled
  25393. */
  25394. isEnabled(checkAncestors?: boolean): boolean;
  25395. /** @hidden */
  25396. protected _syncParentEnabledState(): void;
  25397. /**
  25398. * Set the enabled state of this node
  25399. * @param value defines the new enabled state
  25400. */
  25401. setEnabled(value: boolean): void;
  25402. /**
  25403. * Is this node a descendant of the given node?
  25404. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25405. * @param ancestor defines the parent node to inspect
  25406. * @returns a boolean indicating if this node is a descendant of the given node
  25407. */
  25408. isDescendantOf(ancestor: Node): boolean;
  25409. /** @hidden */
  25410. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25411. /**
  25412. * Will return all nodes that have this node as ascendant
  25413. * @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
  25414. * @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
  25415. * @return all children nodes of all types
  25416. */
  25417. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25418. /**
  25419. * Get all child-meshes of this node
  25420. * @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)
  25421. * @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
  25422. * @returns an array of AbstractMesh
  25423. */
  25424. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25425. /**
  25426. * Get all direct children of this node
  25427. * @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
  25428. * @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)
  25429. * @returns an array of Node
  25430. */
  25431. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25432. /** @hidden */
  25433. _setReady(state: boolean): void;
  25434. /**
  25435. * Get an animation by name
  25436. * @param name defines the name of the animation to look for
  25437. * @returns null if not found else the requested animation
  25438. */
  25439. getAnimationByName(name: string): Nullable<Animation>;
  25440. /**
  25441. * Creates an animation range for this node
  25442. * @param name defines the name of the range
  25443. * @param from defines the starting key
  25444. * @param to defines the end key
  25445. */
  25446. createAnimationRange(name: string, from: number, to: number): void;
  25447. /**
  25448. * Delete a specific animation range
  25449. * @param name defines the name of the range to delete
  25450. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25451. */
  25452. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25453. /**
  25454. * Get an animation range by name
  25455. * @param name defines the name of the animation range to look for
  25456. * @returns null if not found else the requested animation range
  25457. */
  25458. getAnimationRange(name: string): Nullable<AnimationRange>;
  25459. /**
  25460. * Gets the list of all animation ranges defined on this node
  25461. * @returns an array
  25462. */
  25463. getAnimationRanges(): Nullable<AnimationRange>[];
  25464. /**
  25465. * Will start the animation sequence
  25466. * @param name defines the range frames for animation sequence
  25467. * @param loop defines if the animation should loop (false by default)
  25468. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25469. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25470. * @returns the object created for this animation. If range does not exist, it will return null
  25471. */
  25472. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25473. /**
  25474. * Serialize animation ranges into a JSON compatible object
  25475. * @returns serialization object
  25476. */
  25477. serializeAnimationRanges(): any;
  25478. /**
  25479. * Computes the world matrix of the node
  25480. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25481. * @returns the world matrix
  25482. */
  25483. computeWorldMatrix(force?: boolean): Matrix;
  25484. /**
  25485. * Releases resources associated with this node.
  25486. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25487. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25488. */
  25489. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25490. /**
  25491. * Parse animation range data from a serialization object and store them into a given node
  25492. * @param node defines where to store the animation ranges
  25493. * @param parsedNode defines the serialization object to read data from
  25494. * @param scene defines the hosting scene
  25495. */
  25496. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25497. /**
  25498. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25499. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25500. * @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
  25501. * @returns the new bounding vectors
  25502. */
  25503. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25504. min: Vector3;
  25505. max: Vector3;
  25506. };
  25507. }
  25508. }
  25509. declare module BABYLON {
  25510. /**
  25511. * @hidden
  25512. */
  25513. export class _IAnimationState {
  25514. key: number;
  25515. repeatCount: number;
  25516. workValue?: any;
  25517. loopMode?: number;
  25518. offsetValue?: any;
  25519. highLimitValue?: any;
  25520. }
  25521. /**
  25522. * Class used to store any kind of animation
  25523. */
  25524. export class Animation {
  25525. /**Name of the animation */
  25526. name: string;
  25527. /**Property to animate */
  25528. targetProperty: string;
  25529. /**The frames per second of the animation */
  25530. framePerSecond: number;
  25531. /**The data type of the animation */
  25532. dataType: number;
  25533. /**The loop mode of the animation */
  25534. loopMode?: number | undefined;
  25535. /**Specifies if blending should be enabled */
  25536. enableBlending?: boolean | undefined;
  25537. /**
  25538. * Use matrix interpolation instead of using direct key value when animating matrices
  25539. */
  25540. static AllowMatricesInterpolation: boolean;
  25541. /**
  25542. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25543. */
  25544. static AllowMatrixDecomposeForInterpolation: boolean;
  25545. /**
  25546. * Stores the key frames of the animation
  25547. */
  25548. private _keys;
  25549. /**
  25550. * Stores the easing function of the animation
  25551. */
  25552. private _easingFunction;
  25553. /**
  25554. * @hidden Internal use only
  25555. */
  25556. _runtimeAnimations: RuntimeAnimation[];
  25557. /**
  25558. * The set of event that will be linked to this animation
  25559. */
  25560. private _events;
  25561. /**
  25562. * Stores an array of target property paths
  25563. */
  25564. targetPropertyPath: string[];
  25565. /**
  25566. * Stores the blending speed of the animation
  25567. */
  25568. blendingSpeed: number;
  25569. /**
  25570. * Stores the animation ranges for the animation
  25571. */
  25572. private _ranges;
  25573. /**
  25574. * @hidden Internal use
  25575. */
  25576. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25577. /**
  25578. * Sets up an animation
  25579. * @param property The property to animate
  25580. * @param animationType The animation type to apply
  25581. * @param framePerSecond The frames per second of the animation
  25582. * @param easingFunction The easing function used in the animation
  25583. * @returns The created animation
  25584. */
  25585. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25586. /**
  25587. * Create and start an animation on a node
  25588. * @param name defines the name of the global animation that will be run on all nodes
  25589. * @param node defines the root node where the animation will take place
  25590. * @param targetProperty defines property to animate
  25591. * @param framePerSecond defines the number of frame per second yo use
  25592. * @param totalFrame defines the number of frames in total
  25593. * @param from defines the initial value
  25594. * @param to defines the final value
  25595. * @param loopMode defines which loop mode you want to use (off by default)
  25596. * @param easingFunction defines the easing function to use (linear by default)
  25597. * @param onAnimationEnd defines the callback to call when animation end
  25598. * @returns the animatable created for this animation
  25599. */
  25600. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25601. /**
  25602. * Create and start an animation on a node and its descendants
  25603. * @param name defines the name of the global animation that will be run on all nodes
  25604. * @param node defines the root node where the animation will take place
  25605. * @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
  25606. * @param targetProperty defines property to animate
  25607. * @param framePerSecond defines the number of frame per second to use
  25608. * @param totalFrame defines the number of frames in total
  25609. * @param from defines the initial value
  25610. * @param to defines the final value
  25611. * @param loopMode defines which loop mode you want to use (off by default)
  25612. * @param easingFunction defines the easing function to use (linear by default)
  25613. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25614. * @returns the list of animatables created for all nodes
  25615. * @example https://www.babylonjs-playground.com/#MH0VLI
  25616. */
  25617. 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[]>;
  25618. /**
  25619. * Creates a new animation, merges it with the existing animations and starts it
  25620. * @param name Name of the animation
  25621. * @param node Node which contains the scene that begins the animations
  25622. * @param targetProperty Specifies which property to animate
  25623. * @param framePerSecond The frames per second of the animation
  25624. * @param totalFrame The total number of frames
  25625. * @param from The frame at the beginning of the animation
  25626. * @param to The frame at the end of the animation
  25627. * @param loopMode Specifies the loop mode of the animation
  25628. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25629. * @param onAnimationEnd Callback to run once the animation is complete
  25630. * @returns Nullable animation
  25631. */
  25632. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25633. /**
  25634. * Transition property of an host to the target Value
  25635. * @param property The property to transition
  25636. * @param targetValue The target Value of the property
  25637. * @param host The object where the property to animate belongs
  25638. * @param scene Scene used to run the animation
  25639. * @param frameRate Framerate (in frame/s) to use
  25640. * @param transition The transition type we want to use
  25641. * @param duration The duration of the animation, in milliseconds
  25642. * @param onAnimationEnd Callback trigger at the end of the animation
  25643. * @returns Nullable animation
  25644. */
  25645. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25646. /**
  25647. * Return the array of runtime animations currently using this animation
  25648. */
  25649. readonly runtimeAnimations: RuntimeAnimation[];
  25650. /**
  25651. * Specifies if any of the runtime animations are currently running
  25652. */
  25653. readonly hasRunningRuntimeAnimations: boolean;
  25654. /**
  25655. * Initializes the animation
  25656. * @param name Name of the animation
  25657. * @param targetProperty Property to animate
  25658. * @param framePerSecond The frames per second of the animation
  25659. * @param dataType The data type of the animation
  25660. * @param loopMode The loop mode of the animation
  25661. * @param enableBlending Specifies if blending should be enabled
  25662. */
  25663. constructor(
  25664. /**Name of the animation */
  25665. name: string,
  25666. /**Property to animate */
  25667. targetProperty: string,
  25668. /**The frames per second of the animation */
  25669. framePerSecond: number,
  25670. /**The data type of the animation */
  25671. dataType: number,
  25672. /**The loop mode of the animation */
  25673. loopMode?: number | undefined,
  25674. /**Specifies if blending should be enabled */
  25675. enableBlending?: boolean | undefined);
  25676. /**
  25677. * Converts the animation to a string
  25678. * @param fullDetails support for multiple levels of logging within scene loading
  25679. * @returns String form of the animation
  25680. */
  25681. toString(fullDetails?: boolean): string;
  25682. /**
  25683. * Add an event to this animation
  25684. * @param event Event to add
  25685. */
  25686. addEvent(event: AnimationEvent): void;
  25687. /**
  25688. * Remove all events found at the given frame
  25689. * @param frame The frame to remove events from
  25690. */
  25691. removeEvents(frame: number): void;
  25692. /**
  25693. * Retrieves all the events from the animation
  25694. * @returns Events from the animation
  25695. */
  25696. getEvents(): AnimationEvent[];
  25697. /**
  25698. * Creates an animation range
  25699. * @param name Name of the animation range
  25700. * @param from Starting frame of the animation range
  25701. * @param to Ending frame of the animation
  25702. */
  25703. createRange(name: string, from: number, to: number): void;
  25704. /**
  25705. * Deletes an animation range by name
  25706. * @param name Name of the animation range to delete
  25707. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25708. */
  25709. deleteRange(name: string, deleteFrames?: boolean): void;
  25710. /**
  25711. * Gets the animation range by name, or null if not defined
  25712. * @param name Name of the animation range
  25713. * @returns Nullable animation range
  25714. */
  25715. getRange(name: string): Nullable<AnimationRange>;
  25716. /**
  25717. * Gets the key frames from the animation
  25718. * @returns The key frames of the animation
  25719. */
  25720. getKeys(): Array<IAnimationKey>;
  25721. /**
  25722. * Gets the highest frame rate of the animation
  25723. * @returns Highest frame rate of the animation
  25724. */
  25725. getHighestFrame(): number;
  25726. /**
  25727. * Gets the easing function of the animation
  25728. * @returns Easing function of the animation
  25729. */
  25730. getEasingFunction(): IEasingFunction;
  25731. /**
  25732. * Sets the easing function of the animation
  25733. * @param easingFunction A custom mathematical formula for animation
  25734. */
  25735. setEasingFunction(easingFunction: EasingFunction): void;
  25736. /**
  25737. * Interpolates a scalar linearly
  25738. * @param startValue Start value of the animation curve
  25739. * @param endValue End value of the animation curve
  25740. * @param gradient Scalar amount to interpolate
  25741. * @returns Interpolated scalar value
  25742. */
  25743. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25744. /**
  25745. * Interpolates a scalar cubically
  25746. * @param startValue Start value of the animation curve
  25747. * @param outTangent End tangent of the animation
  25748. * @param endValue End value of the animation curve
  25749. * @param inTangent Start tangent of the animation curve
  25750. * @param gradient Scalar amount to interpolate
  25751. * @returns Interpolated scalar value
  25752. */
  25753. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25754. /**
  25755. * Interpolates a quaternion using a spherical linear interpolation
  25756. * @param startValue Start value of the animation curve
  25757. * @param endValue End value of the animation curve
  25758. * @param gradient Scalar amount to interpolate
  25759. * @returns Interpolated quaternion value
  25760. */
  25761. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25762. /**
  25763. * Interpolates a quaternion cubically
  25764. * @param startValue Start value of the animation curve
  25765. * @param outTangent End tangent of the animation curve
  25766. * @param endValue End value of the animation curve
  25767. * @param inTangent Start tangent of the animation curve
  25768. * @param gradient Scalar amount to interpolate
  25769. * @returns Interpolated quaternion value
  25770. */
  25771. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25772. /**
  25773. * Interpolates a Vector3 linearl
  25774. * @param startValue Start value of the animation curve
  25775. * @param endValue End value of the animation curve
  25776. * @param gradient Scalar amount to interpolate
  25777. * @returns Interpolated scalar value
  25778. */
  25779. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25780. /**
  25781. * Interpolates a Vector3 cubically
  25782. * @param startValue Start value of the animation curve
  25783. * @param outTangent End tangent of the animation
  25784. * @param endValue End value of the animation curve
  25785. * @param inTangent Start tangent of the animation curve
  25786. * @param gradient Scalar amount to interpolate
  25787. * @returns InterpolatedVector3 value
  25788. */
  25789. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25790. /**
  25791. * Interpolates a Vector2 linearly
  25792. * @param startValue Start value of the animation curve
  25793. * @param endValue End value of the animation curve
  25794. * @param gradient Scalar amount to interpolate
  25795. * @returns Interpolated Vector2 value
  25796. */
  25797. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25798. /**
  25799. * Interpolates a Vector2 cubically
  25800. * @param startValue Start value of the animation curve
  25801. * @param outTangent End tangent of the animation
  25802. * @param endValue End value of the animation curve
  25803. * @param inTangent Start tangent of the animation curve
  25804. * @param gradient Scalar amount to interpolate
  25805. * @returns Interpolated Vector2 value
  25806. */
  25807. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25808. /**
  25809. * Interpolates a size linearly
  25810. * @param startValue Start value of the animation curve
  25811. * @param endValue End value of the animation curve
  25812. * @param gradient Scalar amount to interpolate
  25813. * @returns Interpolated Size value
  25814. */
  25815. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25816. /**
  25817. * Interpolates a Color3 linearly
  25818. * @param startValue Start value of the animation curve
  25819. * @param endValue End value of the animation curve
  25820. * @param gradient Scalar amount to interpolate
  25821. * @returns Interpolated Color3 value
  25822. */
  25823. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25824. /**
  25825. * @hidden Internal use only
  25826. */
  25827. _getKeyValue(value: any): any;
  25828. /**
  25829. * @hidden Internal use only
  25830. */
  25831. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25832. /**
  25833. * Defines the function to use to interpolate matrices
  25834. * @param startValue defines the start matrix
  25835. * @param endValue defines the end matrix
  25836. * @param gradient defines the gradient between both matrices
  25837. * @param result defines an optional target matrix where to store the interpolation
  25838. * @returns the interpolated matrix
  25839. */
  25840. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25841. /**
  25842. * Makes a copy of the animation
  25843. * @returns Cloned animation
  25844. */
  25845. clone(): Animation;
  25846. /**
  25847. * Sets the key frames of the animation
  25848. * @param values The animation key frames to set
  25849. */
  25850. setKeys(values: Array<IAnimationKey>): void;
  25851. /**
  25852. * Serializes the animation to an object
  25853. * @returns Serialized object
  25854. */
  25855. serialize(): any;
  25856. /**
  25857. * Float animation type
  25858. */
  25859. private static _ANIMATIONTYPE_FLOAT;
  25860. /**
  25861. * Vector3 animation type
  25862. */
  25863. private static _ANIMATIONTYPE_VECTOR3;
  25864. /**
  25865. * Quaternion animation type
  25866. */
  25867. private static _ANIMATIONTYPE_QUATERNION;
  25868. /**
  25869. * Matrix animation type
  25870. */
  25871. private static _ANIMATIONTYPE_MATRIX;
  25872. /**
  25873. * Color3 animation type
  25874. */
  25875. private static _ANIMATIONTYPE_COLOR3;
  25876. /**
  25877. * Vector2 animation type
  25878. */
  25879. private static _ANIMATIONTYPE_VECTOR2;
  25880. /**
  25881. * Size animation type
  25882. */
  25883. private static _ANIMATIONTYPE_SIZE;
  25884. /**
  25885. * Relative Loop Mode
  25886. */
  25887. private static _ANIMATIONLOOPMODE_RELATIVE;
  25888. /**
  25889. * Cycle Loop Mode
  25890. */
  25891. private static _ANIMATIONLOOPMODE_CYCLE;
  25892. /**
  25893. * Constant Loop Mode
  25894. */
  25895. private static _ANIMATIONLOOPMODE_CONSTANT;
  25896. /**
  25897. * Get the float animation type
  25898. */
  25899. static readonly ANIMATIONTYPE_FLOAT: number;
  25900. /**
  25901. * Get the Vector3 animation type
  25902. */
  25903. static readonly ANIMATIONTYPE_VECTOR3: number;
  25904. /**
  25905. * Get the Vector2 animation type
  25906. */
  25907. static readonly ANIMATIONTYPE_VECTOR2: number;
  25908. /**
  25909. * Get the Size animation type
  25910. */
  25911. static readonly ANIMATIONTYPE_SIZE: number;
  25912. /**
  25913. * Get the Quaternion animation type
  25914. */
  25915. static readonly ANIMATIONTYPE_QUATERNION: number;
  25916. /**
  25917. * Get the Matrix animation type
  25918. */
  25919. static readonly ANIMATIONTYPE_MATRIX: number;
  25920. /**
  25921. * Get the Color3 animation type
  25922. */
  25923. static readonly ANIMATIONTYPE_COLOR3: number;
  25924. /**
  25925. * Get the Relative Loop Mode
  25926. */
  25927. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25928. /**
  25929. * Get the Cycle Loop Mode
  25930. */
  25931. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25932. /**
  25933. * Get the Constant Loop Mode
  25934. */
  25935. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25936. /** @hidden */
  25937. static _UniversalLerp(left: any, right: any, amount: number): any;
  25938. /**
  25939. * Parses an animation object and creates an animation
  25940. * @param parsedAnimation Parsed animation object
  25941. * @returns Animation object
  25942. */
  25943. static Parse(parsedAnimation: any): Animation;
  25944. /**
  25945. * Appends the serialized animations from the source animations
  25946. * @param source Source containing the animations
  25947. * @param destination Target to store the animations
  25948. */
  25949. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25950. }
  25951. }
  25952. declare module BABYLON {
  25953. /**
  25954. * Base class of all the textures in babylon.
  25955. * It groups all the common properties the materials, post process, lights... might need
  25956. * in order to make a correct use of the texture.
  25957. */
  25958. export class BaseTexture implements IAnimatable {
  25959. /**
  25960. * Default anisotropic filtering level for the application.
  25961. * It is set to 4 as a good tradeoff between perf and quality.
  25962. */
  25963. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25964. /**
  25965. * Gets or sets the unique id of the texture
  25966. */
  25967. uniqueId: number;
  25968. /**
  25969. * Define the name of the texture.
  25970. */
  25971. name: string;
  25972. /**
  25973. * Gets or sets an object used to store user defined information.
  25974. */
  25975. metadata: any;
  25976. /**
  25977. * For internal use only. Please do not use.
  25978. */
  25979. reservedDataStore: any;
  25980. private _hasAlpha;
  25981. /**
  25982. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25983. */
  25984. hasAlpha: boolean;
  25985. /**
  25986. * Defines if the alpha value should be determined via the rgb values.
  25987. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25988. */
  25989. getAlphaFromRGB: boolean;
  25990. /**
  25991. * Intensity or strength of the texture.
  25992. * It is commonly used by materials to fine tune the intensity of the texture
  25993. */
  25994. level: number;
  25995. /**
  25996. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25997. * This is part of the texture as textures usually maps to one uv set.
  25998. */
  25999. coordinatesIndex: number;
  26000. private _coordinatesMode;
  26001. /**
  26002. * How a texture is mapped.
  26003. *
  26004. * | Value | Type | Description |
  26005. * | ----- | ----------------------------------- | ----------- |
  26006. * | 0 | EXPLICIT_MODE | |
  26007. * | 1 | SPHERICAL_MODE | |
  26008. * | 2 | PLANAR_MODE | |
  26009. * | 3 | CUBIC_MODE | |
  26010. * | 4 | PROJECTION_MODE | |
  26011. * | 5 | SKYBOX_MODE | |
  26012. * | 6 | INVCUBIC_MODE | |
  26013. * | 7 | EQUIRECTANGULAR_MODE | |
  26014. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26015. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26016. */
  26017. coordinatesMode: number;
  26018. /**
  26019. * | Value | Type | Description |
  26020. * | ----- | ------------------ | ----------- |
  26021. * | 0 | CLAMP_ADDRESSMODE | |
  26022. * | 1 | WRAP_ADDRESSMODE | |
  26023. * | 2 | MIRROR_ADDRESSMODE | |
  26024. */
  26025. wrapU: number;
  26026. /**
  26027. * | Value | Type | Description |
  26028. * | ----- | ------------------ | ----------- |
  26029. * | 0 | CLAMP_ADDRESSMODE | |
  26030. * | 1 | WRAP_ADDRESSMODE | |
  26031. * | 2 | MIRROR_ADDRESSMODE | |
  26032. */
  26033. wrapV: number;
  26034. /**
  26035. * | Value | Type | Description |
  26036. * | ----- | ------------------ | ----------- |
  26037. * | 0 | CLAMP_ADDRESSMODE | |
  26038. * | 1 | WRAP_ADDRESSMODE | |
  26039. * | 2 | MIRROR_ADDRESSMODE | |
  26040. */
  26041. wrapR: number;
  26042. /**
  26043. * With compliant hardware and browser (supporting anisotropic filtering)
  26044. * this defines the level of anisotropic filtering in the texture.
  26045. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26046. */
  26047. anisotropicFilteringLevel: number;
  26048. /**
  26049. * Define if the texture is a cube texture or if false a 2d texture.
  26050. */
  26051. isCube: boolean;
  26052. /**
  26053. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26054. */
  26055. is3D: boolean;
  26056. /**
  26057. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26058. * HDR texture are usually stored in linear space.
  26059. * This only impacts the PBR and Background materials
  26060. */
  26061. gammaSpace: boolean;
  26062. /**
  26063. * Gets whether or not the texture contains RGBD data.
  26064. */
  26065. readonly isRGBD: boolean;
  26066. /**
  26067. * Is Z inverted in the texture (useful in a cube texture).
  26068. */
  26069. invertZ: boolean;
  26070. /**
  26071. * Are mip maps generated for this texture or not.
  26072. */
  26073. readonly noMipmap: boolean;
  26074. /**
  26075. * @hidden
  26076. */
  26077. lodLevelInAlpha: boolean;
  26078. /**
  26079. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26080. */
  26081. lodGenerationOffset: number;
  26082. /**
  26083. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26084. */
  26085. lodGenerationScale: number;
  26086. /**
  26087. * Define if the texture is a render target.
  26088. */
  26089. isRenderTarget: boolean;
  26090. /**
  26091. * Define the unique id of the texture in the scene.
  26092. */
  26093. readonly uid: string;
  26094. /**
  26095. * Return a string representation of the texture.
  26096. * @returns the texture as a string
  26097. */
  26098. toString(): string;
  26099. /**
  26100. * Get the class name of the texture.
  26101. * @returns "BaseTexture"
  26102. */
  26103. getClassName(): string;
  26104. /**
  26105. * Define the list of animation attached to the texture.
  26106. */
  26107. animations: Animation[];
  26108. /**
  26109. * An event triggered when the texture is disposed.
  26110. */
  26111. onDisposeObservable: Observable<BaseTexture>;
  26112. private _onDisposeObserver;
  26113. /**
  26114. * Callback triggered when the texture has been disposed.
  26115. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26116. */
  26117. onDispose: () => void;
  26118. /**
  26119. * Define the current state of the loading sequence when in delayed load mode.
  26120. */
  26121. delayLoadState: number;
  26122. private _scene;
  26123. /** @hidden */
  26124. _texture: Nullable<InternalTexture>;
  26125. private _uid;
  26126. /**
  26127. * Define if the texture is preventinga material to render or not.
  26128. * If not and the texture is not ready, the engine will use a default black texture instead.
  26129. */
  26130. readonly isBlocking: boolean;
  26131. /**
  26132. * Instantiates a new BaseTexture.
  26133. * Base class of all the textures in babylon.
  26134. * It groups all the common properties the materials, post process, lights... might need
  26135. * in order to make a correct use of the texture.
  26136. * @param scene Define the scene the texture blongs to
  26137. */
  26138. constructor(scene: Nullable<Scene>);
  26139. /**
  26140. * Get the scene the texture belongs to.
  26141. * @returns the scene or null if undefined
  26142. */
  26143. getScene(): Nullable<Scene>;
  26144. /**
  26145. * Get the texture transform matrix used to offset tile the texture for istance.
  26146. * @returns the transformation matrix
  26147. */
  26148. getTextureMatrix(): Matrix;
  26149. /**
  26150. * Get the texture reflection matrix used to rotate/transform the reflection.
  26151. * @returns the reflection matrix
  26152. */
  26153. getReflectionTextureMatrix(): Matrix;
  26154. /**
  26155. * Get the underlying lower level texture from Babylon.
  26156. * @returns the insternal texture
  26157. */
  26158. getInternalTexture(): Nullable<InternalTexture>;
  26159. /**
  26160. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26161. * @returns true if ready or not blocking
  26162. */
  26163. isReadyOrNotBlocking(): boolean;
  26164. /**
  26165. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26166. * @returns true if fully ready
  26167. */
  26168. isReady(): boolean;
  26169. private _cachedSize;
  26170. /**
  26171. * Get the size of the texture.
  26172. * @returns the texture size.
  26173. */
  26174. getSize(): ISize;
  26175. /**
  26176. * Get the base size of the texture.
  26177. * It can be different from the size if the texture has been resized for POT for instance
  26178. * @returns the base size
  26179. */
  26180. getBaseSize(): ISize;
  26181. /**
  26182. * Update the sampling mode of the texture.
  26183. * Default is Trilinear mode.
  26184. *
  26185. * | Value | Type | Description |
  26186. * | ----- | ------------------ | ----------- |
  26187. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26188. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26189. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26190. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26191. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26192. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26193. * | 7 | NEAREST_LINEAR | |
  26194. * | 8 | NEAREST_NEAREST | |
  26195. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26196. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26197. * | 11 | LINEAR_LINEAR | |
  26198. * | 12 | LINEAR_NEAREST | |
  26199. *
  26200. * > _mag_: magnification filter (close to the viewer)
  26201. * > _min_: minification filter (far from the viewer)
  26202. * > _mip_: filter used between mip map levels
  26203. *@param samplingMode Define the new sampling mode of the texture
  26204. */
  26205. updateSamplingMode(samplingMode: number): void;
  26206. /**
  26207. * Scales the texture if is `canRescale()`
  26208. * @param ratio the resize factor we want to use to rescale
  26209. */
  26210. scale(ratio: number): void;
  26211. /**
  26212. * Get if the texture can rescale.
  26213. */
  26214. readonly canRescale: boolean;
  26215. /** @hidden */
  26216. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26217. /** @hidden */
  26218. _rebuild(): void;
  26219. /**
  26220. * Triggers the load sequence in delayed load mode.
  26221. */
  26222. delayLoad(): void;
  26223. /**
  26224. * Clones the texture.
  26225. * @returns the cloned texture
  26226. */
  26227. clone(): Nullable<BaseTexture>;
  26228. /**
  26229. * Get the texture underlying type (INT, FLOAT...)
  26230. */
  26231. readonly textureType: number;
  26232. /**
  26233. * Get the texture underlying format (RGB, RGBA...)
  26234. */
  26235. readonly textureFormat: number;
  26236. /**
  26237. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26238. * This will returns an RGBA array buffer containing either in values (0-255) or
  26239. * float values (0-1) depending of the underlying buffer type.
  26240. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26241. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26242. * @param buffer defines a user defined buffer to fill with data (can be null)
  26243. * @returns The Array buffer containing the pixels data.
  26244. */
  26245. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26246. /**
  26247. * Release and destroy the underlying lower level texture aka internalTexture.
  26248. */
  26249. releaseInternalTexture(): void;
  26250. /**
  26251. * Get the polynomial representation of the texture data.
  26252. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26253. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26254. */
  26255. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26256. /** @hidden */
  26257. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26258. /** @hidden */
  26259. readonly _lodTextureMid: Nullable<BaseTexture>;
  26260. /** @hidden */
  26261. readonly _lodTextureLow: Nullable<BaseTexture>;
  26262. /**
  26263. * Dispose the texture and release its associated resources.
  26264. */
  26265. dispose(): void;
  26266. /**
  26267. * Serialize the texture into a JSON representation that can be parsed later on.
  26268. * @returns the JSON representation of the texture
  26269. */
  26270. serialize(): any;
  26271. /**
  26272. * Helper function to be called back once a list of texture contains only ready textures.
  26273. * @param textures Define the list of textures to wait for
  26274. * @param callback Define the callback triggered once the entire list will be ready
  26275. */
  26276. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26277. }
  26278. }
  26279. declare module BABYLON {
  26280. /**
  26281. * Uniform buffer objects.
  26282. *
  26283. * Handles blocks of uniform on the GPU.
  26284. *
  26285. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26286. *
  26287. * For more information, please refer to :
  26288. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26289. */
  26290. export class UniformBuffer {
  26291. private _engine;
  26292. private _buffer;
  26293. private _data;
  26294. private _bufferData;
  26295. private _dynamic?;
  26296. private _uniformLocations;
  26297. private _uniformSizes;
  26298. private _uniformLocationPointer;
  26299. private _needSync;
  26300. private _noUBO;
  26301. private _currentEffect;
  26302. private static _MAX_UNIFORM_SIZE;
  26303. private static _tempBuffer;
  26304. /**
  26305. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26306. * This is dynamic to allow compat with webgl 1 and 2.
  26307. * You will need to pass the name of the uniform as well as the value.
  26308. */
  26309. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26310. /**
  26311. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26312. * This is dynamic to allow compat with webgl 1 and 2.
  26313. * You will need to pass the name of the uniform as well as the value.
  26314. */
  26315. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26316. /**
  26317. * Lambda to Update a single float in a uniform buffer.
  26318. * This is dynamic to allow compat with webgl 1 and 2.
  26319. * You will need to pass the name of the uniform as well as the value.
  26320. */
  26321. updateFloat: (name: string, x: number) => void;
  26322. /**
  26323. * Lambda to Update a vec2 of float in a uniform buffer.
  26324. * This is dynamic to allow compat with webgl 1 and 2.
  26325. * You will need to pass the name of the uniform as well as the value.
  26326. */
  26327. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26328. /**
  26329. * Lambda to Update a vec3 of float in a uniform buffer.
  26330. * This is dynamic to allow compat with webgl 1 and 2.
  26331. * You will need to pass the name of the uniform as well as the value.
  26332. */
  26333. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26334. /**
  26335. * Lambda to Update a vec4 of float in a uniform buffer.
  26336. * This is dynamic to allow compat with webgl 1 and 2.
  26337. * You will need to pass the name of the uniform as well as the value.
  26338. */
  26339. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26340. /**
  26341. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26342. * This is dynamic to allow compat with webgl 1 and 2.
  26343. * You will need to pass the name of the uniform as well as the value.
  26344. */
  26345. updateMatrix: (name: string, mat: Matrix) => void;
  26346. /**
  26347. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26348. * This is dynamic to allow compat with webgl 1 and 2.
  26349. * You will need to pass the name of the uniform as well as the value.
  26350. */
  26351. updateVector3: (name: string, vector: Vector3) => void;
  26352. /**
  26353. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26354. * This is dynamic to allow compat with webgl 1 and 2.
  26355. * You will need to pass the name of the uniform as well as the value.
  26356. */
  26357. updateVector4: (name: string, vector: Vector4) => void;
  26358. /**
  26359. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26360. * This is dynamic to allow compat with webgl 1 and 2.
  26361. * You will need to pass the name of the uniform as well as the value.
  26362. */
  26363. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26364. /**
  26365. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26366. * This is dynamic to allow compat with webgl 1 and 2.
  26367. * You will need to pass the name of the uniform as well as the value.
  26368. */
  26369. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26370. /**
  26371. * Instantiates a new Uniform buffer objects.
  26372. *
  26373. * Handles blocks of uniform on the GPU.
  26374. *
  26375. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26376. *
  26377. * For more information, please refer to :
  26378. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26379. * @param engine Define the engine the buffer is associated with
  26380. * @param data Define the data contained in the buffer
  26381. * @param dynamic Define if the buffer is updatable
  26382. */
  26383. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26384. /**
  26385. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26386. * or just falling back on setUniformXXX calls.
  26387. */
  26388. readonly useUbo: boolean;
  26389. /**
  26390. * Indicates if the WebGL underlying uniform buffer is in sync
  26391. * with the javascript cache data.
  26392. */
  26393. readonly isSync: boolean;
  26394. /**
  26395. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26396. * Also, a dynamic UniformBuffer will disable cache verification and always
  26397. * update the underlying WebGL uniform buffer to the GPU.
  26398. * @returns if Dynamic, otherwise false
  26399. */
  26400. isDynamic(): boolean;
  26401. /**
  26402. * The data cache on JS side.
  26403. * @returns the underlying data as a float array
  26404. */
  26405. getData(): Float32Array;
  26406. /**
  26407. * The underlying WebGL Uniform buffer.
  26408. * @returns the webgl buffer
  26409. */
  26410. getBuffer(): Nullable<DataBuffer>;
  26411. /**
  26412. * std140 layout specifies how to align data within an UBO structure.
  26413. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26414. * for specs.
  26415. */
  26416. private _fillAlignment;
  26417. /**
  26418. * Adds an uniform in the buffer.
  26419. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26420. * for the layout to be correct !
  26421. * @param name Name of the uniform, as used in the uniform block in the shader.
  26422. * @param size Data size, or data directly.
  26423. */
  26424. addUniform(name: string, size: number | number[]): void;
  26425. /**
  26426. * Adds a Matrix 4x4 to the uniform buffer.
  26427. * @param name Name of the uniform, as used in the uniform block in the shader.
  26428. * @param mat A 4x4 matrix.
  26429. */
  26430. addMatrix(name: string, mat: Matrix): void;
  26431. /**
  26432. * Adds a vec2 to the uniform buffer.
  26433. * @param name Name of the uniform, as used in the uniform block in the shader.
  26434. * @param x Define the x component value of the vec2
  26435. * @param y Define the y component value of the vec2
  26436. */
  26437. addFloat2(name: string, x: number, y: number): void;
  26438. /**
  26439. * Adds a vec3 to the uniform buffer.
  26440. * @param name Name of the uniform, as used in the uniform block in the shader.
  26441. * @param x Define the x component value of the vec3
  26442. * @param y Define the y component value of the vec3
  26443. * @param z Define the z component value of the vec3
  26444. */
  26445. addFloat3(name: string, x: number, y: number, z: number): void;
  26446. /**
  26447. * Adds a vec3 to the uniform buffer.
  26448. * @param name Name of the uniform, as used in the uniform block in the shader.
  26449. * @param color Define the vec3 from a Color
  26450. */
  26451. addColor3(name: string, color: Color3): void;
  26452. /**
  26453. * Adds a vec4 to the uniform buffer.
  26454. * @param name Name of the uniform, as used in the uniform block in the shader.
  26455. * @param color Define the rgb components from a Color
  26456. * @param alpha Define the a component of the vec4
  26457. */
  26458. addColor4(name: string, color: Color3, alpha: number): void;
  26459. /**
  26460. * Adds a vec3 to the uniform buffer.
  26461. * @param name Name of the uniform, as used in the uniform block in the shader.
  26462. * @param vector Define the vec3 components from a Vector
  26463. */
  26464. addVector3(name: string, vector: Vector3): void;
  26465. /**
  26466. * Adds a Matrix 3x3 to the uniform buffer.
  26467. * @param name Name of the uniform, as used in the uniform block in the shader.
  26468. */
  26469. addMatrix3x3(name: string): void;
  26470. /**
  26471. * Adds a Matrix 2x2 to the uniform buffer.
  26472. * @param name Name of the uniform, as used in the uniform block in the shader.
  26473. */
  26474. addMatrix2x2(name: string): void;
  26475. /**
  26476. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26477. */
  26478. create(): void;
  26479. /** @hidden */
  26480. _rebuild(): void;
  26481. /**
  26482. * Updates the WebGL Uniform Buffer on the GPU.
  26483. * If the `dynamic` flag is set to true, no cache comparison is done.
  26484. * Otherwise, the buffer will be updated only if the cache differs.
  26485. */
  26486. update(): void;
  26487. /**
  26488. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26489. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26490. * @param data Define the flattened data
  26491. * @param size Define the size of the data.
  26492. */
  26493. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26494. private _updateMatrix3x3ForUniform;
  26495. private _updateMatrix3x3ForEffect;
  26496. private _updateMatrix2x2ForEffect;
  26497. private _updateMatrix2x2ForUniform;
  26498. private _updateFloatForEffect;
  26499. private _updateFloatForUniform;
  26500. private _updateFloat2ForEffect;
  26501. private _updateFloat2ForUniform;
  26502. private _updateFloat3ForEffect;
  26503. private _updateFloat3ForUniform;
  26504. private _updateFloat4ForEffect;
  26505. private _updateFloat4ForUniform;
  26506. private _updateMatrixForEffect;
  26507. private _updateMatrixForUniform;
  26508. private _updateVector3ForEffect;
  26509. private _updateVector3ForUniform;
  26510. private _updateVector4ForEffect;
  26511. private _updateVector4ForUniform;
  26512. private _updateColor3ForEffect;
  26513. private _updateColor3ForUniform;
  26514. private _updateColor4ForEffect;
  26515. private _updateColor4ForUniform;
  26516. /**
  26517. * Sets a sampler uniform on the effect.
  26518. * @param name Define the name of the sampler.
  26519. * @param texture Define the texture to set in the sampler
  26520. */
  26521. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26522. /**
  26523. * Directly updates the value of the uniform in the cache AND on the GPU.
  26524. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26525. * @param data Define the flattened data
  26526. */
  26527. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26528. /**
  26529. * Binds this uniform buffer to an effect.
  26530. * @param effect Define the effect to bind the buffer to
  26531. * @param name Name of the uniform block in the shader.
  26532. */
  26533. bindToEffect(effect: Effect, name: string): void;
  26534. /**
  26535. * Disposes the uniform buffer.
  26536. */
  26537. dispose(): void;
  26538. }
  26539. }
  26540. declare module BABYLON {
  26541. /**
  26542. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26544. */
  26545. export class Analyser {
  26546. /**
  26547. * Gets or sets the smoothing
  26548. * @ignorenaming
  26549. */
  26550. SMOOTHING: number;
  26551. /**
  26552. * Gets or sets the FFT table size
  26553. * @ignorenaming
  26554. */
  26555. FFT_SIZE: number;
  26556. /**
  26557. * Gets or sets the bar graph amplitude
  26558. * @ignorenaming
  26559. */
  26560. BARGRAPHAMPLITUDE: number;
  26561. /**
  26562. * Gets or sets the position of the debug canvas
  26563. * @ignorenaming
  26564. */
  26565. DEBUGCANVASPOS: {
  26566. x: number;
  26567. y: number;
  26568. };
  26569. /**
  26570. * Gets or sets the debug canvas size
  26571. * @ignorenaming
  26572. */
  26573. DEBUGCANVASSIZE: {
  26574. width: number;
  26575. height: number;
  26576. };
  26577. private _byteFreqs;
  26578. private _byteTime;
  26579. private _floatFreqs;
  26580. private _webAudioAnalyser;
  26581. private _debugCanvas;
  26582. private _debugCanvasContext;
  26583. private _scene;
  26584. private _registerFunc;
  26585. private _audioEngine;
  26586. /**
  26587. * Creates a new analyser
  26588. * @param scene defines hosting scene
  26589. */
  26590. constructor(scene: Scene);
  26591. /**
  26592. * Get the number of data values you will have to play with for the visualization
  26593. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26594. * @returns a number
  26595. */
  26596. getFrequencyBinCount(): number;
  26597. /**
  26598. * Gets the current frequency data as a byte array
  26599. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26600. * @returns a Uint8Array
  26601. */
  26602. getByteFrequencyData(): Uint8Array;
  26603. /**
  26604. * Gets the current waveform as a byte array
  26605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26606. * @returns a Uint8Array
  26607. */
  26608. getByteTimeDomainData(): Uint8Array;
  26609. /**
  26610. * Gets the current frequency data as a float array
  26611. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26612. * @returns a Float32Array
  26613. */
  26614. getFloatFrequencyData(): Float32Array;
  26615. /**
  26616. * Renders the debug canvas
  26617. */
  26618. drawDebugCanvas(): void;
  26619. /**
  26620. * Stops rendering the debug canvas and removes it
  26621. */
  26622. stopDebugCanvas(): void;
  26623. /**
  26624. * Connects two audio nodes
  26625. * @param inputAudioNode defines first node to connect
  26626. * @param outputAudioNode defines second node to connect
  26627. */
  26628. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26629. /**
  26630. * Releases all associated resources
  26631. */
  26632. dispose(): void;
  26633. }
  26634. }
  26635. declare module BABYLON {
  26636. /**
  26637. * This represents an audio engine and it is responsible
  26638. * to play, synchronize and analyse sounds throughout the application.
  26639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26640. */
  26641. export interface IAudioEngine extends IDisposable {
  26642. /**
  26643. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26644. */
  26645. readonly canUseWebAudio: boolean;
  26646. /**
  26647. * Gets the current AudioContext if available.
  26648. */
  26649. readonly audioContext: Nullable<AudioContext>;
  26650. /**
  26651. * The master gain node defines the global audio volume of your audio engine.
  26652. */
  26653. readonly masterGain: GainNode;
  26654. /**
  26655. * Gets whether or not mp3 are supported by your browser.
  26656. */
  26657. readonly isMP3supported: boolean;
  26658. /**
  26659. * Gets whether or not ogg are supported by your browser.
  26660. */
  26661. readonly isOGGsupported: boolean;
  26662. /**
  26663. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26664. * @ignoreNaming
  26665. */
  26666. WarnedWebAudioUnsupported: boolean;
  26667. /**
  26668. * Defines if the audio engine relies on a custom unlocked button.
  26669. * In this case, the embedded button will not be displayed.
  26670. */
  26671. useCustomUnlockedButton: boolean;
  26672. /**
  26673. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26674. */
  26675. readonly unlocked: boolean;
  26676. /**
  26677. * Event raised when audio has been unlocked on the browser.
  26678. */
  26679. onAudioUnlockedObservable: Observable<AudioEngine>;
  26680. /**
  26681. * Event raised when audio has been locked on the browser.
  26682. */
  26683. onAudioLockedObservable: Observable<AudioEngine>;
  26684. /**
  26685. * Flags the audio engine in Locked state.
  26686. * This happens due to new browser policies preventing audio to autoplay.
  26687. */
  26688. lock(): void;
  26689. /**
  26690. * Unlocks the audio engine once a user action has been done on the dom.
  26691. * This is helpful to resume play once browser policies have been satisfied.
  26692. */
  26693. unlock(): void;
  26694. }
  26695. /**
  26696. * This represents the default audio engine used in babylon.
  26697. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26699. */
  26700. export class AudioEngine implements IAudioEngine {
  26701. private _audioContext;
  26702. private _audioContextInitialized;
  26703. private _muteButton;
  26704. private _hostElement;
  26705. /**
  26706. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26707. */
  26708. canUseWebAudio: boolean;
  26709. /**
  26710. * The master gain node defines the global audio volume of your audio engine.
  26711. */
  26712. masterGain: GainNode;
  26713. /**
  26714. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26715. * @ignoreNaming
  26716. */
  26717. WarnedWebAudioUnsupported: boolean;
  26718. /**
  26719. * Gets whether or not mp3 are supported by your browser.
  26720. */
  26721. isMP3supported: boolean;
  26722. /**
  26723. * Gets whether or not ogg are supported by your browser.
  26724. */
  26725. isOGGsupported: boolean;
  26726. /**
  26727. * Gets whether audio has been unlocked on the device.
  26728. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26729. * a user interaction has happened.
  26730. */
  26731. unlocked: boolean;
  26732. /**
  26733. * Defines if the audio engine relies on a custom unlocked button.
  26734. * In this case, the embedded button will not be displayed.
  26735. */
  26736. useCustomUnlockedButton: boolean;
  26737. /**
  26738. * Event raised when audio has been unlocked on the browser.
  26739. */
  26740. onAudioUnlockedObservable: Observable<AudioEngine>;
  26741. /**
  26742. * Event raised when audio has been locked on the browser.
  26743. */
  26744. onAudioLockedObservable: Observable<AudioEngine>;
  26745. /**
  26746. * Gets the current AudioContext if available.
  26747. */
  26748. readonly audioContext: Nullable<AudioContext>;
  26749. private _connectedAnalyser;
  26750. /**
  26751. * Instantiates a new audio engine.
  26752. *
  26753. * There should be only one per page as some browsers restrict the number
  26754. * of audio contexts you can create.
  26755. * @param hostElement defines the host element where to display the mute icon if necessary
  26756. */
  26757. constructor(hostElement?: Nullable<HTMLElement>);
  26758. /**
  26759. * Flags the audio engine in Locked state.
  26760. * This happens due to new browser policies preventing audio to autoplay.
  26761. */
  26762. lock(): void;
  26763. /**
  26764. * Unlocks the audio engine once a user action has been done on the dom.
  26765. * This is helpful to resume play once browser policies have been satisfied.
  26766. */
  26767. unlock(): void;
  26768. private _resumeAudioContext;
  26769. private _initializeAudioContext;
  26770. private _tryToRun;
  26771. private _triggerRunningState;
  26772. private _triggerSuspendedState;
  26773. private _displayMuteButton;
  26774. private _moveButtonToTopLeft;
  26775. private _onResize;
  26776. private _hideMuteButton;
  26777. /**
  26778. * Destroy and release the resources associated with the audio ccontext.
  26779. */
  26780. dispose(): void;
  26781. /**
  26782. * Gets the global volume sets on the master gain.
  26783. * @returns the global volume if set or -1 otherwise
  26784. */
  26785. getGlobalVolume(): number;
  26786. /**
  26787. * Sets the global volume of your experience (sets on the master gain).
  26788. * @param newVolume Defines the new global volume of the application
  26789. */
  26790. setGlobalVolume(newVolume: number): void;
  26791. /**
  26792. * Connect the audio engine to an audio analyser allowing some amazing
  26793. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26795. * @param analyser The analyser to connect to the engine
  26796. */
  26797. connectToAnalyser(analyser: Analyser): void;
  26798. }
  26799. }
  26800. declare module BABYLON {
  26801. /**
  26802. * Interface used to present a loading screen while loading a scene
  26803. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26804. */
  26805. export interface ILoadingScreen {
  26806. /**
  26807. * Function called to display the loading screen
  26808. */
  26809. displayLoadingUI: () => void;
  26810. /**
  26811. * Function called to hide the loading screen
  26812. */
  26813. hideLoadingUI: () => void;
  26814. /**
  26815. * Gets or sets the color to use for the background
  26816. */
  26817. loadingUIBackgroundColor: string;
  26818. /**
  26819. * Gets or sets the text to display while loading
  26820. */
  26821. loadingUIText: string;
  26822. }
  26823. /**
  26824. * Class used for the default loading screen
  26825. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26826. */
  26827. export class DefaultLoadingScreen implements ILoadingScreen {
  26828. private _renderingCanvas;
  26829. private _loadingText;
  26830. private _loadingDivBackgroundColor;
  26831. private _loadingDiv;
  26832. private _loadingTextDiv;
  26833. /**
  26834. * Creates a new default loading screen
  26835. * @param _renderingCanvas defines the canvas used to render the scene
  26836. * @param _loadingText defines the default text to display
  26837. * @param _loadingDivBackgroundColor defines the default background color
  26838. */
  26839. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26840. /**
  26841. * Function called to display the loading screen
  26842. */
  26843. displayLoadingUI(): void;
  26844. /**
  26845. * Function called to hide the loading screen
  26846. */
  26847. hideLoadingUI(): void;
  26848. /**
  26849. * Gets or sets the text to display while loading
  26850. */
  26851. loadingUIText: string;
  26852. /**
  26853. * Gets or sets the color to use for the background
  26854. */
  26855. loadingUIBackgroundColor: string;
  26856. private _resizeLoadingUI;
  26857. }
  26858. }
  26859. declare module BABYLON {
  26860. /** @hidden */
  26861. export class WebGLPipelineContext implements IPipelineContext {
  26862. engine: Engine;
  26863. program: Nullable<WebGLProgram>;
  26864. context?: WebGLRenderingContext;
  26865. vertexShader?: WebGLShader;
  26866. fragmentShader?: WebGLShader;
  26867. isParallelCompiled: boolean;
  26868. onCompiled?: () => void;
  26869. transformFeedback?: WebGLTransformFeedback | null;
  26870. readonly isAsync: boolean;
  26871. readonly isReady: boolean;
  26872. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26873. }
  26874. }
  26875. declare module BABYLON {
  26876. /** @hidden */
  26877. export class WebGLDataBuffer extends DataBuffer {
  26878. private _buffer;
  26879. constructor(resource: WebGLBuffer);
  26880. readonly underlyingResource: any;
  26881. }
  26882. }
  26883. declare module BABYLON {
  26884. /**
  26885. * Settings for finer control over video usage
  26886. */
  26887. export interface VideoTextureSettings {
  26888. /**
  26889. * Applies `autoplay` to video, if specified
  26890. */
  26891. autoPlay?: boolean;
  26892. /**
  26893. * Applies `loop` to video, if specified
  26894. */
  26895. loop?: boolean;
  26896. /**
  26897. * Automatically updates internal texture from video at every frame in the render loop
  26898. */
  26899. autoUpdateTexture: boolean;
  26900. /**
  26901. * Image src displayed during the video loading or until the user interacts with the video.
  26902. */
  26903. poster?: string;
  26904. }
  26905. /**
  26906. * If you want to display a video in your scene, this is the special texture for that.
  26907. * This special texture works similar to other textures, with the exception of a few parameters.
  26908. * @see https://doc.babylonjs.com/how_to/video_texture
  26909. */
  26910. export class VideoTexture extends Texture {
  26911. /**
  26912. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26913. */
  26914. readonly autoUpdateTexture: boolean;
  26915. /**
  26916. * The video instance used by the texture internally
  26917. */
  26918. readonly video: HTMLVideoElement;
  26919. private _onUserActionRequestedObservable;
  26920. /**
  26921. * Event triggerd when a dom action is required by the user to play the video.
  26922. * This happens due to recent changes in browser policies preventing video to auto start.
  26923. */
  26924. readonly onUserActionRequestedObservable: Observable<Texture>;
  26925. private _generateMipMaps;
  26926. private _engine;
  26927. private _stillImageCaptured;
  26928. private _displayingPosterTexture;
  26929. private _settings;
  26930. private _createInternalTextureOnEvent;
  26931. /**
  26932. * Creates a video texture.
  26933. * If you want to display a video in your scene, this is the special texture for that.
  26934. * This special texture works similar to other textures, with the exception of a few parameters.
  26935. * @see https://doc.babylonjs.com/how_to/video_texture
  26936. * @param name optional name, will detect from video source, if not defined
  26937. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26938. * @param scene is obviously the current scene.
  26939. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26940. * @param invertY is false by default but can be used to invert video on Y axis
  26941. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26942. * @param settings allows finer control over video usage
  26943. */
  26944. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26945. private _getName;
  26946. private _getVideo;
  26947. private _createInternalTexture;
  26948. private reset;
  26949. /**
  26950. * @hidden Internal method to initiate `update`.
  26951. */
  26952. _rebuild(): void;
  26953. /**
  26954. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26955. */
  26956. update(): void;
  26957. /**
  26958. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26959. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26960. */
  26961. updateTexture(isVisible: boolean): void;
  26962. protected _updateInternalTexture: () => void;
  26963. /**
  26964. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26965. * @param url New url.
  26966. */
  26967. updateURL(url: string): void;
  26968. /**
  26969. * Dispose the texture and release its associated resources.
  26970. */
  26971. dispose(): void;
  26972. /**
  26973. * Creates a video texture straight from a stream.
  26974. * @param scene Define the scene the texture should be created in
  26975. * @param stream Define the stream the texture should be created from
  26976. * @returns The created video texture as a promise
  26977. */
  26978. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26979. /**
  26980. * Creates a video texture straight from your WebCam video feed.
  26981. * @param scene Define the scene the texture should be created in
  26982. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26983. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26984. * @returns The created video texture as a promise
  26985. */
  26986. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26987. minWidth: number;
  26988. maxWidth: number;
  26989. minHeight: number;
  26990. maxHeight: number;
  26991. deviceId: string;
  26992. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26993. /**
  26994. * Creates a video texture straight from your WebCam video feed.
  26995. * @param scene Define the scene the texture should be created in
  26996. * @param onReady Define a callback to triggered once the texture will be ready
  26997. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26998. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26999. */
  27000. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27001. minWidth: number;
  27002. maxWidth: number;
  27003. minHeight: number;
  27004. maxHeight: number;
  27005. deviceId: string;
  27006. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27007. }
  27008. }
  27009. declare module BABYLON {
  27010. /**
  27011. * Interface for attribute information associated with buffer instanciation
  27012. */
  27013. export class InstancingAttributeInfo {
  27014. /**
  27015. * Index/offset of the attribute in the vertex shader
  27016. */
  27017. index: number;
  27018. /**
  27019. * size of the attribute, 1, 2, 3 or 4
  27020. */
  27021. attributeSize: number;
  27022. /**
  27023. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27024. * default is FLOAT
  27025. */
  27026. attribyteType: number;
  27027. /**
  27028. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27029. */
  27030. normalized: boolean;
  27031. /**
  27032. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27033. */
  27034. offset: number;
  27035. /**
  27036. * Name of the GLSL attribute, for debugging purpose only
  27037. */
  27038. attributeName: string;
  27039. }
  27040. /**
  27041. * Define options used to create a depth texture
  27042. */
  27043. export class DepthTextureCreationOptions {
  27044. /** Specifies whether or not a stencil should be allocated in the texture */
  27045. generateStencil?: boolean;
  27046. /** Specifies whether or not bilinear filtering is enable on the texture */
  27047. bilinearFiltering?: boolean;
  27048. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27049. comparisonFunction?: number;
  27050. /** Specifies if the created texture is a cube texture */
  27051. isCube?: boolean;
  27052. }
  27053. /**
  27054. * Class used to describe the capabilities of the engine relatively to the current browser
  27055. */
  27056. export class EngineCapabilities {
  27057. /** Maximum textures units per fragment shader */
  27058. maxTexturesImageUnits: number;
  27059. /** Maximum texture units per vertex shader */
  27060. maxVertexTextureImageUnits: number;
  27061. /** Maximum textures units in the entire pipeline */
  27062. maxCombinedTexturesImageUnits: number;
  27063. /** Maximum texture size */
  27064. maxTextureSize: number;
  27065. /** Maximum cube texture size */
  27066. maxCubemapTextureSize: number;
  27067. /** Maximum render texture size */
  27068. maxRenderTextureSize: number;
  27069. /** Maximum number of vertex attributes */
  27070. maxVertexAttribs: number;
  27071. /** Maximum number of varyings */
  27072. maxVaryingVectors: number;
  27073. /** Maximum number of uniforms per vertex shader */
  27074. maxVertexUniformVectors: number;
  27075. /** Maximum number of uniforms per fragment shader */
  27076. maxFragmentUniformVectors: number;
  27077. /** Defines if standard derivates (dx/dy) are supported */
  27078. standardDerivatives: boolean;
  27079. /** Defines if s3tc texture compression is supported */
  27080. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27081. /** Defines if pvrtc texture compression is supported */
  27082. pvrtc: any;
  27083. /** Defines if etc1 texture compression is supported */
  27084. etc1: any;
  27085. /** Defines if etc2 texture compression is supported */
  27086. etc2: any;
  27087. /** Defines if astc texture compression is supported */
  27088. astc: any;
  27089. /** Defines if float textures are supported */
  27090. textureFloat: boolean;
  27091. /** Defines if vertex array objects are supported */
  27092. vertexArrayObject: boolean;
  27093. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27094. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27095. /** Gets the maximum level of anisotropy supported */
  27096. maxAnisotropy: number;
  27097. /** Defines if instancing is supported */
  27098. instancedArrays: boolean;
  27099. /** Defines if 32 bits indices are supported */
  27100. uintIndices: boolean;
  27101. /** Defines if high precision shaders are supported */
  27102. highPrecisionShaderSupported: boolean;
  27103. /** Defines if depth reading in the fragment shader is supported */
  27104. fragmentDepthSupported: boolean;
  27105. /** Defines if float texture linear filtering is supported*/
  27106. textureFloatLinearFiltering: boolean;
  27107. /** Defines if rendering to float textures is supported */
  27108. textureFloatRender: boolean;
  27109. /** Defines if half float textures are supported*/
  27110. textureHalfFloat: boolean;
  27111. /** Defines if half float texture linear filtering is supported*/
  27112. textureHalfFloatLinearFiltering: boolean;
  27113. /** Defines if rendering to half float textures is supported */
  27114. textureHalfFloatRender: boolean;
  27115. /** Defines if textureLOD shader command is supported */
  27116. textureLOD: boolean;
  27117. /** Defines if draw buffers extension is supported */
  27118. drawBuffersExtension: boolean;
  27119. /** Defines if depth textures are supported */
  27120. depthTextureExtension: boolean;
  27121. /** Defines if float color buffer are supported */
  27122. colorBufferFloat: boolean;
  27123. /** Gets disjoint timer query extension (null if not supported) */
  27124. timerQuery: EXT_disjoint_timer_query;
  27125. /** Defines if timestamp can be used with timer query */
  27126. canUseTimestampForTimerQuery: boolean;
  27127. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27128. multiview: any;
  27129. /** Function used to let the system compiles shaders in background */
  27130. parallelShaderCompile: {
  27131. COMPLETION_STATUS_KHR: number;
  27132. };
  27133. }
  27134. /** Interface defining initialization parameters for Engine class */
  27135. export interface EngineOptions extends WebGLContextAttributes {
  27136. /**
  27137. * Defines if the engine should no exceed a specified device ratio
  27138. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27139. */
  27140. limitDeviceRatio?: number;
  27141. /**
  27142. * Defines if webvr should be enabled automatically
  27143. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27144. */
  27145. autoEnableWebVR?: boolean;
  27146. /**
  27147. * Defines if webgl2 should be turned off even if supported
  27148. * @see http://doc.babylonjs.com/features/webgl2
  27149. */
  27150. disableWebGL2Support?: boolean;
  27151. /**
  27152. * Defines if webaudio should be initialized as well
  27153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27154. */
  27155. audioEngine?: boolean;
  27156. /**
  27157. * Defines if animations should run using a deterministic lock step
  27158. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27159. */
  27160. deterministicLockstep?: boolean;
  27161. /** Defines the maximum steps to use with deterministic lock step mode */
  27162. lockstepMaxSteps?: number;
  27163. /**
  27164. * Defines that engine should ignore context lost events
  27165. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27166. */
  27167. doNotHandleContextLost?: boolean;
  27168. /**
  27169. * Defines that engine should ignore modifying touch action attribute and style
  27170. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27171. */
  27172. doNotHandleTouchAction?: boolean;
  27173. /**
  27174. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27175. */
  27176. useHighPrecisionFloats?: boolean;
  27177. }
  27178. /**
  27179. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27180. */
  27181. export class Engine {
  27182. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27183. static ExceptionList: ({
  27184. key: string;
  27185. capture: string;
  27186. captureConstraint: number;
  27187. targets: string[];
  27188. } | {
  27189. key: string;
  27190. capture: null;
  27191. captureConstraint: null;
  27192. targets: string[];
  27193. })[];
  27194. /** Gets the list of created engines */
  27195. static readonly Instances: Engine[];
  27196. /**
  27197. * Gets the latest created engine
  27198. */
  27199. static readonly LastCreatedEngine: Nullable<Engine>;
  27200. /**
  27201. * Gets the latest created scene
  27202. */
  27203. static readonly LastCreatedScene: Nullable<Scene>;
  27204. /**
  27205. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27206. * @param flag defines which part of the materials must be marked as dirty
  27207. * @param predicate defines a predicate used to filter which materials should be affected
  27208. */
  27209. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27210. /**
  27211. * Hidden
  27212. */
  27213. static _TextureLoaders: IInternalTextureLoader[];
  27214. /** Defines that alpha blending is disabled */
  27215. static readonly ALPHA_DISABLE: number;
  27216. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27217. static readonly ALPHA_ADD: number;
  27218. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27219. static readonly ALPHA_COMBINE: number;
  27220. /** Defines that alpha blending to DEST - SRC * DEST */
  27221. static readonly ALPHA_SUBTRACT: number;
  27222. /** Defines that alpha blending to SRC * DEST */
  27223. static readonly ALPHA_MULTIPLY: number;
  27224. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27225. static readonly ALPHA_MAXIMIZED: number;
  27226. /** Defines that alpha blending to SRC + DEST */
  27227. static readonly ALPHA_ONEONE: number;
  27228. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27229. static readonly ALPHA_PREMULTIPLIED: number;
  27230. /**
  27231. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27232. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27233. */
  27234. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27235. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27236. static readonly ALPHA_INTERPOLATE: number;
  27237. /**
  27238. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27239. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27240. */
  27241. static readonly ALPHA_SCREENMODE: number;
  27242. /** Defines that the ressource is not delayed*/
  27243. static readonly DELAYLOADSTATE_NONE: number;
  27244. /** Defines that the ressource was successfully delay loaded */
  27245. static readonly DELAYLOADSTATE_LOADED: number;
  27246. /** Defines that the ressource is currently delay loading */
  27247. static readonly DELAYLOADSTATE_LOADING: number;
  27248. /** Defines that the ressource is delayed and has not started loading */
  27249. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27250. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27251. static readonly NEVER: number;
  27252. /** 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 */
  27253. static readonly ALWAYS: number;
  27254. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27255. static readonly LESS: number;
  27256. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27257. static readonly EQUAL: number;
  27258. /** 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 */
  27259. static readonly LEQUAL: number;
  27260. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27261. static readonly GREATER: number;
  27262. /** 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 */
  27263. static readonly GEQUAL: number;
  27264. /** 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 */
  27265. static readonly NOTEQUAL: number;
  27266. /** Passed to stencilOperation to specify that stencil value must be kept */
  27267. static readonly KEEP: number;
  27268. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27269. static readonly REPLACE: number;
  27270. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27271. static readonly INCR: number;
  27272. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27273. static readonly DECR: number;
  27274. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27275. static readonly INVERT: number;
  27276. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27277. static readonly INCR_WRAP: number;
  27278. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27279. static readonly DECR_WRAP: number;
  27280. /** Texture is not repeating outside of 0..1 UVs */
  27281. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27282. /** Texture is repeating outside of 0..1 UVs */
  27283. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27284. /** Texture is repeating and mirrored */
  27285. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27286. /** ALPHA */
  27287. static readonly TEXTUREFORMAT_ALPHA: number;
  27288. /** LUMINANCE */
  27289. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27290. /** LUMINANCE_ALPHA */
  27291. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27292. /** RGB */
  27293. static readonly TEXTUREFORMAT_RGB: number;
  27294. /** RGBA */
  27295. static readonly TEXTUREFORMAT_RGBA: number;
  27296. /** RED */
  27297. static readonly TEXTUREFORMAT_RED: number;
  27298. /** RED (2nd reference) */
  27299. static readonly TEXTUREFORMAT_R: number;
  27300. /** RG */
  27301. static readonly TEXTUREFORMAT_RG: number;
  27302. /** RED_INTEGER */
  27303. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27304. /** RED_INTEGER (2nd reference) */
  27305. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27306. /** RG_INTEGER */
  27307. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27308. /** RGB_INTEGER */
  27309. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27310. /** RGBA_INTEGER */
  27311. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27312. /** UNSIGNED_BYTE */
  27313. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27314. /** UNSIGNED_BYTE (2nd reference) */
  27315. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27316. /** FLOAT */
  27317. static readonly TEXTURETYPE_FLOAT: number;
  27318. /** HALF_FLOAT */
  27319. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27320. /** BYTE */
  27321. static readonly TEXTURETYPE_BYTE: number;
  27322. /** SHORT */
  27323. static readonly TEXTURETYPE_SHORT: number;
  27324. /** UNSIGNED_SHORT */
  27325. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27326. /** INT */
  27327. static readonly TEXTURETYPE_INT: number;
  27328. /** UNSIGNED_INT */
  27329. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27330. /** UNSIGNED_SHORT_4_4_4_4 */
  27331. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27332. /** UNSIGNED_SHORT_5_5_5_1 */
  27333. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27334. /** UNSIGNED_SHORT_5_6_5 */
  27335. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27336. /** UNSIGNED_INT_2_10_10_10_REV */
  27337. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27338. /** UNSIGNED_INT_24_8 */
  27339. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27340. /** UNSIGNED_INT_10F_11F_11F_REV */
  27341. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27342. /** UNSIGNED_INT_5_9_9_9_REV */
  27343. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27344. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27345. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27346. /** nearest is mag = nearest and min = nearest and mip = linear */
  27347. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27348. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27349. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27350. /** Trilinear is mag = linear and min = linear and mip = linear */
  27351. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27352. /** nearest is mag = nearest and min = nearest and mip = linear */
  27353. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27354. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27355. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27356. /** Trilinear is mag = linear and min = linear and mip = linear */
  27357. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27358. /** mag = nearest and min = nearest and mip = nearest */
  27359. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27360. /** mag = nearest and min = linear and mip = nearest */
  27361. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27362. /** mag = nearest and min = linear and mip = linear */
  27363. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27364. /** mag = nearest and min = linear and mip = none */
  27365. static readonly TEXTURE_NEAREST_LINEAR: number;
  27366. /** mag = nearest and min = nearest and mip = none */
  27367. static readonly TEXTURE_NEAREST_NEAREST: number;
  27368. /** mag = linear and min = nearest and mip = nearest */
  27369. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27370. /** mag = linear and min = nearest and mip = linear */
  27371. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27372. /** mag = linear and min = linear and mip = none */
  27373. static readonly TEXTURE_LINEAR_LINEAR: number;
  27374. /** mag = linear and min = nearest and mip = none */
  27375. static readonly TEXTURE_LINEAR_NEAREST: number;
  27376. /** Explicit coordinates mode */
  27377. static readonly TEXTURE_EXPLICIT_MODE: number;
  27378. /** Spherical coordinates mode */
  27379. static readonly TEXTURE_SPHERICAL_MODE: number;
  27380. /** Planar coordinates mode */
  27381. static readonly TEXTURE_PLANAR_MODE: number;
  27382. /** Cubic coordinates mode */
  27383. static readonly TEXTURE_CUBIC_MODE: number;
  27384. /** Projection coordinates mode */
  27385. static readonly TEXTURE_PROJECTION_MODE: number;
  27386. /** Skybox coordinates mode */
  27387. static readonly TEXTURE_SKYBOX_MODE: number;
  27388. /** Inverse Cubic coordinates mode */
  27389. static readonly TEXTURE_INVCUBIC_MODE: number;
  27390. /** Equirectangular coordinates mode */
  27391. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27392. /** Equirectangular Fixed coordinates mode */
  27393. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27394. /** Equirectangular Fixed Mirrored coordinates mode */
  27395. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27396. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27397. static readonly SCALEMODE_FLOOR: number;
  27398. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27399. static readonly SCALEMODE_NEAREST: number;
  27400. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27401. static readonly SCALEMODE_CEILING: number;
  27402. /**
  27403. * Returns the current npm package of the sdk
  27404. */
  27405. static readonly NpmPackage: string;
  27406. /**
  27407. * Returns the current version of the framework
  27408. */
  27409. static readonly Version: string;
  27410. /**
  27411. * Returns a string describing the current engine
  27412. */
  27413. readonly description: string;
  27414. /**
  27415. * Gets or sets the epsilon value used by collision engine
  27416. */
  27417. static CollisionsEpsilon: number;
  27418. /**
  27419. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27420. */
  27421. static ShadersRepository: string;
  27422. /**
  27423. * Method called to create the default loading screen.
  27424. * This can be overriden in your own app.
  27425. * @param canvas The rendering canvas element
  27426. * @returns The loading screen
  27427. */
  27428. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27429. /**
  27430. * Method called to create the default rescale post process on each engine.
  27431. */
  27432. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27433. /**
  27434. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27435. */
  27436. forcePOTTextures: boolean;
  27437. /**
  27438. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27439. */
  27440. isFullscreen: boolean;
  27441. /**
  27442. * Gets a boolean indicating if the pointer is currently locked
  27443. */
  27444. isPointerLock: boolean;
  27445. /**
  27446. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27447. */
  27448. cullBackFaces: boolean;
  27449. /**
  27450. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27451. */
  27452. renderEvenInBackground: boolean;
  27453. /**
  27454. * Gets or sets a boolean indicating that cache can be kept between frames
  27455. */
  27456. preventCacheWipeBetweenFrames: boolean;
  27457. /**
  27458. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27459. **/
  27460. enableOfflineSupport: boolean;
  27461. /**
  27462. * 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)
  27463. **/
  27464. disableManifestCheck: boolean;
  27465. /**
  27466. * Gets the list of created scenes
  27467. */
  27468. scenes: Scene[];
  27469. /**
  27470. * Event raised when a new scene is created
  27471. */
  27472. onNewSceneAddedObservable: Observable<Scene>;
  27473. /**
  27474. * Gets the list of created postprocesses
  27475. */
  27476. postProcesses: PostProcess[];
  27477. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27478. validateShaderPrograms: boolean;
  27479. /**
  27480. * Observable event triggered each time the rendering canvas is resized
  27481. */
  27482. onResizeObservable: Observable<Engine>;
  27483. /**
  27484. * Observable event triggered each time the canvas loses focus
  27485. */
  27486. onCanvasBlurObservable: Observable<Engine>;
  27487. /**
  27488. * Observable event triggered each time the canvas gains focus
  27489. */
  27490. onCanvasFocusObservable: Observable<Engine>;
  27491. /**
  27492. * Observable event triggered each time the canvas receives pointerout event
  27493. */
  27494. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27495. /**
  27496. * Observable event triggered before each texture is initialized
  27497. */
  27498. onBeforeTextureInitObservable: Observable<Texture>;
  27499. /**
  27500. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27501. */
  27502. disableUniformBuffers: boolean;
  27503. /** @hidden */
  27504. _uniformBuffers: UniformBuffer[];
  27505. /**
  27506. * Gets a boolean indicating that the engine supports uniform buffers
  27507. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27508. */
  27509. readonly supportsUniformBuffers: boolean;
  27510. /**
  27511. * Observable raised when the engine begins a new frame
  27512. */
  27513. onBeginFrameObservable: Observable<Engine>;
  27514. /**
  27515. * If set, will be used to request the next animation frame for the render loop
  27516. */
  27517. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27518. /**
  27519. * Observable raised when the engine ends the current frame
  27520. */
  27521. onEndFrameObservable: Observable<Engine>;
  27522. /**
  27523. * Observable raised when the engine is about to compile a shader
  27524. */
  27525. onBeforeShaderCompilationObservable: Observable<Engine>;
  27526. /**
  27527. * Observable raised when the engine has jsut compiled a shader
  27528. */
  27529. onAfterShaderCompilationObservable: Observable<Engine>;
  27530. /** @hidden */
  27531. _gl: WebGLRenderingContext;
  27532. private _renderingCanvas;
  27533. private _windowIsBackground;
  27534. private _webGLVersion;
  27535. protected _highPrecisionShadersAllowed: boolean;
  27536. /** @hidden */
  27537. readonly _shouldUseHighPrecisionShader: boolean;
  27538. /**
  27539. * Gets a boolean indicating that only power of 2 textures are supported
  27540. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27541. */
  27542. readonly needPOTTextures: boolean;
  27543. /** @hidden */
  27544. _badOS: boolean;
  27545. /** @hidden */
  27546. _badDesktopOS: boolean;
  27547. /**
  27548. * Gets the audio engine
  27549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27550. * @ignorenaming
  27551. */
  27552. static audioEngine: IAudioEngine;
  27553. /**
  27554. * Default AudioEngine factory responsible of creating the Audio Engine.
  27555. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27556. */
  27557. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27558. /**
  27559. * Default offline support factory responsible of creating a tool used to store data locally.
  27560. * By default, this will create a Database object if the workload has been embedded.
  27561. */
  27562. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27563. private _onFocus;
  27564. private _onBlur;
  27565. private _onCanvasPointerOut;
  27566. private _onCanvasBlur;
  27567. private _onCanvasFocus;
  27568. private _onFullscreenChange;
  27569. private _onPointerLockChange;
  27570. private _hardwareScalingLevel;
  27571. /** @hidden */
  27572. _caps: EngineCapabilities;
  27573. private _pointerLockRequested;
  27574. private _isStencilEnable;
  27575. private _colorWrite;
  27576. private _loadingScreen;
  27577. /** @hidden */
  27578. _drawCalls: PerfCounter;
  27579. private _glVersion;
  27580. private _glRenderer;
  27581. private _glVendor;
  27582. private _videoTextureSupported;
  27583. private _renderingQueueLaunched;
  27584. private _activeRenderLoops;
  27585. private _deterministicLockstep;
  27586. private _lockstepMaxSteps;
  27587. /**
  27588. * Observable signaled when a context lost event is raised
  27589. */
  27590. onContextLostObservable: Observable<Engine>;
  27591. /**
  27592. * Observable signaled when a context restored event is raised
  27593. */
  27594. onContextRestoredObservable: Observable<Engine>;
  27595. private _onContextLost;
  27596. private _onContextRestored;
  27597. private _contextWasLost;
  27598. /** @hidden */
  27599. _doNotHandleContextLost: boolean;
  27600. /**
  27601. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27603. */
  27604. doNotHandleContextLost: boolean;
  27605. private _performanceMonitor;
  27606. private _fps;
  27607. private _deltaTime;
  27608. /**
  27609. * Turn this value on if you want to pause FPS computation when in background
  27610. */
  27611. disablePerformanceMonitorInBackground: boolean;
  27612. /**
  27613. * Gets the performance monitor attached to this engine
  27614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27615. */
  27616. readonly performanceMonitor: PerformanceMonitor;
  27617. /**
  27618. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27619. */
  27620. disableVertexArrayObjects: boolean;
  27621. /** @hidden */
  27622. protected _depthCullingState: _DepthCullingState;
  27623. /** @hidden */
  27624. protected _stencilState: _StencilState;
  27625. /** @hidden */
  27626. protected _alphaState: _AlphaState;
  27627. /** @hidden */
  27628. protected _alphaMode: number;
  27629. /** @hidden */
  27630. _internalTexturesCache: InternalTexture[];
  27631. /** @hidden */
  27632. protected _activeChannel: number;
  27633. private _currentTextureChannel;
  27634. /** @hidden */
  27635. protected _boundTexturesCache: {
  27636. [key: string]: Nullable<InternalTexture>;
  27637. };
  27638. /** @hidden */
  27639. protected _currentEffect: Nullable<Effect>;
  27640. /** @hidden */
  27641. protected _currentProgram: Nullable<WebGLProgram>;
  27642. private _compiledEffects;
  27643. private _vertexAttribArraysEnabled;
  27644. /** @hidden */
  27645. protected _cachedViewport: Nullable<Viewport>;
  27646. private _cachedVertexArrayObject;
  27647. /** @hidden */
  27648. protected _cachedVertexBuffers: any;
  27649. /** @hidden */
  27650. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27651. /** @hidden */
  27652. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27653. /** @hidden */
  27654. _currentRenderTarget: Nullable<InternalTexture>;
  27655. private _uintIndicesCurrentlySet;
  27656. private _currentBoundBuffer;
  27657. /** @hidden */
  27658. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27659. private _currentBufferPointers;
  27660. private _currentInstanceLocations;
  27661. private _currentInstanceBuffers;
  27662. private _textureUnits;
  27663. /** @hidden */
  27664. _workingCanvas: Nullable<HTMLCanvasElement>;
  27665. /** @hidden */
  27666. _workingContext: Nullable<CanvasRenderingContext2D>;
  27667. private _rescalePostProcess;
  27668. private _dummyFramebuffer;
  27669. private _externalData;
  27670. /** @hidden */
  27671. _bindedRenderFunction: any;
  27672. private _vaoRecordInProgress;
  27673. private _mustWipeVertexAttributes;
  27674. private _emptyTexture;
  27675. private _emptyCubeTexture;
  27676. private _emptyTexture3D;
  27677. /** @hidden */
  27678. _frameHandler: number;
  27679. private _nextFreeTextureSlots;
  27680. private _maxSimultaneousTextures;
  27681. private _activeRequests;
  27682. private _texturesSupported;
  27683. /** @hidden */
  27684. _textureFormatInUse: Nullable<string>;
  27685. /**
  27686. * Gets the list of texture formats supported
  27687. */
  27688. readonly texturesSupported: Array<string>;
  27689. /**
  27690. * Gets the list of texture formats in use
  27691. */
  27692. readonly textureFormatInUse: Nullable<string>;
  27693. /**
  27694. * Gets the current viewport
  27695. */
  27696. readonly currentViewport: Nullable<Viewport>;
  27697. /**
  27698. * Gets the default empty texture
  27699. */
  27700. readonly emptyTexture: InternalTexture;
  27701. /**
  27702. * Gets the default empty 3D texture
  27703. */
  27704. readonly emptyTexture3D: InternalTexture;
  27705. /**
  27706. * Gets the default empty cube texture
  27707. */
  27708. readonly emptyCubeTexture: InternalTexture;
  27709. /**
  27710. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27711. */
  27712. readonly premultipliedAlpha: boolean;
  27713. /**
  27714. * Creates a new engine
  27715. * @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
  27716. * @param antialias defines enable antialiasing (default: false)
  27717. * @param options defines further options to be sent to the getContext() function
  27718. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27719. */
  27720. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27721. /**
  27722. * Initializes a webVR display and starts listening to display change events
  27723. * The onVRDisplayChangedObservable will be notified upon these changes
  27724. * @returns The onVRDisplayChangedObservable
  27725. */
  27726. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27727. /** @hidden */
  27728. _prepareVRComponent(): void;
  27729. /** @hidden */
  27730. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27731. /** @hidden */
  27732. _submitVRFrame(): void;
  27733. /**
  27734. * Call this function to leave webVR mode
  27735. * Will do nothing if webVR is not supported or if there is no webVR device
  27736. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27737. */
  27738. disableVR(): void;
  27739. /**
  27740. * Gets a boolean indicating that the system is in VR mode and is presenting
  27741. * @returns true if VR mode is engaged
  27742. */
  27743. isVRPresenting(): boolean;
  27744. /** @hidden */
  27745. _requestVRFrame(): void;
  27746. private _disableTouchAction;
  27747. private _rebuildInternalTextures;
  27748. private _rebuildEffects;
  27749. /**
  27750. * Gets a boolean indicating if all created effects are ready
  27751. * @returns true if all effects are ready
  27752. */
  27753. areAllEffectsReady(): boolean;
  27754. private _rebuildBuffers;
  27755. private _initGLContext;
  27756. /**
  27757. * Gets version of the current webGL context
  27758. */
  27759. readonly webGLVersion: number;
  27760. /**
  27761. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27762. */
  27763. readonly isStencilEnable: boolean;
  27764. /** @hidden */
  27765. _prepareWorkingCanvas(): void;
  27766. /**
  27767. * Reset the texture cache to empty state
  27768. */
  27769. resetTextureCache(): void;
  27770. /**
  27771. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27772. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27773. * @returns true if engine is in deterministic lock step mode
  27774. */
  27775. isDeterministicLockStep(): boolean;
  27776. /**
  27777. * Gets the max steps when engine is running in deterministic lock step
  27778. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27779. * @returns the max steps
  27780. */
  27781. getLockstepMaxSteps(): number;
  27782. /**
  27783. * Gets an object containing information about the current webGL context
  27784. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27785. */
  27786. getGlInfo(): {
  27787. vendor: string;
  27788. renderer: string;
  27789. version: string;
  27790. };
  27791. /**
  27792. * Gets current aspect ratio
  27793. * @param camera defines the camera to use to get the aspect ratio
  27794. * @param useScreen defines if screen size must be used (or the current render target if any)
  27795. * @returns a number defining the aspect ratio
  27796. */
  27797. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27798. /**
  27799. * Gets current screen aspect ratio
  27800. * @returns a number defining the aspect ratio
  27801. */
  27802. getScreenAspectRatio(): number;
  27803. /**
  27804. * Gets the current render width
  27805. * @param useScreen defines if screen size must be used (or the current render target if any)
  27806. * @returns a number defining the current render width
  27807. */
  27808. getRenderWidth(useScreen?: boolean): number;
  27809. /**
  27810. * Gets the current render height
  27811. * @param useScreen defines if screen size must be used (or the current render target if any)
  27812. * @returns a number defining the current render height
  27813. */
  27814. getRenderHeight(useScreen?: boolean): number;
  27815. /**
  27816. * Gets the HTML canvas attached with the current webGL context
  27817. * @returns a HTML canvas
  27818. */
  27819. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27820. /**
  27821. * Gets the client rect of the HTML canvas attached with the current webGL context
  27822. * @returns a client rectanglee
  27823. */
  27824. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27825. /**
  27826. * Defines the hardware scaling level.
  27827. * By default the hardware scaling level is computed from the window device ratio.
  27828. * 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.
  27829. * @param level defines the level to use
  27830. */
  27831. setHardwareScalingLevel(level: number): void;
  27832. /**
  27833. * Gets the current hardware scaling level.
  27834. * By default the hardware scaling level is computed from the window device ratio.
  27835. * 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.
  27836. * @returns a number indicating the current hardware scaling level
  27837. */
  27838. getHardwareScalingLevel(): number;
  27839. /**
  27840. * Gets the list of loaded textures
  27841. * @returns an array containing all loaded textures
  27842. */
  27843. getLoadedTexturesCache(): InternalTexture[];
  27844. /**
  27845. * Gets the object containing all engine capabilities
  27846. * @returns the EngineCapabilities object
  27847. */
  27848. getCaps(): EngineCapabilities;
  27849. /**
  27850. * Gets the current depth function
  27851. * @returns a number defining the depth function
  27852. */
  27853. getDepthFunction(): Nullable<number>;
  27854. /**
  27855. * Sets the current depth function
  27856. * @param depthFunc defines the function to use
  27857. */
  27858. setDepthFunction(depthFunc: number): void;
  27859. /**
  27860. * Sets the current depth function to GREATER
  27861. */
  27862. setDepthFunctionToGreater(): void;
  27863. /**
  27864. * Sets the current depth function to GEQUAL
  27865. */
  27866. setDepthFunctionToGreaterOrEqual(): void;
  27867. /**
  27868. * Sets the current depth function to LESS
  27869. */
  27870. setDepthFunctionToLess(): void;
  27871. private _cachedStencilBuffer;
  27872. private _cachedStencilFunction;
  27873. private _cachedStencilMask;
  27874. private _cachedStencilOperationPass;
  27875. private _cachedStencilOperationFail;
  27876. private _cachedStencilOperationDepthFail;
  27877. private _cachedStencilReference;
  27878. /**
  27879. * Caches the the state of the stencil buffer
  27880. */
  27881. cacheStencilState(): void;
  27882. /**
  27883. * Restores the state of the stencil buffer
  27884. */
  27885. restoreStencilState(): void;
  27886. /**
  27887. * Sets the current depth function to LEQUAL
  27888. */
  27889. setDepthFunctionToLessOrEqual(): void;
  27890. /**
  27891. * Gets a boolean indicating if stencil buffer is enabled
  27892. * @returns the current stencil buffer state
  27893. */
  27894. getStencilBuffer(): boolean;
  27895. /**
  27896. * Enable or disable the stencil buffer
  27897. * @param enable defines if the stencil buffer must be enabled or disabled
  27898. */
  27899. setStencilBuffer(enable: boolean): void;
  27900. /**
  27901. * Gets the current stencil mask
  27902. * @returns a number defining the new stencil mask to use
  27903. */
  27904. getStencilMask(): number;
  27905. /**
  27906. * Sets the current stencil mask
  27907. * @param mask defines the new stencil mask to use
  27908. */
  27909. setStencilMask(mask: number): void;
  27910. /**
  27911. * Gets the current stencil function
  27912. * @returns a number defining the stencil function to use
  27913. */
  27914. getStencilFunction(): number;
  27915. /**
  27916. * Gets the current stencil reference value
  27917. * @returns a number defining the stencil reference value to use
  27918. */
  27919. getStencilFunctionReference(): number;
  27920. /**
  27921. * Gets the current stencil mask
  27922. * @returns a number defining the stencil mask to use
  27923. */
  27924. getStencilFunctionMask(): number;
  27925. /**
  27926. * Sets the current stencil function
  27927. * @param stencilFunc defines the new stencil function to use
  27928. */
  27929. setStencilFunction(stencilFunc: number): void;
  27930. /**
  27931. * Sets the current stencil reference
  27932. * @param reference defines the new stencil reference to use
  27933. */
  27934. setStencilFunctionReference(reference: number): void;
  27935. /**
  27936. * Sets the current stencil mask
  27937. * @param mask defines the new stencil mask to use
  27938. */
  27939. setStencilFunctionMask(mask: number): void;
  27940. /**
  27941. * Gets the current stencil operation when stencil fails
  27942. * @returns a number defining stencil operation to use when stencil fails
  27943. */
  27944. getStencilOperationFail(): number;
  27945. /**
  27946. * Gets the current stencil operation when depth fails
  27947. * @returns a number defining stencil operation to use when depth fails
  27948. */
  27949. getStencilOperationDepthFail(): number;
  27950. /**
  27951. * Gets the current stencil operation when stencil passes
  27952. * @returns a number defining stencil operation to use when stencil passes
  27953. */
  27954. getStencilOperationPass(): number;
  27955. /**
  27956. * Sets the stencil operation to use when stencil fails
  27957. * @param operation defines the stencil operation to use when stencil fails
  27958. */
  27959. setStencilOperationFail(operation: number): void;
  27960. /**
  27961. * Sets the stencil operation to use when depth fails
  27962. * @param operation defines the stencil operation to use when depth fails
  27963. */
  27964. setStencilOperationDepthFail(operation: number): void;
  27965. /**
  27966. * Sets the stencil operation to use when stencil passes
  27967. * @param operation defines the stencil operation to use when stencil passes
  27968. */
  27969. setStencilOperationPass(operation: number): void;
  27970. /**
  27971. * Sets a boolean indicating if the dithering state is enabled or disabled
  27972. * @param value defines the dithering state
  27973. */
  27974. setDitheringState(value: boolean): void;
  27975. /**
  27976. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27977. * @param value defines the rasterizer state
  27978. */
  27979. setRasterizerState(value: boolean): void;
  27980. /**
  27981. * stop executing a render loop function and remove it from the execution array
  27982. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27983. */
  27984. stopRenderLoop(renderFunction?: () => void): void;
  27985. /** @hidden */
  27986. _renderLoop(): void;
  27987. /**
  27988. * Register and execute a render loop. The engine can have more than one render function
  27989. * @param renderFunction defines the function to continuously execute
  27990. */
  27991. runRenderLoop(renderFunction: () => void): void;
  27992. /**
  27993. * Toggle full screen mode
  27994. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27995. */
  27996. switchFullscreen(requestPointerLock: boolean): void;
  27997. /**
  27998. * Enters full screen mode
  27999. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28000. */
  28001. enterFullscreen(requestPointerLock: boolean): void;
  28002. /**
  28003. * Exits full screen mode
  28004. */
  28005. exitFullscreen(): void;
  28006. /**
  28007. * Clear the current render buffer or the current render target (if any is set up)
  28008. * @param color defines the color to use
  28009. * @param backBuffer defines if the back buffer must be cleared
  28010. * @param depth defines if the depth buffer must be cleared
  28011. * @param stencil defines if the stencil buffer must be cleared
  28012. */
  28013. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28014. /**
  28015. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28016. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28017. * @param y defines the y-coordinate of the corner of the clear rectangle
  28018. * @param width defines the width of the clear rectangle
  28019. * @param height defines the height of the clear rectangle
  28020. * @param clearColor defines the clear color
  28021. */
  28022. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28023. /**
  28024. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28025. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28026. * @param y defines the y-coordinate of the corner of the clear rectangle
  28027. * @param width defines the width of the clear rectangle
  28028. * @param height defines the height of the clear rectangle
  28029. */
  28030. enableScissor(x: number, y: number, width: number, height: number): void;
  28031. /**
  28032. * Disable previously set scissor test rectangle
  28033. */
  28034. disableScissor(): void;
  28035. private _viewportCached;
  28036. /** @hidden */
  28037. _viewport(x: number, y: number, width: number, height: number): void;
  28038. /**
  28039. * Set the WebGL's viewport
  28040. * @param viewport defines the viewport element to be used
  28041. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28042. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28043. */
  28044. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28045. /**
  28046. * Directly set the WebGL Viewport
  28047. * @param x defines the x coordinate of the viewport (in screen space)
  28048. * @param y defines the y coordinate of the viewport (in screen space)
  28049. * @param width defines the width of the viewport (in screen space)
  28050. * @param height defines the height of the viewport (in screen space)
  28051. * @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
  28052. */
  28053. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28054. /**
  28055. * Begin a new frame
  28056. */
  28057. beginFrame(): void;
  28058. /**
  28059. * Enf the current frame
  28060. */
  28061. endFrame(): void;
  28062. /**
  28063. * Resize the view according to the canvas' size
  28064. */
  28065. resize(): void;
  28066. /**
  28067. * Force a specific size of the canvas
  28068. * @param width defines the new canvas' width
  28069. * @param height defines the new canvas' height
  28070. */
  28071. setSize(width: number, height: number): void;
  28072. /**
  28073. * Binds the frame buffer to the specified texture.
  28074. * @param texture The texture to render to or null for the default canvas
  28075. * @param faceIndex The face of the texture to render to in case of cube texture
  28076. * @param requiredWidth The width of the target to render to
  28077. * @param requiredHeight The height of the target to render to
  28078. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28079. * @param depthStencilTexture The depth stencil texture to use to render
  28080. * @param lodLevel defines le lod level to bind to the frame buffer
  28081. */
  28082. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28083. /** @hidden */
  28084. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28085. /**
  28086. * Unbind the current render target texture from the webGL context
  28087. * @param texture defines the render target texture to unbind
  28088. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28089. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28090. */
  28091. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28092. /**
  28093. * Force the mipmap generation for the given render target texture
  28094. * @param texture defines the render target texture to use
  28095. */
  28096. generateMipMapsForCubemap(texture: InternalTexture): void;
  28097. /**
  28098. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28099. */
  28100. flushFramebuffer(): void;
  28101. /**
  28102. * Unbind the current render target and bind the default framebuffer
  28103. */
  28104. restoreDefaultFramebuffer(): void;
  28105. /**
  28106. * Create an uniform buffer
  28107. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28108. * @param elements defines the content of the uniform buffer
  28109. * @returns the webGL uniform buffer
  28110. */
  28111. createUniformBuffer(elements: FloatArray): DataBuffer;
  28112. /**
  28113. * Create a dynamic uniform buffer
  28114. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28115. * @param elements defines the content of the uniform buffer
  28116. * @returns the webGL uniform buffer
  28117. */
  28118. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28119. /**
  28120. * Update an existing uniform buffer
  28121. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28122. * @param uniformBuffer defines the target uniform buffer
  28123. * @param elements defines the content to update
  28124. * @param offset defines the offset in the uniform buffer where update should start
  28125. * @param count defines the size of the data to update
  28126. */
  28127. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28128. private _resetVertexBufferBinding;
  28129. /**
  28130. * Creates a vertex buffer
  28131. * @param data the data for the vertex buffer
  28132. * @returns the new WebGL static buffer
  28133. */
  28134. createVertexBuffer(data: DataArray): DataBuffer;
  28135. /**
  28136. * Creates a dynamic vertex buffer
  28137. * @param data the data for the dynamic vertex buffer
  28138. * @returns the new WebGL dynamic buffer
  28139. */
  28140. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28141. /**
  28142. * Update a dynamic index buffer
  28143. * @param indexBuffer defines the target index buffer
  28144. * @param indices defines the data to update
  28145. * @param offset defines the offset in the target index buffer where update should start
  28146. */
  28147. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28148. /**
  28149. * Updates a dynamic vertex buffer.
  28150. * @param vertexBuffer the vertex buffer to update
  28151. * @param data the data used to update the vertex buffer
  28152. * @param byteOffset the byte offset of the data
  28153. * @param byteLength the byte length of the data
  28154. */
  28155. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28156. private _resetIndexBufferBinding;
  28157. /**
  28158. * Creates a new index buffer
  28159. * @param indices defines the content of the index buffer
  28160. * @param updatable defines if the index buffer must be updatable
  28161. * @returns a new webGL buffer
  28162. */
  28163. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28164. /**
  28165. * Bind a webGL buffer to the webGL context
  28166. * @param buffer defines the buffer to bind
  28167. */
  28168. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28169. /**
  28170. * Bind an uniform buffer to the current webGL context
  28171. * @param buffer defines the buffer to bind
  28172. */
  28173. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28174. /**
  28175. * Bind a buffer to the current webGL context at a given location
  28176. * @param buffer defines the buffer to bind
  28177. * @param location defines the index where to bind the buffer
  28178. */
  28179. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28180. /**
  28181. * Bind a specific block at a given index in a specific shader program
  28182. * @param pipelineContext defines the pipeline context to use
  28183. * @param blockName defines the block name
  28184. * @param index defines the index where to bind the block
  28185. */
  28186. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28187. private bindIndexBuffer;
  28188. private bindBuffer;
  28189. /**
  28190. * update the bound buffer with the given data
  28191. * @param data defines the data to update
  28192. */
  28193. updateArrayBuffer(data: Float32Array): void;
  28194. private _vertexAttribPointer;
  28195. private _bindIndexBufferWithCache;
  28196. private _bindVertexBuffersAttributes;
  28197. /**
  28198. * Records a vertex array object
  28199. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28200. * @param vertexBuffers defines the list of vertex buffers to store
  28201. * @param indexBuffer defines the index buffer to store
  28202. * @param effect defines the effect to store
  28203. * @returns the new vertex array object
  28204. */
  28205. recordVertexArrayObject(vertexBuffers: {
  28206. [key: string]: VertexBuffer;
  28207. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28208. /**
  28209. * Bind a specific vertex array object
  28210. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28211. * @param vertexArrayObject defines the vertex array object to bind
  28212. * @param indexBuffer defines the index buffer to bind
  28213. */
  28214. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28215. /**
  28216. * Bind webGl buffers directly to the webGL context
  28217. * @param vertexBuffer defines the vertex buffer to bind
  28218. * @param indexBuffer defines the index buffer to bind
  28219. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28220. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28221. * @param effect defines the effect associated with the vertex buffer
  28222. */
  28223. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28224. private _unbindVertexArrayObject;
  28225. /**
  28226. * Bind a list of vertex buffers to the webGL context
  28227. * @param vertexBuffers defines the list of vertex buffers to bind
  28228. * @param indexBuffer defines the index buffer to bind
  28229. * @param effect defines the effect associated with the vertex buffers
  28230. */
  28231. bindBuffers(vertexBuffers: {
  28232. [key: string]: Nullable<VertexBuffer>;
  28233. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28234. /**
  28235. * Unbind all instance attributes
  28236. */
  28237. unbindInstanceAttributes(): void;
  28238. /**
  28239. * Release and free the memory of a vertex array object
  28240. * @param vao defines the vertex array object to delete
  28241. */
  28242. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28243. /** @hidden */
  28244. _releaseBuffer(buffer: DataBuffer): boolean;
  28245. /**
  28246. * Creates a webGL buffer to use with instanciation
  28247. * @param capacity defines the size of the buffer
  28248. * @returns the webGL buffer
  28249. */
  28250. createInstancesBuffer(capacity: number): DataBuffer;
  28251. /**
  28252. * Delete a webGL buffer used with instanciation
  28253. * @param buffer defines the webGL buffer to delete
  28254. */
  28255. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28256. /**
  28257. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28258. * @param instancesBuffer defines the webGL buffer to update and bind
  28259. * @param data defines the data to store in the buffer
  28260. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28261. */
  28262. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28263. /**
  28264. * Apply all cached states (depth, culling, stencil and alpha)
  28265. */
  28266. applyStates(): void;
  28267. /**
  28268. * Send a draw order
  28269. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28270. * @param indexStart defines the starting index
  28271. * @param indexCount defines the number of index to draw
  28272. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28273. */
  28274. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28275. /**
  28276. * Draw a list of points
  28277. * @param verticesStart defines the index of first vertex to draw
  28278. * @param verticesCount defines the count of vertices to draw
  28279. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28280. */
  28281. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28282. /**
  28283. * Draw a list of unindexed primitives
  28284. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28285. * @param verticesStart defines the index of first vertex to draw
  28286. * @param verticesCount defines the count of vertices to draw
  28287. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28288. */
  28289. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28290. /**
  28291. * Draw a list of indexed primitives
  28292. * @param fillMode defines the primitive to use
  28293. * @param indexStart defines the starting index
  28294. * @param indexCount defines the number of index to draw
  28295. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28296. */
  28297. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28298. /**
  28299. * Draw a list of unindexed primitives
  28300. * @param fillMode defines the primitive to use
  28301. * @param verticesStart defines the index of first vertex to draw
  28302. * @param verticesCount defines the count of vertices to draw
  28303. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28304. */
  28305. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28306. private _drawMode;
  28307. /** @hidden */
  28308. _releaseEffect(effect: Effect): void;
  28309. /** @hidden */
  28310. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28311. /**
  28312. * Create a new effect (used to store vertex/fragment shaders)
  28313. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28314. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28315. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28316. * @param samplers defines an array of string used to represent textures
  28317. * @param defines defines the string containing the defines to use to compile the shaders
  28318. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28319. * @param onCompiled defines a function to call when the effect creation is successful
  28320. * @param onError defines a function to call when the effect creation has failed
  28321. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28322. * @returns the new Effect
  28323. */
  28324. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28325. private _compileShader;
  28326. private _compileRawShader;
  28327. /**
  28328. * Directly creates a webGL program
  28329. * @param pipelineContext defines the pipeline context to attach to
  28330. * @param vertexCode defines the vertex shader code to use
  28331. * @param fragmentCode defines the fragment shader code to use
  28332. * @param context defines the webGL context to use (if not set, the current one will be used)
  28333. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28334. * @returns the new webGL program
  28335. */
  28336. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28337. /**
  28338. * Creates a webGL program
  28339. * @param pipelineContext defines the pipeline context to attach to
  28340. * @param vertexCode defines the vertex shader code to use
  28341. * @param fragmentCode defines the fragment shader code to use
  28342. * @param defines defines the string containing the defines to use to compile the shaders
  28343. * @param context defines the webGL context to use (if not set, the current one will be used)
  28344. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28345. * @returns the new webGL program
  28346. */
  28347. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28348. /**
  28349. * Creates a new pipeline context
  28350. * @returns the new pipeline
  28351. */
  28352. createPipelineContext(): WebGLPipelineContext;
  28353. private _createShaderProgram;
  28354. private _finalizePipelineContext;
  28355. /** @hidden */
  28356. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28357. /** @hidden */
  28358. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28359. /** @hidden */
  28360. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28361. /**
  28362. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28363. * @param pipelineContext defines the pipeline context to use
  28364. * @param uniformsNames defines the list of uniform names
  28365. * @returns an array of webGL uniform locations
  28366. */
  28367. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28368. /**
  28369. * Gets the lsit of active attributes for a given webGL program
  28370. * @param pipelineContext defines the pipeline context to use
  28371. * @param attributesNames defines the list of attribute names to get
  28372. * @returns an array of indices indicating the offset of each attribute
  28373. */
  28374. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28375. /**
  28376. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28377. * @param effect defines the effect to activate
  28378. */
  28379. enableEffect(effect: Nullable<Effect>): void;
  28380. /**
  28381. * Set the value of an uniform to an array of int32
  28382. * @param uniform defines the webGL uniform location where to store the value
  28383. * @param array defines the array of int32 to store
  28384. */
  28385. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28386. /**
  28387. * Set the value of an uniform to an array of int32 (stored as vec2)
  28388. * @param uniform defines the webGL uniform location where to store the value
  28389. * @param array defines the array of int32 to store
  28390. */
  28391. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28392. /**
  28393. * Set the value of an uniform to an array of int32 (stored as vec3)
  28394. * @param uniform defines the webGL uniform location where to store the value
  28395. * @param array defines the array of int32 to store
  28396. */
  28397. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28398. /**
  28399. * Set the value of an uniform to an array of int32 (stored as vec4)
  28400. * @param uniform defines the webGL uniform location where to store the value
  28401. * @param array defines the array of int32 to store
  28402. */
  28403. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28404. /**
  28405. * Set the value of an uniform to an array of float32
  28406. * @param uniform defines the webGL uniform location where to store the value
  28407. * @param array defines the array of float32 to store
  28408. */
  28409. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28410. /**
  28411. * Set the value of an uniform to an array of float32 (stored as vec2)
  28412. * @param uniform defines the webGL uniform location where to store the value
  28413. * @param array defines the array of float32 to store
  28414. */
  28415. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28416. /**
  28417. * Set the value of an uniform to an array of float32 (stored as vec3)
  28418. * @param uniform defines the webGL uniform location where to store the value
  28419. * @param array defines the array of float32 to store
  28420. */
  28421. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28422. /**
  28423. * Set the value of an uniform to an array of float32 (stored as vec4)
  28424. * @param uniform defines the webGL uniform location where to store the value
  28425. * @param array defines the array of float32 to store
  28426. */
  28427. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28428. /**
  28429. * Set the value of an uniform to an array of number
  28430. * @param uniform defines the webGL uniform location where to store the value
  28431. * @param array defines the array of number to store
  28432. */
  28433. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28434. /**
  28435. * Set the value of an uniform to an array of number (stored as vec2)
  28436. * @param uniform defines the webGL uniform location where to store the value
  28437. * @param array defines the array of number to store
  28438. */
  28439. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28440. /**
  28441. * Set the value of an uniform to an array of number (stored as vec3)
  28442. * @param uniform defines the webGL uniform location where to store the value
  28443. * @param array defines the array of number to store
  28444. */
  28445. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28446. /**
  28447. * Set the value of an uniform to an array of number (stored as vec4)
  28448. * @param uniform defines the webGL uniform location where to store the value
  28449. * @param array defines the array of number to store
  28450. */
  28451. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28452. /**
  28453. * Set the value of an uniform to an array of float32 (stored as matrices)
  28454. * @param uniform defines the webGL uniform location where to store the value
  28455. * @param matrices defines the array of float32 to store
  28456. */
  28457. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28458. /**
  28459. * Set the value of an uniform to a matrix
  28460. * @param uniform defines the webGL uniform location where to store the value
  28461. * @param matrix defines the matrix to store
  28462. */
  28463. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28464. /**
  28465. * Set the value of an uniform to a matrix (3x3)
  28466. * @param uniform defines the webGL uniform location where to store the value
  28467. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28468. */
  28469. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28470. /**
  28471. * Set the value of an uniform to a matrix (2x2)
  28472. * @param uniform defines the webGL uniform location where to store the value
  28473. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28474. */
  28475. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28476. /**
  28477. * Set the value of an uniform to a number (int)
  28478. * @param uniform defines the webGL uniform location where to store the value
  28479. * @param value defines the int number to store
  28480. */
  28481. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28482. /**
  28483. * Set the value of an uniform to a number (float)
  28484. * @param uniform defines the webGL uniform location where to store the value
  28485. * @param value defines the float number to store
  28486. */
  28487. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28488. /**
  28489. * Set the value of an uniform to a vec2
  28490. * @param uniform defines the webGL uniform location where to store the value
  28491. * @param x defines the 1st component of the value
  28492. * @param y defines the 2nd component of the value
  28493. */
  28494. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28495. /**
  28496. * Set the value of an uniform to a vec3
  28497. * @param uniform defines the webGL uniform location where to store the value
  28498. * @param x defines the 1st component of the value
  28499. * @param y defines the 2nd component of the value
  28500. * @param z defines the 3rd component of the value
  28501. */
  28502. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28503. /**
  28504. * Set the value of an uniform to a boolean
  28505. * @param uniform defines the webGL uniform location where to store the value
  28506. * @param bool defines the boolean to store
  28507. */
  28508. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28509. /**
  28510. * Set the value of an uniform to a vec4
  28511. * @param uniform defines the webGL uniform location where to store the value
  28512. * @param x defines the 1st component of the value
  28513. * @param y defines the 2nd component of the value
  28514. * @param z defines the 3rd component of the value
  28515. * @param w defines the 4th component of the value
  28516. */
  28517. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28518. /**
  28519. * Set the value of an uniform to a Color3
  28520. * @param uniform defines the webGL uniform location where to store the value
  28521. * @param color3 defines the color to store
  28522. */
  28523. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28524. /**
  28525. * Set the value of an uniform to a Color3 and an alpha value
  28526. * @param uniform defines the webGL uniform location where to store the value
  28527. * @param color3 defines the color to store
  28528. * @param alpha defines the alpha component to store
  28529. */
  28530. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28531. /**
  28532. * Sets a Color4 on a uniform variable
  28533. * @param uniform defines the uniform location
  28534. * @param color4 defines the value to be set
  28535. */
  28536. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28537. /**
  28538. * Set various states to the webGL context
  28539. * @param culling defines backface culling state
  28540. * @param zOffset defines the value to apply to zOffset (0 by default)
  28541. * @param force defines if states must be applied even if cache is up to date
  28542. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28543. */
  28544. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28545. /**
  28546. * Set the z offset to apply to current rendering
  28547. * @param value defines the offset to apply
  28548. */
  28549. setZOffset(value: number): void;
  28550. /**
  28551. * Gets the current value of the zOffset
  28552. * @returns the current zOffset state
  28553. */
  28554. getZOffset(): number;
  28555. /**
  28556. * Enable or disable depth buffering
  28557. * @param enable defines the state to set
  28558. */
  28559. setDepthBuffer(enable: boolean): void;
  28560. /**
  28561. * Gets a boolean indicating if depth writing is enabled
  28562. * @returns the current depth writing state
  28563. */
  28564. getDepthWrite(): boolean;
  28565. /**
  28566. * Enable or disable depth writing
  28567. * @param enable defines the state to set
  28568. */
  28569. setDepthWrite(enable: boolean): void;
  28570. /**
  28571. * Enable or disable color writing
  28572. * @param enable defines the state to set
  28573. */
  28574. setColorWrite(enable: boolean): void;
  28575. /**
  28576. * Gets a boolean indicating if color writing is enabled
  28577. * @returns the current color writing state
  28578. */
  28579. getColorWrite(): boolean;
  28580. /**
  28581. * Sets alpha constants used by some alpha blending modes
  28582. * @param r defines the red component
  28583. * @param g defines the green component
  28584. * @param b defines the blue component
  28585. * @param a defines the alpha component
  28586. */
  28587. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28588. /**
  28589. * Sets the current alpha mode
  28590. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28591. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28592. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28593. */
  28594. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28595. /**
  28596. * Gets the current alpha mode
  28597. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28598. * @returns the current alpha mode
  28599. */
  28600. getAlphaMode(): number;
  28601. /**
  28602. * Clears the list of texture accessible through engine.
  28603. * This can help preventing texture load conflict due to name collision.
  28604. */
  28605. clearInternalTexturesCache(): void;
  28606. /**
  28607. * Force the entire cache to be cleared
  28608. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28609. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28610. */
  28611. wipeCaches(bruteForce?: boolean): void;
  28612. /**
  28613. * Set the compressed texture format to use, based on the formats you have, and the formats
  28614. * supported by the hardware / browser.
  28615. *
  28616. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28617. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28618. * to API arguments needed to compressed textures. This puts the burden on the container
  28619. * generator to house the arcane code for determining these for current & future formats.
  28620. *
  28621. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28622. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28623. *
  28624. * Note: The result of this call is not taken into account when a texture is base64.
  28625. *
  28626. * @param formatsAvailable defines the list of those format families you have created
  28627. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28628. *
  28629. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28630. * @returns The extension selected.
  28631. */
  28632. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28633. /** @hidden */
  28634. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28635. min: number;
  28636. mag: number;
  28637. };
  28638. /** @hidden */
  28639. _createTexture(): WebGLTexture;
  28640. /**
  28641. * Usually called from Texture.ts.
  28642. * Passed information to create a WebGLTexture
  28643. * @param urlArg defines a value which contains one of the following:
  28644. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28645. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28646. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28647. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28648. * @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)
  28649. * @param scene needed for loading to the correct scene
  28650. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28651. * @param onLoad optional callback to be called upon successful completion
  28652. * @param onError optional callback to be called upon failure
  28653. * @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
  28654. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28655. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28656. * @param forcedExtension defines the extension to use to pick the right loader
  28657. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28658. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28659. */
  28660. 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;
  28661. private _rescaleTexture;
  28662. private _unpackFlipYCached;
  28663. /**
  28664. * In case you are sharing the context with other applications, it might
  28665. * be interested to not cache the unpack flip y state to ensure a consistent
  28666. * value would be set.
  28667. */
  28668. enableUnpackFlipYCached: boolean;
  28669. /** @hidden */
  28670. _unpackFlipY(value: boolean): void;
  28671. /** @hidden */
  28672. _getUnpackAlignement(): number;
  28673. /**
  28674. * Creates a dynamic texture
  28675. * @param width defines the width of the texture
  28676. * @param height defines the height of the texture
  28677. * @param generateMipMaps defines if the engine should generate the mip levels
  28678. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28679. * @returns the dynamic texture inside an InternalTexture
  28680. */
  28681. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28682. /**
  28683. * Update the sampling mode of a given texture
  28684. * @param samplingMode defines the required sampling mode
  28685. * @param texture defines the texture to update
  28686. */
  28687. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28688. /**
  28689. * Update the content of a dynamic texture
  28690. * @param texture defines the texture to update
  28691. * @param canvas defines the canvas containing the source
  28692. * @param invertY defines if data must be stored with Y axis inverted
  28693. * @param premulAlpha defines if alpha is stored as premultiplied
  28694. * @param format defines the format of the data
  28695. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28696. */
  28697. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28698. /**
  28699. * Update a video texture
  28700. * @param texture defines the texture to update
  28701. * @param video defines the video element to use
  28702. * @param invertY defines if data must be stored with Y axis inverted
  28703. */
  28704. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28705. /**
  28706. * Updates a depth texture Comparison Mode and Function.
  28707. * If the comparison Function is equal to 0, the mode will be set to none.
  28708. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28709. * @param texture The texture to set the comparison function for
  28710. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28711. */
  28712. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28713. /** @hidden */
  28714. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28715. width: number;
  28716. height: number;
  28717. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28718. /**
  28719. * Creates a depth stencil texture.
  28720. * This is only available in WebGL 2 or with the depth texture extension available.
  28721. * @param size The size of face edge in the texture.
  28722. * @param options The options defining the texture.
  28723. * @returns The texture
  28724. */
  28725. createDepthStencilTexture(size: number | {
  28726. width: number;
  28727. height: number;
  28728. }, options: DepthTextureCreationOptions): InternalTexture;
  28729. /**
  28730. * Creates a depth stencil texture.
  28731. * This is only available in WebGL 2 or with the depth texture extension available.
  28732. * @param size The size of face edge in the texture.
  28733. * @param options The options defining the texture.
  28734. * @returns The texture
  28735. */
  28736. private _createDepthStencilTexture;
  28737. /**
  28738. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28739. * @param renderTarget The render target to set the frame buffer for
  28740. */
  28741. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28742. /**
  28743. * Creates a new render target texture
  28744. * @param size defines the size of the texture
  28745. * @param options defines the options used to create the texture
  28746. * @returns a new render target texture stored in an InternalTexture
  28747. */
  28748. createRenderTargetTexture(size: number | {
  28749. width: number;
  28750. height: number;
  28751. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28752. /** @hidden */
  28753. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28754. /**
  28755. * Updates the sample count of a render target texture
  28756. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28757. * @param texture defines the texture to update
  28758. * @param samples defines the sample count to set
  28759. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28760. */
  28761. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28762. /** @hidden */
  28763. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28764. /** @hidden */
  28765. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28766. /** @hidden */
  28767. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28768. /** @hidden */
  28769. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28770. /**
  28771. * @hidden
  28772. */
  28773. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28774. private _prepareWebGLTextureContinuation;
  28775. private _prepareWebGLTexture;
  28776. /** @hidden */
  28777. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28778. /** @hidden */
  28779. _releaseFramebufferObjects(texture: InternalTexture): void;
  28780. /** @hidden */
  28781. _releaseTexture(texture: InternalTexture): void;
  28782. private setProgram;
  28783. private _boundUniforms;
  28784. /**
  28785. * Binds an effect to the webGL context
  28786. * @param effect defines the effect to bind
  28787. */
  28788. bindSamplers(effect: Effect): void;
  28789. private _activateCurrentTexture;
  28790. /** @hidden */
  28791. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28792. /** @hidden */
  28793. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28794. /**
  28795. * Sets a texture to the webGL context from a postprocess
  28796. * @param channel defines the channel to use
  28797. * @param postProcess defines the source postprocess
  28798. */
  28799. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28800. /**
  28801. * Binds the output of the passed in post process to the texture channel specified
  28802. * @param channel The channel the texture should be bound to
  28803. * @param postProcess The post process which's output should be bound
  28804. */
  28805. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28806. /**
  28807. * Unbind all textures from the webGL context
  28808. */
  28809. unbindAllTextures(): void;
  28810. /**
  28811. * Sets a texture to the according uniform.
  28812. * @param channel The texture channel
  28813. * @param uniform The uniform to set
  28814. * @param texture The texture to apply
  28815. */
  28816. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28817. /**
  28818. * Sets a depth stencil texture from a render target to the according uniform.
  28819. * @param channel The texture channel
  28820. * @param uniform The uniform to set
  28821. * @param texture The render target texture containing the depth stencil texture to apply
  28822. */
  28823. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28824. private _bindSamplerUniformToChannel;
  28825. private _getTextureWrapMode;
  28826. private _setTexture;
  28827. /**
  28828. * Sets an array of texture to the webGL context
  28829. * @param channel defines the channel where the texture array must be set
  28830. * @param uniform defines the associated uniform location
  28831. * @param textures defines the array of textures to bind
  28832. */
  28833. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28834. /** @hidden */
  28835. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28836. private _setTextureParameterFloat;
  28837. private _setTextureParameterInteger;
  28838. /**
  28839. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28840. * @param x defines the x coordinate of the rectangle where pixels must be read
  28841. * @param y defines the y coordinate of the rectangle where pixels must be read
  28842. * @param width defines the width of the rectangle where pixels must be read
  28843. * @param height defines the height of the rectangle where pixels must be read
  28844. * @returns a Uint8Array containing RGBA colors
  28845. */
  28846. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28847. /**
  28848. * Add an externaly attached data from its key.
  28849. * This method call will fail and return false, if such key already exists.
  28850. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28851. * @param key the unique key that identifies the data
  28852. * @param data the data object to associate to the key for this Engine instance
  28853. * @return true if no such key were already present and the data was added successfully, false otherwise
  28854. */
  28855. addExternalData<T>(key: string, data: T): boolean;
  28856. /**
  28857. * Get an externaly attached data from its key
  28858. * @param key the unique key that identifies the data
  28859. * @return the associated data, if present (can be null), or undefined if not present
  28860. */
  28861. getExternalData<T>(key: string): T;
  28862. /**
  28863. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28864. * @param key the unique key that identifies the data
  28865. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28866. * @return the associated data, can be null if the factory returned null.
  28867. */
  28868. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28869. /**
  28870. * Remove an externaly attached data from the Engine instance
  28871. * @param key the unique key that identifies the data
  28872. * @return true if the data was successfully removed, false if it doesn't exist
  28873. */
  28874. removeExternalData(key: string): boolean;
  28875. /**
  28876. * Unbind all vertex attributes from the webGL context
  28877. */
  28878. unbindAllAttributes(): void;
  28879. /**
  28880. * 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
  28881. */
  28882. releaseEffects(): void;
  28883. /**
  28884. * Dispose and release all associated resources
  28885. */
  28886. dispose(): void;
  28887. /**
  28888. * Display the loading screen
  28889. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28890. */
  28891. displayLoadingUI(): void;
  28892. /**
  28893. * Hide the loading screen
  28894. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28895. */
  28896. hideLoadingUI(): void;
  28897. /**
  28898. * Gets the current loading screen object
  28899. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28900. */
  28901. /**
  28902. * Sets the current loading screen object
  28903. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28904. */
  28905. loadingScreen: ILoadingScreen;
  28906. /**
  28907. * Sets the current loading screen text
  28908. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28909. */
  28910. loadingUIText: string;
  28911. /**
  28912. * Sets the current loading screen background color
  28913. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28914. */
  28915. loadingUIBackgroundColor: string;
  28916. /**
  28917. * Attach a new callback raised when context lost event is fired
  28918. * @param callback defines the callback to call
  28919. */
  28920. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28921. /**
  28922. * Attach a new callback raised when context restored event is fired
  28923. * @param callback defines the callback to call
  28924. */
  28925. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28926. /**
  28927. * Gets the source code of the vertex shader associated with a specific webGL program
  28928. * @param program defines the program to use
  28929. * @returns a string containing the source code of the vertex shader associated with the program
  28930. */
  28931. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28932. /**
  28933. * Gets the source code of the fragment shader associated with a specific webGL program
  28934. * @param program defines the program to use
  28935. * @returns a string containing the source code of the fragment shader associated with the program
  28936. */
  28937. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28938. /**
  28939. * Get the current error code of the webGL context
  28940. * @returns the error code
  28941. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28942. */
  28943. getError(): number;
  28944. /**
  28945. * Gets the current framerate
  28946. * @returns a number representing the framerate
  28947. */
  28948. getFps(): number;
  28949. /**
  28950. * Gets the time spent between current and previous frame
  28951. * @returns a number representing the delta time in ms
  28952. */
  28953. getDeltaTime(): number;
  28954. private _measureFps;
  28955. /** @hidden */
  28956. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28957. private _canRenderToFloatFramebuffer;
  28958. private _canRenderToHalfFloatFramebuffer;
  28959. private _canRenderToFramebuffer;
  28960. /** @hidden */
  28961. _getWebGLTextureType(type: number): number;
  28962. /** @hidden */
  28963. _getInternalFormat(format: number): number;
  28964. /** @hidden */
  28965. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28966. /** @hidden */
  28967. _getRGBAMultiSampleBufferFormat(type: number): number;
  28968. /** @hidden */
  28969. _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;
  28970. /** @hidden */
  28971. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28972. /**
  28973. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28974. * @returns true if the engine can be created
  28975. * @ignorenaming
  28976. */
  28977. static isSupported(): boolean;
  28978. }
  28979. }
  28980. declare module BABYLON {
  28981. /**
  28982. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28983. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28984. */
  28985. export class EffectFallbacks {
  28986. private _defines;
  28987. private _currentRank;
  28988. private _maxRank;
  28989. private _mesh;
  28990. /**
  28991. * Removes the fallback from the bound mesh.
  28992. */
  28993. unBindMesh(): void;
  28994. /**
  28995. * Adds a fallback on the specified property.
  28996. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28997. * @param define The name of the define in the shader
  28998. */
  28999. addFallback(rank: number, define: string): void;
  29000. /**
  29001. * Sets the mesh to use CPU skinning when needing to fallback.
  29002. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29003. * @param mesh The mesh to use the fallbacks.
  29004. */
  29005. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29006. /**
  29007. * Checks to see if more fallbacks are still availible.
  29008. */
  29009. readonly isMoreFallbacks: boolean;
  29010. /**
  29011. * Removes the defines that shoould be removed when falling back.
  29012. * @param currentDefines defines the current define statements for the shader.
  29013. * @param effect defines the current effect we try to compile
  29014. * @returns The resulting defines with defines of the current rank removed.
  29015. */
  29016. reduce(currentDefines: string, effect: Effect): string;
  29017. }
  29018. /**
  29019. * Options to be used when creating an effect.
  29020. */
  29021. export class EffectCreationOptions {
  29022. /**
  29023. * Atrributes that will be used in the shader.
  29024. */
  29025. attributes: string[];
  29026. /**
  29027. * Uniform varible names that will be set in the shader.
  29028. */
  29029. uniformsNames: string[];
  29030. /**
  29031. * Uniform buffer varible names that will be set in the shader.
  29032. */
  29033. uniformBuffersNames: string[];
  29034. /**
  29035. * Sampler texture variable names that will be set in the shader.
  29036. */
  29037. samplers: string[];
  29038. /**
  29039. * Define statements that will be set in the shader.
  29040. */
  29041. defines: any;
  29042. /**
  29043. * Possible fallbacks for this effect to improve performance when needed.
  29044. */
  29045. fallbacks: Nullable<EffectFallbacks>;
  29046. /**
  29047. * Callback that will be called when the shader is compiled.
  29048. */
  29049. onCompiled: Nullable<(effect: Effect) => void>;
  29050. /**
  29051. * Callback that will be called if an error occurs during shader compilation.
  29052. */
  29053. onError: Nullable<(effect: Effect, errors: string) => void>;
  29054. /**
  29055. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29056. */
  29057. indexParameters: any;
  29058. /**
  29059. * Max number of lights that can be used in the shader.
  29060. */
  29061. maxSimultaneousLights: number;
  29062. /**
  29063. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29064. */
  29065. transformFeedbackVaryings: Nullable<string[]>;
  29066. }
  29067. /**
  29068. * Effect containing vertex and fragment shader that can be executed on an object.
  29069. */
  29070. export class Effect implements IDisposable {
  29071. /**
  29072. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29073. */
  29074. static ShadersRepository: string;
  29075. /**
  29076. * Name of the effect.
  29077. */
  29078. name: any;
  29079. /**
  29080. * String container all the define statements that should be set on the shader.
  29081. */
  29082. defines: string;
  29083. /**
  29084. * Callback that will be called when the shader is compiled.
  29085. */
  29086. onCompiled: Nullable<(effect: Effect) => void>;
  29087. /**
  29088. * Callback that will be called if an error occurs during shader compilation.
  29089. */
  29090. onError: Nullable<(effect: Effect, errors: string) => void>;
  29091. /**
  29092. * Callback that will be called when effect is bound.
  29093. */
  29094. onBind: Nullable<(effect: Effect) => void>;
  29095. /**
  29096. * Unique ID of the effect.
  29097. */
  29098. uniqueId: number;
  29099. /**
  29100. * Observable that will be called when the shader is compiled.
  29101. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29102. */
  29103. onCompileObservable: Observable<Effect>;
  29104. /**
  29105. * Observable that will be called if an error occurs during shader compilation.
  29106. */
  29107. onErrorObservable: Observable<Effect>;
  29108. /** @hidden */
  29109. _onBindObservable: Nullable<Observable<Effect>>;
  29110. /**
  29111. * Observable that will be called when effect is bound.
  29112. */
  29113. readonly onBindObservable: Observable<Effect>;
  29114. /** @hidden */
  29115. _bonesComputationForcedToCPU: boolean;
  29116. private static _uniqueIdSeed;
  29117. private _engine;
  29118. private _uniformBuffersNames;
  29119. private _uniformsNames;
  29120. private _samplerList;
  29121. private _samplers;
  29122. private _isReady;
  29123. private _compilationError;
  29124. private _attributesNames;
  29125. private _attributes;
  29126. private _uniforms;
  29127. /**
  29128. * Key for the effect.
  29129. * @hidden
  29130. */
  29131. _key: string;
  29132. private _indexParameters;
  29133. private _fallbacks;
  29134. private _vertexSourceCode;
  29135. private _fragmentSourceCode;
  29136. private _vertexSourceCodeOverride;
  29137. private _fragmentSourceCodeOverride;
  29138. private _transformFeedbackVaryings;
  29139. /**
  29140. * Compiled shader to webGL program.
  29141. * @hidden
  29142. */
  29143. _pipelineContext: IPipelineContext;
  29144. private _valueCache;
  29145. private static _baseCache;
  29146. /**
  29147. * Instantiates an effect.
  29148. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29149. * @param baseName Name of the effect.
  29150. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29151. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29152. * @param samplers List of sampler variables that will be passed to the shader.
  29153. * @param engine Engine to be used to render the effect
  29154. * @param defines Define statements to be added to the shader.
  29155. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29156. * @param onCompiled Callback that will be called when the shader is compiled.
  29157. * @param onError Callback that will be called if an error occurs during shader compilation.
  29158. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29159. */
  29160. 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);
  29161. /**
  29162. * Unique key for this effect
  29163. */
  29164. readonly key: string;
  29165. /**
  29166. * If the effect has been compiled and prepared.
  29167. * @returns if the effect is compiled and prepared.
  29168. */
  29169. isReady(): boolean;
  29170. /**
  29171. * The engine the effect was initialized with.
  29172. * @returns the engine.
  29173. */
  29174. getEngine(): Engine;
  29175. /**
  29176. * The pipeline context for this effect
  29177. * @returns the associated pipeline context
  29178. */
  29179. getPipelineContext(): IPipelineContext;
  29180. /**
  29181. * The set of names of attribute variables for the shader.
  29182. * @returns An array of attribute names.
  29183. */
  29184. getAttributesNames(): string[];
  29185. /**
  29186. * Returns the attribute at the given index.
  29187. * @param index The index of the attribute.
  29188. * @returns The location of the attribute.
  29189. */
  29190. getAttributeLocation(index: number): number;
  29191. /**
  29192. * Returns the attribute based on the name of the variable.
  29193. * @param name of the attribute to look up.
  29194. * @returns the attribute location.
  29195. */
  29196. getAttributeLocationByName(name: string): number;
  29197. /**
  29198. * The number of attributes.
  29199. * @returns the numnber of attributes.
  29200. */
  29201. getAttributesCount(): number;
  29202. /**
  29203. * Gets the index of a uniform variable.
  29204. * @param uniformName of the uniform to look up.
  29205. * @returns the index.
  29206. */
  29207. getUniformIndex(uniformName: string): number;
  29208. /**
  29209. * Returns the attribute based on the name of the variable.
  29210. * @param uniformName of the uniform to look up.
  29211. * @returns the location of the uniform.
  29212. */
  29213. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29214. /**
  29215. * Returns an array of sampler variable names
  29216. * @returns The array of sampler variable neames.
  29217. */
  29218. getSamplers(): string[];
  29219. /**
  29220. * The error from the last compilation.
  29221. * @returns the error string.
  29222. */
  29223. getCompilationError(): string;
  29224. /**
  29225. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29226. * @param func The callback to be used.
  29227. */
  29228. executeWhenCompiled(func: (effect: Effect) => void): void;
  29229. private _checkIsReady;
  29230. /** @hidden */
  29231. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29232. /** @hidden */
  29233. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29234. /** @hidden */
  29235. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29236. private _processShaderConversion;
  29237. private _processIncludes;
  29238. private _processPrecision;
  29239. /**
  29240. * Recompiles the webGL program
  29241. * @param vertexSourceCode The source code for the vertex shader.
  29242. * @param fragmentSourceCode The source code for the fragment shader.
  29243. * @param onCompiled Callback called when completed.
  29244. * @param onError Callback called on error.
  29245. * @hidden
  29246. */
  29247. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29248. /**
  29249. * Prepares the effect
  29250. * @hidden
  29251. */
  29252. _prepareEffect(): void;
  29253. /**
  29254. * Checks if the effect is supported. (Must be called after compilation)
  29255. */
  29256. readonly isSupported: boolean;
  29257. /**
  29258. * Binds a texture to the engine to be used as output of the shader.
  29259. * @param channel Name of the output variable.
  29260. * @param texture Texture to bind.
  29261. * @hidden
  29262. */
  29263. _bindTexture(channel: string, texture: InternalTexture): void;
  29264. /**
  29265. * Sets a texture on the engine to be used in the shader.
  29266. * @param channel Name of the sampler variable.
  29267. * @param texture Texture to set.
  29268. */
  29269. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29270. /**
  29271. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29272. * @param channel Name of the sampler variable.
  29273. * @param texture Texture to set.
  29274. */
  29275. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29276. /**
  29277. * Sets an array of textures on the engine to be used in the shader.
  29278. * @param channel Name of the variable.
  29279. * @param textures Textures to set.
  29280. */
  29281. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29282. /**
  29283. * 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)
  29284. * @param channel Name of the sampler variable.
  29285. * @param postProcess Post process to get the input texture from.
  29286. */
  29287. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29288. /**
  29289. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29290. * 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)
  29291. * @param channel Name of the sampler variable.
  29292. * @param postProcess Post process to get the output texture from.
  29293. */
  29294. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29295. /** @hidden */
  29296. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29297. /** @hidden */
  29298. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29299. /** @hidden */
  29300. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29301. /** @hidden */
  29302. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29303. /**
  29304. * Binds a buffer to a uniform.
  29305. * @param buffer Buffer to bind.
  29306. * @param name Name of the uniform variable to bind to.
  29307. */
  29308. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29309. /**
  29310. * Binds block to a uniform.
  29311. * @param blockName Name of the block to bind.
  29312. * @param index Index to bind.
  29313. */
  29314. bindUniformBlock(blockName: string, index: number): void;
  29315. /**
  29316. * Sets an interger value on a uniform variable.
  29317. * @param uniformName Name of the variable.
  29318. * @param value Value to be set.
  29319. * @returns this effect.
  29320. */
  29321. setInt(uniformName: string, value: number): Effect;
  29322. /**
  29323. * Sets an int array on a uniform variable.
  29324. * @param uniformName Name of the variable.
  29325. * @param array array to be set.
  29326. * @returns this effect.
  29327. */
  29328. setIntArray(uniformName: string, array: Int32Array): Effect;
  29329. /**
  29330. * 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)
  29331. * @param uniformName Name of the variable.
  29332. * @param array array to be set.
  29333. * @returns this effect.
  29334. */
  29335. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29336. /**
  29337. * 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)
  29338. * @param uniformName Name of the variable.
  29339. * @param array array to be set.
  29340. * @returns this effect.
  29341. */
  29342. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29343. /**
  29344. * 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)
  29345. * @param uniformName Name of the variable.
  29346. * @param array array to be set.
  29347. * @returns this effect.
  29348. */
  29349. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29350. /**
  29351. * Sets an float array on a uniform variable.
  29352. * @param uniformName Name of the variable.
  29353. * @param array array to be set.
  29354. * @returns this effect.
  29355. */
  29356. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29357. /**
  29358. * 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)
  29359. * @param uniformName Name of the variable.
  29360. * @param array array to be set.
  29361. * @returns this effect.
  29362. */
  29363. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29364. /**
  29365. * 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)
  29366. * @param uniformName Name of the variable.
  29367. * @param array array to be set.
  29368. * @returns this effect.
  29369. */
  29370. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29371. /**
  29372. * 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)
  29373. * @param uniformName Name of the variable.
  29374. * @param array array to be set.
  29375. * @returns this effect.
  29376. */
  29377. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29378. /**
  29379. * Sets an array on a uniform variable.
  29380. * @param uniformName Name of the variable.
  29381. * @param array array to be set.
  29382. * @returns this effect.
  29383. */
  29384. setArray(uniformName: string, array: number[]): Effect;
  29385. /**
  29386. * 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)
  29387. * @param uniformName Name of the variable.
  29388. * @param array array to be set.
  29389. * @returns this effect.
  29390. */
  29391. setArray2(uniformName: string, array: number[]): Effect;
  29392. /**
  29393. * 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)
  29394. * @param uniformName Name of the variable.
  29395. * @param array array to be set.
  29396. * @returns this effect.
  29397. */
  29398. setArray3(uniformName: string, array: number[]): Effect;
  29399. /**
  29400. * 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)
  29401. * @param uniformName Name of the variable.
  29402. * @param array array to be set.
  29403. * @returns this effect.
  29404. */
  29405. setArray4(uniformName: string, array: number[]): Effect;
  29406. /**
  29407. * Sets matrices on a uniform variable.
  29408. * @param uniformName Name of the variable.
  29409. * @param matrices matrices to be set.
  29410. * @returns this effect.
  29411. */
  29412. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29413. /**
  29414. * Sets matrix on a uniform variable.
  29415. * @param uniformName Name of the variable.
  29416. * @param matrix matrix to be set.
  29417. * @returns this effect.
  29418. */
  29419. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29420. /**
  29421. * 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)
  29422. * @param uniformName Name of the variable.
  29423. * @param matrix matrix to be set.
  29424. * @returns this effect.
  29425. */
  29426. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29427. /**
  29428. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29429. * @param uniformName Name of the variable.
  29430. * @param matrix matrix to be set.
  29431. * @returns this effect.
  29432. */
  29433. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29434. /**
  29435. * Sets a float on a uniform variable.
  29436. * @param uniformName Name of the variable.
  29437. * @param value value to be set.
  29438. * @returns this effect.
  29439. */
  29440. setFloat(uniformName: string, value: number): Effect;
  29441. /**
  29442. * Sets a boolean on a uniform variable.
  29443. * @param uniformName Name of the variable.
  29444. * @param bool value to be set.
  29445. * @returns this effect.
  29446. */
  29447. setBool(uniformName: string, bool: boolean): Effect;
  29448. /**
  29449. * Sets a Vector2 on a uniform variable.
  29450. * @param uniformName Name of the variable.
  29451. * @param vector2 vector2 to be set.
  29452. * @returns this effect.
  29453. */
  29454. setVector2(uniformName: string, vector2: Vector2): Effect;
  29455. /**
  29456. * Sets a float2 on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param x First float in float2.
  29459. * @param y Second float in float2.
  29460. * @returns this effect.
  29461. */
  29462. setFloat2(uniformName: string, x: number, y: number): Effect;
  29463. /**
  29464. * Sets a Vector3 on a uniform variable.
  29465. * @param uniformName Name of the variable.
  29466. * @param vector3 Value to be set.
  29467. * @returns this effect.
  29468. */
  29469. setVector3(uniformName: string, vector3: Vector3): Effect;
  29470. /**
  29471. * Sets a float3 on a uniform variable.
  29472. * @param uniformName Name of the variable.
  29473. * @param x First float in float3.
  29474. * @param y Second float in float3.
  29475. * @param z Third float in float3.
  29476. * @returns this effect.
  29477. */
  29478. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29479. /**
  29480. * Sets a Vector4 on a uniform variable.
  29481. * @param uniformName Name of the variable.
  29482. * @param vector4 Value to be set.
  29483. * @returns this effect.
  29484. */
  29485. setVector4(uniformName: string, vector4: Vector4): Effect;
  29486. /**
  29487. * Sets a float4 on a uniform variable.
  29488. * @param uniformName Name of the variable.
  29489. * @param x First float in float4.
  29490. * @param y Second float in float4.
  29491. * @param z Third float in float4.
  29492. * @param w Fourth float in float4.
  29493. * @returns this effect.
  29494. */
  29495. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29496. /**
  29497. * Sets a Color3 on a uniform variable.
  29498. * @param uniformName Name of the variable.
  29499. * @param color3 Value to be set.
  29500. * @returns this effect.
  29501. */
  29502. setColor3(uniformName: string, color3: Color3): Effect;
  29503. /**
  29504. * Sets a Color4 on a uniform variable.
  29505. * @param uniformName Name of the variable.
  29506. * @param color3 Value to be set.
  29507. * @param alpha Alpha value to be set.
  29508. * @returns this effect.
  29509. */
  29510. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29511. /**
  29512. * Sets a Color4 on a uniform variable
  29513. * @param uniformName defines the name of the variable
  29514. * @param color4 defines the value to be set
  29515. * @returns this effect.
  29516. */
  29517. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29518. /** Release all associated resources */
  29519. dispose(): void;
  29520. /**
  29521. * This function will add a new shader to the shader store
  29522. * @param name the name of the shader
  29523. * @param pixelShader optional pixel shader content
  29524. * @param vertexShader optional vertex shader content
  29525. */
  29526. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29527. /**
  29528. * Store of each shader (The can be looked up using effect.key)
  29529. */
  29530. static ShadersStore: {
  29531. [key: string]: string;
  29532. };
  29533. /**
  29534. * Store of each included file for a shader (The can be looked up using effect.key)
  29535. */
  29536. static IncludesShadersStore: {
  29537. [key: string]: string;
  29538. };
  29539. /**
  29540. * Resets the cache of effects.
  29541. */
  29542. static ResetCache(): void;
  29543. }
  29544. }
  29545. declare module BABYLON {
  29546. /**
  29547. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29548. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29549. * 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;
  29550. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29551. */
  29552. export class ColorCurves {
  29553. private _dirty;
  29554. private _tempColor;
  29555. private _globalCurve;
  29556. private _highlightsCurve;
  29557. private _midtonesCurve;
  29558. private _shadowsCurve;
  29559. private _positiveCurve;
  29560. private _negativeCurve;
  29561. private _globalHue;
  29562. private _globalDensity;
  29563. private _globalSaturation;
  29564. private _globalExposure;
  29565. /**
  29566. * Gets the global 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 global 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. globalHue: number;
  29574. /**
  29575. * Gets the global 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 global 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. globalDensity: number;
  29585. /**
  29586. * Gets the global 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 global 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. globalSaturation: number;
  29594. /**
  29595. * Gets the global 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 global 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. globalExposure: number;
  29603. private _highlightsHue;
  29604. private _highlightsDensity;
  29605. private _highlightsSaturation;
  29606. private _highlightsExposure;
  29607. /**
  29608. * Gets the highlights Hue value.
  29609. * 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).
  29610. */
  29611. /**
  29612. * Sets the highlights Hue value.
  29613. * 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).
  29614. */
  29615. highlightsHue: number;
  29616. /**
  29617. * Gets the highlights Density value.
  29618. * 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.
  29619. * Values less than zero provide a filter of opposite hue.
  29620. */
  29621. /**
  29622. * Sets the highlights Density value.
  29623. * 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.
  29624. * Values less than zero provide a filter of opposite hue.
  29625. */
  29626. highlightsDensity: number;
  29627. /**
  29628. * Gets the highlights Saturation value.
  29629. * 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.
  29630. */
  29631. /**
  29632. * Sets the highlights Saturation value.
  29633. * 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.
  29634. */
  29635. highlightsSaturation: number;
  29636. /**
  29637. * Gets the highlights Exposure value.
  29638. * 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.
  29639. */
  29640. /**
  29641. * Sets the highlights Exposure value.
  29642. * 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.
  29643. */
  29644. highlightsExposure: number;
  29645. private _midtonesHue;
  29646. private _midtonesDensity;
  29647. private _midtonesSaturation;
  29648. private _midtonesExposure;
  29649. /**
  29650. * Gets the midtones Hue value.
  29651. * 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).
  29652. */
  29653. /**
  29654. * Sets the midtones Hue value.
  29655. * 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).
  29656. */
  29657. midtonesHue: number;
  29658. /**
  29659. * Gets the midtones Density value.
  29660. * 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.
  29661. * Values less than zero provide a filter of opposite hue.
  29662. */
  29663. /**
  29664. * Sets the midtones Density value.
  29665. * 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.
  29666. * Values less than zero provide a filter of opposite hue.
  29667. */
  29668. midtonesDensity: number;
  29669. /**
  29670. * Gets the midtones Saturation value.
  29671. * 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.
  29672. */
  29673. /**
  29674. * Sets the midtones Saturation value.
  29675. * 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.
  29676. */
  29677. midtonesSaturation: number;
  29678. /**
  29679. * Gets the midtones Exposure value.
  29680. * 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.
  29681. */
  29682. /**
  29683. * Sets the midtones Exposure value.
  29684. * 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.
  29685. */
  29686. midtonesExposure: number;
  29687. private _shadowsHue;
  29688. private _shadowsDensity;
  29689. private _shadowsSaturation;
  29690. private _shadowsExposure;
  29691. /**
  29692. * Gets the shadows Hue value.
  29693. * 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).
  29694. */
  29695. /**
  29696. * Sets the shadows Hue value.
  29697. * 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).
  29698. */
  29699. shadowsHue: number;
  29700. /**
  29701. * Gets the shadows Density value.
  29702. * 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.
  29703. * Values less than zero provide a filter of opposite hue.
  29704. */
  29705. /**
  29706. * Sets the shadows Density value.
  29707. * 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.
  29708. * Values less than zero provide a filter of opposite hue.
  29709. */
  29710. shadowsDensity: number;
  29711. /**
  29712. * Gets the shadows Saturation value.
  29713. * 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.
  29714. */
  29715. /**
  29716. * Sets the shadows Saturation value.
  29717. * 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.
  29718. */
  29719. shadowsSaturation: number;
  29720. /**
  29721. * Gets the shadows Exposure value.
  29722. * 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.
  29723. */
  29724. /**
  29725. * Sets the shadows Exposure value.
  29726. * 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.
  29727. */
  29728. shadowsExposure: number;
  29729. /**
  29730. * Returns the class name
  29731. * @returns The class name
  29732. */
  29733. getClassName(): string;
  29734. /**
  29735. * Binds the color curves to the shader.
  29736. * @param colorCurves The color curve to bind
  29737. * @param effect The effect to bind to
  29738. * @param positiveUniform The positive uniform shader parameter
  29739. * @param neutralUniform The neutral uniform shader parameter
  29740. * @param negativeUniform The negative uniform shader parameter
  29741. */
  29742. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29743. /**
  29744. * Prepare the list of uniforms associated with the ColorCurves effects.
  29745. * @param uniformsList The list of uniforms used in the effect
  29746. */
  29747. static PrepareUniforms(uniformsList: string[]): void;
  29748. /**
  29749. * Returns color grading data based on a hue, density, saturation and exposure value.
  29750. * @param filterHue The hue of the color filter.
  29751. * @param filterDensity The density of the color filter.
  29752. * @param saturation The saturation.
  29753. * @param exposure The exposure.
  29754. * @param result The result data container.
  29755. */
  29756. private getColorGradingDataToRef;
  29757. /**
  29758. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29759. * @param value The input slider value in range [-100,100].
  29760. * @returns Adjusted value.
  29761. */
  29762. private static applyColorGradingSliderNonlinear;
  29763. /**
  29764. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29765. * @param hue The hue (H) input.
  29766. * @param saturation The saturation (S) input.
  29767. * @param brightness The brightness (B) input.
  29768. * @result An RGBA color represented as Vector4.
  29769. */
  29770. private static fromHSBToRef;
  29771. /**
  29772. * Returns a value clamped between min and max
  29773. * @param value The value to clamp
  29774. * @param min The minimum of value
  29775. * @param max The maximum of value
  29776. * @returns The clamped value.
  29777. */
  29778. private static clamp;
  29779. /**
  29780. * Clones the current color curve instance.
  29781. * @return The cloned curves
  29782. */
  29783. clone(): ColorCurves;
  29784. /**
  29785. * Serializes the current color curve instance to a json representation.
  29786. * @return a JSON representation
  29787. */
  29788. serialize(): any;
  29789. /**
  29790. * Parses the color curve from a json representation.
  29791. * @param source the JSON source to parse
  29792. * @return The parsed curves
  29793. */
  29794. static Parse(source: any): ColorCurves;
  29795. }
  29796. }
  29797. declare module BABYLON {
  29798. /**
  29799. * Interface to follow in your material defines to integrate easily the
  29800. * Image proccessing functions.
  29801. * @hidden
  29802. */
  29803. export interface IImageProcessingConfigurationDefines {
  29804. IMAGEPROCESSING: boolean;
  29805. VIGNETTE: boolean;
  29806. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29807. VIGNETTEBLENDMODEOPAQUE: boolean;
  29808. TONEMAPPING: boolean;
  29809. TONEMAPPING_ACES: boolean;
  29810. CONTRAST: boolean;
  29811. EXPOSURE: boolean;
  29812. COLORCURVES: boolean;
  29813. COLORGRADING: boolean;
  29814. COLORGRADING3D: boolean;
  29815. SAMPLER3DGREENDEPTH: boolean;
  29816. SAMPLER3DBGRMAP: boolean;
  29817. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29818. }
  29819. /**
  29820. * @hidden
  29821. */
  29822. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29823. IMAGEPROCESSING: boolean;
  29824. VIGNETTE: boolean;
  29825. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29826. VIGNETTEBLENDMODEOPAQUE: boolean;
  29827. TONEMAPPING: boolean;
  29828. TONEMAPPING_ACES: boolean;
  29829. CONTRAST: boolean;
  29830. COLORCURVES: boolean;
  29831. COLORGRADING: boolean;
  29832. COLORGRADING3D: boolean;
  29833. SAMPLER3DGREENDEPTH: boolean;
  29834. SAMPLER3DBGRMAP: boolean;
  29835. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29836. EXPOSURE: boolean;
  29837. constructor();
  29838. }
  29839. /**
  29840. * This groups together the common properties used for image processing either in direct forward pass
  29841. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29842. * or not.
  29843. */
  29844. export class ImageProcessingConfiguration {
  29845. /**
  29846. * Default tone mapping applied in BabylonJS.
  29847. */
  29848. static readonly TONEMAPPING_STANDARD: number;
  29849. /**
  29850. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29851. * to other engines rendering to increase portability.
  29852. */
  29853. static readonly TONEMAPPING_ACES: number;
  29854. /**
  29855. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29856. */
  29857. colorCurves: Nullable<ColorCurves>;
  29858. private _colorCurvesEnabled;
  29859. /**
  29860. * Gets wether the color curves effect is enabled.
  29861. */
  29862. /**
  29863. * Sets wether the color curves effect is enabled.
  29864. */
  29865. colorCurvesEnabled: boolean;
  29866. private _colorGradingTexture;
  29867. /**
  29868. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29869. */
  29870. /**
  29871. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29872. */
  29873. colorGradingTexture: Nullable<BaseTexture>;
  29874. private _colorGradingEnabled;
  29875. /**
  29876. * Gets wether the color grading effect is enabled.
  29877. */
  29878. /**
  29879. * Sets wether the color grading effect is enabled.
  29880. */
  29881. colorGradingEnabled: boolean;
  29882. private _colorGradingWithGreenDepth;
  29883. /**
  29884. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29885. */
  29886. /**
  29887. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29888. */
  29889. colorGradingWithGreenDepth: boolean;
  29890. private _colorGradingBGR;
  29891. /**
  29892. * Gets wether the color grading texture contains BGR values.
  29893. */
  29894. /**
  29895. * Sets wether the color grading texture contains BGR values.
  29896. */
  29897. colorGradingBGR: boolean;
  29898. /** @hidden */
  29899. _exposure: number;
  29900. /**
  29901. * Gets the Exposure used in the effect.
  29902. */
  29903. /**
  29904. * Sets the Exposure used in the effect.
  29905. */
  29906. exposure: number;
  29907. private _toneMappingEnabled;
  29908. /**
  29909. * Gets wether the tone mapping effect is enabled.
  29910. */
  29911. /**
  29912. * Sets wether the tone mapping effect is enabled.
  29913. */
  29914. toneMappingEnabled: boolean;
  29915. private _toneMappingType;
  29916. /**
  29917. * Gets the type of tone mapping effect.
  29918. */
  29919. /**
  29920. * Sets the type of tone mapping effect used in BabylonJS.
  29921. */
  29922. toneMappingType: number;
  29923. protected _contrast: number;
  29924. /**
  29925. * Gets the contrast used in the effect.
  29926. */
  29927. /**
  29928. * Sets the contrast used in the effect.
  29929. */
  29930. contrast: number;
  29931. /**
  29932. * Vignette stretch size.
  29933. */
  29934. vignetteStretch: number;
  29935. /**
  29936. * Vignette centre X Offset.
  29937. */
  29938. vignetteCentreX: number;
  29939. /**
  29940. * Vignette centre Y Offset.
  29941. */
  29942. vignetteCentreY: number;
  29943. /**
  29944. * Vignette weight or intensity of the vignette effect.
  29945. */
  29946. vignetteWeight: number;
  29947. /**
  29948. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29949. * if vignetteEnabled is set to true.
  29950. */
  29951. vignetteColor: Color4;
  29952. /**
  29953. * Camera field of view used by the Vignette effect.
  29954. */
  29955. vignetteCameraFov: number;
  29956. private _vignetteBlendMode;
  29957. /**
  29958. * Gets the vignette blend mode allowing different kind of effect.
  29959. */
  29960. /**
  29961. * Sets the vignette blend mode allowing different kind of effect.
  29962. */
  29963. vignetteBlendMode: number;
  29964. private _vignetteEnabled;
  29965. /**
  29966. * Gets wether the vignette effect is enabled.
  29967. */
  29968. /**
  29969. * Sets wether the vignette effect is enabled.
  29970. */
  29971. vignetteEnabled: boolean;
  29972. private _applyByPostProcess;
  29973. /**
  29974. * Gets wether the image processing is applied through a post process or not.
  29975. */
  29976. /**
  29977. * Sets wether the image processing is applied through a post process or not.
  29978. */
  29979. applyByPostProcess: boolean;
  29980. private _isEnabled;
  29981. /**
  29982. * Gets wether the image processing is enabled or not.
  29983. */
  29984. /**
  29985. * Sets wether the image processing is enabled or not.
  29986. */
  29987. isEnabled: boolean;
  29988. /**
  29989. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29990. */
  29991. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29992. /**
  29993. * Method called each time the image processing information changes requires to recompile the effect.
  29994. */
  29995. protected _updateParameters(): void;
  29996. /**
  29997. * Gets the current class name.
  29998. * @return "ImageProcessingConfiguration"
  29999. */
  30000. getClassName(): string;
  30001. /**
  30002. * Prepare the list of uniforms associated with the Image Processing effects.
  30003. * @param uniforms The list of uniforms used in the effect
  30004. * @param defines the list of defines currently in use
  30005. */
  30006. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30007. /**
  30008. * Prepare the list of samplers associated with the Image Processing effects.
  30009. * @param samplersList The list of uniforms used in the effect
  30010. * @param defines the list of defines currently in use
  30011. */
  30012. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30013. /**
  30014. * Prepare the list of defines associated to the shader.
  30015. * @param defines the list of defines to complete
  30016. * @param forPostProcess Define if we are currently in post process mode or not
  30017. */
  30018. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30019. /**
  30020. * Returns true if all the image processing information are ready.
  30021. * @returns True if ready, otherwise, false
  30022. */
  30023. isReady(): boolean;
  30024. /**
  30025. * Binds the image processing to the shader.
  30026. * @param effect The effect to bind to
  30027. * @param aspectRatio Define the current aspect ratio of the effect
  30028. */
  30029. bind(effect: Effect, aspectRatio?: number): void;
  30030. /**
  30031. * Clones the current image processing instance.
  30032. * @return The cloned image processing
  30033. */
  30034. clone(): ImageProcessingConfiguration;
  30035. /**
  30036. * Serializes the current image processing instance to a json representation.
  30037. * @return a JSON representation
  30038. */
  30039. serialize(): any;
  30040. /**
  30041. * Parses the image processing from a json representation.
  30042. * @param source the JSON source to parse
  30043. * @return The parsed image processing
  30044. */
  30045. static Parse(source: any): ImageProcessingConfiguration;
  30046. private static _VIGNETTEMODE_MULTIPLY;
  30047. private static _VIGNETTEMODE_OPAQUE;
  30048. /**
  30049. * Used to apply the vignette as a mix with the pixel color.
  30050. */
  30051. static readonly VIGNETTEMODE_MULTIPLY: number;
  30052. /**
  30053. * Used to apply the vignette as a replacement of the pixel color.
  30054. */
  30055. static readonly VIGNETTEMODE_OPAQUE: number;
  30056. }
  30057. }
  30058. declare module BABYLON {
  30059. /**
  30060. * This represents all the required information to add a fresnel effect on a material:
  30061. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30062. */
  30063. export class FresnelParameters {
  30064. private _isEnabled;
  30065. /**
  30066. * Define if the fresnel effect is enable or not.
  30067. */
  30068. isEnabled: boolean;
  30069. /**
  30070. * Define the color used on edges (grazing angle)
  30071. */
  30072. leftColor: Color3;
  30073. /**
  30074. * Define the color used on center
  30075. */
  30076. rightColor: Color3;
  30077. /**
  30078. * Define bias applied to computed fresnel term
  30079. */
  30080. bias: number;
  30081. /**
  30082. * Defined the power exponent applied to fresnel term
  30083. */
  30084. power: number;
  30085. /**
  30086. * Clones the current fresnel and its valuues
  30087. * @returns a clone fresnel configuration
  30088. */
  30089. clone(): FresnelParameters;
  30090. /**
  30091. * Serializes the current fresnel parameters to a JSON representation.
  30092. * @return the JSON serialization
  30093. */
  30094. serialize(): any;
  30095. /**
  30096. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30097. * @param parsedFresnelParameters Define the JSON representation
  30098. * @returns the parsed parameters
  30099. */
  30100. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30101. }
  30102. }
  30103. declare module BABYLON {
  30104. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30105. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30106. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30107. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30108. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30109. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30110. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30111. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30112. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30113. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30114. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30115. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30116. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30117. /**
  30118. * Decorator used to define property that can be serialized as reference to a camera
  30119. * @param sourceName defines the name of the property to decorate
  30120. */
  30121. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30122. /**
  30123. * Class used to help serialization objects
  30124. */
  30125. export class SerializationHelper {
  30126. /** hidden */
  30127. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30128. /** hidden */
  30129. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30130. /** hidden */
  30131. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30132. /** hidden */
  30133. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30134. /**
  30135. * Appends the serialized animations from the source animations
  30136. * @param source Source containing the animations
  30137. * @param destination Target to store the animations
  30138. */
  30139. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30140. /**
  30141. * Static function used to serialized a specific entity
  30142. * @param entity defines the entity to serialize
  30143. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30144. * @returns a JSON compatible object representing the serialization of the entity
  30145. */
  30146. static Serialize<T>(entity: T, serializationObject?: any): any;
  30147. /**
  30148. * Creates a new entity from a serialization data object
  30149. * @param creationFunction defines a function used to instanciated the new entity
  30150. * @param source defines the source serialization data
  30151. * @param scene defines the hosting scene
  30152. * @param rootUrl defines the root url for resources
  30153. * @returns a new entity
  30154. */
  30155. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30156. /**
  30157. * Clones an object
  30158. * @param creationFunction defines the function used to instanciate the new object
  30159. * @param source defines the source object
  30160. * @returns the cloned object
  30161. */
  30162. static Clone<T>(creationFunction: () => T, source: T): T;
  30163. /**
  30164. * Instanciates a new object based on a source one (some data will be shared between both object)
  30165. * @param creationFunction defines the function used to instanciate the new object
  30166. * @param source defines the source object
  30167. * @returns the new object
  30168. */
  30169. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30170. }
  30171. }
  30172. declare module BABYLON {
  30173. /**
  30174. * This is the base class of all the camera used in the application.
  30175. * @see http://doc.babylonjs.com/features/cameras
  30176. */
  30177. export class Camera extends Node {
  30178. /** @hidden */
  30179. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30180. /**
  30181. * This is the default projection mode used by the cameras.
  30182. * It helps recreating a feeling of perspective and better appreciate depth.
  30183. * This is the best way to simulate real life cameras.
  30184. */
  30185. static readonly PERSPECTIVE_CAMERA: number;
  30186. /**
  30187. * This helps creating camera with an orthographic mode.
  30188. * 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.
  30189. */
  30190. static readonly ORTHOGRAPHIC_CAMERA: number;
  30191. /**
  30192. * This is the default FOV mode for perspective cameras.
  30193. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30194. */
  30195. static readonly FOVMODE_VERTICAL_FIXED: number;
  30196. /**
  30197. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30198. */
  30199. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30200. /**
  30201. * This specifies ther is no need for a camera rig.
  30202. * Basically only one eye is rendered corresponding to the camera.
  30203. */
  30204. static readonly RIG_MODE_NONE: number;
  30205. /**
  30206. * Simulates a camera Rig with one blue eye and one red eye.
  30207. * This can be use with 3d blue and red glasses.
  30208. */
  30209. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30210. /**
  30211. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30212. */
  30213. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30214. /**
  30215. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30216. */
  30217. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30218. /**
  30219. * Defines that both eyes of the camera will be rendered over under each other.
  30220. */
  30221. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30222. /**
  30223. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30224. */
  30225. static readonly RIG_MODE_VR: number;
  30226. /**
  30227. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30228. */
  30229. static readonly RIG_MODE_WEBVR: number;
  30230. /**
  30231. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30232. */
  30233. static readonly RIG_MODE_CUSTOM: number;
  30234. /**
  30235. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30236. */
  30237. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30238. /**
  30239. * Define the input manager associated with the camera.
  30240. */
  30241. inputs: CameraInputsManager<Camera>;
  30242. /** @hidden */
  30243. _position: Vector3;
  30244. /**
  30245. * Define the current local position of the camera in the scene
  30246. */
  30247. position: Vector3;
  30248. /**
  30249. * The vector the camera should consider as up.
  30250. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30251. */
  30252. upVector: Vector3;
  30253. /**
  30254. * Define the current limit on the left side for an orthographic camera
  30255. * In scene unit
  30256. */
  30257. orthoLeft: Nullable<number>;
  30258. /**
  30259. * Define the current limit on the right side for an orthographic camera
  30260. * In scene unit
  30261. */
  30262. orthoRight: Nullable<number>;
  30263. /**
  30264. * Define the current limit on the bottom side for an orthographic camera
  30265. * In scene unit
  30266. */
  30267. orthoBottom: Nullable<number>;
  30268. /**
  30269. * Define the current limit on the top side for an orthographic camera
  30270. * In scene unit
  30271. */
  30272. orthoTop: Nullable<number>;
  30273. /**
  30274. * Field Of View is set in Radians. (default is 0.8)
  30275. */
  30276. fov: number;
  30277. /**
  30278. * Define the minimum distance the camera can see from.
  30279. * This is important to note that the depth buffer are not infinite and the closer it starts
  30280. * the more your scene might encounter depth fighting issue.
  30281. */
  30282. minZ: number;
  30283. /**
  30284. * Define the maximum distance the camera can see to.
  30285. * This is important to note that the depth buffer are not infinite and the further it end
  30286. * the more your scene might encounter depth fighting issue.
  30287. */
  30288. maxZ: number;
  30289. /**
  30290. * Define the default inertia of the camera.
  30291. * This helps giving a smooth feeling to the camera movement.
  30292. */
  30293. inertia: number;
  30294. /**
  30295. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30296. */
  30297. mode: number;
  30298. /**
  30299. * Define wether the camera is intermediate.
  30300. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30301. */
  30302. isIntermediate: boolean;
  30303. /**
  30304. * Define the viewport of the camera.
  30305. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30306. */
  30307. viewport: Viewport;
  30308. /**
  30309. * Restricts the camera to viewing objects with the same layerMask.
  30310. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30311. */
  30312. layerMask: number;
  30313. /**
  30314. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30315. */
  30316. fovMode: number;
  30317. /**
  30318. * Rig mode of the camera.
  30319. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30320. * This is normally controlled byt the camera themselves as internal use.
  30321. */
  30322. cameraRigMode: number;
  30323. /**
  30324. * Defines the distance between both "eyes" in case of a RIG
  30325. */
  30326. interaxialDistance: number;
  30327. /**
  30328. * Defines if stereoscopic rendering is done side by side or over under.
  30329. */
  30330. isStereoscopicSideBySide: boolean;
  30331. /**
  30332. * 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
  30333. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30334. * else in the scene.
  30335. */
  30336. customRenderTargets: RenderTargetTexture[];
  30337. /**
  30338. * When set, the camera will render to this render target instead of the default canvas
  30339. */
  30340. outputRenderTarget: Nullable<RenderTargetTexture>;
  30341. /**
  30342. * Observable triggered when the camera view matrix has changed.
  30343. */
  30344. onViewMatrixChangedObservable: Observable<Camera>;
  30345. /**
  30346. * Observable triggered when the camera Projection matrix has changed.
  30347. */
  30348. onProjectionMatrixChangedObservable: Observable<Camera>;
  30349. /**
  30350. * Observable triggered when the inputs have been processed.
  30351. */
  30352. onAfterCheckInputsObservable: Observable<Camera>;
  30353. /**
  30354. * Observable triggered when reset has been called and applied to the camera.
  30355. */
  30356. onRestoreStateObservable: Observable<Camera>;
  30357. /** @hidden */
  30358. _cameraRigParams: any;
  30359. /** @hidden */
  30360. _rigCameras: Camera[];
  30361. /** @hidden */
  30362. _rigPostProcess: Nullable<PostProcess>;
  30363. protected _webvrViewMatrix: Matrix;
  30364. /** @hidden */
  30365. _skipRendering: boolean;
  30366. /** @hidden */
  30367. _projectionMatrix: Matrix;
  30368. /** @hidden */
  30369. _postProcesses: Nullable<PostProcess>[];
  30370. /** @hidden */
  30371. _activeMeshes: SmartArray<AbstractMesh>;
  30372. protected _globalPosition: Vector3;
  30373. /** hidden */
  30374. _computedViewMatrix: Matrix;
  30375. private _doNotComputeProjectionMatrix;
  30376. private _transformMatrix;
  30377. private _frustumPlanes;
  30378. private _refreshFrustumPlanes;
  30379. private _storedFov;
  30380. private _stateStored;
  30381. /**
  30382. * Instantiates a new camera object.
  30383. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30384. * @see http://doc.babylonjs.com/features/cameras
  30385. * @param name Defines the name of the camera in the scene
  30386. * @param position Defines the position of the camera
  30387. * @param scene Defines the scene the camera belongs too
  30388. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30389. */
  30390. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30391. /**
  30392. * Store current camera state (fov, position, etc..)
  30393. * @returns the camera
  30394. */
  30395. storeState(): Camera;
  30396. /**
  30397. * Restores the camera state values if it has been stored. You must call storeState() first
  30398. */
  30399. protected _restoreStateValues(): boolean;
  30400. /**
  30401. * Restored camera state. You must call storeState() first.
  30402. * @returns true if restored and false otherwise
  30403. */
  30404. restoreState(): boolean;
  30405. /**
  30406. * Gets the class name of the camera.
  30407. * @returns the class name
  30408. */
  30409. getClassName(): string;
  30410. /** @hidden */
  30411. readonly _isCamera: boolean;
  30412. /**
  30413. * Gets a string representation of the camera useful for debug purpose.
  30414. * @param fullDetails Defines that a more verboe level of logging is required
  30415. * @returns the string representation
  30416. */
  30417. toString(fullDetails?: boolean): string;
  30418. /**
  30419. * Gets the current world space position of the camera.
  30420. */
  30421. readonly globalPosition: Vector3;
  30422. /**
  30423. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30424. * @returns the active meshe list
  30425. */
  30426. getActiveMeshes(): SmartArray<AbstractMesh>;
  30427. /**
  30428. * Check wether a mesh is part of the current active mesh list of the camera
  30429. * @param mesh Defines the mesh to check
  30430. * @returns true if active, false otherwise
  30431. */
  30432. isActiveMesh(mesh: Mesh): boolean;
  30433. /**
  30434. * Is this camera ready to be used/rendered
  30435. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30436. * @return true if the camera is ready
  30437. */
  30438. isReady(completeCheck?: boolean): boolean;
  30439. /** @hidden */
  30440. _initCache(): void;
  30441. /** @hidden */
  30442. _updateCache(ignoreParentClass?: boolean): void;
  30443. /** @hidden */
  30444. _isSynchronized(): boolean;
  30445. /** @hidden */
  30446. _isSynchronizedViewMatrix(): boolean;
  30447. /** @hidden */
  30448. _isSynchronizedProjectionMatrix(): boolean;
  30449. /**
  30450. * Attach the input controls to a specific dom element to get the input from.
  30451. * @param element Defines the element the controls should be listened from
  30452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30453. */
  30454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30455. /**
  30456. * Detach the current controls from the specified dom element.
  30457. * @param element Defines the element to stop listening the inputs from
  30458. */
  30459. detachControl(element: HTMLElement): void;
  30460. /**
  30461. * Update the camera state according to the different inputs gathered during the frame.
  30462. */
  30463. update(): void;
  30464. /** @hidden */
  30465. _checkInputs(): void;
  30466. /** @hidden */
  30467. readonly rigCameras: Camera[];
  30468. /**
  30469. * Gets the post process used by the rig cameras
  30470. */
  30471. readonly rigPostProcess: Nullable<PostProcess>;
  30472. /**
  30473. * Internal, gets the first post proces.
  30474. * @returns the first post process to be run on this camera.
  30475. */
  30476. _getFirstPostProcess(): Nullable<PostProcess>;
  30477. private _cascadePostProcessesToRigCams;
  30478. /**
  30479. * Attach a post process to the camera.
  30480. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30481. * @param postProcess The post process to attach to the camera
  30482. * @param insertAt The position of the post process in case several of them are in use in the scene
  30483. * @returns the position the post process has been inserted at
  30484. */
  30485. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30486. /**
  30487. * Detach a post process to the camera.
  30488. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30489. * @param postProcess The post process to detach from the camera
  30490. */
  30491. detachPostProcess(postProcess: PostProcess): void;
  30492. /**
  30493. * Gets the current world matrix of the camera
  30494. */
  30495. getWorldMatrix(): Matrix;
  30496. /** @hidden */
  30497. _getViewMatrix(): Matrix;
  30498. /**
  30499. * Gets the current view matrix of the camera.
  30500. * @param force forces the camera to recompute the matrix without looking at the cached state
  30501. * @returns the view matrix
  30502. */
  30503. getViewMatrix(force?: boolean): Matrix;
  30504. /**
  30505. * Freeze the projection matrix.
  30506. * It will prevent the cache check of the camera projection compute and can speed up perf
  30507. * if no parameter of the camera are meant to change
  30508. * @param projection Defines manually a projection if necessary
  30509. */
  30510. freezeProjectionMatrix(projection?: Matrix): void;
  30511. /**
  30512. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30513. */
  30514. unfreezeProjectionMatrix(): void;
  30515. /**
  30516. * Gets the current projection matrix of the camera.
  30517. * @param force forces the camera to recompute the matrix without looking at the cached state
  30518. * @returns the projection matrix
  30519. */
  30520. getProjectionMatrix(force?: boolean): Matrix;
  30521. /**
  30522. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30523. * @returns a Matrix
  30524. */
  30525. getTransformationMatrix(): Matrix;
  30526. private _updateFrustumPlanes;
  30527. /**
  30528. * Checks if a cullable object (mesh...) is in the camera frustum
  30529. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30530. * @param target The object to check
  30531. * @returns true if the object is in frustum otherwise false
  30532. */
  30533. isInFrustum(target: ICullable): boolean;
  30534. /**
  30535. * Checks if a cullable object (mesh...) is in the camera frustum
  30536. * Unlike isInFrustum this cheks the full bounding box
  30537. * @param target The object to check
  30538. * @returns true if the object is in frustum otherwise false
  30539. */
  30540. isCompletelyInFrustum(target: ICullable): boolean;
  30541. /**
  30542. * Gets a ray in the forward direction from the camera.
  30543. * @param length Defines the length of the ray to create
  30544. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30545. * @param origin Defines the start point of the ray which defaults to the camera position
  30546. * @returns the forward ray
  30547. */
  30548. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30549. /**
  30550. * Releases resources associated with this node.
  30551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30553. */
  30554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30555. /** @hidden */
  30556. _isLeftCamera: boolean;
  30557. /**
  30558. * Gets the left camera of a rig setup in case of Rigged Camera
  30559. */
  30560. readonly isLeftCamera: boolean;
  30561. /** @hidden */
  30562. _isRightCamera: boolean;
  30563. /**
  30564. * Gets the right camera of a rig setup in case of Rigged Camera
  30565. */
  30566. readonly isRightCamera: boolean;
  30567. /**
  30568. * Gets the left camera of a rig setup in case of Rigged Camera
  30569. */
  30570. readonly leftCamera: Nullable<FreeCamera>;
  30571. /**
  30572. * Gets the right camera of a rig setup in case of Rigged Camera
  30573. */
  30574. readonly rightCamera: Nullable<FreeCamera>;
  30575. /**
  30576. * Gets the left camera target of a rig setup in case of Rigged Camera
  30577. * @returns the target position
  30578. */
  30579. getLeftTarget(): Nullable<Vector3>;
  30580. /**
  30581. * Gets the right camera target of a rig setup in case of Rigged Camera
  30582. * @returns the target position
  30583. */
  30584. getRightTarget(): Nullable<Vector3>;
  30585. /**
  30586. * @hidden
  30587. */
  30588. setCameraRigMode(mode: number, rigParams: any): void;
  30589. /** @hidden */
  30590. static _setStereoscopicRigMode(camera: Camera): void;
  30591. /** @hidden */
  30592. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30593. /** @hidden */
  30594. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30595. /** @hidden */
  30596. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30597. /** @hidden */
  30598. _getVRProjectionMatrix(): Matrix;
  30599. protected _updateCameraRotationMatrix(): void;
  30600. protected _updateWebVRCameraRotationMatrix(): void;
  30601. /**
  30602. * This function MUST be overwritten by the different WebVR cameras available.
  30603. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30604. * @hidden
  30605. */
  30606. _getWebVRProjectionMatrix(): Matrix;
  30607. /**
  30608. * This function MUST be overwritten by the different WebVR cameras available.
  30609. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30610. * @hidden
  30611. */
  30612. _getWebVRViewMatrix(): Matrix;
  30613. /** @hidden */
  30614. setCameraRigParameter(name: string, value: any): void;
  30615. /**
  30616. * needs to be overridden by children so sub has required properties to be copied
  30617. * @hidden
  30618. */
  30619. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30620. /**
  30621. * May need to be overridden by children
  30622. * @hidden
  30623. */
  30624. _updateRigCameras(): void;
  30625. /** @hidden */
  30626. _setupInputs(): void;
  30627. /**
  30628. * Serialiaze the camera setup to a json represention
  30629. * @returns the JSON representation
  30630. */
  30631. serialize(): any;
  30632. /**
  30633. * Clones the current camera.
  30634. * @param name The cloned camera name
  30635. * @returns the cloned camera
  30636. */
  30637. clone(name: string): Camera;
  30638. /**
  30639. * Gets the direction of the camera relative to a given local axis.
  30640. * @param localAxis Defines the reference axis to provide a relative direction.
  30641. * @return the direction
  30642. */
  30643. getDirection(localAxis: Vector3): Vector3;
  30644. /**
  30645. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30646. * @param localAxis Defines the reference axis to provide a relative direction.
  30647. * @param result Defines the vector to store the result in
  30648. */
  30649. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30650. /**
  30651. * Gets a camera constructor for a given camera type
  30652. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30653. * @param name The name of the camera the result will be able to instantiate
  30654. * @param scene The scene the result will construct the camera in
  30655. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30656. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30657. * @returns a factory method to construc the camera
  30658. */
  30659. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30660. /**
  30661. * Compute the world matrix of the camera.
  30662. * @returns the camera workd matrix
  30663. */
  30664. computeWorldMatrix(): Matrix;
  30665. /**
  30666. * Parse a JSON and creates the camera from the parsed information
  30667. * @param parsedCamera The JSON to parse
  30668. * @param scene The scene to instantiate the camera in
  30669. * @returns the newly constructed camera
  30670. */
  30671. static Parse(parsedCamera: any, scene: Scene): Camera;
  30672. }
  30673. }
  30674. declare module BABYLON {
  30675. /**
  30676. * Interface for any object that can request an animation frame
  30677. */
  30678. export interface ICustomAnimationFrameRequester {
  30679. /**
  30680. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30681. */
  30682. renderFunction?: Function;
  30683. /**
  30684. * Called to request the next frame to render to
  30685. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30686. */
  30687. requestAnimationFrame: Function;
  30688. /**
  30689. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30690. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30691. */
  30692. requestID?: number;
  30693. }
  30694. /**
  30695. * Interface containing an array of animations
  30696. */
  30697. export interface IAnimatable {
  30698. /**
  30699. * Array of animations
  30700. */
  30701. animations: Nullable<Array<Animation>>;
  30702. }
  30703. /** Interface used by value gradients (color, factor, ...) */
  30704. export interface IValueGradient {
  30705. /**
  30706. * Gets or sets the gradient value (between 0 and 1)
  30707. */
  30708. gradient: number;
  30709. }
  30710. /** Class used to store color4 gradient */
  30711. export class ColorGradient implements IValueGradient {
  30712. /**
  30713. * Gets or sets the gradient value (between 0 and 1)
  30714. */
  30715. gradient: number;
  30716. /**
  30717. * Gets or sets first associated color
  30718. */
  30719. color1: Color4;
  30720. /**
  30721. * Gets or sets second associated color
  30722. */
  30723. color2?: Color4;
  30724. /**
  30725. * Will get a color picked randomly between color1 and color2.
  30726. * If color2 is undefined then color1 will be used
  30727. * @param result defines the target Color4 to store the result in
  30728. */
  30729. getColorToRef(result: Color4): void;
  30730. }
  30731. /** Class used to store color 3 gradient */
  30732. export class Color3Gradient implements IValueGradient {
  30733. /**
  30734. * Gets or sets the gradient value (between 0 and 1)
  30735. */
  30736. gradient: number;
  30737. /**
  30738. * Gets or sets the associated color
  30739. */
  30740. color: Color3;
  30741. }
  30742. /** Class used to store factor gradient */
  30743. export class FactorGradient implements IValueGradient {
  30744. /**
  30745. * Gets or sets the gradient value (between 0 and 1)
  30746. */
  30747. gradient: number;
  30748. /**
  30749. * Gets or sets first associated factor
  30750. */
  30751. factor1: number;
  30752. /**
  30753. * Gets or sets second associated factor
  30754. */
  30755. factor2?: number;
  30756. /**
  30757. * Will get a number picked randomly between factor1 and factor2.
  30758. * If factor2 is undefined then factor1 will be used
  30759. * @returns the picked number
  30760. */
  30761. getFactor(): number;
  30762. }
  30763. /**
  30764. * @ignore
  30765. * Application error to support additional information when loading a file
  30766. */
  30767. export class LoadFileError extends Error {
  30768. /** defines the optional web request */
  30769. request?: WebRequest | undefined;
  30770. private static _setPrototypeOf;
  30771. /**
  30772. * Creates a new LoadFileError
  30773. * @param message defines the message of the error
  30774. * @param request defines the optional web request
  30775. */
  30776. constructor(message: string,
  30777. /** defines the optional web request */
  30778. request?: WebRequest | undefined);
  30779. }
  30780. /**
  30781. * Class used to define a retry strategy when error happens while loading assets
  30782. */
  30783. export class RetryStrategy {
  30784. /**
  30785. * Function used to defines an exponential back off strategy
  30786. * @param maxRetries defines the maximum number of retries (3 by default)
  30787. * @param baseInterval defines the interval between retries
  30788. * @returns the strategy function to use
  30789. */
  30790. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30791. }
  30792. /**
  30793. * File request interface
  30794. */
  30795. export interface IFileRequest {
  30796. /**
  30797. * Raised when the request is complete (success or error).
  30798. */
  30799. onCompleteObservable: Observable<IFileRequest>;
  30800. /**
  30801. * Aborts the request for a file.
  30802. */
  30803. abort: () => void;
  30804. }
  30805. /**
  30806. * Class containing a set of static utilities functions
  30807. */
  30808. export class Tools {
  30809. /**
  30810. * Gets or sets the base URL to use to load assets
  30811. */
  30812. static BaseUrl: string;
  30813. /**
  30814. * Enable/Disable Custom HTTP Request Headers globally.
  30815. * default = false
  30816. * @see CustomRequestHeaders
  30817. */
  30818. static UseCustomRequestHeaders: boolean;
  30819. /**
  30820. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30821. * i.e. when loading files, where the server/service expects an Authorization header
  30822. */
  30823. static CustomRequestHeaders: {
  30824. [key: string]: string;
  30825. };
  30826. /**
  30827. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30828. */
  30829. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30830. /**
  30831. * Default behaviour for cors in the application.
  30832. * It can be a string if the expected behavior is identical in the entire app.
  30833. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30834. */
  30835. static CorsBehavior: string | ((url: string | string[]) => string);
  30836. /**
  30837. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30838. * @ignorenaming
  30839. */
  30840. static UseFallbackTexture: boolean;
  30841. /**
  30842. * Use this object to register external classes like custom textures or material
  30843. * to allow the laoders to instantiate them
  30844. */
  30845. static RegisteredExternalClasses: {
  30846. [key: string]: Object;
  30847. };
  30848. /**
  30849. * Texture content used if a texture cannot loaded
  30850. * @ignorenaming
  30851. */
  30852. static fallbackTexture: string;
  30853. /**
  30854. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30855. * @param u defines the coordinate on X axis
  30856. * @param v defines the coordinate on Y axis
  30857. * @param width defines the width of the source data
  30858. * @param height defines the height of the source data
  30859. * @param pixels defines the source byte array
  30860. * @param color defines the output color
  30861. */
  30862. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30863. /**
  30864. * Interpolates between a and b via alpha
  30865. * @param a The lower value (returned when alpha = 0)
  30866. * @param b The upper value (returned when alpha = 1)
  30867. * @param alpha The interpolation-factor
  30868. * @return The mixed value
  30869. */
  30870. static Mix(a: number, b: number, alpha: number): number;
  30871. /**
  30872. * Tries to instantiate a new object from a given class name
  30873. * @param className defines the class name to instantiate
  30874. * @returns the new object or null if the system was not able to do the instantiation
  30875. */
  30876. static Instantiate(className: string): any;
  30877. /**
  30878. * Provides a slice function that will work even on IE
  30879. * @param data defines the array to slice
  30880. * @param start defines the start of the data (optional)
  30881. * @param end defines the end of the data (optional)
  30882. * @returns the new sliced array
  30883. */
  30884. static Slice<T>(data: T, start?: number, end?: number): T;
  30885. /**
  30886. * Polyfill for setImmediate
  30887. * @param action defines the action to execute after the current execution block
  30888. */
  30889. static SetImmediate(action: () => void): void;
  30890. /**
  30891. * Function indicating if a number is an exponent of 2
  30892. * @param value defines the value to test
  30893. * @returns true if the value is an exponent of 2
  30894. */
  30895. static IsExponentOfTwo(value: number): boolean;
  30896. private static _tmpFloatArray;
  30897. /**
  30898. * Returns the nearest 32-bit single precision float representation of a Number
  30899. * @param value A Number. If the parameter is of a different type, it will get converted
  30900. * to a number or to NaN if it cannot be converted
  30901. * @returns number
  30902. */
  30903. static FloatRound(value: number): number;
  30904. /**
  30905. * Find the next highest power of two.
  30906. * @param x Number to start search from.
  30907. * @return Next highest power of two.
  30908. */
  30909. static CeilingPOT(x: number): number;
  30910. /**
  30911. * Find the next lowest power of two.
  30912. * @param x Number to start search from.
  30913. * @return Next lowest power of two.
  30914. */
  30915. static FloorPOT(x: number): number;
  30916. /**
  30917. * Find the nearest power of two.
  30918. * @param x Number to start search from.
  30919. * @return Next nearest power of two.
  30920. */
  30921. static NearestPOT(x: number): number;
  30922. /**
  30923. * Get the closest exponent of two
  30924. * @param value defines the value to approximate
  30925. * @param max defines the maximum value to return
  30926. * @param mode defines how to define the closest value
  30927. * @returns closest exponent of two of the given value
  30928. */
  30929. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30930. /**
  30931. * Extracts the filename from a path
  30932. * @param path defines the path to use
  30933. * @returns the filename
  30934. */
  30935. static GetFilename(path: string): string;
  30936. /**
  30937. * Extracts the "folder" part of a path (everything before the filename).
  30938. * @param uri The URI to extract the info from
  30939. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30940. * @returns The "folder" part of the path
  30941. */
  30942. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30943. /**
  30944. * Extracts text content from a DOM element hierarchy
  30945. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30946. */
  30947. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30948. /**
  30949. * Convert an angle in radians to degrees
  30950. * @param angle defines the angle to convert
  30951. * @returns the angle in degrees
  30952. */
  30953. static ToDegrees(angle: number): number;
  30954. /**
  30955. * Convert an angle in degrees to radians
  30956. * @param angle defines the angle to convert
  30957. * @returns the angle in radians
  30958. */
  30959. static ToRadians(angle: number): number;
  30960. /**
  30961. * Encode a buffer to a base64 string
  30962. * @param buffer defines the buffer to encode
  30963. * @returns the encoded string
  30964. */
  30965. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30966. /**
  30967. * Extracts minimum and maximum values from a list of indexed positions
  30968. * @param positions defines the positions to use
  30969. * @param indices defines the indices to the positions
  30970. * @param indexStart defines the start index
  30971. * @param indexCount defines the end index
  30972. * @param bias defines bias value to add to the result
  30973. * @return minimum and maximum values
  30974. */
  30975. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30976. minimum: Vector3;
  30977. maximum: Vector3;
  30978. };
  30979. /**
  30980. * Extracts minimum and maximum values from a list of positions
  30981. * @param positions defines the positions to use
  30982. * @param start defines the start index in the positions array
  30983. * @param count defines the number of positions to handle
  30984. * @param bias defines bias value to add to the result
  30985. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30986. * @return minimum and maximum values
  30987. */
  30988. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30989. minimum: Vector3;
  30990. maximum: Vector3;
  30991. };
  30992. /**
  30993. * Returns an array if obj is not an array
  30994. * @param obj defines the object to evaluate as an array
  30995. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30996. * @returns either obj directly if obj is an array or a new array containing obj
  30997. */
  30998. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30999. /**
  31000. * Gets the pointer prefix to use
  31001. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31002. */
  31003. static GetPointerPrefix(): string;
  31004. /**
  31005. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31006. * @param func - the function to be called
  31007. * @param requester - the object that will request the next frame. Falls back to window.
  31008. * @returns frame number
  31009. */
  31010. static QueueNewFrame(func: () => void, requester?: any): number;
  31011. /**
  31012. * Ask the browser to promote the current element to fullscreen rendering mode
  31013. * @param element defines the DOM element to promote
  31014. */
  31015. static RequestFullscreen(element: HTMLElement): void;
  31016. /**
  31017. * Asks the browser to exit fullscreen mode
  31018. */
  31019. static ExitFullscreen(): void;
  31020. /**
  31021. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31022. * @param url define the url we are trying
  31023. * @param element define the dom element where to configure the cors policy
  31024. */
  31025. static SetCorsBehavior(url: string | string[], element: {
  31026. crossOrigin: string | null;
  31027. }): void;
  31028. /**
  31029. * Removes unwanted characters from an url
  31030. * @param url defines the url to clean
  31031. * @returns the cleaned url
  31032. */
  31033. static CleanUrl(url: string): string;
  31034. /**
  31035. * Gets or sets a function used to pre-process url before using them to load assets
  31036. */
  31037. static PreprocessUrl: (url: string) => string;
  31038. /**
  31039. * Loads an image as an HTMLImageElement.
  31040. * @param input url string, ArrayBuffer, or Blob to load
  31041. * @param onLoad callback called when the image successfully loads
  31042. * @param onError callback called when the image fails to load
  31043. * @param offlineProvider offline provider for caching
  31044. * @returns the HTMLImageElement of the loaded image
  31045. */
  31046. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31047. /**
  31048. * Loads a file
  31049. * @param url url string, ArrayBuffer, or Blob to load
  31050. * @param onSuccess callback called when the file successfully loads
  31051. * @param onProgress callback called while file is loading (if the server supports this mode)
  31052. * @param offlineProvider defines the offline provider for caching
  31053. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31054. * @param onError callback called when the file fails to load
  31055. * @returns a file request object
  31056. */
  31057. 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;
  31058. /**
  31059. * Load a script (identified by an url). When the url returns, the
  31060. * content of this file is added into a new script element, attached to the DOM (body element)
  31061. * @param scriptUrl defines the url of the script to laod
  31062. * @param onSuccess defines the callback called when the script is loaded
  31063. * @param onError defines the callback to call if an error occurs
  31064. * @param scriptId defines the id of the script element
  31065. */
  31066. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31067. /**
  31068. * Load an asynchronous script (identified by an url). When the url returns, the
  31069. * content of this file is added into a new script element, attached to the DOM (body element)
  31070. * @param scriptUrl defines the url of the script to laod
  31071. * @param scriptId defines the id of the script element
  31072. * @returns a promise request object
  31073. */
  31074. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31075. /**
  31076. * Loads a file from a blob
  31077. * @param fileToLoad defines the blob to use
  31078. * @param callback defines the callback to call when data is loaded
  31079. * @param progressCallback defines the callback to call during loading process
  31080. * @returns a file request object
  31081. */
  31082. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31083. /**
  31084. * Loads a file
  31085. * @param fileToLoad defines the file to load
  31086. * @param callback defines the callback to call when data is loaded
  31087. * @param progressCallBack defines the callback to call during loading process
  31088. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31089. * @returns a file request object
  31090. */
  31091. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31092. /**
  31093. * Creates a data url from a given string content
  31094. * @param content defines the content to convert
  31095. * @returns the new data url link
  31096. */
  31097. static FileAsURL(content: string): string;
  31098. /**
  31099. * Format the given number to a specific decimal format
  31100. * @param value defines the number to format
  31101. * @param decimals defines the number of decimals to use
  31102. * @returns the formatted string
  31103. */
  31104. static Format(value: number, decimals?: number): string;
  31105. /**
  31106. * Checks if a given vector is inside a specific range
  31107. * @param v defines the vector to test
  31108. * @param min defines the minimum range
  31109. * @param max defines the maximum range
  31110. */
  31111. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31112. /**
  31113. * Tries to copy an object by duplicating every property
  31114. * @param source defines the source object
  31115. * @param destination defines the target object
  31116. * @param doNotCopyList defines a list of properties to avoid
  31117. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31118. */
  31119. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31120. /**
  31121. * Gets a boolean indicating if the given object has no own property
  31122. * @param obj defines the object to test
  31123. * @returns true if object has no own property
  31124. */
  31125. static IsEmpty(obj: any): boolean;
  31126. /**
  31127. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31128. * @param str Source string
  31129. * @param suffix Suffix to search for in the source string
  31130. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31131. */
  31132. static EndsWith(str: string, suffix: string): boolean;
  31133. /**
  31134. * Function used to register events at window level
  31135. * @param events defines the events to register
  31136. */
  31137. static RegisterTopRootEvents(events: {
  31138. name: string;
  31139. handler: Nullable<(e: FocusEvent) => any>;
  31140. }[]): void;
  31141. /**
  31142. * Function used to unregister events from window level
  31143. * @param events defines the events to unregister
  31144. */
  31145. static UnregisterTopRootEvents(events: {
  31146. name: string;
  31147. handler: Nullable<(e: FocusEvent) => any>;
  31148. }[]): void;
  31149. /**
  31150. * @ignore
  31151. */
  31152. static _ScreenshotCanvas: HTMLCanvasElement;
  31153. /**
  31154. * Dumps the current bound framebuffer
  31155. * @param width defines the rendering width
  31156. * @param height defines the rendering height
  31157. * @param engine defines the hosting engine
  31158. * @param successCallback defines the callback triggered once the data are available
  31159. * @param mimeType defines the mime type of the result
  31160. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31161. */
  31162. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31163. /**
  31164. * Converts the canvas data to blob.
  31165. * This acts as a polyfill for browsers not supporting the to blob function.
  31166. * @param canvas Defines the canvas to extract the data from
  31167. * @param successCallback Defines the callback triggered once the data are available
  31168. * @param mimeType Defines the mime type of the result
  31169. */
  31170. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31171. /**
  31172. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31173. * @param successCallback defines the callback triggered once the data are available
  31174. * @param mimeType defines the mime type of the result
  31175. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31176. */
  31177. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31178. /**
  31179. * Downloads a blob in the browser
  31180. * @param blob defines the blob to download
  31181. * @param fileName defines the name of the downloaded file
  31182. */
  31183. static Download(blob: Blob, fileName: string): void;
  31184. /**
  31185. * Captures a screenshot of the current rendering
  31186. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31187. * @param engine defines the rendering engine
  31188. * @param camera defines the source camera
  31189. * @param size This parameter can be set to a single number or to an object with the
  31190. * following (optional) properties: precision, width, height. If a single number is passed,
  31191. * it will be used for both width and height. If an object is passed, the screenshot size
  31192. * will be derived from the parameters. The precision property is a multiplier allowing
  31193. * rendering at a higher or lower resolution
  31194. * @param successCallback defines the callback receives a single parameter which contains the
  31195. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31196. * src parameter of an <img> to display it
  31197. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31198. * Check your browser for supported MIME types
  31199. */
  31200. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31201. /**
  31202. * Generates an image screenshot from the specified camera.
  31203. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31204. * @param engine The engine to use for rendering
  31205. * @param camera The camera to use for rendering
  31206. * @param size This parameter can be set to a single number or to an object with the
  31207. * following (optional) properties: precision, width, height. If a single number is passed,
  31208. * it will be used for both width and height. If an object is passed, the screenshot size
  31209. * will be derived from the parameters. The precision property is a multiplier allowing
  31210. * rendering at a higher or lower resolution
  31211. * @param successCallback The callback receives a single parameter which contains the
  31212. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31213. * src parameter of an <img> to display it
  31214. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31215. * Check your browser for supported MIME types
  31216. * @param samples Texture samples (default: 1)
  31217. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31218. * @param fileName A name for for the downloaded file.
  31219. */
  31220. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31221. /**
  31222. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31223. * Be aware Math.random() could cause collisions, but:
  31224. * "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"
  31225. * @returns a pseudo random id
  31226. */
  31227. static RandomId(): string;
  31228. /**
  31229. * Test if the given uri is a base64 string
  31230. * @param uri The uri to test
  31231. * @return True if the uri is a base64 string or false otherwise
  31232. */
  31233. static IsBase64(uri: string): boolean;
  31234. /**
  31235. * Decode the given base64 uri.
  31236. * @param uri The uri to decode
  31237. * @return The decoded base64 data.
  31238. */
  31239. static DecodeBase64(uri: string): ArrayBuffer;
  31240. /**
  31241. * Gets the absolute url.
  31242. * @param url the input url
  31243. * @return the absolute url
  31244. */
  31245. static GetAbsoluteUrl(url: string): string;
  31246. /**
  31247. * No log
  31248. */
  31249. static readonly NoneLogLevel: number;
  31250. /**
  31251. * Only message logs
  31252. */
  31253. static readonly MessageLogLevel: number;
  31254. /**
  31255. * Only warning logs
  31256. */
  31257. static readonly WarningLogLevel: number;
  31258. /**
  31259. * Only error logs
  31260. */
  31261. static readonly ErrorLogLevel: number;
  31262. /**
  31263. * All logs
  31264. */
  31265. static readonly AllLogLevel: number;
  31266. /**
  31267. * Gets a value indicating the number of loading errors
  31268. * @ignorenaming
  31269. */
  31270. static readonly errorsCount: number;
  31271. /**
  31272. * Callback called when a new log is added
  31273. */
  31274. static OnNewCacheEntry: (entry: string) => void;
  31275. /**
  31276. * Log a message to the console
  31277. * @param message defines the message to log
  31278. */
  31279. static Log(message: string): void;
  31280. /**
  31281. * Write a warning message to the console
  31282. * @param message defines the message to log
  31283. */
  31284. static Warn(message: string): void;
  31285. /**
  31286. * Write an error message to the console
  31287. * @param message defines the message to log
  31288. */
  31289. static Error(message: string): void;
  31290. /**
  31291. * Gets current log cache (list of logs)
  31292. */
  31293. static readonly LogCache: string;
  31294. /**
  31295. * Clears the log cache
  31296. */
  31297. static ClearLogCache(): void;
  31298. /**
  31299. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31300. */
  31301. static LogLevels: number;
  31302. /**
  31303. * Checks if the loaded document was accessed via `file:`-Protocol.
  31304. * @returns boolean
  31305. */
  31306. static IsFileURL(): boolean;
  31307. /**
  31308. * Checks if the window object exists
  31309. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31310. */
  31311. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31312. /**
  31313. * No performance log
  31314. */
  31315. static readonly PerformanceNoneLogLevel: number;
  31316. /**
  31317. * Use user marks to log performance
  31318. */
  31319. static readonly PerformanceUserMarkLogLevel: number;
  31320. /**
  31321. * Log performance to the console
  31322. */
  31323. static readonly PerformanceConsoleLogLevel: number;
  31324. private static _performance;
  31325. /**
  31326. * Sets the current performance log level
  31327. */
  31328. static PerformanceLogLevel: number;
  31329. private static _StartPerformanceCounterDisabled;
  31330. private static _EndPerformanceCounterDisabled;
  31331. private static _StartUserMark;
  31332. private static _EndUserMark;
  31333. private static _StartPerformanceConsole;
  31334. private static _EndPerformanceConsole;
  31335. /**
  31336. * Starts a performance counter
  31337. */
  31338. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31339. /**
  31340. * Ends a specific performance coutner
  31341. */
  31342. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31343. /**
  31344. * Gets either window.performance.now() if supported or Date.now() else
  31345. */
  31346. static readonly Now: number;
  31347. /**
  31348. * This method will return the name of the class used to create the instance of the given object.
  31349. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31350. * @param object the object to get the class name from
  31351. * @param isType defines if the object is actually a type
  31352. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31353. */
  31354. static GetClassName(object: any, isType?: boolean): string;
  31355. /**
  31356. * Gets the first element of an array satisfying a given predicate
  31357. * @param array defines the array to browse
  31358. * @param predicate defines the predicate to use
  31359. * @returns null if not found or the element
  31360. */
  31361. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31362. /**
  31363. * This method will return the name of the full name of the class, including its owning module (if any).
  31364. * 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).
  31365. * @param object the object to get the class name from
  31366. * @param isType defines if the object is actually a type
  31367. * @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.
  31368. * @ignorenaming
  31369. */
  31370. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31371. /**
  31372. * Returns a promise that resolves after the given amount of time.
  31373. * @param delay Number of milliseconds to delay
  31374. * @returns Promise that resolves after the given amount of time
  31375. */
  31376. static DelayAsync(delay: number): Promise<void>;
  31377. /**
  31378. * Gets the current gradient from an array of IValueGradient
  31379. * @param ratio defines the current ratio to get
  31380. * @param gradients defines the array of IValueGradient
  31381. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31382. */
  31383. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31384. }
  31385. /**
  31386. * This class is used to track a performance counter which is number based.
  31387. * The user has access to many properties which give statistics of different nature.
  31388. *
  31389. * The implementer can track two kinds of Performance Counter: time and count.
  31390. * 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.
  31391. * 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.
  31392. */
  31393. export class PerfCounter {
  31394. /**
  31395. * Gets or sets a global boolean to turn on and off all the counters
  31396. */
  31397. static Enabled: boolean;
  31398. /**
  31399. * Returns the smallest value ever
  31400. */
  31401. readonly min: number;
  31402. /**
  31403. * Returns the biggest value ever
  31404. */
  31405. readonly max: number;
  31406. /**
  31407. * Returns the average value since the performance counter is running
  31408. */
  31409. readonly average: number;
  31410. /**
  31411. * Returns the average value of the last second the counter was monitored
  31412. */
  31413. readonly lastSecAverage: number;
  31414. /**
  31415. * Returns the current value
  31416. */
  31417. readonly current: number;
  31418. /**
  31419. * Gets the accumulated total
  31420. */
  31421. readonly total: number;
  31422. /**
  31423. * Gets the total value count
  31424. */
  31425. readonly count: number;
  31426. /**
  31427. * Creates a new counter
  31428. */
  31429. constructor();
  31430. /**
  31431. * Call this method to start monitoring a new frame.
  31432. * 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.
  31433. */
  31434. fetchNewFrame(): void;
  31435. /**
  31436. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31437. * @param newCount the count value to add to the monitored count
  31438. * @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.
  31439. */
  31440. addCount(newCount: number, fetchResult: boolean): void;
  31441. /**
  31442. * Start monitoring this performance counter
  31443. */
  31444. beginMonitoring(): void;
  31445. /**
  31446. * Compute the time lapsed since the previous beginMonitoring() call.
  31447. * @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
  31448. */
  31449. endMonitoring(newFrame?: boolean): void;
  31450. private _fetchResult;
  31451. private _startMonitoringTime;
  31452. private _min;
  31453. private _max;
  31454. private _average;
  31455. private _current;
  31456. private _totalValueCount;
  31457. private _totalAccumulated;
  31458. private _lastSecAverage;
  31459. private _lastSecAccumulated;
  31460. private _lastSecTime;
  31461. private _lastSecValueCount;
  31462. }
  31463. /**
  31464. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31465. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31466. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31467. * @param name The name of the class, case should be preserved
  31468. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31469. */
  31470. export function className(name: string, module?: string): (target: Object) => void;
  31471. /**
  31472. * An implementation of a loop for asynchronous functions.
  31473. */
  31474. export class AsyncLoop {
  31475. /**
  31476. * Defines the number of iterations for the loop
  31477. */
  31478. iterations: number;
  31479. /**
  31480. * Defines the current index of the loop.
  31481. */
  31482. index: number;
  31483. private _done;
  31484. private _fn;
  31485. private _successCallback;
  31486. /**
  31487. * Constructor.
  31488. * @param iterations the number of iterations.
  31489. * @param func the function to run each iteration
  31490. * @param successCallback the callback that will be called upon succesful execution
  31491. * @param offset starting offset.
  31492. */
  31493. constructor(
  31494. /**
  31495. * Defines the number of iterations for the loop
  31496. */
  31497. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31498. /**
  31499. * Execute the next iteration. Must be called after the last iteration was finished.
  31500. */
  31501. executeNext(): void;
  31502. /**
  31503. * Break the loop and run the success callback.
  31504. */
  31505. breakLoop(): void;
  31506. /**
  31507. * Create and run an async loop.
  31508. * @param iterations the number of iterations.
  31509. * @param fn the function to run each iteration
  31510. * @param successCallback the callback that will be called upon succesful execution
  31511. * @param offset starting offset.
  31512. * @returns the created async loop object
  31513. */
  31514. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31515. /**
  31516. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31517. * @param iterations total number of iterations
  31518. * @param syncedIterations number of synchronous iterations in each async iteration.
  31519. * @param fn the function to call each iteration.
  31520. * @param callback a success call back that will be called when iterating stops.
  31521. * @param breakFunction a break condition (optional)
  31522. * @param timeout timeout settings for the setTimeout function. default - 0.
  31523. * @returns the created async loop object
  31524. */
  31525. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31526. }
  31527. }
  31528. declare module BABYLON {
  31529. /** @hidden */
  31530. export interface ICollisionCoordinator {
  31531. createCollider(): Collider;
  31532. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31533. init(scene: Scene): void;
  31534. }
  31535. /** @hidden */
  31536. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31537. private _scene;
  31538. private _scaledPosition;
  31539. private _scaledVelocity;
  31540. private _finalPosition;
  31541. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31542. createCollider(): Collider;
  31543. init(scene: Scene): void;
  31544. private _collideWithWorld;
  31545. }
  31546. }
  31547. declare module BABYLON {
  31548. /**
  31549. * Class used to manage all inputs for the scene.
  31550. */
  31551. export class InputManager {
  31552. /** The distance in pixel that you have to move to prevent some events */
  31553. static DragMovementThreshold: number;
  31554. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31555. static LongPressDelay: number;
  31556. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31557. static DoubleClickDelay: number;
  31558. /** If you need to check double click without raising a single click at first click, enable this flag */
  31559. static ExclusiveDoubleClickMode: boolean;
  31560. private _wheelEventName;
  31561. private _onPointerMove;
  31562. private _onPointerDown;
  31563. private _onPointerUp;
  31564. private _initClickEvent;
  31565. private _initActionManager;
  31566. private _delayedSimpleClick;
  31567. private _delayedSimpleClickTimeout;
  31568. private _previousDelayedSimpleClickTimeout;
  31569. private _meshPickProceed;
  31570. private _previousButtonPressed;
  31571. private _currentPickResult;
  31572. private _previousPickResult;
  31573. private _totalPointersPressed;
  31574. private _doubleClickOccured;
  31575. private _pointerOverMesh;
  31576. private _pickedDownMesh;
  31577. private _pickedUpMesh;
  31578. private _pointerX;
  31579. private _pointerY;
  31580. private _unTranslatedPointerX;
  31581. private _unTranslatedPointerY;
  31582. private _startingPointerPosition;
  31583. private _previousStartingPointerPosition;
  31584. private _startingPointerTime;
  31585. private _previousStartingPointerTime;
  31586. private _pointerCaptures;
  31587. private _onKeyDown;
  31588. private _onKeyUp;
  31589. private _onCanvasFocusObserver;
  31590. private _onCanvasBlurObserver;
  31591. private _scene;
  31592. /**
  31593. * Creates a new InputManager
  31594. * @param scene defines the hosting scene
  31595. */
  31596. constructor(scene: Scene);
  31597. /**
  31598. * Gets the mesh that is currently under the pointer
  31599. */
  31600. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31601. /**
  31602. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31603. */
  31604. readonly unTranslatedPointer: Vector2;
  31605. /**
  31606. * Gets or sets the current on-screen X position of the pointer
  31607. */
  31608. pointerX: number;
  31609. /**
  31610. * Gets or sets the current on-screen Y position of the pointer
  31611. */
  31612. pointerY: number;
  31613. private _updatePointerPosition;
  31614. private _processPointerMove;
  31615. private _setRayOnPointerInfo;
  31616. private _checkPrePointerObservable;
  31617. /**
  31618. * Use this method to simulate a pointer move on a mesh
  31619. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31620. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31621. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31622. */
  31623. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31624. /**
  31625. * Use this method to simulate a pointer down on a mesh
  31626. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31627. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31628. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31629. */
  31630. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31631. private _processPointerDown;
  31632. /** @hidden */
  31633. _isPointerSwiping(): boolean;
  31634. /**
  31635. * Use this method to simulate a pointer up on a mesh
  31636. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31637. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31638. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31639. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31640. */
  31641. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31642. private _processPointerUp;
  31643. /**
  31644. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31645. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31646. * @returns true if the pointer was captured
  31647. */
  31648. isPointerCaptured(pointerId?: number): boolean;
  31649. /**
  31650. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31651. * @param attachUp defines if you want to attach events to pointerup
  31652. * @param attachDown defines if you want to attach events to pointerdown
  31653. * @param attachMove defines if you want to attach events to pointermove
  31654. */
  31655. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31656. /**
  31657. * Detaches all event handlers
  31658. */
  31659. detachControl(): void;
  31660. /**
  31661. * Force the value of meshUnderPointer
  31662. * @param mesh defines the mesh to use
  31663. */
  31664. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31665. /**
  31666. * Gets the mesh under the pointer
  31667. * @returns a Mesh or null if no mesh is under the pointer
  31668. */
  31669. getPointerOverMesh(): Nullable<AbstractMesh>;
  31670. }
  31671. }
  31672. declare module BABYLON {
  31673. /**
  31674. * This class defines the direct association between an animation and a target
  31675. */
  31676. export class TargetedAnimation {
  31677. /**
  31678. * Animation to perform
  31679. */
  31680. animation: Animation;
  31681. /**
  31682. * Target to animate
  31683. */
  31684. target: any;
  31685. }
  31686. /**
  31687. * Use this class to create coordinated animations on multiple targets
  31688. */
  31689. export class AnimationGroup implements IDisposable {
  31690. /** The name of the animation group */
  31691. name: string;
  31692. private _scene;
  31693. private _targetedAnimations;
  31694. private _animatables;
  31695. private _from;
  31696. private _to;
  31697. private _isStarted;
  31698. private _isPaused;
  31699. private _speedRatio;
  31700. /**
  31701. * Gets or sets the unique id of the node
  31702. */
  31703. uniqueId: number;
  31704. /**
  31705. * This observable will notify when one animation have ended
  31706. */
  31707. onAnimationEndObservable: Observable<TargetedAnimation>;
  31708. /**
  31709. * Observer raised when one animation loops
  31710. */
  31711. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31712. /**
  31713. * This observable will notify when all animations have ended.
  31714. */
  31715. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31716. /**
  31717. * This observable will notify when all animations have paused.
  31718. */
  31719. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31720. /**
  31721. * This observable will notify when all animations are playing.
  31722. */
  31723. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31724. /**
  31725. * Gets the first frame
  31726. */
  31727. readonly from: number;
  31728. /**
  31729. * Gets the last frame
  31730. */
  31731. readonly to: number;
  31732. /**
  31733. * Define if the animations are started
  31734. */
  31735. readonly isStarted: boolean;
  31736. /**
  31737. * Gets a value indicating that the current group is playing
  31738. */
  31739. readonly isPlaying: boolean;
  31740. /**
  31741. * Gets or sets the speed ratio to use for all animations
  31742. */
  31743. /**
  31744. * Gets or sets the speed ratio to use for all animations
  31745. */
  31746. speedRatio: number;
  31747. /**
  31748. * Gets the targeted animations for this animation group
  31749. */
  31750. readonly targetedAnimations: Array<TargetedAnimation>;
  31751. /**
  31752. * returning the list of animatables controlled by this animation group.
  31753. */
  31754. readonly animatables: Array<Animatable>;
  31755. /**
  31756. * Instantiates a new Animation Group.
  31757. * This helps managing several animations at once.
  31758. * @see http://doc.babylonjs.com/how_to/group
  31759. * @param name Defines the name of the group
  31760. * @param scene Defines the scene the group belongs to
  31761. */
  31762. constructor(
  31763. /** The name of the animation group */
  31764. name: string, scene?: Nullable<Scene>);
  31765. /**
  31766. * Add an animation (with its target) in the group
  31767. * @param animation defines the animation we want to add
  31768. * @param target defines the target of the animation
  31769. * @returns the TargetedAnimation object
  31770. */
  31771. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31772. /**
  31773. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31774. * It can add constant keys at begin or end
  31775. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31776. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31777. * @returns the animation group
  31778. */
  31779. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31780. /**
  31781. * Start all animations on given targets
  31782. * @param loop defines if animations must loop
  31783. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31784. * @param from defines the from key (optional)
  31785. * @param to defines the to key (optional)
  31786. * @returns the current animation group
  31787. */
  31788. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31789. /**
  31790. * Pause all animations
  31791. * @returns the animation group
  31792. */
  31793. pause(): AnimationGroup;
  31794. /**
  31795. * Play all animations to initial state
  31796. * This function will start() the animations if they were not started or will restart() them if they were paused
  31797. * @param loop defines if animations must loop
  31798. * @returns the animation group
  31799. */
  31800. play(loop?: boolean): AnimationGroup;
  31801. /**
  31802. * Reset all animations to initial state
  31803. * @returns the animation group
  31804. */
  31805. reset(): AnimationGroup;
  31806. /**
  31807. * Restart animations from key 0
  31808. * @returns the animation group
  31809. */
  31810. restart(): AnimationGroup;
  31811. /**
  31812. * Stop all animations
  31813. * @returns the animation group
  31814. */
  31815. stop(): AnimationGroup;
  31816. /**
  31817. * Set animation weight for all animatables
  31818. * @param weight defines the weight to use
  31819. * @return the animationGroup
  31820. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31821. */
  31822. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31823. /**
  31824. * Synchronize and normalize all animatables with a source animatable
  31825. * @param root defines the root animatable to synchronize with
  31826. * @return the animationGroup
  31827. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31828. */
  31829. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31830. /**
  31831. * Goes to a specific frame in this animation group
  31832. * @param frame the frame number to go to
  31833. * @return the animationGroup
  31834. */
  31835. goToFrame(frame: number): AnimationGroup;
  31836. /**
  31837. * Dispose all associated resources
  31838. */
  31839. dispose(): void;
  31840. private _checkAnimationGroupEnded;
  31841. /**
  31842. * Clone the current animation group and returns a copy
  31843. * @param newName defines the name of the new group
  31844. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31845. * @returns the new aniamtion group
  31846. */
  31847. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31848. /**
  31849. * Returns a new AnimationGroup object parsed from the source provided.
  31850. * @param parsedAnimationGroup defines the source
  31851. * @param scene defines the scene that will receive the animationGroup
  31852. * @returns a new AnimationGroup
  31853. */
  31854. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31855. /**
  31856. * Returns the string "AnimationGroup"
  31857. * @returns "AnimationGroup"
  31858. */
  31859. getClassName(): string;
  31860. /**
  31861. * Creates a detailled string about the object
  31862. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31863. * @returns a string representing the object
  31864. */
  31865. toString(fullDetails?: boolean): string;
  31866. }
  31867. }
  31868. declare module BABYLON {
  31869. /**
  31870. * Define an interface for all classes that will hold resources
  31871. */
  31872. export interface IDisposable {
  31873. /**
  31874. * Releases all held resources
  31875. */
  31876. dispose(): void;
  31877. }
  31878. /** Interface defining initialization parameters for Scene class */
  31879. export interface SceneOptions {
  31880. /**
  31881. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31882. * It will improve performance when the number of geometries becomes important.
  31883. */
  31884. useGeometryUniqueIdsMap?: boolean;
  31885. /**
  31886. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31887. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31888. */
  31889. useMaterialMeshMap?: boolean;
  31890. /**
  31891. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31892. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31893. */
  31894. useClonedMeshhMap?: boolean;
  31895. }
  31896. /**
  31897. * Represents a scene to be rendered by the engine.
  31898. * @see http://doc.babylonjs.com/features/scene
  31899. */
  31900. export class Scene extends AbstractScene implements IAnimatable {
  31901. private static _uniqueIdCounter;
  31902. /** The fog is deactivated */
  31903. static readonly FOGMODE_NONE: number;
  31904. /** The fog density is following an exponential function */
  31905. static readonly FOGMODE_EXP: number;
  31906. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31907. static readonly FOGMODE_EXP2: number;
  31908. /** The fog density is following a linear function. */
  31909. static readonly FOGMODE_LINEAR: number;
  31910. /**
  31911. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31912. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31913. */
  31914. static MinDeltaTime: number;
  31915. /**
  31916. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31917. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31918. */
  31919. static MaxDeltaTime: number;
  31920. /**
  31921. * Factory used to create the default material.
  31922. * @param name The name of the material to create
  31923. * @param scene The scene to create the material for
  31924. * @returns The default material
  31925. */
  31926. static DefaultMaterialFactory(scene: Scene): Material;
  31927. /**
  31928. * Factory used to create the a collision coordinator.
  31929. * @returns The collision coordinator
  31930. */
  31931. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31932. /** @hidden */
  31933. _inputManager: InputManager;
  31934. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31935. cameraToUseForPointers: Nullable<Camera>;
  31936. /** @hidden */
  31937. readonly _isScene: boolean;
  31938. /**
  31939. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31940. */
  31941. autoClear: boolean;
  31942. /**
  31943. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31944. */
  31945. autoClearDepthAndStencil: boolean;
  31946. /**
  31947. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31948. */
  31949. clearColor: Color4;
  31950. /**
  31951. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31952. */
  31953. ambientColor: Color3;
  31954. /**
  31955. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31956. * It should only be one of the following (if not the default embedded one):
  31957. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31958. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31959. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31960. * The material properties need to be setup according to the type of texture in use.
  31961. */
  31962. environmentBRDFTexture: BaseTexture;
  31963. /** @hidden */
  31964. protected _environmentTexture: Nullable<BaseTexture>;
  31965. /**
  31966. * Texture used in all pbr material as the reflection texture.
  31967. * As in the majority of the scene they are the same (exception for multi room and so on),
  31968. * this is easier to reference from here than from all the materials.
  31969. */
  31970. /**
  31971. * Texture used in all pbr material as the reflection texture.
  31972. * As in the majority of the scene they are the same (exception for multi room and so on),
  31973. * this is easier to set here than in all the materials.
  31974. */
  31975. environmentTexture: Nullable<BaseTexture>;
  31976. /** @hidden */
  31977. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31978. /**
  31979. * Default image processing configuration used either in the rendering
  31980. * Forward main pass or through the imageProcessingPostProcess if present.
  31981. * As in the majority of the scene they are the same (exception for multi camera),
  31982. * this is easier to reference from here than from all the materials and post process.
  31983. *
  31984. * No setter as we it is a shared configuration, you can set the values instead.
  31985. */
  31986. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31987. private _forceWireframe;
  31988. /**
  31989. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31990. */
  31991. forceWireframe: boolean;
  31992. private _forcePointsCloud;
  31993. /**
  31994. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31995. */
  31996. forcePointsCloud: boolean;
  31997. /**
  31998. * Gets or sets the active clipplane 1
  31999. */
  32000. clipPlane: Nullable<Plane>;
  32001. /**
  32002. * Gets or sets the active clipplane 2
  32003. */
  32004. clipPlane2: Nullable<Plane>;
  32005. /**
  32006. * Gets or sets the active clipplane 3
  32007. */
  32008. clipPlane3: Nullable<Plane>;
  32009. /**
  32010. * Gets or sets the active clipplane 4
  32011. */
  32012. clipPlane4: Nullable<Plane>;
  32013. /**
  32014. * Gets or sets a boolean indicating if animations are enabled
  32015. */
  32016. animationsEnabled: boolean;
  32017. private _animationPropertiesOverride;
  32018. /**
  32019. * Gets or sets the animation properties override
  32020. */
  32021. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32022. /**
  32023. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32024. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32025. */
  32026. useConstantAnimationDeltaTime: boolean;
  32027. /**
  32028. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32029. * Please note that it requires to run a ray cast through the scene on every frame
  32030. */
  32031. constantlyUpdateMeshUnderPointer: boolean;
  32032. /**
  32033. * Defines the HTML cursor to use when hovering over interactive elements
  32034. */
  32035. hoverCursor: string;
  32036. /**
  32037. * Defines the HTML default cursor to use (empty by default)
  32038. */
  32039. defaultCursor: string;
  32040. /**
  32041. * This is used to call preventDefault() on pointer down
  32042. * in order to block unwanted artifacts like system double clicks
  32043. */
  32044. preventDefaultOnPointerDown: boolean;
  32045. /**
  32046. * This is used to call preventDefault() on pointer up
  32047. * in order to block unwanted artifacts like system double clicks
  32048. */
  32049. preventDefaultOnPointerUp: boolean;
  32050. /**
  32051. * Gets or sets user defined metadata
  32052. */
  32053. metadata: any;
  32054. /**
  32055. * For internal use only. Please do not use.
  32056. */
  32057. reservedDataStore: any;
  32058. /**
  32059. * Gets the name of the plugin used to load this scene (null by default)
  32060. */
  32061. loadingPluginName: string;
  32062. /**
  32063. * Use this array to add regular expressions used to disable offline support for specific urls
  32064. */
  32065. disableOfflineSupportExceptionRules: RegExp[];
  32066. /**
  32067. * An event triggered when the scene is disposed.
  32068. */
  32069. onDisposeObservable: Observable<Scene>;
  32070. private _onDisposeObserver;
  32071. /** Sets a function to be executed when this scene is disposed. */
  32072. onDispose: () => void;
  32073. /**
  32074. * An event triggered before rendering the scene (right after animations and physics)
  32075. */
  32076. onBeforeRenderObservable: Observable<Scene>;
  32077. private _onBeforeRenderObserver;
  32078. /** Sets a function to be executed before rendering this scene */
  32079. beforeRender: Nullable<() => void>;
  32080. /**
  32081. * An event triggered after rendering the scene
  32082. */
  32083. onAfterRenderObservable: Observable<Scene>;
  32084. private _onAfterRenderObserver;
  32085. /** Sets a function to be executed after rendering this scene */
  32086. afterRender: Nullable<() => void>;
  32087. /**
  32088. * An event triggered before animating the scene
  32089. */
  32090. onBeforeAnimationsObservable: Observable<Scene>;
  32091. /**
  32092. * An event triggered after animations processing
  32093. */
  32094. onAfterAnimationsObservable: Observable<Scene>;
  32095. /**
  32096. * An event triggered before draw calls are ready to be sent
  32097. */
  32098. onBeforeDrawPhaseObservable: Observable<Scene>;
  32099. /**
  32100. * An event triggered after draw calls have been sent
  32101. */
  32102. onAfterDrawPhaseObservable: Observable<Scene>;
  32103. /**
  32104. * An event triggered when the scene is ready
  32105. */
  32106. onReadyObservable: Observable<Scene>;
  32107. /**
  32108. * An event triggered before rendering a camera
  32109. */
  32110. onBeforeCameraRenderObservable: Observable<Camera>;
  32111. private _onBeforeCameraRenderObserver;
  32112. /** Sets a function to be executed before rendering a camera*/
  32113. beforeCameraRender: () => void;
  32114. /**
  32115. * An event triggered after rendering a camera
  32116. */
  32117. onAfterCameraRenderObservable: Observable<Camera>;
  32118. private _onAfterCameraRenderObserver;
  32119. /** Sets a function to be executed after rendering a camera*/
  32120. afterCameraRender: () => void;
  32121. /**
  32122. * An event triggered when active meshes evaluation is about to start
  32123. */
  32124. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32125. /**
  32126. * An event triggered when active meshes evaluation is done
  32127. */
  32128. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32129. /**
  32130. * An event triggered when particles rendering is about to start
  32131. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32132. */
  32133. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32134. /**
  32135. * An event triggered when particles rendering is done
  32136. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32137. */
  32138. onAfterParticlesRenderingObservable: Observable<Scene>;
  32139. /**
  32140. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32141. */
  32142. onDataLoadedObservable: Observable<Scene>;
  32143. /**
  32144. * An event triggered when a camera is created
  32145. */
  32146. onNewCameraAddedObservable: Observable<Camera>;
  32147. /**
  32148. * An event triggered when a camera is removed
  32149. */
  32150. onCameraRemovedObservable: Observable<Camera>;
  32151. /**
  32152. * An event triggered when a light is created
  32153. */
  32154. onNewLightAddedObservable: Observable<Light>;
  32155. /**
  32156. * An event triggered when a light is removed
  32157. */
  32158. onLightRemovedObservable: Observable<Light>;
  32159. /**
  32160. * An event triggered when a geometry is created
  32161. */
  32162. onNewGeometryAddedObservable: Observable<Geometry>;
  32163. /**
  32164. * An event triggered when a geometry is removed
  32165. */
  32166. onGeometryRemovedObservable: Observable<Geometry>;
  32167. /**
  32168. * An event triggered when a transform node is created
  32169. */
  32170. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32171. /**
  32172. * An event triggered when a transform node is removed
  32173. */
  32174. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32175. /**
  32176. * An event triggered when a mesh is created
  32177. */
  32178. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32179. /**
  32180. * An event triggered when a mesh is removed
  32181. */
  32182. onMeshRemovedObservable: Observable<AbstractMesh>;
  32183. /**
  32184. * An event triggered when a skeleton is created
  32185. */
  32186. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32187. /**
  32188. * An event triggered when a skeleton is removed
  32189. */
  32190. onSkeletonRemovedObservable: Observable<Skeleton>;
  32191. /**
  32192. * An event triggered when a material is created
  32193. */
  32194. onNewMaterialAddedObservable: Observable<Material>;
  32195. /**
  32196. * An event triggered when a material is removed
  32197. */
  32198. onMaterialRemovedObservable: Observable<Material>;
  32199. /**
  32200. * An event triggered when a texture is created
  32201. */
  32202. onNewTextureAddedObservable: Observable<BaseTexture>;
  32203. /**
  32204. * An event triggered when a texture is removed
  32205. */
  32206. onTextureRemovedObservable: Observable<BaseTexture>;
  32207. /**
  32208. * An event triggered when render targets are about to be rendered
  32209. * Can happen multiple times per frame.
  32210. */
  32211. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32212. /**
  32213. * An event triggered when render targets were rendered.
  32214. * Can happen multiple times per frame.
  32215. */
  32216. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32217. /**
  32218. * An event triggered before calculating deterministic simulation step
  32219. */
  32220. onBeforeStepObservable: Observable<Scene>;
  32221. /**
  32222. * An event triggered after calculating deterministic simulation step
  32223. */
  32224. onAfterStepObservable: Observable<Scene>;
  32225. /**
  32226. * An event triggered when the activeCamera property is updated
  32227. */
  32228. onActiveCameraChanged: Observable<Scene>;
  32229. /**
  32230. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32231. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32232. * 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)
  32233. */
  32234. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32235. /**
  32236. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32237. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32238. * 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)
  32239. */
  32240. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32241. /**
  32242. * This Observable will when a mesh has been imported into the scene.
  32243. */
  32244. onMeshImportedObservable: Observable<AbstractMesh>;
  32245. /**
  32246. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32247. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32248. */
  32249. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32250. /** @hidden */
  32251. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32252. /**
  32253. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32254. */
  32255. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32256. /**
  32257. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32258. */
  32259. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32260. /**
  32261. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32262. */
  32263. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32264. /** Callback called when a pointer move is detected */
  32265. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32266. /** Callback called when a pointer down is detected */
  32267. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32268. /** Callback called when a pointer up is detected */
  32269. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32270. /** Callback called when a pointer pick is detected */
  32271. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32272. /**
  32273. * 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).
  32274. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32275. */
  32276. onPrePointerObservable: Observable<PointerInfoPre>;
  32277. /**
  32278. * Observable event triggered each time an input event is received from the rendering canvas
  32279. */
  32280. onPointerObservable: Observable<PointerInfo>;
  32281. /**
  32282. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32283. */
  32284. readonly unTranslatedPointer: Vector2;
  32285. /**
  32286. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32287. */
  32288. static DragMovementThreshold: number;
  32289. /**
  32290. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32291. */
  32292. static LongPressDelay: number;
  32293. /**
  32294. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32295. */
  32296. static DoubleClickDelay: number;
  32297. /** If you need to check double click without raising a single click at first click, enable this flag */
  32298. static ExclusiveDoubleClickMode: boolean;
  32299. /** @hidden */
  32300. _mirroredCameraPosition: Nullable<Vector3>;
  32301. /**
  32302. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32303. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32304. */
  32305. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32306. /**
  32307. * Observable event triggered each time an keyboard event is received from the hosting window
  32308. */
  32309. onKeyboardObservable: Observable<KeyboardInfo>;
  32310. private _useRightHandedSystem;
  32311. /**
  32312. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32313. */
  32314. useRightHandedSystem: boolean;
  32315. private _timeAccumulator;
  32316. private _currentStepId;
  32317. private _currentInternalStep;
  32318. /**
  32319. * Sets the step Id used by deterministic lock step
  32320. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32321. * @param newStepId defines the step Id
  32322. */
  32323. setStepId(newStepId: number): void;
  32324. /**
  32325. * Gets the step Id used by deterministic lock step
  32326. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32327. * @returns the step Id
  32328. */
  32329. getStepId(): number;
  32330. /**
  32331. * Gets the internal step used by deterministic lock step
  32332. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32333. * @returns the internal step
  32334. */
  32335. getInternalStep(): number;
  32336. private _fogEnabled;
  32337. /**
  32338. * Gets or sets a boolean indicating if fog is enabled on this scene
  32339. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32340. * (Default is true)
  32341. */
  32342. fogEnabled: boolean;
  32343. private _fogMode;
  32344. /**
  32345. * Gets or sets the fog mode to use
  32346. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32347. * | mode | value |
  32348. * | --- | --- |
  32349. * | FOGMODE_NONE | 0 |
  32350. * | FOGMODE_EXP | 1 |
  32351. * | FOGMODE_EXP2 | 2 |
  32352. * | FOGMODE_LINEAR | 3 |
  32353. */
  32354. fogMode: number;
  32355. /**
  32356. * Gets or sets the fog color to use
  32357. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32358. * (Default is Color3(0.2, 0.2, 0.3))
  32359. */
  32360. fogColor: Color3;
  32361. /**
  32362. * Gets or sets the fog density to use
  32363. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32364. * (Default is 0.1)
  32365. */
  32366. fogDensity: number;
  32367. /**
  32368. * Gets or sets the fog start distance to use
  32369. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32370. * (Default is 0)
  32371. */
  32372. fogStart: number;
  32373. /**
  32374. * Gets or sets the fog end distance to use
  32375. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32376. * (Default is 1000)
  32377. */
  32378. fogEnd: number;
  32379. private _shadowsEnabled;
  32380. /**
  32381. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32382. */
  32383. shadowsEnabled: boolean;
  32384. private _lightsEnabled;
  32385. /**
  32386. * Gets or sets a boolean indicating if lights are enabled on this scene
  32387. */
  32388. lightsEnabled: boolean;
  32389. /** All of the active cameras added to this scene. */
  32390. activeCameras: Camera[];
  32391. /** @hidden */
  32392. _activeCamera: Nullable<Camera>;
  32393. /** Gets or sets the current active camera */
  32394. activeCamera: Nullable<Camera>;
  32395. private _defaultMaterial;
  32396. /** The default material used on meshes when no material is affected */
  32397. /** The default material used on meshes when no material is affected */
  32398. defaultMaterial: Material;
  32399. private _texturesEnabled;
  32400. /**
  32401. * Gets or sets a boolean indicating if textures are enabled on this scene
  32402. */
  32403. texturesEnabled: boolean;
  32404. /**
  32405. * Gets or sets a boolean indicating if particles are enabled on this scene
  32406. */
  32407. particlesEnabled: boolean;
  32408. /**
  32409. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32410. */
  32411. spritesEnabled: boolean;
  32412. private _skeletonsEnabled;
  32413. /**
  32414. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32415. */
  32416. skeletonsEnabled: boolean;
  32417. /**
  32418. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32419. */
  32420. lensFlaresEnabled: boolean;
  32421. /**
  32422. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32423. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32424. */
  32425. collisionsEnabled: boolean;
  32426. private _collisionCoordinator;
  32427. /** @hidden */
  32428. readonly collisionCoordinator: ICollisionCoordinator;
  32429. /**
  32430. * Defines the gravity applied to this scene (used only for collisions)
  32431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32432. */
  32433. gravity: Vector3;
  32434. /**
  32435. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32436. */
  32437. postProcessesEnabled: boolean;
  32438. /**
  32439. * The list of postprocesses added to the scene
  32440. */
  32441. postProcesses: PostProcess[];
  32442. /**
  32443. * Gets the current postprocess manager
  32444. */
  32445. postProcessManager: PostProcessManager;
  32446. /**
  32447. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32448. */
  32449. renderTargetsEnabled: boolean;
  32450. /**
  32451. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32452. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32453. */
  32454. dumpNextRenderTargets: boolean;
  32455. /**
  32456. * The list of user defined render targets added to the scene
  32457. */
  32458. customRenderTargets: RenderTargetTexture[];
  32459. /**
  32460. * Defines if texture loading must be delayed
  32461. * If true, textures will only be loaded when they need to be rendered
  32462. */
  32463. useDelayedTextureLoading: boolean;
  32464. /**
  32465. * Gets the list of meshes imported to the scene through SceneLoader
  32466. */
  32467. importedMeshesFiles: String[];
  32468. /**
  32469. * Gets or sets a boolean indicating if probes are enabled on this scene
  32470. */
  32471. probesEnabled: boolean;
  32472. /**
  32473. * Gets or sets the current offline provider to use to store scene data
  32474. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32475. */
  32476. offlineProvider: IOfflineProvider;
  32477. /**
  32478. * Gets or sets the action manager associated with the scene
  32479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32480. */
  32481. actionManager: AbstractActionManager;
  32482. private _meshesForIntersections;
  32483. /**
  32484. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32485. */
  32486. proceduralTexturesEnabled: boolean;
  32487. private _engine;
  32488. private _totalVertices;
  32489. /** @hidden */
  32490. _activeIndices: PerfCounter;
  32491. /** @hidden */
  32492. _activeParticles: PerfCounter;
  32493. /** @hidden */
  32494. _activeBones: PerfCounter;
  32495. private _animationRatio;
  32496. /** @hidden */
  32497. _animationTimeLast: number;
  32498. /** @hidden */
  32499. _animationTime: number;
  32500. /**
  32501. * Gets or sets a general scale for animation speed
  32502. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32503. */
  32504. animationTimeScale: number;
  32505. /** @hidden */
  32506. _cachedMaterial: Nullable<Material>;
  32507. /** @hidden */
  32508. _cachedEffect: Nullable<Effect>;
  32509. /** @hidden */
  32510. _cachedVisibility: Nullable<number>;
  32511. private _renderId;
  32512. private _frameId;
  32513. private _executeWhenReadyTimeoutId;
  32514. private _intermediateRendering;
  32515. private _viewUpdateFlag;
  32516. private _projectionUpdateFlag;
  32517. /** @hidden */
  32518. _toBeDisposed: Nullable<IDisposable>[];
  32519. private _activeRequests;
  32520. /** @hidden */
  32521. _pendingData: any[];
  32522. private _isDisposed;
  32523. /**
  32524. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32525. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32526. */
  32527. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32528. private _activeMeshes;
  32529. private _processedMaterials;
  32530. private _renderTargets;
  32531. /** @hidden */
  32532. _activeParticleSystems: SmartArray<IParticleSystem>;
  32533. private _activeSkeletons;
  32534. private _softwareSkinnedMeshes;
  32535. private _renderingManager;
  32536. /** @hidden */
  32537. _activeAnimatables: Animatable[];
  32538. private _transformMatrix;
  32539. private _sceneUbo;
  32540. /** @hidden */
  32541. _viewMatrix: Matrix;
  32542. private _projectionMatrix;
  32543. /** @hidden */
  32544. _forcedViewPosition: Nullable<Vector3>;
  32545. /** @hidden */
  32546. _frustumPlanes: Plane[];
  32547. /**
  32548. * Gets the list of frustum planes (built from the active camera)
  32549. */
  32550. readonly frustumPlanes: Plane[];
  32551. /**
  32552. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32553. * This is useful if there are more lights that the maximum simulteanous authorized
  32554. */
  32555. requireLightSorting: boolean;
  32556. /** @hidden */
  32557. readonly useMaterialMeshMap: boolean;
  32558. /** @hidden */
  32559. readonly useClonedMeshhMap: boolean;
  32560. private _externalData;
  32561. private _uid;
  32562. /**
  32563. * @hidden
  32564. * Backing store of defined scene components.
  32565. */
  32566. _components: ISceneComponent[];
  32567. /**
  32568. * @hidden
  32569. * Backing store of defined scene components.
  32570. */
  32571. _serializableComponents: ISceneSerializableComponent[];
  32572. /**
  32573. * List of components to register on the next registration step.
  32574. */
  32575. private _transientComponents;
  32576. /**
  32577. * Registers the transient components if needed.
  32578. */
  32579. private _registerTransientComponents;
  32580. /**
  32581. * @hidden
  32582. * Add a component to the scene.
  32583. * Note that the ccomponent could be registered on th next frame if this is called after
  32584. * the register component stage.
  32585. * @param component Defines the component to add to the scene
  32586. */
  32587. _addComponent(component: ISceneComponent): void;
  32588. /**
  32589. * @hidden
  32590. * Gets a component from the scene.
  32591. * @param name defines the name of the component to retrieve
  32592. * @returns the component or null if not present
  32593. */
  32594. _getComponent(name: string): Nullable<ISceneComponent>;
  32595. /**
  32596. * @hidden
  32597. * Defines the actions happening before camera updates.
  32598. */
  32599. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32600. /**
  32601. * @hidden
  32602. * Defines the actions happening before clear the canvas.
  32603. */
  32604. _beforeClearStage: Stage<SimpleStageAction>;
  32605. /**
  32606. * @hidden
  32607. * Defines the actions when collecting render targets for the frame.
  32608. */
  32609. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32610. /**
  32611. * @hidden
  32612. * Defines the actions happening for one camera in the frame.
  32613. */
  32614. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32615. /**
  32616. * @hidden
  32617. * Defines the actions happening during the per mesh ready checks.
  32618. */
  32619. _isReadyForMeshStage: Stage<MeshStageAction>;
  32620. /**
  32621. * @hidden
  32622. * Defines the actions happening before evaluate active mesh checks.
  32623. */
  32624. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32625. /**
  32626. * @hidden
  32627. * Defines the actions happening during the evaluate sub mesh checks.
  32628. */
  32629. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32630. /**
  32631. * @hidden
  32632. * Defines the actions happening during the active mesh stage.
  32633. */
  32634. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32635. /**
  32636. * @hidden
  32637. * Defines the actions happening during the per camera render target step.
  32638. */
  32639. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32640. /**
  32641. * @hidden
  32642. * Defines the actions happening just before the active camera is drawing.
  32643. */
  32644. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32645. /**
  32646. * @hidden
  32647. * Defines the actions happening just before a render target is drawing.
  32648. */
  32649. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32650. /**
  32651. * @hidden
  32652. * Defines the actions happening just before a rendering group is drawing.
  32653. */
  32654. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32655. /**
  32656. * @hidden
  32657. * Defines the actions happening just before a mesh is drawing.
  32658. */
  32659. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32660. /**
  32661. * @hidden
  32662. * Defines the actions happening just after a mesh has been drawn.
  32663. */
  32664. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32665. /**
  32666. * @hidden
  32667. * Defines the actions happening just after a rendering group has been drawn.
  32668. */
  32669. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32670. /**
  32671. * @hidden
  32672. * Defines the actions happening just after the active camera has been drawn.
  32673. */
  32674. _afterCameraDrawStage: Stage<CameraStageAction>;
  32675. /**
  32676. * @hidden
  32677. * Defines the actions happening just after a render target has been drawn.
  32678. */
  32679. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32680. /**
  32681. * @hidden
  32682. * Defines the actions happening just after rendering all cameras and computing intersections.
  32683. */
  32684. _afterRenderStage: Stage<SimpleStageAction>;
  32685. /**
  32686. * @hidden
  32687. * Defines the actions happening when a pointer move event happens.
  32688. */
  32689. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32690. /**
  32691. * @hidden
  32692. * Defines the actions happening when a pointer down event happens.
  32693. */
  32694. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32695. /**
  32696. * @hidden
  32697. * Defines the actions happening when a pointer up event happens.
  32698. */
  32699. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32700. /**
  32701. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32702. */
  32703. private geometriesByUniqueId;
  32704. /**
  32705. * Creates a new Scene
  32706. * @param engine defines the engine to use to render this scene
  32707. * @param options defines the scene options
  32708. */
  32709. constructor(engine: Engine, options?: SceneOptions);
  32710. /**
  32711. * Gets a string idenfifying the name of the class
  32712. * @returns "Scene" string
  32713. */
  32714. getClassName(): string;
  32715. private _defaultMeshCandidates;
  32716. /**
  32717. * @hidden
  32718. */
  32719. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32720. private _defaultSubMeshCandidates;
  32721. /**
  32722. * @hidden
  32723. */
  32724. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32725. /**
  32726. * Sets the default candidate providers for the scene.
  32727. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32728. * and getCollidingSubMeshCandidates to their default function
  32729. */
  32730. setDefaultCandidateProviders(): void;
  32731. /**
  32732. * Gets the mesh that is currently under the pointer
  32733. */
  32734. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32735. /**
  32736. * Gets or sets the current on-screen X position of the pointer
  32737. */
  32738. pointerX: number;
  32739. /**
  32740. * Gets or sets the current on-screen Y position of the pointer
  32741. */
  32742. pointerY: number;
  32743. /**
  32744. * Gets the cached material (ie. the latest rendered one)
  32745. * @returns the cached material
  32746. */
  32747. getCachedMaterial(): Nullable<Material>;
  32748. /**
  32749. * Gets the cached effect (ie. the latest rendered one)
  32750. * @returns the cached effect
  32751. */
  32752. getCachedEffect(): Nullable<Effect>;
  32753. /**
  32754. * Gets the cached visibility state (ie. the latest rendered one)
  32755. * @returns the cached visibility state
  32756. */
  32757. getCachedVisibility(): Nullable<number>;
  32758. /**
  32759. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32760. * @param material defines the current material
  32761. * @param effect defines the current effect
  32762. * @param visibility defines the current visibility state
  32763. * @returns true if one parameter is not cached
  32764. */
  32765. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32766. /**
  32767. * Gets the engine associated with the scene
  32768. * @returns an Engine
  32769. */
  32770. getEngine(): Engine;
  32771. /**
  32772. * Gets the total number of vertices rendered per frame
  32773. * @returns the total number of vertices rendered per frame
  32774. */
  32775. getTotalVertices(): number;
  32776. /**
  32777. * Gets the performance counter for total vertices
  32778. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32779. */
  32780. readonly totalVerticesPerfCounter: PerfCounter;
  32781. /**
  32782. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32783. * @returns the total number of active indices rendered per frame
  32784. */
  32785. getActiveIndices(): number;
  32786. /**
  32787. * Gets the performance counter for active indices
  32788. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32789. */
  32790. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32791. /**
  32792. * Gets the total number of active particles rendered per frame
  32793. * @returns the total number of active particles rendered per frame
  32794. */
  32795. getActiveParticles(): number;
  32796. /**
  32797. * Gets the performance counter for active particles
  32798. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32799. */
  32800. readonly activeParticlesPerfCounter: PerfCounter;
  32801. /**
  32802. * Gets the total number of active bones rendered per frame
  32803. * @returns the total number of active bones rendered per frame
  32804. */
  32805. getActiveBones(): number;
  32806. /**
  32807. * Gets the performance counter for active bones
  32808. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32809. */
  32810. readonly activeBonesPerfCounter: PerfCounter;
  32811. /**
  32812. * Gets the array of active meshes
  32813. * @returns an array of AbstractMesh
  32814. */
  32815. getActiveMeshes(): SmartArray<AbstractMesh>;
  32816. /**
  32817. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32818. * @returns a number
  32819. */
  32820. getAnimationRatio(): number;
  32821. /**
  32822. * Gets an unique Id for the current render phase
  32823. * @returns a number
  32824. */
  32825. getRenderId(): number;
  32826. /**
  32827. * Gets an unique Id for the current frame
  32828. * @returns a number
  32829. */
  32830. getFrameId(): number;
  32831. /** Call this function if you want to manually increment the render Id*/
  32832. incrementRenderId(): void;
  32833. private _createUbo;
  32834. /**
  32835. * Use this method to simulate a pointer move on a mesh
  32836. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32837. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32838. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32839. * @returns the current scene
  32840. */
  32841. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32842. /**
  32843. * Use this method to simulate a pointer down on a mesh
  32844. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32845. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32846. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32847. * @returns the current scene
  32848. */
  32849. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32850. /**
  32851. * Use this method to simulate a pointer up on a mesh
  32852. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32853. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32854. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32855. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32856. * @returns the current scene
  32857. */
  32858. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32859. /**
  32860. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32861. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32862. * @returns true if the pointer was captured
  32863. */
  32864. isPointerCaptured(pointerId?: number): boolean;
  32865. /**
  32866. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32867. * @param attachUp defines if you want to attach events to pointerup
  32868. * @param attachDown defines if you want to attach events to pointerdown
  32869. * @param attachMove defines if you want to attach events to pointermove
  32870. */
  32871. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32872. /** Detaches all event handlers*/
  32873. detachControl(): void;
  32874. /**
  32875. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32876. * Delay loaded resources are not taking in account
  32877. * @return true if all required resources are ready
  32878. */
  32879. isReady(): boolean;
  32880. /** Resets all cached information relative to material (including effect and visibility) */
  32881. resetCachedMaterial(): void;
  32882. /**
  32883. * Registers a function to be called before every frame render
  32884. * @param func defines the function to register
  32885. */
  32886. registerBeforeRender(func: () => void): void;
  32887. /**
  32888. * Unregisters a function called before every frame render
  32889. * @param func defines the function to unregister
  32890. */
  32891. unregisterBeforeRender(func: () => void): void;
  32892. /**
  32893. * Registers a function to be called after every frame render
  32894. * @param func defines the function to register
  32895. */
  32896. registerAfterRender(func: () => void): void;
  32897. /**
  32898. * Unregisters a function called after every frame render
  32899. * @param func defines the function to unregister
  32900. */
  32901. unregisterAfterRender(func: () => void): void;
  32902. private _executeOnceBeforeRender;
  32903. /**
  32904. * The provided function will run before render once and will be disposed afterwards.
  32905. * A timeout delay can be provided so that the function will be executed in N ms.
  32906. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32907. * @param func The function to be executed.
  32908. * @param timeout optional delay in ms
  32909. */
  32910. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32911. /** @hidden */
  32912. _addPendingData(data: any): void;
  32913. /** @hidden */
  32914. _removePendingData(data: any): void;
  32915. /**
  32916. * Returns the number of items waiting to be loaded
  32917. * @returns the number of items waiting to be loaded
  32918. */
  32919. getWaitingItemsCount(): number;
  32920. /**
  32921. * Returns a boolean indicating if the scene is still loading data
  32922. */
  32923. readonly isLoading: boolean;
  32924. /**
  32925. * Registers a function to be executed when the scene is ready
  32926. * @param {Function} func - the function to be executed
  32927. */
  32928. executeWhenReady(func: () => void): void;
  32929. /**
  32930. * Returns a promise that resolves when the scene is ready
  32931. * @returns A promise that resolves when the scene is ready
  32932. */
  32933. whenReadyAsync(): Promise<void>;
  32934. /** @hidden */
  32935. _checkIsReady(): void;
  32936. /**
  32937. * Gets all animatable attached to the scene
  32938. */
  32939. readonly animatables: Animatable[];
  32940. /**
  32941. * Resets the last animation time frame.
  32942. * Useful to override when animations start running when loading a scene for the first time.
  32943. */
  32944. resetLastAnimationTimeFrame(): void;
  32945. /**
  32946. * Gets the current view matrix
  32947. * @returns a Matrix
  32948. */
  32949. getViewMatrix(): Matrix;
  32950. /**
  32951. * Gets the current projection matrix
  32952. * @returns a Matrix
  32953. */
  32954. getProjectionMatrix(): Matrix;
  32955. /**
  32956. * Gets the current transform matrix
  32957. * @returns a Matrix made of View * Projection
  32958. */
  32959. getTransformMatrix(): Matrix;
  32960. /**
  32961. * Sets the current transform matrix
  32962. * @param viewL defines the View matrix to use
  32963. * @param projectionL defines the Projection matrix to use
  32964. * @param viewR defines the right View matrix to use (if provided)
  32965. * @param projectionR defines the right Projection matrix to use (if provided)
  32966. */
  32967. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32968. /**
  32969. * Gets the uniform buffer used to store scene data
  32970. * @returns a UniformBuffer
  32971. */
  32972. getSceneUniformBuffer(): UniformBuffer;
  32973. /**
  32974. * Gets an unique (relatively to the current scene) Id
  32975. * @returns an unique number for the scene
  32976. */
  32977. getUniqueId(): number;
  32978. /**
  32979. * Add a mesh to the list of scene's meshes
  32980. * @param newMesh defines the mesh to add
  32981. * @param recursive if all child meshes should also be added to the scene
  32982. */
  32983. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32984. /**
  32985. * Remove a mesh for the list of scene's meshes
  32986. * @param toRemove defines the mesh to remove
  32987. * @param recursive if all child meshes should also be removed from the scene
  32988. * @returns the index where the mesh was in the mesh list
  32989. */
  32990. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32991. /**
  32992. * Add a transform node to the list of scene's transform nodes
  32993. * @param newTransformNode defines the transform node to add
  32994. */
  32995. addTransformNode(newTransformNode: TransformNode): void;
  32996. /**
  32997. * Remove a transform node for the list of scene's transform nodes
  32998. * @param toRemove defines the transform node to remove
  32999. * @returns the index where the transform node was in the transform node list
  33000. */
  33001. removeTransformNode(toRemove: TransformNode): number;
  33002. /**
  33003. * Remove a skeleton for the list of scene's skeletons
  33004. * @param toRemove defines the skeleton to remove
  33005. * @returns the index where the skeleton was in the skeleton list
  33006. */
  33007. removeSkeleton(toRemove: Skeleton): number;
  33008. /**
  33009. * Remove a morph target for the list of scene's morph targets
  33010. * @param toRemove defines the morph target to remove
  33011. * @returns the index where the morph target was in the morph target list
  33012. */
  33013. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33014. /**
  33015. * Remove a light for the list of scene's lights
  33016. * @param toRemove defines the light to remove
  33017. * @returns the index where the light was in the light list
  33018. */
  33019. removeLight(toRemove: Light): number;
  33020. /**
  33021. * Remove a camera for the list of scene's cameras
  33022. * @param toRemove defines the camera to remove
  33023. * @returns the index where the camera was in the camera list
  33024. */
  33025. removeCamera(toRemove: Camera): number;
  33026. /**
  33027. * Remove a particle system for the list of scene's particle systems
  33028. * @param toRemove defines the particle system to remove
  33029. * @returns the index where the particle system was in the particle system list
  33030. */
  33031. removeParticleSystem(toRemove: IParticleSystem): number;
  33032. /**
  33033. * Remove a animation for the list of scene's animations
  33034. * @param toRemove defines the animation to remove
  33035. * @returns the index where the animation was in the animation list
  33036. */
  33037. removeAnimation(toRemove: Animation): number;
  33038. /**
  33039. * Will stop the animation of the given target
  33040. * @param target - the target
  33041. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33042. * @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)
  33043. */
  33044. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33045. /**
  33046. * Removes the given animation group from this scene.
  33047. * @param toRemove The animation group to remove
  33048. * @returns The index of the removed animation group
  33049. */
  33050. removeAnimationGroup(toRemove: AnimationGroup): number;
  33051. /**
  33052. * Removes the given multi-material from this scene.
  33053. * @param toRemove The multi-material to remove
  33054. * @returns The index of the removed multi-material
  33055. */
  33056. removeMultiMaterial(toRemove: MultiMaterial): number;
  33057. /**
  33058. * Removes the given material from this scene.
  33059. * @param toRemove The material to remove
  33060. * @returns The index of the removed material
  33061. */
  33062. removeMaterial(toRemove: Material): number;
  33063. /**
  33064. * Removes the given action manager from this scene.
  33065. * @param toRemove The action manager to remove
  33066. * @returns The index of the removed action manager
  33067. */
  33068. removeActionManager(toRemove: AbstractActionManager): number;
  33069. /**
  33070. * Removes the given texture from this scene.
  33071. * @param toRemove The texture to remove
  33072. * @returns The index of the removed texture
  33073. */
  33074. removeTexture(toRemove: BaseTexture): number;
  33075. /**
  33076. * Adds the given light to this scene
  33077. * @param newLight The light to add
  33078. */
  33079. addLight(newLight: Light): void;
  33080. /**
  33081. * Sorts the list list based on light priorities
  33082. */
  33083. sortLightsByPriority(): void;
  33084. /**
  33085. * Adds the given camera to this scene
  33086. * @param newCamera The camera to add
  33087. */
  33088. addCamera(newCamera: Camera): void;
  33089. /**
  33090. * Adds the given skeleton to this scene
  33091. * @param newSkeleton The skeleton to add
  33092. */
  33093. addSkeleton(newSkeleton: Skeleton): void;
  33094. /**
  33095. * Adds the given particle system to this scene
  33096. * @param newParticleSystem The particle system to add
  33097. */
  33098. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33099. /**
  33100. * Adds the given animation to this scene
  33101. * @param newAnimation The animation to add
  33102. */
  33103. addAnimation(newAnimation: Animation): void;
  33104. /**
  33105. * Adds the given animation group to this scene.
  33106. * @param newAnimationGroup The animation group to add
  33107. */
  33108. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33109. /**
  33110. * Adds the given multi-material to this scene
  33111. * @param newMultiMaterial The multi-material to add
  33112. */
  33113. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33114. /**
  33115. * Adds the given material to this scene
  33116. * @param newMaterial The material to add
  33117. */
  33118. addMaterial(newMaterial: Material): void;
  33119. /**
  33120. * Adds the given morph target to this scene
  33121. * @param newMorphTargetManager The morph target to add
  33122. */
  33123. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33124. /**
  33125. * Adds the given geometry to this scene
  33126. * @param newGeometry The geometry to add
  33127. */
  33128. addGeometry(newGeometry: Geometry): void;
  33129. /**
  33130. * Adds the given action manager to this scene
  33131. * @param newActionManager The action manager to add
  33132. */
  33133. addActionManager(newActionManager: AbstractActionManager): void;
  33134. /**
  33135. * Adds the given texture to this scene.
  33136. * @param newTexture The texture to add
  33137. */
  33138. addTexture(newTexture: BaseTexture): void;
  33139. /**
  33140. * Switch active camera
  33141. * @param newCamera defines the new active camera
  33142. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33143. */
  33144. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33145. /**
  33146. * sets the active camera of the scene using its ID
  33147. * @param id defines the camera's ID
  33148. * @return the new active camera or null if none found.
  33149. */
  33150. setActiveCameraByID(id: string): Nullable<Camera>;
  33151. /**
  33152. * sets the active camera of the scene using its name
  33153. * @param name defines the camera's name
  33154. * @returns the new active camera or null if none found.
  33155. */
  33156. setActiveCameraByName(name: string): Nullable<Camera>;
  33157. /**
  33158. * get an animation group using its name
  33159. * @param name defines the material's name
  33160. * @return the animation group or null if none found.
  33161. */
  33162. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33163. /**
  33164. * Get a material using its unique id
  33165. * @param uniqueId defines the material's unique id
  33166. * @return the material or null if none found.
  33167. */
  33168. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33169. /**
  33170. * get a material using its id
  33171. * @param id defines the material's ID
  33172. * @return the material or null if none found.
  33173. */
  33174. getMaterialByID(id: string): Nullable<Material>;
  33175. /**
  33176. * Gets a material using its name
  33177. * @param name defines the material's name
  33178. * @return the material or null if none found.
  33179. */
  33180. getMaterialByName(name: string): Nullable<Material>;
  33181. /**
  33182. * Gets a camera using its id
  33183. * @param id defines the id to look for
  33184. * @returns the camera or null if not found
  33185. */
  33186. getCameraByID(id: string): Nullable<Camera>;
  33187. /**
  33188. * Gets a camera using its unique id
  33189. * @param uniqueId defines the unique id to look for
  33190. * @returns the camera or null if not found
  33191. */
  33192. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33193. /**
  33194. * Gets a camera using its name
  33195. * @param name defines the camera's name
  33196. * @return the camera or null if none found.
  33197. */
  33198. getCameraByName(name: string): Nullable<Camera>;
  33199. /**
  33200. * Gets a bone using its id
  33201. * @param id defines the bone's id
  33202. * @return the bone or null if not found
  33203. */
  33204. getBoneByID(id: string): Nullable<Bone>;
  33205. /**
  33206. * Gets a bone using its id
  33207. * @param name defines the bone's name
  33208. * @return the bone or null if not found
  33209. */
  33210. getBoneByName(name: string): Nullable<Bone>;
  33211. /**
  33212. * Gets a light node using its name
  33213. * @param name defines the the light's name
  33214. * @return the light or null if none found.
  33215. */
  33216. getLightByName(name: string): Nullable<Light>;
  33217. /**
  33218. * Gets a light node using its id
  33219. * @param id defines the light's id
  33220. * @return the light or null if none found.
  33221. */
  33222. getLightByID(id: string): Nullable<Light>;
  33223. /**
  33224. * Gets a light node using its scene-generated unique ID
  33225. * @param uniqueId defines the light's unique id
  33226. * @return the light or null if none found.
  33227. */
  33228. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33229. /**
  33230. * Gets a particle system by id
  33231. * @param id defines the particle system id
  33232. * @return the corresponding system or null if none found
  33233. */
  33234. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33235. /**
  33236. * Gets a geometry using its ID
  33237. * @param id defines the geometry's id
  33238. * @return the geometry or null if none found.
  33239. */
  33240. getGeometryByID(id: string): Nullable<Geometry>;
  33241. private _getGeometryByUniqueID;
  33242. /**
  33243. * Add a new geometry to this scene
  33244. * @param geometry defines the geometry to be added to the scene.
  33245. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33246. * @return a boolean defining if the geometry was added or not
  33247. */
  33248. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33249. /**
  33250. * Removes an existing geometry
  33251. * @param geometry defines the geometry to be removed from the scene
  33252. * @return a boolean defining if the geometry was removed or not
  33253. */
  33254. removeGeometry(geometry: Geometry): boolean;
  33255. /**
  33256. * Gets the list of geometries attached to the scene
  33257. * @returns an array of Geometry
  33258. */
  33259. getGeometries(): Geometry[];
  33260. /**
  33261. * Gets the first added mesh found of a given ID
  33262. * @param id defines the id to search for
  33263. * @return the mesh found or null if not found at all
  33264. */
  33265. getMeshByID(id: string): Nullable<AbstractMesh>;
  33266. /**
  33267. * Gets a list of meshes using their id
  33268. * @param id defines the id to search for
  33269. * @returns a list of meshes
  33270. */
  33271. getMeshesByID(id: string): Array<AbstractMesh>;
  33272. /**
  33273. * Gets the first added transform node found of a given ID
  33274. * @param id defines the id to search for
  33275. * @return the found transform node or null if not found at all.
  33276. */
  33277. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33278. /**
  33279. * Gets a transform node with its auto-generated unique id
  33280. * @param uniqueId efines the unique id to search for
  33281. * @return the found transform node or null if not found at all.
  33282. */
  33283. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33284. /**
  33285. * Gets a list of transform nodes using their id
  33286. * @param id defines the id to search for
  33287. * @returns a list of transform nodes
  33288. */
  33289. getTransformNodesByID(id: string): Array<TransformNode>;
  33290. /**
  33291. * Gets a mesh with its auto-generated unique id
  33292. * @param uniqueId defines the unique id to search for
  33293. * @return the found mesh or null if not found at all.
  33294. */
  33295. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33296. /**
  33297. * Gets a the last added mesh using a given id
  33298. * @param id defines the id to search for
  33299. * @return the found mesh or null if not found at all.
  33300. */
  33301. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33302. /**
  33303. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33304. * @param id defines the id to search for
  33305. * @return the found node or null if not found at all
  33306. */
  33307. getLastEntryByID(id: string): Nullable<Node>;
  33308. /**
  33309. * Gets a node (Mesh, Camera, Light) using a given id
  33310. * @param id defines the id to search for
  33311. * @return the found node or null if not found at all
  33312. */
  33313. getNodeByID(id: string): Nullable<Node>;
  33314. /**
  33315. * Gets a node (Mesh, Camera, Light) using a given name
  33316. * @param name defines the name to search for
  33317. * @return the found node or null if not found at all.
  33318. */
  33319. getNodeByName(name: string): Nullable<Node>;
  33320. /**
  33321. * Gets a mesh using a given name
  33322. * @param name defines the name to search for
  33323. * @return the found mesh or null if not found at all.
  33324. */
  33325. getMeshByName(name: string): Nullable<AbstractMesh>;
  33326. /**
  33327. * Gets a transform node using a given name
  33328. * @param name defines the name to search for
  33329. * @return the found transform node or null if not found at all.
  33330. */
  33331. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33332. /**
  33333. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33334. * @param id defines the id to search for
  33335. * @return the found skeleton or null if not found at all.
  33336. */
  33337. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33338. /**
  33339. * Gets a skeleton using a given auto generated unique id
  33340. * @param uniqueId defines the unique id to search for
  33341. * @return the found skeleton or null if not found at all.
  33342. */
  33343. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33344. /**
  33345. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33346. * @param id defines the id to search for
  33347. * @return the found skeleton or null if not found at all.
  33348. */
  33349. getSkeletonById(id: string): Nullable<Skeleton>;
  33350. /**
  33351. * Gets a skeleton using a given name
  33352. * @param name defines the name to search for
  33353. * @return the found skeleton or null if not found at all.
  33354. */
  33355. getSkeletonByName(name: string): Nullable<Skeleton>;
  33356. /**
  33357. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33358. * @param id defines the id to search for
  33359. * @return the found morph target manager or null if not found at all.
  33360. */
  33361. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33362. /**
  33363. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33364. * @param id defines the id to search for
  33365. * @return the found morph target or null if not found at all.
  33366. */
  33367. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33368. /**
  33369. * Gets a boolean indicating if the given mesh is active
  33370. * @param mesh defines the mesh to look for
  33371. * @returns true if the mesh is in the active list
  33372. */
  33373. isActiveMesh(mesh: AbstractMesh): boolean;
  33374. /**
  33375. * Return a unique id as a string which can serve as an identifier for the scene
  33376. */
  33377. readonly uid: string;
  33378. /**
  33379. * Add an externaly attached data from its key.
  33380. * This method call will fail and return false, if such key already exists.
  33381. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33382. * @param key the unique key that identifies the data
  33383. * @param data the data object to associate to the key for this Engine instance
  33384. * @return true if no such key were already present and the data was added successfully, false otherwise
  33385. */
  33386. addExternalData<T>(key: string, data: T): boolean;
  33387. /**
  33388. * Get an externaly attached data from its key
  33389. * @param key the unique key that identifies the data
  33390. * @return the associated data, if present (can be null), or undefined if not present
  33391. */
  33392. getExternalData<T>(key: string): Nullable<T>;
  33393. /**
  33394. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33395. * @param key the unique key that identifies the data
  33396. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33397. * @return the associated data, can be null if the factory returned null.
  33398. */
  33399. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33400. /**
  33401. * Remove an externaly attached data from the Engine instance
  33402. * @param key the unique key that identifies the data
  33403. * @return true if the data was successfully removed, false if it doesn't exist
  33404. */
  33405. removeExternalData(key: string): boolean;
  33406. private _evaluateSubMesh;
  33407. /**
  33408. * Clear the processed materials smart array preventing retention point in material dispose.
  33409. */
  33410. freeProcessedMaterials(): void;
  33411. private _preventFreeActiveMeshesAndRenderingGroups;
  33412. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33413. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33414. * when disposing several meshes in a row or a hierarchy of meshes.
  33415. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33416. */
  33417. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33418. /**
  33419. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33420. */
  33421. freeActiveMeshes(): void;
  33422. /**
  33423. * Clear the info related to rendering groups preventing retention points during dispose.
  33424. */
  33425. freeRenderingGroups(): void;
  33426. /** @hidden */
  33427. _isInIntermediateRendering(): boolean;
  33428. /**
  33429. * Lambda returning the list of potentially active meshes.
  33430. */
  33431. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33432. /**
  33433. * Lambda returning the list of potentially active sub meshes.
  33434. */
  33435. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33436. /**
  33437. * Lambda returning the list of potentially intersecting sub meshes.
  33438. */
  33439. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33440. /**
  33441. * Lambda returning the list of potentially colliding sub meshes.
  33442. */
  33443. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33444. private _activeMeshesFrozen;
  33445. /**
  33446. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33447. * @returns the current scene
  33448. */
  33449. freezeActiveMeshes(): Scene;
  33450. /**
  33451. * Use this function to restart evaluating active meshes on every frame
  33452. * @returns the current scene
  33453. */
  33454. unfreezeActiveMeshes(): Scene;
  33455. private _evaluateActiveMeshes;
  33456. private _activeMesh;
  33457. /**
  33458. * Update the transform matrix to update from the current active camera
  33459. * @param force defines a boolean used to force the update even if cache is up to date
  33460. */
  33461. updateTransformMatrix(force?: boolean): void;
  33462. private _bindFrameBuffer;
  33463. /** @hidden */
  33464. _allowPostProcessClearColor: boolean;
  33465. /** @hidden */
  33466. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33467. private _processSubCameras;
  33468. private _checkIntersections;
  33469. /** @hidden */
  33470. _advancePhysicsEngineStep(step: number): void;
  33471. /**
  33472. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33473. */
  33474. getDeterministicFrameTime: () => number;
  33475. /** @hidden */
  33476. _animate(): void;
  33477. /** Execute all animations (for a frame) */
  33478. animate(): void;
  33479. /**
  33480. * Render the scene
  33481. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33482. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33483. */
  33484. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33485. /**
  33486. * Freeze all materials
  33487. * A frozen material will not be updatable but should be faster to render
  33488. */
  33489. freezeMaterials(): void;
  33490. /**
  33491. * Unfreeze all materials
  33492. * A frozen material will not be updatable but should be faster to render
  33493. */
  33494. unfreezeMaterials(): void;
  33495. /**
  33496. * Releases all held ressources
  33497. */
  33498. dispose(): void;
  33499. /**
  33500. * Gets if the scene is already disposed
  33501. */
  33502. readonly isDisposed: boolean;
  33503. /**
  33504. * Call this function to reduce memory footprint of the scene.
  33505. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33506. */
  33507. clearCachedVertexData(): void;
  33508. /**
  33509. * This function will remove the local cached buffer data from texture.
  33510. * It will save memory but will prevent the texture from being rebuilt
  33511. */
  33512. cleanCachedTextureBuffer(): void;
  33513. /**
  33514. * Get the world extend vectors with an optional filter
  33515. *
  33516. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33517. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33518. */
  33519. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33520. min: Vector3;
  33521. max: Vector3;
  33522. };
  33523. /**
  33524. * Creates a ray that can be used to pick in the scene
  33525. * @param x defines the x coordinate of the origin (on-screen)
  33526. * @param y defines the y coordinate of the origin (on-screen)
  33527. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33528. * @param camera defines the camera to use for the picking
  33529. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33530. * @returns a Ray
  33531. */
  33532. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33533. /**
  33534. * Creates a ray that can be used to pick in the scene
  33535. * @param x defines the x coordinate of the origin (on-screen)
  33536. * @param y defines the y coordinate of the origin (on-screen)
  33537. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33538. * @param result defines the ray where to store the picking ray
  33539. * @param camera defines the camera to use for the picking
  33540. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33541. * @returns the current scene
  33542. */
  33543. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33544. /**
  33545. * Creates a ray that can be used to pick in the scene
  33546. * @param x defines the x coordinate of the origin (on-screen)
  33547. * @param y defines the y coordinate of the origin (on-screen)
  33548. * @param camera defines the camera to use for the picking
  33549. * @returns a Ray
  33550. */
  33551. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33552. /**
  33553. * Creates a ray that can be used to pick in the scene
  33554. * @param x defines the x coordinate of the origin (on-screen)
  33555. * @param y defines the y coordinate of the origin (on-screen)
  33556. * @param result defines the ray where to store the picking ray
  33557. * @param camera defines the camera to use for the picking
  33558. * @returns the current scene
  33559. */
  33560. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33561. /** Launch a ray to try to pick a mesh in the scene
  33562. * @param x position on screen
  33563. * @param y position on screen
  33564. * @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
  33565. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33566. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33567. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33568. * @returns a PickingInfo
  33569. */
  33570. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33571. /** Use the given ray to pick a mesh in the scene
  33572. * @param ray The ray to use to pick meshes
  33573. * @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
  33574. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33575. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33576. * @returns a PickingInfo
  33577. */
  33578. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33579. /**
  33580. * Launch a ray to try to pick a mesh in the scene
  33581. * @param x X position on screen
  33582. * @param y Y position on screen
  33583. * @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
  33584. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33585. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33586. * @returns an array of PickingInfo
  33587. */
  33588. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33589. /**
  33590. * Launch a ray to try to pick a mesh in the scene
  33591. * @param ray Ray to use
  33592. * @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
  33593. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33594. * @returns an array of PickingInfo
  33595. */
  33596. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33597. /**
  33598. * Force the value of meshUnderPointer
  33599. * @param mesh defines the mesh to use
  33600. */
  33601. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33602. /**
  33603. * Gets the mesh under the pointer
  33604. * @returns a Mesh or null if no mesh is under the pointer
  33605. */
  33606. getPointerOverMesh(): Nullable<AbstractMesh>;
  33607. /** @hidden */
  33608. _rebuildGeometries(): void;
  33609. /** @hidden */
  33610. _rebuildTextures(): void;
  33611. private _getByTags;
  33612. /**
  33613. * Get a list of meshes by tags
  33614. * @param tagsQuery defines the tags query to use
  33615. * @param forEach defines a predicate used to filter results
  33616. * @returns an array of Mesh
  33617. */
  33618. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33619. /**
  33620. * Get a list of cameras by tags
  33621. * @param tagsQuery defines the tags query to use
  33622. * @param forEach defines a predicate used to filter results
  33623. * @returns an array of Camera
  33624. */
  33625. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33626. /**
  33627. * Get a list of lights by tags
  33628. * @param tagsQuery defines the tags query to use
  33629. * @param forEach defines a predicate used to filter results
  33630. * @returns an array of Light
  33631. */
  33632. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33633. /**
  33634. * Get a list of materials by tags
  33635. * @param tagsQuery defines the tags query to use
  33636. * @param forEach defines a predicate used to filter results
  33637. * @returns an array of Material
  33638. */
  33639. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33640. /**
  33641. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33642. * This allowed control for front to back rendering or reversly depending of the special needs.
  33643. *
  33644. * @param renderingGroupId The rendering group id corresponding to its index
  33645. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33646. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33647. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33648. */
  33649. 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;
  33650. /**
  33651. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33652. *
  33653. * @param renderingGroupId The rendering group id corresponding to its index
  33654. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33655. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33656. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33657. */
  33658. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33659. /**
  33660. * Gets the current auto clear configuration for one rendering group of the rendering
  33661. * manager.
  33662. * @param index the rendering group index to get the information for
  33663. * @returns The auto clear setup for the requested rendering group
  33664. */
  33665. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33666. private _blockMaterialDirtyMechanism;
  33667. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33668. blockMaterialDirtyMechanism: boolean;
  33669. /**
  33670. * Will flag all materials as dirty to trigger new shader compilation
  33671. * @param flag defines the flag used to specify which material part must be marked as dirty
  33672. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33673. */
  33674. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33675. /** @hidden */
  33676. _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;
  33677. /** @hidden */
  33678. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33679. }
  33680. }
  33681. declare module BABYLON {
  33682. /**
  33683. * Set of assets to keep when moving a scene into an asset container.
  33684. */
  33685. export class KeepAssets extends AbstractScene {
  33686. }
  33687. /**
  33688. * Container with a set of assets that can be added or removed from a scene.
  33689. */
  33690. export class AssetContainer extends AbstractScene {
  33691. /**
  33692. * The scene the AssetContainer belongs to.
  33693. */
  33694. scene: Scene;
  33695. /**
  33696. * Instantiates an AssetContainer.
  33697. * @param scene The scene the AssetContainer belongs to.
  33698. */
  33699. constructor(scene: Scene);
  33700. /**
  33701. * Adds all the assets from the container to the scene.
  33702. */
  33703. addAllToScene(): void;
  33704. /**
  33705. * Removes all the assets in the container from the scene
  33706. */
  33707. removeAllFromScene(): void;
  33708. /**
  33709. * Disposes all the assets in the container
  33710. */
  33711. dispose(): void;
  33712. private _moveAssets;
  33713. /**
  33714. * Removes all the assets contained in the scene and adds them to the container.
  33715. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33716. */
  33717. moveAllFromScene(keepAssets?: KeepAssets): void;
  33718. /**
  33719. * 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.
  33720. * @returns the root mesh
  33721. */
  33722. createRootMesh(): Mesh;
  33723. }
  33724. }
  33725. declare module BABYLON {
  33726. /**
  33727. * Defines how the parser contract is defined.
  33728. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33729. */
  33730. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33731. /**
  33732. * Defines how the individual parser contract is defined.
  33733. * These parser can parse an individual asset
  33734. */
  33735. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33736. /**
  33737. * Base class of the scene acting as a container for the different elements composing a scene.
  33738. * This class is dynamically extended by the different components of the scene increasing
  33739. * flexibility and reducing coupling
  33740. */
  33741. export abstract class AbstractScene {
  33742. /**
  33743. * Stores the list of available parsers in the application.
  33744. */
  33745. private static _BabylonFileParsers;
  33746. /**
  33747. * Stores the list of available individual parsers in the application.
  33748. */
  33749. private static _IndividualBabylonFileParsers;
  33750. /**
  33751. * Adds a parser in the list of available ones
  33752. * @param name Defines the name of the parser
  33753. * @param parser Defines the parser to add
  33754. */
  33755. static AddParser(name: string, parser: BabylonFileParser): void;
  33756. /**
  33757. * Gets a general parser from the list of avaialble ones
  33758. * @param name Defines the name of the parser
  33759. * @returns the requested parser or null
  33760. */
  33761. static GetParser(name: string): Nullable<BabylonFileParser>;
  33762. /**
  33763. * Adds n individual parser in the list of available ones
  33764. * @param name Defines the name of the parser
  33765. * @param parser Defines the parser to add
  33766. */
  33767. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33768. /**
  33769. * Gets an individual parser from the list of avaialble ones
  33770. * @param name Defines the name of the parser
  33771. * @returns the requested parser or null
  33772. */
  33773. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33774. /**
  33775. * Parser json data and populate both a scene and its associated container object
  33776. * @param jsonData Defines the data to parse
  33777. * @param scene Defines the scene to parse the data for
  33778. * @param container Defines the container attached to the parsing sequence
  33779. * @param rootUrl Defines the root url of the data
  33780. */
  33781. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33782. /**
  33783. * Gets the list of root nodes (ie. nodes with no parent)
  33784. */
  33785. rootNodes: Node[];
  33786. /** All of the cameras added to this scene
  33787. * @see http://doc.babylonjs.com/babylon101/cameras
  33788. */
  33789. cameras: Camera[];
  33790. /**
  33791. * All of the lights added to this scene
  33792. * @see http://doc.babylonjs.com/babylon101/lights
  33793. */
  33794. lights: Light[];
  33795. /**
  33796. * All of the (abstract) meshes added to this scene
  33797. */
  33798. meshes: AbstractMesh[];
  33799. /**
  33800. * The list of skeletons added to the scene
  33801. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33802. */
  33803. skeletons: Skeleton[];
  33804. /**
  33805. * All of the particle systems added to this scene
  33806. * @see http://doc.babylonjs.com/babylon101/particles
  33807. */
  33808. particleSystems: IParticleSystem[];
  33809. /**
  33810. * Gets a list of Animations associated with the scene
  33811. */
  33812. animations: Animation[];
  33813. /**
  33814. * All of the animation groups added to this scene
  33815. * @see http://doc.babylonjs.com/how_to/group
  33816. */
  33817. animationGroups: AnimationGroup[];
  33818. /**
  33819. * All of the multi-materials added to this scene
  33820. * @see http://doc.babylonjs.com/how_to/multi_materials
  33821. */
  33822. multiMaterials: MultiMaterial[];
  33823. /**
  33824. * All of the materials added to this scene
  33825. * In the context of a Scene, it is not supposed to be modified manually.
  33826. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33827. * Note also that the order of the Material wihin the array is not significant and might change.
  33828. * @see http://doc.babylonjs.com/babylon101/materials
  33829. */
  33830. materials: Material[];
  33831. /**
  33832. * The list of morph target managers added to the scene
  33833. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33834. */
  33835. morphTargetManagers: MorphTargetManager[];
  33836. /**
  33837. * The list of geometries used in the scene.
  33838. */
  33839. geometries: Geometry[];
  33840. /**
  33841. * All of the tranform nodes added to this scene
  33842. * In the context of a Scene, it is not supposed to be modified manually.
  33843. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33844. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33845. * @see http://doc.babylonjs.com/how_to/transformnode
  33846. */
  33847. transformNodes: TransformNode[];
  33848. /**
  33849. * ActionManagers available on the scene.
  33850. */
  33851. actionManagers: AbstractActionManager[];
  33852. /**
  33853. * Textures to keep.
  33854. */
  33855. textures: BaseTexture[];
  33856. /**
  33857. * Environment texture for the scene
  33858. */
  33859. environmentTexture: Nullable<BaseTexture>;
  33860. }
  33861. }
  33862. declare module BABYLON {
  33863. /**
  33864. * Defines a sound that can be played in the application.
  33865. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33867. */
  33868. export class Sound {
  33869. /**
  33870. * The name of the sound in the scene.
  33871. */
  33872. name: string;
  33873. /**
  33874. * Does the sound autoplay once loaded.
  33875. */
  33876. autoplay: boolean;
  33877. /**
  33878. * Does the sound loop after it finishes playing once.
  33879. */
  33880. loop: boolean;
  33881. /**
  33882. * Does the sound use a custom attenuation curve to simulate the falloff
  33883. * happening when the source gets further away from the camera.
  33884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33885. */
  33886. useCustomAttenuation: boolean;
  33887. /**
  33888. * The sound track id this sound belongs to.
  33889. */
  33890. soundTrackId: number;
  33891. /**
  33892. * Is this sound currently played.
  33893. */
  33894. isPlaying: boolean;
  33895. /**
  33896. * Is this sound currently paused.
  33897. */
  33898. isPaused: boolean;
  33899. /**
  33900. * Does this sound enables spatial sound.
  33901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33902. */
  33903. spatialSound: boolean;
  33904. /**
  33905. * Define the reference distance the sound should be heard perfectly.
  33906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33907. */
  33908. refDistance: number;
  33909. /**
  33910. * Define the roll off factor of spatial sounds.
  33911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33912. */
  33913. rolloffFactor: number;
  33914. /**
  33915. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33917. */
  33918. maxDistance: number;
  33919. /**
  33920. * Define the distance attenuation model the sound will follow.
  33921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33922. */
  33923. distanceModel: string;
  33924. /**
  33925. * @hidden
  33926. * Back Compat
  33927. **/
  33928. onended: () => any;
  33929. /**
  33930. * Observable event when the current playing sound finishes.
  33931. */
  33932. onEndedObservable: Observable<Sound>;
  33933. private _panningModel;
  33934. private _playbackRate;
  33935. private _streaming;
  33936. private _startTime;
  33937. private _startOffset;
  33938. private _position;
  33939. /** @hidden */
  33940. _positionInEmitterSpace: boolean;
  33941. private _localDirection;
  33942. private _volume;
  33943. private _isReadyToPlay;
  33944. private _isDirectional;
  33945. private _readyToPlayCallback;
  33946. private _audioBuffer;
  33947. private _soundSource;
  33948. private _streamingSource;
  33949. private _soundPanner;
  33950. private _soundGain;
  33951. private _inputAudioNode;
  33952. private _outputAudioNode;
  33953. private _coneInnerAngle;
  33954. private _coneOuterAngle;
  33955. private _coneOuterGain;
  33956. private _scene;
  33957. private _connectedTransformNode;
  33958. private _customAttenuationFunction;
  33959. private _registerFunc;
  33960. private _isOutputConnected;
  33961. private _htmlAudioElement;
  33962. private _urlType;
  33963. /** @hidden */
  33964. static _SceneComponentInitialization: (scene: Scene) => void;
  33965. /**
  33966. * Create a sound and attach it to a scene
  33967. * @param name Name of your sound
  33968. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33969. * @param scene defines the scene the sound belongs to
  33970. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33971. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33972. */
  33973. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33974. /**
  33975. * Release the sound and its associated resources
  33976. */
  33977. dispose(): void;
  33978. /**
  33979. * Gets if the sounds is ready to be played or not.
  33980. * @returns true if ready, otherwise false
  33981. */
  33982. isReady(): boolean;
  33983. private _soundLoaded;
  33984. /**
  33985. * Sets the data of the sound from an audiobuffer
  33986. * @param audioBuffer The audioBuffer containing the data
  33987. */
  33988. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33989. /**
  33990. * Updates the current sounds options such as maxdistance, loop...
  33991. * @param options A JSON object containing values named as the object properties
  33992. */
  33993. updateOptions(options: any): void;
  33994. private _createSpatialParameters;
  33995. private _updateSpatialParameters;
  33996. /**
  33997. * Switch the panning model to HRTF:
  33998. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34000. */
  34001. switchPanningModelToHRTF(): void;
  34002. /**
  34003. * Switch the panning model to Equal Power:
  34004. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34006. */
  34007. switchPanningModelToEqualPower(): void;
  34008. private _switchPanningModel;
  34009. /**
  34010. * Connect this sound to a sound track audio node like gain...
  34011. * @param soundTrackAudioNode the sound track audio node to connect to
  34012. */
  34013. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34014. /**
  34015. * Transform this sound into a directional source
  34016. * @param coneInnerAngle Size of the inner cone in degree
  34017. * @param coneOuterAngle Size of the outer cone in degree
  34018. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34019. */
  34020. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34021. /**
  34022. * Gets or sets the inner angle for the directional cone.
  34023. */
  34024. /**
  34025. * Gets or sets the inner angle for the directional cone.
  34026. */
  34027. directionalConeInnerAngle: number;
  34028. /**
  34029. * Gets or sets the outer angle for the directional cone.
  34030. */
  34031. /**
  34032. * Gets or sets the outer angle for the directional cone.
  34033. */
  34034. directionalConeOuterAngle: number;
  34035. /**
  34036. * Sets the position of the emitter if spatial sound is enabled
  34037. * @param newPosition Defines the new posisiton
  34038. */
  34039. setPosition(newPosition: Vector3): void;
  34040. /**
  34041. * Sets the local direction of the emitter if spatial sound is enabled
  34042. * @param newLocalDirection Defines the new local direction
  34043. */
  34044. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34045. private _updateDirection;
  34046. /** @hidden */
  34047. updateDistanceFromListener(): void;
  34048. /**
  34049. * Sets a new custom attenuation function for the sound.
  34050. * @param callback Defines the function used for the attenuation
  34051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34052. */
  34053. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34054. /**
  34055. * Play the sound
  34056. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34057. * @param offset (optional) Start the sound setting it at a specific time
  34058. */
  34059. play(time?: number, offset?: number): void;
  34060. private _onended;
  34061. /**
  34062. * Stop the sound
  34063. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34064. */
  34065. stop(time?: number): void;
  34066. /**
  34067. * Put the sound in pause
  34068. */
  34069. pause(): void;
  34070. /**
  34071. * Sets a dedicated volume for this sounds
  34072. * @param newVolume Define the new volume of the sound
  34073. * @param time Define in how long the sound should be at this value
  34074. */
  34075. setVolume(newVolume: number, time?: number): void;
  34076. /**
  34077. * Set the sound play back rate
  34078. * @param newPlaybackRate Define the playback rate the sound should be played at
  34079. */
  34080. setPlaybackRate(newPlaybackRate: number): void;
  34081. /**
  34082. * Gets the volume of the sound.
  34083. * @returns the volume of the sound
  34084. */
  34085. getVolume(): number;
  34086. /**
  34087. * Attach the sound to a dedicated mesh
  34088. * @param transformNode The transform node to connect the sound with
  34089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34090. */
  34091. attachToMesh(transformNode: TransformNode): void;
  34092. /**
  34093. * Detach the sound from the previously attached mesh
  34094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34095. */
  34096. detachFromMesh(): void;
  34097. private _onRegisterAfterWorldMatrixUpdate;
  34098. /**
  34099. * Clone the current sound in the scene.
  34100. * @returns the new sound clone
  34101. */
  34102. clone(): Nullable<Sound>;
  34103. /**
  34104. * Gets the current underlying audio buffer containing the data
  34105. * @returns the audio buffer
  34106. */
  34107. getAudioBuffer(): Nullable<AudioBuffer>;
  34108. /**
  34109. * Serializes the Sound in a JSON representation
  34110. * @returns the JSON representation of the sound
  34111. */
  34112. serialize(): any;
  34113. /**
  34114. * Parse a JSON representation of a sound to innstantiate in a given scene
  34115. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34116. * @param scene Define the scene the new parsed sound should be created in
  34117. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34118. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34119. * @returns the newly parsed sound
  34120. */
  34121. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34122. }
  34123. }
  34124. declare module BABYLON {
  34125. /**
  34126. * This defines an action helpful to play a defined sound on a triggered action.
  34127. */
  34128. export class PlaySoundAction extends Action {
  34129. private _sound;
  34130. /**
  34131. * Instantiate the action
  34132. * @param triggerOptions defines the trigger options
  34133. * @param sound defines the sound to play
  34134. * @param condition defines the trigger related conditions
  34135. */
  34136. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34137. /** @hidden */
  34138. _prepare(): void;
  34139. /**
  34140. * Execute the action and play the sound.
  34141. */
  34142. execute(): void;
  34143. /**
  34144. * Serializes the actions and its related information.
  34145. * @param parent defines the object to serialize in
  34146. * @returns the serialized object
  34147. */
  34148. serialize(parent: any): any;
  34149. }
  34150. /**
  34151. * This defines an action helpful to stop a defined sound on a triggered action.
  34152. */
  34153. export class StopSoundAction extends Action {
  34154. private _sound;
  34155. /**
  34156. * Instantiate the action
  34157. * @param triggerOptions defines the trigger options
  34158. * @param sound defines the sound to stop
  34159. * @param condition defines the trigger related conditions
  34160. */
  34161. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34162. /** @hidden */
  34163. _prepare(): void;
  34164. /**
  34165. * Execute the action and stop the sound.
  34166. */
  34167. execute(): void;
  34168. /**
  34169. * Serializes the actions and its related information.
  34170. * @param parent defines the object to serialize in
  34171. * @returns the serialized object
  34172. */
  34173. serialize(parent: any): any;
  34174. }
  34175. }
  34176. declare module BABYLON {
  34177. /**
  34178. * This defines an action responsible to change the value of a property
  34179. * by interpolating between its current value and the newly set one once triggered.
  34180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34181. */
  34182. export class InterpolateValueAction extends Action {
  34183. /**
  34184. * Defines the path of the property where the value should be interpolated
  34185. */
  34186. propertyPath: string;
  34187. /**
  34188. * Defines the target value at the end of the interpolation.
  34189. */
  34190. value: any;
  34191. /**
  34192. * Defines the time it will take for the property to interpolate to the value.
  34193. */
  34194. duration: number;
  34195. /**
  34196. * Defines if the other scene animations should be stopped when the action has been triggered
  34197. */
  34198. stopOtherAnimations?: boolean;
  34199. /**
  34200. * Defines a callback raised once the interpolation animation has been done.
  34201. */
  34202. onInterpolationDone?: () => void;
  34203. /**
  34204. * Observable triggered once the interpolation animation has been done.
  34205. */
  34206. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34207. private _target;
  34208. private _effectiveTarget;
  34209. private _property;
  34210. /**
  34211. * Instantiate the action
  34212. * @param triggerOptions defines the trigger options
  34213. * @param target defines the object containing the value to interpolate
  34214. * @param propertyPath defines the path to the property in the target object
  34215. * @param value defines the target value at the end of the interpolation
  34216. * @param duration deines the time it will take for the property to interpolate to the value.
  34217. * @param condition defines the trigger related conditions
  34218. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34219. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34220. */
  34221. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34222. /** @hidden */
  34223. _prepare(): void;
  34224. /**
  34225. * Execute the action starts the value interpolation.
  34226. */
  34227. execute(): void;
  34228. /**
  34229. * Serializes the actions and its related information.
  34230. * @param parent defines the object to serialize in
  34231. * @returns the serialized object
  34232. */
  34233. serialize(parent: any): any;
  34234. }
  34235. }
  34236. declare module BABYLON {
  34237. /**
  34238. * Options allowed during the creation of a sound track.
  34239. */
  34240. export interface ISoundTrackOptions {
  34241. /**
  34242. * The volume the sound track should take during creation
  34243. */
  34244. volume?: number;
  34245. /**
  34246. * Define if the sound track is the main sound track of the scene
  34247. */
  34248. mainTrack?: boolean;
  34249. }
  34250. /**
  34251. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34252. * It will be also used in a future release to apply effects on a specific track.
  34253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34254. */
  34255. export class SoundTrack {
  34256. /**
  34257. * The unique identifier of the sound track in the scene.
  34258. */
  34259. id: number;
  34260. /**
  34261. * The list of sounds included in the sound track.
  34262. */
  34263. soundCollection: Array<Sound>;
  34264. private _outputAudioNode;
  34265. private _scene;
  34266. private _isMainTrack;
  34267. private _connectedAnalyser;
  34268. private _options;
  34269. private _isInitialized;
  34270. /**
  34271. * Creates a new sound track.
  34272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34273. * @param scene Define the scene the sound track belongs to
  34274. * @param options
  34275. */
  34276. constructor(scene: Scene, options?: ISoundTrackOptions);
  34277. private _initializeSoundTrackAudioGraph;
  34278. /**
  34279. * Release the sound track and its associated resources
  34280. */
  34281. dispose(): void;
  34282. /**
  34283. * Adds a sound to this sound track
  34284. * @param sound define the cound to add
  34285. * @ignoreNaming
  34286. */
  34287. AddSound(sound: Sound): void;
  34288. /**
  34289. * Removes a sound to this sound track
  34290. * @param sound define the cound to remove
  34291. * @ignoreNaming
  34292. */
  34293. RemoveSound(sound: Sound): void;
  34294. /**
  34295. * Set a global volume for the full sound track.
  34296. * @param newVolume Define the new volume of the sound track
  34297. */
  34298. setVolume(newVolume: number): void;
  34299. /**
  34300. * Switch the panning model to HRTF:
  34301. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34303. */
  34304. switchPanningModelToHRTF(): void;
  34305. /**
  34306. * Switch the panning model to Equal Power:
  34307. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34309. */
  34310. switchPanningModelToEqualPower(): void;
  34311. /**
  34312. * Connect the sound track to an audio analyser allowing some amazing
  34313. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34315. * @param analyser The analyser to connect to the engine
  34316. */
  34317. connectToAnalyser(analyser: Analyser): void;
  34318. }
  34319. }
  34320. declare module BABYLON {
  34321. interface AbstractScene {
  34322. /**
  34323. * The list of sounds used in the scene.
  34324. */
  34325. sounds: Nullable<Array<Sound>>;
  34326. }
  34327. interface Scene {
  34328. /**
  34329. * @hidden
  34330. * Backing field
  34331. */
  34332. _mainSoundTrack: SoundTrack;
  34333. /**
  34334. * The main sound track played by the scene.
  34335. * It cotains your primary collection of sounds.
  34336. */
  34337. mainSoundTrack: SoundTrack;
  34338. /**
  34339. * The list of sound tracks added to the scene
  34340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34341. */
  34342. soundTracks: Nullable<Array<SoundTrack>>;
  34343. /**
  34344. * Gets a sound using a given name
  34345. * @param name defines the name to search for
  34346. * @return the found sound or null if not found at all.
  34347. */
  34348. getSoundByName(name: string): Nullable<Sound>;
  34349. /**
  34350. * Gets or sets if audio support is enabled
  34351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34352. */
  34353. audioEnabled: boolean;
  34354. /**
  34355. * Gets or sets if audio will be output to headphones
  34356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34357. */
  34358. headphone: boolean;
  34359. }
  34360. /**
  34361. * Defines the sound scene component responsible to manage any sounds
  34362. * in a given scene.
  34363. */
  34364. export class AudioSceneComponent implements ISceneSerializableComponent {
  34365. /**
  34366. * The component name helpfull to identify the component in the list of scene components.
  34367. */
  34368. readonly name: string;
  34369. /**
  34370. * The scene the component belongs to.
  34371. */
  34372. scene: Scene;
  34373. private _audioEnabled;
  34374. /**
  34375. * Gets whether audio is enabled or not.
  34376. * Please use related enable/disable method to switch state.
  34377. */
  34378. readonly audioEnabled: boolean;
  34379. private _headphone;
  34380. /**
  34381. * Gets whether audio is outputing to headphone or not.
  34382. * Please use the according Switch methods to change output.
  34383. */
  34384. readonly headphone: boolean;
  34385. /**
  34386. * Creates a new instance of the component for the given scene
  34387. * @param scene Defines the scene to register the component in
  34388. */
  34389. constructor(scene: Scene);
  34390. /**
  34391. * Registers the component in a given scene
  34392. */
  34393. register(): void;
  34394. /**
  34395. * Rebuilds the elements related to this component in case of
  34396. * context lost for instance.
  34397. */
  34398. rebuild(): void;
  34399. /**
  34400. * Serializes the component data to the specified json object
  34401. * @param serializationObject The object to serialize to
  34402. */
  34403. serialize(serializationObject: any): void;
  34404. /**
  34405. * Adds all the element from the container to the scene
  34406. * @param container the container holding the elements
  34407. */
  34408. addFromContainer(container: AbstractScene): void;
  34409. /**
  34410. * Removes all the elements in the container from the scene
  34411. * @param container contains the elements to remove
  34412. * @param dispose if the removed element should be disposed (default: false)
  34413. */
  34414. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34415. /**
  34416. * Disposes the component and the associated ressources.
  34417. */
  34418. dispose(): void;
  34419. /**
  34420. * Disables audio in the associated scene.
  34421. */
  34422. disableAudio(): void;
  34423. /**
  34424. * Enables audio in the associated scene.
  34425. */
  34426. enableAudio(): void;
  34427. /**
  34428. * Switch audio to headphone output.
  34429. */
  34430. switchAudioModeForHeadphones(): void;
  34431. /**
  34432. * Switch audio to normal speakers.
  34433. */
  34434. switchAudioModeForNormalSpeakers(): void;
  34435. private _afterRender;
  34436. }
  34437. }
  34438. declare module BABYLON {
  34439. /**
  34440. * Wraps one or more Sound objects and selects one with random weight for playback.
  34441. */
  34442. export class WeightedSound {
  34443. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34444. loop: boolean;
  34445. private _coneInnerAngle;
  34446. private _coneOuterAngle;
  34447. private _volume;
  34448. /** A Sound is currently playing. */
  34449. isPlaying: boolean;
  34450. /** A Sound is currently paused. */
  34451. isPaused: boolean;
  34452. private _sounds;
  34453. private _weights;
  34454. private _currentIndex?;
  34455. /**
  34456. * Creates a new WeightedSound from the list of sounds given.
  34457. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34458. * @param sounds Array of Sounds that will be selected from.
  34459. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34460. */
  34461. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34462. /**
  34463. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34464. */
  34465. /**
  34466. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34467. */
  34468. directionalConeInnerAngle: number;
  34469. /**
  34470. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34471. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34472. */
  34473. /**
  34474. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34475. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34476. */
  34477. directionalConeOuterAngle: number;
  34478. /**
  34479. * Playback volume.
  34480. */
  34481. /**
  34482. * Playback volume.
  34483. */
  34484. volume: number;
  34485. private _onended;
  34486. /**
  34487. * Suspend playback
  34488. */
  34489. pause(): void;
  34490. /**
  34491. * Stop playback
  34492. */
  34493. stop(): void;
  34494. /**
  34495. * Start playback.
  34496. * @param startOffset Position the clip head at a specific time in seconds.
  34497. */
  34498. play(startOffset?: number): void;
  34499. }
  34500. }
  34501. declare module BABYLON {
  34502. /**
  34503. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34504. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34505. */
  34506. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34507. /**
  34508. * Gets the name of the behavior.
  34509. */
  34510. readonly name: string;
  34511. /**
  34512. * The easing function used by animations
  34513. */
  34514. static EasingFunction: BackEase;
  34515. /**
  34516. * The easing mode used by animations
  34517. */
  34518. static EasingMode: number;
  34519. /**
  34520. * The duration of the animation, in milliseconds
  34521. */
  34522. transitionDuration: number;
  34523. /**
  34524. * Length of the distance animated by the transition when lower radius is reached
  34525. */
  34526. lowerRadiusTransitionRange: number;
  34527. /**
  34528. * Length of the distance animated by the transition when upper radius is reached
  34529. */
  34530. upperRadiusTransitionRange: number;
  34531. private _autoTransitionRange;
  34532. /**
  34533. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34534. */
  34535. /**
  34536. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34537. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34538. */
  34539. autoTransitionRange: boolean;
  34540. private _attachedCamera;
  34541. private _onAfterCheckInputsObserver;
  34542. private _onMeshTargetChangedObserver;
  34543. /**
  34544. * Initializes the behavior.
  34545. */
  34546. init(): void;
  34547. /**
  34548. * Attaches the behavior to its arc rotate camera.
  34549. * @param camera Defines the camera to attach the behavior to
  34550. */
  34551. attach(camera: ArcRotateCamera): void;
  34552. /**
  34553. * Detaches the behavior from its current arc rotate camera.
  34554. */
  34555. detach(): void;
  34556. private _radiusIsAnimating;
  34557. private _radiusBounceTransition;
  34558. private _animatables;
  34559. private _cachedWheelPrecision;
  34560. /**
  34561. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34562. * @param radiusLimit The limit to check against.
  34563. * @return Bool to indicate if at limit.
  34564. */
  34565. private _isRadiusAtLimit;
  34566. /**
  34567. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34568. * @param radiusDelta The delta by which to animate to. Can be negative.
  34569. */
  34570. private _applyBoundRadiusAnimation;
  34571. /**
  34572. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34573. */
  34574. protected _clearAnimationLocks(): void;
  34575. /**
  34576. * Stops and removes all animations that have been applied to the camera
  34577. */
  34578. stopAllAnimations(): void;
  34579. }
  34580. }
  34581. declare module BABYLON {
  34582. /**
  34583. * 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.
  34584. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34585. */
  34586. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34587. /**
  34588. * Gets the name of the behavior.
  34589. */
  34590. readonly name: string;
  34591. private _mode;
  34592. private _radiusScale;
  34593. private _positionScale;
  34594. private _defaultElevation;
  34595. private _elevationReturnTime;
  34596. private _elevationReturnWaitTime;
  34597. private _zoomStopsAnimation;
  34598. private _framingTime;
  34599. /**
  34600. * The easing function used by animations
  34601. */
  34602. static EasingFunction: ExponentialEase;
  34603. /**
  34604. * The easing mode used by animations
  34605. */
  34606. static EasingMode: number;
  34607. /**
  34608. * Sets the current mode used by the behavior
  34609. */
  34610. /**
  34611. * Gets current mode used by the behavior.
  34612. */
  34613. mode: number;
  34614. /**
  34615. * Sets the scale applied to the radius (1 by default)
  34616. */
  34617. /**
  34618. * Gets the scale applied to the radius
  34619. */
  34620. radiusScale: number;
  34621. /**
  34622. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34623. */
  34624. /**
  34625. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34626. */
  34627. positionScale: number;
  34628. /**
  34629. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34630. * behaviour is triggered, in radians.
  34631. */
  34632. /**
  34633. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34634. * behaviour is triggered, in radians.
  34635. */
  34636. defaultElevation: number;
  34637. /**
  34638. * Sets the time (in milliseconds) taken to return to the default beta position.
  34639. * Negative value indicates camera should not return to default.
  34640. */
  34641. /**
  34642. * Gets the time (in milliseconds) taken to return to the default beta position.
  34643. * Negative value indicates camera should not return to default.
  34644. */
  34645. elevationReturnTime: number;
  34646. /**
  34647. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34648. */
  34649. /**
  34650. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34651. */
  34652. elevationReturnWaitTime: number;
  34653. /**
  34654. * Sets the flag that indicates if user zooming should stop animation.
  34655. */
  34656. /**
  34657. * Gets the flag that indicates if user zooming should stop animation.
  34658. */
  34659. zoomStopsAnimation: boolean;
  34660. /**
  34661. * Sets the transition time when framing the mesh, in milliseconds
  34662. */
  34663. /**
  34664. * Gets the transition time when framing the mesh, in milliseconds
  34665. */
  34666. framingTime: number;
  34667. /**
  34668. * Define if the behavior should automatically change the configured
  34669. * camera limits and sensibilities.
  34670. */
  34671. autoCorrectCameraLimitsAndSensibility: boolean;
  34672. private _onPrePointerObservableObserver;
  34673. private _onAfterCheckInputsObserver;
  34674. private _onMeshTargetChangedObserver;
  34675. private _attachedCamera;
  34676. private _isPointerDown;
  34677. private _lastInteractionTime;
  34678. /**
  34679. * Initializes the behavior.
  34680. */
  34681. init(): void;
  34682. /**
  34683. * Attaches the behavior to its arc rotate camera.
  34684. * @param camera Defines the camera to attach the behavior to
  34685. */
  34686. attach(camera: ArcRotateCamera): void;
  34687. /**
  34688. * Detaches the behavior from its current arc rotate camera.
  34689. */
  34690. detach(): void;
  34691. private _animatables;
  34692. private _betaIsAnimating;
  34693. private _betaTransition;
  34694. private _radiusTransition;
  34695. private _vectorTransition;
  34696. /**
  34697. * Targets the given mesh and updates zoom level accordingly.
  34698. * @param mesh The mesh to target.
  34699. * @param radius Optional. If a cached radius position already exists, overrides default.
  34700. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34701. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34702. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34703. */
  34704. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34705. /**
  34706. * Targets the given mesh with its children and updates zoom level accordingly.
  34707. * @param mesh The mesh to target.
  34708. * @param radius Optional. If a cached radius position already exists, overrides default.
  34709. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34710. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34711. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34712. */
  34713. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34714. /**
  34715. * Targets the given meshes with their children and updates zoom level accordingly.
  34716. * @param meshes The mesh to target.
  34717. * @param radius Optional. If a cached radius position already exists, overrides default.
  34718. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34719. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34720. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34721. */
  34722. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34723. /**
  34724. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34725. * @param minimumWorld Determines the smaller position of the bounding box extend
  34726. * @param maximumWorld Determines the bigger position of the bounding box extend
  34727. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34728. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34729. */
  34730. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34731. /**
  34732. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34733. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34734. * frustum width.
  34735. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34736. * to fully enclose the mesh in the viewing frustum.
  34737. */
  34738. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34739. /**
  34740. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34741. * is automatically returned to its default position (expected to be above ground plane).
  34742. */
  34743. private _maintainCameraAboveGround;
  34744. /**
  34745. * Returns the frustum slope based on the canvas ratio and camera FOV
  34746. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34747. */
  34748. private _getFrustumSlope;
  34749. /**
  34750. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34751. */
  34752. private _clearAnimationLocks;
  34753. /**
  34754. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34755. */
  34756. private _applyUserInteraction;
  34757. /**
  34758. * Stops and removes all animations that have been applied to the camera
  34759. */
  34760. stopAllAnimations(): void;
  34761. /**
  34762. * Gets a value indicating if the user is moving the camera
  34763. */
  34764. readonly isUserIsMoving: boolean;
  34765. /**
  34766. * The camera can move all the way towards the mesh.
  34767. */
  34768. static IgnoreBoundsSizeMode: number;
  34769. /**
  34770. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34771. */
  34772. static FitFrustumSidesMode: number;
  34773. }
  34774. }
  34775. declare module BABYLON {
  34776. /**
  34777. * Base class for Camera Pointer Inputs.
  34778. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34779. * for example usage.
  34780. */
  34781. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34782. /**
  34783. * Defines the camera the input is attached to.
  34784. */
  34785. abstract camera: Camera;
  34786. /**
  34787. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34788. */
  34789. protected _altKey: boolean;
  34790. protected _ctrlKey: boolean;
  34791. protected _metaKey: boolean;
  34792. protected _shiftKey: boolean;
  34793. /**
  34794. * Which mouse buttons were pressed at time of last mouse event.
  34795. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34796. */
  34797. protected _buttonsPressed: number;
  34798. /**
  34799. * Defines the buttons associated with the input to handle camera move.
  34800. */
  34801. buttons: number[];
  34802. /**
  34803. * Attach the input controls to a specific dom element to get the input from.
  34804. * @param element Defines the element the controls should be listened from
  34805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34806. */
  34807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34808. /**
  34809. * Detach the current controls from the specified dom element.
  34810. * @param element Defines the element to stop listening the inputs from
  34811. */
  34812. detachControl(element: Nullable<HTMLElement>): void;
  34813. /**
  34814. * Gets the class name of the current input.
  34815. * @returns the class name
  34816. */
  34817. getClassName(): string;
  34818. /**
  34819. * Get the friendly name associated with the input class.
  34820. * @returns the input friendly name
  34821. */
  34822. getSimpleName(): string;
  34823. /**
  34824. * Called on pointer POINTERDOUBLETAP event.
  34825. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34826. */
  34827. protected onDoubleTap(type: string): void;
  34828. /**
  34829. * Called on pointer POINTERMOVE event if only a single touch is active.
  34830. * Override this method to provide functionality.
  34831. */
  34832. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34833. /**
  34834. * Called on pointer POINTERMOVE event if multiple touches are active.
  34835. * Override this method to provide functionality.
  34836. */
  34837. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34838. /**
  34839. * Called on JS contextmenu event.
  34840. * Override this method to provide functionality.
  34841. */
  34842. protected onContextMenu(evt: PointerEvent): void;
  34843. /**
  34844. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34845. * press.
  34846. * Override this method to provide functionality.
  34847. */
  34848. protected onButtonDown(evt: PointerEvent): void;
  34849. /**
  34850. * Called each time a new POINTERUP event occurs. Ie, for each button
  34851. * release.
  34852. * Override this method to provide functionality.
  34853. */
  34854. protected onButtonUp(evt: PointerEvent): void;
  34855. /**
  34856. * Called when window becomes inactive.
  34857. * Override this method to provide functionality.
  34858. */
  34859. protected onLostFocus(): void;
  34860. private _pointerInput;
  34861. private _observer;
  34862. private _onLostFocus;
  34863. private pointA;
  34864. private pointB;
  34865. }
  34866. }
  34867. declare module BABYLON {
  34868. /**
  34869. * Manage the pointers inputs to control an arc rotate camera.
  34870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34871. */
  34872. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34873. /**
  34874. * Defines the camera the input is attached to.
  34875. */
  34876. camera: ArcRotateCamera;
  34877. /**
  34878. * Gets the class name of the current input.
  34879. * @returns the class name
  34880. */
  34881. getClassName(): string;
  34882. /**
  34883. * Defines the buttons associated with the input to handle camera move.
  34884. */
  34885. buttons: number[];
  34886. /**
  34887. * Defines the pointer angular sensibility along the X axis or how fast is
  34888. * the camera rotating.
  34889. */
  34890. angularSensibilityX: number;
  34891. /**
  34892. * Defines the pointer angular sensibility along the Y axis or how fast is
  34893. * the camera rotating.
  34894. */
  34895. angularSensibilityY: number;
  34896. /**
  34897. * Defines the pointer pinch precision or how fast is the camera zooming.
  34898. */
  34899. pinchPrecision: number;
  34900. /**
  34901. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34902. * from 0.
  34903. * It defines the percentage of current camera.radius to use as delta when
  34904. * pinch zoom is used.
  34905. */
  34906. pinchDeltaPercentage: number;
  34907. /**
  34908. * Defines the pointer panning sensibility or how fast is the camera moving.
  34909. */
  34910. panningSensibility: number;
  34911. /**
  34912. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34913. */
  34914. multiTouchPanning: boolean;
  34915. /**
  34916. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34917. * zoom (pinch) through multitouch.
  34918. */
  34919. multiTouchPanAndZoom: boolean;
  34920. /**
  34921. * Revers pinch action direction.
  34922. */
  34923. pinchInwards: boolean;
  34924. private _isPanClick;
  34925. private _twoFingerActivityCount;
  34926. private _isPinching;
  34927. /**
  34928. * Called on pointer POINTERMOVE event if only a single touch is active.
  34929. */
  34930. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34931. /**
  34932. * Called on pointer POINTERDOUBLETAP event.
  34933. */
  34934. protected onDoubleTap(type: string): void;
  34935. /**
  34936. * Called on pointer POINTERMOVE event if multiple touches are active.
  34937. */
  34938. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34939. /**
  34940. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34941. * press.
  34942. */
  34943. protected onButtonDown(evt: PointerEvent): void;
  34944. /**
  34945. * Called each time a new POINTERUP event occurs. Ie, for each button
  34946. * release.
  34947. */
  34948. protected onButtonUp(evt: PointerEvent): void;
  34949. /**
  34950. * Called when window becomes inactive.
  34951. */
  34952. protected onLostFocus(): void;
  34953. }
  34954. }
  34955. declare module BABYLON {
  34956. /**
  34957. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34958. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34959. */
  34960. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34961. /**
  34962. * Defines the camera the input is attached to.
  34963. */
  34964. camera: ArcRotateCamera;
  34965. /**
  34966. * Defines the list of key codes associated with the up action (increase alpha)
  34967. */
  34968. keysUp: number[];
  34969. /**
  34970. * Defines the list of key codes associated with the down action (decrease alpha)
  34971. */
  34972. keysDown: number[];
  34973. /**
  34974. * Defines the list of key codes associated with the left action (increase beta)
  34975. */
  34976. keysLeft: number[];
  34977. /**
  34978. * Defines the list of key codes associated with the right action (decrease beta)
  34979. */
  34980. keysRight: number[];
  34981. /**
  34982. * Defines the list of key codes associated with the reset action.
  34983. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34984. */
  34985. keysReset: number[];
  34986. /**
  34987. * Defines the panning sensibility of the inputs.
  34988. * (How fast is the camera paning)
  34989. */
  34990. panningSensibility: number;
  34991. /**
  34992. * Defines the zooming sensibility of the inputs.
  34993. * (How fast is the camera zooming)
  34994. */
  34995. zoomingSensibility: number;
  34996. /**
  34997. * Defines wether maintaining the alt key down switch the movement mode from
  34998. * orientation to zoom.
  34999. */
  35000. useAltToZoom: boolean;
  35001. /**
  35002. * Rotation speed of the camera
  35003. */
  35004. angularSpeed: number;
  35005. private _keys;
  35006. private _ctrlPressed;
  35007. private _altPressed;
  35008. private _onCanvasBlurObserver;
  35009. private _onKeyboardObserver;
  35010. private _engine;
  35011. private _scene;
  35012. /**
  35013. * Attach the input controls to a specific dom element to get the input from.
  35014. * @param element Defines the element the controls should be listened from
  35015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35016. */
  35017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35018. /**
  35019. * Detach the current controls from the specified dom element.
  35020. * @param element Defines the element to stop listening the inputs from
  35021. */
  35022. detachControl(element: Nullable<HTMLElement>): void;
  35023. /**
  35024. * Update the current camera state depending on the inputs that have been used this frame.
  35025. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35026. */
  35027. checkInputs(): void;
  35028. /**
  35029. * Gets the class name of the current intput.
  35030. * @returns the class name
  35031. */
  35032. getClassName(): string;
  35033. /**
  35034. * Get the friendly name associated with the input class.
  35035. * @returns the input friendly name
  35036. */
  35037. getSimpleName(): string;
  35038. }
  35039. }
  35040. declare module BABYLON {
  35041. /**
  35042. * Manage the mouse wheel inputs to control an arc rotate camera.
  35043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35044. */
  35045. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35046. /**
  35047. * Defines the camera the input is attached to.
  35048. */
  35049. camera: ArcRotateCamera;
  35050. /**
  35051. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35052. */
  35053. wheelPrecision: number;
  35054. /**
  35055. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35056. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35057. */
  35058. wheelDeltaPercentage: number;
  35059. private _wheel;
  35060. private _observer;
  35061. /**
  35062. * Attach the input controls to a specific dom element to get the input from.
  35063. * @param element Defines the element the controls should be listened from
  35064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35065. */
  35066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35067. /**
  35068. * Detach the current controls from the specified dom element.
  35069. * @param element Defines the element to stop listening the inputs from
  35070. */
  35071. detachControl(element: Nullable<HTMLElement>): void;
  35072. /**
  35073. * Gets the class name of the current intput.
  35074. * @returns the class name
  35075. */
  35076. getClassName(): string;
  35077. /**
  35078. * Get the friendly name associated with the input class.
  35079. * @returns the input friendly name
  35080. */
  35081. getSimpleName(): string;
  35082. }
  35083. }
  35084. declare module BABYLON {
  35085. /**
  35086. * Default Inputs manager for the ArcRotateCamera.
  35087. * It groups all the default supported inputs for ease of use.
  35088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35089. */
  35090. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35091. /**
  35092. * Instantiates a new ArcRotateCameraInputsManager.
  35093. * @param camera Defines the camera the inputs belong to
  35094. */
  35095. constructor(camera: ArcRotateCamera);
  35096. /**
  35097. * Add mouse wheel input support to the input manager.
  35098. * @returns the current input manager
  35099. */
  35100. addMouseWheel(): ArcRotateCameraInputsManager;
  35101. /**
  35102. * Add pointers input support to the input manager.
  35103. * @returns the current input manager
  35104. */
  35105. addPointers(): ArcRotateCameraInputsManager;
  35106. /**
  35107. * Add keyboard input support to the input manager.
  35108. * @returns the current input manager
  35109. */
  35110. addKeyboard(): ArcRotateCameraInputsManager;
  35111. }
  35112. }
  35113. declare module BABYLON {
  35114. /**
  35115. * This represents an orbital type of camera.
  35116. *
  35117. * 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.
  35118. * 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.
  35119. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35120. */
  35121. export class ArcRotateCamera extends TargetCamera {
  35122. /**
  35123. * Defines the rotation angle of the camera along the longitudinal axis.
  35124. */
  35125. alpha: number;
  35126. /**
  35127. * Defines the rotation angle of the camera along the latitudinal axis.
  35128. */
  35129. beta: number;
  35130. /**
  35131. * Defines the radius of the camera from it s target point.
  35132. */
  35133. radius: number;
  35134. protected _target: Vector3;
  35135. protected _targetHost: Nullable<AbstractMesh>;
  35136. /**
  35137. * Defines the target point of the camera.
  35138. * The camera looks towards it form the radius distance.
  35139. */
  35140. target: Vector3;
  35141. /**
  35142. * Define the current local position of the camera in the scene
  35143. */
  35144. position: Vector3;
  35145. protected _upVector: Vector3;
  35146. protected _upToYMatrix: Matrix;
  35147. protected _YToUpMatrix: Matrix;
  35148. /**
  35149. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35150. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35151. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35152. */
  35153. upVector: Vector3;
  35154. /**
  35155. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35156. */
  35157. setMatUp(): void;
  35158. /**
  35159. * Current inertia value on the longitudinal axis.
  35160. * The bigger this number the longer it will take for the camera to stop.
  35161. */
  35162. inertialAlphaOffset: number;
  35163. /**
  35164. * Current inertia value on the latitudinal axis.
  35165. * The bigger this number the longer it will take for the camera to stop.
  35166. */
  35167. inertialBetaOffset: number;
  35168. /**
  35169. * Current inertia value on the radius axis.
  35170. * The bigger this number the longer it will take for the camera to stop.
  35171. */
  35172. inertialRadiusOffset: number;
  35173. /**
  35174. * Minimum allowed angle on the longitudinal axis.
  35175. * This can help limiting how the Camera is able to move in the scene.
  35176. */
  35177. lowerAlphaLimit: Nullable<number>;
  35178. /**
  35179. * Maximum allowed angle on the longitudinal axis.
  35180. * This can help limiting how the Camera is able to move in the scene.
  35181. */
  35182. upperAlphaLimit: Nullable<number>;
  35183. /**
  35184. * Minimum allowed angle on the latitudinal axis.
  35185. * This can help limiting how the Camera is able to move in the scene.
  35186. */
  35187. lowerBetaLimit: number;
  35188. /**
  35189. * Maximum allowed angle on the latitudinal axis.
  35190. * This can help limiting how the Camera is able to move in the scene.
  35191. */
  35192. upperBetaLimit: number;
  35193. /**
  35194. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35195. * This can help limiting how the Camera is able to move in the scene.
  35196. */
  35197. lowerRadiusLimit: Nullable<number>;
  35198. /**
  35199. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35200. * This can help limiting how the Camera is able to move in the scene.
  35201. */
  35202. upperRadiusLimit: Nullable<number>;
  35203. /**
  35204. * Defines the current inertia value used during panning of the camera along the X axis.
  35205. */
  35206. inertialPanningX: number;
  35207. /**
  35208. * Defines the current inertia value used during panning of the camera along the Y axis.
  35209. */
  35210. inertialPanningY: number;
  35211. /**
  35212. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35213. * Basically if your fingers moves away from more than this distance you will be considered
  35214. * in pinch mode.
  35215. */
  35216. pinchToPanMaxDistance: number;
  35217. /**
  35218. * Defines the maximum distance the camera can pan.
  35219. * This could help keeping the cammera always in your scene.
  35220. */
  35221. panningDistanceLimit: Nullable<number>;
  35222. /**
  35223. * Defines the target of the camera before paning.
  35224. */
  35225. panningOriginTarget: Vector3;
  35226. /**
  35227. * Defines the value of the inertia used during panning.
  35228. * 0 would mean stop inertia and one would mean no decelleration at all.
  35229. */
  35230. panningInertia: number;
  35231. /**
  35232. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35233. */
  35234. angularSensibilityX: number;
  35235. /**
  35236. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35237. */
  35238. angularSensibilityY: number;
  35239. /**
  35240. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35241. */
  35242. pinchPrecision: number;
  35243. /**
  35244. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35245. * It will be used instead of pinchDeltaPrecision if different from 0.
  35246. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35247. */
  35248. pinchDeltaPercentage: number;
  35249. /**
  35250. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35251. */
  35252. panningSensibility: number;
  35253. /**
  35254. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35255. */
  35256. keysUp: number[];
  35257. /**
  35258. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35259. */
  35260. keysDown: number[];
  35261. /**
  35262. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35263. */
  35264. keysLeft: number[];
  35265. /**
  35266. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35267. */
  35268. keysRight: number[];
  35269. /**
  35270. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35271. */
  35272. wheelPrecision: number;
  35273. /**
  35274. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35275. * It will be used instead of pinchDeltaPrecision if different from 0.
  35276. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35277. */
  35278. wheelDeltaPercentage: number;
  35279. /**
  35280. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35281. */
  35282. zoomOnFactor: number;
  35283. /**
  35284. * Defines a screen offset for the camera position.
  35285. */
  35286. targetScreenOffset: Vector2;
  35287. /**
  35288. * Allows the camera to be completely reversed.
  35289. * If false the camera can not arrive upside down.
  35290. */
  35291. allowUpsideDown: boolean;
  35292. /**
  35293. * Define if double tap/click is used to restore the previously saved state of the camera.
  35294. */
  35295. useInputToRestoreState: boolean;
  35296. /** @hidden */
  35297. _viewMatrix: Matrix;
  35298. /** @hidden */
  35299. _useCtrlForPanning: boolean;
  35300. /** @hidden */
  35301. _panningMouseButton: number;
  35302. /**
  35303. * Defines the input associated to the camera.
  35304. */
  35305. inputs: ArcRotateCameraInputsManager;
  35306. /** @hidden */
  35307. _reset: () => void;
  35308. /**
  35309. * Defines the allowed panning axis.
  35310. */
  35311. panningAxis: Vector3;
  35312. protected _localDirection: Vector3;
  35313. protected _transformedDirection: Vector3;
  35314. private _bouncingBehavior;
  35315. /**
  35316. * Gets the bouncing behavior of the camera if it has been enabled.
  35317. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35318. */
  35319. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35320. /**
  35321. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35322. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35323. */
  35324. useBouncingBehavior: boolean;
  35325. private _framingBehavior;
  35326. /**
  35327. * Gets the framing behavior of the camera if it has been enabled.
  35328. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35329. */
  35330. readonly framingBehavior: Nullable<FramingBehavior>;
  35331. /**
  35332. * Defines if the framing behavior of the camera is enabled on the camera.
  35333. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35334. */
  35335. useFramingBehavior: boolean;
  35336. private _autoRotationBehavior;
  35337. /**
  35338. * Gets the auto rotation behavior of the camera if it has been enabled.
  35339. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35340. */
  35341. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35342. /**
  35343. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35345. */
  35346. useAutoRotationBehavior: boolean;
  35347. /**
  35348. * Observable triggered when the mesh target has been changed on the camera.
  35349. */
  35350. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35351. /**
  35352. * Event raised when the camera is colliding with a mesh.
  35353. */
  35354. onCollide: (collidedMesh: AbstractMesh) => void;
  35355. /**
  35356. * Defines whether the camera should check collision with the objects oh the scene.
  35357. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35358. */
  35359. checkCollisions: boolean;
  35360. /**
  35361. * Defines the collision radius of the camera.
  35362. * This simulates a sphere around the camera.
  35363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35364. */
  35365. collisionRadius: Vector3;
  35366. protected _collider: Collider;
  35367. protected _previousPosition: Vector3;
  35368. protected _collisionVelocity: Vector3;
  35369. protected _newPosition: Vector3;
  35370. protected _previousAlpha: number;
  35371. protected _previousBeta: number;
  35372. protected _previousRadius: number;
  35373. protected _collisionTriggered: boolean;
  35374. protected _targetBoundingCenter: Nullable<Vector3>;
  35375. private _computationVector;
  35376. /**
  35377. * Instantiates a new ArcRotateCamera in a given scene
  35378. * @param name Defines the name of the camera
  35379. * @param alpha Defines the camera rotation along the logitudinal axis
  35380. * @param beta Defines the camera rotation along the latitudinal axis
  35381. * @param radius Defines the camera distance from its target
  35382. * @param target Defines the camera target
  35383. * @param scene Defines the scene the camera belongs to
  35384. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35385. */
  35386. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35387. /** @hidden */
  35388. _initCache(): void;
  35389. /** @hidden */
  35390. _updateCache(ignoreParentClass?: boolean): void;
  35391. protected _getTargetPosition(): Vector3;
  35392. private _storedAlpha;
  35393. private _storedBeta;
  35394. private _storedRadius;
  35395. private _storedTarget;
  35396. /**
  35397. * Stores the current state of the camera (alpha, beta, radius and target)
  35398. * @returns the camera itself
  35399. */
  35400. storeState(): Camera;
  35401. /**
  35402. * @hidden
  35403. * Restored camera state. You must call storeState() first
  35404. */
  35405. _restoreStateValues(): boolean;
  35406. /** @hidden */
  35407. _isSynchronizedViewMatrix(): boolean;
  35408. /**
  35409. * Attached controls to the current camera.
  35410. * @param element Defines the element the controls should be listened from
  35411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35412. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35413. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35414. */
  35415. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35416. /**
  35417. * Detach the current controls from the camera.
  35418. * The camera will stop reacting to inputs.
  35419. * @param element Defines the element to stop listening the inputs from
  35420. */
  35421. detachControl(element: HTMLElement): void;
  35422. /** @hidden */
  35423. _checkInputs(): void;
  35424. protected _checkLimits(): void;
  35425. /**
  35426. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35427. */
  35428. rebuildAnglesAndRadius(): void;
  35429. /**
  35430. * Use a position to define the current camera related information like aplha, beta and radius
  35431. * @param position Defines the position to set the camera at
  35432. */
  35433. setPosition(position: Vector3): void;
  35434. /**
  35435. * Defines the target the camera should look at.
  35436. * This will automatically adapt alpha beta and radius to fit within the new target.
  35437. * @param target Defines the new target as a Vector or a mesh
  35438. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35439. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35440. */
  35441. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35442. /** @hidden */
  35443. _getViewMatrix(): Matrix;
  35444. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35445. /**
  35446. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35447. * @param meshes Defines the mesh to zoom on
  35448. * @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)
  35449. */
  35450. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35451. /**
  35452. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35453. * The target will be changed but the radius
  35454. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35455. * @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)
  35456. */
  35457. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35458. min: Vector3;
  35459. max: Vector3;
  35460. distance: number;
  35461. }, doNotUpdateMaxZ?: boolean): void;
  35462. /**
  35463. * @override
  35464. * Override Camera.createRigCamera
  35465. */
  35466. createRigCamera(name: string, cameraIndex: number): Camera;
  35467. /**
  35468. * @hidden
  35469. * @override
  35470. * Override Camera._updateRigCameras
  35471. */
  35472. _updateRigCameras(): void;
  35473. /**
  35474. * Destroy the camera and release the current resources hold by it.
  35475. */
  35476. dispose(): void;
  35477. /**
  35478. * Gets the current object class name.
  35479. * @return the class name
  35480. */
  35481. getClassName(): string;
  35482. }
  35483. }
  35484. declare module BABYLON {
  35485. /**
  35486. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35487. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35488. */
  35489. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35490. /**
  35491. * Gets the name of the behavior.
  35492. */
  35493. readonly name: string;
  35494. private _zoomStopsAnimation;
  35495. private _idleRotationSpeed;
  35496. private _idleRotationWaitTime;
  35497. private _idleRotationSpinupTime;
  35498. /**
  35499. * Sets the flag that indicates if user zooming should stop animation.
  35500. */
  35501. /**
  35502. * Gets the flag that indicates if user zooming should stop animation.
  35503. */
  35504. zoomStopsAnimation: boolean;
  35505. /**
  35506. * Sets the default speed at which the camera rotates around the model.
  35507. */
  35508. /**
  35509. * Gets the default speed at which the camera rotates around the model.
  35510. */
  35511. idleRotationSpeed: number;
  35512. /**
  35513. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35514. */
  35515. /**
  35516. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35517. */
  35518. idleRotationWaitTime: number;
  35519. /**
  35520. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35521. */
  35522. /**
  35523. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35524. */
  35525. idleRotationSpinupTime: number;
  35526. /**
  35527. * Gets a value indicating if the camera is currently rotating because of this behavior
  35528. */
  35529. readonly rotationInProgress: boolean;
  35530. private _onPrePointerObservableObserver;
  35531. private _onAfterCheckInputsObserver;
  35532. private _attachedCamera;
  35533. private _isPointerDown;
  35534. private _lastFrameTime;
  35535. private _lastInteractionTime;
  35536. private _cameraRotationSpeed;
  35537. /**
  35538. * Initializes the behavior.
  35539. */
  35540. init(): void;
  35541. /**
  35542. * Attaches the behavior to its arc rotate camera.
  35543. * @param camera Defines the camera to attach the behavior to
  35544. */
  35545. attach(camera: ArcRotateCamera): void;
  35546. /**
  35547. * Detaches the behavior from its current arc rotate camera.
  35548. */
  35549. detach(): void;
  35550. /**
  35551. * Returns true if user is scrolling.
  35552. * @return true if user is scrolling.
  35553. */
  35554. private _userIsZooming;
  35555. private _lastFrameRadius;
  35556. private _shouldAnimationStopForInteraction;
  35557. /**
  35558. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35559. */
  35560. private _applyUserInteraction;
  35561. private _userIsMoving;
  35562. }
  35563. }
  35564. declare module BABYLON {
  35565. /**
  35566. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35567. */
  35568. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35569. private ui;
  35570. /**
  35571. * The name of the behavior
  35572. */
  35573. name: string;
  35574. /**
  35575. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35576. */
  35577. distanceAwayFromFace: number;
  35578. /**
  35579. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35580. */
  35581. distanceAwayFromBottomOfFace: number;
  35582. private _faceVectors;
  35583. private _target;
  35584. private _scene;
  35585. private _onRenderObserver;
  35586. private _tmpMatrix;
  35587. private _tmpVector;
  35588. /**
  35589. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35590. * @param ui The transform node that should be attched to the mesh
  35591. */
  35592. constructor(ui: TransformNode);
  35593. /**
  35594. * Initializes the behavior
  35595. */
  35596. init(): void;
  35597. private _closestFace;
  35598. private _zeroVector;
  35599. private _lookAtTmpMatrix;
  35600. private _lookAtToRef;
  35601. /**
  35602. * Attaches the AttachToBoxBehavior to the passed in mesh
  35603. * @param target The mesh that the specified node will be attached to
  35604. */
  35605. attach(target: Mesh): void;
  35606. /**
  35607. * Detaches the behavior from the mesh
  35608. */
  35609. detach(): void;
  35610. }
  35611. }
  35612. declare module BABYLON {
  35613. /**
  35614. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35615. */
  35616. export class FadeInOutBehavior implements Behavior<Mesh> {
  35617. /**
  35618. * Time in milliseconds to delay before fading in (Default: 0)
  35619. */
  35620. delay: number;
  35621. /**
  35622. * Time in milliseconds for the mesh to fade in (Default: 300)
  35623. */
  35624. fadeInTime: number;
  35625. private _millisecondsPerFrame;
  35626. private _hovered;
  35627. private _hoverValue;
  35628. private _ownerNode;
  35629. /**
  35630. * Instatiates the FadeInOutBehavior
  35631. */
  35632. constructor();
  35633. /**
  35634. * The name of the behavior
  35635. */
  35636. readonly name: string;
  35637. /**
  35638. * Initializes the behavior
  35639. */
  35640. init(): void;
  35641. /**
  35642. * Attaches the fade behavior on the passed in mesh
  35643. * @param ownerNode The mesh that will be faded in/out once attached
  35644. */
  35645. attach(ownerNode: Mesh): void;
  35646. /**
  35647. * Detaches the behavior from the mesh
  35648. */
  35649. detach(): void;
  35650. /**
  35651. * Triggers the mesh to begin fading in or out
  35652. * @param value if the object should fade in or out (true to fade in)
  35653. */
  35654. fadeIn(value: boolean): void;
  35655. private _update;
  35656. private _setAllVisibility;
  35657. }
  35658. }
  35659. declare module BABYLON {
  35660. /**
  35661. * Class containing a set of static utilities functions for managing Pivots
  35662. * @hidden
  35663. */
  35664. export class PivotTools {
  35665. private static _PivotCached;
  35666. private static _OldPivotPoint;
  35667. private static _PivotTranslation;
  35668. private static _PivotTmpVector;
  35669. /** @hidden */
  35670. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35671. /** @hidden */
  35672. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35673. }
  35674. }
  35675. declare module BABYLON {
  35676. /**
  35677. * Class containing static functions to help procedurally build meshes
  35678. */
  35679. export class PlaneBuilder {
  35680. /**
  35681. * Creates a plane mesh
  35682. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35683. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35684. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35686. * * 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
  35687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35688. * @param name defines the name of the mesh
  35689. * @param options defines the options used to create the mesh
  35690. * @param scene defines the hosting scene
  35691. * @returns the plane mesh
  35692. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35693. */
  35694. static CreatePlane(name: string, options: {
  35695. size?: number;
  35696. width?: number;
  35697. height?: number;
  35698. sideOrientation?: number;
  35699. frontUVs?: Vector4;
  35700. backUVs?: Vector4;
  35701. updatable?: boolean;
  35702. sourcePlane?: Plane;
  35703. }, scene?: Nullable<Scene>): Mesh;
  35704. }
  35705. }
  35706. declare module BABYLON {
  35707. /**
  35708. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35709. */
  35710. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35711. private static _AnyMouseID;
  35712. private _attachedNode;
  35713. private _dragPlane;
  35714. private _scene;
  35715. private _pointerObserver;
  35716. private _beforeRenderObserver;
  35717. private static _planeScene;
  35718. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35719. /**
  35720. * 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)
  35721. */
  35722. maxDragAngle: number;
  35723. /**
  35724. * @hidden
  35725. */
  35726. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35727. /**
  35728. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35729. */
  35730. currentDraggingPointerID: number;
  35731. /**
  35732. * The last position where the pointer hit the drag plane in world space
  35733. */
  35734. lastDragPosition: Vector3;
  35735. /**
  35736. * If the behavior is currently in a dragging state
  35737. */
  35738. dragging: boolean;
  35739. /**
  35740. * 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)
  35741. */
  35742. dragDeltaRatio: number;
  35743. /**
  35744. * If the drag plane orientation should be updated during the dragging (Default: true)
  35745. */
  35746. updateDragPlane: boolean;
  35747. private _debugMode;
  35748. private _moving;
  35749. /**
  35750. * Fires each time the attached mesh is dragged with the pointer
  35751. * * delta between last drag position and current drag position in world space
  35752. * * dragDistance along the drag axis
  35753. * * dragPlaneNormal normal of the current drag plane used during the drag
  35754. * * dragPlanePoint in world space where the drag intersects the drag plane
  35755. */
  35756. onDragObservable: Observable<{
  35757. delta: Vector3;
  35758. dragPlanePoint: Vector3;
  35759. dragPlaneNormal: Vector3;
  35760. dragDistance: number;
  35761. pointerId: number;
  35762. }>;
  35763. /**
  35764. * Fires each time a drag begins (eg. mouse down on mesh)
  35765. */
  35766. onDragStartObservable: Observable<{
  35767. dragPlanePoint: Vector3;
  35768. pointerId: number;
  35769. }>;
  35770. /**
  35771. * Fires each time a drag ends (eg. mouse release after drag)
  35772. */
  35773. onDragEndObservable: Observable<{
  35774. dragPlanePoint: Vector3;
  35775. pointerId: number;
  35776. }>;
  35777. /**
  35778. * If the attached mesh should be moved when dragged
  35779. */
  35780. moveAttached: boolean;
  35781. /**
  35782. * If the drag behavior will react to drag events (Default: true)
  35783. */
  35784. enabled: boolean;
  35785. /**
  35786. * If camera controls should be detached during the drag
  35787. */
  35788. detachCameraControls: boolean;
  35789. /**
  35790. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35791. */
  35792. useObjectOrienationForDragging: boolean;
  35793. private _options;
  35794. /**
  35795. * Creates a pointer drag behavior that can be attached to a mesh
  35796. * @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)
  35797. */
  35798. constructor(options?: {
  35799. dragAxis?: Vector3;
  35800. dragPlaneNormal?: Vector3;
  35801. });
  35802. /**
  35803. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35804. */
  35805. validateDrag: (targetPosition: Vector3) => boolean;
  35806. /**
  35807. * The name of the behavior
  35808. */
  35809. readonly name: string;
  35810. /**
  35811. * Initializes the behavior
  35812. */
  35813. init(): void;
  35814. private _tmpVector;
  35815. private _alternatePickedPoint;
  35816. private _worldDragAxis;
  35817. private _targetPosition;
  35818. private _attachedElement;
  35819. /**
  35820. * Attaches the drag behavior the passed in mesh
  35821. * @param ownerNode The mesh that will be dragged around once attached
  35822. */
  35823. attach(ownerNode: AbstractMesh): void;
  35824. /**
  35825. * Force relase the drag action by code.
  35826. */
  35827. releaseDrag(): void;
  35828. private _startDragRay;
  35829. private _lastPointerRay;
  35830. /**
  35831. * Simulates the start of a pointer drag event on the behavior
  35832. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35833. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35834. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35835. */
  35836. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35837. private _startDrag;
  35838. private _dragDelta;
  35839. private _moveDrag;
  35840. private _pickWithRayOnDragPlane;
  35841. private _pointA;
  35842. private _pointB;
  35843. private _pointC;
  35844. private _lineA;
  35845. private _lineB;
  35846. private _localAxis;
  35847. private _lookAt;
  35848. private _updateDragPlanePosition;
  35849. /**
  35850. * Detaches the behavior from the mesh
  35851. */
  35852. detach(): void;
  35853. }
  35854. }
  35855. declare module BABYLON {
  35856. /**
  35857. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35858. */
  35859. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35860. private _dragBehaviorA;
  35861. private _dragBehaviorB;
  35862. private _startDistance;
  35863. private _initialScale;
  35864. private _targetScale;
  35865. private _ownerNode;
  35866. private _sceneRenderObserver;
  35867. /**
  35868. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35869. */
  35870. constructor();
  35871. /**
  35872. * The name of the behavior
  35873. */
  35874. readonly name: string;
  35875. /**
  35876. * Initializes the behavior
  35877. */
  35878. init(): void;
  35879. private _getCurrentDistance;
  35880. /**
  35881. * Attaches the scale behavior the passed in mesh
  35882. * @param ownerNode The mesh that will be scaled around once attached
  35883. */
  35884. attach(ownerNode: Mesh): void;
  35885. /**
  35886. * Detaches the behavior from the mesh
  35887. */
  35888. detach(): void;
  35889. }
  35890. }
  35891. declare module BABYLON {
  35892. /**
  35893. * 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
  35894. */
  35895. export class SixDofDragBehavior implements Behavior<Mesh> {
  35896. private static _virtualScene;
  35897. private _ownerNode;
  35898. private _sceneRenderObserver;
  35899. private _scene;
  35900. private _targetPosition;
  35901. private _virtualOriginMesh;
  35902. private _virtualDragMesh;
  35903. private _pointerObserver;
  35904. private _moving;
  35905. private _startingOrientation;
  35906. /**
  35907. * 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)
  35908. */
  35909. private zDragFactor;
  35910. /**
  35911. * If the object should rotate to face the drag origin
  35912. */
  35913. rotateDraggedObject: boolean;
  35914. /**
  35915. * If the behavior is currently in a dragging state
  35916. */
  35917. dragging: boolean;
  35918. /**
  35919. * 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)
  35920. */
  35921. dragDeltaRatio: number;
  35922. /**
  35923. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35924. */
  35925. currentDraggingPointerID: number;
  35926. /**
  35927. * If camera controls should be detached during the drag
  35928. */
  35929. detachCameraControls: boolean;
  35930. /**
  35931. * Fires each time a drag starts
  35932. */
  35933. onDragStartObservable: Observable<{}>;
  35934. /**
  35935. * Fires each time a drag ends (eg. mouse release after drag)
  35936. */
  35937. onDragEndObservable: Observable<{}>;
  35938. /**
  35939. * 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
  35940. */
  35941. constructor();
  35942. /**
  35943. * The name of the behavior
  35944. */
  35945. readonly name: string;
  35946. /**
  35947. * Initializes the behavior
  35948. */
  35949. init(): void;
  35950. /**
  35951. * Attaches the scale behavior the passed in mesh
  35952. * @param ownerNode The mesh that will be scaled around once attached
  35953. */
  35954. attach(ownerNode: Mesh): void;
  35955. /**
  35956. * Detaches the behavior from the mesh
  35957. */
  35958. detach(): void;
  35959. }
  35960. }
  35961. declare module BABYLON {
  35962. /**
  35963. * Class used to apply inverse kinematics to bones
  35964. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35965. */
  35966. export class BoneIKController {
  35967. private static _tmpVecs;
  35968. private static _tmpQuat;
  35969. private static _tmpMats;
  35970. /**
  35971. * Gets or sets the target mesh
  35972. */
  35973. targetMesh: AbstractMesh;
  35974. /** Gets or sets the mesh used as pole */
  35975. poleTargetMesh: AbstractMesh;
  35976. /**
  35977. * Gets or sets the bone used as pole
  35978. */
  35979. poleTargetBone: Nullable<Bone>;
  35980. /**
  35981. * Gets or sets the target position
  35982. */
  35983. targetPosition: Vector3;
  35984. /**
  35985. * Gets or sets the pole target position
  35986. */
  35987. poleTargetPosition: Vector3;
  35988. /**
  35989. * Gets or sets the pole target local offset
  35990. */
  35991. poleTargetLocalOffset: Vector3;
  35992. /**
  35993. * Gets or sets the pole angle
  35994. */
  35995. poleAngle: number;
  35996. /**
  35997. * Gets or sets the mesh associated with the controller
  35998. */
  35999. mesh: AbstractMesh;
  36000. /**
  36001. * 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)
  36002. */
  36003. slerpAmount: number;
  36004. private _bone1Quat;
  36005. private _bone1Mat;
  36006. private _bone2Ang;
  36007. private _bone1;
  36008. private _bone2;
  36009. private _bone1Length;
  36010. private _bone2Length;
  36011. private _maxAngle;
  36012. private _maxReach;
  36013. private _rightHandedSystem;
  36014. private _bendAxis;
  36015. private _slerping;
  36016. private _adjustRoll;
  36017. /**
  36018. * Gets or sets maximum allowed angle
  36019. */
  36020. maxAngle: number;
  36021. /**
  36022. * Creates a new BoneIKController
  36023. * @param mesh defines the mesh to control
  36024. * @param bone defines the bone to control
  36025. * @param options defines options to set up the controller
  36026. */
  36027. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36028. targetMesh?: AbstractMesh;
  36029. poleTargetMesh?: AbstractMesh;
  36030. poleTargetBone?: Bone;
  36031. poleTargetLocalOffset?: Vector3;
  36032. poleAngle?: number;
  36033. bendAxis?: Vector3;
  36034. maxAngle?: number;
  36035. slerpAmount?: number;
  36036. });
  36037. private _setMaxAngle;
  36038. /**
  36039. * Force the controller to update the bones
  36040. */
  36041. update(): void;
  36042. }
  36043. }
  36044. declare module BABYLON {
  36045. /**
  36046. * Class used to make a bone look toward a point in space
  36047. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36048. */
  36049. export class BoneLookController {
  36050. private static _tmpVecs;
  36051. private static _tmpQuat;
  36052. private static _tmpMats;
  36053. /**
  36054. * The target Vector3 that the bone will look at
  36055. */
  36056. target: Vector3;
  36057. /**
  36058. * The mesh that the bone is attached to
  36059. */
  36060. mesh: AbstractMesh;
  36061. /**
  36062. * The bone that will be looking to the target
  36063. */
  36064. bone: Bone;
  36065. /**
  36066. * The up axis of the coordinate system that is used when the bone is rotated
  36067. */
  36068. upAxis: Vector3;
  36069. /**
  36070. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36071. */
  36072. upAxisSpace: Space;
  36073. /**
  36074. * Used to make an adjustment to the yaw of the bone
  36075. */
  36076. adjustYaw: number;
  36077. /**
  36078. * Used to make an adjustment to the pitch of the bone
  36079. */
  36080. adjustPitch: number;
  36081. /**
  36082. * Used to make an adjustment to the roll of the bone
  36083. */
  36084. adjustRoll: number;
  36085. /**
  36086. * 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)
  36087. */
  36088. slerpAmount: number;
  36089. private _minYaw;
  36090. private _maxYaw;
  36091. private _minPitch;
  36092. private _maxPitch;
  36093. private _minYawSin;
  36094. private _minYawCos;
  36095. private _maxYawSin;
  36096. private _maxYawCos;
  36097. private _midYawConstraint;
  36098. private _minPitchTan;
  36099. private _maxPitchTan;
  36100. private _boneQuat;
  36101. private _slerping;
  36102. private _transformYawPitch;
  36103. private _transformYawPitchInv;
  36104. private _firstFrameSkipped;
  36105. private _yawRange;
  36106. private _fowardAxis;
  36107. /**
  36108. * Gets or sets the minimum yaw angle that the bone can look to
  36109. */
  36110. minYaw: number;
  36111. /**
  36112. * Gets or sets the maximum yaw angle that the bone can look to
  36113. */
  36114. maxYaw: number;
  36115. /**
  36116. * Gets or sets the minimum pitch angle that the bone can look to
  36117. */
  36118. minPitch: number;
  36119. /**
  36120. * Gets or sets the maximum pitch angle that the bone can look to
  36121. */
  36122. maxPitch: number;
  36123. /**
  36124. * Create a BoneLookController
  36125. * @param mesh the mesh that the bone belongs to
  36126. * @param bone the bone that will be looking to the target
  36127. * @param target the target Vector3 to look at
  36128. * @param options optional settings:
  36129. * * maxYaw: the maximum angle the bone will yaw to
  36130. * * minYaw: the minimum angle the bone will yaw to
  36131. * * maxPitch: the maximum angle the bone will pitch to
  36132. * * minPitch: the minimum angle the bone will yaw to
  36133. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36134. * * upAxis: the up axis of the coordinate system
  36135. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36136. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36137. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36138. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36139. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36140. * * adjustRoll: used to make an adjustment to the roll of the bone
  36141. **/
  36142. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36143. maxYaw?: number;
  36144. minYaw?: number;
  36145. maxPitch?: number;
  36146. minPitch?: number;
  36147. slerpAmount?: number;
  36148. upAxis?: Vector3;
  36149. upAxisSpace?: Space;
  36150. yawAxis?: Vector3;
  36151. pitchAxis?: Vector3;
  36152. adjustYaw?: number;
  36153. adjustPitch?: number;
  36154. adjustRoll?: number;
  36155. });
  36156. /**
  36157. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36158. */
  36159. update(): void;
  36160. private _getAngleDiff;
  36161. private _getAngleBetween;
  36162. private _isAngleBetween;
  36163. }
  36164. }
  36165. declare module BABYLON {
  36166. /**
  36167. * Manage the gamepad inputs to control an arc rotate camera.
  36168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36169. */
  36170. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36171. /**
  36172. * Defines the camera the input is attached to.
  36173. */
  36174. camera: ArcRotateCamera;
  36175. /**
  36176. * Defines the gamepad the input is gathering event from.
  36177. */
  36178. gamepad: Nullable<Gamepad>;
  36179. /**
  36180. * Defines the gamepad rotation sensiblity.
  36181. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36182. */
  36183. gamepadRotationSensibility: number;
  36184. /**
  36185. * Defines the gamepad move sensiblity.
  36186. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36187. */
  36188. gamepadMoveSensibility: number;
  36189. private _onGamepadConnectedObserver;
  36190. private _onGamepadDisconnectedObserver;
  36191. /**
  36192. * Attach the input controls to a specific dom element to get the input from.
  36193. * @param element Defines the element the controls should be listened from
  36194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36195. */
  36196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36197. /**
  36198. * Detach the current controls from the specified dom element.
  36199. * @param element Defines the element to stop listening the inputs from
  36200. */
  36201. detachControl(element: Nullable<HTMLElement>): void;
  36202. /**
  36203. * Update the current camera state depending on the inputs that have been used this frame.
  36204. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36205. */
  36206. checkInputs(): void;
  36207. /**
  36208. * Gets the class name of the current intput.
  36209. * @returns the class name
  36210. */
  36211. getClassName(): string;
  36212. /**
  36213. * Get the friendly name associated with the input class.
  36214. * @returns the input friendly name
  36215. */
  36216. getSimpleName(): string;
  36217. }
  36218. }
  36219. declare module BABYLON {
  36220. interface ArcRotateCameraInputsManager {
  36221. /**
  36222. * Add orientation input support to the input manager.
  36223. * @returns the current input manager
  36224. */
  36225. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36226. }
  36227. /**
  36228. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36230. */
  36231. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36232. /**
  36233. * Defines the camera the input is attached to.
  36234. */
  36235. camera: ArcRotateCamera;
  36236. /**
  36237. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36238. */
  36239. alphaCorrection: number;
  36240. /**
  36241. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36242. */
  36243. gammaCorrection: number;
  36244. private _alpha;
  36245. private _gamma;
  36246. private _dirty;
  36247. private _deviceOrientationHandler;
  36248. /**
  36249. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36250. */
  36251. constructor();
  36252. /**
  36253. * Attach the input controls to a specific dom element to get the input from.
  36254. * @param element Defines the element the controls should be listened from
  36255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36256. */
  36257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36258. /** @hidden */
  36259. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36260. /**
  36261. * Update the current camera state depending on the inputs that have been used this frame.
  36262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36263. */
  36264. checkInputs(): void;
  36265. /**
  36266. * Detach the current controls from the specified dom element.
  36267. * @param element Defines the element to stop listening the inputs from
  36268. */
  36269. detachControl(element: Nullable<HTMLElement>): void;
  36270. /**
  36271. * Gets the class name of the current intput.
  36272. * @returns the class name
  36273. */
  36274. getClassName(): string;
  36275. /**
  36276. * Get the friendly name associated with the input class.
  36277. * @returns the input friendly name
  36278. */
  36279. getSimpleName(): string;
  36280. }
  36281. }
  36282. declare module BABYLON {
  36283. /**
  36284. * Listen to mouse events to control the camera.
  36285. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36286. */
  36287. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36288. /**
  36289. * Defines the camera the input is attached to.
  36290. */
  36291. camera: FlyCamera;
  36292. /**
  36293. * Defines if touch is enabled. (Default is true.)
  36294. */
  36295. touchEnabled: boolean;
  36296. /**
  36297. * Defines the buttons associated with the input to handle camera rotation.
  36298. */
  36299. buttons: number[];
  36300. /**
  36301. * Assign buttons for Yaw control.
  36302. */
  36303. buttonsYaw: number[];
  36304. /**
  36305. * Assign buttons for Pitch control.
  36306. */
  36307. buttonsPitch: number[];
  36308. /**
  36309. * Assign buttons for Roll control.
  36310. */
  36311. buttonsRoll: number[];
  36312. /**
  36313. * Detect if any button is being pressed while mouse is moved.
  36314. * -1 = Mouse locked.
  36315. * 0 = Left button.
  36316. * 1 = Middle Button.
  36317. * 2 = Right Button.
  36318. */
  36319. activeButton: number;
  36320. /**
  36321. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36322. * Higher values reduce its sensitivity.
  36323. */
  36324. angularSensibility: number;
  36325. private _mousemoveCallback;
  36326. private _observer;
  36327. private _rollObserver;
  36328. private previousPosition;
  36329. private noPreventDefault;
  36330. private element;
  36331. /**
  36332. * Listen to mouse events to control the camera.
  36333. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36335. */
  36336. constructor(touchEnabled?: boolean);
  36337. /**
  36338. * Attach the mouse control to the HTML DOM element.
  36339. * @param element Defines the element that listens to the input events.
  36340. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36341. */
  36342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36343. /**
  36344. * Detach the current controls from the specified dom element.
  36345. * @param element Defines the element to stop listening the inputs from
  36346. */
  36347. detachControl(element: Nullable<HTMLElement>): void;
  36348. /**
  36349. * Gets the class name of the current input.
  36350. * @returns the class name.
  36351. */
  36352. getClassName(): string;
  36353. /**
  36354. * Get the friendly name associated with the input class.
  36355. * @returns the input's friendly name.
  36356. */
  36357. getSimpleName(): string;
  36358. private _pointerInput;
  36359. private _onMouseMove;
  36360. /**
  36361. * Rotate camera by mouse offset.
  36362. */
  36363. private rotateCamera;
  36364. }
  36365. }
  36366. declare module BABYLON {
  36367. /**
  36368. * Default Inputs manager for the FlyCamera.
  36369. * It groups all the default supported inputs for ease of use.
  36370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36371. */
  36372. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36373. /**
  36374. * Instantiates a new FlyCameraInputsManager.
  36375. * @param camera Defines the camera the inputs belong to.
  36376. */
  36377. constructor(camera: FlyCamera);
  36378. /**
  36379. * Add keyboard input support to the input manager.
  36380. * @returns the new FlyCameraKeyboardMoveInput().
  36381. */
  36382. addKeyboard(): FlyCameraInputsManager;
  36383. /**
  36384. * Add mouse input support to the input manager.
  36385. * @param touchEnabled Enable touch screen support.
  36386. * @returns the new FlyCameraMouseInput().
  36387. */
  36388. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36389. }
  36390. }
  36391. declare module BABYLON {
  36392. /**
  36393. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36394. * such as in a 3D Space Shooter or a Flight Simulator.
  36395. */
  36396. export class FlyCamera extends TargetCamera {
  36397. /**
  36398. * Define the collision ellipsoid of the camera.
  36399. * This is helpful for simulating a camera body, like a player's body.
  36400. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36401. */
  36402. ellipsoid: Vector3;
  36403. /**
  36404. * Define an offset for the position of the ellipsoid around the camera.
  36405. * This can be helpful if the camera is attached away from the player's body center,
  36406. * such as at its head.
  36407. */
  36408. ellipsoidOffset: Vector3;
  36409. /**
  36410. * Enable or disable collisions of the camera with the rest of the scene objects.
  36411. */
  36412. checkCollisions: boolean;
  36413. /**
  36414. * Enable or disable gravity on the camera.
  36415. */
  36416. applyGravity: boolean;
  36417. /**
  36418. * Define the current direction the camera is moving to.
  36419. */
  36420. cameraDirection: Vector3;
  36421. /**
  36422. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36423. * This overrides and empties cameraRotation.
  36424. */
  36425. rotationQuaternion: Quaternion;
  36426. /**
  36427. * Track Roll to maintain the wanted Rolling when looking around.
  36428. */
  36429. _trackRoll: number;
  36430. /**
  36431. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36432. */
  36433. rollCorrect: number;
  36434. /**
  36435. * Mimic a banked turn, Rolling the camera when Yawing.
  36436. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36437. */
  36438. bankedTurn: boolean;
  36439. /**
  36440. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36441. */
  36442. bankedTurnLimit: number;
  36443. /**
  36444. * Value of 0 disables the banked Roll.
  36445. * Value of 1 is equal to the Yaw angle in radians.
  36446. */
  36447. bankedTurnMultiplier: number;
  36448. /**
  36449. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36450. */
  36451. inputs: FlyCameraInputsManager;
  36452. /**
  36453. * Gets the input sensibility for mouse input.
  36454. * Higher values reduce sensitivity.
  36455. */
  36456. /**
  36457. * Sets the input sensibility for a mouse input.
  36458. * Higher values reduce sensitivity.
  36459. */
  36460. angularSensibility: number;
  36461. /**
  36462. * Get the keys for camera movement forward.
  36463. */
  36464. /**
  36465. * Set the keys for camera movement forward.
  36466. */
  36467. keysForward: number[];
  36468. /**
  36469. * Get the keys for camera movement backward.
  36470. */
  36471. keysBackward: number[];
  36472. /**
  36473. * Get the keys for camera movement up.
  36474. */
  36475. /**
  36476. * Set the keys for camera movement up.
  36477. */
  36478. keysUp: number[];
  36479. /**
  36480. * Get the keys for camera movement down.
  36481. */
  36482. /**
  36483. * Set the keys for camera movement down.
  36484. */
  36485. keysDown: number[];
  36486. /**
  36487. * Get the keys for camera movement left.
  36488. */
  36489. /**
  36490. * Set the keys for camera movement left.
  36491. */
  36492. keysLeft: number[];
  36493. /**
  36494. * Set the keys for camera movement right.
  36495. */
  36496. /**
  36497. * Set the keys for camera movement right.
  36498. */
  36499. keysRight: number[];
  36500. /**
  36501. * Event raised when the camera collides with a mesh in the scene.
  36502. */
  36503. onCollide: (collidedMesh: AbstractMesh) => void;
  36504. private _collider;
  36505. private _needMoveForGravity;
  36506. private _oldPosition;
  36507. private _diffPosition;
  36508. private _newPosition;
  36509. /** @hidden */
  36510. _localDirection: Vector3;
  36511. /** @hidden */
  36512. _transformedDirection: Vector3;
  36513. /**
  36514. * Instantiates a FlyCamera.
  36515. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36516. * such as in a 3D Space Shooter or a Flight Simulator.
  36517. * @param name Define the name of the camera in the scene.
  36518. * @param position Define the starting position of the camera in the scene.
  36519. * @param scene Define the scene the camera belongs to.
  36520. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36521. */
  36522. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36523. /**
  36524. * Attach a control to the HTML DOM element.
  36525. * @param element Defines the element that listens to the input events.
  36526. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36527. */
  36528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36529. /**
  36530. * Detach a control from the HTML DOM element.
  36531. * The camera will stop reacting to that input.
  36532. * @param element Defines the element that listens to the input events.
  36533. */
  36534. detachControl(element: HTMLElement): void;
  36535. private _collisionMask;
  36536. /**
  36537. * Get the mask that the camera ignores in collision events.
  36538. */
  36539. /**
  36540. * Set the mask that the camera ignores in collision events.
  36541. */
  36542. collisionMask: number;
  36543. /** @hidden */
  36544. _collideWithWorld(displacement: Vector3): void;
  36545. /** @hidden */
  36546. private _onCollisionPositionChange;
  36547. /** @hidden */
  36548. _checkInputs(): void;
  36549. /** @hidden */
  36550. _decideIfNeedsToMove(): boolean;
  36551. /** @hidden */
  36552. _updatePosition(): void;
  36553. /**
  36554. * Restore the Roll to its target value at the rate specified.
  36555. * @param rate - Higher means slower restoring.
  36556. * @hidden
  36557. */
  36558. restoreRoll(rate: number): void;
  36559. /**
  36560. * Destroy the camera and release the current resources held by it.
  36561. */
  36562. dispose(): void;
  36563. /**
  36564. * Get the current object class name.
  36565. * @returns the class name.
  36566. */
  36567. getClassName(): string;
  36568. }
  36569. }
  36570. declare module BABYLON {
  36571. /**
  36572. * Listen to keyboard events to control the camera.
  36573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36574. */
  36575. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36576. /**
  36577. * Defines the camera the input is attached to.
  36578. */
  36579. camera: FlyCamera;
  36580. /**
  36581. * The list of keyboard keys used to control the forward move of the camera.
  36582. */
  36583. keysForward: number[];
  36584. /**
  36585. * The list of keyboard keys used to control the backward move of the camera.
  36586. */
  36587. keysBackward: number[];
  36588. /**
  36589. * The list of keyboard keys used to control the forward move of the camera.
  36590. */
  36591. keysUp: number[];
  36592. /**
  36593. * The list of keyboard keys used to control the backward move of the camera.
  36594. */
  36595. keysDown: number[];
  36596. /**
  36597. * The list of keyboard keys used to control the right strafe move of the camera.
  36598. */
  36599. keysRight: number[];
  36600. /**
  36601. * The list of keyboard keys used to control the left strafe move of the camera.
  36602. */
  36603. keysLeft: number[];
  36604. private _keys;
  36605. private _onCanvasBlurObserver;
  36606. private _onKeyboardObserver;
  36607. private _engine;
  36608. private _scene;
  36609. /**
  36610. * Attach the input controls to a specific dom element to get the input from.
  36611. * @param element Defines the element the controls should be listened from
  36612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36613. */
  36614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36615. /**
  36616. * Detach the current controls from the specified dom element.
  36617. * @param element Defines the element to stop listening the inputs from
  36618. */
  36619. detachControl(element: Nullable<HTMLElement>): void;
  36620. /**
  36621. * Gets the class name of the current intput.
  36622. * @returns the class name
  36623. */
  36624. getClassName(): string;
  36625. /** @hidden */
  36626. _onLostFocus(e: FocusEvent): void;
  36627. /**
  36628. * Get the friendly name associated with the input class.
  36629. * @returns the input friendly name
  36630. */
  36631. getSimpleName(): string;
  36632. /**
  36633. * Update the current camera state depending on the inputs that have been used this frame.
  36634. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36635. */
  36636. checkInputs(): void;
  36637. }
  36638. }
  36639. declare module BABYLON {
  36640. /**
  36641. * Manage the mouse wheel inputs to control a follow camera.
  36642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36643. */
  36644. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36645. /**
  36646. * Defines the camera the input is attached to.
  36647. */
  36648. camera: FollowCamera;
  36649. /**
  36650. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36651. */
  36652. axisControlRadius: boolean;
  36653. /**
  36654. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36655. */
  36656. axisControlHeight: boolean;
  36657. /**
  36658. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36659. */
  36660. axisControlRotation: boolean;
  36661. /**
  36662. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36663. * relation to mouseWheel events.
  36664. */
  36665. wheelPrecision: number;
  36666. /**
  36667. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36668. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36669. */
  36670. wheelDeltaPercentage: number;
  36671. private _wheel;
  36672. private _observer;
  36673. /**
  36674. * Attach the input controls to a specific dom element to get the input from.
  36675. * @param element Defines the element the controls should be listened from
  36676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36677. */
  36678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36679. /**
  36680. * Detach the current controls from the specified dom element.
  36681. * @param element Defines the element to stop listening the inputs from
  36682. */
  36683. detachControl(element: Nullable<HTMLElement>): void;
  36684. /**
  36685. * Gets the class name of the current intput.
  36686. * @returns the class name
  36687. */
  36688. getClassName(): string;
  36689. /**
  36690. * Get the friendly name associated with the input class.
  36691. * @returns the input friendly name
  36692. */
  36693. getSimpleName(): string;
  36694. }
  36695. }
  36696. declare module BABYLON {
  36697. /**
  36698. * Manage the pointers inputs to control an follow camera.
  36699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36700. */
  36701. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36702. /**
  36703. * Defines the camera the input is attached to.
  36704. */
  36705. camera: FollowCamera;
  36706. /**
  36707. * Gets the class name of the current input.
  36708. * @returns the class name
  36709. */
  36710. getClassName(): string;
  36711. /**
  36712. * Defines the pointer angular sensibility along the X axis or how fast is
  36713. * the camera rotating.
  36714. * A negative number will reverse the axis direction.
  36715. */
  36716. angularSensibilityX: number;
  36717. /**
  36718. * Defines the pointer angular sensibility along the Y axis or how fast is
  36719. * the camera rotating.
  36720. * A negative number will reverse the axis direction.
  36721. */
  36722. angularSensibilityY: number;
  36723. /**
  36724. * Defines the pointer pinch precision or how fast is the camera zooming.
  36725. * A negative number will reverse the axis direction.
  36726. */
  36727. pinchPrecision: number;
  36728. /**
  36729. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36730. * from 0.
  36731. * It defines the percentage of current camera.radius to use as delta when
  36732. * pinch zoom is used.
  36733. */
  36734. pinchDeltaPercentage: number;
  36735. /**
  36736. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36737. */
  36738. axisXControlRadius: boolean;
  36739. /**
  36740. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36741. */
  36742. axisXControlHeight: boolean;
  36743. /**
  36744. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36745. */
  36746. axisXControlRotation: boolean;
  36747. /**
  36748. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36749. */
  36750. axisYControlRadius: boolean;
  36751. /**
  36752. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36753. */
  36754. axisYControlHeight: boolean;
  36755. /**
  36756. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36757. */
  36758. axisYControlRotation: boolean;
  36759. /**
  36760. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36761. */
  36762. axisPinchControlRadius: boolean;
  36763. /**
  36764. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36765. */
  36766. axisPinchControlHeight: boolean;
  36767. /**
  36768. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36769. */
  36770. axisPinchControlRotation: boolean;
  36771. /**
  36772. * Log error messages if basic misconfiguration has occurred.
  36773. */
  36774. warningEnable: boolean;
  36775. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36776. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36777. private _warningCounter;
  36778. private _warning;
  36779. }
  36780. }
  36781. declare module BABYLON {
  36782. /**
  36783. * Default Inputs manager for the FollowCamera.
  36784. * It groups all the default supported inputs for ease of use.
  36785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36786. */
  36787. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36788. /**
  36789. * Instantiates a new FollowCameraInputsManager.
  36790. * @param camera Defines the camera the inputs belong to
  36791. */
  36792. constructor(camera: FollowCamera);
  36793. /**
  36794. * Add keyboard input support to the input manager.
  36795. * @returns the current input manager
  36796. */
  36797. addKeyboard(): FollowCameraInputsManager;
  36798. /**
  36799. * Add mouse wheel input support to the input manager.
  36800. * @returns the current input manager
  36801. */
  36802. addMouseWheel(): FollowCameraInputsManager;
  36803. /**
  36804. * Add pointers input support to the input manager.
  36805. * @returns the current input manager
  36806. */
  36807. addPointers(): FollowCameraInputsManager;
  36808. /**
  36809. * Add orientation input support to the input manager.
  36810. * @returns the current input manager
  36811. */
  36812. addVRDeviceOrientation(): FollowCameraInputsManager;
  36813. }
  36814. }
  36815. declare module BABYLON {
  36816. /**
  36817. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36818. * an arc rotate version arcFollowCamera are available.
  36819. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36820. */
  36821. export class FollowCamera extends TargetCamera {
  36822. /**
  36823. * Distance the follow camera should follow an object at
  36824. */
  36825. radius: number;
  36826. /**
  36827. * Minimum allowed distance of the camera to the axis of rotation
  36828. * (The camera can not get closer).
  36829. * This can help limiting how the Camera is able to move in the scene.
  36830. */
  36831. lowerRadiusLimit: Nullable<number>;
  36832. /**
  36833. * Maximum allowed distance of the camera to the axis of rotation
  36834. * (The camera can not get further).
  36835. * This can help limiting how the Camera is able to move in the scene.
  36836. */
  36837. upperRadiusLimit: Nullable<number>;
  36838. /**
  36839. * Define a rotation offset between the camera and the object it follows
  36840. */
  36841. rotationOffset: number;
  36842. /**
  36843. * Minimum allowed angle to camera position relative to target object.
  36844. * This can help limiting how the Camera is able to move in the scene.
  36845. */
  36846. lowerRotationOffsetLimit: Nullable<number>;
  36847. /**
  36848. * Maximum allowed angle to camera position relative to target object.
  36849. * This can help limiting how the Camera is able to move in the scene.
  36850. */
  36851. upperRotationOffsetLimit: Nullable<number>;
  36852. /**
  36853. * Define a height offset between the camera and the object it follows.
  36854. * It can help following an object from the top (like a car chaing a plane)
  36855. */
  36856. heightOffset: number;
  36857. /**
  36858. * Minimum allowed height of camera position relative to target object.
  36859. * This can help limiting how the Camera is able to move in the scene.
  36860. */
  36861. lowerHeightOffsetLimit: Nullable<number>;
  36862. /**
  36863. * Maximum allowed height of camera position relative to target object.
  36864. * This can help limiting how the Camera is able to move in the scene.
  36865. */
  36866. upperHeightOffsetLimit: Nullable<number>;
  36867. /**
  36868. * Define how fast the camera can accelerate to follow it s target.
  36869. */
  36870. cameraAcceleration: number;
  36871. /**
  36872. * Define the speed limit of the camera following an object.
  36873. */
  36874. maxCameraSpeed: number;
  36875. /**
  36876. * Define the target of the camera.
  36877. */
  36878. lockedTarget: Nullable<AbstractMesh>;
  36879. /**
  36880. * Defines the input associated with the camera.
  36881. */
  36882. inputs: FollowCameraInputsManager;
  36883. /**
  36884. * Instantiates the follow camera.
  36885. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36886. * @param name Define the name of the camera in the scene
  36887. * @param position Define the position of the camera
  36888. * @param scene Define the scene the camera belong to
  36889. * @param lockedTarget Define the target of the camera
  36890. */
  36891. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36892. private _follow;
  36893. /**
  36894. * Attached controls to the current camera.
  36895. * @param element Defines the element the controls should be listened from
  36896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36897. */
  36898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36899. /**
  36900. * Detach the current controls from the camera.
  36901. * The camera will stop reacting to inputs.
  36902. * @param element Defines the element to stop listening the inputs from
  36903. */
  36904. detachControl(element: HTMLElement): void;
  36905. /** @hidden */
  36906. _checkInputs(): void;
  36907. private _checkLimits;
  36908. /**
  36909. * Gets the camera class name.
  36910. * @returns the class name
  36911. */
  36912. getClassName(): string;
  36913. }
  36914. /**
  36915. * Arc Rotate version of the follow camera.
  36916. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36917. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36918. */
  36919. export class ArcFollowCamera extends TargetCamera {
  36920. /** The longitudinal angle of the camera */
  36921. alpha: number;
  36922. /** The latitudinal angle of the camera */
  36923. beta: number;
  36924. /** The radius of the camera from its target */
  36925. radius: number;
  36926. /** Define the camera target (the messh it should follow) */
  36927. target: Nullable<AbstractMesh>;
  36928. private _cartesianCoordinates;
  36929. /**
  36930. * Instantiates a new ArcFollowCamera
  36931. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36932. * @param name Define the name of the camera
  36933. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36934. * @param beta Define the rotation angle of the camera around the elevation axis
  36935. * @param radius Define the radius of the camera from its target point
  36936. * @param target Define the target of the camera
  36937. * @param scene Define the scene the camera belongs to
  36938. */
  36939. constructor(name: string,
  36940. /** The longitudinal angle of the camera */
  36941. alpha: number,
  36942. /** The latitudinal angle of the camera */
  36943. beta: number,
  36944. /** The radius of the camera from its target */
  36945. radius: number,
  36946. /** Define the camera target (the messh it should follow) */
  36947. target: Nullable<AbstractMesh>, scene: Scene);
  36948. private _follow;
  36949. /** @hidden */
  36950. _checkInputs(): void;
  36951. /**
  36952. * Returns the class name of the object.
  36953. * It is mostly used internally for serialization purposes.
  36954. */
  36955. getClassName(): string;
  36956. }
  36957. }
  36958. declare module BABYLON {
  36959. /**
  36960. * Manage the keyboard inputs to control the movement of a follow camera.
  36961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36962. */
  36963. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36964. /**
  36965. * Defines the camera the input is attached to.
  36966. */
  36967. camera: FollowCamera;
  36968. /**
  36969. * Defines the list of key codes associated with the up action (increase heightOffset)
  36970. */
  36971. keysHeightOffsetIncr: number[];
  36972. /**
  36973. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36974. */
  36975. keysHeightOffsetDecr: number[];
  36976. /**
  36977. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36978. */
  36979. keysHeightOffsetModifierAlt: boolean;
  36980. /**
  36981. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36982. */
  36983. keysHeightOffsetModifierCtrl: boolean;
  36984. /**
  36985. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36986. */
  36987. keysHeightOffsetModifierShift: boolean;
  36988. /**
  36989. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36990. */
  36991. keysRotationOffsetIncr: number[];
  36992. /**
  36993. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36994. */
  36995. keysRotationOffsetDecr: number[];
  36996. /**
  36997. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36998. */
  36999. keysRotationOffsetModifierAlt: boolean;
  37000. /**
  37001. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37002. */
  37003. keysRotationOffsetModifierCtrl: boolean;
  37004. /**
  37005. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37006. */
  37007. keysRotationOffsetModifierShift: boolean;
  37008. /**
  37009. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37010. */
  37011. keysRadiusIncr: number[];
  37012. /**
  37013. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37014. */
  37015. keysRadiusDecr: number[];
  37016. /**
  37017. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37018. */
  37019. keysRadiusModifierAlt: boolean;
  37020. /**
  37021. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37022. */
  37023. keysRadiusModifierCtrl: boolean;
  37024. /**
  37025. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37026. */
  37027. keysRadiusModifierShift: boolean;
  37028. /**
  37029. * Defines the rate of change of heightOffset.
  37030. */
  37031. heightSensibility: number;
  37032. /**
  37033. * Defines the rate of change of rotationOffset.
  37034. */
  37035. rotationSensibility: number;
  37036. /**
  37037. * Defines the rate of change of radius.
  37038. */
  37039. radiusSensibility: number;
  37040. private _keys;
  37041. private _ctrlPressed;
  37042. private _altPressed;
  37043. private _shiftPressed;
  37044. private _onCanvasBlurObserver;
  37045. private _onKeyboardObserver;
  37046. private _engine;
  37047. private _scene;
  37048. /**
  37049. * Attach the input controls to a specific dom element to get the input from.
  37050. * @param element Defines the element the controls should be listened from
  37051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37052. */
  37053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37054. /**
  37055. * Detach the current controls from the specified dom element.
  37056. * @param element Defines the element to stop listening the inputs from
  37057. */
  37058. detachControl(element: Nullable<HTMLElement>): void;
  37059. /**
  37060. * Update the current camera state depending on the inputs that have been used this frame.
  37061. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37062. */
  37063. checkInputs(): void;
  37064. /**
  37065. * Gets the class name of the current input.
  37066. * @returns the class name
  37067. */
  37068. getClassName(): string;
  37069. /**
  37070. * Get the friendly name associated with the input class.
  37071. * @returns the input friendly name
  37072. */
  37073. getSimpleName(): string;
  37074. /**
  37075. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37076. * allow modification of the heightOffset value.
  37077. */
  37078. private _modifierHeightOffset;
  37079. /**
  37080. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37081. * allow modification of the rotationOffset value.
  37082. */
  37083. private _modifierRotationOffset;
  37084. /**
  37085. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37086. * allow modification of the radius value.
  37087. */
  37088. private _modifierRadius;
  37089. }
  37090. }
  37091. declare module BABYLON {
  37092. interface FreeCameraInputsManager {
  37093. /**
  37094. * @hidden
  37095. */
  37096. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37097. /**
  37098. * Add orientation input support to the input manager.
  37099. * @returns the current input manager
  37100. */
  37101. addDeviceOrientation(): FreeCameraInputsManager;
  37102. }
  37103. /**
  37104. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37105. * Screen rotation is taken into account.
  37106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37107. */
  37108. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37109. private _camera;
  37110. private _screenOrientationAngle;
  37111. private _constantTranform;
  37112. private _screenQuaternion;
  37113. private _alpha;
  37114. private _beta;
  37115. private _gamma;
  37116. /**
  37117. * @hidden
  37118. */
  37119. _onDeviceOrientationChangedObservable: Observable<void>;
  37120. /**
  37121. * Instantiates a new input
  37122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37123. */
  37124. constructor();
  37125. /**
  37126. * Define the camera controlled by the input.
  37127. */
  37128. camera: FreeCamera;
  37129. /**
  37130. * Attach the input controls to a specific dom element to get the input from.
  37131. * @param element Defines the element the controls should be listened from
  37132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37133. */
  37134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37135. private _orientationChanged;
  37136. private _deviceOrientation;
  37137. /**
  37138. * Detach the current controls from the specified dom element.
  37139. * @param element Defines the element to stop listening the inputs from
  37140. */
  37141. detachControl(element: Nullable<HTMLElement>): void;
  37142. /**
  37143. * Update the current camera state depending on the inputs that have been used this frame.
  37144. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37145. */
  37146. checkInputs(): void;
  37147. /**
  37148. * Gets the class name of the current intput.
  37149. * @returns the class name
  37150. */
  37151. getClassName(): string;
  37152. /**
  37153. * Get the friendly name associated with the input class.
  37154. * @returns the input friendly name
  37155. */
  37156. getSimpleName(): string;
  37157. }
  37158. }
  37159. declare module BABYLON {
  37160. /**
  37161. * Manage the gamepad inputs to control a free camera.
  37162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37163. */
  37164. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37165. /**
  37166. * Define the camera the input is attached to.
  37167. */
  37168. camera: FreeCamera;
  37169. /**
  37170. * Define the Gamepad controlling the input
  37171. */
  37172. gamepad: Nullable<Gamepad>;
  37173. /**
  37174. * Defines the gamepad rotation sensiblity.
  37175. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37176. */
  37177. gamepadAngularSensibility: number;
  37178. /**
  37179. * Defines the gamepad move sensiblity.
  37180. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37181. */
  37182. gamepadMoveSensibility: number;
  37183. private _onGamepadConnectedObserver;
  37184. private _onGamepadDisconnectedObserver;
  37185. private _cameraTransform;
  37186. private _deltaTransform;
  37187. private _vector3;
  37188. private _vector2;
  37189. /**
  37190. * Attach the input controls to a specific dom element to get the input from.
  37191. * @param element Defines the element the controls should be listened from
  37192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37193. */
  37194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37195. /**
  37196. * Detach the current controls from the specified dom element.
  37197. * @param element Defines the element to stop listening the inputs from
  37198. */
  37199. detachControl(element: Nullable<HTMLElement>): void;
  37200. /**
  37201. * Update the current camera state depending on the inputs that have been used this frame.
  37202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37203. */
  37204. checkInputs(): void;
  37205. /**
  37206. * Gets the class name of the current intput.
  37207. * @returns the class name
  37208. */
  37209. getClassName(): string;
  37210. /**
  37211. * Get the friendly name associated with the input class.
  37212. * @returns the input friendly name
  37213. */
  37214. getSimpleName(): string;
  37215. }
  37216. }
  37217. declare module BABYLON {
  37218. /**
  37219. * Defines the potential axis of a Joystick
  37220. */
  37221. export enum JoystickAxis {
  37222. /** X axis */
  37223. X = 0,
  37224. /** Y axis */
  37225. Y = 1,
  37226. /** Z axis */
  37227. Z = 2
  37228. }
  37229. /**
  37230. * Class used to define virtual joystick (used in touch mode)
  37231. */
  37232. export class VirtualJoystick {
  37233. /**
  37234. * Gets or sets a boolean indicating that left and right values must be inverted
  37235. */
  37236. reverseLeftRight: boolean;
  37237. /**
  37238. * Gets or sets a boolean indicating that up and down values must be inverted
  37239. */
  37240. reverseUpDown: boolean;
  37241. /**
  37242. * Gets the offset value for the position (ie. the change of the position value)
  37243. */
  37244. deltaPosition: Vector3;
  37245. /**
  37246. * Gets a boolean indicating if the virtual joystick was pressed
  37247. */
  37248. pressed: boolean;
  37249. /**
  37250. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37251. */
  37252. static Canvas: Nullable<HTMLCanvasElement>;
  37253. private static _globalJoystickIndex;
  37254. private static vjCanvasContext;
  37255. private static vjCanvasWidth;
  37256. private static vjCanvasHeight;
  37257. private static halfWidth;
  37258. private _action;
  37259. private _axisTargetedByLeftAndRight;
  37260. private _axisTargetedByUpAndDown;
  37261. private _joystickSensibility;
  37262. private _inversedSensibility;
  37263. private _joystickPointerID;
  37264. private _joystickColor;
  37265. private _joystickPointerPos;
  37266. private _joystickPreviousPointerPos;
  37267. private _joystickPointerStartPos;
  37268. private _deltaJoystickVector;
  37269. private _leftJoystick;
  37270. private _touches;
  37271. private _onPointerDownHandlerRef;
  37272. private _onPointerMoveHandlerRef;
  37273. private _onPointerUpHandlerRef;
  37274. private _onResize;
  37275. /**
  37276. * Creates a new virtual joystick
  37277. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37278. */
  37279. constructor(leftJoystick?: boolean);
  37280. /**
  37281. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37282. * @param newJoystickSensibility defines the new sensibility
  37283. */
  37284. setJoystickSensibility(newJoystickSensibility: number): void;
  37285. private _onPointerDown;
  37286. private _onPointerMove;
  37287. private _onPointerUp;
  37288. /**
  37289. * Change the color of the virtual joystick
  37290. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37291. */
  37292. setJoystickColor(newColor: string): void;
  37293. /**
  37294. * Defines a callback to call when the joystick is touched
  37295. * @param action defines the callback
  37296. */
  37297. setActionOnTouch(action: () => any): void;
  37298. /**
  37299. * Defines which axis you'd like to control for left & right
  37300. * @param axis defines the axis to use
  37301. */
  37302. setAxisForLeftRight(axis: JoystickAxis): void;
  37303. /**
  37304. * Defines which axis you'd like to control for up & down
  37305. * @param axis defines the axis to use
  37306. */
  37307. setAxisForUpDown(axis: JoystickAxis): void;
  37308. private _drawVirtualJoystick;
  37309. /**
  37310. * Release internal HTML canvas
  37311. */
  37312. releaseCanvas(): void;
  37313. }
  37314. }
  37315. declare module BABYLON {
  37316. interface FreeCameraInputsManager {
  37317. /**
  37318. * Add virtual joystick input support to the input manager.
  37319. * @returns the current input manager
  37320. */
  37321. addVirtualJoystick(): FreeCameraInputsManager;
  37322. }
  37323. /**
  37324. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37326. */
  37327. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37328. /**
  37329. * Defines the camera the input is attached to.
  37330. */
  37331. camera: FreeCamera;
  37332. private _leftjoystick;
  37333. private _rightjoystick;
  37334. /**
  37335. * Gets the left stick of the virtual joystick.
  37336. * @returns The virtual Joystick
  37337. */
  37338. getLeftJoystick(): VirtualJoystick;
  37339. /**
  37340. * Gets the right stick of the virtual joystick.
  37341. * @returns The virtual Joystick
  37342. */
  37343. getRightJoystick(): VirtualJoystick;
  37344. /**
  37345. * Update the current camera state depending on the inputs that have been used this frame.
  37346. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37347. */
  37348. checkInputs(): void;
  37349. /**
  37350. * Attach the input controls to a specific dom element to get the input from.
  37351. * @param element Defines the element the controls should be listened from
  37352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37353. */
  37354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37355. /**
  37356. * Detach the current controls from the specified dom element.
  37357. * @param element Defines the element to stop listening the inputs from
  37358. */
  37359. detachControl(element: Nullable<HTMLElement>): void;
  37360. /**
  37361. * Gets the class name of the current intput.
  37362. * @returns the class name
  37363. */
  37364. getClassName(): string;
  37365. /**
  37366. * Get the friendly name associated with the input class.
  37367. * @returns the input friendly name
  37368. */
  37369. getSimpleName(): string;
  37370. }
  37371. }
  37372. declare module BABYLON {
  37373. /**
  37374. * This represents a FPS type of camera controlled by touch.
  37375. * This is like a universal camera minus the Gamepad controls.
  37376. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37377. */
  37378. export class TouchCamera extends FreeCamera {
  37379. /**
  37380. * Defines the touch sensibility for rotation.
  37381. * The higher the faster.
  37382. */
  37383. touchAngularSensibility: number;
  37384. /**
  37385. * Defines the touch sensibility for move.
  37386. * The higher the faster.
  37387. */
  37388. touchMoveSensibility: number;
  37389. /**
  37390. * Instantiates a new touch camera.
  37391. * This represents a FPS type of camera controlled by touch.
  37392. * This is like a universal camera minus the Gamepad controls.
  37393. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37394. * @param name Define the name of the camera in the scene
  37395. * @param position Define the start position of the camera in the scene
  37396. * @param scene Define the scene the camera belongs to
  37397. */
  37398. constructor(name: string, position: Vector3, scene: Scene);
  37399. /**
  37400. * Gets the current object class name.
  37401. * @return the class name
  37402. */
  37403. getClassName(): string;
  37404. /** @hidden */
  37405. _setupInputs(): void;
  37406. }
  37407. }
  37408. declare module BABYLON {
  37409. /**
  37410. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37411. * being tilted forward or back and left or right.
  37412. */
  37413. export class DeviceOrientationCamera extends FreeCamera {
  37414. private _initialQuaternion;
  37415. private _quaternionCache;
  37416. private _tmpDragQuaternion;
  37417. /**
  37418. * Creates a new device orientation camera
  37419. * @param name The name of the camera
  37420. * @param position The start position camera
  37421. * @param scene The scene the camera belongs to
  37422. */
  37423. constructor(name: string, position: Vector3, scene: Scene);
  37424. /**
  37425. * @hidden
  37426. * Disabled pointer input on first orientation sensor update (Default: true)
  37427. */
  37428. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37429. private _dragFactor;
  37430. /**
  37431. * Enabled turning on the y axis when the orientation sensor is active
  37432. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37433. */
  37434. enableHorizontalDragging(dragFactor?: number): void;
  37435. /**
  37436. * Gets the current instance class name ("DeviceOrientationCamera").
  37437. * This helps avoiding instanceof at run time.
  37438. * @returns the class name
  37439. */
  37440. getClassName(): string;
  37441. /**
  37442. * @hidden
  37443. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37444. */
  37445. _checkInputs(): void;
  37446. /**
  37447. * Reset the camera to its default orientation on the specified axis only.
  37448. * @param axis The axis to reset
  37449. */
  37450. resetToCurrentRotation(axis?: Axis): void;
  37451. }
  37452. }
  37453. declare module BABYLON {
  37454. /**
  37455. * 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,
  37456. * which still works and will still be found in many Playgrounds.
  37457. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37458. */
  37459. export class UniversalCamera extends TouchCamera {
  37460. /**
  37461. * Defines the gamepad rotation sensiblity.
  37462. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37463. */
  37464. gamepadAngularSensibility: number;
  37465. /**
  37466. * Defines the gamepad move sensiblity.
  37467. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37468. */
  37469. gamepadMoveSensibility: number;
  37470. /**
  37471. * 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,
  37472. * which still works and will still be found in many Playgrounds.
  37473. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37474. * @param name Define the name of the camera in the scene
  37475. * @param position Define the start position of the camera in the scene
  37476. * @param scene Define the scene the camera belongs to
  37477. */
  37478. constructor(name: string, position: Vector3, scene: Scene);
  37479. /**
  37480. * Gets the current object class name.
  37481. * @return the class name
  37482. */
  37483. getClassName(): string;
  37484. }
  37485. }
  37486. declare module BABYLON {
  37487. /**
  37488. * This represents a FPS type of camera. This is only here for back compat purpose.
  37489. * Please use the UniversalCamera instead as both are identical.
  37490. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37491. */
  37492. export class GamepadCamera extends UniversalCamera {
  37493. /**
  37494. * Instantiates a new Gamepad Camera
  37495. * This represents a FPS type of camera. This is only here for back compat purpose.
  37496. * Please use the UniversalCamera instead as both are identical.
  37497. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37498. * @param name Define the name of the camera in the scene
  37499. * @param position Define the start position of the camera in the scene
  37500. * @param scene Define the scene the camera belongs to
  37501. */
  37502. constructor(name: string, position: Vector3, scene: Scene);
  37503. /**
  37504. * Gets the current object class name.
  37505. * @return the class name
  37506. */
  37507. getClassName(): string;
  37508. }
  37509. }
  37510. declare module BABYLON {
  37511. /** @hidden */
  37512. export var passPixelShader: {
  37513. name: string;
  37514. shader: string;
  37515. };
  37516. }
  37517. declare module BABYLON {
  37518. /** @hidden */
  37519. export var passCubePixelShader: {
  37520. name: string;
  37521. shader: string;
  37522. };
  37523. }
  37524. declare module BABYLON {
  37525. /**
  37526. * PassPostProcess which produces an output the same as it's input
  37527. */
  37528. export class PassPostProcess extends PostProcess {
  37529. /**
  37530. * Creates the PassPostProcess
  37531. * @param name The name of the effect.
  37532. * @param options The required width/height ratio to downsize to before computing the render pass.
  37533. * @param camera The camera to apply the render pass to.
  37534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37535. * @param engine The engine which the post process will be applied. (default: current engine)
  37536. * @param reusable If the post process can be reused on the same frame. (default: false)
  37537. * @param textureType The type of texture to be used when performing the post processing.
  37538. * @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)
  37539. */
  37540. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37541. }
  37542. /**
  37543. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37544. */
  37545. export class PassCubePostProcess extends PostProcess {
  37546. private _face;
  37547. /**
  37548. * Gets or sets the cube face to display.
  37549. * * 0 is +X
  37550. * * 1 is -X
  37551. * * 2 is +Y
  37552. * * 3 is -Y
  37553. * * 4 is +Z
  37554. * * 5 is -Z
  37555. */
  37556. face: number;
  37557. /**
  37558. * Creates the PassCubePostProcess
  37559. * @param name The name of the effect.
  37560. * @param options The required width/height ratio to downsize to before computing the render pass.
  37561. * @param camera The camera to apply the render pass to.
  37562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37563. * @param engine The engine which the post process will be applied. (default: current engine)
  37564. * @param reusable If the post process can be reused on the same frame. (default: false)
  37565. * @param textureType The type of texture to be used when performing the post processing.
  37566. * @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)
  37567. */
  37568. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37569. }
  37570. }
  37571. declare module BABYLON {
  37572. /** @hidden */
  37573. export var anaglyphPixelShader: {
  37574. name: string;
  37575. shader: string;
  37576. };
  37577. }
  37578. declare module BABYLON {
  37579. /**
  37580. * Postprocess used to generate anaglyphic rendering
  37581. */
  37582. export class AnaglyphPostProcess extends PostProcess {
  37583. private _passedProcess;
  37584. /**
  37585. * Creates a new AnaglyphPostProcess
  37586. * @param name defines postprocess name
  37587. * @param options defines creation options or target ratio scale
  37588. * @param rigCameras defines cameras using this postprocess
  37589. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37590. * @param engine defines hosting engine
  37591. * @param reusable defines if the postprocess will be reused multiple times per frame
  37592. */
  37593. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37594. }
  37595. }
  37596. declare module BABYLON {
  37597. /**
  37598. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37599. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37600. */
  37601. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37602. /**
  37603. * Creates a new AnaglyphArcRotateCamera
  37604. * @param name defines camera name
  37605. * @param alpha defines alpha angle (in radians)
  37606. * @param beta defines beta angle (in radians)
  37607. * @param radius defines radius
  37608. * @param target defines camera target
  37609. * @param interaxialDistance defines distance between each color axis
  37610. * @param scene defines the hosting scene
  37611. */
  37612. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37613. /**
  37614. * Gets camera class name
  37615. * @returns AnaglyphArcRotateCamera
  37616. */
  37617. getClassName(): string;
  37618. }
  37619. }
  37620. declare module BABYLON {
  37621. /**
  37622. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37623. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37624. */
  37625. export class AnaglyphFreeCamera extends FreeCamera {
  37626. /**
  37627. * Creates a new AnaglyphFreeCamera
  37628. * @param name defines camera name
  37629. * @param position defines initial position
  37630. * @param interaxialDistance defines distance between each color axis
  37631. * @param scene defines the hosting scene
  37632. */
  37633. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37634. /**
  37635. * Gets camera class name
  37636. * @returns AnaglyphFreeCamera
  37637. */
  37638. getClassName(): string;
  37639. }
  37640. }
  37641. declare module BABYLON {
  37642. /**
  37643. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37644. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37645. */
  37646. export class AnaglyphGamepadCamera extends GamepadCamera {
  37647. /**
  37648. * Creates a new AnaglyphGamepadCamera
  37649. * @param name defines camera name
  37650. * @param position defines initial position
  37651. * @param interaxialDistance defines distance between each color axis
  37652. * @param scene defines the hosting scene
  37653. */
  37654. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37655. /**
  37656. * Gets camera class name
  37657. * @returns AnaglyphGamepadCamera
  37658. */
  37659. getClassName(): string;
  37660. }
  37661. }
  37662. declare module BABYLON {
  37663. /**
  37664. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37665. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37666. */
  37667. export class AnaglyphUniversalCamera extends UniversalCamera {
  37668. /**
  37669. * Creates a new AnaglyphUniversalCamera
  37670. * @param name defines camera name
  37671. * @param position defines initial position
  37672. * @param interaxialDistance defines distance between each color axis
  37673. * @param scene defines the hosting scene
  37674. */
  37675. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37676. /**
  37677. * Gets camera class name
  37678. * @returns AnaglyphUniversalCamera
  37679. */
  37680. getClassName(): string;
  37681. }
  37682. }
  37683. declare module BABYLON {
  37684. /** @hidden */
  37685. export var stereoscopicInterlacePixelShader: {
  37686. name: string;
  37687. shader: string;
  37688. };
  37689. }
  37690. declare module BABYLON {
  37691. /**
  37692. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37693. */
  37694. export class StereoscopicInterlacePostProcess extends PostProcess {
  37695. private _stepSize;
  37696. private _passedProcess;
  37697. /**
  37698. * Initializes a StereoscopicInterlacePostProcess
  37699. * @param name The name of the effect.
  37700. * @param rigCameras The rig cameras to be appled to the post process
  37701. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37703. * @param engine The engine which the post process will be applied. (default: current engine)
  37704. * @param reusable If the post process can be reused on the same frame. (default: false)
  37705. */
  37706. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37707. }
  37708. }
  37709. declare module BABYLON {
  37710. /**
  37711. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37712. * @see http://doc.babylonjs.com/features/cameras
  37713. */
  37714. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37715. /**
  37716. * Creates a new StereoscopicArcRotateCamera
  37717. * @param name defines camera name
  37718. * @param alpha defines alpha angle (in radians)
  37719. * @param beta defines beta angle (in radians)
  37720. * @param radius defines radius
  37721. * @param target defines camera target
  37722. * @param interaxialDistance defines distance between each color axis
  37723. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37724. * @param scene defines the hosting scene
  37725. */
  37726. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37727. /**
  37728. * Gets camera class name
  37729. * @returns StereoscopicArcRotateCamera
  37730. */
  37731. getClassName(): string;
  37732. }
  37733. }
  37734. declare module BABYLON {
  37735. /**
  37736. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37737. * @see http://doc.babylonjs.com/features/cameras
  37738. */
  37739. export class StereoscopicFreeCamera extends FreeCamera {
  37740. /**
  37741. * Creates a new StereoscopicFreeCamera
  37742. * @param name defines camera name
  37743. * @param position defines initial position
  37744. * @param interaxialDistance defines distance between each color axis
  37745. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37746. * @param scene defines the hosting scene
  37747. */
  37748. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37749. /**
  37750. * Gets camera class name
  37751. * @returns StereoscopicFreeCamera
  37752. */
  37753. getClassName(): string;
  37754. }
  37755. }
  37756. declare module BABYLON {
  37757. /**
  37758. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37759. * @see http://doc.babylonjs.com/features/cameras
  37760. */
  37761. export class StereoscopicGamepadCamera extends GamepadCamera {
  37762. /**
  37763. * Creates a new StereoscopicGamepadCamera
  37764. * @param name defines camera name
  37765. * @param position defines initial position
  37766. * @param interaxialDistance defines distance between each color axis
  37767. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37768. * @param scene defines the hosting scene
  37769. */
  37770. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37771. /**
  37772. * Gets camera class name
  37773. * @returns StereoscopicGamepadCamera
  37774. */
  37775. getClassName(): string;
  37776. }
  37777. }
  37778. declare module BABYLON {
  37779. /**
  37780. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37781. * @see http://doc.babylonjs.com/features/cameras
  37782. */
  37783. export class StereoscopicUniversalCamera extends UniversalCamera {
  37784. /**
  37785. * Creates a new StereoscopicUniversalCamera
  37786. * @param name defines camera name
  37787. * @param position defines initial position
  37788. * @param interaxialDistance defines distance between each color axis
  37789. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37790. * @param scene defines the hosting scene
  37791. */
  37792. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37793. /**
  37794. * Gets camera class name
  37795. * @returns StereoscopicUniversalCamera
  37796. */
  37797. getClassName(): string;
  37798. }
  37799. }
  37800. declare module BABYLON {
  37801. /**
  37802. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37803. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37804. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37805. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37806. */
  37807. export class VirtualJoysticksCamera extends FreeCamera {
  37808. /**
  37809. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37810. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37811. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37812. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37813. * @param name Define the name of the camera in the scene
  37814. * @param position Define the start position of the camera in the scene
  37815. * @param scene Define the scene the camera belongs to
  37816. */
  37817. constructor(name: string, position: Vector3, scene: Scene);
  37818. /**
  37819. * Gets the current object class name.
  37820. * @return the class name
  37821. */
  37822. getClassName(): string;
  37823. }
  37824. }
  37825. declare module BABYLON {
  37826. /**
  37827. * This represents all the required metrics to create a VR camera.
  37828. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37829. */
  37830. export class VRCameraMetrics {
  37831. /**
  37832. * Define the horizontal resolution off the screen.
  37833. */
  37834. hResolution: number;
  37835. /**
  37836. * Define the vertical resolution off the screen.
  37837. */
  37838. vResolution: number;
  37839. /**
  37840. * Define the horizontal screen size.
  37841. */
  37842. hScreenSize: number;
  37843. /**
  37844. * Define the vertical screen size.
  37845. */
  37846. vScreenSize: number;
  37847. /**
  37848. * Define the vertical screen center position.
  37849. */
  37850. vScreenCenter: number;
  37851. /**
  37852. * Define the distance of the eyes to the screen.
  37853. */
  37854. eyeToScreenDistance: number;
  37855. /**
  37856. * Define the distance between both lenses
  37857. */
  37858. lensSeparationDistance: number;
  37859. /**
  37860. * Define the distance between both viewer's eyes.
  37861. */
  37862. interpupillaryDistance: number;
  37863. /**
  37864. * Define the distortion factor of the VR postprocess.
  37865. * Please, touch with care.
  37866. */
  37867. distortionK: number[];
  37868. /**
  37869. * Define the chromatic aberration correction factors for the VR post process.
  37870. */
  37871. chromaAbCorrection: number[];
  37872. /**
  37873. * Define the scale factor of the post process.
  37874. * The smaller the better but the slower.
  37875. */
  37876. postProcessScaleFactor: number;
  37877. /**
  37878. * Define an offset for the lens center.
  37879. */
  37880. lensCenterOffset: number;
  37881. /**
  37882. * Define if the current vr camera should compensate the distortion of the lense or not.
  37883. */
  37884. compensateDistortion: boolean;
  37885. /**
  37886. * Defines if multiview should be enabled when rendering (Default: false)
  37887. */
  37888. multiviewEnabled: boolean;
  37889. /**
  37890. * Gets the rendering aspect ratio based on the provided resolutions.
  37891. */
  37892. readonly aspectRatio: number;
  37893. /**
  37894. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37895. */
  37896. readonly aspectRatioFov: number;
  37897. /**
  37898. * @hidden
  37899. */
  37900. readonly leftHMatrix: Matrix;
  37901. /**
  37902. * @hidden
  37903. */
  37904. readonly rightHMatrix: Matrix;
  37905. /**
  37906. * @hidden
  37907. */
  37908. readonly leftPreViewMatrix: Matrix;
  37909. /**
  37910. * @hidden
  37911. */
  37912. readonly rightPreViewMatrix: Matrix;
  37913. /**
  37914. * Get the default VRMetrics based on the most generic setup.
  37915. * @returns the default vr metrics
  37916. */
  37917. static GetDefault(): VRCameraMetrics;
  37918. }
  37919. }
  37920. declare module BABYLON {
  37921. /** @hidden */
  37922. export var vrDistortionCorrectionPixelShader: {
  37923. name: string;
  37924. shader: string;
  37925. };
  37926. }
  37927. declare module BABYLON {
  37928. /**
  37929. * VRDistortionCorrectionPostProcess used for mobile VR
  37930. */
  37931. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37932. private _isRightEye;
  37933. private _distortionFactors;
  37934. private _postProcessScaleFactor;
  37935. private _lensCenterOffset;
  37936. private _scaleIn;
  37937. private _scaleFactor;
  37938. private _lensCenter;
  37939. /**
  37940. * Initializes the VRDistortionCorrectionPostProcess
  37941. * @param name The name of the effect.
  37942. * @param camera The camera to apply the render pass to.
  37943. * @param isRightEye If this is for the right eye distortion
  37944. * @param vrMetrics All the required metrics for the VR camera
  37945. */
  37946. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37947. }
  37948. }
  37949. declare module BABYLON {
  37950. /**
  37951. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37952. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37953. */
  37954. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37955. /**
  37956. * Creates a new VRDeviceOrientationArcRotateCamera
  37957. * @param name defines camera name
  37958. * @param alpha defines the camera rotation along the logitudinal axis
  37959. * @param beta defines the camera rotation along the latitudinal axis
  37960. * @param radius defines the camera distance from its target
  37961. * @param target defines the camera target
  37962. * @param scene defines the scene the camera belongs to
  37963. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37964. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37965. */
  37966. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37967. /**
  37968. * Gets camera class name
  37969. * @returns VRDeviceOrientationArcRotateCamera
  37970. */
  37971. getClassName(): string;
  37972. }
  37973. }
  37974. declare module BABYLON {
  37975. /**
  37976. * Camera used to simulate VR rendering (based on FreeCamera)
  37977. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37978. */
  37979. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37980. /**
  37981. * Creates a new VRDeviceOrientationFreeCamera
  37982. * @param name defines camera name
  37983. * @param position defines the start position of the camera
  37984. * @param scene defines the scene the camera belongs to
  37985. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37986. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37987. */
  37988. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37989. /**
  37990. * Gets camera class name
  37991. * @returns VRDeviceOrientationFreeCamera
  37992. */
  37993. getClassName(): string;
  37994. }
  37995. }
  37996. declare module BABYLON {
  37997. /**
  37998. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37999. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38000. */
  38001. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38002. /**
  38003. * Creates a new VRDeviceOrientationGamepadCamera
  38004. * @param name defines camera name
  38005. * @param position defines the start position of the camera
  38006. * @param scene defines the scene the camera belongs to
  38007. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38008. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38009. */
  38010. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38011. /**
  38012. * Gets camera class name
  38013. * @returns VRDeviceOrientationGamepadCamera
  38014. */
  38015. getClassName(): string;
  38016. }
  38017. }
  38018. declare module BABYLON {
  38019. /**
  38020. * Defines supported buttons for XBox360 compatible gamepads
  38021. */
  38022. export enum Xbox360Button {
  38023. /** A */
  38024. A = 0,
  38025. /** B */
  38026. B = 1,
  38027. /** X */
  38028. X = 2,
  38029. /** Y */
  38030. Y = 3,
  38031. /** Start */
  38032. Start = 4,
  38033. /** Back */
  38034. Back = 5,
  38035. /** Left button */
  38036. LB = 6,
  38037. /** Right button */
  38038. RB = 7,
  38039. /** Left stick */
  38040. LeftStick = 8,
  38041. /** Right stick */
  38042. RightStick = 9
  38043. }
  38044. /** Defines values for XBox360 DPad */
  38045. export enum Xbox360Dpad {
  38046. /** Up */
  38047. Up = 0,
  38048. /** Down */
  38049. Down = 1,
  38050. /** Left */
  38051. Left = 2,
  38052. /** Right */
  38053. Right = 3
  38054. }
  38055. /**
  38056. * Defines a XBox360 gamepad
  38057. */
  38058. export class Xbox360Pad extends Gamepad {
  38059. private _leftTrigger;
  38060. private _rightTrigger;
  38061. private _onlefttriggerchanged;
  38062. private _onrighttriggerchanged;
  38063. private _onbuttondown;
  38064. private _onbuttonup;
  38065. private _ondpaddown;
  38066. private _ondpadup;
  38067. /** Observable raised when a button is pressed */
  38068. onButtonDownObservable: Observable<Xbox360Button>;
  38069. /** Observable raised when a button is released */
  38070. onButtonUpObservable: Observable<Xbox360Button>;
  38071. /** Observable raised when a pad is pressed */
  38072. onPadDownObservable: Observable<Xbox360Dpad>;
  38073. /** Observable raised when a pad is released */
  38074. onPadUpObservable: Observable<Xbox360Dpad>;
  38075. private _buttonA;
  38076. private _buttonB;
  38077. private _buttonX;
  38078. private _buttonY;
  38079. private _buttonBack;
  38080. private _buttonStart;
  38081. private _buttonLB;
  38082. private _buttonRB;
  38083. private _buttonLeftStick;
  38084. private _buttonRightStick;
  38085. private _dPadUp;
  38086. private _dPadDown;
  38087. private _dPadLeft;
  38088. private _dPadRight;
  38089. private _isXboxOnePad;
  38090. /**
  38091. * Creates a new XBox360 gamepad object
  38092. * @param id defines the id of this gamepad
  38093. * @param index defines its index
  38094. * @param gamepad defines the internal HTML gamepad object
  38095. * @param xboxOne defines if it is a XBox One gamepad
  38096. */
  38097. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38098. /**
  38099. * Defines the callback to call when left trigger is pressed
  38100. * @param callback defines the callback to use
  38101. */
  38102. onlefttriggerchanged(callback: (value: number) => void): void;
  38103. /**
  38104. * Defines the callback to call when right trigger is pressed
  38105. * @param callback defines the callback to use
  38106. */
  38107. onrighttriggerchanged(callback: (value: number) => void): void;
  38108. /**
  38109. * Gets the left trigger value
  38110. */
  38111. /**
  38112. * Sets the left trigger value
  38113. */
  38114. leftTrigger: number;
  38115. /**
  38116. * Gets the right trigger value
  38117. */
  38118. /**
  38119. * Sets the right trigger value
  38120. */
  38121. rightTrigger: number;
  38122. /**
  38123. * Defines the callback to call when a button is pressed
  38124. * @param callback defines the callback to use
  38125. */
  38126. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38127. /**
  38128. * Defines the callback to call when a button is released
  38129. * @param callback defines the callback to use
  38130. */
  38131. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38132. /**
  38133. * Defines the callback to call when a pad is pressed
  38134. * @param callback defines the callback to use
  38135. */
  38136. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38137. /**
  38138. * Defines the callback to call when a pad is released
  38139. * @param callback defines the callback to use
  38140. */
  38141. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38142. private _setButtonValue;
  38143. private _setDPadValue;
  38144. /**
  38145. * Gets the value of the `A` button
  38146. */
  38147. /**
  38148. * Sets the value of the `A` button
  38149. */
  38150. buttonA: number;
  38151. /**
  38152. * Gets the value of the `B` button
  38153. */
  38154. /**
  38155. * Sets the value of the `B` button
  38156. */
  38157. buttonB: number;
  38158. /**
  38159. * Gets the value of the `X` button
  38160. */
  38161. /**
  38162. * Sets the value of the `X` button
  38163. */
  38164. buttonX: number;
  38165. /**
  38166. * Gets the value of the `Y` button
  38167. */
  38168. /**
  38169. * Sets the value of the `Y` button
  38170. */
  38171. buttonY: number;
  38172. /**
  38173. * Gets the value of the `Start` button
  38174. */
  38175. /**
  38176. * Sets the value of the `Start` button
  38177. */
  38178. buttonStart: number;
  38179. /**
  38180. * Gets the value of the `Back` button
  38181. */
  38182. /**
  38183. * Sets the value of the `Back` button
  38184. */
  38185. buttonBack: number;
  38186. /**
  38187. * Gets the value of the `Left` button
  38188. */
  38189. /**
  38190. * Sets the value of the `Left` button
  38191. */
  38192. buttonLB: number;
  38193. /**
  38194. * Gets the value of the `Right` button
  38195. */
  38196. /**
  38197. * Sets the value of the `Right` button
  38198. */
  38199. buttonRB: number;
  38200. /**
  38201. * Gets the value of the Left joystick
  38202. */
  38203. /**
  38204. * Sets the value of the Left joystick
  38205. */
  38206. buttonLeftStick: number;
  38207. /**
  38208. * Gets the value of the Right joystick
  38209. */
  38210. /**
  38211. * Sets the value of the Right joystick
  38212. */
  38213. buttonRightStick: number;
  38214. /**
  38215. * Gets the value of D-pad up
  38216. */
  38217. /**
  38218. * Sets the value of D-pad up
  38219. */
  38220. dPadUp: number;
  38221. /**
  38222. * Gets the value of D-pad down
  38223. */
  38224. /**
  38225. * Sets the value of D-pad down
  38226. */
  38227. dPadDown: number;
  38228. /**
  38229. * Gets the value of D-pad left
  38230. */
  38231. /**
  38232. * Sets the value of D-pad left
  38233. */
  38234. dPadLeft: number;
  38235. /**
  38236. * Gets the value of D-pad right
  38237. */
  38238. /**
  38239. * Sets the value of D-pad right
  38240. */
  38241. dPadRight: number;
  38242. /**
  38243. * Force the gamepad to synchronize with device values
  38244. */
  38245. update(): void;
  38246. /**
  38247. * Disposes the gamepad
  38248. */
  38249. dispose(): void;
  38250. }
  38251. }
  38252. declare module BABYLON {
  38253. /**
  38254. * Base class of materials working in push mode in babylon JS
  38255. * @hidden
  38256. */
  38257. export class PushMaterial extends Material {
  38258. protected _activeEffect: Effect;
  38259. protected _normalMatrix: Matrix;
  38260. /**
  38261. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38262. * This means that the material can keep using a previous shader while a new one is being compiled.
  38263. * This is mostly used when shader parallel compilation is supported (true by default)
  38264. */
  38265. allowShaderHotSwapping: boolean;
  38266. constructor(name: string, scene: Scene);
  38267. getEffect(): Effect;
  38268. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38269. /**
  38270. * Binds the given world matrix to the active effect
  38271. *
  38272. * @param world the matrix to bind
  38273. */
  38274. bindOnlyWorldMatrix(world: Matrix): void;
  38275. /**
  38276. * Binds the given normal matrix to the active effect
  38277. *
  38278. * @param normalMatrix the matrix to bind
  38279. */
  38280. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38281. bind(world: Matrix, mesh?: Mesh): void;
  38282. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38283. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38284. }
  38285. }
  38286. declare module BABYLON {
  38287. /**
  38288. * This groups all the flags used to control the materials channel.
  38289. */
  38290. export class MaterialFlags {
  38291. private static _DiffuseTextureEnabled;
  38292. /**
  38293. * Are diffuse textures enabled in the application.
  38294. */
  38295. static DiffuseTextureEnabled: boolean;
  38296. private static _AmbientTextureEnabled;
  38297. /**
  38298. * Are ambient textures enabled in the application.
  38299. */
  38300. static AmbientTextureEnabled: boolean;
  38301. private static _OpacityTextureEnabled;
  38302. /**
  38303. * Are opacity textures enabled in the application.
  38304. */
  38305. static OpacityTextureEnabled: boolean;
  38306. private static _ReflectionTextureEnabled;
  38307. /**
  38308. * Are reflection textures enabled in the application.
  38309. */
  38310. static ReflectionTextureEnabled: boolean;
  38311. private static _EmissiveTextureEnabled;
  38312. /**
  38313. * Are emissive textures enabled in the application.
  38314. */
  38315. static EmissiveTextureEnabled: boolean;
  38316. private static _SpecularTextureEnabled;
  38317. /**
  38318. * Are specular textures enabled in the application.
  38319. */
  38320. static SpecularTextureEnabled: boolean;
  38321. private static _BumpTextureEnabled;
  38322. /**
  38323. * Are bump textures enabled in the application.
  38324. */
  38325. static BumpTextureEnabled: boolean;
  38326. private static _LightmapTextureEnabled;
  38327. /**
  38328. * Are lightmap textures enabled in the application.
  38329. */
  38330. static LightmapTextureEnabled: boolean;
  38331. private static _RefractionTextureEnabled;
  38332. /**
  38333. * Are refraction textures enabled in the application.
  38334. */
  38335. static RefractionTextureEnabled: boolean;
  38336. private static _ColorGradingTextureEnabled;
  38337. /**
  38338. * Are color grading textures enabled in the application.
  38339. */
  38340. static ColorGradingTextureEnabled: boolean;
  38341. private static _FresnelEnabled;
  38342. /**
  38343. * Are fresnels enabled in the application.
  38344. */
  38345. static FresnelEnabled: boolean;
  38346. private static _ClearCoatTextureEnabled;
  38347. /**
  38348. * Are clear coat textures enabled in the application.
  38349. */
  38350. static ClearCoatTextureEnabled: boolean;
  38351. private static _ClearCoatBumpTextureEnabled;
  38352. /**
  38353. * Are clear coat bump textures enabled in the application.
  38354. */
  38355. static ClearCoatBumpTextureEnabled: boolean;
  38356. private static _ClearCoatTintTextureEnabled;
  38357. /**
  38358. * Are clear coat tint textures enabled in the application.
  38359. */
  38360. static ClearCoatTintTextureEnabled: boolean;
  38361. private static _SheenTextureEnabled;
  38362. /**
  38363. * Are sheen textures enabled in the application.
  38364. */
  38365. static SheenTextureEnabled: boolean;
  38366. private static _AnisotropicTextureEnabled;
  38367. /**
  38368. * Are anisotropic textures enabled in the application.
  38369. */
  38370. static AnisotropicTextureEnabled: boolean;
  38371. private static _ThicknessTextureEnabled;
  38372. /**
  38373. * Are thickness textures enabled in the application.
  38374. */
  38375. static ThicknessTextureEnabled: boolean;
  38376. }
  38377. }
  38378. declare module BABYLON {
  38379. /** @hidden */
  38380. export var defaultFragmentDeclaration: {
  38381. name: string;
  38382. shader: string;
  38383. };
  38384. }
  38385. declare module BABYLON {
  38386. /** @hidden */
  38387. export var defaultUboDeclaration: {
  38388. name: string;
  38389. shader: string;
  38390. };
  38391. }
  38392. declare module BABYLON {
  38393. /** @hidden */
  38394. export var lightFragmentDeclaration: {
  38395. name: string;
  38396. shader: string;
  38397. };
  38398. }
  38399. declare module BABYLON {
  38400. /** @hidden */
  38401. export var lightUboDeclaration: {
  38402. name: string;
  38403. shader: string;
  38404. };
  38405. }
  38406. declare module BABYLON {
  38407. /** @hidden */
  38408. export var lightsFragmentFunctions: {
  38409. name: string;
  38410. shader: string;
  38411. };
  38412. }
  38413. declare module BABYLON {
  38414. /** @hidden */
  38415. export var shadowsFragmentFunctions: {
  38416. name: string;
  38417. shader: string;
  38418. };
  38419. }
  38420. declare module BABYLON {
  38421. /** @hidden */
  38422. export var fresnelFunction: {
  38423. name: string;
  38424. shader: string;
  38425. };
  38426. }
  38427. declare module BABYLON {
  38428. /** @hidden */
  38429. export var reflectionFunction: {
  38430. name: string;
  38431. shader: string;
  38432. };
  38433. }
  38434. declare module BABYLON {
  38435. /** @hidden */
  38436. export var bumpFragmentFunctions: {
  38437. name: string;
  38438. shader: string;
  38439. };
  38440. }
  38441. declare module BABYLON {
  38442. /** @hidden */
  38443. export var logDepthDeclaration: {
  38444. name: string;
  38445. shader: string;
  38446. };
  38447. }
  38448. declare module BABYLON {
  38449. /** @hidden */
  38450. export var bumpFragment: {
  38451. name: string;
  38452. shader: string;
  38453. };
  38454. }
  38455. declare module BABYLON {
  38456. /** @hidden */
  38457. export var depthPrePass: {
  38458. name: string;
  38459. shader: string;
  38460. };
  38461. }
  38462. declare module BABYLON {
  38463. /** @hidden */
  38464. export var lightFragment: {
  38465. name: string;
  38466. shader: string;
  38467. };
  38468. }
  38469. declare module BABYLON {
  38470. /** @hidden */
  38471. export var logDepthFragment: {
  38472. name: string;
  38473. shader: string;
  38474. };
  38475. }
  38476. declare module BABYLON {
  38477. /** @hidden */
  38478. export var defaultPixelShader: {
  38479. name: string;
  38480. shader: string;
  38481. };
  38482. }
  38483. declare module BABYLON {
  38484. /** @hidden */
  38485. export var defaultVertexDeclaration: {
  38486. name: string;
  38487. shader: string;
  38488. };
  38489. }
  38490. declare module BABYLON {
  38491. /** @hidden */
  38492. export var bumpVertexDeclaration: {
  38493. name: string;
  38494. shader: string;
  38495. };
  38496. }
  38497. declare module BABYLON {
  38498. /** @hidden */
  38499. export var bumpVertex: {
  38500. name: string;
  38501. shader: string;
  38502. };
  38503. }
  38504. declare module BABYLON {
  38505. /** @hidden */
  38506. export var fogVertex: {
  38507. name: string;
  38508. shader: string;
  38509. };
  38510. }
  38511. declare module BABYLON {
  38512. /** @hidden */
  38513. export var shadowsVertex: {
  38514. name: string;
  38515. shader: string;
  38516. };
  38517. }
  38518. declare module BABYLON {
  38519. /** @hidden */
  38520. export var pointCloudVertex: {
  38521. name: string;
  38522. shader: string;
  38523. };
  38524. }
  38525. declare module BABYLON {
  38526. /** @hidden */
  38527. export var logDepthVertex: {
  38528. name: string;
  38529. shader: string;
  38530. };
  38531. }
  38532. declare module BABYLON {
  38533. /** @hidden */
  38534. export var defaultVertexShader: {
  38535. name: string;
  38536. shader: string;
  38537. };
  38538. }
  38539. declare module BABYLON {
  38540. /** @hidden */
  38541. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38542. MAINUV1: boolean;
  38543. MAINUV2: boolean;
  38544. DIFFUSE: boolean;
  38545. DIFFUSEDIRECTUV: number;
  38546. AMBIENT: boolean;
  38547. AMBIENTDIRECTUV: number;
  38548. OPACITY: boolean;
  38549. OPACITYDIRECTUV: number;
  38550. OPACITYRGB: boolean;
  38551. REFLECTION: boolean;
  38552. EMISSIVE: boolean;
  38553. EMISSIVEDIRECTUV: number;
  38554. SPECULAR: boolean;
  38555. SPECULARDIRECTUV: number;
  38556. BUMP: boolean;
  38557. BUMPDIRECTUV: number;
  38558. PARALLAX: boolean;
  38559. PARALLAXOCCLUSION: boolean;
  38560. SPECULAROVERALPHA: boolean;
  38561. CLIPPLANE: boolean;
  38562. CLIPPLANE2: boolean;
  38563. CLIPPLANE3: boolean;
  38564. CLIPPLANE4: boolean;
  38565. ALPHATEST: boolean;
  38566. DEPTHPREPASS: boolean;
  38567. ALPHAFROMDIFFUSE: boolean;
  38568. POINTSIZE: boolean;
  38569. FOG: boolean;
  38570. SPECULARTERM: boolean;
  38571. DIFFUSEFRESNEL: boolean;
  38572. OPACITYFRESNEL: boolean;
  38573. REFLECTIONFRESNEL: boolean;
  38574. REFRACTIONFRESNEL: boolean;
  38575. EMISSIVEFRESNEL: boolean;
  38576. FRESNEL: boolean;
  38577. NORMAL: boolean;
  38578. UV1: boolean;
  38579. UV2: boolean;
  38580. VERTEXCOLOR: boolean;
  38581. VERTEXALPHA: boolean;
  38582. NUM_BONE_INFLUENCERS: number;
  38583. BonesPerMesh: number;
  38584. BONETEXTURE: boolean;
  38585. INSTANCES: boolean;
  38586. GLOSSINESS: boolean;
  38587. ROUGHNESS: boolean;
  38588. EMISSIVEASILLUMINATION: boolean;
  38589. LINKEMISSIVEWITHDIFFUSE: boolean;
  38590. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38591. LIGHTMAP: boolean;
  38592. LIGHTMAPDIRECTUV: number;
  38593. OBJECTSPACE_NORMALMAP: boolean;
  38594. USELIGHTMAPASSHADOWMAP: boolean;
  38595. REFLECTIONMAP_3D: boolean;
  38596. REFLECTIONMAP_SPHERICAL: boolean;
  38597. REFLECTIONMAP_PLANAR: boolean;
  38598. REFLECTIONMAP_CUBIC: boolean;
  38599. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38600. REFLECTIONMAP_PROJECTION: boolean;
  38601. REFLECTIONMAP_SKYBOX: boolean;
  38602. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38603. REFLECTIONMAP_EXPLICIT: boolean;
  38604. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38605. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38606. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38607. INVERTCUBICMAP: boolean;
  38608. LOGARITHMICDEPTH: boolean;
  38609. REFRACTION: boolean;
  38610. REFRACTIONMAP_3D: boolean;
  38611. REFLECTIONOVERALPHA: boolean;
  38612. TWOSIDEDLIGHTING: boolean;
  38613. SHADOWFLOAT: boolean;
  38614. MORPHTARGETS: boolean;
  38615. MORPHTARGETS_NORMAL: boolean;
  38616. MORPHTARGETS_TANGENT: boolean;
  38617. NUM_MORPH_INFLUENCERS: number;
  38618. NONUNIFORMSCALING: boolean;
  38619. PREMULTIPLYALPHA: boolean;
  38620. IMAGEPROCESSING: boolean;
  38621. VIGNETTE: boolean;
  38622. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38623. VIGNETTEBLENDMODEOPAQUE: boolean;
  38624. TONEMAPPING: boolean;
  38625. TONEMAPPING_ACES: boolean;
  38626. CONTRAST: boolean;
  38627. COLORCURVES: boolean;
  38628. COLORGRADING: boolean;
  38629. COLORGRADING3D: boolean;
  38630. SAMPLER3DGREENDEPTH: boolean;
  38631. SAMPLER3DBGRMAP: boolean;
  38632. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38633. MULTIVIEW: boolean;
  38634. /**
  38635. * If the reflection texture on this material is in linear color space
  38636. * @hidden
  38637. */
  38638. IS_REFLECTION_LINEAR: boolean;
  38639. /**
  38640. * If the refraction texture on this material is in linear color space
  38641. * @hidden
  38642. */
  38643. IS_REFRACTION_LINEAR: boolean;
  38644. EXPOSURE: boolean;
  38645. constructor();
  38646. setReflectionMode(modeToEnable: string): void;
  38647. }
  38648. /**
  38649. * This is the default material used in Babylon. It is the best trade off between quality
  38650. * and performances.
  38651. * @see http://doc.babylonjs.com/babylon101/materials
  38652. */
  38653. export class StandardMaterial extends PushMaterial {
  38654. private _diffuseTexture;
  38655. /**
  38656. * The basic texture of the material as viewed under a light.
  38657. */
  38658. diffuseTexture: Nullable<BaseTexture>;
  38659. private _ambientTexture;
  38660. /**
  38661. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38662. */
  38663. ambientTexture: Nullable<BaseTexture>;
  38664. private _opacityTexture;
  38665. /**
  38666. * Define the transparency of the material from a texture.
  38667. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38668. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38669. */
  38670. opacityTexture: Nullable<BaseTexture>;
  38671. private _reflectionTexture;
  38672. /**
  38673. * Define the texture used to display the reflection.
  38674. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38675. */
  38676. reflectionTexture: Nullable<BaseTexture>;
  38677. private _emissiveTexture;
  38678. /**
  38679. * Define texture of the material as if self lit.
  38680. * This will be mixed in the final result even in the absence of light.
  38681. */
  38682. emissiveTexture: Nullable<BaseTexture>;
  38683. private _specularTexture;
  38684. /**
  38685. * Define how the color and intensity of the highlight given by the light in the material.
  38686. */
  38687. specularTexture: Nullable<BaseTexture>;
  38688. private _bumpTexture;
  38689. /**
  38690. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38691. * 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.
  38692. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38693. */
  38694. bumpTexture: Nullable<BaseTexture>;
  38695. private _lightmapTexture;
  38696. /**
  38697. * Complex lighting can be computationally expensive to compute at runtime.
  38698. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38699. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38700. */
  38701. lightmapTexture: Nullable<BaseTexture>;
  38702. private _refractionTexture;
  38703. /**
  38704. * Define the texture used to display the refraction.
  38705. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38706. */
  38707. refractionTexture: Nullable<BaseTexture>;
  38708. /**
  38709. * The color of the material lit by the environmental background lighting.
  38710. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38711. */
  38712. ambientColor: Color3;
  38713. /**
  38714. * The basic color of the material as viewed under a light.
  38715. */
  38716. diffuseColor: Color3;
  38717. /**
  38718. * Define how the color and intensity of the highlight given by the light in the material.
  38719. */
  38720. specularColor: Color3;
  38721. /**
  38722. * Define the color of the material as if self lit.
  38723. * This will be mixed in the final result even in the absence of light.
  38724. */
  38725. emissiveColor: Color3;
  38726. /**
  38727. * Defines how sharp are the highlights in the material.
  38728. * The bigger the value the sharper giving a more glossy feeling to the result.
  38729. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38730. */
  38731. specularPower: number;
  38732. private _useAlphaFromDiffuseTexture;
  38733. /**
  38734. * Does the transparency come from the diffuse texture alpha channel.
  38735. */
  38736. useAlphaFromDiffuseTexture: boolean;
  38737. private _useEmissiveAsIllumination;
  38738. /**
  38739. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38740. */
  38741. useEmissiveAsIllumination: boolean;
  38742. private _linkEmissiveWithDiffuse;
  38743. /**
  38744. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38745. * the emissive level when the final color is close to one.
  38746. */
  38747. linkEmissiveWithDiffuse: boolean;
  38748. private _useSpecularOverAlpha;
  38749. /**
  38750. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38751. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38752. */
  38753. useSpecularOverAlpha: boolean;
  38754. private _useReflectionOverAlpha;
  38755. /**
  38756. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38757. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38758. */
  38759. useReflectionOverAlpha: boolean;
  38760. private _disableLighting;
  38761. /**
  38762. * Does lights from the scene impacts this material.
  38763. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38764. */
  38765. disableLighting: boolean;
  38766. private _useObjectSpaceNormalMap;
  38767. /**
  38768. * Allows using an object space normal map (instead of tangent space).
  38769. */
  38770. useObjectSpaceNormalMap: boolean;
  38771. private _useParallax;
  38772. /**
  38773. * Is parallax enabled or not.
  38774. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38775. */
  38776. useParallax: boolean;
  38777. private _useParallaxOcclusion;
  38778. /**
  38779. * Is parallax occlusion enabled or not.
  38780. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38781. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38782. */
  38783. useParallaxOcclusion: boolean;
  38784. /**
  38785. * 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.
  38786. */
  38787. parallaxScaleBias: number;
  38788. private _roughness;
  38789. /**
  38790. * Helps to define how blurry the reflections should appears in the material.
  38791. */
  38792. roughness: number;
  38793. /**
  38794. * In case of refraction, define the value of the indice of refraction.
  38795. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38796. */
  38797. indexOfRefraction: number;
  38798. /**
  38799. * Invert the refraction texture alongside the y axis.
  38800. * It can be useful with procedural textures or probe for instance.
  38801. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38802. */
  38803. invertRefractionY: boolean;
  38804. /**
  38805. * Defines the alpha limits in alpha test mode.
  38806. */
  38807. alphaCutOff: number;
  38808. private _useLightmapAsShadowmap;
  38809. /**
  38810. * In case of light mapping, define whether the map contains light or shadow informations.
  38811. */
  38812. useLightmapAsShadowmap: boolean;
  38813. private _diffuseFresnelParameters;
  38814. /**
  38815. * Define the diffuse fresnel parameters of the material.
  38816. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38817. */
  38818. diffuseFresnelParameters: FresnelParameters;
  38819. private _opacityFresnelParameters;
  38820. /**
  38821. * Define the opacity fresnel parameters of the material.
  38822. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38823. */
  38824. opacityFresnelParameters: FresnelParameters;
  38825. private _reflectionFresnelParameters;
  38826. /**
  38827. * Define the reflection fresnel parameters of the material.
  38828. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38829. */
  38830. reflectionFresnelParameters: FresnelParameters;
  38831. private _refractionFresnelParameters;
  38832. /**
  38833. * Define the refraction fresnel parameters of the material.
  38834. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38835. */
  38836. refractionFresnelParameters: FresnelParameters;
  38837. private _emissiveFresnelParameters;
  38838. /**
  38839. * Define the emissive fresnel parameters of the material.
  38840. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38841. */
  38842. emissiveFresnelParameters: FresnelParameters;
  38843. private _useReflectionFresnelFromSpecular;
  38844. /**
  38845. * If true automatically deducts the fresnels values from the material specularity.
  38846. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38847. */
  38848. useReflectionFresnelFromSpecular: boolean;
  38849. private _useGlossinessFromSpecularMapAlpha;
  38850. /**
  38851. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38852. */
  38853. useGlossinessFromSpecularMapAlpha: boolean;
  38854. private _maxSimultaneousLights;
  38855. /**
  38856. * Defines the maximum number of lights that can be used in the material
  38857. */
  38858. maxSimultaneousLights: number;
  38859. private _invertNormalMapX;
  38860. /**
  38861. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38862. */
  38863. invertNormalMapX: boolean;
  38864. private _invertNormalMapY;
  38865. /**
  38866. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38867. */
  38868. invertNormalMapY: boolean;
  38869. private _twoSidedLighting;
  38870. /**
  38871. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38872. */
  38873. twoSidedLighting: boolean;
  38874. /**
  38875. * Default configuration related to image processing available in the standard Material.
  38876. */
  38877. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38878. /**
  38879. * Gets the image processing configuration used either in this material.
  38880. */
  38881. /**
  38882. * Sets the Default image processing configuration used either in the this material.
  38883. *
  38884. * If sets to null, the scene one is in use.
  38885. */
  38886. imageProcessingConfiguration: ImageProcessingConfiguration;
  38887. /**
  38888. * Keep track of the image processing observer to allow dispose and replace.
  38889. */
  38890. private _imageProcessingObserver;
  38891. /**
  38892. * Attaches a new image processing configuration to the Standard Material.
  38893. * @param configuration
  38894. */
  38895. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38896. /**
  38897. * Gets wether the color curves effect is enabled.
  38898. */
  38899. /**
  38900. * Sets wether the color curves effect is enabled.
  38901. */
  38902. cameraColorCurvesEnabled: boolean;
  38903. /**
  38904. * Gets wether the color grading effect is enabled.
  38905. */
  38906. /**
  38907. * Gets wether the color grading effect is enabled.
  38908. */
  38909. cameraColorGradingEnabled: boolean;
  38910. /**
  38911. * Gets wether tonemapping is enabled or not.
  38912. */
  38913. /**
  38914. * Sets wether tonemapping is enabled or not
  38915. */
  38916. cameraToneMappingEnabled: boolean;
  38917. /**
  38918. * The camera exposure used on this material.
  38919. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38920. * This corresponds to a photographic exposure.
  38921. */
  38922. /**
  38923. * The camera exposure used on this material.
  38924. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38925. * This corresponds to a photographic exposure.
  38926. */
  38927. cameraExposure: number;
  38928. /**
  38929. * Gets The camera contrast used on this material.
  38930. */
  38931. /**
  38932. * Sets The camera contrast used on this material.
  38933. */
  38934. cameraContrast: number;
  38935. /**
  38936. * Gets the Color Grading 2D Lookup Texture.
  38937. */
  38938. /**
  38939. * Sets the Color Grading 2D Lookup Texture.
  38940. */
  38941. cameraColorGradingTexture: Nullable<BaseTexture>;
  38942. /**
  38943. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38944. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38945. * 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;
  38946. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38947. */
  38948. /**
  38949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38951. * 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;
  38952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38953. */
  38954. cameraColorCurves: Nullable<ColorCurves>;
  38955. /**
  38956. * Custom callback helping to override the default shader used in the material.
  38957. */
  38958. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38959. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38960. protected _worldViewProjectionMatrix: Matrix;
  38961. protected _globalAmbientColor: Color3;
  38962. protected _useLogarithmicDepth: boolean;
  38963. /**
  38964. * Instantiates a new standard material.
  38965. * This is the default material used in Babylon. It is the best trade off between quality
  38966. * and performances.
  38967. * @see http://doc.babylonjs.com/babylon101/materials
  38968. * @param name Define the name of the material in the scene
  38969. * @param scene Define the scene the material belong to
  38970. */
  38971. constructor(name: string, scene: Scene);
  38972. /**
  38973. * Gets a boolean indicating that current material needs to register RTT
  38974. */
  38975. readonly hasRenderTargetTextures: boolean;
  38976. /**
  38977. * Gets the current class name of the material e.g. "StandardMaterial"
  38978. * Mainly use in serialization.
  38979. * @returns the class name
  38980. */
  38981. getClassName(): string;
  38982. /**
  38983. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38984. * You can try switching to logarithmic depth.
  38985. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38986. */
  38987. useLogarithmicDepth: boolean;
  38988. /**
  38989. * Specifies if the material will require alpha blending
  38990. * @returns a boolean specifying if alpha blending is needed
  38991. */
  38992. needAlphaBlending(): boolean;
  38993. /**
  38994. * Specifies if this material should be rendered in alpha test mode
  38995. * @returns a boolean specifying if an alpha test is needed.
  38996. */
  38997. needAlphaTesting(): boolean;
  38998. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38999. /**
  39000. * Get the texture used for alpha test purpose.
  39001. * @returns the diffuse texture in case of the standard material.
  39002. */
  39003. getAlphaTestTexture(): Nullable<BaseTexture>;
  39004. /**
  39005. * Get if the submesh is ready to be used and all its information available.
  39006. * Child classes can use it to update shaders
  39007. * @param mesh defines the mesh to check
  39008. * @param subMesh defines which submesh to check
  39009. * @param useInstances specifies that instances should be used
  39010. * @returns a boolean indicating that the submesh is ready or not
  39011. */
  39012. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39013. /**
  39014. * Builds the material UBO layouts.
  39015. * Used internally during the effect preparation.
  39016. */
  39017. buildUniformLayout(): void;
  39018. /**
  39019. * Unbinds the material from the mesh
  39020. */
  39021. unbind(): void;
  39022. /**
  39023. * Binds the submesh to this material by preparing the effect and shader to draw
  39024. * @param world defines the world transformation matrix
  39025. * @param mesh defines the mesh containing the submesh
  39026. * @param subMesh defines the submesh to bind the material to
  39027. */
  39028. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39029. /**
  39030. * Get the list of animatables in the material.
  39031. * @returns the list of animatables object used in the material
  39032. */
  39033. getAnimatables(): IAnimatable[];
  39034. /**
  39035. * Gets the active textures from the material
  39036. * @returns an array of textures
  39037. */
  39038. getActiveTextures(): BaseTexture[];
  39039. /**
  39040. * Specifies if the material uses a texture
  39041. * @param texture defines the texture to check against the material
  39042. * @returns a boolean specifying if the material uses the texture
  39043. */
  39044. hasTexture(texture: BaseTexture): boolean;
  39045. /**
  39046. * Disposes the material
  39047. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39048. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39049. */
  39050. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39051. /**
  39052. * Makes a duplicate of the material, and gives it a new name
  39053. * @param name defines the new name for the duplicated material
  39054. * @returns the cloned material
  39055. */
  39056. clone(name: string): StandardMaterial;
  39057. /**
  39058. * Serializes this material in a JSON representation
  39059. * @returns the serialized material object
  39060. */
  39061. serialize(): any;
  39062. /**
  39063. * Creates a standard material from parsed material data
  39064. * @param source defines the JSON representation of the material
  39065. * @param scene defines the hosting scene
  39066. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39067. * @returns a new standard material
  39068. */
  39069. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39070. /**
  39071. * Are diffuse textures enabled in the application.
  39072. */
  39073. static DiffuseTextureEnabled: boolean;
  39074. /**
  39075. * Are ambient textures enabled in the application.
  39076. */
  39077. static AmbientTextureEnabled: boolean;
  39078. /**
  39079. * Are opacity textures enabled in the application.
  39080. */
  39081. static OpacityTextureEnabled: boolean;
  39082. /**
  39083. * Are reflection textures enabled in the application.
  39084. */
  39085. static ReflectionTextureEnabled: boolean;
  39086. /**
  39087. * Are emissive textures enabled in the application.
  39088. */
  39089. static EmissiveTextureEnabled: boolean;
  39090. /**
  39091. * Are specular textures enabled in the application.
  39092. */
  39093. static SpecularTextureEnabled: boolean;
  39094. /**
  39095. * Are bump textures enabled in the application.
  39096. */
  39097. static BumpTextureEnabled: boolean;
  39098. /**
  39099. * Are lightmap textures enabled in the application.
  39100. */
  39101. static LightmapTextureEnabled: boolean;
  39102. /**
  39103. * Are refraction textures enabled in the application.
  39104. */
  39105. static RefractionTextureEnabled: boolean;
  39106. /**
  39107. * Are color grading textures enabled in the application.
  39108. */
  39109. static ColorGradingTextureEnabled: boolean;
  39110. /**
  39111. * Are fresnels enabled in the application.
  39112. */
  39113. static FresnelEnabled: boolean;
  39114. }
  39115. }
  39116. declare module BABYLON {
  39117. /**
  39118. * A class extending Texture allowing drawing on a texture
  39119. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39120. */
  39121. export class DynamicTexture extends Texture {
  39122. private _generateMipMaps;
  39123. private _canvas;
  39124. private _context;
  39125. private _engine;
  39126. /**
  39127. * Creates a DynamicTexture
  39128. * @param name defines the name of the texture
  39129. * @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
  39130. * @param scene defines the scene where you want the texture
  39131. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39132. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39133. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39134. */
  39135. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39136. /**
  39137. * Get the current class name of the texture useful for serialization or dynamic coding.
  39138. * @returns "DynamicTexture"
  39139. */
  39140. getClassName(): string;
  39141. /**
  39142. * Gets the current state of canRescale
  39143. */
  39144. readonly canRescale: boolean;
  39145. private _recreate;
  39146. /**
  39147. * Scales the texture
  39148. * @param ratio the scale factor to apply to both width and height
  39149. */
  39150. scale(ratio: number): void;
  39151. /**
  39152. * Resizes the texture
  39153. * @param width the new width
  39154. * @param height the new height
  39155. */
  39156. scaleTo(width: number, height: number): void;
  39157. /**
  39158. * Gets the context of the canvas used by the texture
  39159. * @returns the canvas context of the dynamic texture
  39160. */
  39161. getContext(): CanvasRenderingContext2D;
  39162. /**
  39163. * Clears the texture
  39164. */
  39165. clear(): void;
  39166. /**
  39167. * Updates the texture
  39168. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39169. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39170. */
  39171. update(invertY?: boolean, premulAlpha?: boolean): void;
  39172. /**
  39173. * Draws text onto the texture
  39174. * @param text defines the text to be drawn
  39175. * @param x defines the placement of the text from the left
  39176. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39177. * @param font defines the font to be used with font-style, font-size, font-name
  39178. * @param color defines the color used for the text
  39179. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39180. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39181. * @param update defines whether texture is immediately update (default is true)
  39182. */
  39183. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39184. /**
  39185. * Clones the texture
  39186. * @returns the clone of the texture.
  39187. */
  39188. clone(): DynamicTexture;
  39189. /**
  39190. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39191. * @returns a serialized dynamic texture object
  39192. */
  39193. serialize(): any;
  39194. /** @hidden */
  39195. _rebuild(): void;
  39196. }
  39197. }
  39198. declare module BABYLON {
  39199. /** @hidden */
  39200. export var imageProcessingPixelShader: {
  39201. name: string;
  39202. shader: string;
  39203. };
  39204. }
  39205. declare module BABYLON {
  39206. /**
  39207. * ImageProcessingPostProcess
  39208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39209. */
  39210. export class ImageProcessingPostProcess extends PostProcess {
  39211. /**
  39212. * Default configuration related to image processing available in the PBR Material.
  39213. */
  39214. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39215. /**
  39216. * Gets the image processing configuration used either in this material.
  39217. */
  39218. /**
  39219. * Sets the Default image processing configuration used either in the this material.
  39220. *
  39221. * If sets to null, the scene one is in use.
  39222. */
  39223. imageProcessingConfiguration: ImageProcessingConfiguration;
  39224. /**
  39225. * Keep track of the image processing observer to allow dispose and replace.
  39226. */
  39227. private _imageProcessingObserver;
  39228. /**
  39229. * Attaches a new image processing configuration to the PBR Material.
  39230. * @param configuration
  39231. */
  39232. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39233. /**
  39234. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39235. */
  39236. /**
  39237. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39238. */
  39239. colorCurves: Nullable<ColorCurves>;
  39240. /**
  39241. * Gets wether the color curves effect is enabled.
  39242. */
  39243. /**
  39244. * Sets wether the color curves effect is enabled.
  39245. */
  39246. colorCurvesEnabled: boolean;
  39247. /**
  39248. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39249. */
  39250. /**
  39251. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39252. */
  39253. colorGradingTexture: Nullable<BaseTexture>;
  39254. /**
  39255. * Gets wether the color grading effect is enabled.
  39256. */
  39257. /**
  39258. * Gets wether the color grading effect is enabled.
  39259. */
  39260. colorGradingEnabled: boolean;
  39261. /**
  39262. * Gets exposure used in the effect.
  39263. */
  39264. /**
  39265. * Sets exposure used in the effect.
  39266. */
  39267. exposure: number;
  39268. /**
  39269. * Gets wether tonemapping is enabled or not.
  39270. */
  39271. /**
  39272. * Sets wether tonemapping is enabled or not
  39273. */
  39274. toneMappingEnabled: boolean;
  39275. /**
  39276. * Gets the type of tone mapping effect.
  39277. */
  39278. /**
  39279. * Sets the type of tone mapping effect.
  39280. */
  39281. toneMappingType: number;
  39282. /**
  39283. * Gets contrast used in the effect.
  39284. */
  39285. /**
  39286. * Sets contrast used in the effect.
  39287. */
  39288. contrast: number;
  39289. /**
  39290. * Gets Vignette stretch size.
  39291. */
  39292. /**
  39293. * Sets Vignette stretch size.
  39294. */
  39295. vignetteStretch: number;
  39296. /**
  39297. * Gets Vignette centre X Offset.
  39298. */
  39299. /**
  39300. * Sets Vignette centre X Offset.
  39301. */
  39302. vignetteCentreX: number;
  39303. /**
  39304. * Gets Vignette centre Y Offset.
  39305. */
  39306. /**
  39307. * Sets Vignette centre Y Offset.
  39308. */
  39309. vignetteCentreY: number;
  39310. /**
  39311. * Gets Vignette weight or intensity of the vignette effect.
  39312. */
  39313. /**
  39314. * Sets Vignette weight or intensity of the vignette effect.
  39315. */
  39316. vignetteWeight: number;
  39317. /**
  39318. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39319. * if vignetteEnabled is set to true.
  39320. */
  39321. /**
  39322. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39323. * if vignetteEnabled is set to true.
  39324. */
  39325. vignetteColor: Color4;
  39326. /**
  39327. * Gets Camera field of view used by the Vignette effect.
  39328. */
  39329. /**
  39330. * Sets Camera field of view used by the Vignette effect.
  39331. */
  39332. vignetteCameraFov: number;
  39333. /**
  39334. * Gets the vignette blend mode allowing different kind of effect.
  39335. */
  39336. /**
  39337. * Sets the vignette blend mode allowing different kind of effect.
  39338. */
  39339. vignetteBlendMode: number;
  39340. /**
  39341. * Gets wether the vignette effect is enabled.
  39342. */
  39343. /**
  39344. * Sets wether the vignette effect is enabled.
  39345. */
  39346. vignetteEnabled: boolean;
  39347. private _fromLinearSpace;
  39348. /**
  39349. * Gets wether the input of the processing is in Gamma or Linear Space.
  39350. */
  39351. /**
  39352. * Sets wether the input of the processing is in Gamma or Linear Space.
  39353. */
  39354. fromLinearSpace: boolean;
  39355. /**
  39356. * Defines cache preventing GC.
  39357. */
  39358. private _defines;
  39359. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39360. /**
  39361. * "ImageProcessingPostProcess"
  39362. * @returns "ImageProcessingPostProcess"
  39363. */
  39364. getClassName(): string;
  39365. protected _updateParameters(): void;
  39366. dispose(camera?: Camera): void;
  39367. }
  39368. }
  39369. declare module BABYLON {
  39370. /**
  39371. * Class containing static functions to help procedurally build meshes
  39372. */
  39373. export class GroundBuilder {
  39374. /**
  39375. * Creates a ground mesh
  39376. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39377. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39379. * @param name defines the name of the mesh
  39380. * @param options defines the options used to create the mesh
  39381. * @param scene defines the hosting scene
  39382. * @returns the ground mesh
  39383. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39384. */
  39385. static CreateGround(name: string, options: {
  39386. width?: number;
  39387. height?: number;
  39388. subdivisions?: number;
  39389. subdivisionsX?: number;
  39390. subdivisionsY?: number;
  39391. updatable?: boolean;
  39392. }, scene: any): Mesh;
  39393. /**
  39394. * Creates a tiled ground mesh
  39395. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39396. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39397. * * 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
  39398. * * 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
  39399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39400. * @param name defines the name of the mesh
  39401. * @param options defines the options used to create the mesh
  39402. * @param scene defines the hosting scene
  39403. * @returns the tiled ground mesh
  39404. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39405. */
  39406. static CreateTiledGround(name: string, options: {
  39407. xmin: number;
  39408. zmin: number;
  39409. xmax: number;
  39410. zmax: number;
  39411. subdivisions?: {
  39412. w: number;
  39413. h: number;
  39414. };
  39415. precision?: {
  39416. w: number;
  39417. h: number;
  39418. };
  39419. updatable?: boolean;
  39420. }, scene?: Nullable<Scene>): Mesh;
  39421. /**
  39422. * Creates a ground mesh from a height map
  39423. * * The parameter `url` sets the URL of the height map image resource.
  39424. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39425. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39426. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39427. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39428. * * 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.
  39429. * * 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).
  39430. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39432. * @param name defines the name of the mesh
  39433. * @param url defines the url to the height map
  39434. * @param options defines the options used to create the mesh
  39435. * @param scene defines the hosting scene
  39436. * @returns the ground mesh
  39437. * @see https://doc.babylonjs.com/babylon101/height_map
  39438. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39439. */
  39440. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39441. width?: number;
  39442. height?: number;
  39443. subdivisions?: number;
  39444. minHeight?: number;
  39445. maxHeight?: number;
  39446. colorFilter?: Color3;
  39447. alphaFilter?: number;
  39448. updatable?: boolean;
  39449. onReady?: (mesh: GroundMesh) => void;
  39450. }, scene?: Nullable<Scene>): GroundMesh;
  39451. }
  39452. }
  39453. declare module BABYLON {
  39454. /**
  39455. * Class containing static functions to help procedurally build meshes
  39456. */
  39457. export class TorusBuilder {
  39458. /**
  39459. * Creates a torus mesh
  39460. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39461. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39462. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39464. * * 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
  39465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39466. * @param name defines the name of the mesh
  39467. * @param options defines the options used to create the mesh
  39468. * @param scene defines the hosting scene
  39469. * @returns the torus mesh
  39470. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39471. */
  39472. static CreateTorus(name: string, options: {
  39473. diameter?: number;
  39474. thickness?: number;
  39475. tessellation?: number;
  39476. updatable?: boolean;
  39477. sideOrientation?: number;
  39478. frontUVs?: Vector4;
  39479. backUVs?: Vector4;
  39480. }, scene: any): Mesh;
  39481. }
  39482. }
  39483. declare module BABYLON {
  39484. /**
  39485. * Class containing static functions to help procedurally build meshes
  39486. */
  39487. export class CylinderBuilder {
  39488. /**
  39489. * Creates a cylinder or a cone mesh
  39490. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39491. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39492. * * 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.
  39493. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39494. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39495. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39496. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39497. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39498. * * 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).
  39499. * * 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
  39500. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39501. * * 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
  39502. * * 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.
  39503. * * If `enclose` is false, a ring surface is one element.
  39504. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39505. * * 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
  39506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39507. * * 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
  39508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39509. * @param name defines the name of the mesh
  39510. * @param options defines the options used to create the mesh
  39511. * @param scene defines the hosting scene
  39512. * @returns the cylinder mesh
  39513. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39514. */
  39515. static CreateCylinder(name: string, options: {
  39516. height?: number;
  39517. diameterTop?: number;
  39518. diameterBottom?: number;
  39519. diameter?: number;
  39520. tessellation?: number;
  39521. subdivisions?: number;
  39522. arc?: number;
  39523. faceColors?: Color4[];
  39524. faceUV?: Vector4[];
  39525. updatable?: boolean;
  39526. hasRings?: boolean;
  39527. enclose?: boolean;
  39528. sideOrientation?: number;
  39529. frontUVs?: Vector4;
  39530. backUVs?: Vector4;
  39531. }, scene: any): Mesh;
  39532. }
  39533. }
  39534. declare module BABYLON {
  39535. /**
  39536. * Manager for handling gamepads
  39537. */
  39538. export class GamepadManager {
  39539. private _scene?;
  39540. private _babylonGamepads;
  39541. private _oneGamepadConnected;
  39542. /** @hidden */
  39543. _isMonitoring: boolean;
  39544. private _gamepadEventSupported;
  39545. private _gamepadSupport;
  39546. /**
  39547. * observable to be triggered when the gamepad controller has been connected
  39548. */
  39549. onGamepadConnectedObservable: Observable<Gamepad>;
  39550. /**
  39551. * observable to be triggered when the gamepad controller has been disconnected
  39552. */
  39553. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39554. private _onGamepadConnectedEvent;
  39555. private _onGamepadDisconnectedEvent;
  39556. /**
  39557. * Initializes the gamepad manager
  39558. * @param _scene BabylonJS scene
  39559. */
  39560. constructor(_scene?: Scene | undefined);
  39561. /**
  39562. * The gamepads in the game pad manager
  39563. */
  39564. readonly gamepads: Gamepad[];
  39565. /**
  39566. * Get the gamepad controllers based on type
  39567. * @param type The type of gamepad controller
  39568. * @returns Nullable gamepad
  39569. */
  39570. getGamepadByType(type?: number): Nullable<Gamepad>;
  39571. /**
  39572. * Disposes the gamepad manager
  39573. */
  39574. dispose(): void;
  39575. private _addNewGamepad;
  39576. private _startMonitoringGamepads;
  39577. private _stopMonitoringGamepads;
  39578. /** @hidden */
  39579. _checkGamepadsStatus(): void;
  39580. private _updateGamepadObjects;
  39581. }
  39582. }
  39583. declare module BABYLON {
  39584. interface Scene {
  39585. /** @hidden */
  39586. _gamepadManager: Nullable<GamepadManager>;
  39587. /**
  39588. * Gets the gamepad manager associated with the scene
  39589. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39590. */
  39591. gamepadManager: GamepadManager;
  39592. }
  39593. /**
  39594. * Interface representing a free camera inputs manager
  39595. */
  39596. interface FreeCameraInputsManager {
  39597. /**
  39598. * Adds gamepad input support to the FreeCameraInputsManager.
  39599. * @returns the FreeCameraInputsManager
  39600. */
  39601. addGamepad(): FreeCameraInputsManager;
  39602. }
  39603. /**
  39604. * Interface representing an arc rotate camera inputs manager
  39605. */
  39606. interface ArcRotateCameraInputsManager {
  39607. /**
  39608. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39609. * @returns the camera inputs manager
  39610. */
  39611. addGamepad(): ArcRotateCameraInputsManager;
  39612. }
  39613. /**
  39614. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39615. */
  39616. export class GamepadSystemSceneComponent implements ISceneComponent {
  39617. /**
  39618. * The component name helpfull to identify the component in the list of scene components.
  39619. */
  39620. readonly name: string;
  39621. /**
  39622. * The scene the component belongs to.
  39623. */
  39624. scene: Scene;
  39625. /**
  39626. * Creates a new instance of the component for the given scene
  39627. * @param scene Defines the scene to register the component in
  39628. */
  39629. constructor(scene: Scene);
  39630. /**
  39631. * Registers the component in a given scene
  39632. */
  39633. register(): void;
  39634. /**
  39635. * Rebuilds the elements related to this component in case of
  39636. * context lost for instance.
  39637. */
  39638. rebuild(): void;
  39639. /**
  39640. * Disposes the component and the associated ressources
  39641. */
  39642. dispose(): void;
  39643. private _beforeCameraUpdate;
  39644. }
  39645. }
  39646. declare module BABYLON {
  39647. /**
  39648. * Options to modify the vr teleportation behavior.
  39649. */
  39650. export interface VRTeleportationOptions {
  39651. /**
  39652. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39653. */
  39654. floorMeshName?: string;
  39655. /**
  39656. * A list of meshes to be used as the teleportation floor. (default: empty)
  39657. */
  39658. floorMeshes?: Mesh[];
  39659. }
  39660. /**
  39661. * Options to modify the vr experience helper's behavior.
  39662. */
  39663. export interface VRExperienceHelperOptions extends WebVROptions {
  39664. /**
  39665. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39666. */
  39667. createDeviceOrientationCamera?: boolean;
  39668. /**
  39669. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39670. */
  39671. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39672. /**
  39673. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39674. */
  39675. laserToggle?: boolean;
  39676. /**
  39677. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39678. */
  39679. floorMeshes?: Mesh[];
  39680. /**
  39681. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39682. */
  39683. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39684. }
  39685. /**
  39686. * Event containing information after VR has been entered
  39687. */
  39688. export class OnAfterEnteringVRObservableEvent {
  39689. /**
  39690. * If entering vr was successful
  39691. */
  39692. success: boolean;
  39693. }
  39694. /**
  39695. * Helps to quickly add VR support to an existing scene.
  39696. * See http://doc.babylonjs.com/how_to/webvr_helper
  39697. */
  39698. export class VRExperienceHelper {
  39699. /** Options to modify the vr experience helper's behavior. */
  39700. webVROptions: VRExperienceHelperOptions;
  39701. private _scene;
  39702. private _position;
  39703. private _btnVR;
  39704. private _btnVRDisplayed;
  39705. private _webVRsupported;
  39706. private _webVRready;
  39707. private _webVRrequesting;
  39708. private _webVRpresenting;
  39709. private _hasEnteredVR;
  39710. private _fullscreenVRpresenting;
  39711. private _canvas;
  39712. private _webVRCamera;
  39713. private _vrDeviceOrientationCamera;
  39714. private _deviceOrientationCamera;
  39715. private _existingCamera;
  39716. private _onKeyDown;
  39717. private _onVrDisplayPresentChange;
  39718. private _onVRDisplayChanged;
  39719. private _onVRRequestPresentStart;
  39720. private _onVRRequestPresentComplete;
  39721. /**
  39722. * Observable raised right before entering VR.
  39723. */
  39724. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39725. /**
  39726. * Observable raised when entering VR has completed.
  39727. */
  39728. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39729. /**
  39730. * Observable raised when exiting VR.
  39731. */
  39732. onExitingVRObservable: Observable<VRExperienceHelper>;
  39733. /**
  39734. * Observable raised when controller mesh is loaded.
  39735. */
  39736. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39737. /** Return this.onEnteringVRObservable
  39738. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39739. */
  39740. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39741. /** Return this.onExitingVRObservable
  39742. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39743. */
  39744. readonly onExitingVR: Observable<VRExperienceHelper>;
  39745. /** Return this.onControllerMeshLoadedObservable
  39746. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39747. */
  39748. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39749. private _rayLength;
  39750. private _useCustomVRButton;
  39751. private _teleportationRequested;
  39752. private _teleportActive;
  39753. private _floorMeshName;
  39754. private _floorMeshesCollection;
  39755. private _rotationAllowed;
  39756. private _teleportBackwardsVector;
  39757. private _teleportationTarget;
  39758. private _isDefaultTeleportationTarget;
  39759. private _postProcessMove;
  39760. private _teleportationFillColor;
  39761. private _teleportationBorderColor;
  39762. private _rotationAngle;
  39763. private _haloCenter;
  39764. private _cameraGazer;
  39765. private _padSensibilityUp;
  39766. private _padSensibilityDown;
  39767. private _leftController;
  39768. private _rightController;
  39769. /**
  39770. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39771. */
  39772. onNewMeshSelected: Observable<AbstractMesh>;
  39773. /**
  39774. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39775. */
  39776. onNewMeshPicked: Observable<PickingInfo>;
  39777. private _circleEase;
  39778. /**
  39779. * Observable raised before camera teleportation
  39780. */
  39781. onBeforeCameraTeleport: Observable<Vector3>;
  39782. /**
  39783. * Observable raised after camera teleportation
  39784. */
  39785. onAfterCameraTeleport: Observable<Vector3>;
  39786. /**
  39787. * Observable raised when current selected mesh gets unselected
  39788. */
  39789. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39790. private _raySelectionPredicate;
  39791. /**
  39792. * To be optionaly changed by user to define custom ray selection
  39793. */
  39794. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39795. /**
  39796. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39797. */
  39798. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39799. /**
  39800. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39801. */
  39802. teleportationEnabled: boolean;
  39803. private _defaultHeight;
  39804. private _teleportationInitialized;
  39805. private _interactionsEnabled;
  39806. private _interactionsRequested;
  39807. private _displayGaze;
  39808. private _displayLaserPointer;
  39809. /**
  39810. * The mesh used to display where the user is going to teleport.
  39811. */
  39812. /**
  39813. * Sets the mesh to be used to display where the user is going to teleport.
  39814. */
  39815. teleportationTarget: Mesh;
  39816. /**
  39817. * 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
  39818. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39819. * See http://doc.babylonjs.com/resources/baking_transformations
  39820. */
  39821. gazeTrackerMesh: Mesh;
  39822. /**
  39823. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39824. */
  39825. updateGazeTrackerScale: boolean;
  39826. /**
  39827. * If the gaze trackers color should be updated when selecting meshes
  39828. */
  39829. updateGazeTrackerColor: boolean;
  39830. /**
  39831. * The gaze tracking mesh corresponding to the left controller
  39832. */
  39833. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39834. /**
  39835. * The gaze tracking mesh corresponding to the right controller
  39836. */
  39837. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39838. /**
  39839. * If the ray of the gaze should be displayed.
  39840. */
  39841. /**
  39842. * Sets if the ray of the gaze should be displayed.
  39843. */
  39844. displayGaze: boolean;
  39845. /**
  39846. * If the ray of the LaserPointer should be displayed.
  39847. */
  39848. /**
  39849. * Sets if the ray of the LaserPointer should be displayed.
  39850. */
  39851. displayLaserPointer: boolean;
  39852. /**
  39853. * The deviceOrientationCamera used as the camera when not in VR.
  39854. */
  39855. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39856. /**
  39857. * Based on the current WebVR support, returns the current VR camera used.
  39858. */
  39859. readonly currentVRCamera: Nullable<Camera>;
  39860. /**
  39861. * The webVRCamera which is used when in VR.
  39862. */
  39863. readonly webVRCamera: WebVRFreeCamera;
  39864. /**
  39865. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39866. */
  39867. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39868. private readonly _teleportationRequestInitiated;
  39869. /**
  39870. * Defines wether or not Pointer lock should be requested when switching to
  39871. * full screen.
  39872. */
  39873. requestPointerLockOnFullScreen: boolean;
  39874. /**
  39875. * Instantiates a VRExperienceHelper.
  39876. * Helps to quickly add VR support to an existing scene.
  39877. * @param scene The scene the VRExperienceHelper belongs to.
  39878. * @param webVROptions Options to modify the vr experience helper's behavior.
  39879. */
  39880. constructor(scene: Scene,
  39881. /** Options to modify the vr experience helper's behavior. */
  39882. webVROptions?: VRExperienceHelperOptions);
  39883. private _onDefaultMeshLoaded;
  39884. private _onResize;
  39885. private _onFullscreenChange;
  39886. /**
  39887. * Gets a value indicating if we are currently in VR mode.
  39888. */
  39889. readonly isInVRMode: boolean;
  39890. private onVrDisplayPresentChange;
  39891. private onVRDisplayChanged;
  39892. private moveButtonToBottomRight;
  39893. private displayVRButton;
  39894. private updateButtonVisibility;
  39895. private _cachedAngularSensibility;
  39896. /**
  39897. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39898. * Otherwise, will use the fullscreen API.
  39899. */
  39900. enterVR(): void;
  39901. /**
  39902. * Attempt to exit VR, or fullscreen.
  39903. */
  39904. exitVR(): void;
  39905. /**
  39906. * The position of the vr experience helper.
  39907. */
  39908. /**
  39909. * Sets the position of the vr experience helper.
  39910. */
  39911. position: Vector3;
  39912. /**
  39913. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39914. */
  39915. enableInteractions(): void;
  39916. private readonly _noControllerIsActive;
  39917. private beforeRender;
  39918. private _isTeleportationFloor;
  39919. /**
  39920. * Adds a floor mesh to be used for teleportation.
  39921. * @param floorMesh the mesh to be used for teleportation.
  39922. */
  39923. addFloorMesh(floorMesh: Mesh): void;
  39924. /**
  39925. * Removes a floor mesh from being used for teleportation.
  39926. * @param floorMesh the mesh to be removed.
  39927. */
  39928. removeFloorMesh(floorMesh: Mesh): void;
  39929. /**
  39930. * Enables interactions and teleportation using the VR controllers and gaze.
  39931. * @param vrTeleportationOptions options to modify teleportation behavior.
  39932. */
  39933. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39934. private _onNewGamepadConnected;
  39935. private _tryEnableInteractionOnController;
  39936. private _onNewGamepadDisconnected;
  39937. private _enableInteractionOnController;
  39938. private _checkTeleportWithRay;
  39939. private _checkRotate;
  39940. private _checkTeleportBackwards;
  39941. private _enableTeleportationOnController;
  39942. private _createTeleportationCircles;
  39943. private _displayTeleportationTarget;
  39944. private _hideTeleportationTarget;
  39945. private _rotateCamera;
  39946. private _moveTeleportationSelectorTo;
  39947. private _workingVector;
  39948. private _workingQuaternion;
  39949. private _workingMatrix;
  39950. /**
  39951. * Teleports the users feet to the desired location
  39952. * @param location The location where the user's feet should be placed
  39953. */
  39954. teleportCamera(location: Vector3): void;
  39955. private _convertNormalToDirectionOfRay;
  39956. private _castRayAndSelectObject;
  39957. private _notifySelectedMeshUnselected;
  39958. /**
  39959. * Sets the color of the laser ray from the vr controllers.
  39960. * @param color new color for the ray.
  39961. */
  39962. changeLaserColor(color: Color3): void;
  39963. /**
  39964. * Sets the color of the ray from the vr headsets gaze.
  39965. * @param color new color for the ray.
  39966. */
  39967. changeGazeColor(color: Color3): void;
  39968. /**
  39969. * Exits VR and disposes of the vr experience helper
  39970. */
  39971. dispose(): void;
  39972. /**
  39973. * Gets the name of the VRExperienceHelper class
  39974. * @returns "VRExperienceHelper"
  39975. */
  39976. getClassName(): string;
  39977. }
  39978. }
  39979. declare module BABYLON {
  39980. /**
  39981. * Manages an XRSession
  39982. * @see https://doc.babylonjs.com/how_to/webxr
  39983. */
  39984. export class WebXRSessionManager implements IDisposable {
  39985. private scene;
  39986. /**
  39987. * Fires every time a new xrFrame arrives which can be used to update the camera
  39988. */
  39989. onXRFrameObservable: Observable<any>;
  39990. /**
  39991. * Fires when the xr session is ended either by the device or manually done
  39992. */
  39993. onXRSessionEnded: Observable<any>;
  39994. /** @hidden */
  39995. _xrSession: XRSession;
  39996. /** @hidden */
  39997. _frameOfReference: XRFrameOfReference;
  39998. /** @hidden */
  39999. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40000. /** @hidden */
  40001. _currentXRFrame: Nullable<XRFrame>;
  40002. private _xrNavigator;
  40003. private _xrDevice;
  40004. private _tmpMatrix;
  40005. /**
  40006. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40007. * @param scene The scene which the session should be created for
  40008. */
  40009. constructor(scene: Scene);
  40010. /**
  40011. * Initializes the manager
  40012. * After initialization enterXR can be called to start an XR session
  40013. * @returns Promise which resolves after it is initialized
  40014. */
  40015. initializeAsync(): Promise<void>;
  40016. /**
  40017. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40018. * @param sessionCreationOptions xr options to create the session with
  40019. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40020. * @returns Promise which resolves after it enters XR
  40021. */
  40022. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40023. /**
  40024. * Stops the xrSession and restores the renderloop
  40025. * @returns Promise which resolves after it exits XR
  40026. */
  40027. exitXRAsync(): Promise<void>;
  40028. /**
  40029. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40030. * @param ray ray to cast into the environment
  40031. * @returns Promise which resolves with a collision point in the environment if it exists
  40032. */
  40033. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40034. /**
  40035. * Checks if a session would be supported for the creation options specified
  40036. * @param options creation options to check if they are supported
  40037. * @returns true if supported
  40038. */
  40039. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40040. /**
  40041. * @hidden
  40042. * Converts the render layer of xrSession to a render target
  40043. * @param session session to create render target for
  40044. * @param scene scene the new render target should be created for
  40045. */
  40046. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40047. /**
  40048. * Disposes of the session manager
  40049. */
  40050. dispose(): void;
  40051. }
  40052. }
  40053. declare module BABYLON {
  40054. /**
  40055. * WebXR Camera which holds the views for the xrSession
  40056. * @see https://doc.babylonjs.com/how_to/webxr
  40057. */
  40058. export class WebXRCamera extends FreeCamera {
  40059. private static _TmpMatrix;
  40060. /**
  40061. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40062. * @param name the name of the camera
  40063. * @param scene the scene to add the camera to
  40064. */
  40065. constructor(name: string, scene: Scene);
  40066. private _updateNumberOfRigCameras;
  40067. /** @hidden */
  40068. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40069. /**
  40070. * Updates the cameras position from the current pose information of the XR session
  40071. * @param xrSessionManager the session containing pose information
  40072. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40073. */
  40074. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40075. }
  40076. }
  40077. declare module BABYLON {
  40078. /**
  40079. * States of the webXR experience
  40080. */
  40081. export enum WebXRState {
  40082. /**
  40083. * Transitioning to being in XR mode
  40084. */
  40085. ENTERING_XR = 0,
  40086. /**
  40087. * Transitioning to non XR mode
  40088. */
  40089. EXITING_XR = 1,
  40090. /**
  40091. * In XR mode and presenting
  40092. */
  40093. IN_XR = 2,
  40094. /**
  40095. * Not entered XR mode
  40096. */
  40097. NOT_IN_XR = 3
  40098. }
  40099. /**
  40100. * Helper class used to enable XR
  40101. * @see https://doc.babylonjs.com/how_to/webxr
  40102. */
  40103. export class WebXRExperienceHelper implements IDisposable {
  40104. private scene;
  40105. /**
  40106. * 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
  40107. */
  40108. container: AbstractMesh;
  40109. /**
  40110. * Camera used to render xr content
  40111. */
  40112. camera: WebXRCamera;
  40113. /**
  40114. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40115. */
  40116. state: WebXRState;
  40117. private _setState;
  40118. private static _TmpVector;
  40119. /**
  40120. * Fires when the state of the experience helper has changed
  40121. */
  40122. onStateChangedObservable: Observable<WebXRState>;
  40123. /** @hidden */
  40124. _sessionManager: WebXRSessionManager;
  40125. private _nonVRCamera;
  40126. private _originalSceneAutoClear;
  40127. private _supported;
  40128. /**
  40129. * Creates the experience helper
  40130. * @param scene the scene to attach the experience helper to
  40131. * @returns a promise for the experience helper
  40132. */
  40133. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40134. /**
  40135. * Creates a WebXRExperienceHelper
  40136. * @param scene The scene the helper should be created in
  40137. */
  40138. private constructor();
  40139. /**
  40140. * Exits XR mode and returns the scene to its original state
  40141. * @returns promise that resolves after xr mode has exited
  40142. */
  40143. exitXRAsync(): Promise<void>;
  40144. /**
  40145. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40146. * @param sessionCreationOptions options for the XR session
  40147. * @param frameOfReference frame of reference of the XR session
  40148. * @returns promise that resolves after xr mode has entered
  40149. */
  40150. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40151. /**
  40152. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40153. * @param ray ray to cast into the environment
  40154. * @returns Promise which resolves with a collision point in the environment if it exists
  40155. */
  40156. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40157. /**
  40158. * Updates the global position of the camera by moving the camera's container
  40159. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40160. * @param position The desired global position of the camera
  40161. */
  40162. setPositionOfCameraUsingContainer(position: Vector3): void;
  40163. /**
  40164. * Rotates the xr camera by rotating the camera's container around the camera's position
  40165. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40166. * @param rotation the desired quaternion rotation to apply to the camera
  40167. */
  40168. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40169. /**
  40170. * Checks if the creation options are supported by the xr session
  40171. * @param options creation options
  40172. * @returns true if supported
  40173. */
  40174. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40175. /**
  40176. * Disposes of the experience helper
  40177. */
  40178. dispose(): void;
  40179. }
  40180. }
  40181. declare module BABYLON {
  40182. /**
  40183. * Button which can be used to enter a different mode of XR
  40184. */
  40185. export class WebXREnterExitUIButton {
  40186. /** button element */
  40187. element: HTMLElement;
  40188. /** XR initialization options for the button */
  40189. initializationOptions: XRSessionCreationOptions;
  40190. /**
  40191. * Creates a WebXREnterExitUIButton
  40192. * @param element button element
  40193. * @param initializationOptions XR initialization options for the button
  40194. */
  40195. constructor(
  40196. /** button element */
  40197. element: HTMLElement,
  40198. /** XR initialization options for the button */
  40199. initializationOptions: XRSessionCreationOptions);
  40200. /**
  40201. * Overwritable function which can be used to update the button's visuals when the state changes
  40202. * @param activeButton the current active button in the UI
  40203. */
  40204. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40205. }
  40206. /**
  40207. * Options to create the webXR UI
  40208. */
  40209. export class WebXREnterExitUIOptions {
  40210. /**
  40211. * Context to enter xr with
  40212. */
  40213. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40214. /**
  40215. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40216. */
  40217. customButtons?: Array<WebXREnterExitUIButton>;
  40218. }
  40219. /**
  40220. * UI to allow the user to enter/exit XR mode
  40221. */
  40222. export class WebXREnterExitUI implements IDisposable {
  40223. private scene;
  40224. private _overlay;
  40225. private _buttons;
  40226. private _activeButton;
  40227. /**
  40228. * Fired every time the active button is changed.
  40229. *
  40230. * When xr is entered via a button that launches xr that button will be the callback parameter
  40231. *
  40232. * When exiting xr the callback parameter will be null)
  40233. */
  40234. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40235. /**
  40236. * Creates UI to allow the user to enter/exit XR mode
  40237. * @param scene the scene to add the ui to
  40238. * @param helper the xr experience helper to enter/exit xr with
  40239. * @param options options to configure the UI
  40240. * @returns the created ui
  40241. */
  40242. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40243. private constructor();
  40244. private _updateButtons;
  40245. /**
  40246. * Disposes of the object
  40247. */
  40248. dispose(): void;
  40249. }
  40250. }
  40251. declare module BABYLON {
  40252. /**
  40253. * Represents an XR input
  40254. */
  40255. export class WebXRController {
  40256. /**
  40257. * 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
  40258. */
  40259. grip?: AbstractMesh;
  40260. /**
  40261. * Pointer which can be used to select objects or attach a visible laser to
  40262. */
  40263. pointer: AbstractMesh;
  40264. /**
  40265. * Creates the controller
  40266. * @see https://doc.babylonjs.com/how_to/webxr
  40267. * @param scene the scene which the controller should be associated to
  40268. */
  40269. constructor(scene: Scene);
  40270. /**
  40271. * Disposes of the object
  40272. */
  40273. dispose(): void;
  40274. }
  40275. /**
  40276. * XR input used to track XR inputs such as controllers/rays
  40277. */
  40278. export class WebXRInput implements IDisposable {
  40279. private helper;
  40280. /**
  40281. * XR controllers being tracked
  40282. */
  40283. controllers: Array<WebXRController>;
  40284. private _tmpMatrix;
  40285. private _frameObserver;
  40286. /**
  40287. * Initializes the WebXRInput
  40288. * @param helper experience helper which the input should be created for
  40289. */
  40290. constructor(helper: WebXRExperienceHelper);
  40291. /**
  40292. * Disposes of the object
  40293. */
  40294. dispose(): void;
  40295. }
  40296. }
  40297. declare module BABYLON {
  40298. /**
  40299. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40300. */
  40301. export class WebXRManagedOutputCanvas implements IDisposable {
  40302. private _canvas;
  40303. /**
  40304. * xrpresent context of the canvas which can be used to display/mirror xr content
  40305. */
  40306. canvasContext: Nullable<WebGLRenderingContext>;
  40307. /**
  40308. * Initializes the canvas to be added/removed upon entering/exiting xr
  40309. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40310. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40311. */
  40312. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40313. /**
  40314. * Disposes of the object
  40315. */
  40316. dispose(): void;
  40317. private _setManagedOutputCanvas;
  40318. private _addCanvas;
  40319. private _removeCanvas;
  40320. }
  40321. }
  40322. declare module BABYLON {
  40323. /**
  40324. * Contains an array of blocks representing the octree
  40325. */
  40326. export interface IOctreeContainer<T> {
  40327. /**
  40328. * Blocks within the octree
  40329. */
  40330. blocks: Array<OctreeBlock<T>>;
  40331. }
  40332. /**
  40333. * Class used to store a cell in an octree
  40334. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40335. */
  40336. export class OctreeBlock<T> {
  40337. /**
  40338. * Gets the content of the current block
  40339. */
  40340. entries: T[];
  40341. /**
  40342. * Gets the list of block children
  40343. */
  40344. blocks: Array<OctreeBlock<T>>;
  40345. private _depth;
  40346. private _maxDepth;
  40347. private _capacity;
  40348. private _minPoint;
  40349. private _maxPoint;
  40350. private _boundingVectors;
  40351. private _creationFunc;
  40352. /**
  40353. * Creates a new block
  40354. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40355. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40356. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40357. * @param depth defines the current depth of this block in the octree
  40358. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40359. * @param creationFunc defines a callback to call when an element is added to the block
  40360. */
  40361. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40362. /**
  40363. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40364. */
  40365. readonly capacity: number;
  40366. /**
  40367. * Gets the minimum vector (in world space) of the block's bounding box
  40368. */
  40369. readonly minPoint: Vector3;
  40370. /**
  40371. * Gets the maximum vector (in world space) of the block's bounding box
  40372. */
  40373. readonly maxPoint: Vector3;
  40374. /**
  40375. * Add a new element to this block
  40376. * @param entry defines the element to add
  40377. */
  40378. addEntry(entry: T): void;
  40379. /**
  40380. * Remove an element from this block
  40381. * @param entry defines the element to remove
  40382. */
  40383. removeEntry(entry: T): void;
  40384. /**
  40385. * Add an array of elements to this block
  40386. * @param entries defines the array of elements to add
  40387. */
  40388. addEntries(entries: T[]): void;
  40389. /**
  40390. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40391. * @param frustumPlanes defines the frustum planes to test
  40392. * @param selection defines the array to store current content if selection is positive
  40393. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40394. */
  40395. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40396. /**
  40397. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40398. * @param sphereCenter defines the bounding sphere center
  40399. * @param sphereRadius defines the bounding sphere radius
  40400. * @param selection defines the array to store current content if selection is positive
  40401. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40402. */
  40403. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40404. /**
  40405. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40406. * @param ray defines the ray to test with
  40407. * @param selection defines the array to store current content if selection is positive
  40408. */
  40409. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40410. /**
  40411. * Subdivide the content into child blocks (this block will then be empty)
  40412. */
  40413. createInnerBlocks(): void;
  40414. /**
  40415. * @hidden
  40416. */
  40417. 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;
  40418. }
  40419. }
  40420. declare module BABYLON {
  40421. /**
  40422. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40423. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40424. */
  40425. export class Octree<T> {
  40426. /** 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.) */
  40427. maxDepth: number;
  40428. /**
  40429. * Blocks within the octree containing objects
  40430. */
  40431. blocks: Array<OctreeBlock<T>>;
  40432. /**
  40433. * Content stored in the octree
  40434. */
  40435. dynamicContent: T[];
  40436. private _maxBlockCapacity;
  40437. private _selectionContent;
  40438. private _creationFunc;
  40439. /**
  40440. * Creates a octree
  40441. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40442. * @param creationFunc function to be used to instatiate the octree
  40443. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40444. * @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.)
  40445. */
  40446. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40447. /** 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.) */
  40448. maxDepth?: number);
  40449. /**
  40450. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40451. * @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);
  40452. * @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);
  40453. * @param entries meshes to be added to the octree blocks
  40454. */
  40455. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40456. /**
  40457. * Adds a mesh to the octree
  40458. * @param entry Mesh to add to the octree
  40459. */
  40460. addMesh(entry: T): void;
  40461. /**
  40462. * Remove an element from the octree
  40463. * @param entry defines the element to remove
  40464. */
  40465. removeMesh(entry: T): void;
  40466. /**
  40467. * Selects an array of meshes within the frustum
  40468. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40469. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40470. * @returns array of meshes within the frustum
  40471. */
  40472. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40473. /**
  40474. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40475. * @param sphereCenter defines the bounding sphere center
  40476. * @param sphereRadius defines the bounding sphere radius
  40477. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40478. * @returns an array of objects that intersect the sphere
  40479. */
  40480. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40481. /**
  40482. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40483. * @param ray defines the ray to test with
  40484. * @returns array of intersected objects
  40485. */
  40486. intersectsRay(ray: Ray): SmartArray<T>;
  40487. /**
  40488. * Adds a mesh into the octree block if it intersects the block
  40489. */
  40490. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40491. /**
  40492. * Adds a submesh into the octree block if it intersects the block
  40493. */
  40494. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40495. }
  40496. }
  40497. declare module BABYLON {
  40498. interface Scene {
  40499. /**
  40500. * @hidden
  40501. * Backing Filed
  40502. */
  40503. _selectionOctree: Octree<AbstractMesh>;
  40504. /**
  40505. * Gets the octree used to boost mesh selection (picking)
  40506. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40507. */
  40508. selectionOctree: Octree<AbstractMesh>;
  40509. /**
  40510. * Creates or updates the octree used to boost selection (picking)
  40511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40512. * @param maxCapacity defines the maximum capacity per leaf
  40513. * @param maxDepth defines the maximum depth of the octree
  40514. * @returns an octree of AbstractMesh
  40515. */
  40516. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40517. }
  40518. interface AbstractMesh {
  40519. /**
  40520. * @hidden
  40521. * Backing Field
  40522. */
  40523. _submeshesOctree: Octree<SubMesh>;
  40524. /**
  40525. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40526. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40527. * @param maxCapacity defines the maximum size of each block (64 by default)
  40528. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40529. * @returns the new octree
  40530. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40532. */
  40533. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40534. }
  40535. /**
  40536. * Defines the octree scene component responsible to manage any octrees
  40537. * in a given scene.
  40538. */
  40539. export class OctreeSceneComponent {
  40540. /**
  40541. * The component name help to identify the component in the list of scene components.
  40542. */
  40543. readonly name: string;
  40544. /**
  40545. * The scene the component belongs to.
  40546. */
  40547. scene: Scene;
  40548. /**
  40549. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40550. */
  40551. readonly checksIsEnabled: boolean;
  40552. /**
  40553. * Creates a new instance of the component for the given scene
  40554. * @param scene Defines the scene to register the component in
  40555. */
  40556. constructor(scene: Scene);
  40557. /**
  40558. * Registers the component in a given scene
  40559. */
  40560. register(): void;
  40561. /**
  40562. * Return the list of active meshes
  40563. * @returns the list of active meshes
  40564. */
  40565. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40566. /**
  40567. * Return the list of active sub meshes
  40568. * @param mesh The mesh to get the candidates sub meshes from
  40569. * @returns the list of active sub meshes
  40570. */
  40571. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40572. private _tempRay;
  40573. /**
  40574. * Return the list of sub meshes intersecting with a given local ray
  40575. * @param mesh defines the mesh to find the submesh for
  40576. * @param localRay defines the ray in local space
  40577. * @returns the list of intersecting sub meshes
  40578. */
  40579. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40580. /**
  40581. * Return the list of sub meshes colliding with a collider
  40582. * @param mesh defines the mesh to find the submesh for
  40583. * @param collider defines the collider to evaluate the collision against
  40584. * @returns the list of colliding sub meshes
  40585. */
  40586. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40587. /**
  40588. * Rebuilds the elements related to this component in case of
  40589. * context lost for instance.
  40590. */
  40591. rebuild(): void;
  40592. /**
  40593. * Disposes the component and the associated ressources.
  40594. */
  40595. dispose(): void;
  40596. }
  40597. }
  40598. declare module BABYLON {
  40599. /**
  40600. * Renders a layer on top of an existing scene
  40601. */
  40602. export class UtilityLayerRenderer implements IDisposable {
  40603. /** the original scene that will be rendered on top of */
  40604. originalScene: Scene;
  40605. private _pointerCaptures;
  40606. private _lastPointerEvents;
  40607. private static _DefaultUtilityLayer;
  40608. private static _DefaultKeepDepthUtilityLayer;
  40609. private _sharedGizmoLight;
  40610. /**
  40611. * @hidden
  40612. * Light which used by gizmos to get light shading
  40613. */
  40614. _getSharedGizmoLight(): HemisphericLight;
  40615. /**
  40616. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40617. */
  40618. pickUtilitySceneFirst: boolean;
  40619. /**
  40620. * 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)
  40621. */
  40622. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40623. /**
  40624. * 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)
  40625. */
  40626. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40627. /**
  40628. * The scene that is rendered on top of the original scene
  40629. */
  40630. utilityLayerScene: Scene;
  40631. /**
  40632. * If the utility layer should automatically be rendered on top of existing scene
  40633. */
  40634. shouldRender: boolean;
  40635. /**
  40636. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40637. */
  40638. onlyCheckPointerDownEvents: boolean;
  40639. /**
  40640. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40641. */
  40642. processAllEvents: boolean;
  40643. /**
  40644. * Observable raised when the pointer move from the utility layer scene to the main scene
  40645. */
  40646. onPointerOutObservable: Observable<number>;
  40647. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40648. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40649. private _afterRenderObserver;
  40650. private _sceneDisposeObserver;
  40651. private _originalPointerObserver;
  40652. /**
  40653. * Instantiates a UtilityLayerRenderer
  40654. * @param originalScene the original scene that will be rendered on top of
  40655. * @param handleEvents boolean indicating if the utility layer should handle events
  40656. */
  40657. constructor(
  40658. /** the original scene that will be rendered on top of */
  40659. originalScene: Scene, handleEvents?: boolean);
  40660. private _notifyObservers;
  40661. /**
  40662. * Renders the utility layers scene on top of the original scene
  40663. */
  40664. render(): void;
  40665. /**
  40666. * Disposes of the renderer
  40667. */
  40668. dispose(): void;
  40669. private _updateCamera;
  40670. }
  40671. }
  40672. declare module BABYLON {
  40673. /**
  40674. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40675. */
  40676. export class Gizmo implements IDisposable {
  40677. /** The utility layer the gizmo will be added to */
  40678. gizmoLayer: UtilityLayerRenderer;
  40679. /**
  40680. * The root mesh of the gizmo
  40681. */
  40682. _rootMesh: Mesh;
  40683. private _attachedMesh;
  40684. /**
  40685. * Ratio for the scale of the gizmo (Default: 1)
  40686. */
  40687. scaleRatio: number;
  40688. /**
  40689. * If a custom mesh has been set (Default: false)
  40690. */
  40691. protected _customMeshSet: boolean;
  40692. /**
  40693. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40694. * * When set, interactions will be enabled
  40695. */
  40696. attachedMesh: Nullable<AbstractMesh>;
  40697. /**
  40698. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40699. * @param mesh The mesh to replace the default mesh of the gizmo
  40700. */
  40701. setCustomMesh(mesh: Mesh): void;
  40702. /**
  40703. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40704. */
  40705. updateGizmoRotationToMatchAttachedMesh: boolean;
  40706. /**
  40707. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40708. */
  40709. updateGizmoPositionToMatchAttachedMesh: boolean;
  40710. /**
  40711. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40712. */
  40713. protected _updateScale: boolean;
  40714. protected _interactionsEnabled: boolean;
  40715. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40716. private _beforeRenderObserver;
  40717. private _tempVector;
  40718. /**
  40719. * Creates a gizmo
  40720. * @param gizmoLayer The utility layer the gizmo will be added to
  40721. */
  40722. constructor(
  40723. /** The utility layer the gizmo will be added to */
  40724. gizmoLayer?: UtilityLayerRenderer);
  40725. /**
  40726. * Updates the gizmo to match the attached mesh's position/rotation
  40727. */
  40728. protected _update(): void;
  40729. /**
  40730. * Disposes of the gizmo
  40731. */
  40732. dispose(): void;
  40733. }
  40734. }
  40735. declare module BABYLON {
  40736. /**
  40737. * Single axis drag gizmo
  40738. */
  40739. export class AxisDragGizmo extends Gizmo {
  40740. /**
  40741. * Drag behavior responsible for the gizmos dragging interactions
  40742. */
  40743. dragBehavior: PointerDragBehavior;
  40744. private _pointerObserver;
  40745. /**
  40746. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40747. */
  40748. snapDistance: number;
  40749. /**
  40750. * Event that fires each time the gizmo snaps to a new location.
  40751. * * snapDistance is the the change in distance
  40752. */
  40753. onSnapObservable: Observable<{
  40754. snapDistance: number;
  40755. }>;
  40756. /** @hidden */
  40757. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40758. /** @hidden */
  40759. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40760. /**
  40761. * Creates an AxisDragGizmo
  40762. * @param gizmoLayer The utility layer the gizmo will be added to
  40763. * @param dragAxis The axis which the gizmo will be able to drag on
  40764. * @param color The color of the gizmo
  40765. */
  40766. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40767. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40768. /**
  40769. * Disposes of the gizmo
  40770. */
  40771. dispose(): void;
  40772. }
  40773. }
  40774. declare module BABYLON.Debug {
  40775. /**
  40776. * The Axes viewer will show 3 axes in a specific point in space
  40777. */
  40778. export class AxesViewer {
  40779. private _xAxis;
  40780. private _yAxis;
  40781. private _zAxis;
  40782. private _scaleLinesFactor;
  40783. private _instanced;
  40784. /**
  40785. * Gets the hosting scene
  40786. */
  40787. scene: Scene;
  40788. /**
  40789. * Gets or sets a number used to scale line length
  40790. */
  40791. scaleLines: number;
  40792. /** Gets the node hierarchy used to render x-axis */
  40793. readonly xAxis: TransformNode;
  40794. /** Gets the node hierarchy used to render y-axis */
  40795. readonly yAxis: TransformNode;
  40796. /** Gets the node hierarchy used to render z-axis */
  40797. readonly zAxis: TransformNode;
  40798. /**
  40799. * Creates a new AxesViewer
  40800. * @param scene defines the hosting scene
  40801. * @param scaleLines defines a number used to scale line length (1 by default)
  40802. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40803. * @param xAxis defines the node hierarchy used to render the x-axis
  40804. * @param yAxis defines the node hierarchy used to render the y-axis
  40805. * @param zAxis defines the node hierarchy used to render the z-axis
  40806. */
  40807. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40808. /**
  40809. * Force the viewer to update
  40810. * @param position defines the position of the viewer
  40811. * @param xaxis defines the x axis of the viewer
  40812. * @param yaxis defines the y axis of the viewer
  40813. * @param zaxis defines the z axis of the viewer
  40814. */
  40815. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40816. /**
  40817. * Creates an instance of this axes viewer.
  40818. * @returns a new axes viewer with instanced meshes
  40819. */
  40820. createInstance(): AxesViewer;
  40821. /** Releases resources */
  40822. dispose(): void;
  40823. private static _SetRenderingGroupId;
  40824. }
  40825. }
  40826. declare module BABYLON.Debug {
  40827. /**
  40828. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40829. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40830. */
  40831. export class BoneAxesViewer extends AxesViewer {
  40832. /**
  40833. * Gets or sets the target mesh where to display the axes viewer
  40834. */
  40835. mesh: Nullable<Mesh>;
  40836. /**
  40837. * Gets or sets the target bone where to display the axes viewer
  40838. */
  40839. bone: Nullable<Bone>;
  40840. /** Gets current position */
  40841. pos: Vector3;
  40842. /** Gets direction of X axis */
  40843. xaxis: Vector3;
  40844. /** Gets direction of Y axis */
  40845. yaxis: Vector3;
  40846. /** Gets direction of Z axis */
  40847. zaxis: Vector3;
  40848. /**
  40849. * Creates a new BoneAxesViewer
  40850. * @param scene defines the hosting scene
  40851. * @param bone defines the target bone
  40852. * @param mesh defines the target mesh
  40853. * @param scaleLines defines a scaling factor for line length (1 by default)
  40854. */
  40855. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40856. /**
  40857. * Force the viewer to update
  40858. */
  40859. update(): void;
  40860. /** Releases resources */
  40861. dispose(): void;
  40862. }
  40863. }
  40864. declare module BABYLON {
  40865. /**
  40866. * Interface used to define scene explorer extensibility option
  40867. */
  40868. export interface IExplorerExtensibilityOption {
  40869. /**
  40870. * Define the option label
  40871. */
  40872. label: string;
  40873. /**
  40874. * Defines the action to execute on click
  40875. */
  40876. action: (entity: any) => void;
  40877. }
  40878. /**
  40879. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40880. */
  40881. export interface IExplorerExtensibilityGroup {
  40882. /**
  40883. * Defines a predicate to test if a given type mut be extended
  40884. */
  40885. predicate: (entity: any) => boolean;
  40886. /**
  40887. * Gets the list of options added to a type
  40888. */
  40889. entries: IExplorerExtensibilityOption[];
  40890. }
  40891. /**
  40892. * Interface used to define the options to use to create the Inspector
  40893. */
  40894. export interface IInspectorOptions {
  40895. /**
  40896. * Display in overlay mode (default: false)
  40897. */
  40898. overlay?: boolean;
  40899. /**
  40900. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40901. */
  40902. globalRoot?: HTMLElement;
  40903. /**
  40904. * Display the Scene explorer
  40905. */
  40906. showExplorer?: boolean;
  40907. /**
  40908. * Display the property inspector
  40909. */
  40910. showInspector?: boolean;
  40911. /**
  40912. * Display in embed mode (both panes on the right)
  40913. */
  40914. embedMode?: boolean;
  40915. /**
  40916. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40917. */
  40918. handleResize?: boolean;
  40919. /**
  40920. * Allow the panes to popup (default: true)
  40921. */
  40922. enablePopup?: boolean;
  40923. /**
  40924. * Allow the panes to be closed by users (default: true)
  40925. */
  40926. enableClose?: boolean;
  40927. /**
  40928. * Optional list of extensibility entries
  40929. */
  40930. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40931. /**
  40932. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40933. */
  40934. inspectorURL?: string;
  40935. }
  40936. interface Scene {
  40937. /**
  40938. * @hidden
  40939. * Backing field
  40940. */
  40941. _debugLayer: DebugLayer;
  40942. /**
  40943. * Gets the debug layer (aka Inspector) associated with the scene
  40944. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40945. */
  40946. debugLayer: DebugLayer;
  40947. }
  40948. /**
  40949. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40950. * what is happening in your scene
  40951. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40952. */
  40953. export class DebugLayer {
  40954. /**
  40955. * Define the url to get the inspector script from.
  40956. * By default it uses the babylonjs CDN.
  40957. * @ignoreNaming
  40958. */
  40959. static InspectorURL: string;
  40960. private _scene;
  40961. private BJSINSPECTOR;
  40962. /**
  40963. * Observable triggered when a property is changed through the inspector.
  40964. */
  40965. onPropertyChangedObservable: Observable<{
  40966. object: any;
  40967. property: string;
  40968. value: any;
  40969. initialValue: any;
  40970. }>;
  40971. /**
  40972. * Instantiates a new debug layer.
  40973. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40974. * what is happening in your scene
  40975. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40976. * @param scene Defines the scene to inspect
  40977. */
  40978. constructor(scene: Scene);
  40979. /** Creates the inspector window. */
  40980. private _createInspector;
  40981. /**
  40982. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40983. * @param entity defines the entity to select
  40984. * @param lineContainerTitle defines the specific block to highlight
  40985. */
  40986. select(entity: any, lineContainerTitle?: string): void;
  40987. /** Get the inspector from bundle or global */
  40988. private _getGlobalInspector;
  40989. /**
  40990. * Get if the inspector is visible or not.
  40991. * @returns true if visible otherwise, false
  40992. */
  40993. isVisible(): boolean;
  40994. /**
  40995. * Hide the inspector and close its window.
  40996. */
  40997. hide(): void;
  40998. /**
  40999. * Launch the debugLayer.
  41000. * @param config Define the configuration of the inspector
  41001. * @return a promise fulfilled when the debug layer is visible
  41002. */
  41003. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41004. }
  41005. }
  41006. declare module BABYLON {
  41007. /**
  41008. * Class containing static functions to help procedurally build meshes
  41009. */
  41010. export class BoxBuilder {
  41011. /**
  41012. * Creates a box mesh
  41013. * * The parameter `size` sets the size (float) of each box side (default 1)
  41014. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41015. * * 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)
  41016. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41018. * * 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
  41019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41020. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41021. * @param name defines the name of the mesh
  41022. * @param options defines the options used to create the mesh
  41023. * @param scene defines the hosting scene
  41024. * @returns the box mesh
  41025. */
  41026. static CreateBox(name: string, options: {
  41027. size?: number;
  41028. width?: number;
  41029. height?: number;
  41030. depth?: number;
  41031. faceUV?: Vector4[];
  41032. faceColors?: Color4[];
  41033. sideOrientation?: number;
  41034. frontUVs?: Vector4;
  41035. backUVs?: Vector4;
  41036. wrap?: boolean;
  41037. topBaseAt?: number;
  41038. bottomBaseAt?: number;
  41039. updatable?: boolean;
  41040. }, scene?: Nullable<Scene>): Mesh;
  41041. }
  41042. }
  41043. declare module BABYLON {
  41044. /**
  41045. * Class containing static functions to help procedurally build meshes
  41046. */
  41047. export class SphereBuilder {
  41048. /**
  41049. * Creates a sphere mesh
  41050. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41051. * * 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`)
  41052. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41053. * * 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
  41054. * * 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)
  41055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41056. * * 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
  41057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41058. * @param name defines the name of the mesh
  41059. * @param options defines the options used to create the mesh
  41060. * @param scene defines the hosting scene
  41061. * @returns the sphere mesh
  41062. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41063. */
  41064. static CreateSphere(name: string, options: {
  41065. segments?: number;
  41066. diameter?: number;
  41067. diameterX?: number;
  41068. diameterY?: number;
  41069. diameterZ?: number;
  41070. arc?: number;
  41071. slice?: number;
  41072. sideOrientation?: number;
  41073. frontUVs?: Vector4;
  41074. backUVs?: Vector4;
  41075. updatable?: boolean;
  41076. }, scene: any): Mesh;
  41077. }
  41078. }
  41079. declare module BABYLON.Debug {
  41080. /**
  41081. * Used to show the physics impostor around the specific mesh
  41082. */
  41083. export class PhysicsViewer {
  41084. /** @hidden */
  41085. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41086. /** @hidden */
  41087. protected _meshes: Array<Nullable<AbstractMesh>>;
  41088. /** @hidden */
  41089. protected _scene: Nullable<Scene>;
  41090. /** @hidden */
  41091. protected _numMeshes: number;
  41092. /** @hidden */
  41093. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41094. private _renderFunction;
  41095. private _utilityLayer;
  41096. private _debugBoxMesh;
  41097. private _debugSphereMesh;
  41098. private _debugCylinderMesh;
  41099. private _debugMaterial;
  41100. private _debugMeshMeshes;
  41101. /**
  41102. * Creates a new PhysicsViewer
  41103. * @param scene defines the hosting scene
  41104. */
  41105. constructor(scene: Scene);
  41106. /** @hidden */
  41107. protected _updateDebugMeshes(): void;
  41108. /**
  41109. * Renders a specified physic impostor
  41110. * @param impostor defines the impostor to render
  41111. * @param targetMesh defines the mesh represented by the impostor
  41112. * @returns the new debug mesh used to render the impostor
  41113. */
  41114. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41115. /**
  41116. * Hides a specified physic impostor
  41117. * @param impostor defines the impostor to hide
  41118. */
  41119. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41120. private _getDebugMaterial;
  41121. private _getDebugBoxMesh;
  41122. private _getDebugSphereMesh;
  41123. private _getDebugCylinderMesh;
  41124. private _getDebugMeshMesh;
  41125. private _getDebugMesh;
  41126. /** Releases all resources */
  41127. dispose(): void;
  41128. }
  41129. }
  41130. declare module BABYLON {
  41131. /**
  41132. * Class containing static functions to help procedurally build meshes
  41133. */
  41134. export class LinesBuilder {
  41135. /**
  41136. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41137. * * 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
  41138. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41139. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41140. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41141. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41142. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41143. * * 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
  41144. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41146. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41147. * @param name defines the name of the new line system
  41148. * @param options defines the options used to create the line system
  41149. * @param scene defines the hosting scene
  41150. * @returns a new line system mesh
  41151. */
  41152. static CreateLineSystem(name: string, options: {
  41153. lines: Vector3[][];
  41154. updatable?: boolean;
  41155. instance?: Nullable<LinesMesh>;
  41156. colors?: Nullable<Color4[][]>;
  41157. useVertexAlpha?: boolean;
  41158. }, scene: Nullable<Scene>): LinesMesh;
  41159. /**
  41160. * Creates a line mesh
  41161. * 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
  41162. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41163. * * The parameter `points` is an array successive Vector3
  41164. * * 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
  41165. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41166. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41167. * * When updating an instance, remember that only point positions can change, not the number of points
  41168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41170. * @param name defines the name of the new line system
  41171. * @param options defines the options used to create the line system
  41172. * @param scene defines the hosting scene
  41173. * @returns a new line mesh
  41174. */
  41175. static CreateLines(name: string, options: {
  41176. points: Vector3[];
  41177. updatable?: boolean;
  41178. instance?: Nullable<LinesMesh>;
  41179. colors?: Color4[];
  41180. useVertexAlpha?: boolean;
  41181. }, scene?: Nullable<Scene>): LinesMesh;
  41182. /**
  41183. * Creates a dashed line mesh
  41184. * * 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
  41185. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41186. * * The parameter `points` is an array successive Vector3
  41187. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41188. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41189. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41190. * * 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
  41191. * * When updating an instance, remember that only point positions can change, not the number of points
  41192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41193. * @param name defines the name of the mesh
  41194. * @param options defines the options used to create the mesh
  41195. * @param scene defines the hosting scene
  41196. * @returns the dashed line mesh
  41197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41198. */
  41199. static CreateDashedLines(name: string, options: {
  41200. points: Vector3[];
  41201. dashSize?: number;
  41202. gapSize?: number;
  41203. dashNb?: number;
  41204. updatable?: boolean;
  41205. instance?: LinesMesh;
  41206. }, scene?: Nullable<Scene>): LinesMesh;
  41207. }
  41208. }
  41209. declare module BABYLON {
  41210. /**
  41211. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41212. * in order to better appreciate the issue one might have.
  41213. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41214. */
  41215. export class RayHelper {
  41216. /**
  41217. * Defines the ray we are currently tryin to visualize.
  41218. */
  41219. ray: Nullable<Ray>;
  41220. private _renderPoints;
  41221. private _renderLine;
  41222. private _renderFunction;
  41223. private _scene;
  41224. private _updateToMeshFunction;
  41225. private _attachedToMesh;
  41226. private _meshSpaceDirection;
  41227. private _meshSpaceOrigin;
  41228. /**
  41229. * Helper function to create a colored helper in a scene in one line.
  41230. * @param ray Defines the ray we are currently tryin to visualize
  41231. * @param scene Defines the scene the ray is used in
  41232. * @param color Defines the color we want to see the ray in
  41233. * @returns The newly created ray helper.
  41234. */
  41235. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41236. /**
  41237. * Instantiate a new ray helper.
  41238. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41239. * in order to better appreciate the issue one might have.
  41240. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41241. * @param ray Defines the ray we are currently tryin to visualize
  41242. */
  41243. constructor(ray: Ray);
  41244. /**
  41245. * Shows the ray we are willing to debug.
  41246. * @param scene Defines the scene the ray needs to be rendered in
  41247. * @param color Defines the color the ray needs to be rendered in
  41248. */
  41249. show(scene: Scene, color?: Color3): void;
  41250. /**
  41251. * Hides the ray we are debugging.
  41252. */
  41253. hide(): void;
  41254. private _render;
  41255. /**
  41256. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41257. * @param mesh Defines the mesh we want the helper attached to
  41258. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41259. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41260. * @param length Defines the length of the ray
  41261. */
  41262. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41263. /**
  41264. * Detach the ray helper from the mesh it has previously been attached to.
  41265. */
  41266. detachFromMesh(): void;
  41267. private _updateToMesh;
  41268. /**
  41269. * Dispose the helper and release its associated resources.
  41270. */
  41271. dispose(): void;
  41272. }
  41273. }
  41274. declare module BABYLON.Debug {
  41275. /**
  41276. * Class used to render a debug view of a given skeleton
  41277. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41278. */
  41279. export class SkeletonViewer {
  41280. /** defines the skeleton to render */
  41281. skeleton: Skeleton;
  41282. /** defines the mesh attached to the skeleton */
  41283. mesh: AbstractMesh;
  41284. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41285. autoUpdateBonesMatrices: boolean;
  41286. /** defines the rendering group id to use with the viewer */
  41287. renderingGroupId: number;
  41288. /** Gets or sets the color used to render the skeleton */
  41289. color: Color3;
  41290. private _scene;
  41291. private _debugLines;
  41292. private _debugMesh;
  41293. private _isEnabled;
  41294. private _renderFunction;
  41295. private _utilityLayer;
  41296. /**
  41297. * Returns the mesh used to render the bones
  41298. */
  41299. readonly debugMesh: Nullable<LinesMesh>;
  41300. /**
  41301. * Creates a new SkeletonViewer
  41302. * @param skeleton defines the skeleton to render
  41303. * @param mesh defines the mesh attached to the skeleton
  41304. * @param scene defines the hosting scene
  41305. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41306. * @param renderingGroupId defines the rendering group id to use with the viewer
  41307. */
  41308. constructor(
  41309. /** defines the skeleton to render */
  41310. skeleton: Skeleton,
  41311. /** defines the mesh attached to the skeleton */
  41312. mesh: AbstractMesh, scene: Scene,
  41313. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41314. autoUpdateBonesMatrices?: boolean,
  41315. /** defines the rendering group id to use with the viewer */
  41316. renderingGroupId?: number);
  41317. /** Gets or sets a boolean indicating if the viewer is enabled */
  41318. isEnabled: boolean;
  41319. private _getBonePosition;
  41320. private _getLinesForBonesWithLength;
  41321. private _getLinesForBonesNoLength;
  41322. /** Update the viewer to sync with current skeleton state */
  41323. update(): void;
  41324. /** Release associated resources */
  41325. dispose(): void;
  41326. }
  41327. }
  41328. declare module BABYLON {
  41329. /**
  41330. * Options to create the null engine
  41331. */
  41332. export class NullEngineOptions {
  41333. /**
  41334. * Render width (Default: 512)
  41335. */
  41336. renderWidth: number;
  41337. /**
  41338. * Render height (Default: 256)
  41339. */
  41340. renderHeight: number;
  41341. /**
  41342. * Texture size (Default: 512)
  41343. */
  41344. textureSize: number;
  41345. /**
  41346. * If delta time between frames should be constant
  41347. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41348. */
  41349. deterministicLockstep: boolean;
  41350. /**
  41351. * Maximum about of steps between frames (Default: 4)
  41352. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41353. */
  41354. lockstepMaxSteps: number;
  41355. }
  41356. /**
  41357. * The null engine class provides support for headless version of babylon.js.
  41358. * This can be used in server side scenario or for testing purposes
  41359. */
  41360. export class NullEngine extends Engine {
  41361. private _options;
  41362. /**
  41363. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41364. */
  41365. isDeterministicLockStep(): boolean;
  41366. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41367. getLockstepMaxSteps(): number;
  41368. /**
  41369. * Sets hardware scaling, used to save performance if needed
  41370. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41371. */
  41372. getHardwareScalingLevel(): number;
  41373. constructor(options?: NullEngineOptions);
  41374. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41375. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41376. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41377. getRenderWidth(useScreen?: boolean): number;
  41378. getRenderHeight(useScreen?: boolean): number;
  41379. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41380. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41381. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41382. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41383. bindSamplers(effect: Effect): void;
  41384. enableEffect(effect: Effect): void;
  41385. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41386. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41387. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41388. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41389. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41390. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41391. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41392. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41393. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41394. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41395. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41396. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41397. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41398. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41399. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41400. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41401. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41402. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41403. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41404. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41405. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41406. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41407. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41408. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41409. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41410. bindBuffers(vertexBuffers: {
  41411. [key: string]: VertexBuffer;
  41412. }, indexBuffer: DataBuffer, effect: Effect): void;
  41413. wipeCaches(bruteForce?: boolean): void;
  41414. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41415. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41416. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41417. /** @hidden */
  41418. _createTexture(): WebGLTexture;
  41419. /** @hidden */
  41420. _releaseTexture(texture: InternalTexture): void;
  41421. 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;
  41422. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41423. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41424. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41425. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41426. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41427. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41428. areAllEffectsReady(): boolean;
  41429. /**
  41430. * @hidden
  41431. * Get the current error code of the webGL context
  41432. * @returns the error code
  41433. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41434. */
  41435. getError(): number;
  41436. /** @hidden */
  41437. _getUnpackAlignement(): number;
  41438. /** @hidden */
  41439. _unpackFlipY(value: boolean): void;
  41440. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41441. /**
  41442. * Updates a dynamic vertex buffer.
  41443. * @param vertexBuffer the vertex buffer to update
  41444. * @param data the data used to update the vertex buffer
  41445. * @param byteOffset the byte offset of the data (optional)
  41446. * @param byteLength the byte length of the data (optional)
  41447. */
  41448. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41449. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41450. /** @hidden */
  41451. _bindTexture(channel: number, texture: InternalTexture): void;
  41452. /** @hidden */
  41453. _releaseBuffer(buffer: DataBuffer): boolean;
  41454. releaseEffects(): void;
  41455. displayLoadingUI(): void;
  41456. hideLoadingUI(): void;
  41457. /** @hidden */
  41458. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41459. /** @hidden */
  41460. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41461. /** @hidden */
  41462. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41463. /** @hidden */
  41464. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41465. }
  41466. }
  41467. declare module BABYLON {
  41468. /** @hidden */
  41469. export class _OcclusionDataStorage {
  41470. /** @hidden */
  41471. occlusionInternalRetryCounter: number;
  41472. /** @hidden */
  41473. isOcclusionQueryInProgress: boolean;
  41474. /** @hidden */
  41475. isOccluded: boolean;
  41476. /** @hidden */
  41477. occlusionRetryCount: number;
  41478. /** @hidden */
  41479. occlusionType: number;
  41480. /** @hidden */
  41481. occlusionQueryAlgorithmType: number;
  41482. }
  41483. interface Engine {
  41484. /**
  41485. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41486. * @return the new query
  41487. */
  41488. createQuery(): WebGLQuery;
  41489. /**
  41490. * Delete and release a webGL query
  41491. * @param query defines the query to delete
  41492. * @return the current engine
  41493. */
  41494. deleteQuery(query: WebGLQuery): Engine;
  41495. /**
  41496. * Check if a given query has resolved and got its value
  41497. * @param query defines the query to check
  41498. * @returns true if the query got its value
  41499. */
  41500. isQueryResultAvailable(query: WebGLQuery): boolean;
  41501. /**
  41502. * Gets the value of a given query
  41503. * @param query defines the query to check
  41504. * @returns the value of the query
  41505. */
  41506. getQueryResult(query: WebGLQuery): number;
  41507. /**
  41508. * Initiates an occlusion query
  41509. * @param algorithmType defines the algorithm to use
  41510. * @param query defines the query to use
  41511. * @returns the current engine
  41512. * @see http://doc.babylonjs.com/features/occlusionquery
  41513. */
  41514. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41515. /**
  41516. * Ends an occlusion query
  41517. * @see http://doc.babylonjs.com/features/occlusionquery
  41518. * @param algorithmType defines the algorithm to use
  41519. * @returns the current engine
  41520. */
  41521. endOcclusionQuery(algorithmType: number): Engine;
  41522. /**
  41523. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41524. * Please note that only one query can be issued at a time
  41525. * @returns a time token used to track the time span
  41526. */
  41527. startTimeQuery(): Nullable<_TimeToken>;
  41528. /**
  41529. * Ends a time query
  41530. * @param token defines the token used to measure the time span
  41531. * @returns the time spent (in ns)
  41532. */
  41533. endTimeQuery(token: _TimeToken): int;
  41534. /** @hidden */
  41535. _currentNonTimestampToken: Nullable<_TimeToken>;
  41536. /** @hidden */
  41537. _createTimeQuery(): WebGLQuery;
  41538. /** @hidden */
  41539. _deleteTimeQuery(query: WebGLQuery): void;
  41540. /** @hidden */
  41541. _getGlAlgorithmType(algorithmType: number): number;
  41542. /** @hidden */
  41543. _getTimeQueryResult(query: WebGLQuery): any;
  41544. /** @hidden */
  41545. _getTimeQueryAvailability(query: WebGLQuery): any;
  41546. }
  41547. interface AbstractMesh {
  41548. /**
  41549. * Backing filed
  41550. * @hidden
  41551. */
  41552. __occlusionDataStorage: _OcclusionDataStorage;
  41553. /**
  41554. * Access property
  41555. * @hidden
  41556. */
  41557. _occlusionDataStorage: _OcclusionDataStorage;
  41558. /**
  41559. * 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.
  41560. * The default value is -1 which means don't break the query and wait till the result
  41561. * @see http://doc.babylonjs.com/features/occlusionquery
  41562. */
  41563. occlusionRetryCount: number;
  41564. /**
  41565. * 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:
  41566. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41567. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41568. * * 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.
  41569. * @see http://doc.babylonjs.com/features/occlusionquery
  41570. */
  41571. occlusionType: number;
  41572. /**
  41573. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41574. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41575. * * 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.
  41576. * @see http://doc.babylonjs.com/features/occlusionquery
  41577. */
  41578. occlusionQueryAlgorithmType: number;
  41579. /**
  41580. * 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
  41581. * @see http://doc.babylonjs.com/features/occlusionquery
  41582. */
  41583. isOccluded: boolean;
  41584. /**
  41585. * Flag to check the progress status of the query
  41586. * @see http://doc.babylonjs.com/features/occlusionquery
  41587. */
  41588. isOcclusionQueryInProgress: boolean;
  41589. }
  41590. }
  41591. declare module BABYLON {
  41592. /** @hidden */
  41593. export var _forceTransformFeedbackToBundle: boolean;
  41594. interface Engine {
  41595. /**
  41596. * Creates a webGL transform feedback object
  41597. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41598. * @returns the webGL transform feedback object
  41599. */
  41600. createTransformFeedback(): WebGLTransformFeedback;
  41601. /**
  41602. * Delete a webGL transform feedback object
  41603. * @param value defines the webGL transform feedback object to delete
  41604. */
  41605. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41606. /**
  41607. * Bind a webGL transform feedback object to the webgl context
  41608. * @param value defines the webGL transform feedback object to bind
  41609. */
  41610. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41611. /**
  41612. * Begins a transform feedback operation
  41613. * @param usePoints defines if points or triangles must be used
  41614. */
  41615. beginTransformFeedback(usePoints: boolean): void;
  41616. /**
  41617. * Ends a transform feedback operation
  41618. */
  41619. endTransformFeedback(): void;
  41620. /**
  41621. * Specify the varyings to use with transform feedback
  41622. * @param program defines the associated webGL program
  41623. * @param value defines the list of strings representing the varying names
  41624. */
  41625. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41626. /**
  41627. * Bind a webGL buffer for a transform feedback operation
  41628. * @param value defines the webGL buffer to bind
  41629. */
  41630. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41631. }
  41632. }
  41633. declare module BABYLON {
  41634. /**
  41635. * Creation options of the multi render target texture.
  41636. */
  41637. export interface IMultiRenderTargetOptions {
  41638. /**
  41639. * Define if the texture needs to create mip maps after render.
  41640. */
  41641. generateMipMaps?: boolean;
  41642. /**
  41643. * Define the types of all the draw buffers we want to create
  41644. */
  41645. types?: number[];
  41646. /**
  41647. * Define the sampling modes of all the draw buffers we want to create
  41648. */
  41649. samplingModes?: number[];
  41650. /**
  41651. * Define if a depth buffer is required
  41652. */
  41653. generateDepthBuffer?: boolean;
  41654. /**
  41655. * Define if a stencil buffer is required
  41656. */
  41657. generateStencilBuffer?: boolean;
  41658. /**
  41659. * Define if a depth texture is required instead of a depth buffer
  41660. */
  41661. generateDepthTexture?: boolean;
  41662. /**
  41663. * Define the number of desired draw buffers
  41664. */
  41665. textureCount?: number;
  41666. /**
  41667. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41668. */
  41669. doNotChangeAspectRatio?: boolean;
  41670. /**
  41671. * Define the default type of the buffers we are creating
  41672. */
  41673. defaultType?: number;
  41674. }
  41675. /**
  41676. * A multi render target, like a render target provides the ability to render to a texture.
  41677. * Unlike the render target, it can render to several draw buffers in one draw.
  41678. * This is specially interesting in deferred rendering or for any effects requiring more than
  41679. * just one color from a single pass.
  41680. */
  41681. export class MultiRenderTarget extends RenderTargetTexture {
  41682. private _internalTextures;
  41683. private _textures;
  41684. private _multiRenderTargetOptions;
  41685. /**
  41686. * Get if draw buffers are currently supported by the used hardware and browser.
  41687. */
  41688. readonly isSupported: boolean;
  41689. /**
  41690. * Get the list of textures generated by the multi render target.
  41691. */
  41692. readonly textures: Texture[];
  41693. /**
  41694. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41695. */
  41696. readonly depthTexture: Texture;
  41697. /**
  41698. * Set the wrapping mode on U of all the textures we are rendering to.
  41699. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41700. */
  41701. wrapU: number;
  41702. /**
  41703. * Set the wrapping mode on V of all the textures we are rendering to.
  41704. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41705. */
  41706. wrapV: number;
  41707. /**
  41708. * Instantiate a new multi render target texture.
  41709. * A multi render target, like a render target provides the ability to render to a texture.
  41710. * Unlike the render target, it can render to several draw buffers in one draw.
  41711. * This is specially interesting in deferred rendering or for any effects requiring more than
  41712. * just one color from a single pass.
  41713. * @param name Define the name of the texture
  41714. * @param size Define the size of the buffers to render to
  41715. * @param count Define the number of target we are rendering into
  41716. * @param scene Define the scene the texture belongs to
  41717. * @param options Define the options used to create the multi render target
  41718. */
  41719. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41720. /** @hidden */
  41721. _rebuild(): void;
  41722. private _createInternalTextures;
  41723. private _createTextures;
  41724. /**
  41725. * Define the number of samples used if MSAA is enabled.
  41726. */
  41727. samples: number;
  41728. /**
  41729. * Resize all the textures in the multi render target.
  41730. * Be carrefull as it will recreate all the data in the new texture.
  41731. * @param size Define the new size
  41732. */
  41733. resize(size: any): void;
  41734. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41735. /**
  41736. * Dispose the render targets and their associated resources
  41737. */
  41738. dispose(): void;
  41739. /**
  41740. * Release all the underlying texture used as draw buffers.
  41741. */
  41742. releaseInternalTextures(): void;
  41743. }
  41744. }
  41745. declare module BABYLON {
  41746. interface Engine {
  41747. /**
  41748. * Unbind a list of render target textures from the webGL context
  41749. * This is used only when drawBuffer extension or webGL2 are active
  41750. * @param textures defines the render target textures to unbind
  41751. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41752. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41753. */
  41754. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41755. /**
  41756. * Create a multi render target texture
  41757. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41758. * @param size defines the size of the texture
  41759. * @param options defines the creation options
  41760. * @returns the cube texture as an InternalTexture
  41761. */
  41762. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41763. /**
  41764. * Update the sample count for a given multiple render target texture
  41765. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41766. * @param textures defines the textures to update
  41767. * @param samples defines the sample count to set
  41768. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41769. */
  41770. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41771. }
  41772. }
  41773. declare module BABYLON {
  41774. /**
  41775. * Gather the list of clipboard event types as constants.
  41776. */
  41777. export class ClipboardEventTypes {
  41778. /**
  41779. * The clipboard event is fired when a copy command is active (pressed).
  41780. */
  41781. static readonly COPY: number;
  41782. /**
  41783. * The clipboard event is fired when a cut command is active (pressed).
  41784. */
  41785. static readonly CUT: number;
  41786. /**
  41787. * The clipboard event is fired when a paste command is active (pressed).
  41788. */
  41789. static readonly PASTE: number;
  41790. }
  41791. /**
  41792. * This class is used to store clipboard related info for the onClipboardObservable event.
  41793. */
  41794. export class ClipboardInfo {
  41795. /**
  41796. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41797. */
  41798. type: number;
  41799. /**
  41800. * Defines the related dom event
  41801. */
  41802. event: ClipboardEvent;
  41803. /**
  41804. *Creates an instance of ClipboardInfo.
  41805. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41806. * @param event Defines the related dom event
  41807. */
  41808. constructor(
  41809. /**
  41810. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41811. */
  41812. type: number,
  41813. /**
  41814. * Defines the related dom event
  41815. */
  41816. event: ClipboardEvent);
  41817. /**
  41818. * Get the clipboard event's type from the keycode.
  41819. * @param keyCode Defines the keyCode for the current keyboard event.
  41820. * @return {number}
  41821. */
  41822. static GetTypeFromCharacter(keyCode: number): number;
  41823. }
  41824. }
  41825. declare module BABYLON {
  41826. /**
  41827. * Class used to represent data loading progression
  41828. */
  41829. export class SceneLoaderProgressEvent {
  41830. /** defines if data length to load can be evaluated */
  41831. readonly lengthComputable: boolean;
  41832. /** defines the loaded data length */
  41833. readonly loaded: number;
  41834. /** defines the data length to load */
  41835. readonly total: number;
  41836. /**
  41837. * Create a new progress event
  41838. * @param lengthComputable defines if data length to load can be evaluated
  41839. * @param loaded defines the loaded data length
  41840. * @param total defines the data length to load
  41841. */
  41842. constructor(
  41843. /** defines if data length to load can be evaluated */
  41844. lengthComputable: boolean,
  41845. /** defines the loaded data length */
  41846. loaded: number,
  41847. /** defines the data length to load */
  41848. total: number);
  41849. /**
  41850. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41851. * @param event defines the source event
  41852. * @returns a new SceneLoaderProgressEvent
  41853. */
  41854. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41855. }
  41856. /**
  41857. * Interface used by SceneLoader plugins to define supported file extensions
  41858. */
  41859. export interface ISceneLoaderPluginExtensions {
  41860. /**
  41861. * Defines the list of supported extensions
  41862. */
  41863. [extension: string]: {
  41864. isBinary: boolean;
  41865. };
  41866. }
  41867. /**
  41868. * Interface used by SceneLoader plugin factory
  41869. */
  41870. export interface ISceneLoaderPluginFactory {
  41871. /**
  41872. * Defines the name of the factory
  41873. */
  41874. name: string;
  41875. /**
  41876. * Function called to create a new plugin
  41877. * @return the new plugin
  41878. */
  41879. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41880. /**
  41881. * Boolean indicating if the plugin can direct load specific data
  41882. */
  41883. canDirectLoad?: (data: string) => boolean;
  41884. }
  41885. /**
  41886. * Interface used to define a SceneLoader plugin
  41887. */
  41888. export interface ISceneLoaderPlugin {
  41889. /**
  41890. * The friendly name of this plugin.
  41891. */
  41892. name: string;
  41893. /**
  41894. * The file extensions supported by this plugin.
  41895. */
  41896. extensions: string | ISceneLoaderPluginExtensions;
  41897. /**
  41898. * Import meshes into a scene.
  41899. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41900. * @param scene The scene to import into
  41901. * @param data The data to import
  41902. * @param rootUrl The root url for scene and resources
  41903. * @param meshes The meshes array to import into
  41904. * @param particleSystems The particle systems array to import into
  41905. * @param skeletons The skeletons array to import into
  41906. * @param onError The callback when import fails
  41907. * @returns True if successful or false otherwise
  41908. */
  41909. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41910. /**
  41911. * Load into a scene.
  41912. * @param scene The scene to load into
  41913. * @param data The data to import
  41914. * @param rootUrl The root url for scene and resources
  41915. * @param onError The callback when import fails
  41916. * @returns true if successful or false otherwise
  41917. */
  41918. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41919. /**
  41920. * The callback that returns true if the data can be directly loaded.
  41921. */
  41922. canDirectLoad?: (data: string) => boolean;
  41923. /**
  41924. * The callback that allows custom handling of the root url based on the response url.
  41925. */
  41926. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41927. /**
  41928. * Load into an asset container.
  41929. * @param scene The scene to load into
  41930. * @param data The data to import
  41931. * @param rootUrl The root url for scene and resources
  41932. * @param onError The callback when import fails
  41933. * @returns The loaded asset container
  41934. */
  41935. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41936. }
  41937. /**
  41938. * Interface used to define an async SceneLoader plugin
  41939. */
  41940. export interface ISceneLoaderPluginAsync {
  41941. /**
  41942. * The friendly name of this plugin.
  41943. */
  41944. name: string;
  41945. /**
  41946. * The file extensions supported by this plugin.
  41947. */
  41948. extensions: string | ISceneLoaderPluginExtensions;
  41949. /**
  41950. * Import meshes into a scene.
  41951. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41952. * @param scene The scene to import into
  41953. * @param data The data to import
  41954. * @param rootUrl The root url for scene and resources
  41955. * @param onProgress The callback when the load progresses
  41956. * @param fileName Defines the name of the file to load
  41957. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41958. */
  41959. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41960. meshes: AbstractMesh[];
  41961. particleSystems: IParticleSystem[];
  41962. skeletons: Skeleton[];
  41963. animationGroups: AnimationGroup[];
  41964. }>;
  41965. /**
  41966. * Load into a scene.
  41967. * @param scene The scene to load into
  41968. * @param data The data to import
  41969. * @param rootUrl The root url for scene and resources
  41970. * @param onProgress The callback when the load progresses
  41971. * @param fileName Defines the name of the file to load
  41972. * @returns Nothing
  41973. */
  41974. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41975. /**
  41976. * The callback that returns true if the data can be directly loaded.
  41977. */
  41978. canDirectLoad?: (data: string) => boolean;
  41979. /**
  41980. * The callback that allows custom handling of the root url based on the response url.
  41981. */
  41982. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41983. /**
  41984. * Load into an asset container.
  41985. * @param scene The scene to load into
  41986. * @param data The data to import
  41987. * @param rootUrl The root url for scene and resources
  41988. * @param onProgress The callback when the load progresses
  41989. * @param fileName Defines the name of the file to load
  41990. * @returns The loaded asset container
  41991. */
  41992. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41993. }
  41994. /**
  41995. * Class used to load scene from various file formats using registered plugins
  41996. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41997. */
  41998. export class SceneLoader {
  41999. /**
  42000. * No logging while loading
  42001. */
  42002. static readonly NO_LOGGING: number;
  42003. /**
  42004. * Minimal logging while loading
  42005. */
  42006. static readonly MINIMAL_LOGGING: number;
  42007. /**
  42008. * Summary logging while loading
  42009. */
  42010. static readonly SUMMARY_LOGGING: number;
  42011. /**
  42012. * Detailled logging while loading
  42013. */
  42014. static readonly DETAILED_LOGGING: number;
  42015. /**
  42016. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42017. */
  42018. static ForceFullSceneLoadingForIncremental: boolean;
  42019. /**
  42020. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42021. */
  42022. static ShowLoadingScreen: boolean;
  42023. /**
  42024. * Defines the current logging level (while loading the scene)
  42025. * @ignorenaming
  42026. */
  42027. static loggingLevel: number;
  42028. /**
  42029. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42030. */
  42031. static CleanBoneMatrixWeights: boolean;
  42032. /**
  42033. * Event raised when a plugin is used to load a scene
  42034. */
  42035. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42036. private static _registeredPlugins;
  42037. private static _getDefaultPlugin;
  42038. private static _getPluginForExtension;
  42039. private static _getPluginForDirectLoad;
  42040. private static _getPluginForFilename;
  42041. private static _getDirectLoad;
  42042. private static _loadData;
  42043. private static _getFileInfo;
  42044. /**
  42045. * Gets a plugin that can load the given extension
  42046. * @param extension defines the extension to load
  42047. * @returns a plugin or null if none works
  42048. */
  42049. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42050. /**
  42051. * Gets a boolean indicating that the given extension can be loaded
  42052. * @param extension defines the extension to load
  42053. * @returns true if the extension is supported
  42054. */
  42055. static IsPluginForExtensionAvailable(extension: string): boolean;
  42056. /**
  42057. * Adds a new plugin to the list of registered plugins
  42058. * @param plugin defines the plugin to add
  42059. */
  42060. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42061. /**
  42062. * Import meshes into a scene
  42063. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42064. * @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)
  42065. * @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)
  42066. * @param scene the instance of BABYLON.Scene to append to
  42067. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42068. * @param onProgress a callback with a progress event for each file being loaded
  42069. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42070. * @param pluginExtension the extension used to determine the plugin
  42071. * @returns The loaded plugin
  42072. */
  42073. 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>;
  42074. /**
  42075. * Import meshes into a scene
  42076. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42077. * @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)
  42078. * @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)
  42079. * @param scene the instance of BABYLON.Scene to append to
  42080. * @param onProgress a callback with a progress event for each file being loaded
  42081. * @param pluginExtension the extension used to determine the plugin
  42082. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42083. */
  42084. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42085. meshes: AbstractMesh[];
  42086. particleSystems: IParticleSystem[];
  42087. skeletons: Skeleton[];
  42088. animationGroups: AnimationGroup[];
  42089. }>;
  42090. /**
  42091. * Load a scene
  42092. * @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)
  42093. * @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)
  42094. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42095. * @param onSuccess a callback with the scene when import succeeds
  42096. * @param onProgress a callback with a progress event for each file being loaded
  42097. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42098. * @param pluginExtension the extension used to determine the plugin
  42099. * @returns The loaded plugin
  42100. */
  42101. 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>;
  42102. /**
  42103. * Load a scene
  42104. * @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)
  42105. * @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)
  42106. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42107. * @param onProgress a callback with a progress event for each file being loaded
  42108. * @param pluginExtension the extension used to determine the plugin
  42109. * @returns The loaded scene
  42110. */
  42111. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42112. /**
  42113. * Append a scene
  42114. * @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)
  42115. * @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)
  42116. * @param scene is the instance of BABYLON.Scene to append to
  42117. * @param onSuccess a callback with the scene when import succeeds
  42118. * @param onProgress a callback with a progress event for each file being loaded
  42119. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42120. * @param pluginExtension the extension used to determine the plugin
  42121. * @returns The loaded plugin
  42122. */
  42123. 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>;
  42124. /**
  42125. * Append a scene
  42126. * @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)
  42127. * @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)
  42128. * @param scene is the instance of BABYLON.Scene to append to
  42129. * @param onProgress a callback with a progress event for each file being loaded
  42130. * @param pluginExtension the extension used to determine the plugin
  42131. * @returns The given scene
  42132. */
  42133. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42134. /**
  42135. * Load a scene into an asset container
  42136. * @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)
  42137. * @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)
  42138. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42139. * @param onSuccess a callback with the scene when import succeeds
  42140. * @param onProgress a callback with a progress event for each file being loaded
  42141. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42142. * @param pluginExtension the extension used to determine the plugin
  42143. * @returns The loaded plugin
  42144. */
  42145. 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>;
  42146. /**
  42147. * Load a scene into an asset container
  42148. * @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)
  42149. * @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)
  42150. * @param scene is the instance of Scene to append to
  42151. * @param onProgress a callback with a progress event for each file being loaded
  42152. * @param pluginExtension the extension used to determine the plugin
  42153. * @returns The loaded asset container
  42154. */
  42155. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42156. }
  42157. }
  42158. declare module BABYLON {
  42159. /**
  42160. * Google Daydream controller
  42161. */
  42162. export class DaydreamController extends WebVRController {
  42163. /**
  42164. * Base Url for the controller model.
  42165. */
  42166. static MODEL_BASE_URL: string;
  42167. /**
  42168. * File name for the controller model.
  42169. */
  42170. static MODEL_FILENAME: string;
  42171. /**
  42172. * Gamepad Id prefix used to identify Daydream Controller.
  42173. */
  42174. static readonly GAMEPAD_ID_PREFIX: string;
  42175. /**
  42176. * Creates a new DaydreamController from a gamepad
  42177. * @param vrGamepad the gamepad that the controller should be created from
  42178. */
  42179. constructor(vrGamepad: any);
  42180. /**
  42181. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42182. * @param scene scene in which to add meshes
  42183. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42184. */
  42185. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42186. /**
  42187. * Called once for each button that changed state since the last frame
  42188. * @param buttonIdx Which button index changed
  42189. * @param state New state of the button
  42190. * @param changes Which properties on the state changed since last frame
  42191. */
  42192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42193. }
  42194. }
  42195. declare module BABYLON {
  42196. /**
  42197. * Gear VR Controller
  42198. */
  42199. export class GearVRController extends WebVRController {
  42200. /**
  42201. * Base Url for the controller model.
  42202. */
  42203. static MODEL_BASE_URL: string;
  42204. /**
  42205. * File name for the controller model.
  42206. */
  42207. static MODEL_FILENAME: string;
  42208. /**
  42209. * Gamepad Id prefix used to identify this controller.
  42210. */
  42211. static readonly GAMEPAD_ID_PREFIX: string;
  42212. private readonly _buttonIndexToObservableNameMap;
  42213. /**
  42214. * Creates a new GearVRController from a gamepad
  42215. * @param vrGamepad the gamepad that the controller should be created from
  42216. */
  42217. constructor(vrGamepad: any);
  42218. /**
  42219. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42220. * @param scene scene in which to add meshes
  42221. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42222. */
  42223. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42224. /**
  42225. * Called once for each button that changed state since the last frame
  42226. * @param buttonIdx Which button index changed
  42227. * @param state New state of the button
  42228. * @param changes Which properties on the state changed since last frame
  42229. */
  42230. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42231. }
  42232. }
  42233. declare module BABYLON {
  42234. /**
  42235. * Generic Controller
  42236. */
  42237. export class GenericController extends WebVRController {
  42238. /**
  42239. * Base Url for the controller model.
  42240. */
  42241. static readonly MODEL_BASE_URL: string;
  42242. /**
  42243. * File name for the controller model.
  42244. */
  42245. static readonly MODEL_FILENAME: string;
  42246. /**
  42247. * Creates a new GenericController from a gamepad
  42248. * @param vrGamepad the gamepad that the controller should be created from
  42249. */
  42250. constructor(vrGamepad: any);
  42251. /**
  42252. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42253. * @param scene scene in which to add meshes
  42254. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42255. */
  42256. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42257. /**
  42258. * Called once for each button that changed state since the last frame
  42259. * @param buttonIdx Which button index changed
  42260. * @param state New state of the button
  42261. * @param changes Which properties on the state changed since last frame
  42262. */
  42263. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42264. }
  42265. }
  42266. declare module BABYLON {
  42267. /**
  42268. * Oculus Touch Controller
  42269. */
  42270. export class OculusTouchController extends WebVRController {
  42271. /**
  42272. * Base Url for the controller model.
  42273. */
  42274. static MODEL_BASE_URL: string;
  42275. /**
  42276. * File name for the left controller model.
  42277. */
  42278. static MODEL_LEFT_FILENAME: string;
  42279. /**
  42280. * File name for the right controller model.
  42281. */
  42282. static MODEL_RIGHT_FILENAME: string;
  42283. /**
  42284. * Fired when the secondary trigger on this controller is modified
  42285. */
  42286. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42287. /**
  42288. * Fired when the thumb rest on this controller is modified
  42289. */
  42290. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42291. /**
  42292. * Creates a new OculusTouchController from a gamepad
  42293. * @param vrGamepad the gamepad that the controller should be created from
  42294. */
  42295. constructor(vrGamepad: any);
  42296. /**
  42297. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42298. * @param scene scene in which to add meshes
  42299. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42300. */
  42301. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42302. /**
  42303. * Fired when the A button on this controller is modified
  42304. */
  42305. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42306. /**
  42307. * Fired when the B button on this controller is modified
  42308. */
  42309. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42310. /**
  42311. * Fired when the X button on this controller is modified
  42312. */
  42313. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42314. /**
  42315. * Fired when the Y button on this controller is modified
  42316. */
  42317. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42318. /**
  42319. * Called once for each button that changed state since the last frame
  42320. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42321. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42322. * 2) secondary trigger (same)
  42323. * 3) A (right) X (left), touch, pressed = value
  42324. * 4) B / Y
  42325. * 5) thumb rest
  42326. * @param buttonIdx Which button index changed
  42327. * @param state New state of the button
  42328. * @param changes Which properties on the state changed since last frame
  42329. */
  42330. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42331. }
  42332. }
  42333. declare module BABYLON {
  42334. /**
  42335. * Vive Controller
  42336. */
  42337. export class ViveController extends WebVRController {
  42338. /**
  42339. * Base Url for the controller model.
  42340. */
  42341. static MODEL_BASE_URL: string;
  42342. /**
  42343. * File name for the controller model.
  42344. */
  42345. static MODEL_FILENAME: string;
  42346. /**
  42347. * Creates a new ViveController from a gamepad
  42348. * @param vrGamepad the gamepad that the controller should be created from
  42349. */
  42350. constructor(vrGamepad: any);
  42351. /**
  42352. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42353. * @param scene scene in which to add meshes
  42354. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42355. */
  42356. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42357. /**
  42358. * Fired when the left button on this controller is modified
  42359. */
  42360. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42361. /**
  42362. * Fired when the right button on this controller is modified
  42363. */
  42364. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42365. /**
  42366. * Fired when the menu button on this controller is modified
  42367. */
  42368. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42369. /**
  42370. * Called once for each button that changed state since the last frame
  42371. * Vive mapping:
  42372. * 0: touchpad
  42373. * 1: trigger
  42374. * 2: left AND right buttons
  42375. * 3: menu button
  42376. * @param buttonIdx Which button index changed
  42377. * @param state New state of the button
  42378. * @param changes Which properties on the state changed since last frame
  42379. */
  42380. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42381. }
  42382. }
  42383. declare module BABYLON {
  42384. /**
  42385. * Defines the WindowsMotionController object that the state of the windows motion controller
  42386. */
  42387. export class WindowsMotionController extends WebVRController {
  42388. /**
  42389. * The base url used to load the left and right controller models
  42390. */
  42391. static MODEL_BASE_URL: string;
  42392. /**
  42393. * The name of the left controller model file
  42394. */
  42395. static MODEL_LEFT_FILENAME: string;
  42396. /**
  42397. * The name of the right controller model file
  42398. */
  42399. static MODEL_RIGHT_FILENAME: string;
  42400. /**
  42401. * The controller name prefix for this controller type
  42402. */
  42403. static readonly GAMEPAD_ID_PREFIX: string;
  42404. /**
  42405. * The controller id pattern for this controller type
  42406. */
  42407. private static readonly GAMEPAD_ID_PATTERN;
  42408. private _loadedMeshInfo;
  42409. private readonly _mapping;
  42410. /**
  42411. * Fired when the trackpad on this controller is clicked
  42412. */
  42413. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42414. /**
  42415. * Fired when the trackpad on this controller is modified
  42416. */
  42417. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42418. /**
  42419. * The current x and y values of this controller's trackpad
  42420. */
  42421. trackpad: StickValues;
  42422. /**
  42423. * Creates a new WindowsMotionController from a gamepad
  42424. * @param vrGamepad the gamepad that the controller should be created from
  42425. */
  42426. constructor(vrGamepad: any);
  42427. /**
  42428. * Fired when the trigger on this controller is modified
  42429. */
  42430. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42431. /**
  42432. * Fired when the menu button on this controller is modified
  42433. */
  42434. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42435. /**
  42436. * Fired when the grip button on this controller is modified
  42437. */
  42438. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42439. /**
  42440. * Fired when the thumbstick button on this controller is modified
  42441. */
  42442. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42443. /**
  42444. * Fired when the touchpad button on this controller is modified
  42445. */
  42446. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42447. /**
  42448. * Fired when the touchpad values on this controller are modified
  42449. */
  42450. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42451. private _updateTrackpad;
  42452. /**
  42453. * Called once per frame by the engine.
  42454. */
  42455. update(): void;
  42456. /**
  42457. * Called once for each button that changed state since the last frame
  42458. * @param buttonIdx Which button index changed
  42459. * @param state New state of the button
  42460. * @param changes Which properties on the state changed since last frame
  42461. */
  42462. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42463. /**
  42464. * Moves the buttons on the controller mesh based on their current state
  42465. * @param buttonName the name of the button to move
  42466. * @param buttonValue the value of the button which determines the buttons new position
  42467. */
  42468. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42469. /**
  42470. * Moves the axis on the controller mesh based on its current state
  42471. * @param axis the index of the axis
  42472. * @param axisValue the value of the axis which determines the meshes new position
  42473. * @hidden
  42474. */
  42475. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42476. /**
  42477. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42478. * @param scene scene in which to add meshes
  42479. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42480. */
  42481. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42482. /**
  42483. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42484. * can be transformed by button presses and axes values, based on this._mapping.
  42485. *
  42486. * @param scene scene in which the meshes exist
  42487. * @param meshes list of meshes that make up the controller model to process
  42488. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42489. */
  42490. private processModel;
  42491. private createMeshInfo;
  42492. /**
  42493. * Gets the ray of the controller in the direction the controller is pointing
  42494. * @param length the length the resulting ray should be
  42495. * @returns a ray in the direction the controller is pointing
  42496. */
  42497. getForwardRay(length?: number): Ray;
  42498. /**
  42499. * Disposes of the controller
  42500. */
  42501. dispose(): void;
  42502. }
  42503. }
  42504. declare module BABYLON {
  42505. /**
  42506. * Single axis scale gizmo
  42507. */
  42508. export class AxisScaleGizmo extends Gizmo {
  42509. private _coloredMaterial;
  42510. /**
  42511. * Drag behavior responsible for the gizmos dragging interactions
  42512. */
  42513. dragBehavior: PointerDragBehavior;
  42514. private _pointerObserver;
  42515. /**
  42516. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42517. */
  42518. snapDistance: number;
  42519. /**
  42520. * Event that fires each time the gizmo snaps to a new location.
  42521. * * snapDistance is the the change in distance
  42522. */
  42523. onSnapObservable: Observable<{
  42524. snapDistance: number;
  42525. }>;
  42526. /**
  42527. * If the scaling operation should be done on all axis (default: false)
  42528. */
  42529. uniformScaling: boolean;
  42530. /**
  42531. * Creates an AxisScaleGizmo
  42532. * @param gizmoLayer The utility layer the gizmo will be added to
  42533. * @param dragAxis The axis which the gizmo will be able to scale on
  42534. * @param color The color of the gizmo
  42535. */
  42536. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42537. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42538. /**
  42539. * Disposes of the gizmo
  42540. */
  42541. dispose(): void;
  42542. /**
  42543. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42544. * @param mesh The mesh to replace the default mesh of the gizmo
  42545. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42546. */
  42547. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42548. }
  42549. }
  42550. declare module BABYLON {
  42551. /**
  42552. * Bounding box gizmo
  42553. */
  42554. export class BoundingBoxGizmo extends Gizmo {
  42555. private _lineBoundingBox;
  42556. private _rotateSpheresParent;
  42557. private _scaleBoxesParent;
  42558. private _boundingDimensions;
  42559. private _renderObserver;
  42560. private _pointerObserver;
  42561. private _scaleDragSpeed;
  42562. private _tmpQuaternion;
  42563. private _tmpVector;
  42564. private _tmpRotationMatrix;
  42565. /**
  42566. * 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)
  42567. */
  42568. ignoreChildren: boolean;
  42569. /**
  42570. * 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)
  42571. */
  42572. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42573. /**
  42574. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42575. */
  42576. rotationSphereSize: number;
  42577. /**
  42578. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42579. */
  42580. scaleBoxSize: number;
  42581. /**
  42582. * 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)
  42583. */
  42584. fixedDragMeshScreenSize: boolean;
  42585. /**
  42586. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42587. */
  42588. fixedDragMeshScreenSizeDistanceFactor: number;
  42589. /**
  42590. * Fired when a rotation sphere or scale box is dragged
  42591. */
  42592. onDragStartObservable: Observable<{}>;
  42593. /**
  42594. * Fired when a scale box is dragged
  42595. */
  42596. onScaleBoxDragObservable: Observable<{}>;
  42597. /**
  42598. * Fired when a scale box drag is ended
  42599. */
  42600. onScaleBoxDragEndObservable: Observable<{}>;
  42601. /**
  42602. * Fired when a rotation sphere is dragged
  42603. */
  42604. onRotationSphereDragObservable: Observable<{}>;
  42605. /**
  42606. * Fired when a rotation sphere drag is ended
  42607. */
  42608. onRotationSphereDragEndObservable: Observable<{}>;
  42609. /**
  42610. * 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)
  42611. */
  42612. scalePivot: Nullable<Vector3>;
  42613. /**
  42614. * Mesh used as a pivot to rotate the attached mesh
  42615. */
  42616. private _anchorMesh;
  42617. private _existingMeshScale;
  42618. private _dragMesh;
  42619. private pointerDragBehavior;
  42620. private coloredMaterial;
  42621. private hoverColoredMaterial;
  42622. /**
  42623. * Sets the color of the bounding box gizmo
  42624. * @param color the color to set
  42625. */
  42626. setColor(color: Color3): void;
  42627. /**
  42628. * Creates an BoundingBoxGizmo
  42629. * @param gizmoLayer The utility layer the gizmo will be added to
  42630. * @param color The color of the gizmo
  42631. */
  42632. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42633. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42634. private _selectNode;
  42635. /**
  42636. * Updates the bounding box information for the Gizmo
  42637. */
  42638. updateBoundingBox(): void;
  42639. private _updateRotationSpheres;
  42640. private _updateScaleBoxes;
  42641. /**
  42642. * Enables rotation on the specified axis and disables rotation on the others
  42643. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42644. */
  42645. setEnabledRotationAxis(axis: string): void;
  42646. /**
  42647. * Enables/disables scaling
  42648. * @param enable if scaling should be enabled
  42649. */
  42650. setEnabledScaling(enable: boolean): void;
  42651. private _updateDummy;
  42652. /**
  42653. * Enables a pointer drag behavior on the bounding box of the gizmo
  42654. */
  42655. enableDragBehavior(): void;
  42656. /**
  42657. * Disposes of the gizmo
  42658. */
  42659. dispose(): void;
  42660. /**
  42661. * 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)
  42662. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42663. * @returns the bounding box mesh with the passed in mesh as a child
  42664. */
  42665. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42666. /**
  42667. * CustomMeshes are not supported by this gizmo
  42668. * @param mesh The mesh to replace the default mesh of the gizmo
  42669. */
  42670. setCustomMesh(mesh: Mesh): void;
  42671. }
  42672. }
  42673. declare module BABYLON {
  42674. /**
  42675. * Single plane rotation gizmo
  42676. */
  42677. export class PlaneRotationGizmo extends Gizmo {
  42678. /**
  42679. * Drag behavior responsible for the gizmos dragging interactions
  42680. */
  42681. dragBehavior: PointerDragBehavior;
  42682. private _pointerObserver;
  42683. /**
  42684. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42685. */
  42686. snapDistance: number;
  42687. /**
  42688. * Event that fires each time the gizmo snaps to a new location.
  42689. * * snapDistance is the the change in distance
  42690. */
  42691. onSnapObservable: Observable<{
  42692. snapDistance: number;
  42693. }>;
  42694. /**
  42695. * Creates a PlaneRotationGizmo
  42696. * @param gizmoLayer The utility layer the gizmo will be added to
  42697. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42698. * @param color The color of the gizmo
  42699. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42700. */
  42701. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42702. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42703. /**
  42704. * Disposes of the gizmo
  42705. */
  42706. dispose(): void;
  42707. }
  42708. }
  42709. declare module BABYLON {
  42710. /**
  42711. * Gizmo that enables rotating a mesh along 3 axis
  42712. */
  42713. export class RotationGizmo extends Gizmo {
  42714. /**
  42715. * Internal gizmo used for interactions on the x axis
  42716. */
  42717. xGizmo: PlaneRotationGizmo;
  42718. /**
  42719. * Internal gizmo used for interactions on the y axis
  42720. */
  42721. yGizmo: PlaneRotationGizmo;
  42722. /**
  42723. * Internal gizmo used for interactions on the z axis
  42724. */
  42725. zGizmo: PlaneRotationGizmo;
  42726. /** Fires an event when any of it's sub gizmos are dragged */
  42727. onDragStartObservable: Observable<{}>;
  42728. /** Fires an event when any of it's sub gizmos are released from dragging */
  42729. onDragEndObservable: Observable<{}>;
  42730. attachedMesh: Nullable<AbstractMesh>;
  42731. /**
  42732. * Creates a RotationGizmo
  42733. * @param gizmoLayer The utility layer the gizmo will be added to
  42734. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42735. */
  42736. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42737. updateGizmoRotationToMatchAttachedMesh: boolean;
  42738. /**
  42739. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42740. */
  42741. snapDistance: number;
  42742. /**
  42743. * Ratio for the scale of the gizmo (Default: 1)
  42744. */
  42745. scaleRatio: number;
  42746. /**
  42747. * Disposes of the gizmo
  42748. */
  42749. dispose(): void;
  42750. /**
  42751. * CustomMeshes are not supported by this gizmo
  42752. * @param mesh The mesh to replace the default mesh of the gizmo
  42753. */
  42754. setCustomMesh(mesh: Mesh): void;
  42755. }
  42756. }
  42757. declare module BABYLON {
  42758. /**
  42759. * Gizmo that enables dragging a mesh along 3 axis
  42760. */
  42761. export class PositionGizmo extends Gizmo {
  42762. /**
  42763. * Internal gizmo used for interactions on the x axis
  42764. */
  42765. xGizmo: AxisDragGizmo;
  42766. /**
  42767. * Internal gizmo used for interactions on the y axis
  42768. */
  42769. yGizmo: AxisDragGizmo;
  42770. /**
  42771. * Internal gizmo used for interactions on the z axis
  42772. */
  42773. zGizmo: AxisDragGizmo;
  42774. /** Fires an event when any of it's sub gizmos are dragged */
  42775. onDragStartObservable: Observable<{}>;
  42776. /** Fires an event when any of it's sub gizmos are released from dragging */
  42777. onDragEndObservable: Observable<{}>;
  42778. attachedMesh: Nullable<AbstractMesh>;
  42779. /**
  42780. * Creates a PositionGizmo
  42781. * @param gizmoLayer The utility layer the gizmo will be added to
  42782. */
  42783. constructor(gizmoLayer?: UtilityLayerRenderer);
  42784. updateGizmoRotationToMatchAttachedMesh: boolean;
  42785. /**
  42786. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42787. */
  42788. snapDistance: number;
  42789. /**
  42790. * Ratio for the scale of the gizmo (Default: 1)
  42791. */
  42792. scaleRatio: number;
  42793. /**
  42794. * Disposes of the gizmo
  42795. */
  42796. dispose(): void;
  42797. /**
  42798. * CustomMeshes are not supported by this gizmo
  42799. * @param mesh The mesh to replace the default mesh of the gizmo
  42800. */
  42801. setCustomMesh(mesh: Mesh): void;
  42802. }
  42803. }
  42804. declare module BABYLON {
  42805. /**
  42806. * Class containing static functions to help procedurally build meshes
  42807. */
  42808. export class PolyhedronBuilder {
  42809. /**
  42810. * Creates a polyhedron mesh
  42811. * * 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
  42812. * * The parameter `size` (positive float, default 1) sets the polygon size
  42813. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42814. * * 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`
  42815. * * 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
  42816. * * 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)`)
  42817. * * 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
  42818. * * 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
  42819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42820. * * 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
  42821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42822. * @param name defines the name of the mesh
  42823. * @param options defines the options used to create the mesh
  42824. * @param scene defines the hosting scene
  42825. * @returns the polyhedron mesh
  42826. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42827. */
  42828. static CreatePolyhedron(name: string, options: {
  42829. type?: number;
  42830. size?: number;
  42831. sizeX?: number;
  42832. sizeY?: number;
  42833. sizeZ?: number;
  42834. custom?: any;
  42835. faceUV?: Vector4[];
  42836. faceColors?: Color4[];
  42837. flat?: boolean;
  42838. updatable?: boolean;
  42839. sideOrientation?: number;
  42840. frontUVs?: Vector4;
  42841. backUVs?: Vector4;
  42842. }, scene?: Nullable<Scene>): Mesh;
  42843. }
  42844. }
  42845. declare module BABYLON {
  42846. /**
  42847. * Gizmo that enables scaling a mesh along 3 axis
  42848. */
  42849. export class ScaleGizmo extends Gizmo {
  42850. /**
  42851. * Internal gizmo used for interactions on the x axis
  42852. */
  42853. xGizmo: AxisScaleGizmo;
  42854. /**
  42855. * Internal gizmo used for interactions on the y axis
  42856. */
  42857. yGizmo: AxisScaleGizmo;
  42858. /**
  42859. * Internal gizmo used for interactions on the z axis
  42860. */
  42861. zGizmo: AxisScaleGizmo;
  42862. /**
  42863. * Internal gizmo used to scale all axis equally
  42864. */
  42865. uniformScaleGizmo: AxisScaleGizmo;
  42866. /** Fires an event when any of it's sub gizmos are dragged */
  42867. onDragStartObservable: Observable<{}>;
  42868. /** Fires an event when any of it's sub gizmos are released from dragging */
  42869. onDragEndObservable: Observable<{}>;
  42870. attachedMesh: Nullable<AbstractMesh>;
  42871. /**
  42872. * Creates a ScaleGizmo
  42873. * @param gizmoLayer The utility layer the gizmo will be added to
  42874. */
  42875. constructor(gizmoLayer?: UtilityLayerRenderer);
  42876. updateGizmoRotationToMatchAttachedMesh: boolean;
  42877. /**
  42878. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42879. */
  42880. snapDistance: number;
  42881. /**
  42882. * Ratio for the scale of the gizmo (Default: 1)
  42883. */
  42884. scaleRatio: number;
  42885. /**
  42886. * Disposes of the gizmo
  42887. */
  42888. dispose(): void;
  42889. }
  42890. }
  42891. declare module BABYLON {
  42892. /**
  42893. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42894. */
  42895. export class GizmoManager implements IDisposable {
  42896. private scene;
  42897. /**
  42898. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42899. */
  42900. gizmos: {
  42901. positionGizmo: Nullable<PositionGizmo>;
  42902. rotationGizmo: Nullable<RotationGizmo>;
  42903. scaleGizmo: Nullable<ScaleGizmo>;
  42904. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42905. };
  42906. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42907. clearGizmoOnEmptyPointerEvent: boolean;
  42908. /** Fires an event when the manager is attached to a mesh */
  42909. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42910. private _gizmosEnabled;
  42911. private _pointerObserver;
  42912. private _attachedMesh;
  42913. private _boundingBoxColor;
  42914. private _defaultUtilityLayer;
  42915. private _defaultKeepDepthUtilityLayer;
  42916. /**
  42917. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42918. */
  42919. boundingBoxDragBehavior: SixDofDragBehavior;
  42920. /**
  42921. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42922. */
  42923. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42924. /**
  42925. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42926. */
  42927. usePointerToAttachGizmos: boolean;
  42928. /**
  42929. * Instatiates a gizmo manager
  42930. * @param scene the scene to overlay the gizmos on top of
  42931. */
  42932. constructor(scene: Scene);
  42933. /**
  42934. * Attaches a set of gizmos to the specified mesh
  42935. * @param mesh The mesh the gizmo's should be attached to
  42936. */
  42937. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42938. /**
  42939. * If the position gizmo is enabled
  42940. */
  42941. positionGizmoEnabled: boolean;
  42942. /**
  42943. * If the rotation gizmo is enabled
  42944. */
  42945. rotationGizmoEnabled: boolean;
  42946. /**
  42947. * If the scale gizmo is enabled
  42948. */
  42949. scaleGizmoEnabled: boolean;
  42950. /**
  42951. * If the boundingBox gizmo is enabled
  42952. */
  42953. boundingBoxGizmoEnabled: boolean;
  42954. /**
  42955. * Disposes of the gizmo manager
  42956. */
  42957. dispose(): void;
  42958. }
  42959. }
  42960. declare module BABYLON {
  42961. /**
  42962. * A directional light is defined by a direction (what a surprise!).
  42963. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42964. * 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.
  42965. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42966. */
  42967. export class DirectionalLight extends ShadowLight {
  42968. private _shadowFrustumSize;
  42969. /**
  42970. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42971. */
  42972. /**
  42973. * Specifies a fix frustum size for the shadow generation.
  42974. */
  42975. shadowFrustumSize: number;
  42976. private _shadowOrthoScale;
  42977. /**
  42978. * Gets the shadow projection scale against the optimal computed one.
  42979. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42980. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42981. */
  42982. /**
  42983. * Sets the shadow projection scale against the optimal computed one.
  42984. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42985. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42986. */
  42987. shadowOrthoScale: number;
  42988. /**
  42989. * Automatically compute the projection matrix to best fit (including all the casters)
  42990. * on each frame.
  42991. */
  42992. autoUpdateExtends: boolean;
  42993. private _orthoLeft;
  42994. private _orthoRight;
  42995. private _orthoTop;
  42996. private _orthoBottom;
  42997. /**
  42998. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42999. * The directional light is emitted from everywhere in the given direction.
  43000. * It can cast shadows.
  43001. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43002. * @param name The friendly name of the light
  43003. * @param direction The direction of the light
  43004. * @param scene The scene the light belongs to
  43005. */
  43006. constructor(name: string, direction: Vector3, scene: Scene);
  43007. /**
  43008. * Returns the string "DirectionalLight".
  43009. * @return The class name
  43010. */
  43011. getClassName(): string;
  43012. /**
  43013. * Returns the integer 1.
  43014. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43015. */
  43016. getTypeID(): number;
  43017. /**
  43018. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43019. * Returns the DirectionalLight Shadow projection matrix.
  43020. */
  43021. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43022. /**
  43023. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43024. * Returns the DirectionalLight Shadow projection matrix.
  43025. */
  43026. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43027. /**
  43028. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43029. * Returns the DirectionalLight Shadow projection matrix.
  43030. */
  43031. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43032. protected _buildUniformLayout(): void;
  43033. /**
  43034. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43035. * @param effect The effect to update
  43036. * @param lightIndex The index of the light in the effect to update
  43037. * @returns The directional light
  43038. */
  43039. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43040. /**
  43041. * Gets the minZ used for shadow according to both the scene and the light.
  43042. *
  43043. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43044. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43045. * @param activeCamera The camera we are returning the min for
  43046. * @returns the depth min z
  43047. */
  43048. getDepthMinZ(activeCamera: Camera): number;
  43049. /**
  43050. * Gets the maxZ used for shadow according to both the scene and the light.
  43051. *
  43052. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43053. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43054. * @param activeCamera The camera we are returning the max for
  43055. * @returns the depth max z
  43056. */
  43057. getDepthMaxZ(activeCamera: Camera): number;
  43058. /**
  43059. * Prepares the list of defines specific to the light type.
  43060. * @param defines the list of defines
  43061. * @param lightIndex defines the index of the light for the effect
  43062. */
  43063. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43064. }
  43065. }
  43066. declare module BABYLON {
  43067. /**
  43068. * Class containing static functions to help procedurally build meshes
  43069. */
  43070. export class HemisphereBuilder {
  43071. /**
  43072. * Creates a hemisphere mesh
  43073. * @param name defines the name of the mesh
  43074. * @param options defines the options used to create the mesh
  43075. * @param scene defines the hosting scene
  43076. * @returns the hemisphere mesh
  43077. */
  43078. static CreateHemisphere(name: string, options: {
  43079. segments?: number;
  43080. diameter?: number;
  43081. sideOrientation?: number;
  43082. }, scene: any): Mesh;
  43083. }
  43084. }
  43085. declare module BABYLON {
  43086. /**
  43087. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43088. * These values define a cone of light starting from the position, emitting toward the direction.
  43089. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43090. * and the exponent defines the speed of the decay of the light with distance (reach).
  43091. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43092. */
  43093. export class SpotLight extends ShadowLight {
  43094. private _angle;
  43095. private _innerAngle;
  43096. private _cosHalfAngle;
  43097. private _lightAngleScale;
  43098. private _lightAngleOffset;
  43099. /**
  43100. * Gets the cone angle of the spot light in Radians.
  43101. */
  43102. /**
  43103. * Sets the cone angle of the spot light in Radians.
  43104. */
  43105. angle: number;
  43106. /**
  43107. * Only used in gltf falloff mode, this defines the angle where
  43108. * the directional falloff will start before cutting at angle which could be seen
  43109. * as outer angle.
  43110. */
  43111. /**
  43112. * Only used in gltf falloff mode, this defines the angle where
  43113. * the directional falloff will start before cutting at angle which could be seen
  43114. * as outer angle.
  43115. */
  43116. innerAngle: number;
  43117. private _shadowAngleScale;
  43118. /**
  43119. * Allows scaling the angle of the light for shadow generation only.
  43120. */
  43121. /**
  43122. * Allows scaling the angle of the light for shadow generation only.
  43123. */
  43124. shadowAngleScale: number;
  43125. /**
  43126. * The light decay speed with the distance from the emission spot.
  43127. */
  43128. exponent: number;
  43129. private _projectionTextureMatrix;
  43130. /**
  43131. * Allows reading the projecton texture
  43132. */
  43133. readonly projectionTextureMatrix: Matrix;
  43134. protected _projectionTextureLightNear: number;
  43135. /**
  43136. * Gets the near clip of the Spotlight for texture projection.
  43137. */
  43138. /**
  43139. * Sets the near clip of the Spotlight for texture projection.
  43140. */
  43141. projectionTextureLightNear: number;
  43142. protected _projectionTextureLightFar: number;
  43143. /**
  43144. * Gets the far clip of the Spotlight for texture projection.
  43145. */
  43146. /**
  43147. * Sets the far clip of the Spotlight for texture projection.
  43148. */
  43149. projectionTextureLightFar: number;
  43150. protected _projectionTextureUpDirection: Vector3;
  43151. /**
  43152. * Gets the Up vector of the Spotlight for texture projection.
  43153. */
  43154. /**
  43155. * Sets the Up vector of the Spotlight for texture projection.
  43156. */
  43157. projectionTextureUpDirection: Vector3;
  43158. private _projectionTexture;
  43159. /**
  43160. * Gets the projection texture of the light.
  43161. */
  43162. /**
  43163. * Sets the projection texture of the light.
  43164. */
  43165. projectionTexture: Nullable<BaseTexture>;
  43166. private _projectionTextureViewLightDirty;
  43167. private _projectionTextureProjectionLightDirty;
  43168. private _projectionTextureDirty;
  43169. private _projectionTextureViewTargetVector;
  43170. private _projectionTextureViewLightMatrix;
  43171. private _projectionTextureProjectionLightMatrix;
  43172. private _projectionTextureScalingMatrix;
  43173. /**
  43174. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43175. * It can cast shadows.
  43176. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43177. * @param name The light friendly name
  43178. * @param position The position of the spot light in the scene
  43179. * @param direction The direction of the light in the scene
  43180. * @param angle The cone angle of the light in Radians
  43181. * @param exponent The light decay speed with the distance from the emission spot
  43182. * @param scene The scene the lights belongs to
  43183. */
  43184. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43185. /**
  43186. * Returns the string "SpotLight".
  43187. * @returns the class name
  43188. */
  43189. getClassName(): string;
  43190. /**
  43191. * Returns the integer 2.
  43192. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43193. */
  43194. getTypeID(): number;
  43195. /**
  43196. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43197. */
  43198. protected _setDirection(value: Vector3): void;
  43199. /**
  43200. * Overrides the position setter to recompute the projection texture view light Matrix.
  43201. */
  43202. protected _setPosition(value: Vector3): void;
  43203. /**
  43204. * 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.
  43205. * Returns the SpotLight.
  43206. */
  43207. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43208. protected _computeProjectionTextureViewLightMatrix(): void;
  43209. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43210. /**
  43211. * Main function for light texture projection matrix computing.
  43212. */
  43213. protected _computeProjectionTextureMatrix(): void;
  43214. protected _buildUniformLayout(): void;
  43215. private _computeAngleValues;
  43216. /**
  43217. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43218. * @param effect The effect to update
  43219. * @param lightIndex The index of the light in the effect to update
  43220. * @returns The spot light
  43221. */
  43222. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43223. /**
  43224. * Disposes the light and the associated resources.
  43225. */
  43226. dispose(): void;
  43227. /**
  43228. * Prepares the list of defines specific to the light type.
  43229. * @param defines the list of defines
  43230. * @param lightIndex defines the index of the light for the effect
  43231. */
  43232. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43233. }
  43234. }
  43235. declare module BABYLON {
  43236. /**
  43237. * Gizmo that enables viewing a light
  43238. */
  43239. export class LightGizmo extends Gizmo {
  43240. private _lightMesh;
  43241. private _material;
  43242. /**
  43243. * Creates a LightGizmo
  43244. * @param gizmoLayer The utility layer the gizmo will be added to
  43245. */
  43246. constructor(gizmoLayer?: UtilityLayerRenderer);
  43247. private _light;
  43248. /**
  43249. * The light that the gizmo is attached to
  43250. */
  43251. light: Nullable<Light>;
  43252. /**
  43253. * @hidden
  43254. * Updates the gizmo to match the attached mesh's position/rotation
  43255. */
  43256. protected _update(): void;
  43257. private static _Scale;
  43258. /**
  43259. * Creates the lines for a light mesh
  43260. */
  43261. private static _createLightLines;
  43262. private static _CreateHemisphericLightMesh;
  43263. private static _CreatePointLightMesh;
  43264. private static _CreateSpotLightMesh;
  43265. private static _CreateDirectionalLightMesh;
  43266. }
  43267. }
  43268. declare module BABYLON {
  43269. /** @hidden */
  43270. export var backgroundFragmentDeclaration: {
  43271. name: string;
  43272. shader: string;
  43273. };
  43274. }
  43275. declare module BABYLON {
  43276. /** @hidden */
  43277. export var backgroundUboDeclaration: {
  43278. name: string;
  43279. shader: string;
  43280. };
  43281. }
  43282. declare module BABYLON {
  43283. /** @hidden */
  43284. export var backgroundPixelShader: {
  43285. name: string;
  43286. shader: string;
  43287. };
  43288. }
  43289. declare module BABYLON {
  43290. /** @hidden */
  43291. export var backgroundVertexDeclaration: {
  43292. name: string;
  43293. shader: string;
  43294. };
  43295. }
  43296. declare module BABYLON {
  43297. /** @hidden */
  43298. export var backgroundVertexShader: {
  43299. name: string;
  43300. shader: string;
  43301. };
  43302. }
  43303. declare module BABYLON {
  43304. /**
  43305. * Background material used to create an efficient environement around your scene.
  43306. */
  43307. export class BackgroundMaterial extends PushMaterial {
  43308. /**
  43309. * Standard reflectance value at parallel view angle.
  43310. */
  43311. static StandardReflectance0: number;
  43312. /**
  43313. * Standard reflectance value at grazing angle.
  43314. */
  43315. static StandardReflectance90: number;
  43316. protected _primaryColor: Color3;
  43317. /**
  43318. * Key light Color (multiply against the environement texture)
  43319. */
  43320. primaryColor: Color3;
  43321. protected __perceptualColor: Nullable<Color3>;
  43322. /**
  43323. * Experimental Internal Use Only.
  43324. *
  43325. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43326. * This acts as a helper to set the primary color to a more "human friendly" value.
  43327. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43328. * output color as close as possible from the chosen value.
  43329. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43330. * part of lighting setup.)
  43331. */
  43332. _perceptualColor: Nullable<Color3>;
  43333. protected _primaryColorShadowLevel: float;
  43334. /**
  43335. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43336. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43337. */
  43338. primaryColorShadowLevel: float;
  43339. protected _primaryColorHighlightLevel: float;
  43340. /**
  43341. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43342. * The primary color is used at the level chosen to define what the white area would look.
  43343. */
  43344. primaryColorHighlightLevel: float;
  43345. protected _reflectionTexture: Nullable<BaseTexture>;
  43346. /**
  43347. * Reflection Texture used in the material.
  43348. * Should be author in a specific way for the best result (refer to the documentation).
  43349. */
  43350. reflectionTexture: Nullable<BaseTexture>;
  43351. protected _reflectionBlur: float;
  43352. /**
  43353. * Reflection Texture level of blur.
  43354. *
  43355. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43356. * texture twice.
  43357. */
  43358. reflectionBlur: float;
  43359. protected _diffuseTexture: Nullable<BaseTexture>;
  43360. /**
  43361. * Diffuse Texture used in the material.
  43362. * Should be author in a specific way for the best result (refer to the documentation).
  43363. */
  43364. diffuseTexture: Nullable<BaseTexture>;
  43365. protected _shadowLights: Nullable<IShadowLight[]>;
  43366. /**
  43367. * Specify the list of lights casting shadow on the material.
  43368. * All scene shadow lights will be included if null.
  43369. */
  43370. shadowLights: Nullable<IShadowLight[]>;
  43371. protected _shadowLevel: float;
  43372. /**
  43373. * Helps adjusting the shadow to a softer level if required.
  43374. * 0 means black shadows and 1 means no shadows.
  43375. */
  43376. shadowLevel: float;
  43377. protected _sceneCenter: Vector3;
  43378. /**
  43379. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43380. * It is usually zero but might be interesting to modify according to your setup.
  43381. */
  43382. sceneCenter: Vector3;
  43383. protected _opacityFresnel: boolean;
  43384. /**
  43385. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43386. * This helps ensuring a nice transition when the camera goes under the ground.
  43387. */
  43388. opacityFresnel: boolean;
  43389. protected _reflectionFresnel: boolean;
  43390. /**
  43391. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43392. * This helps adding a mirror texture on the ground.
  43393. */
  43394. reflectionFresnel: boolean;
  43395. protected _reflectionFalloffDistance: number;
  43396. /**
  43397. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43398. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43399. */
  43400. reflectionFalloffDistance: number;
  43401. protected _reflectionAmount: number;
  43402. /**
  43403. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43404. */
  43405. reflectionAmount: number;
  43406. protected _reflectionReflectance0: number;
  43407. /**
  43408. * This specifies the weight of the reflection at grazing angle.
  43409. */
  43410. reflectionReflectance0: number;
  43411. protected _reflectionReflectance90: number;
  43412. /**
  43413. * This specifies the weight of the reflection at a perpendicular point of view.
  43414. */
  43415. reflectionReflectance90: number;
  43416. /**
  43417. * Sets the reflection reflectance fresnel values according to the default standard
  43418. * empirically know to work well :-)
  43419. */
  43420. reflectionStandardFresnelWeight: number;
  43421. protected _useRGBColor: boolean;
  43422. /**
  43423. * Helps to directly use the maps channels instead of their level.
  43424. */
  43425. useRGBColor: boolean;
  43426. protected _enableNoise: boolean;
  43427. /**
  43428. * This helps reducing the banding effect that could occur on the background.
  43429. */
  43430. enableNoise: boolean;
  43431. /**
  43432. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43433. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43434. * Recommended to be keep at 1.0 except for special cases.
  43435. */
  43436. fovMultiplier: number;
  43437. private _fovMultiplier;
  43438. /**
  43439. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43440. */
  43441. useEquirectangularFOV: boolean;
  43442. private _maxSimultaneousLights;
  43443. /**
  43444. * Number of Simultaneous lights allowed on the material.
  43445. */
  43446. maxSimultaneousLights: int;
  43447. /**
  43448. * Default configuration related to image processing available in the Background Material.
  43449. */
  43450. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43451. /**
  43452. * Keep track of the image processing observer to allow dispose and replace.
  43453. */
  43454. private _imageProcessingObserver;
  43455. /**
  43456. * Attaches a new image processing configuration to the PBR Material.
  43457. * @param configuration (if null the scene configuration will be use)
  43458. */
  43459. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43460. /**
  43461. * Gets the image processing configuration used either in this material.
  43462. */
  43463. /**
  43464. * Sets the Default image processing configuration used either in the this material.
  43465. *
  43466. * If sets to null, the scene one is in use.
  43467. */
  43468. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43469. /**
  43470. * Gets wether the color curves effect is enabled.
  43471. */
  43472. /**
  43473. * Sets wether the color curves effect is enabled.
  43474. */
  43475. cameraColorCurvesEnabled: boolean;
  43476. /**
  43477. * Gets wether the color grading effect is enabled.
  43478. */
  43479. /**
  43480. * Gets wether the color grading effect is enabled.
  43481. */
  43482. cameraColorGradingEnabled: boolean;
  43483. /**
  43484. * Gets wether tonemapping is enabled or not.
  43485. */
  43486. /**
  43487. * Sets wether tonemapping is enabled or not
  43488. */
  43489. cameraToneMappingEnabled: boolean;
  43490. /**
  43491. * The camera exposure used on this material.
  43492. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43493. * This corresponds to a photographic exposure.
  43494. */
  43495. /**
  43496. * The camera exposure used on this material.
  43497. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43498. * This corresponds to a photographic exposure.
  43499. */
  43500. cameraExposure: float;
  43501. /**
  43502. * Gets The camera contrast used on this material.
  43503. */
  43504. /**
  43505. * Sets The camera contrast used on this material.
  43506. */
  43507. cameraContrast: float;
  43508. /**
  43509. * Gets the Color Grading 2D Lookup Texture.
  43510. */
  43511. /**
  43512. * Sets the Color Grading 2D Lookup Texture.
  43513. */
  43514. cameraColorGradingTexture: Nullable<BaseTexture>;
  43515. /**
  43516. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43517. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43518. * 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;
  43519. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43520. */
  43521. /**
  43522. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43523. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43524. * 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;
  43525. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43526. */
  43527. cameraColorCurves: Nullable<ColorCurves>;
  43528. /**
  43529. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43530. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43531. */
  43532. switchToBGR: boolean;
  43533. private _renderTargets;
  43534. private _reflectionControls;
  43535. private _white;
  43536. private _primaryShadowColor;
  43537. private _primaryHighlightColor;
  43538. /**
  43539. * Instantiates a Background Material in the given scene
  43540. * @param name The friendly name of the material
  43541. * @param scene The scene to add the material to
  43542. */
  43543. constructor(name: string, scene: Scene);
  43544. /**
  43545. * Gets a boolean indicating that current material needs to register RTT
  43546. */
  43547. readonly hasRenderTargetTextures: boolean;
  43548. /**
  43549. * The entire material has been created in order to prevent overdraw.
  43550. * @returns false
  43551. */
  43552. needAlphaTesting(): boolean;
  43553. /**
  43554. * The entire material has been created in order to prevent overdraw.
  43555. * @returns true if blending is enable
  43556. */
  43557. needAlphaBlending(): boolean;
  43558. /**
  43559. * Checks wether the material is ready to be rendered for a given mesh.
  43560. * @param mesh The mesh to render
  43561. * @param subMesh The submesh to check against
  43562. * @param useInstances Specify wether or not the material is used with instances
  43563. * @returns true if all the dependencies are ready (Textures, Effects...)
  43564. */
  43565. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43566. /**
  43567. * Compute the primary color according to the chosen perceptual color.
  43568. */
  43569. private _computePrimaryColorFromPerceptualColor;
  43570. /**
  43571. * Compute the highlights and shadow colors according to their chosen levels.
  43572. */
  43573. private _computePrimaryColors;
  43574. /**
  43575. * Build the uniform buffer used in the material.
  43576. */
  43577. buildUniformLayout(): void;
  43578. /**
  43579. * Unbind the material.
  43580. */
  43581. unbind(): void;
  43582. /**
  43583. * Bind only the world matrix to the material.
  43584. * @param world The world matrix to bind.
  43585. */
  43586. bindOnlyWorldMatrix(world: Matrix): void;
  43587. /**
  43588. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43589. * @param world The world matrix to bind.
  43590. * @param subMesh The submesh to bind for.
  43591. */
  43592. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43593. /**
  43594. * Dispose the material.
  43595. * @param forceDisposeEffect Force disposal of the associated effect.
  43596. * @param forceDisposeTextures Force disposal of the associated textures.
  43597. */
  43598. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43599. /**
  43600. * Clones the material.
  43601. * @param name The cloned name.
  43602. * @returns The cloned material.
  43603. */
  43604. clone(name: string): BackgroundMaterial;
  43605. /**
  43606. * Serializes the current material to its JSON representation.
  43607. * @returns The JSON representation.
  43608. */
  43609. serialize(): any;
  43610. /**
  43611. * Gets the class name of the material
  43612. * @returns "BackgroundMaterial"
  43613. */
  43614. getClassName(): string;
  43615. /**
  43616. * Parse a JSON input to create back a background material.
  43617. * @param source The JSON data to parse
  43618. * @param scene The scene to create the parsed material in
  43619. * @param rootUrl The root url of the assets the material depends upon
  43620. * @returns the instantiated BackgroundMaterial.
  43621. */
  43622. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43623. }
  43624. }
  43625. declare module BABYLON {
  43626. /**
  43627. * Represents the different options available during the creation of
  43628. * a Environment helper.
  43629. *
  43630. * This can control the default ground, skybox and image processing setup of your scene.
  43631. */
  43632. export interface IEnvironmentHelperOptions {
  43633. /**
  43634. * Specifies wether or not to create a ground.
  43635. * True by default.
  43636. */
  43637. createGround: boolean;
  43638. /**
  43639. * Specifies the ground size.
  43640. * 15 by default.
  43641. */
  43642. groundSize: number;
  43643. /**
  43644. * The texture used on the ground for the main color.
  43645. * Comes from the BabylonJS CDN by default.
  43646. *
  43647. * Remarks: Can be either a texture or a url.
  43648. */
  43649. groundTexture: string | BaseTexture;
  43650. /**
  43651. * The color mixed in the ground texture by default.
  43652. * BabylonJS clearColor by default.
  43653. */
  43654. groundColor: Color3;
  43655. /**
  43656. * Specifies the ground opacity.
  43657. * 1 by default.
  43658. */
  43659. groundOpacity: number;
  43660. /**
  43661. * Enables the ground to receive shadows.
  43662. * True by default.
  43663. */
  43664. enableGroundShadow: boolean;
  43665. /**
  43666. * Helps preventing the shadow to be fully black on the ground.
  43667. * 0.5 by default.
  43668. */
  43669. groundShadowLevel: number;
  43670. /**
  43671. * Creates a mirror texture attach to the ground.
  43672. * false by default.
  43673. */
  43674. enableGroundMirror: boolean;
  43675. /**
  43676. * Specifies the ground mirror size ratio.
  43677. * 0.3 by default as the default kernel is 64.
  43678. */
  43679. groundMirrorSizeRatio: number;
  43680. /**
  43681. * Specifies the ground mirror blur kernel size.
  43682. * 64 by default.
  43683. */
  43684. groundMirrorBlurKernel: number;
  43685. /**
  43686. * Specifies the ground mirror visibility amount.
  43687. * 1 by default
  43688. */
  43689. groundMirrorAmount: number;
  43690. /**
  43691. * Specifies the ground mirror reflectance weight.
  43692. * This uses the standard weight of the background material to setup the fresnel effect
  43693. * of the mirror.
  43694. * 1 by default.
  43695. */
  43696. groundMirrorFresnelWeight: number;
  43697. /**
  43698. * Specifies the ground mirror Falloff distance.
  43699. * This can helps reducing the size of the reflection.
  43700. * 0 by Default.
  43701. */
  43702. groundMirrorFallOffDistance: number;
  43703. /**
  43704. * Specifies the ground mirror texture type.
  43705. * Unsigned Int by Default.
  43706. */
  43707. groundMirrorTextureType: number;
  43708. /**
  43709. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43710. * the shown objects.
  43711. */
  43712. groundYBias: number;
  43713. /**
  43714. * Specifies wether or not to create a skybox.
  43715. * True by default.
  43716. */
  43717. createSkybox: boolean;
  43718. /**
  43719. * Specifies the skybox size.
  43720. * 20 by default.
  43721. */
  43722. skyboxSize: number;
  43723. /**
  43724. * The texture used on the skybox for the main color.
  43725. * Comes from the BabylonJS CDN by default.
  43726. *
  43727. * Remarks: Can be either a texture or a url.
  43728. */
  43729. skyboxTexture: string | BaseTexture;
  43730. /**
  43731. * The color mixed in the skybox texture by default.
  43732. * BabylonJS clearColor by default.
  43733. */
  43734. skyboxColor: Color3;
  43735. /**
  43736. * The background rotation around the Y axis of the scene.
  43737. * This helps aligning the key lights of your scene with the background.
  43738. * 0 by default.
  43739. */
  43740. backgroundYRotation: number;
  43741. /**
  43742. * Compute automatically the size of the elements to best fit with the scene.
  43743. */
  43744. sizeAuto: boolean;
  43745. /**
  43746. * Default position of the rootMesh if autoSize is not true.
  43747. */
  43748. rootPosition: Vector3;
  43749. /**
  43750. * Sets up the image processing in the scene.
  43751. * true by default.
  43752. */
  43753. setupImageProcessing: boolean;
  43754. /**
  43755. * The texture used as your environment texture in the scene.
  43756. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43757. *
  43758. * Remarks: Can be either a texture or a url.
  43759. */
  43760. environmentTexture: string | BaseTexture;
  43761. /**
  43762. * The value of the exposure to apply to the scene.
  43763. * 0.6 by default if setupImageProcessing is true.
  43764. */
  43765. cameraExposure: number;
  43766. /**
  43767. * The value of the contrast to apply to the scene.
  43768. * 1.6 by default if setupImageProcessing is true.
  43769. */
  43770. cameraContrast: number;
  43771. /**
  43772. * Specifies wether or not tonemapping should be enabled in the scene.
  43773. * true by default if setupImageProcessing is true.
  43774. */
  43775. toneMappingEnabled: boolean;
  43776. }
  43777. /**
  43778. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43779. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43780. * It also helps with the default setup of your imageProcessing configuration.
  43781. */
  43782. export class EnvironmentHelper {
  43783. /**
  43784. * Default ground texture URL.
  43785. */
  43786. private static _groundTextureCDNUrl;
  43787. /**
  43788. * Default skybox texture URL.
  43789. */
  43790. private static _skyboxTextureCDNUrl;
  43791. /**
  43792. * Default environment texture URL.
  43793. */
  43794. private static _environmentTextureCDNUrl;
  43795. /**
  43796. * Creates the default options for the helper.
  43797. */
  43798. private static _getDefaultOptions;
  43799. private _rootMesh;
  43800. /**
  43801. * Gets the root mesh created by the helper.
  43802. */
  43803. readonly rootMesh: Mesh;
  43804. private _skybox;
  43805. /**
  43806. * Gets the skybox created by the helper.
  43807. */
  43808. readonly skybox: Nullable<Mesh>;
  43809. private _skyboxTexture;
  43810. /**
  43811. * Gets the skybox texture created by the helper.
  43812. */
  43813. readonly skyboxTexture: Nullable<BaseTexture>;
  43814. private _skyboxMaterial;
  43815. /**
  43816. * Gets the skybox material created by the helper.
  43817. */
  43818. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43819. private _ground;
  43820. /**
  43821. * Gets the ground mesh created by the helper.
  43822. */
  43823. readonly ground: Nullable<Mesh>;
  43824. private _groundTexture;
  43825. /**
  43826. * Gets the ground texture created by the helper.
  43827. */
  43828. readonly groundTexture: Nullable<BaseTexture>;
  43829. private _groundMirror;
  43830. /**
  43831. * Gets the ground mirror created by the helper.
  43832. */
  43833. readonly groundMirror: Nullable<MirrorTexture>;
  43834. /**
  43835. * Gets the ground mirror render list to helps pushing the meshes
  43836. * you wish in the ground reflection.
  43837. */
  43838. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43839. private _groundMaterial;
  43840. /**
  43841. * Gets the ground material created by the helper.
  43842. */
  43843. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43844. /**
  43845. * Stores the creation options.
  43846. */
  43847. private readonly _scene;
  43848. private _options;
  43849. /**
  43850. * This observable will be notified with any error during the creation of the environment,
  43851. * mainly texture creation errors.
  43852. */
  43853. onErrorObservable: Observable<{
  43854. message?: string;
  43855. exception?: any;
  43856. }>;
  43857. /**
  43858. * constructor
  43859. * @param options Defines the options we want to customize the helper
  43860. * @param scene The scene to add the material to
  43861. */
  43862. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43863. /**
  43864. * Updates the background according to the new options
  43865. * @param options
  43866. */
  43867. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43868. /**
  43869. * Sets the primary color of all the available elements.
  43870. * @param color the main color to affect to the ground and the background
  43871. */
  43872. setMainColor(color: Color3): void;
  43873. /**
  43874. * Setup the image processing according to the specified options.
  43875. */
  43876. private _setupImageProcessing;
  43877. /**
  43878. * Setup the environment texture according to the specified options.
  43879. */
  43880. private _setupEnvironmentTexture;
  43881. /**
  43882. * Setup the background according to the specified options.
  43883. */
  43884. private _setupBackground;
  43885. /**
  43886. * Get the scene sizes according to the setup.
  43887. */
  43888. private _getSceneSize;
  43889. /**
  43890. * Setup the ground according to the specified options.
  43891. */
  43892. private _setupGround;
  43893. /**
  43894. * Setup the ground material according to the specified options.
  43895. */
  43896. private _setupGroundMaterial;
  43897. /**
  43898. * Setup the ground diffuse texture according to the specified options.
  43899. */
  43900. private _setupGroundDiffuseTexture;
  43901. /**
  43902. * Setup the ground mirror texture according to the specified options.
  43903. */
  43904. private _setupGroundMirrorTexture;
  43905. /**
  43906. * Setup the ground to receive the mirror texture.
  43907. */
  43908. private _setupMirrorInGroundMaterial;
  43909. /**
  43910. * Setup the skybox according to the specified options.
  43911. */
  43912. private _setupSkybox;
  43913. /**
  43914. * Setup the skybox material according to the specified options.
  43915. */
  43916. private _setupSkyboxMaterial;
  43917. /**
  43918. * Setup the skybox reflection texture according to the specified options.
  43919. */
  43920. private _setupSkyboxReflectionTexture;
  43921. private _errorHandler;
  43922. /**
  43923. * Dispose all the elements created by the Helper.
  43924. */
  43925. dispose(): void;
  43926. }
  43927. }
  43928. declare module BABYLON {
  43929. /**
  43930. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43931. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43932. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43933. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43934. */
  43935. export class PhotoDome extends TransformNode {
  43936. private _useDirectMapping;
  43937. /**
  43938. * The texture being displayed on the sphere
  43939. */
  43940. protected _photoTexture: Texture;
  43941. /**
  43942. * Gets or sets the texture being displayed on the sphere
  43943. */
  43944. photoTexture: Texture;
  43945. /**
  43946. * Observable raised when an error occured while loading the 360 image
  43947. */
  43948. onLoadErrorObservable: Observable<string>;
  43949. /**
  43950. * The skybox material
  43951. */
  43952. protected _material: BackgroundMaterial;
  43953. /**
  43954. * The surface used for the skybox
  43955. */
  43956. protected _mesh: Mesh;
  43957. /**
  43958. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43959. * Also see the options.resolution property.
  43960. */
  43961. fovMultiplier: number;
  43962. /**
  43963. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43964. * @param name Element's name, child elements will append suffixes for their own names.
  43965. * @param urlsOfPhoto defines the url of the photo to display
  43966. * @param options defines an object containing optional or exposed sub element properties
  43967. * @param onError defines a callback called when an error occured while loading the texture
  43968. */
  43969. constructor(name: string, urlOfPhoto: string, options: {
  43970. resolution?: number;
  43971. size?: number;
  43972. useDirectMapping?: boolean;
  43973. faceForward?: boolean;
  43974. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43975. /**
  43976. * Releases resources associated with this node.
  43977. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43978. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43979. */
  43980. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43981. }
  43982. }
  43983. declare module BABYLON {
  43984. /** @hidden */
  43985. export var rgbdDecodePixelShader: {
  43986. name: string;
  43987. shader: string;
  43988. };
  43989. }
  43990. declare module BABYLON {
  43991. /**
  43992. * Class used to host texture specific utilities
  43993. */
  43994. export class BRDFTextureTools {
  43995. /**
  43996. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43997. * @param texture the texture to expand.
  43998. */
  43999. private static _ExpandDefaultBRDFTexture;
  44000. /**
  44001. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44002. * @param scene defines the hosting scene
  44003. * @returns the environment BRDF texture
  44004. */
  44005. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44006. private static _environmentBRDFBase64Texture;
  44007. }
  44008. }
  44009. declare module BABYLON {
  44010. /**
  44011. * @hidden
  44012. */
  44013. export interface IMaterialClearCoatDefines {
  44014. CLEARCOAT: boolean;
  44015. CLEARCOAT_DEFAULTIOR: boolean;
  44016. CLEARCOAT_TEXTURE: boolean;
  44017. CLEARCOAT_TEXTUREDIRECTUV: number;
  44018. CLEARCOAT_BUMP: boolean;
  44019. CLEARCOAT_BUMPDIRECTUV: number;
  44020. CLEARCOAT_TINT: boolean;
  44021. CLEARCOAT_TINT_TEXTURE: boolean;
  44022. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44023. /** @hidden */
  44024. _areTexturesDirty: boolean;
  44025. }
  44026. /**
  44027. * Define the code related to the clear coat parameters of the pbr material.
  44028. */
  44029. export class PBRClearCoatConfiguration {
  44030. /**
  44031. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44032. * The default fits with a polyurethane material.
  44033. */
  44034. private static readonly _DefaultIndiceOfRefraction;
  44035. private _isEnabled;
  44036. /**
  44037. * Defines if the clear coat is enabled in the material.
  44038. */
  44039. isEnabled: boolean;
  44040. /**
  44041. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44042. */
  44043. intensity: number;
  44044. /**
  44045. * Defines the clear coat layer roughness.
  44046. */
  44047. roughness: number;
  44048. private _indiceOfRefraction;
  44049. /**
  44050. * Defines the indice of refraction of the clear coat.
  44051. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44052. * The default fits with a polyurethane material.
  44053. * Changing the default value is more performance intensive.
  44054. */
  44055. indiceOfRefraction: number;
  44056. private _texture;
  44057. /**
  44058. * Stores the clear coat values in a texture.
  44059. */
  44060. texture: Nullable<BaseTexture>;
  44061. private _bumpTexture;
  44062. /**
  44063. * Define the clear coat specific bump texture.
  44064. */
  44065. bumpTexture: Nullable<BaseTexture>;
  44066. private _isTintEnabled;
  44067. /**
  44068. * Defines if the clear coat tint is enabled in the material.
  44069. */
  44070. isTintEnabled: boolean;
  44071. /**
  44072. * Defines the clear coat tint of the material.
  44073. * This is only use if tint is enabled
  44074. */
  44075. tintColor: Color3;
  44076. /**
  44077. * Defines the distance at which the tint color should be found in the
  44078. * clear coat media.
  44079. * This is only use if tint is enabled
  44080. */
  44081. tintColorAtDistance: number;
  44082. /**
  44083. * Defines the clear coat layer thickness.
  44084. * This is only use if tint is enabled
  44085. */
  44086. tintThickness: number;
  44087. private _tintTexture;
  44088. /**
  44089. * Stores the clear tint values in a texture.
  44090. * rgb is tint
  44091. * a is a thickness factor
  44092. */
  44093. tintTexture: Nullable<BaseTexture>;
  44094. /** @hidden */
  44095. private _internalMarkAllSubMeshesAsTexturesDirty;
  44096. /** @hidden */
  44097. _markAllSubMeshesAsTexturesDirty(): void;
  44098. /**
  44099. * Instantiate a new istance of clear coat configuration.
  44100. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44101. */
  44102. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44103. /**
  44104. * Gets wehter the submesh is ready to be used or not.
  44105. * @param defines the list of "defines" to update.
  44106. * @param scene defines the scene the material belongs to.
  44107. * @param engine defines the engine the material belongs to.
  44108. * @param disableBumpMap defines wether the material disables bump or not.
  44109. * @returns - boolean indicating that the submesh is ready or not.
  44110. */
  44111. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44112. /**
  44113. * Checks to see if a texture is used in the material.
  44114. * @param defines the list of "defines" to update.
  44115. * @param scene defines the scene to the material belongs to.
  44116. */
  44117. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44118. /**
  44119. * Binds the material data.
  44120. * @param uniformBuffer defines the Uniform buffer to fill in.
  44121. * @param scene defines the scene the material belongs to.
  44122. * @param engine defines the engine the material belongs to.
  44123. * @param disableBumpMap defines wether the material disables bump or not.
  44124. * @param isFrozen defines wether the material is frozen or not.
  44125. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44126. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44127. */
  44128. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44129. /**
  44130. * Checks to see if a texture is used in the material.
  44131. * @param texture - Base texture to use.
  44132. * @returns - Boolean specifying if a texture is used in the material.
  44133. */
  44134. hasTexture(texture: BaseTexture): boolean;
  44135. /**
  44136. * Returns an array of the actively used textures.
  44137. * @param activeTextures Array of BaseTextures
  44138. */
  44139. getActiveTextures(activeTextures: BaseTexture[]): void;
  44140. /**
  44141. * Returns the animatable textures.
  44142. * @param animatables Array of animatable textures.
  44143. */
  44144. getAnimatables(animatables: IAnimatable[]): void;
  44145. /**
  44146. * Disposes the resources of the material.
  44147. * @param forceDisposeTextures - Forces the disposal of all textures.
  44148. */
  44149. dispose(forceDisposeTextures?: boolean): void;
  44150. /**
  44151. * Get the current class name of the texture useful for serialization or dynamic coding.
  44152. * @returns "PBRClearCoatConfiguration"
  44153. */
  44154. getClassName(): string;
  44155. /**
  44156. * Add fallbacks to the effect fallbacks list.
  44157. * @param defines defines the Base texture to use.
  44158. * @param fallbacks defines the current fallback list.
  44159. * @param currentRank defines the current fallback rank.
  44160. * @returns the new fallback rank.
  44161. */
  44162. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44163. /**
  44164. * Add the required uniforms to the current list.
  44165. * @param uniforms defines the current uniform list.
  44166. */
  44167. static AddUniforms(uniforms: string[]): void;
  44168. /**
  44169. * Add the required samplers to the current list.
  44170. * @param samplers defines the current sampler list.
  44171. */
  44172. static AddSamplers(samplers: string[]): void;
  44173. /**
  44174. * Add the required uniforms to the current buffer.
  44175. * @param uniformBuffer defines the current uniform buffer.
  44176. */
  44177. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44178. /**
  44179. * Makes a duplicate of the current configuration into another one.
  44180. * @param clearCoatConfiguration define the config where to copy the info
  44181. */
  44182. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44183. /**
  44184. * Serializes this clear coat configuration.
  44185. * @returns - An object with the serialized config.
  44186. */
  44187. serialize(): any;
  44188. /**
  44189. * Parses a Clear Coat Configuration from a serialized object.
  44190. * @param source - Serialized object.
  44191. */
  44192. parse(source: any): void;
  44193. }
  44194. }
  44195. declare module BABYLON {
  44196. /**
  44197. * @hidden
  44198. */
  44199. export interface IMaterialAnisotropicDefines {
  44200. ANISOTROPIC: boolean;
  44201. ANISOTROPIC_TEXTURE: boolean;
  44202. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44203. MAINUV1: boolean;
  44204. _areTexturesDirty: boolean;
  44205. _needUVs: boolean;
  44206. }
  44207. /**
  44208. * Define the code related to the anisotropic parameters of the pbr material.
  44209. */
  44210. export class PBRAnisotropicConfiguration {
  44211. private _isEnabled;
  44212. /**
  44213. * Defines if the anisotropy is enabled in the material.
  44214. */
  44215. isEnabled: boolean;
  44216. /**
  44217. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44218. */
  44219. intensity: number;
  44220. /**
  44221. * Defines if the effect is along the tangents, bitangents or in between.
  44222. * By default, the effect is "strectching" the highlights along the tangents.
  44223. */
  44224. direction: Vector2;
  44225. private _texture;
  44226. /**
  44227. * Stores the anisotropy values in a texture.
  44228. * rg is direction (like normal from -1 to 1)
  44229. * b is a intensity
  44230. */
  44231. texture: Nullable<BaseTexture>;
  44232. /** @hidden */
  44233. private _internalMarkAllSubMeshesAsTexturesDirty;
  44234. /** @hidden */
  44235. _markAllSubMeshesAsTexturesDirty(): void;
  44236. /**
  44237. * Instantiate a new istance of anisotropy configuration.
  44238. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44239. */
  44240. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44241. /**
  44242. * Specifies that the submesh is ready to be used.
  44243. * @param defines the list of "defines" to update.
  44244. * @param scene defines the scene the material belongs to.
  44245. * @returns - boolean indicating that the submesh is ready or not.
  44246. */
  44247. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44248. /**
  44249. * Checks to see if a texture is used in the material.
  44250. * @param defines the list of "defines" to update.
  44251. * @param mesh the mesh we are preparing the defines for.
  44252. * @param scene defines the scene the material belongs to.
  44253. */
  44254. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44255. /**
  44256. * Binds the material data.
  44257. * @param uniformBuffer defines the Uniform buffer to fill in.
  44258. * @param scene defines the scene the material belongs to.
  44259. * @param isFrozen defines wether the material is frozen or not.
  44260. */
  44261. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44262. /**
  44263. * Checks to see if a texture is used in the material.
  44264. * @param texture - Base texture to use.
  44265. * @returns - Boolean specifying if a texture is used in the material.
  44266. */
  44267. hasTexture(texture: BaseTexture): boolean;
  44268. /**
  44269. * Returns an array of the actively used textures.
  44270. * @param activeTextures Array of BaseTextures
  44271. */
  44272. getActiveTextures(activeTextures: BaseTexture[]): void;
  44273. /**
  44274. * Returns the animatable textures.
  44275. * @param animatables Array of animatable textures.
  44276. */
  44277. getAnimatables(animatables: IAnimatable[]): void;
  44278. /**
  44279. * Disposes the resources of the material.
  44280. * @param forceDisposeTextures - Forces the disposal of all textures.
  44281. */
  44282. dispose(forceDisposeTextures?: boolean): void;
  44283. /**
  44284. * Get the current class name of the texture useful for serialization or dynamic coding.
  44285. * @returns "PBRAnisotropicConfiguration"
  44286. */
  44287. getClassName(): string;
  44288. /**
  44289. * Add fallbacks to the effect fallbacks list.
  44290. * @param defines defines the Base texture to use.
  44291. * @param fallbacks defines the current fallback list.
  44292. * @param currentRank defines the current fallback rank.
  44293. * @returns the new fallback rank.
  44294. */
  44295. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44296. /**
  44297. * Add the required uniforms to the current list.
  44298. * @param uniforms defines the current uniform list.
  44299. */
  44300. static AddUniforms(uniforms: string[]): void;
  44301. /**
  44302. * Add the required uniforms to the current buffer.
  44303. * @param uniformBuffer defines the current uniform buffer.
  44304. */
  44305. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44306. /**
  44307. * Add the required samplers to the current list.
  44308. * @param samplers defines the current sampler list.
  44309. */
  44310. static AddSamplers(samplers: string[]): void;
  44311. /**
  44312. * Makes a duplicate of the current configuration into another one.
  44313. * @param anisotropicConfiguration define the config where to copy the info
  44314. */
  44315. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44316. /**
  44317. * Serializes this anisotropy configuration.
  44318. * @returns - An object with the serialized config.
  44319. */
  44320. serialize(): any;
  44321. /**
  44322. * Parses a anisotropy Configuration from a serialized object.
  44323. * @param source - Serialized object.
  44324. */
  44325. parse(source: any): void;
  44326. }
  44327. }
  44328. declare module BABYLON {
  44329. /**
  44330. * @hidden
  44331. */
  44332. export interface IMaterialBRDFDefines {
  44333. BRDF_V_HEIGHT_CORRELATED: boolean;
  44334. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44335. SPHERICAL_HARMONICS: boolean;
  44336. /** @hidden */
  44337. _areMiscDirty: boolean;
  44338. }
  44339. /**
  44340. * Define the code related to the BRDF parameters of the pbr material.
  44341. */
  44342. export class PBRBRDFConfiguration {
  44343. /**
  44344. * Default value used for the energy conservation.
  44345. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44346. */
  44347. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44348. /**
  44349. * Default value used for the Smith Visibility Height Correlated mode.
  44350. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44351. */
  44352. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44353. /**
  44354. * Default value used for the IBL diffuse part.
  44355. * This can help switching back to the polynomials mode globally which is a tiny bit
  44356. * less GPU intensive at the drawback of a lower quality.
  44357. */
  44358. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44359. private _useEnergyConservation;
  44360. /**
  44361. * Defines if the material uses energy conservation.
  44362. */
  44363. useEnergyConservation: boolean;
  44364. private _useSmithVisibilityHeightCorrelated;
  44365. /**
  44366. * LEGACY Mode set to false
  44367. * Defines if the material uses height smith correlated visibility term.
  44368. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44369. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44370. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44371. * Not relying on height correlated will also disable energy conservation.
  44372. */
  44373. useSmithVisibilityHeightCorrelated: boolean;
  44374. private _useSphericalHarmonics;
  44375. /**
  44376. * LEGACY Mode set to false
  44377. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44378. * diffuse part of the IBL.
  44379. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44380. * to the ground truth.
  44381. */
  44382. useSphericalHarmonics: boolean;
  44383. /** @hidden */
  44384. private _internalMarkAllSubMeshesAsMiscDirty;
  44385. /** @hidden */
  44386. _markAllSubMeshesAsMiscDirty(): void;
  44387. /**
  44388. * Instantiate a new istance of clear coat configuration.
  44389. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44390. */
  44391. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44392. /**
  44393. * Checks to see if a texture is used in the material.
  44394. * @param defines the list of "defines" to update.
  44395. */
  44396. prepareDefines(defines: IMaterialBRDFDefines): void;
  44397. /**
  44398. * Get the current class name of the texture useful for serialization or dynamic coding.
  44399. * @returns "PBRClearCoatConfiguration"
  44400. */
  44401. getClassName(): string;
  44402. /**
  44403. * Makes a duplicate of the current configuration into another one.
  44404. * @param brdfConfiguration define the config where to copy the info
  44405. */
  44406. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44407. /**
  44408. * Serializes this BRDF configuration.
  44409. * @returns - An object with the serialized config.
  44410. */
  44411. serialize(): any;
  44412. /**
  44413. * Parses a BRDF Configuration from a serialized object.
  44414. * @param source - Serialized object.
  44415. */
  44416. parse(source: any): void;
  44417. }
  44418. }
  44419. declare module BABYLON {
  44420. /**
  44421. * @hidden
  44422. */
  44423. export interface IMaterialSheenDefines {
  44424. SHEEN: boolean;
  44425. SHEEN_TEXTURE: boolean;
  44426. SHEEN_TEXTUREDIRECTUV: number;
  44427. SHEEN_LINKWITHALBEDO: boolean;
  44428. /** @hidden */
  44429. _areTexturesDirty: boolean;
  44430. }
  44431. /**
  44432. * Define the code related to the Sheen parameters of the pbr material.
  44433. */
  44434. export class PBRSheenConfiguration {
  44435. private _isEnabled;
  44436. /**
  44437. * Defines if the material uses sheen.
  44438. */
  44439. isEnabled: boolean;
  44440. private _linkSheenWithAlbedo;
  44441. /**
  44442. * Defines if the sheen is linked to the sheen color.
  44443. */
  44444. linkSheenWithAlbedo: boolean;
  44445. /**
  44446. * Defines the sheen intensity.
  44447. */
  44448. intensity: number;
  44449. /**
  44450. * Defines the sheen color.
  44451. */
  44452. color: Color3;
  44453. private _texture;
  44454. /**
  44455. * Stores the sheen tint values in a texture.
  44456. * rgb is tint
  44457. * a is a intensity
  44458. */
  44459. texture: Nullable<BaseTexture>;
  44460. /** @hidden */
  44461. private _internalMarkAllSubMeshesAsTexturesDirty;
  44462. /** @hidden */
  44463. _markAllSubMeshesAsTexturesDirty(): void;
  44464. /**
  44465. * Instantiate a new istance of clear coat configuration.
  44466. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44467. */
  44468. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44469. /**
  44470. * Specifies that the submesh is ready to be used.
  44471. * @param defines the list of "defines" to update.
  44472. * @param scene defines the scene the material belongs to.
  44473. * @returns - boolean indicating that the submesh is ready or not.
  44474. */
  44475. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44476. /**
  44477. * Checks to see if a texture is used in the material.
  44478. * @param defines the list of "defines" to update.
  44479. * @param scene defines the scene the material belongs to.
  44480. */
  44481. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44482. /**
  44483. * Binds the material data.
  44484. * @param uniformBuffer defines the Uniform buffer to fill in.
  44485. * @param scene defines the scene the material belongs to.
  44486. * @param isFrozen defines wether the material is frozen or not.
  44487. */
  44488. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44489. /**
  44490. * Checks to see if a texture is used in the material.
  44491. * @param texture - Base texture to use.
  44492. * @returns - Boolean specifying if a texture is used in the material.
  44493. */
  44494. hasTexture(texture: BaseTexture): boolean;
  44495. /**
  44496. * Returns an array of the actively used textures.
  44497. * @param activeTextures Array of BaseTextures
  44498. */
  44499. getActiveTextures(activeTextures: BaseTexture[]): void;
  44500. /**
  44501. * Returns the animatable textures.
  44502. * @param animatables Array of animatable textures.
  44503. */
  44504. getAnimatables(animatables: IAnimatable[]): void;
  44505. /**
  44506. * Disposes the resources of the material.
  44507. * @param forceDisposeTextures - Forces the disposal of all textures.
  44508. */
  44509. dispose(forceDisposeTextures?: boolean): void;
  44510. /**
  44511. * Get the current class name of the texture useful for serialization or dynamic coding.
  44512. * @returns "PBRSheenConfiguration"
  44513. */
  44514. getClassName(): string;
  44515. /**
  44516. * Add fallbacks to the effect fallbacks list.
  44517. * @param defines defines the Base texture to use.
  44518. * @param fallbacks defines the current fallback list.
  44519. * @param currentRank defines the current fallback rank.
  44520. * @returns the new fallback rank.
  44521. */
  44522. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44523. /**
  44524. * Add the required uniforms to the current list.
  44525. * @param uniforms defines the current uniform list.
  44526. */
  44527. static AddUniforms(uniforms: string[]): void;
  44528. /**
  44529. * Add the required uniforms to the current buffer.
  44530. * @param uniformBuffer defines the current uniform buffer.
  44531. */
  44532. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44533. /**
  44534. * Add the required samplers to the current list.
  44535. * @param samplers defines the current sampler list.
  44536. */
  44537. static AddSamplers(samplers: string[]): void;
  44538. /**
  44539. * Makes a duplicate of the current configuration into another one.
  44540. * @param sheenConfiguration define the config where to copy the info
  44541. */
  44542. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44543. /**
  44544. * Serializes this BRDF configuration.
  44545. * @returns - An object with the serialized config.
  44546. */
  44547. serialize(): any;
  44548. /**
  44549. * Parses a Sheen Configuration from a serialized object.
  44550. * @param source - Serialized object.
  44551. */
  44552. parse(source: any): void;
  44553. }
  44554. }
  44555. declare module BABYLON {
  44556. /**
  44557. * @hidden
  44558. */
  44559. export interface IMaterialSubSurfaceDefines {
  44560. SUBSURFACE: boolean;
  44561. SS_REFRACTION: boolean;
  44562. SS_TRANSLUCENCY: boolean;
  44563. SS_SCATERRING: boolean;
  44564. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44565. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44566. SS_REFRACTIONMAP_3D: boolean;
  44567. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44568. SS_LODINREFRACTIONALPHA: boolean;
  44569. SS_GAMMAREFRACTION: boolean;
  44570. SS_RGBDREFRACTION: boolean;
  44571. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44572. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44573. /** @hidden */
  44574. _areTexturesDirty: boolean;
  44575. }
  44576. /**
  44577. * Define the code related to the sub surface parameters of the pbr material.
  44578. */
  44579. export class PBRSubSurfaceConfiguration {
  44580. private _isRefractionEnabled;
  44581. /**
  44582. * Defines if the refraction is enabled in the material.
  44583. */
  44584. isRefractionEnabled: boolean;
  44585. private _isTranslucencyEnabled;
  44586. /**
  44587. * Defines if the translucency is enabled in the material.
  44588. */
  44589. isTranslucencyEnabled: boolean;
  44590. private _isScatteringEnabled;
  44591. /**
  44592. * Defines the refraction intensity of the material.
  44593. * The refraction when enabled replaces the Diffuse part of the material.
  44594. * The intensity helps transitionning between diffuse and refraction.
  44595. */
  44596. refractionIntensity: number;
  44597. /**
  44598. * Defines the translucency intensity of the material.
  44599. * When translucency has been enabled, this defines how much of the "translucency"
  44600. * is addded to the diffuse part of the material.
  44601. */
  44602. translucencyIntensity: number;
  44603. /**
  44604. * Defines the scattering intensity of the material.
  44605. * When scattering has been enabled, this defines how much of the "scattered light"
  44606. * is addded to the diffuse part of the material.
  44607. */
  44608. scatteringIntensity: number;
  44609. private _thicknessTexture;
  44610. /**
  44611. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44612. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44613. * 0 would mean minimumThickness
  44614. * 1 would mean maximumThickness
  44615. * The other channels might be use as a mask to vary the different effects intensity.
  44616. */
  44617. thicknessTexture: Nullable<BaseTexture>;
  44618. private _refractionTexture;
  44619. /**
  44620. * Defines the texture to use for refraction.
  44621. */
  44622. refractionTexture: Nullable<BaseTexture>;
  44623. private _indexOfRefraction;
  44624. /**
  44625. * Defines the indice of refraction used in the material.
  44626. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44627. */
  44628. indexOfRefraction: number;
  44629. private _invertRefractionY;
  44630. /**
  44631. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44632. */
  44633. invertRefractionY: boolean;
  44634. private _linkRefractionWithTransparency;
  44635. /**
  44636. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44637. * Materials half opaque for instance using refraction could benefit from this control.
  44638. */
  44639. linkRefractionWithTransparency: boolean;
  44640. /**
  44641. * Defines the minimum thickness stored in the thickness map.
  44642. * If no thickness map is defined, this value will be used to simulate thickness.
  44643. */
  44644. minimumThickness: number;
  44645. /**
  44646. * Defines the maximum thickness stored in the thickness map.
  44647. */
  44648. maximumThickness: number;
  44649. /**
  44650. * Defines the volume tint of the material.
  44651. * This is used for both translucency and scattering.
  44652. */
  44653. tintColor: Color3;
  44654. /**
  44655. * Defines the distance at which the tint color should be found in the media.
  44656. * This is used for refraction only.
  44657. */
  44658. tintColorAtDistance: number;
  44659. /**
  44660. * Defines how far each channel transmit through the media.
  44661. * It is defined as a color to simplify it selection.
  44662. */
  44663. diffusionDistance: Color3;
  44664. private _useMaskFromThicknessTexture;
  44665. /**
  44666. * Stores the intensity of the different subsurface effects in the thickness texture.
  44667. * * the green channel is the translucency intensity.
  44668. * * the blue channel is the scattering intensity.
  44669. * * the alpha channel is the refraction intensity.
  44670. */
  44671. useMaskFromThicknessTexture: boolean;
  44672. /** @hidden */
  44673. private _internalMarkAllSubMeshesAsTexturesDirty;
  44674. /** @hidden */
  44675. _markAllSubMeshesAsTexturesDirty(): void;
  44676. /**
  44677. * Instantiate a new istance of sub surface configuration.
  44678. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44679. */
  44680. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44681. /**
  44682. * Gets wehter the submesh is ready to be used or not.
  44683. * @param defines the list of "defines" to update.
  44684. * @param scene defines the scene the material belongs to.
  44685. * @returns - boolean indicating that the submesh is ready or not.
  44686. */
  44687. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44688. /**
  44689. * Checks to see if a texture is used in the material.
  44690. * @param defines the list of "defines" to update.
  44691. * @param scene defines the scene to the material belongs to.
  44692. */
  44693. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44694. /**
  44695. * Binds the material data.
  44696. * @param uniformBuffer defines the Uniform buffer to fill in.
  44697. * @param scene defines the scene the material belongs to.
  44698. * @param engine defines the engine the material belongs to.
  44699. * @param isFrozen defines wether the material is frozen or not.
  44700. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44701. */
  44702. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44703. /**
  44704. * Unbinds the material from the mesh.
  44705. * @param activeEffect defines the effect that should be unbound from.
  44706. * @returns true if unbound, otherwise false
  44707. */
  44708. unbind(activeEffect: Effect): boolean;
  44709. /**
  44710. * Returns the texture used for refraction or null if none is used.
  44711. * @param scene defines the scene the material belongs to.
  44712. * @returns - Refraction texture if present. If no refraction texture and refraction
  44713. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44714. */
  44715. private _getRefractionTexture;
  44716. /**
  44717. * Returns true if alpha blending should be disabled.
  44718. */
  44719. readonly disableAlphaBlending: boolean;
  44720. /**
  44721. * Fills the list of render target textures.
  44722. * @param renderTargets the list of render targets to update
  44723. */
  44724. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44725. /**
  44726. * Checks to see if a texture is used in the material.
  44727. * @param texture - Base texture to use.
  44728. * @returns - Boolean specifying if a texture is used in the material.
  44729. */
  44730. hasTexture(texture: BaseTexture): boolean;
  44731. /**
  44732. * Gets a boolean indicating that current material needs to register RTT
  44733. * @returns true if this uses a render target otherwise false.
  44734. */
  44735. hasRenderTargetTextures(): boolean;
  44736. /**
  44737. * Returns an array of the actively used textures.
  44738. * @param activeTextures Array of BaseTextures
  44739. */
  44740. getActiveTextures(activeTextures: BaseTexture[]): void;
  44741. /**
  44742. * Returns the animatable textures.
  44743. * @param animatables Array of animatable textures.
  44744. */
  44745. getAnimatables(animatables: IAnimatable[]): void;
  44746. /**
  44747. * Disposes the resources of the material.
  44748. * @param forceDisposeTextures - Forces the disposal of all textures.
  44749. */
  44750. dispose(forceDisposeTextures?: boolean): void;
  44751. /**
  44752. * Get the current class name of the texture useful for serialization or dynamic coding.
  44753. * @returns "PBRSubSurfaceConfiguration"
  44754. */
  44755. getClassName(): string;
  44756. /**
  44757. * Add fallbacks to the effect fallbacks list.
  44758. * @param defines defines the Base texture to use.
  44759. * @param fallbacks defines the current fallback list.
  44760. * @param currentRank defines the current fallback rank.
  44761. * @returns the new fallback rank.
  44762. */
  44763. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44764. /**
  44765. * Add the required uniforms to the current list.
  44766. * @param uniforms defines the current uniform list.
  44767. */
  44768. static AddUniforms(uniforms: string[]): void;
  44769. /**
  44770. * Add the required samplers to the current list.
  44771. * @param samplers defines the current sampler list.
  44772. */
  44773. static AddSamplers(samplers: string[]): void;
  44774. /**
  44775. * Add the required uniforms to the current buffer.
  44776. * @param uniformBuffer defines the current uniform buffer.
  44777. */
  44778. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44779. /**
  44780. * Makes a duplicate of the current configuration into another one.
  44781. * @param configuration define the config where to copy the info
  44782. */
  44783. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44784. /**
  44785. * Serializes this Sub Surface configuration.
  44786. * @returns - An object with the serialized config.
  44787. */
  44788. serialize(): any;
  44789. /**
  44790. * Parses a Sub Surface Configuration from a serialized object.
  44791. * @param source - Serialized object.
  44792. */
  44793. parse(source: any): void;
  44794. }
  44795. }
  44796. declare module BABYLON {
  44797. /** @hidden */
  44798. export var pbrFragmentDeclaration: {
  44799. name: string;
  44800. shader: string;
  44801. };
  44802. }
  44803. declare module BABYLON {
  44804. /** @hidden */
  44805. export var pbrUboDeclaration: {
  44806. name: string;
  44807. shader: string;
  44808. };
  44809. }
  44810. declare module BABYLON {
  44811. /** @hidden */
  44812. export var pbrFragmentExtraDeclaration: {
  44813. name: string;
  44814. shader: string;
  44815. };
  44816. }
  44817. declare module BABYLON {
  44818. /** @hidden */
  44819. export var pbrFragmentSamplersDeclaration: {
  44820. name: string;
  44821. shader: string;
  44822. };
  44823. }
  44824. declare module BABYLON {
  44825. /** @hidden */
  44826. export var pbrHelperFunctions: {
  44827. name: string;
  44828. shader: string;
  44829. };
  44830. }
  44831. declare module BABYLON {
  44832. /** @hidden */
  44833. export var harmonicsFunctions: {
  44834. name: string;
  44835. shader: string;
  44836. };
  44837. }
  44838. declare module BABYLON {
  44839. /** @hidden */
  44840. export var pbrDirectLightingSetupFunctions: {
  44841. name: string;
  44842. shader: string;
  44843. };
  44844. }
  44845. declare module BABYLON {
  44846. /** @hidden */
  44847. export var pbrDirectLightingFalloffFunctions: {
  44848. name: string;
  44849. shader: string;
  44850. };
  44851. }
  44852. declare module BABYLON {
  44853. /** @hidden */
  44854. export var pbrBRDFFunctions: {
  44855. name: string;
  44856. shader: string;
  44857. };
  44858. }
  44859. declare module BABYLON {
  44860. /** @hidden */
  44861. export var pbrDirectLightingFunctions: {
  44862. name: string;
  44863. shader: string;
  44864. };
  44865. }
  44866. declare module BABYLON {
  44867. /** @hidden */
  44868. export var pbrIBLFunctions: {
  44869. name: string;
  44870. shader: string;
  44871. };
  44872. }
  44873. declare module BABYLON {
  44874. /** @hidden */
  44875. export var pbrDebug: {
  44876. name: string;
  44877. shader: string;
  44878. };
  44879. }
  44880. declare module BABYLON {
  44881. /** @hidden */
  44882. export var pbrPixelShader: {
  44883. name: string;
  44884. shader: string;
  44885. };
  44886. }
  44887. declare module BABYLON {
  44888. /** @hidden */
  44889. export var pbrVertexDeclaration: {
  44890. name: string;
  44891. shader: string;
  44892. };
  44893. }
  44894. declare module BABYLON {
  44895. /** @hidden */
  44896. export var pbrVertexShader: {
  44897. name: string;
  44898. shader: string;
  44899. };
  44900. }
  44901. declare module BABYLON {
  44902. /**
  44903. * Manages the defines for the PBR Material.
  44904. * @hidden
  44905. */
  44906. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44907. PBR: boolean;
  44908. MAINUV1: boolean;
  44909. MAINUV2: boolean;
  44910. UV1: boolean;
  44911. UV2: boolean;
  44912. ALBEDO: boolean;
  44913. ALBEDODIRECTUV: number;
  44914. VERTEXCOLOR: boolean;
  44915. AMBIENT: boolean;
  44916. AMBIENTDIRECTUV: number;
  44917. AMBIENTINGRAYSCALE: boolean;
  44918. OPACITY: boolean;
  44919. VERTEXALPHA: boolean;
  44920. OPACITYDIRECTUV: number;
  44921. OPACITYRGB: boolean;
  44922. ALPHATEST: boolean;
  44923. DEPTHPREPASS: boolean;
  44924. ALPHABLEND: boolean;
  44925. ALPHAFROMALBEDO: boolean;
  44926. ALPHATESTVALUE: string;
  44927. SPECULAROVERALPHA: boolean;
  44928. RADIANCEOVERALPHA: boolean;
  44929. ALPHAFRESNEL: boolean;
  44930. LINEARALPHAFRESNEL: boolean;
  44931. PREMULTIPLYALPHA: boolean;
  44932. EMISSIVE: boolean;
  44933. EMISSIVEDIRECTUV: number;
  44934. REFLECTIVITY: boolean;
  44935. REFLECTIVITYDIRECTUV: number;
  44936. SPECULARTERM: boolean;
  44937. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44938. MICROSURFACEAUTOMATIC: boolean;
  44939. LODBASEDMICROSFURACE: boolean;
  44940. MICROSURFACEMAP: boolean;
  44941. MICROSURFACEMAPDIRECTUV: number;
  44942. METALLICWORKFLOW: boolean;
  44943. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44944. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44945. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44946. AOSTOREINMETALMAPRED: boolean;
  44947. ENVIRONMENTBRDF: boolean;
  44948. ENVIRONMENTBRDF_RGBD: boolean;
  44949. NORMAL: boolean;
  44950. TANGENT: boolean;
  44951. BUMP: boolean;
  44952. BUMPDIRECTUV: number;
  44953. OBJECTSPACE_NORMALMAP: boolean;
  44954. PARALLAX: boolean;
  44955. PARALLAXOCCLUSION: boolean;
  44956. NORMALXYSCALE: boolean;
  44957. LIGHTMAP: boolean;
  44958. LIGHTMAPDIRECTUV: number;
  44959. USELIGHTMAPASSHADOWMAP: boolean;
  44960. GAMMALIGHTMAP: boolean;
  44961. REFLECTION: boolean;
  44962. REFLECTIONMAP_3D: boolean;
  44963. REFLECTIONMAP_SPHERICAL: boolean;
  44964. REFLECTIONMAP_PLANAR: boolean;
  44965. REFLECTIONMAP_CUBIC: boolean;
  44966. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44967. REFLECTIONMAP_PROJECTION: boolean;
  44968. REFLECTIONMAP_SKYBOX: boolean;
  44969. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44970. REFLECTIONMAP_EXPLICIT: boolean;
  44971. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44972. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44973. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44974. INVERTCUBICMAP: boolean;
  44975. USESPHERICALFROMREFLECTIONMAP: boolean;
  44976. SPHERICAL_HARMONICS: boolean;
  44977. USESPHERICALINVERTEX: boolean;
  44978. REFLECTIONMAP_OPPOSITEZ: boolean;
  44979. LODINREFLECTIONALPHA: boolean;
  44980. GAMMAREFLECTION: boolean;
  44981. RGBDREFLECTION: boolean;
  44982. RADIANCEOCCLUSION: boolean;
  44983. HORIZONOCCLUSION: boolean;
  44984. INSTANCES: boolean;
  44985. NUM_BONE_INFLUENCERS: number;
  44986. BonesPerMesh: number;
  44987. BONETEXTURE: boolean;
  44988. NONUNIFORMSCALING: boolean;
  44989. MORPHTARGETS: boolean;
  44990. MORPHTARGETS_NORMAL: boolean;
  44991. MORPHTARGETS_TANGENT: boolean;
  44992. NUM_MORPH_INFLUENCERS: number;
  44993. IMAGEPROCESSING: boolean;
  44994. VIGNETTE: boolean;
  44995. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44996. VIGNETTEBLENDMODEOPAQUE: boolean;
  44997. TONEMAPPING: boolean;
  44998. TONEMAPPING_ACES: boolean;
  44999. CONTRAST: boolean;
  45000. COLORCURVES: boolean;
  45001. COLORGRADING: boolean;
  45002. COLORGRADING3D: boolean;
  45003. SAMPLER3DGREENDEPTH: boolean;
  45004. SAMPLER3DBGRMAP: boolean;
  45005. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45006. EXPOSURE: boolean;
  45007. MULTIVIEW: boolean;
  45008. USEPHYSICALLIGHTFALLOFF: boolean;
  45009. USEGLTFLIGHTFALLOFF: boolean;
  45010. TWOSIDEDLIGHTING: boolean;
  45011. SHADOWFLOAT: boolean;
  45012. CLIPPLANE: boolean;
  45013. CLIPPLANE2: boolean;
  45014. CLIPPLANE3: boolean;
  45015. CLIPPLANE4: boolean;
  45016. POINTSIZE: boolean;
  45017. FOG: boolean;
  45018. LOGARITHMICDEPTH: boolean;
  45019. FORCENORMALFORWARD: boolean;
  45020. SPECULARAA: boolean;
  45021. CLEARCOAT: boolean;
  45022. CLEARCOAT_DEFAULTIOR: boolean;
  45023. CLEARCOAT_TEXTURE: boolean;
  45024. CLEARCOAT_TEXTUREDIRECTUV: number;
  45025. CLEARCOAT_BUMP: boolean;
  45026. CLEARCOAT_BUMPDIRECTUV: number;
  45027. CLEARCOAT_TINT: boolean;
  45028. CLEARCOAT_TINT_TEXTURE: boolean;
  45029. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45030. ANISOTROPIC: boolean;
  45031. ANISOTROPIC_TEXTURE: boolean;
  45032. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45033. BRDF_V_HEIGHT_CORRELATED: boolean;
  45034. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45035. SHEEN: boolean;
  45036. SHEEN_TEXTURE: boolean;
  45037. SHEEN_TEXTUREDIRECTUV: number;
  45038. SHEEN_LINKWITHALBEDO: boolean;
  45039. SUBSURFACE: boolean;
  45040. SS_REFRACTION: boolean;
  45041. SS_TRANSLUCENCY: boolean;
  45042. SS_SCATERRING: boolean;
  45043. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45044. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45045. SS_REFRACTIONMAP_3D: boolean;
  45046. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45047. SS_LODINREFRACTIONALPHA: boolean;
  45048. SS_GAMMAREFRACTION: boolean;
  45049. SS_RGBDREFRACTION: boolean;
  45050. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45051. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45052. UNLIT: boolean;
  45053. DEBUGMODE: number;
  45054. /**
  45055. * Initializes the PBR Material defines.
  45056. */
  45057. constructor();
  45058. /**
  45059. * Resets the PBR Material defines.
  45060. */
  45061. reset(): void;
  45062. }
  45063. /**
  45064. * The Physically based material base class of BJS.
  45065. *
  45066. * This offers the main features of a standard PBR material.
  45067. * For more information, please refer to the documentation :
  45068. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45069. */
  45070. export abstract class PBRBaseMaterial extends PushMaterial {
  45071. /**
  45072. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45073. */
  45074. static readonly PBRMATERIAL_OPAQUE: number;
  45075. /**
  45076. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45077. */
  45078. static readonly PBRMATERIAL_ALPHATEST: number;
  45079. /**
  45080. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45081. */
  45082. static readonly PBRMATERIAL_ALPHABLEND: number;
  45083. /**
  45084. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45085. * They are also discarded below the alpha cutoff threshold to improve performances.
  45086. */
  45087. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45088. /**
  45089. * Defines the default value of how much AO map is occluding the analytical lights
  45090. * (point spot...).
  45091. */
  45092. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45093. /**
  45094. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45095. */
  45096. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45097. /**
  45098. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45099. * to enhance interoperability with other engines.
  45100. */
  45101. static readonly LIGHTFALLOFF_GLTF: number;
  45102. /**
  45103. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45104. * to enhance interoperability with other materials.
  45105. */
  45106. static readonly LIGHTFALLOFF_STANDARD: number;
  45107. /**
  45108. * Intensity of the direct lights e.g. the four lights available in your scene.
  45109. * This impacts both the direct diffuse and specular highlights.
  45110. */
  45111. protected _directIntensity: number;
  45112. /**
  45113. * Intensity of the emissive part of the material.
  45114. * This helps controlling the emissive effect without modifying the emissive color.
  45115. */
  45116. protected _emissiveIntensity: number;
  45117. /**
  45118. * Intensity of the environment e.g. how much the environment will light the object
  45119. * either through harmonics for rough material or through the refelction for shiny ones.
  45120. */
  45121. protected _environmentIntensity: number;
  45122. /**
  45123. * This is a special control allowing the reduction of the specular highlights coming from the
  45124. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45125. */
  45126. protected _specularIntensity: number;
  45127. /**
  45128. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45129. */
  45130. private _lightingInfos;
  45131. /**
  45132. * Debug Control allowing disabling the bump map on this material.
  45133. */
  45134. protected _disableBumpMap: boolean;
  45135. /**
  45136. * AKA Diffuse Texture in standard nomenclature.
  45137. */
  45138. protected _albedoTexture: Nullable<BaseTexture>;
  45139. /**
  45140. * AKA Occlusion Texture in other nomenclature.
  45141. */
  45142. protected _ambientTexture: Nullable<BaseTexture>;
  45143. /**
  45144. * AKA Occlusion Texture Intensity in other nomenclature.
  45145. */
  45146. protected _ambientTextureStrength: number;
  45147. /**
  45148. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45149. * 1 means it completely occludes it
  45150. * 0 mean it has no impact
  45151. */
  45152. protected _ambientTextureImpactOnAnalyticalLights: number;
  45153. /**
  45154. * Stores the alpha values in a texture.
  45155. */
  45156. protected _opacityTexture: Nullable<BaseTexture>;
  45157. /**
  45158. * Stores the reflection values in a texture.
  45159. */
  45160. protected _reflectionTexture: Nullable<BaseTexture>;
  45161. /**
  45162. * Stores the emissive values in a texture.
  45163. */
  45164. protected _emissiveTexture: Nullable<BaseTexture>;
  45165. /**
  45166. * AKA Specular texture in other nomenclature.
  45167. */
  45168. protected _reflectivityTexture: Nullable<BaseTexture>;
  45169. /**
  45170. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45171. */
  45172. protected _metallicTexture: Nullable<BaseTexture>;
  45173. /**
  45174. * Specifies the metallic scalar of the metallic/roughness workflow.
  45175. * Can also be used to scale the metalness values of the metallic texture.
  45176. */
  45177. protected _metallic: Nullable<number>;
  45178. /**
  45179. * Specifies the roughness scalar of the metallic/roughness workflow.
  45180. * Can also be used to scale the roughness values of the metallic texture.
  45181. */
  45182. protected _roughness: Nullable<number>;
  45183. /**
  45184. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45185. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45186. */
  45187. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45188. /**
  45189. * Stores surface normal data used to displace a mesh in a texture.
  45190. */
  45191. protected _bumpTexture: Nullable<BaseTexture>;
  45192. /**
  45193. * Stores the pre-calculated light information of a mesh in a texture.
  45194. */
  45195. protected _lightmapTexture: Nullable<BaseTexture>;
  45196. /**
  45197. * The color of a material in ambient lighting.
  45198. */
  45199. protected _ambientColor: Color3;
  45200. /**
  45201. * AKA Diffuse Color in other nomenclature.
  45202. */
  45203. protected _albedoColor: Color3;
  45204. /**
  45205. * AKA Specular Color in other nomenclature.
  45206. */
  45207. protected _reflectivityColor: Color3;
  45208. /**
  45209. * The color applied when light is reflected from a material.
  45210. */
  45211. protected _reflectionColor: Color3;
  45212. /**
  45213. * The color applied when light is emitted from a material.
  45214. */
  45215. protected _emissiveColor: Color3;
  45216. /**
  45217. * AKA Glossiness in other nomenclature.
  45218. */
  45219. protected _microSurface: number;
  45220. /**
  45221. * Specifies that the material will use the light map as a show map.
  45222. */
  45223. protected _useLightmapAsShadowmap: boolean;
  45224. /**
  45225. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45226. * makes the reflect vector face the model (under horizon).
  45227. */
  45228. protected _useHorizonOcclusion: boolean;
  45229. /**
  45230. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45231. * too much the area relying on ambient texture to define their ambient occlusion.
  45232. */
  45233. protected _useRadianceOcclusion: boolean;
  45234. /**
  45235. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45236. */
  45237. protected _useAlphaFromAlbedoTexture: boolean;
  45238. /**
  45239. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45240. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45241. */
  45242. protected _useSpecularOverAlpha: boolean;
  45243. /**
  45244. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45245. */
  45246. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45247. /**
  45248. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45249. */
  45250. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45251. /**
  45252. * Specifies if the metallic texture contains the roughness information in its green channel.
  45253. */
  45254. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45255. /**
  45256. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45257. */
  45258. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45259. /**
  45260. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45261. */
  45262. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45263. /**
  45264. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45265. */
  45266. protected _useAmbientInGrayScale: boolean;
  45267. /**
  45268. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45269. * The material will try to infer what glossiness each pixel should be.
  45270. */
  45271. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45272. /**
  45273. * Defines the falloff type used in this material.
  45274. * It by default is Physical.
  45275. */
  45276. protected _lightFalloff: number;
  45277. /**
  45278. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45279. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45280. */
  45281. protected _useRadianceOverAlpha: boolean;
  45282. /**
  45283. * Allows using an object space normal map (instead of tangent space).
  45284. */
  45285. protected _useObjectSpaceNormalMap: boolean;
  45286. /**
  45287. * Allows using the bump map in parallax mode.
  45288. */
  45289. protected _useParallax: boolean;
  45290. /**
  45291. * Allows using the bump map in parallax occlusion mode.
  45292. */
  45293. protected _useParallaxOcclusion: boolean;
  45294. /**
  45295. * Controls the scale bias of the parallax mode.
  45296. */
  45297. protected _parallaxScaleBias: number;
  45298. /**
  45299. * If sets to true, disables all the lights affecting the material.
  45300. */
  45301. protected _disableLighting: boolean;
  45302. /**
  45303. * Number of Simultaneous lights allowed on the material.
  45304. */
  45305. protected _maxSimultaneousLights: number;
  45306. /**
  45307. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45308. */
  45309. protected _invertNormalMapX: boolean;
  45310. /**
  45311. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45312. */
  45313. protected _invertNormalMapY: boolean;
  45314. /**
  45315. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45316. */
  45317. protected _twoSidedLighting: boolean;
  45318. /**
  45319. * Defines the alpha limits in alpha test mode.
  45320. */
  45321. protected _alphaCutOff: number;
  45322. /**
  45323. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45324. */
  45325. protected _forceAlphaTest: boolean;
  45326. /**
  45327. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45328. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45329. */
  45330. protected _useAlphaFresnel: boolean;
  45331. /**
  45332. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45333. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45334. */
  45335. protected _useLinearAlphaFresnel: boolean;
  45336. /**
  45337. * The transparency mode of the material.
  45338. */
  45339. protected _transparencyMode: Nullable<number>;
  45340. /**
  45341. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45342. * from cos thetav and roughness:
  45343. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45344. */
  45345. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45346. /**
  45347. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45348. */
  45349. protected _forceIrradianceInFragment: boolean;
  45350. /**
  45351. * Force normal to face away from face.
  45352. */
  45353. protected _forceNormalForward: boolean;
  45354. /**
  45355. * Enables specular anti aliasing in the PBR shader.
  45356. * It will both interacts on the Geometry for analytical and IBL lighting.
  45357. * It also prefilter the roughness map based on the bump values.
  45358. */
  45359. protected _enableSpecularAntiAliasing: boolean;
  45360. /**
  45361. * Default configuration related to image processing available in the PBR Material.
  45362. */
  45363. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45364. /**
  45365. * Keep track of the image processing observer to allow dispose and replace.
  45366. */
  45367. private _imageProcessingObserver;
  45368. /**
  45369. * Attaches a new image processing configuration to the PBR Material.
  45370. * @param configuration
  45371. */
  45372. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45373. /**
  45374. * Stores the available render targets.
  45375. */
  45376. private _renderTargets;
  45377. /**
  45378. * Sets the global ambient color for the material used in lighting calculations.
  45379. */
  45380. private _globalAmbientColor;
  45381. /**
  45382. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45383. */
  45384. private _useLogarithmicDepth;
  45385. /**
  45386. * If set to true, no lighting calculations will be applied.
  45387. */
  45388. private _unlit;
  45389. private _debugMode;
  45390. /**
  45391. * @hidden
  45392. * This is reserved for the inspector.
  45393. * Defines the material debug mode.
  45394. * It helps seeing only some components of the material while troubleshooting.
  45395. */
  45396. debugMode: number;
  45397. /**
  45398. * @hidden
  45399. * This is reserved for the inspector.
  45400. * Specify from where on screen the debug mode should start.
  45401. * The value goes from -1 (full screen) to 1 (not visible)
  45402. * It helps with side by side comparison against the final render
  45403. * This defaults to -1
  45404. */
  45405. private debugLimit;
  45406. /**
  45407. * @hidden
  45408. * This is reserved for the inspector.
  45409. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45410. * You can use the factor to better multiply the final value.
  45411. */
  45412. private debugFactor;
  45413. /**
  45414. * Defines the clear coat layer parameters for the material.
  45415. */
  45416. readonly clearCoat: PBRClearCoatConfiguration;
  45417. /**
  45418. * Defines the anisotropic parameters for the material.
  45419. */
  45420. readonly anisotropy: PBRAnisotropicConfiguration;
  45421. /**
  45422. * Defines the BRDF parameters for the material.
  45423. */
  45424. readonly brdf: PBRBRDFConfiguration;
  45425. /**
  45426. * Defines the Sheen parameters for the material.
  45427. */
  45428. readonly sheen: PBRSheenConfiguration;
  45429. /**
  45430. * Defines the SubSurface parameters for the material.
  45431. */
  45432. readonly subSurface: PBRSubSurfaceConfiguration;
  45433. /**
  45434. * Custom callback helping to override the default shader used in the material.
  45435. */
  45436. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45437. /**
  45438. * Instantiates a new PBRMaterial instance.
  45439. *
  45440. * @param name The material name
  45441. * @param scene The scene the material will be use in.
  45442. */
  45443. constructor(name: string, scene: Scene);
  45444. /**
  45445. * Gets a boolean indicating that current material needs to register RTT
  45446. */
  45447. readonly hasRenderTargetTextures: boolean;
  45448. /**
  45449. * Gets the name of the material class.
  45450. */
  45451. getClassName(): string;
  45452. /**
  45453. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45454. */
  45455. /**
  45456. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45457. */
  45458. useLogarithmicDepth: boolean;
  45459. /**
  45460. * Gets the current transparency mode.
  45461. */
  45462. /**
  45463. * Sets the transparency mode of the material.
  45464. *
  45465. * | Value | Type | Description |
  45466. * | ----- | ----------------------------------- | ----------- |
  45467. * | 0 | OPAQUE | |
  45468. * | 1 | ALPHATEST | |
  45469. * | 2 | ALPHABLEND | |
  45470. * | 3 | ALPHATESTANDBLEND | |
  45471. *
  45472. */
  45473. transparencyMode: Nullable<number>;
  45474. /**
  45475. * Returns true if alpha blending should be disabled.
  45476. */
  45477. private readonly _disableAlphaBlending;
  45478. /**
  45479. * Specifies whether or not this material should be rendered in alpha blend mode.
  45480. */
  45481. needAlphaBlending(): boolean;
  45482. /**
  45483. * Specifies if the mesh will require alpha blending.
  45484. * @param mesh - BJS mesh.
  45485. */
  45486. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45487. /**
  45488. * Specifies whether or not this material should be rendered in alpha test mode.
  45489. */
  45490. needAlphaTesting(): boolean;
  45491. /**
  45492. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45493. */
  45494. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45495. /**
  45496. * Gets the texture used for the alpha test.
  45497. */
  45498. getAlphaTestTexture(): Nullable<BaseTexture>;
  45499. /**
  45500. * Specifies that the submesh is ready to be used.
  45501. * @param mesh - BJS mesh.
  45502. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45503. * @param useInstances - Specifies that instances should be used.
  45504. * @returns - boolean indicating that the submesh is ready or not.
  45505. */
  45506. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45507. /**
  45508. * Specifies if the material uses metallic roughness workflow.
  45509. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45510. */
  45511. isMetallicWorkflow(): boolean;
  45512. private _prepareEffect;
  45513. private _prepareDefines;
  45514. /**
  45515. * Force shader compilation
  45516. */
  45517. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45518. clipPlane: boolean;
  45519. }>): void;
  45520. /**
  45521. * Initializes the uniform buffer layout for the shader.
  45522. */
  45523. buildUniformLayout(): void;
  45524. /**
  45525. * Unbinds the material from the mesh
  45526. */
  45527. unbind(): void;
  45528. /**
  45529. * Binds the submesh data.
  45530. * @param world - The world matrix.
  45531. * @param mesh - The BJS mesh.
  45532. * @param subMesh - A submesh of the BJS mesh.
  45533. */
  45534. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45535. /**
  45536. * Returns the animatable textures.
  45537. * @returns - Array of animatable textures.
  45538. */
  45539. getAnimatables(): IAnimatable[];
  45540. /**
  45541. * Returns the texture used for reflections.
  45542. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45543. */
  45544. private _getReflectionTexture;
  45545. /**
  45546. * Returns an array of the actively used textures.
  45547. * @returns - Array of BaseTextures
  45548. */
  45549. getActiveTextures(): BaseTexture[];
  45550. /**
  45551. * Checks to see if a texture is used in the material.
  45552. * @param texture - Base texture to use.
  45553. * @returns - Boolean specifying if a texture is used in the material.
  45554. */
  45555. hasTexture(texture: BaseTexture): boolean;
  45556. /**
  45557. * Disposes the resources of the material.
  45558. * @param forceDisposeEffect - Forces the disposal of effects.
  45559. * @param forceDisposeTextures - Forces the disposal of all textures.
  45560. */
  45561. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45562. }
  45563. }
  45564. declare module BABYLON {
  45565. /**
  45566. * The Physically based material of BJS.
  45567. *
  45568. * This offers the main features of a standard PBR material.
  45569. * For more information, please refer to the documentation :
  45570. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45571. */
  45572. export class PBRMaterial extends PBRBaseMaterial {
  45573. /**
  45574. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45575. */
  45576. static readonly PBRMATERIAL_OPAQUE: number;
  45577. /**
  45578. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45579. */
  45580. static readonly PBRMATERIAL_ALPHATEST: number;
  45581. /**
  45582. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45583. */
  45584. static readonly PBRMATERIAL_ALPHABLEND: number;
  45585. /**
  45586. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45587. * They are also discarded below the alpha cutoff threshold to improve performances.
  45588. */
  45589. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45590. /**
  45591. * Defines the default value of how much AO map is occluding the analytical lights
  45592. * (point spot...).
  45593. */
  45594. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45595. /**
  45596. * Intensity of the direct lights e.g. the four lights available in your scene.
  45597. * This impacts both the direct diffuse and specular highlights.
  45598. */
  45599. directIntensity: number;
  45600. /**
  45601. * Intensity of the emissive part of the material.
  45602. * This helps controlling the emissive effect without modifying the emissive color.
  45603. */
  45604. emissiveIntensity: number;
  45605. /**
  45606. * Intensity of the environment e.g. how much the environment will light the object
  45607. * either through harmonics for rough material or through the refelction for shiny ones.
  45608. */
  45609. environmentIntensity: number;
  45610. /**
  45611. * This is a special control allowing the reduction of the specular highlights coming from the
  45612. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45613. */
  45614. specularIntensity: number;
  45615. /**
  45616. * Debug Control allowing disabling the bump map on this material.
  45617. */
  45618. disableBumpMap: boolean;
  45619. /**
  45620. * AKA Diffuse Texture in standard nomenclature.
  45621. */
  45622. albedoTexture: BaseTexture;
  45623. /**
  45624. * AKA Occlusion Texture in other nomenclature.
  45625. */
  45626. ambientTexture: BaseTexture;
  45627. /**
  45628. * AKA Occlusion Texture Intensity in other nomenclature.
  45629. */
  45630. ambientTextureStrength: number;
  45631. /**
  45632. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45633. * 1 means it completely occludes it
  45634. * 0 mean it has no impact
  45635. */
  45636. ambientTextureImpactOnAnalyticalLights: number;
  45637. /**
  45638. * Stores the alpha values in a texture.
  45639. */
  45640. opacityTexture: BaseTexture;
  45641. /**
  45642. * Stores the reflection values in a texture.
  45643. */
  45644. reflectionTexture: Nullable<BaseTexture>;
  45645. /**
  45646. * Stores the emissive values in a texture.
  45647. */
  45648. emissiveTexture: BaseTexture;
  45649. /**
  45650. * AKA Specular texture in other nomenclature.
  45651. */
  45652. reflectivityTexture: BaseTexture;
  45653. /**
  45654. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45655. */
  45656. metallicTexture: BaseTexture;
  45657. /**
  45658. * Specifies the metallic scalar of the metallic/roughness workflow.
  45659. * Can also be used to scale the metalness values of the metallic texture.
  45660. */
  45661. metallic: Nullable<number>;
  45662. /**
  45663. * Specifies the roughness scalar of the metallic/roughness workflow.
  45664. * Can also be used to scale the roughness values of the metallic texture.
  45665. */
  45666. roughness: Nullable<number>;
  45667. /**
  45668. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45669. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45670. */
  45671. microSurfaceTexture: BaseTexture;
  45672. /**
  45673. * Stores surface normal data used to displace a mesh in a texture.
  45674. */
  45675. bumpTexture: BaseTexture;
  45676. /**
  45677. * Stores the pre-calculated light information of a mesh in a texture.
  45678. */
  45679. lightmapTexture: BaseTexture;
  45680. /**
  45681. * Stores the refracted light information in a texture.
  45682. */
  45683. refractionTexture: Nullable<BaseTexture>;
  45684. /**
  45685. * The color of a material in ambient lighting.
  45686. */
  45687. ambientColor: Color3;
  45688. /**
  45689. * AKA Diffuse Color in other nomenclature.
  45690. */
  45691. albedoColor: Color3;
  45692. /**
  45693. * AKA Specular Color in other nomenclature.
  45694. */
  45695. reflectivityColor: Color3;
  45696. /**
  45697. * The color reflected from the material.
  45698. */
  45699. reflectionColor: Color3;
  45700. /**
  45701. * The color emitted from the material.
  45702. */
  45703. emissiveColor: Color3;
  45704. /**
  45705. * AKA Glossiness in other nomenclature.
  45706. */
  45707. microSurface: number;
  45708. /**
  45709. * source material index of refraction (IOR)' / 'destination material IOR.
  45710. */
  45711. indexOfRefraction: number;
  45712. /**
  45713. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45714. */
  45715. invertRefractionY: boolean;
  45716. /**
  45717. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45718. * Materials half opaque for instance using refraction could benefit from this control.
  45719. */
  45720. linkRefractionWithTransparency: boolean;
  45721. /**
  45722. * If true, the light map contains occlusion information instead of lighting info.
  45723. */
  45724. useLightmapAsShadowmap: boolean;
  45725. /**
  45726. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45727. */
  45728. useAlphaFromAlbedoTexture: boolean;
  45729. /**
  45730. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45731. */
  45732. forceAlphaTest: boolean;
  45733. /**
  45734. * Defines the alpha limits in alpha test mode.
  45735. */
  45736. alphaCutOff: number;
  45737. /**
  45738. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45739. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45740. */
  45741. useSpecularOverAlpha: boolean;
  45742. /**
  45743. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45744. */
  45745. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45746. /**
  45747. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45748. */
  45749. useRoughnessFromMetallicTextureAlpha: boolean;
  45750. /**
  45751. * Specifies if the metallic texture contains the roughness information in its green channel.
  45752. */
  45753. useRoughnessFromMetallicTextureGreen: boolean;
  45754. /**
  45755. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45756. */
  45757. useMetallnessFromMetallicTextureBlue: boolean;
  45758. /**
  45759. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45760. */
  45761. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45762. /**
  45763. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45764. */
  45765. useAmbientInGrayScale: boolean;
  45766. /**
  45767. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45768. * The material will try to infer what glossiness each pixel should be.
  45769. */
  45770. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45771. /**
  45772. * BJS is using an harcoded light falloff based on a manually sets up range.
  45773. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45774. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45775. */
  45776. /**
  45777. * BJS is using an harcoded light falloff based on a manually sets up range.
  45778. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45779. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45780. */
  45781. usePhysicalLightFalloff: boolean;
  45782. /**
  45783. * In order to support the falloff compatibility with gltf, a special mode has been added
  45784. * to reproduce the gltf light falloff.
  45785. */
  45786. /**
  45787. * In order to support the falloff compatibility with gltf, a special mode has been added
  45788. * to reproduce the gltf light falloff.
  45789. */
  45790. useGLTFLightFalloff: boolean;
  45791. /**
  45792. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45793. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45794. */
  45795. useRadianceOverAlpha: boolean;
  45796. /**
  45797. * Allows using an object space normal map (instead of tangent space).
  45798. */
  45799. useObjectSpaceNormalMap: boolean;
  45800. /**
  45801. * Allows using the bump map in parallax mode.
  45802. */
  45803. useParallax: boolean;
  45804. /**
  45805. * Allows using the bump map in parallax occlusion mode.
  45806. */
  45807. useParallaxOcclusion: boolean;
  45808. /**
  45809. * Controls the scale bias of the parallax mode.
  45810. */
  45811. parallaxScaleBias: number;
  45812. /**
  45813. * If sets to true, disables all the lights affecting the material.
  45814. */
  45815. disableLighting: boolean;
  45816. /**
  45817. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45818. */
  45819. forceIrradianceInFragment: boolean;
  45820. /**
  45821. * Number of Simultaneous lights allowed on the material.
  45822. */
  45823. maxSimultaneousLights: number;
  45824. /**
  45825. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45826. */
  45827. invertNormalMapX: boolean;
  45828. /**
  45829. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45830. */
  45831. invertNormalMapY: boolean;
  45832. /**
  45833. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45834. */
  45835. twoSidedLighting: boolean;
  45836. /**
  45837. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45838. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45839. */
  45840. useAlphaFresnel: boolean;
  45841. /**
  45842. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45843. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45844. */
  45845. useLinearAlphaFresnel: boolean;
  45846. /**
  45847. * Let user defines the brdf lookup texture used for IBL.
  45848. * A default 8bit version is embedded but you could point at :
  45849. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45850. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45851. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45852. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45853. */
  45854. environmentBRDFTexture: Nullable<BaseTexture>;
  45855. /**
  45856. * Force normal to face away from face.
  45857. */
  45858. forceNormalForward: boolean;
  45859. /**
  45860. * Enables specular anti aliasing in the PBR shader.
  45861. * It will both interacts on the Geometry for analytical and IBL lighting.
  45862. * It also prefilter the roughness map based on the bump values.
  45863. */
  45864. enableSpecularAntiAliasing: boolean;
  45865. /**
  45866. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45867. * makes the reflect vector face the model (under horizon).
  45868. */
  45869. useHorizonOcclusion: boolean;
  45870. /**
  45871. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45872. * too much the area relying on ambient texture to define their ambient occlusion.
  45873. */
  45874. useRadianceOcclusion: boolean;
  45875. /**
  45876. * If set to true, no lighting calculations will be applied.
  45877. */
  45878. unlit: boolean;
  45879. /**
  45880. * Gets the image processing configuration used either in this material.
  45881. */
  45882. /**
  45883. * Sets the Default image processing configuration used either in the this material.
  45884. *
  45885. * If sets to null, the scene one is in use.
  45886. */
  45887. imageProcessingConfiguration: ImageProcessingConfiguration;
  45888. /**
  45889. * Gets wether the color curves effect is enabled.
  45890. */
  45891. /**
  45892. * Sets wether the color curves effect is enabled.
  45893. */
  45894. cameraColorCurvesEnabled: boolean;
  45895. /**
  45896. * Gets wether the color grading effect is enabled.
  45897. */
  45898. /**
  45899. * Gets wether the color grading effect is enabled.
  45900. */
  45901. cameraColorGradingEnabled: boolean;
  45902. /**
  45903. * Gets wether tonemapping is enabled or not.
  45904. */
  45905. /**
  45906. * Sets wether tonemapping is enabled or not
  45907. */
  45908. cameraToneMappingEnabled: boolean;
  45909. /**
  45910. * The camera exposure used on this material.
  45911. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45912. * This corresponds to a photographic exposure.
  45913. */
  45914. /**
  45915. * The camera exposure used on this material.
  45916. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45917. * This corresponds to a photographic exposure.
  45918. */
  45919. cameraExposure: number;
  45920. /**
  45921. * Gets The camera contrast used on this material.
  45922. */
  45923. /**
  45924. * Sets The camera contrast used on this material.
  45925. */
  45926. cameraContrast: number;
  45927. /**
  45928. * Gets the Color Grading 2D Lookup Texture.
  45929. */
  45930. /**
  45931. * Sets the Color Grading 2D Lookup Texture.
  45932. */
  45933. cameraColorGradingTexture: Nullable<BaseTexture>;
  45934. /**
  45935. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45936. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45937. * 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;
  45938. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45939. */
  45940. /**
  45941. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45942. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45943. * 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;
  45944. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45945. */
  45946. cameraColorCurves: Nullable<ColorCurves>;
  45947. /**
  45948. * Instantiates a new PBRMaterial instance.
  45949. *
  45950. * @param name The material name
  45951. * @param scene The scene the material will be use in.
  45952. */
  45953. constructor(name: string, scene: Scene);
  45954. /**
  45955. * Returns the name of this material class.
  45956. */
  45957. getClassName(): string;
  45958. /**
  45959. * Makes a duplicate of the current material.
  45960. * @param name - name to use for the new material.
  45961. */
  45962. clone(name: string): PBRMaterial;
  45963. /**
  45964. * Serializes this PBR Material.
  45965. * @returns - An object with the serialized material.
  45966. */
  45967. serialize(): any;
  45968. /**
  45969. * Parses a PBR Material from a serialized object.
  45970. * @param source - Serialized object.
  45971. * @param scene - BJS scene instance.
  45972. * @param rootUrl - url for the scene object
  45973. * @returns - PBRMaterial
  45974. */
  45975. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45976. }
  45977. }
  45978. declare module BABYLON {
  45979. /**
  45980. * Direct draw surface info
  45981. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45982. */
  45983. export interface DDSInfo {
  45984. /**
  45985. * Width of the texture
  45986. */
  45987. width: number;
  45988. /**
  45989. * Width of the texture
  45990. */
  45991. height: number;
  45992. /**
  45993. * Number of Mipmaps for the texture
  45994. * @see https://en.wikipedia.org/wiki/Mipmap
  45995. */
  45996. mipmapCount: number;
  45997. /**
  45998. * If the textures format is a known fourCC format
  45999. * @see https://www.fourcc.org/
  46000. */
  46001. isFourCC: boolean;
  46002. /**
  46003. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46004. */
  46005. isRGB: boolean;
  46006. /**
  46007. * If the texture is a lumincance format
  46008. */
  46009. isLuminance: boolean;
  46010. /**
  46011. * If this is a cube texture
  46012. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46013. */
  46014. isCube: boolean;
  46015. /**
  46016. * If the texture is a compressed format eg. FOURCC_DXT1
  46017. */
  46018. isCompressed: boolean;
  46019. /**
  46020. * The dxgiFormat of the texture
  46021. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46022. */
  46023. dxgiFormat: number;
  46024. /**
  46025. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46026. */
  46027. textureType: number;
  46028. /**
  46029. * Sphericle polynomial created for the dds texture
  46030. */
  46031. sphericalPolynomial?: SphericalPolynomial;
  46032. }
  46033. /**
  46034. * Class used to provide DDS decompression tools
  46035. */
  46036. export class DDSTools {
  46037. /**
  46038. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46039. */
  46040. static StoreLODInAlphaChannel: boolean;
  46041. /**
  46042. * Gets DDS information from an array buffer
  46043. * @param arrayBuffer defines the array buffer to read data from
  46044. * @returns the DDS information
  46045. */
  46046. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46047. private static _FloatView;
  46048. private static _Int32View;
  46049. private static _ToHalfFloat;
  46050. private static _FromHalfFloat;
  46051. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46052. private static _GetHalfFloatRGBAArrayBuffer;
  46053. private static _GetFloatRGBAArrayBuffer;
  46054. private static _GetFloatAsUIntRGBAArrayBuffer;
  46055. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46056. private static _GetRGBAArrayBuffer;
  46057. private static _ExtractLongWordOrder;
  46058. private static _GetRGBArrayBuffer;
  46059. private static _GetLuminanceArrayBuffer;
  46060. /**
  46061. * Uploads DDS Levels to a Babylon Texture
  46062. * @hidden
  46063. */
  46064. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46065. }
  46066. interface Engine {
  46067. /**
  46068. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46069. * @param rootUrl defines the url where the file to load is located
  46070. * @param scene defines the current scene
  46071. * @param lodScale defines scale to apply to the mip map selection
  46072. * @param lodOffset defines offset to apply to the mip map selection
  46073. * @param onLoad defines an optional callback raised when the texture is loaded
  46074. * @param onError defines an optional callback raised if there is an issue to load the texture
  46075. * @param format defines the format of the data
  46076. * @param forcedExtension defines the extension to use to pick the right loader
  46077. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46078. * @returns the cube texture as an InternalTexture
  46079. */
  46080. 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;
  46081. }
  46082. }
  46083. declare module BABYLON {
  46084. /**
  46085. * Implementation of the DDS Texture Loader.
  46086. * @hidden
  46087. */
  46088. export class _DDSTextureLoader implements IInternalTextureLoader {
  46089. /**
  46090. * Defines wether the loader supports cascade loading the different faces.
  46091. */
  46092. readonly supportCascades: boolean;
  46093. /**
  46094. * This returns if the loader support the current file information.
  46095. * @param extension defines the file extension of the file being loaded
  46096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46097. * @param fallback defines the fallback internal texture if any
  46098. * @param isBase64 defines whether the texture is encoded as a base64
  46099. * @param isBuffer defines whether the texture data are stored as a buffer
  46100. * @returns true if the loader can load the specified file
  46101. */
  46102. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46103. /**
  46104. * Transform the url before loading if required.
  46105. * @param rootUrl the url of the texture
  46106. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46107. * @returns the transformed texture
  46108. */
  46109. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46110. /**
  46111. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46112. * @param rootUrl the url of the texture
  46113. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46114. * @returns the fallback texture
  46115. */
  46116. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46117. /**
  46118. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46119. * @param data contains the texture data
  46120. * @param texture defines the BabylonJS internal texture
  46121. * @param createPolynomials will be true if polynomials have been requested
  46122. * @param onLoad defines the callback to trigger once the texture is ready
  46123. * @param onError defines the callback to trigger in case of error
  46124. */
  46125. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46126. /**
  46127. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46128. * @param data contains the texture data
  46129. * @param texture defines the BabylonJS internal texture
  46130. * @param callback defines the method to call once ready to upload
  46131. */
  46132. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46133. }
  46134. }
  46135. declare module BABYLON {
  46136. /** @hidden */
  46137. export var rgbdEncodePixelShader: {
  46138. name: string;
  46139. shader: string;
  46140. };
  46141. }
  46142. declare module BABYLON {
  46143. /**
  46144. * Raw texture data and descriptor sufficient for WebGL texture upload
  46145. */
  46146. export interface EnvironmentTextureInfo {
  46147. /**
  46148. * Version of the environment map
  46149. */
  46150. version: number;
  46151. /**
  46152. * Width of image
  46153. */
  46154. width: number;
  46155. /**
  46156. * Irradiance information stored in the file.
  46157. */
  46158. irradiance: any;
  46159. /**
  46160. * Specular information stored in the file.
  46161. */
  46162. specular: any;
  46163. }
  46164. /**
  46165. * Sets of helpers addressing the serialization and deserialization of environment texture
  46166. * stored in a BabylonJS env file.
  46167. * Those files are usually stored as .env files.
  46168. */
  46169. export class EnvironmentTextureTools {
  46170. /**
  46171. * Magic number identifying the env file.
  46172. */
  46173. private static _MagicBytes;
  46174. /**
  46175. * Gets the environment info from an env file.
  46176. * @param data The array buffer containing the .env bytes.
  46177. * @returns the environment file info (the json header) if successfully parsed.
  46178. */
  46179. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46180. /**
  46181. * Creates an environment texture from a loaded cube texture.
  46182. * @param texture defines the cube texture to convert in env file
  46183. * @return a promise containing the environment data if succesfull.
  46184. */
  46185. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46186. /**
  46187. * Creates a JSON representation of the spherical data.
  46188. * @param texture defines the texture containing the polynomials
  46189. * @return the JSON representation of the spherical info
  46190. */
  46191. private static _CreateEnvTextureIrradiance;
  46192. /**
  46193. * Uploads the texture info contained in the env file to the GPU.
  46194. * @param texture defines the internal texture to upload to
  46195. * @param arrayBuffer defines the buffer cotaining the data to load
  46196. * @param info defines the texture info retrieved through the GetEnvInfo method
  46197. * @returns a promise
  46198. */
  46199. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46200. /**
  46201. * Uploads the levels of image data to the GPU.
  46202. * @param texture defines the internal texture to upload to
  46203. * @param imageData defines the array buffer views of image data [mipmap][face]
  46204. * @returns a promise
  46205. */
  46206. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46207. /**
  46208. * Uploads spherical polynomials information to the texture.
  46209. * @param texture defines the texture we are trying to upload the information to
  46210. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46211. */
  46212. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46213. /** @hidden */
  46214. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46215. }
  46216. }
  46217. declare module BABYLON {
  46218. /**
  46219. * Implementation of the ENV Texture Loader.
  46220. * @hidden
  46221. */
  46222. export class _ENVTextureLoader implements IInternalTextureLoader {
  46223. /**
  46224. * Defines wether the loader supports cascade loading the different faces.
  46225. */
  46226. readonly supportCascades: boolean;
  46227. /**
  46228. * This returns if the loader support the current file information.
  46229. * @param extension defines the file extension of the file being loaded
  46230. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46231. * @param fallback defines the fallback internal texture if any
  46232. * @param isBase64 defines whether the texture is encoded as a base64
  46233. * @param isBuffer defines whether the texture data are stored as a buffer
  46234. * @returns true if the loader can load the specified file
  46235. */
  46236. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46237. /**
  46238. * Transform the url before loading if required.
  46239. * @param rootUrl the url of the texture
  46240. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46241. * @returns the transformed texture
  46242. */
  46243. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46244. /**
  46245. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46246. * @param rootUrl the url of the texture
  46247. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46248. * @returns the fallback texture
  46249. */
  46250. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46251. /**
  46252. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46253. * @param data contains the texture data
  46254. * @param texture defines the BabylonJS internal texture
  46255. * @param createPolynomials will be true if polynomials have been requested
  46256. * @param onLoad defines the callback to trigger once the texture is ready
  46257. * @param onError defines the callback to trigger in case of error
  46258. */
  46259. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46260. /**
  46261. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46262. * @param data contains the texture data
  46263. * @param texture defines the BabylonJS internal texture
  46264. * @param callback defines the method to call once ready to upload
  46265. */
  46266. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46267. }
  46268. }
  46269. declare module BABYLON {
  46270. /**
  46271. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46272. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46273. */
  46274. export class KhronosTextureContainer {
  46275. /** contents of the KTX container file */
  46276. arrayBuffer: any;
  46277. private static HEADER_LEN;
  46278. private static COMPRESSED_2D;
  46279. private static COMPRESSED_3D;
  46280. private static TEX_2D;
  46281. private static TEX_3D;
  46282. /**
  46283. * Gets the openGL type
  46284. */
  46285. glType: number;
  46286. /**
  46287. * Gets the openGL type size
  46288. */
  46289. glTypeSize: number;
  46290. /**
  46291. * Gets the openGL format
  46292. */
  46293. glFormat: number;
  46294. /**
  46295. * Gets the openGL internal format
  46296. */
  46297. glInternalFormat: number;
  46298. /**
  46299. * Gets the base internal format
  46300. */
  46301. glBaseInternalFormat: number;
  46302. /**
  46303. * Gets image width in pixel
  46304. */
  46305. pixelWidth: number;
  46306. /**
  46307. * Gets image height in pixel
  46308. */
  46309. pixelHeight: number;
  46310. /**
  46311. * Gets image depth in pixels
  46312. */
  46313. pixelDepth: number;
  46314. /**
  46315. * Gets the number of array elements
  46316. */
  46317. numberOfArrayElements: number;
  46318. /**
  46319. * Gets the number of faces
  46320. */
  46321. numberOfFaces: number;
  46322. /**
  46323. * Gets the number of mipmap levels
  46324. */
  46325. numberOfMipmapLevels: number;
  46326. /**
  46327. * Gets the bytes of key value data
  46328. */
  46329. bytesOfKeyValueData: number;
  46330. /**
  46331. * Gets the load type
  46332. */
  46333. loadType: number;
  46334. /**
  46335. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46336. */
  46337. isInvalid: boolean;
  46338. /**
  46339. * Creates a new KhronosTextureContainer
  46340. * @param arrayBuffer contents of the KTX container file
  46341. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46342. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46343. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46344. */
  46345. constructor(
  46346. /** contents of the KTX container file */
  46347. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46348. /**
  46349. * Uploads KTX content to a Babylon Texture.
  46350. * It is assumed that the texture has already been created & is currently bound
  46351. * @hidden
  46352. */
  46353. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46354. private _upload2DCompressedLevels;
  46355. }
  46356. }
  46357. declare module BABYLON {
  46358. /**
  46359. * Implementation of the KTX Texture Loader.
  46360. * @hidden
  46361. */
  46362. export class _KTXTextureLoader implements IInternalTextureLoader {
  46363. /**
  46364. * Defines wether the loader supports cascade loading the different faces.
  46365. */
  46366. readonly supportCascades: boolean;
  46367. /**
  46368. * This returns if the loader support the current file information.
  46369. * @param extension defines the file extension of the file being loaded
  46370. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46371. * @param fallback defines the fallback internal texture if any
  46372. * @param isBase64 defines whether the texture is encoded as a base64
  46373. * @param isBuffer defines whether the texture data are stored as a buffer
  46374. * @returns true if the loader can load the specified file
  46375. */
  46376. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46377. /**
  46378. * Transform the url before loading if required.
  46379. * @param rootUrl the url of the texture
  46380. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46381. * @returns the transformed texture
  46382. */
  46383. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46384. /**
  46385. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46386. * @param rootUrl the url of the texture
  46387. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46388. * @returns the fallback texture
  46389. */
  46390. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46391. /**
  46392. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46393. * @param data contains the texture data
  46394. * @param texture defines the BabylonJS internal texture
  46395. * @param createPolynomials will be true if polynomials have been requested
  46396. * @param onLoad defines the callback to trigger once the texture is ready
  46397. * @param onError defines the callback to trigger in case of error
  46398. */
  46399. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46400. /**
  46401. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46402. * @param data contains the texture data
  46403. * @param texture defines the BabylonJS internal texture
  46404. * @param callback defines the method to call once ready to upload
  46405. */
  46406. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46407. }
  46408. }
  46409. declare module BABYLON {
  46410. /** @hidden */
  46411. export var _forceSceneHelpersToBundle: boolean;
  46412. interface Scene {
  46413. /**
  46414. * Creates a default light for the scene.
  46415. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46416. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46417. */
  46418. createDefaultLight(replace?: boolean): void;
  46419. /**
  46420. * Creates a default camera for the scene.
  46421. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46422. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46423. * @param replace has default false, when true replaces the active camera in the scene
  46424. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46425. */
  46426. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46427. /**
  46428. * Creates a default camera and a default light.
  46429. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46430. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46431. * @param replace has the default false, when true replaces the active camera/light in the scene
  46432. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46433. */
  46434. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46435. /**
  46436. * Creates a new sky box
  46437. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46438. * @param environmentTexture defines the texture to use as environment texture
  46439. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46440. * @param scale defines the overall scale of the skybox
  46441. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46442. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46443. * @returns a new mesh holding the sky box
  46444. */
  46445. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46446. /**
  46447. * Creates a new environment
  46448. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46449. * @param options defines the options you can use to configure the environment
  46450. * @returns the new EnvironmentHelper
  46451. */
  46452. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46453. /**
  46454. * Creates a new VREXperienceHelper
  46455. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46456. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46457. * @returns a new VREXperienceHelper
  46458. */
  46459. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46460. /**
  46461. * Creates a new XREXperienceHelper
  46462. * @see http://doc.babylonjs.com/how_to/webxr
  46463. * @returns a promise for a new XREXperienceHelper
  46464. */
  46465. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46466. }
  46467. }
  46468. declare module BABYLON {
  46469. /**
  46470. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46471. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46472. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46473. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46474. */
  46475. export class VideoDome extends TransformNode {
  46476. /**
  46477. * Define the video source as a Monoscopic panoramic 360 video.
  46478. */
  46479. static readonly MODE_MONOSCOPIC: number;
  46480. /**
  46481. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46482. */
  46483. static readonly MODE_TOPBOTTOM: number;
  46484. /**
  46485. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46486. */
  46487. static readonly MODE_SIDEBYSIDE: number;
  46488. private _useDirectMapping;
  46489. /**
  46490. * The video texture being displayed on the sphere
  46491. */
  46492. protected _videoTexture: VideoTexture;
  46493. /**
  46494. * Gets the video texture being displayed on the sphere
  46495. */
  46496. readonly videoTexture: VideoTexture;
  46497. /**
  46498. * The skybox material
  46499. */
  46500. protected _material: BackgroundMaterial;
  46501. /**
  46502. * The surface used for the skybox
  46503. */
  46504. protected _mesh: Mesh;
  46505. /**
  46506. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46507. * Also see the options.resolution property.
  46508. */
  46509. fovMultiplier: number;
  46510. private _videoMode;
  46511. /**
  46512. * Gets or set the current video mode for the video. It can be:
  46513. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46514. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46515. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46516. */
  46517. videoMode: number;
  46518. /**
  46519. * Oberserver used in Stereoscopic VR Mode.
  46520. */
  46521. private _onBeforeCameraRenderObserver;
  46522. /**
  46523. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46524. * @param name Element's name, child elements will append suffixes for their own names.
  46525. * @param urlsOrVideo defines the url(s) or the video element to use
  46526. * @param options An object containing optional or exposed sub element properties
  46527. */
  46528. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46529. resolution?: number;
  46530. clickToPlay?: boolean;
  46531. autoPlay?: boolean;
  46532. loop?: boolean;
  46533. size?: number;
  46534. poster?: string;
  46535. faceForward?: boolean;
  46536. useDirectMapping?: boolean;
  46537. }, scene: Scene);
  46538. private _changeVideoMode;
  46539. /**
  46540. * Releases resources associated with this node.
  46541. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46542. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46543. */
  46544. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46545. }
  46546. }
  46547. declare module BABYLON {
  46548. /**
  46549. * This class can be used to get instrumentation data from a Babylon engine
  46550. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46551. */
  46552. export class EngineInstrumentation implements IDisposable {
  46553. /**
  46554. * Define the instrumented engine.
  46555. */
  46556. engine: Engine;
  46557. private _captureGPUFrameTime;
  46558. private _gpuFrameTimeToken;
  46559. private _gpuFrameTime;
  46560. private _captureShaderCompilationTime;
  46561. private _shaderCompilationTime;
  46562. private _onBeginFrameObserver;
  46563. private _onEndFrameObserver;
  46564. private _onBeforeShaderCompilationObserver;
  46565. private _onAfterShaderCompilationObserver;
  46566. /**
  46567. * Gets the perf counter used for GPU frame time
  46568. */
  46569. readonly gpuFrameTimeCounter: PerfCounter;
  46570. /**
  46571. * Gets the GPU frame time capture status
  46572. */
  46573. /**
  46574. * Enable or disable the GPU frame time capture
  46575. */
  46576. captureGPUFrameTime: boolean;
  46577. /**
  46578. * Gets the perf counter used for shader compilation time
  46579. */
  46580. readonly shaderCompilationTimeCounter: PerfCounter;
  46581. /**
  46582. * Gets the shader compilation time capture status
  46583. */
  46584. /**
  46585. * Enable or disable the shader compilation time capture
  46586. */
  46587. captureShaderCompilationTime: boolean;
  46588. /**
  46589. * Instantiates a new engine instrumentation.
  46590. * This class can be used to get instrumentation data from a Babylon engine
  46591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46592. * @param engine Defines the engine to instrument
  46593. */
  46594. constructor(
  46595. /**
  46596. * Define the instrumented engine.
  46597. */
  46598. engine: Engine);
  46599. /**
  46600. * Dispose and release associated resources.
  46601. */
  46602. dispose(): void;
  46603. }
  46604. }
  46605. declare module BABYLON {
  46606. /**
  46607. * This class can be used to get instrumentation data from a Babylon engine
  46608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46609. */
  46610. export class SceneInstrumentation implements IDisposable {
  46611. /**
  46612. * Defines the scene to instrument
  46613. */
  46614. scene: Scene;
  46615. private _captureActiveMeshesEvaluationTime;
  46616. private _activeMeshesEvaluationTime;
  46617. private _captureRenderTargetsRenderTime;
  46618. private _renderTargetsRenderTime;
  46619. private _captureFrameTime;
  46620. private _frameTime;
  46621. private _captureRenderTime;
  46622. private _renderTime;
  46623. private _captureInterFrameTime;
  46624. private _interFrameTime;
  46625. private _captureParticlesRenderTime;
  46626. private _particlesRenderTime;
  46627. private _captureSpritesRenderTime;
  46628. private _spritesRenderTime;
  46629. private _capturePhysicsTime;
  46630. private _physicsTime;
  46631. private _captureAnimationsTime;
  46632. private _animationsTime;
  46633. private _captureCameraRenderTime;
  46634. private _cameraRenderTime;
  46635. private _onBeforeActiveMeshesEvaluationObserver;
  46636. private _onAfterActiveMeshesEvaluationObserver;
  46637. private _onBeforeRenderTargetsRenderObserver;
  46638. private _onAfterRenderTargetsRenderObserver;
  46639. private _onAfterRenderObserver;
  46640. private _onBeforeDrawPhaseObserver;
  46641. private _onAfterDrawPhaseObserver;
  46642. private _onBeforeAnimationsObserver;
  46643. private _onBeforeParticlesRenderingObserver;
  46644. private _onAfterParticlesRenderingObserver;
  46645. private _onBeforeSpritesRenderingObserver;
  46646. private _onAfterSpritesRenderingObserver;
  46647. private _onBeforePhysicsObserver;
  46648. private _onAfterPhysicsObserver;
  46649. private _onAfterAnimationsObserver;
  46650. private _onBeforeCameraRenderObserver;
  46651. private _onAfterCameraRenderObserver;
  46652. /**
  46653. * Gets the perf counter used for active meshes evaluation time
  46654. */
  46655. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46656. /**
  46657. * Gets the active meshes evaluation time capture status
  46658. */
  46659. /**
  46660. * Enable or disable the active meshes evaluation time capture
  46661. */
  46662. captureActiveMeshesEvaluationTime: boolean;
  46663. /**
  46664. * Gets the perf counter used for render targets render time
  46665. */
  46666. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46667. /**
  46668. * Gets the render targets render time capture status
  46669. */
  46670. /**
  46671. * Enable or disable the render targets render time capture
  46672. */
  46673. captureRenderTargetsRenderTime: boolean;
  46674. /**
  46675. * Gets the perf counter used for particles render time
  46676. */
  46677. readonly particlesRenderTimeCounter: PerfCounter;
  46678. /**
  46679. * Gets the particles render time capture status
  46680. */
  46681. /**
  46682. * Enable or disable the particles render time capture
  46683. */
  46684. captureParticlesRenderTime: boolean;
  46685. /**
  46686. * Gets the perf counter used for sprites render time
  46687. */
  46688. readonly spritesRenderTimeCounter: PerfCounter;
  46689. /**
  46690. * Gets the sprites render time capture status
  46691. */
  46692. /**
  46693. * Enable or disable the sprites render time capture
  46694. */
  46695. captureSpritesRenderTime: boolean;
  46696. /**
  46697. * Gets the perf counter used for physics time
  46698. */
  46699. readonly physicsTimeCounter: PerfCounter;
  46700. /**
  46701. * Gets the physics time capture status
  46702. */
  46703. /**
  46704. * Enable or disable the physics time capture
  46705. */
  46706. capturePhysicsTime: boolean;
  46707. /**
  46708. * Gets the perf counter used for animations time
  46709. */
  46710. readonly animationsTimeCounter: PerfCounter;
  46711. /**
  46712. * Gets the animations time capture status
  46713. */
  46714. /**
  46715. * Enable or disable the animations time capture
  46716. */
  46717. captureAnimationsTime: boolean;
  46718. /**
  46719. * Gets the perf counter used for frame time capture
  46720. */
  46721. readonly frameTimeCounter: PerfCounter;
  46722. /**
  46723. * Gets the frame time capture status
  46724. */
  46725. /**
  46726. * Enable or disable the frame time capture
  46727. */
  46728. captureFrameTime: boolean;
  46729. /**
  46730. * Gets the perf counter used for inter-frames time capture
  46731. */
  46732. readonly interFrameTimeCounter: PerfCounter;
  46733. /**
  46734. * Gets the inter-frames time capture status
  46735. */
  46736. /**
  46737. * Enable or disable the inter-frames time capture
  46738. */
  46739. captureInterFrameTime: boolean;
  46740. /**
  46741. * Gets the perf counter used for render time capture
  46742. */
  46743. readonly renderTimeCounter: PerfCounter;
  46744. /**
  46745. * Gets the render time capture status
  46746. */
  46747. /**
  46748. * Enable or disable the render time capture
  46749. */
  46750. captureRenderTime: boolean;
  46751. /**
  46752. * Gets the perf counter used for camera render time capture
  46753. */
  46754. readonly cameraRenderTimeCounter: PerfCounter;
  46755. /**
  46756. * Gets the camera render time capture status
  46757. */
  46758. /**
  46759. * Enable or disable the camera render time capture
  46760. */
  46761. captureCameraRenderTime: boolean;
  46762. /**
  46763. * Gets the perf counter used for draw calls
  46764. */
  46765. readonly drawCallsCounter: PerfCounter;
  46766. /**
  46767. * Instantiates a new scene instrumentation.
  46768. * This class can be used to get instrumentation data from a Babylon engine
  46769. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46770. * @param scene Defines the scene to instrument
  46771. */
  46772. constructor(
  46773. /**
  46774. * Defines the scene to instrument
  46775. */
  46776. scene: Scene);
  46777. /**
  46778. * Dispose and release associated resources.
  46779. */
  46780. dispose(): void;
  46781. }
  46782. }
  46783. declare module BABYLON {
  46784. /** @hidden */
  46785. export var glowMapGenerationPixelShader: {
  46786. name: string;
  46787. shader: string;
  46788. };
  46789. }
  46790. declare module BABYLON {
  46791. /** @hidden */
  46792. export var glowMapGenerationVertexShader: {
  46793. name: string;
  46794. shader: string;
  46795. };
  46796. }
  46797. declare module BABYLON {
  46798. /**
  46799. * Effect layer options. This helps customizing the behaviour
  46800. * of the effect layer.
  46801. */
  46802. export interface IEffectLayerOptions {
  46803. /**
  46804. * Multiplication factor apply to the canvas size to compute the render target size
  46805. * used to generated the objects (the smaller the faster).
  46806. */
  46807. mainTextureRatio: number;
  46808. /**
  46809. * Enforces a fixed size texture to ensure effect stability across devices.
  46810. */
  46811. mainTextureFixedSize?: number;
  46812. /**
  46813. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46814. */
  46815. alphaBlendingMode: number;
  46816. /**
  46817. * The camera attached to the layer.
  46818. */
  46819. camera: Nullable<Camera>;
  46820. /**
  46821. * The rendering group to draw the layer in.
  46822. */
  46823. renderingGroupId: number;
  46824. }
  46825. /**
  46826. * The effect layer Helps adding post process effect blended with the main pass.
  46827. *
  46828. * This can be for instance use to generate glow or higlight effects on the scene.
  46829. *
  46830. * The effect layer class can not be used directly and is intented to inherited from to be
  46831. * customized per effects.
  46832. */
  46833. export abstract class EffectLayer {
  46834. private _vertexBuffers;
  46835. private _indexBuffer;
  46836. private _cachedDefines;
  46837. private _effectLayerMapGenerationEffect;
  46838. private _effectLayerOptions;
  46839. private _mergeEffect;
  46840. protected _scene: Scene;
  46841. protected _engine: Engine;
  46842. protected _maxSize: number;
  46843. protected _mainTextureDesiredSize: ISize;
  46844. protected _mainTexture: RenderTargetTexture;
  46845. protected _shouldRender: boolean;
  46846. protected _postProcesses: PostProcess[];
  46847. protected _textures: BaseTexture[];
  46848. protected _emissiveTextureAndColor: {
  46849. texture: Nullable<BaseTexture>;
  46850. color: Color4;
  46851. };
  46852. /**
  46853. * The name of the layer
  46854. */
  46855. name: string;
  46856. /**
  46857. * The clear color of the texture used to generate the glow map.
  46858. */
  46859. neutralColor: Color4;
  46860. /**
  46861. * Specifies wether the highlight layer is enabled or not.
  46862. */
  46863. isEnabled: boolean;
  46864. /**
  46865. * Gets the camera attached to the layer.
  46866. */
  46867. readonly camera: Nullable<Camera>;
  46868. /**
  46869. * Gets the rendering group id the layer should render in.
  46870. */
  46871. readonly renderingGroupId: number;
  46872. /**
  46873. * An event triggered when the effect layer has been disposed.
  46874. */
  46875. onDisposeObservable: Observable<EffectLayer>;
  46876. /**
  46877. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46878. */
  46879. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46880. /**
  46881. * An event triggered when the generated texture is being merged in the scene.
  46882. */
  46883. onBeforeComposeObservable: Observable<EffectLayer>;
  46884. /**
  46885. * An event triggered when the generated texture has been merged in the scene.
  46886. */
  46887. onAfterComposeObservable: Observable<EffectLayer>;
  46888. /**
  46889. * An event triggered when the efffect layer changes its size.
  46890. */
  46891. onSizeChangedObservable: Observable<EffectLayer>;
  46892. /** @hidden */
  46893. static _SceneComponentInitialization: (scene: Scene) => void;
  46894. /**
  46895. * Instantiates a new effect Layer and references it in the scene.
  46896. * @param name The name of the layer
  46897. * @param scene The scene to use the layer in
  46898. */
  46899. constructor(
  46900. /** The Friendly of the effect in the scene */
  46901. name: string, scene: Scene);
  46902. /**
  46903. * Get the effect name of the layer.
  46904. * @return The effect name
  46905. */
  46906. abstract getEffectName(): string;
  46907. /**
  46908. * Checks for the readiness of the element composing the layer.
  46909. * @param subMesh the mesh to check for
  46910. * @param useInstances specify wether or not to use instances to render the mesh
  46911. * @return true if ready otherwise, false
  46912. */
  46913. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46914. /**
  46915. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46916. * @returns true if the effect requires stencil during the main canvas render pass.
  46917. */
  46918. abstract needStencil(): boolean;
  46919. /**
  46920. * Create the merge effect. This is the shader use to blit the information back
  46921. * to the main canvas at the end of the scene rendering.
  46922. * @returns The effect containing the shader used to merge the effect on the main canvas
  46923. */
  46924. protected abstract _createMergeEffect(): Effect;
  46925. /**
  46926. * Creates the render target textures and post processes used in the effect layer.
  46927. */
  46928. protected abstract _createTextureAndPostProcesses(): void;
  46929. /**
  46930. * Implementation specific of rendering the generating effect on the main canvas.
  46931. * @param effect The effect used to render through
  46932. */
  46933. protected abstract _internalRender(effect: Effect): void;
  46934. /**
  46935. * Sets the required values for both the emissive texture and and the main color.
  46936. */
  46937. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46938. /**
  46939. * Free any resources and references associated to a mesh.
  46940. * Internal use
  46941. * @param mesh The mesh to free.
  46942. */
  46943. abstract _disposeMesh(mesh: Mesh): void;
  46944. /**
  46945. * Serializes this layer (Glow or Highlight for example)
  46946. * @returns a serialized layer object
  46947. */
  46948. abstract serialize?(): any;
  46949. /**
  46950. * Initializes the effect layer with the required options.
  46951. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46952. */
  46953. protected _init(options: Partial<IEffectLayerOptions>): void;
  46954. /**
  46955. * Generates the index buffer of the full screen quad blending to the main canvas.
  46956. */
  46957. private _generateIndexBuffer;
  46958. /**
  46959. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46960. */
  46961. private _generateVertexBuffer;
  46962. /**
  46963. * Sets the main texture desired size which is the closest power of two
  46964. * of the engine canvas size.
  46965. */
  46966. private _setMainTextureSize;
  46967. /**
  46968. * Creates the main texture for the effect layer.
  46969. */
  46970. protected _createMainTexture(): void;
  46971. /**
  46972. * Adds specific effects defines.
  46973. * @param defines The defines to add specifics to.
  46974. */
  46975. protected _addCustomEffectDefines(defines: string[]): void;
  46976. /**
  46977. * Checks for the readiness of the element composing the layer.
  46978. * @param subMesh the mesh to check for
  46979. * @param useInstances specify wether or not to use instances to render the mesh
  46980. * @param emissiveTexture the associated emissive texture used to generate the glow
  46981. * @return true if ready otherwise, false
  46982. */
  46983. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46984. /**
  46985. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46986. */
  46987. render(): void;
  46988. /**
  46989. * Determine if a given mesh will be used in the current effect.
  46990. * @param mesh mesh to test
  46991. * @returns true if the mesh will be used
  46992. */
  46993. hasMesh(mesh: AbstractMesh): boolean;
  46994. /**
  46995. * Returns true if the layer contains information to display, otherwise false.
  46996. * @returns true if the glow layer should be rendered
  46997. */
  46998. shouldRender(): boolean;
  46999. /**
  47000. * Returns true if the mesh should render, otherwise false.
  47001. * @param mesh The mesh to render
  47002. * @returns true if it should render otherwise false
  47003. */
  47004. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47005. /**
  47006. * Returns true if the mesh can be rendered, otherwise false.
  47007. * @param mesh The mesh to render
  47008. * @param material The material used on the mesh
  47009. * @returns true if it can be rendered otherwise false
  47010. */
  47011. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47012. /**
  47013. * Returns true if the mesh should render, otherwise false.
  47014. * @param mesh The mesh to render
  47015. * @returns true if it should render otherwise false
  47016. */
  47017. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47018. /**
  47019. * Renders the submesh passed in parameter to the generation map.
  47020. */
  47021. protected _renderSubMesh(subMesh: SubMesh): void;
  47022. /**
  47023. * Rebuild the required buffers.
  47024. * @hidden Internal use only.
  47025. */
  47026. _rebuild(): void;
  47027. /**
  47028. * Dispose only the render target textures and post process.
  47029. */
  47030. private _disposeTextureAndPostProcesses;
  47031. /**
  47032. * Dispose the highlight layer and free resources.
  47033. */
  47034. dispose(): void;
  47035. /**
  47036. * Gets the class name of the effect layer
  47037. * @returns the string with the class name of the effect layer
  47038. */
  47039. getClassName(): string;
  47040. /**
  47041. * Creates an effect layer from parsed effect layer data
  47042. * @param parsedEffectLayer defines effect layer data
  47043. * @param scene defines the current scene
  47044. * @param rootUrl defines the root URL containing the effect layer information
  47045. * @returns a parsed effect Layer
  47046. */
  47047. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47048. }
  47049. }
  47050. declare module BABYLON {
  47051. interface AbstractScene {
  47052. /**
  47053. * The list of effect layers (highlights/glow) added to the scene
  47054. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47055. * @see http://doc.babylonjs.com/how_to/glow_layer
  47056. */
  47057. effectLayers: Array<EffectLayer>;
  47058. /**
  47059. * Removes the given effect layer from this scene.
  47060. * @param toRemove defines the effect layer to remove
  47061. * @returns the index of the removed effect layer
  47062. */
  47063. removeEffectLayer(toRemove: EffectLayer): number;
  47064. /**
  47065. * Adds the given effect layer to this scene
  47066. * @param newEffectLayer defines the effect layer to add
  47067. */
  47068. addEffectLayer(newEffectLayer: EffectLayer): void;
  47069. }
  47070. /**
  47071. * Defines the layer scene component responsible to manage any effect layers
  47072. * in a given scene.
  47073. */
  47074. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47075. /**
  47076. * The component name helpfull to identify the component in the list of scene components.
  47077. */
  47078. readonly name: string;
  47079. /**
  47080. * The scene the component belongs to.
  47081. */
  47082. scene: Scene;
  47083. private _engine;
  47084. private _renderEffects;
  47085. private _needStencil;
  47086. private _previousStencilState;
  47087. /**
  47088. * Creates a new instance of the component for the given scene
  47089. * @param scene Defines the scene to register the component in
  47090. */
  47091. constructor(scene: Scene);
  47092. /**
  47093. * Registers the component in a given scene
  47094. */
  47095. register(): void;
  47096. /**
  47097. * Rebuilds the elements related to this component in case of
  47098. * context lost for instance.
  47099. */
  47100. rebuild(): void;
  47101. /**
  47102. * Serializes the component data to the specified json object
  47103. * @param serializationObject The object to serialize to
  47104. */
  47105. serialize(serializationObject: any): void;
  47106. /**
  47107. * Adds all the element from the container to the scene
  47108. * @param container the container holding the elements
  47109. */
  47110. addFromContainer(container: AbstractScene): void;
  47111. /**
  47112. * Removes all the elements in the container from the scene
  47113. * @param container contains the elements to remove
  47114. * @param dispose if the removed element should be disposed (default: false)
  47115. */
  47116. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47117. /**
  47118. * Disposes the component and the associated ressources.
  47119. */
  47120. dispose(): void;
  47121. private _isReadyForMesh;
  47122. private _renderMainTexture;
  47123. private _setStencil;
  47124. private _setStencilBack;
  47125. private _draw;
  47126. private _drawCamera;
  47127. private _drawRenderingGroup;
  47128. }
  47129. }
  47130. declare module BABYLON {
  47131. /** @hidden */
  47132. export var glowMapMergePixelShader: {
  47133. name: string;
  47134. shader: string;
  47135. };
  47136. }
  47137. declare module BABYLON {
  47138. /** @hidden */
  47139. export var glowMapMergeVertexShader: {
  47140. name: string;
  47141. shader: string;
  47142. };
  47143. }
  47144. declare module BABYLON {
  47145. interface AbstractScene {
  47146. /**
  47147. * Return a the first highlight layer of the scene with a given name.
  47148. * @param name The name of the highlight layer to look for.
  47149. * @return The highlight layer if found otherwise null.
  47150. */
  47151. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47152. }
  47153. /**
  47154. * Glow layer options. This helps customizing the behaviour
  47155. * of the glow layer.
  47156. */
  47157. export interface IGlowLayerOptions {
  47158. /**
  47159. * Multiplication factor apply to the canvas size to compute the render target size
  47160. * used to generated the glowing objects (the smaller the faster).
  47161. */
  47162. mainTextureRatio: number;
  47163. /**
  47164. * Enforces a fixed size texture to ensure resize independant blur.
  47165. */
  47166. mainTextureFixedSize?: number;
  47167. /**
  47168. * How big is the kernel of the blur texture.
  47169. */
  47170. blurKernelSize: number;
  47171. /**
  47172. * The camera attached to the layer.
  47173. */
  47174. camera: Nullable<Camera>;
  47175. /**
  47176. * Enable MSAA by chosing the number of samples.
  47177. */
  47178. mainTextureSamples?: number;
  47179. /**
  47180. * The rendering group to draw the layer in.
  47181. */
  47182. renderingGroupId: number;
  47183. }
  47184. /**
  47185. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47186. *
  47187. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47188. * glowy meshes to your scene.
  47189. *
  47190. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47191. */
  47192. export class GlowLayer extends EffectLayer {
  47193. /**
  47194. * Effect Name of the layer.
  47195. */
  47196. static readonly EffectName: string;
  47197. /**
  47198. * The default blur kernel size used for the glow.
  47199. */
  47200. static DefaultBlurKernelSize: number;
  47201. /**
  47202. * The default texture size ratio used for the glow.
  47203. */
  47204. static DefaultTextureRatio: number;
  47205. /**
  47206. * Sets the kernel size of the blur.
  47207. */
  47208. /**
  47209. * Gets the kernel size of the blur.
  47210. */
  47211. blurKernelSize: number;
  47212. /**
  47213. * Sets the glow intensity.
  47214. */
  47215. /**
  47216. * Gets the glow intensity.
  47217. */
  47218. intensity: number;
  47219. private _options;
  47220. private _intensity;
  47221. private _horizontalBlurPostprocess1;
  47222. private _verticalBlurPostprocess1;
  47223. private _horizontalBlurPostprocess2;
  47224. private _verticalBlurPostprocess2;
  47225. private _blurTexture1;
  47226. private _blurTexture2;
  47227. private _postProcesses1;
  47228. private _postProcesses2;
  47229. private _includedOnlyMeshes;
  47230. private _excludedMeshes;
  47231. /**
  47232. * Callback used to let the user override the color selection on a per mesh basis
  47233. */
  47234. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47235. /**
  47236. * Callback used to let the user override the texture selection on a per mesh basis
  47237. */
  47238. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47239. /**
  47240. * Instantiates a new glow Layer and references it to the scene.
  47241. * @param name The name of the layer
  47242. * @param scene The scene to use the layer in
  47243. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47244. */
  47245. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47246. /**
  47247. * Get the effect name of the layer.
  47248. * @return The effect name
  47249. */
  47250. getEffectName(): string;
  47251. /**
  47252. * Create the merge effect. This is the shader use to blit the information back
  47253. * to the main canvas at the end of the scene rendering.
  47254. */
  47255. protected _createMergeEffect(): Effect;
  47256. /**
  47257. * Creates the render target textures and post processes used in the glow layer.
  47258. */
  47259. protected _createTextureAndPostProcesses(): void;
  47260. /**
  47261. * Checks for the readiness of the element composing the layer.
  47262. * @param subMesh the mesh to check for
  47263. * @param useInstances specify wether or not to use instances to render the mesh
  47264. * @param emissiveTexture the associated emissive texture used to generate the glow
  47265. * @return true if ready otherwise, false
  47266. */
  47267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47268. /**
  47269. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47270. */
  47271. needStencil(): boolean;
  47272. /**
  47273. * Returns true if the mesh can be rendered, otherwise false.
  47274. * @param mesh The mesh to render
  47275. * @param material The material used on the mesh
  47276. * @returns true if it can be rendered otherwise false
  47277. */
  47278. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47279. /**
  47280. * Implementation specific of rendering the generating effect on the main canvas.
  47281. * @param effect The effect used to render through
  47282. */
  47283. protected _internalRender(effect: Effect): void;
  47284. /**
  47285. * Sets the required values for both the emissive texture and and the main color.
  47286. */
  47287. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47288. /**
  47289. * Returns true if the mesh should render, otherwise false.
  47290. * @param mesh The mesh to render
  47291. * @returns true if it should render otherwise false
  47292. */
  47293. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47294. /**
  47295. * Adds specific effects defines.
  47296. * @param defines The defines to add specifics to.
  47297. */
  47298. protected _addCustomEffectDefines(defines: string[]): void;
  47299. /**
  47300. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47301. * @param mesh The mesh to exclude from the glow layer
  47302. */
  47303. addExcludedMesh(mesh: Mesh): void;
  47304. /**
  47305. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47306. * @param mesh The mesh to remove
  47307. */
  47308. removeExcludedMesh(mesh: Mesh): void;
  47309. /**
  47310. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47311. * @param mesh The mesh to include in the glow layer
  47312. */
  47313. addIncludedOnlyMesh(mesh: Mesh): void;
  47314. /**
  47315. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47316. * @param mesh The mesh to remove
  47317. */
  47318. removeIncludedOnlyMesh(mesh: Mesh): void;
  47319. /**
  47320. * Determine if a given mesh will be used in the glow layer
  47321. * @param mesh The mesh to test
  47322. * @returns true if the mesh will be highlighted by the current glow layer
  47323. */
  47324. hasMesh(mesh: AbstractMesh): boolean;
  47325. /**
  47326. * Free any resources and references associated to a mesh.
  47327. * Internal use
  47328. * @param mesh The mesh to free.
  47329. * @hidden
  47330. */
  47331. _disposeMesh(mesh: Mesh): void;
  47332. /**
  47333. * Gets the class name of the effect layer
  47334. * @returns the string with the class name of the effect layer
  47335. */
  47336. getClassName(): string;
  47337. /**
  47338. * Serializes this glow layer
  47339. * @returns a serialized glow layer object
  47340. */
  47341. serialize(): any;
  47342. /**
  47343. * Creates a Glow Layer from parsed glow layer data
  47344. * @param parsedGlowLayer defines glow layer data
  47345. * @param scene defines the current scene
  47346. * @param rootUrl defines the root URL containing the glow layer information
  47347. * @returns a parsed Glow Layer
  47348. */
  47349. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47350. }
  47351. }
  47352. declare module BABYLON {
  47353. /** @hidden */
  47354. export var glowBlurPostProcessPixelShader: {
  47355. name: string;
  47356. shader: string;
  47357. };
  47358. }
  47359. declare module BABYLON {
  47360. interface AbstractScene {
  47361. /**
  47362. * Return a the first highlight layer of the scene with a given name.
  47363. * @param name The name of the highlight layer to look for.
  47364. * @return The highlight layer if found otherwise null.
  47365. */
  47366. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47367. }
  47368. /**
  47369. * Highlight layer options. This helps customizing the behaviour
  47370. * of the highlight layer.
  47371. */
  47372. export interface IHighlightLayerOptions {
  47373. /**
  47374. * Multiplication factor apply to the canvas size to compute the render target size
  47375. * used to generated the glowing objects (the smaller the faster).
  47376. */
  47377. mainTextureRatio: number;
  47378. /**
  47379. * Enforces a fixed size texture to ensure resize independant blur.
  47380. */
  47381. mainTextureFixedSize?: number;
  47382. /**
  47383. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47384. * of the picture to blur (the smaller the faster).
  47385. */
  47386. blurTextureSizeRatio: number;
  47387. /**
  47388. * How big in texel of the blur texture is the vertical blur.
  47389. */
  47390. blurVerticalSize: number;
  47391. /**
  47392. * How big in texel of the blur texture is the horizontal blur.
  47393. */
  47394. blurHorizontalSize: number;
  47395. /**
  47396. * Alpha blending mode used to apply the blur. Default is combine.
  47397. */
  47398. alphaBlendingMode: number;
  47399. /**
  47400. * The camera attached to the layer.
  47401. */
  47402. camera: Nullable<Camera>;
  47403. /**
  47404. * Should we display highlight as a solid stroke?
  47405. */
  47406. isStroke?: boolean;
  47407. /**
  47408. * The rendering group to draw the layer in.
  47409. */
  47410. renderingGroupId: number;
  47411. }
  47412. /**
  47413. * The highlight layer Helps adding a glow effect around a mesh.
  47414. *
  47415. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47416. * glowy meshes to your scene.
  47417. *
  47418. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47419. */
  47420. export class HighlightLayer extends EffectLayer {
  47421. name: string;
  47422. /**
  47423. * Effect Name of the highlight layer.
  47424. */
  47425. static readonly EffectName: string;
  47426. /**
  47427. * The neutral color used during the preparation of the glow effect.
  47428. * This is black by default as the blend operation is a blend operation.
  47429. */
  47430. static NeutralColor: Color4;
  47431. /**
  47432. * Stencil value used for glowing meshes.
  47433. */
  47434. static GlowingMeshStencilReference: number;
  47435. /**
  47436. * Stencil value used for the other meshes in the scene.
  47437. */
  47438. static NormalMeshStencilReference: number;
  47439. /**
  47440. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47441. */
  47442. innerGlow: boolean;
  47443. /**
  47444. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47445. */
  47446. outerGlow: boolean;
  47447. /**
  47448. * Specifies the horizontal size of the blur.
  47449. */
  47450. /**
  47451. * Gets the horizontal size of the blur.
  47452. */
  47453. blurHorizontalSize: number;
  47454. /**
  47455. * Specifies the vertical size of the blur.
  47456. */
  47457. /**
  47458. * Gets the vertical size of the blur.
  47459. */
  47460. blurVerticalSize: number;
  47461. /**
  47462. * An event triggered when the highlight layer is being blurred.
  47463. */
  47464. onBeforeBlurObservable: Observable<HighlightLayer>;
  47465. /**
  47466. * An event triggered when the highlight layer has been blurred.
  47467. */
  47468. onAfterBlurObservable: Observable<HighlightLayer>;
  47469. private _instanceGlowingMeshStencilReference;
  47470. private _options;
  47471. private _downSamplePostprocess;
  47472. private _horizontalBlurPostprocess;
  47473. private _verticalBlurPostprocess;
  47474. private _blurTexture;
  47475. private _meshes;
  47476. private _excludedMeshes;
  47477. /**
  47478. * Instantiates a new highlight Layer and references it to the scene..
  47479. * @param name The name of the layer
  47480. * @param scene The scene to use the layer in
  47481. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47482. */
  47483. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47484. /**
  47485. * Get the effect name of the layer.
  47486. * @return The effect name
  47487. */
  47488. getEffectName(): string;
  47489. /**
  47490. * Create the merge effect. This is the shader use to blit the information back
  47491. * to the main canvas at the end of the scene rendering.
  47492. */
  47493. protected _createMergeEffect(): Effect;
  47494. /**
  47495. * Creates the render target textures and post processes used in the highlight layer.
  47496. */
  47497. protected _createTextureAndPostProcesses(): void;
  47498. /**
  47499. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47500. */
  47501. needStencil(): boolean;
  47502. /**
  47503. * Checks for the readiness of the element composing the layer.
  47504. * @param subMesh the mesh to check for
  47505. * @param useInstances specify wether or not to use instances to render the mesh
  47506. * @param emissiveTexture the associated emissive texture used to generate the glow
  47507. * @return true if ready otherwise, false
  47508. */
  47509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47510. /**
  47511. * Implementation specific of rendering the generating effect on the main canvas.
  47512. * @param effect The effect used to render through
  47513. */
  47514. protected _internalRender(effect: Effect): void;
  47515. /**
  47516. * Returns true if the layer contains information to display, otherwise false.
  47517. */
  47518. shouldRender(): boolean;
  47519. /**
  47520. * Returns true if the mesh should render, otherwise false.
  47521. * @param mesh The mesh to render
  47522. * @returns true if it should render otherwise false
  47523. */
  47524. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47525. /**
  47526. * Sets the required values for both the emissive texture and and the main color.
  47527. */
  47528. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47529. /**
  47530. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47531. * @param mesh The mesh to exclude from the highlight layer
  47532. */
  47533. addExcludedMesh(mesh: Mesh): void;
  47534. /**
  47535. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47536. * @param mesh The mesh to highlight
  47537. */
  47538. removeExcludedMesh(mesh: Mesh): void;
  47539. /**
  47540. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47541. * @param mesh mesh to test
  47542. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47543. */
  47544. hasMesh(mesh: AbstractMesh): boolean;
  47545. /**
  47546. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47547. * @param mesh The mesh to highlight
  47548. * @param color The color of the highlight
  47549. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47550. */
  47551. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47552. /**
  47553. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47554. * @param mesh The mesh to highlight
  47555. */
  47556. removeMesh(mesh: Mesh): void;
  47557. /**
  47558. * Force the stencil to the normal expected value for none glowing parts
  47559. */
  47560. private _defaultStencilReference;
  47561. /**
  47562. * Free any resources and references associated to a mesh.
  47563. * Internal use
  47564. * @param mesh The mesh to free.
  47565. * @hidden
  47566. */
  47567. _disposeMesh(mesh: Mesh): void;
  47568. /**
  47569. * Dispose the highlight layer and free resources.
  47570. */
  47571. dispose(): void;
  47572. /**
  47573. * Gets the class name of the effect layer
  47574. * @returns the string with the class name of the effect layer
  47575. */
  47576. getClassName(): string;
  47577. /**
  47578. * Serializes this Highlight layer
  47579. * @returns a serialized Highlight layer object
  47580. */
  47581. serialize(): any;
  47582. /**
  47583. * Creates a Highlight layer from parsed Highlight layer data
  47584. * @param parsedHightlightLayer defines the Highlight layer data
  47585. * @param scene defines the current scene
  47586. * @param rootUrl defines the root URL containing the Highlight layer information
  47587. * @returns a parsed Highlight layer
  47588. */
  47589. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47590. }
  47591. }
  47592. declare module BABYLON {
  47593. /** @hidden */
  47594. export var lensFlarePixelShader: {
  47595. name: string;
  47596. shader: string;
  47597. };
  47598. }
  47599. declare module BABYLON {
  47600. /** @hidden */
  47601. export var lensFlareVertexShader: {
  47602. name: string;
  47603. shader: string;
  47604. };
  47605. }
  47606. declare module BABYLON {
  47607. /**
  47608. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47609. * It is usually composed of several `lensFlare`.
  47610. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47611. */
  47612. export class LensFlareSystem {
  47613. /**
  47614. * Define the name of the lens flare system
  47615. */
  47616. name: string;
  47617. /**
  47618. * List of lens flares used in this system.
  47619. */
  47620. lensFlares: LensFlare[];
  47621. /**
  47622. * Define a limit from the border the lens flare can be visible.
  47623. */
  47624. borderLimit: number;
  47625. /**
  47626. * Define a viewport border we do not want to see the lens flare in.
  47627. */
  47628. viewportBorder: number;
  47629. /**
  47630. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47631. */
  47632. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47633. /**
  47634. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47635. */
  47636. layerMask: number;
  47637. /**
  47638. * Define the id of the lens flare system in the scene.
  47639. * (equal to name by default)
  47640. */
  47641. id: string;
  47642. private _scene;
  47643. private _emitter;
  47644. private _vertexBuffers;
  47645. private _indexBuffer;
  47646. private _effect;
  47647. private _positionX;
  47648. private _positionY;
  47649. private _isEnabled;
  47650. /** @hidden */
  47651. static _SceneComponentInitialization: (scene: Scene) => void;
  47652. /**
  47653. * Instantiates a lens flare system.
  47654. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47655. * It is usually composed of several `lensFlare`.
  47656. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47657. * @param name Define the name of the lens flare system in the scene
  47658. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47659. * @param scene Define the scene the lens flare system belongs to
  47660. */
  47661. constructor(
  47662. /**
  47663. * Define the name of the lens flare system
  47664. */
  47665. name: string, emitter: any, scene: Scene);
  47666. /**
  47667. * Define if the lens flare system is enabled.
  47668. */
  47669. isEnabled: boolean;
  47670. /**
  47671. * Get the scene the effects belongs to.
  47672. * @returns the scene holding the lens flare system
  47673. */
  47674. getScene(): Scene;
  47675. /**
  47676. * Get the emitter of the lens flare system.
  47677. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47678. * @returns the emitter of the lens flare system
  47679. */
  47680. getEmitter(): any;
  47681. /**
  47682. * Set the emitter of the lens flare system.
  47683. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47684. * @param newEmitter Define the new emitter of the system
  47685. */
  47686. setEmitter(newEmitter: any): void;
  47687. /**
  47688. * Get the lens flare system emitter position.
  47689. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47690. * @returns the position
  47691. */
  47692. getEmitterPosition(): Vector3;
  47693. /**
  47694. * @hidden
  47695. */
  47696. computeEffectivePosition(globalViewport: Viewport): boolean;
  47697. /** @hidden */
  47698. _isVisible(): boolean;
  47699. /**
  47700. * @hidden
  47701. */
  47702. render(): boolean;
  47703. /**
  47704. * Dispose and release the lens flare with its associated resources.
  47705. */
  47706. dispose(): void;
  47707. /**
  47708. * Parse a lens flare system from a JSON repressentation
  47709. * @param parsedLensFlareSystem Define the JSON to parse
  47710. * @param scene Define the scene the parsed system should be instantiated in
  47711. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47712. * @returns the parsed system
  47713. */
  47714. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47715. /**
  47716. * Serialize the current Lens Flare System into a JSON representation.
  47717. * @returns the serialized JSON
  47718. */
  47719. serialize(): any;
  47720. }
  47721. }
  47722. declare module BABYLON {
  47723. /**
  47724. * This represents one of the lens effect in a `lensFlareSystem`.
  47725. * It controls one of the indiviual texture used in the effect.
  47726. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47727. */
  47728. export class LensFlare {
  47729. /**
  47730. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47731. */
  47732. size: number;
  47733. /**
  47734. * 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.
  47735. */
  47736. position: number;
  47737. /**
  47738. * Define the lens color.
  47739. */
  47740. color: Color3;
  47741. /**
  47742. * Define the lens texture.
  47743. */
  47744. texture: Nullable<Texture>;
  47745. /**
  47746. * Define the alpha mode to render this particular lens.
  47747. */
  47748. alphaMode: number;
  47749. private _system;
  47750. /**
  47751. * Creates a new Lens Flare.
  47752. * This represents one of the lens effect in a `lensFlareSystem`.
  47753. * It controls one of the indiviual texture used in the effect.
  47754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47755. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47756. * @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.
  47757. * @param color Define the lens color
  47758. * @param imgUrl Define the lens texture url
  47759. * @param system Define the `lensFlareSystem` this flare is part of
  47760. * @returns The newly created Lens Flare
  47761. */
  47762. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47763. /**
  47764. * Instantiates a new Lens Flare.
  47765. * This represents one of the lens effect in a `lensFlareSystem`.
  47766. * It controls one of the indiviual texture used in the effect.
  47767. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47768. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47769. * @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.
  47770. * @param color Define the lens color
  47771. * @param imgUrl Define the lens texture url
  47772. * @param system Define the `lensFlareSystem` this flare is part of
  47773. */
  47774. constructor(
  47775. /**
  47776. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47777. */
  47778. size: number,
  47779. /**
  47780. * 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.
  47781. */
  47782. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47783. /**
  47784. * Dispose and release the lens flare with its associated resources.
  47785. */
  47786. dispose(): void;
  47787. }
  47788. }
  47789. declare module BABYLON {
  47790. interface AbstractScene {
  47791. /**
  47792. * The list of lens flare system added to the scene
  47793. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47794. */
  47795. lensFlareSystems: Array<LensFlareSystem>;
  47796. /**
  47797. * Removes the given lens flare system from this scene.
  47798. * @param toRemove The lens flare system to remove
  47799. * @returns The index of the removed lens flare system
  47800. */
  47801. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47802. /**
  47803. * Adds the given lens flare system to this scene
  47804. * @param newLensFlareSystem The lens flare system to add
  47805. */
  47806. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47807. /**
  47808. * Gets a lens flare system using its name
  47809. * @param name defines the name to look for
  47810. * @returns the lens flare system or null if not found
  47811. */
  47812. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47813. /**
  47814. * Gets a lens flare system using its id
  47815. * @param id defines the id to look for
  47816. * @returns the lens flare system or null if not found
  47817. */
  47818. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47819. }
  47820. /**
  47821. * Defines the lens flare scene component responsible to manage any lens flares
  47822. * in a given scene.
  47823. */
  47824. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47825. /**
  47826. * The component name helpfull to identify the component in the list of scene components.
  47827. */
  47828. readonly name: string;
  47829. /**
  47830. * The scene the component belongs to.
  47831. */
  47832. scene: Scene;
  47833. /**
  47834. * Creates a new instance of the component for the given scene
  47835. * @param scene Defines the scene to register the component in
  47836. */
  47837. constructor(scene: Scene);
  47838. /**
  47839. * Registers the component in a given scene
  47840. */
  47841. register(): void;
  47842. /**
  47843. * Rebuilds the elements related to this component in case of
  47844. * context lost for instance.
  47845. */
  47846. rebuild(): void;
  47847. /**
  47848. * Adds all the element from the container to the scene
  47849. * @param container the container holding the elements
  47850. */
  47851. addFromContainer(container: AbstractScene): void;
  47852. /**
  47853. * Removes all the elements in the container from the scene
  47854. * @param container contains the elements to remove
  47855. * @param dispose if the removed element should be disposed (default: false)
  47856. */
  47857. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47858. /**
  47859. * Serializes the component data to the specified json object
  47860. * @param serializationObject The object to serialize to
  47861. */
  47862. serialize(serializationObject: any): void;
  47863. /**
  47864. * Disposes the component and the associated ressources.
  47865. */
  47866. dispose(): void;
  47867. private _draw;
  47868. }
  47869. }
  47870. declare module BABYLON {
  47871. /**
  47872. * Defines the shadow generator component responsible to manage any shadow generators
  47873. * in a given scene.
  47874. */
  47875. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47876. /**
  47877. * The component name helpfull to identify the component in the list of scene components.
  47878. */
  47879. readonly name: string;
  47880. /**
  47881. * The scene the component belongs to.
  47882. */
  47883. scene: Scene;
  47884. /**
  47885. * Creates a new instance of the component for the given scene
  47886. * @param scene Defines the scene to register the component in
  47887. */
  47888. constructor(scene: Scene);
  47889. /**
  47890. * Registers the component in a given scene
  47891. */
  47892. register(): void;
  47893. /**
  47894. * Rebuilds the elements related to this component in case of
  47895. * context lost for instance.
  47896. */
  47897. rebuild(): void;
  47898. /**
  47899. * Serializes the component data to the specified json object
  47900. * @param serializationObject The object to serialize to
  47901. */
  47902. serialize(serializationObject: any): void;
  47903. /**
  47904. * Adds all the element from the container to the scene
  47905. * @param container the container holding the elements
  47906. */
  47907. addFromContainer(container: AbstractScene): void;
  47908. /**
  47909. * Removes all the elements in the container from the scene
  47910. * @param container contains the elements to remove
  47911. * @param dispose if the removed element should be disposed (default: false)
  47912. */
  47913. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47914. /**
  47915. * Rebuilds the elements related to this component in case of
  47916. * context lost for instance.
  47917. */
  47918. dispose(): void;
  47919. private _gatherRenderTargets;
  47920. }
  47921. }
  47922. declare module BABYLON {
  47923. /**
  47924. * A point light is a light defined by an unique point in world space.
  47925. * The light is emitted in every direction from this point.
  47926. * A good example of a point light is a standard light bulb.
  47927. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47928. */
  47929. export class PointLight extends ShadowLight {
  47930. private _shadowAngle;
  47931. /**
  47932. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47933. * This specifies what angle the shadow will use to be created.
  47934. *
  47935. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47936. */
  47937. /**
  47938. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47939. * This specifies what angle the shadow will use to be created.
  47940. *
  47941. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47942. */
  47943. shadowAngle: number;
  47944. /**
  47945. * Gets the direction if it has been set.
  47946. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47947. */
  47948. /**
  47949. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47950. */
  47951. direction: Vector3;
  47952. /**
  47953. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47954. * A PointLight emits the light in every direction.
  47955. * It can cast shadows.
  47956. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47957. * ```javascript
  47958. * var pointLight = new PointLight("pl", camera.position, scene);
  47959. * ```
  47960. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47961. * @param name The light friendly name
  47962. * @param position The position of the point light in the scene
  47963. * @param scene The scene the lights belongs to
  47964. */
  47965. constructor(name: string, position: Vector3, scene: Scene);
  47966. /**
  47967. * Returns the string "PointLight"
  47968. * @returns the class name
  47969. */
  47970. getClassName(): string;
  47971. /**
  47972. * Returns the integer 0.
  47973. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47974. */
  47975. getTypeID(): number;
  47976. /**
  47977. * Specifies wether or not the shadowmap should be a cube texture.
  47978. * @returns true if the shadowmap needs to be a cube texture.
  47979. */
  47980. needCube(): boolean;
  47981. /**
  47982. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47983. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47984. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47985. */
  47986. getShadowDirection(faceIndex?: number): Vector3;
  47987. /**
  47988. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47989. * - fov = PI / 2
  47990. * - aspect ratio : 1.0
  47991. * - z-near and far equal to the active camera minZ and maxZ.
  47992. * Returns the PointLight.
  47993. */
  47994. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47995. protected _buildUniformLayout(): void;
  47996. /**
  47997. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47998. * @param effect The effect to update
  47999. * @param lightIndex The index of the light in the effect to update
  48000. * @returns The point light
  48001. */
  48002. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48003. /**
  48004. * Prepares the list of defines specific to the light type.
  48005. * @param defines the list of defines
  48006. * @param lightIndex defines the index of the light for the effect
  48007. */
  48008. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48009. }
  48010. }
  48011. declare module BABYLON {
  48012. /**
  48013. * Header information of HDR texture files.
  48014. */
  48015. export interface HDRInfo {
  48016. /**
  48017. * The height of the texture in pixels.
  48018. */
  48019. height: number;
  48020. /**
  48021. * The width of the texture in pixels.
  48022. */
  48023. width: number;
  48024. /**
  48025. * The index of the beginning of the data in the binary file.
  48026. */
  48027. dataPosition: number;
  48028. }
  48029. /**
  48030. * This groups tools to convert HDR texture to native colors array.
  48031. */
  48032. export class HDRTools {
  48033. private static Ldexp;
  48034. private static Rgbe2float;
  48035. private static readStringLine;
  48036. /**
  48037. * Reads header information from an RGBE texture stored in a native array.
  48038. * More information on this format are available here:
  48039. * https://en.wikipedia.org/wiki/RGBE_image_format
  48040. *
  48041. * @param uint8array The binary file stored in native array.
  48042. * @return The header information.
  48043. */
  48044. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48045. /**
  48046. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48047. * This RGBE texture needs to store the information as a panorama.
  48048. *
  48049. * More information on this format are available here:
  48050. * https://en.wikipedia.org/wiki/RGBE_image_format
  48051. *
  48052. * @param buffer The binary file stored in an array buffer.
  48053. * @param size The expected size of the extracted cubemap.
  48054. * @return The Cube Map information.
  48055. */
  48056. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48057. /**
  48058. * Returns the pixels data extracted from an RGBE texture.
  48059. * This pixels will be stored left to right up to down in the R G B order in one array.
  48060. *
  48061. * More information on this format are available here:
  48062. * https://en.wikipedia.org/wiki/RGBE_image_format
  48063. *
  48064. * @param uint8array The binary file stored in an array buffer.
  48065. * @param hdrInfo The header information of the file.
  48066. * @return The pixels data in RGB right to left up to down order.
  48067. */
  48068. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48069. private static RGBE_ReadPixels_RLE;
  48070. }
  48071. }
  48072. declare module BABYLON {
  48073. /**
  48074. * This represents a texture coming from an HDR input.
  48075. *
  48076. * The only supported format is currently panorama picture stored in RGBE format.
  48077. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48078. */
  48079. export class HDRCubeTexture extends BaseTexture {
  48080. private static _facesMapping;
  48081. private _generateHarmonics;
  48082. private _noMipmap;
  48083. private _textureMatrix;
  48084. private _size;
  48085. private _onLoad;
  48086. private _onError;
  48087. /**
  48088. * The texture URL.
  48089. */
  48090. url: string;
  48091. /**
  48092. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48093. */
  48094. coordinatesMode: number;
  48095. protected _isBlocking: boolean;
  48096. /**
  48097. * Sets wether or not the texture is blocking during loading.
  48098. */
  48099. /**
  48100. * Gets wether or not the texture is blocking during loading.
  48101. */
  48102. isBlocking: boolean;
  48103. protected _rotationY: number;
  48104. /**
  48105. * Sets texture matrix rotation angle around Y axis in radians.
  48106. */
  48107. /**
  48108. * Gets texture matrix rotation angle around Y axis radians.
  48109. */
  48110. rotationY: number;
  48111. /**
  48112. * Gets or sets the center of the bounding box associated with the cube texture
  48113. * It must define where the camera used to render the texture was set
  48114. */
  48115. boundingBoxPosition: Vector3;
  48116. private _boundingBoxSize;
  48117. /**
  48118. * Gets or sets the size of the bounding box associated with the cube texture
  48119. * When defined, the cubemap will switch to local mode
  48120. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48121. * @example https://www.babylonjs-playground.com/#RNASML
  48122. */
  48123. boundingBoxSize: Vector3;
  48124. /**
  48125. * Instantiates an HDRTexture from the following parameters.
  48126. *
  48127. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48128. * @param scene The scene the texture will be used in
  48129. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48130. * @param noMipmap Forces to not generate the mipmap if true
  48131. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48132. * @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)
  48133. * @param reserved Reserved flag for internal use.
  48134. */
  48135. 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>);
  48136. /**
  48137. * Get the current class name of the texture useful for serialization or dynamic coding.
  48138. * @returns "HDRCubeTexture"
  48139. */
  48140. getClassName(): string;
  48141. /**
  48142. * Occurs when the file is raw .hdr file.
  48143. */
  48144. private loadTexture;
  48145. clone(): HDRCubeTexture;
  48146. delayLoad(): void;
  48147. /**
  48148. * Get the texture reflection matrix used to rotate/transform the reflection.
  48149. * @returns the reflection matrix
  48150. */
  48151. getReflectionTextureMatrix(): Matrix;
  48152. /**
  48153. * Set the texture reflection matrix used to rotate/transform the reflection.
  48154. * @param value Define the reflection matrix to set
  48155. */
  48156. setReflectionTextureMatrix(value: Matrix): void;
  48157. /**
  48158. * Parses a JSON representation of an HDR Texture in order to create the texture
  48159. * @param parsedTexture Define the JSON representation
  48160. * @param scene Define the scene the texture should be created in
  48161. * @param rootUrl Define the root url in case we need to load relative dependencies
  48162. * @returns the newly created texture after parsing
  48163. */
  48164. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48165. serialize(): any;
  48166. }
  48167. }
  48168. declare module BABYLON {
  48169. /**
  48170. * Class used to control physics engine
  48171. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48172. */
  48173. export class PhysicsEngine implements IPhysicsEngine {
  48174. private _physicsPlugin;
  48175. /**
  48176. * Global value used to control the smallest number supported by the simulation
  48177. */
  48178. static Epsilon: number;
  48179. private _impostors;
  48180. private _joints;
  48181. /**
  48182. * Gets the gravity vector used by the simulation
  48183. */
  48184. gravity: Vector3;
  48185. /**
  48186. * Factory used to create the default physics plugin.
  48187. * @returns The default physics plugin
  48188. */
  48189. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48190. /**
  48191. * Creates a new Physics Engine
  48192. * @param gravity defines the gravity vector used by the simulation
  48193. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48194. */
  48195. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48196. /**
  48197. * Sets the gravity vector used by the simulation
  48198. * @param gravity defines the gravity vector to use
  48199. */
  48200. setGravity(gravity: Vector3): void;
  48201. /**
  48202. * Set the time step of the physics engine.
  48203. * Default is 1/60.
  48204. * To slow it down, enter 1/600 for example.
  48205. * To speed it up, 1/30
  48206. * @param newTimeStep defines the new timestep to apply to this world.
  48207. */
  48208. setTimeStep(newTimeStep?: number): void;
  48209. /**
  48210. * Get the time step of the physics engine.
  48211. * @returns the current time step
  48212. */
  48213. getTimeStep(): number;
  48214. /**
  48215. * Release all resources
  48216. */
  48217. dispose(): void;
  48218. /**
  48219. * Gets the name of the current physics plugin
  48220. * @returns the name of the plugin
  48221. */
  48222. getPhysicsPluginName(): string;
  48223. /**
  48224. * Adding a new impostor for the impostor tracking.
  48225. * This will be done by the impostor itself.
  48226. * @param impostor the impostor to add
  48227. */
  48228. addImpostor(impostor: PhysicsImpostor): void;
  48229. /**
  48230. * Remove an impostor from the engine.
  48231. * This impostor and its mesh will not longer be updated by the physics engine.
  48232. * @param impostor the impostor to remove
  48233. */
  48234. removeImpostor(impostor: PhysicsImpostor): void;
  48235. /**
  48236. * Add a joint to the physics engine
  48237. * @param mainImpostor defines the main impostor to which the joint is added.
  48238. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48239. * @param joint defines the joint that will connect both impostors.
  48240. */
  48241. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48242. /**
  48243. * Removes a joint from the simulation
  48244. * @param mainImpostor defines the impostor used with the joint
  48245. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48246. * @param joint defines the joint to remove
  48247. */
  48248. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48249. /**
  48250. * Called by the scene. No need to call it.
  48251. * @param delta defines the timespam between frames
  48252. */
  48253. _step(delta: number): void;
  48254. /**
  48255. * Gets the current plugin used to run the simulation
  48256. * @returns current plugin
  48257. */
  48258. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48259. /**
  48260. * Gets the list of physic impostors
  48261. * @returns an array of PhysicsImpostor
  48262. */
  48263. getImpostors(): Array<PhysicsImpostor>;
  48264. /**
  48265. * Gets the impostor for a physics enabled object
  48266. * @param object defines the object impersonated by the impostor
  48267. * @returns the PhysicsImpostor or null if not found
  48268. */
  48269. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48270. /**
  48271. * Gets the impostor for a physics body object
  48272. * @param body defines physics body used by the impostor
  48273. * @returns the PhysicsImpostor or null if not found
  48274. */
  48275. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48276. /**
  48277. * Does a raycast in the physics world
  48278. * @param from when should the ray start?
  48279. * @param to when should the ray end?
  48280. * @returns PhysicsRaycastResult
  48281. */
  48282. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48283. }
  48284. }
  48285. declare module BABYLON {
  48286. /** @hidden */
  48287. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48288. private _useDeltaForWorldStep;
  48289. world: any;
  48290. name: string;
  48291. private _physicsMaterials;
  48292. private _fixedTimeStep;
  48293. private _cannonRaycastResult;
  48294. private _raycastResult;
  48295. private _removeAfterStep;
  48296. BJSCANNON: any;
  48297. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48298. setGravity(gravity: Vector3): void;
  48299. setTimeStep(timeStep: number): void;
  48300. getTimeStep(): number;
  48301. executeStep(delta: number): void;
  48302. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48303. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48304. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48305. private _processChildMeshes;
  48306. removePhysicsBody(impostor: PhysicsImpostor): void;
  48307. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48308. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48309. private _addMaterial;
  48310. private _checkWithEpsilon;
  48311. private _createShape;
  48312. private _createHeightmap;
  48313. private _minus90X;
  48314. private _plus90X;
  48315. private _tmpPosition;
  48316. private _tmpDeltaPosition;
  48317. private _tmpUnityRotation;
  48318. private _updatePhysicsBodyTransformation;
  48319. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48320. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48321. isSupported(): boolean;
  48322. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48323. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48324. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48325. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48326. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48327. getBodyMass(impostor: PhysicsImpostor): number;
  48328. getBodyFriction(impostor: PhysicsImpostor): number;
  48329. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48330. getBodyRestitution(impostor: PhysicsImpostor): number;
  48331. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48332. sleepBody(impostor: PhysicsImpostor): void;
  48333. wakeUpBody(impostor: PhysicsImpostor): void;
  48334. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48335. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48336. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48337. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48338. getRadius(impostor: PhysicsImpostor): number;
  48339. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48340. dispose(): void;
  48341. private _extendNamespace;
  48342. /**
  48343. * Does a raycast in the physics world
  48344. * @param from when should the ray start?
  48345. * @param to when should the ray end?
  48346. * @returns PhysicsRaycastResult
  48347. */
  48348. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48349. }
  48350. }
  48351. declare module BABYLON {
  48352. /** @hidden */
  48353. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48354. world: any;
  48355. name: string;
  48356. BJSOIMO: any;
  48357. private _raycastResult;
  48358. constructor(iterations?: number, oimoInjection?: any);
  48359. setGravity(gravity: Vector3): void;
  48360. setTimeStep(timeStep: number): void;
  48361. getTimeStep(): number;
  48362. private _tmpImpostorsArray;
  48363. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48364. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48365. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48366. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48367. private _tmpPositionVector;
  48368. removePhysicsBody(impostor: PhysicsImpostor): void;
  48369. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48370. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48371. isSupported(): boolean;
  48372. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48373. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48374. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48375. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48376. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48377. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48378. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48379. getBodyMass(impostor: PhysicsImpostor): number;
  48380. getBodyFriction(impostor: PhysicsImpostor): number;
  48381. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48382. getBodyRestitution(impostor: PhysicsImpostor): number;
  48383. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48384. sleepBody(impostor: PhysicsImpostor): void;
  48385. wakeUpBody(impostor: PhysicsImpostor): void;
  48386. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48387. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48388. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48389. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48390. getRadius(impostor: PhysicsImpostor): number;
  48391. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48392. dispose(): void;
  48393. /**
  48394. * Does a raycast in the physics world
  48395. * @param from when should the ray start?
  48396. * @param to when should the ray end?
  48397. * @returns PhysicsRaycastResult
  48398. */
  48399. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48400. }
  48401. }
  48402. declare module BABYLON {
  48403. /**
  48404. * Class containing static functions to help procedurally build meshes
  48405. */
  48406. export class RibbonBuilder {
  48407. /**
  48408. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48409. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48410. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48411. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48412. * * 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
  48413. * * 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
  48414. * * 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
  48415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48416. * * 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
  48417. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48418. * * 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
  48419. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48420. * * 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
  48421. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48423. * @param name defines the name of the mesh
  48424. * @param options defines the options used to create the mesh
  48425. * @param scene defines the hosting scene
  48426. * @returns the ribbon mesh
  48427. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48429. */
  48430. static CreateRibbon(name: string, options: {
  48431. pathArray: Vector3[][];
  48432. closeArray?: boolean;
  48433. closePath?: boolean;
  48434. offset?: number;
  48435. updatable?: boolean;
  48436. sideOrientation?: number;
  48437. frontUVs?: Vector4;
  48438. backUVs?: Vector4;
  48439. instance?: Mesh;
  48440. invertUV?: boolean;
  48441. uvs?: Vector2[];
  48442. colors?: Color4[];
  48443. }, scene?: Nullable<Scene>): Mesh;
  48444. }
  48445. }
  48446. declare module BABYLON {
  48447. /**
  48448. * Class containing static functions to help procedurally build meshes
  48449. */
  48450. export class ShapeBuilder {
  48451. /**
  48452. * 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.
  48453. * * 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.
  48454. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48455. * * 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.
  48456. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48457. * * 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
  48458. * * 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
  48459. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48461. * * 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
  48462. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48464. * @param name defines the name of the mesh
  48465. * @param options defines the options used to create the mesh
  48466. * @param scene defines the hosting scene
  48467. * @returns the extruded shape mesh
  48468. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48470. */
  48471. static ExtrudeShape(name: string, options: {
  48472. shape: Vector3[];
  48473. path: Vector3[];
  48474. scale?: number;
  48475. rotation?: number;
  48476. cap?: number;
  48477. updatable?: boolean;
  48478. sideOrientation?: number;
  48479. frontUVs?: Vector4;
  48480. backUVs?: Vector4;
  48481. instance?: Mesh;
  48482. invertUV?: boolean;
  48483. }, scene?: Nullable<Scene>): Mesh;
  48484. /**
  48485. * Creates an custom extruded shape mesh.
  48486. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48487. * * 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.
  48488. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48489. * * 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
  48490. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48491. * * 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
  48492. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48493. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48494. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48495. * * 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
  48496. * * 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
  48497. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48499. * * 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
  48500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48502. * @param name defines the name of the mesh
  48503. * @param options defines the options used to create the mesh
  48504. * @param scene defines the hosting scene
  48505. * @returns the custom extruded shape mesh
  48506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48509. */
  48510. static ExtrudeShapeCustom(name: string, options: {
  48511. shape: Vector3[];
  48512. path: Vector3[];
  48513. scaleFunction?: any;
  48514. rotationFunction?: any;
  48515. ribbonCloseArray?: boolean;
  48516. ribbonClosePath?: boolean;
  48517. cap?: number;
  48518. updatable?: boolean;
  48519. sideOrientation?: number;
  48520. frontUVs?: Vector4;
  48521. backUVs?: Vector4;
  48522. instance?: Mesh;
  48523. invertUV?: boolean;
  48524. }, scene?: Nullable<Scene>): Mesh;
  48525. private static _ExtrudeShapeGeneric;
  48526. }
  48527. }
  48528. declare module BABYLON {
  48529. /**
  48530. * AmmoJS Physics plugin
  48531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48532. * @see https://github.com/kripken/ammo.js/
  48533. */
  48534. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48535. private _useDeltaForWorldStep;
  48536. /**
  48537. * Reference to the Ammo library
  48538. */
  48539. bjsAMMO: any;
  48540. /**
  48541. * Created ammoJS world which physics bodies are added to
  48542. */
  48543. world: any;
  48544. /**
  48545. * Name of the plugin
  48546. */
  48547. name: string;
  48548. private _timeStep;
  48549. private _fixedTimeStep;
  48550. private _maxSteps;
  48551. private _tmpQuaternion;
  48552. private _tmpAmmoTransform;
  48553. private _tmpAmmoQuaternion;
  48554. private _tmpAmmoConcreteContactResultCallback;
  48555. private _collisionConfiguration;
  48556. private _dispatcher;
  48557. private _overlappingPairCache;
  48558. private _solver;
  48559. private _softBodySolver;
  48560. private _tmpAmmoVectorA;
  48561. private _tmpAmmoVectorB;
  48562. private _tmpAmmoVectorC;
  48563. private _tmpAmmoVectorD;
  48564. private _tmpContactCallbackResult;
  48565. private _tmpAmmoVectorRCA;
  48566. private _tmpAmmoVectorRCB;
  48567. private _raycastResult;
  48568. private static readonly DISABLE_COLLISION_FLAG;
  48569. private static readonly KINEMATIC_FLAG;
  48570. private static readonly DISABLE_DEACTIVATION_FLAG;
  48571. /**
  48572. * Initializes the ammoJS plugin
  48573. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48574. * @param ammoInjection can be used to inject your own ammo reference
  48575. */
  48576. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48577. /**
  48578. * Sets the gravity of the physics world (m/(s^2))
  48579. * @param gravity Gravity to set
  48580. */
  48581. setGravity(gravity: Vector3): void;
  48582. /**
  48583. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48584. * @param timeStep timestep to use in seconds
  48585. */
  48586. setTimeStep(timeStep: number): void;
  48587. /**
  48588. * 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)
  48589. * @param fixedTimeStep fixedTimeStep to use in seconds
  48590. */
  48591. setFixedTimeStep(fixedTimeStep: number): void;
  48592. /**
  48593. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48594. * @param maxSteps the maximum number of steps by the physics engine per frame
  48595. */
  48596. setMaxSteps(maxSteps: number): void;
  48597. /**
  48598. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48599. * @returns the current timestep in seconds
  48600. */
  48601. getTimeStep(): number;
  48602. private _isImpostorInContact;
  48603. private _isImpostorPairInContact;
  48604. private _stepSimulation;
  48605. /**
  48606. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48607. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48608. * After the step the babylon meshes are set to the position of the physics imposters
  48609. * @param delta amount of time to step forward
  48610. * @param impostors array of imposters to update before/after the step
  48611. */
  48612. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48613. /**
  48614. * Update babylon mesh to match physics world object
  48615. * @param impostor imposter to match
  48616. */
  48617. private _afterSoftStep;
  48618. /**
  48619. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48620. * @param impostor imposter to match
  48621. */
  48622. private _ropeStep;
  48623. /**
  48624. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48625. * @param impostor imposter to match
  48626. */
  48627. private _softbodyOrClothStep;
  48628. private _tmpVector;
  48629. private _tmpMatrix;
  48630. /**
  48631. * Applies an impulse on the imposter
  48632. * @param impostor imposter to apply impulse to
  48633. * @param force amount of force to be applied to the imposter
  48634. * @param contactPoint the location to apply the impulse on the imposter
  48635. */
  48636. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48637. /**
  48638. * Applies a force on the imposter
  48639. * @param impostor imposter to apply force
  48640. * @param force amount of force to be applied to the imposter
  48641. * @param contactPoint the location to apply the force on the imposter
  48642. */
  48643. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48644. /**
  48645. * Creates a physics body using the plugin
  48646. * @param impostor the imposter to create the physics body on
  48647. */
  48648. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48649. /**
  48650. * Removes the physics body from the imposter and disposes of the body's memory
  48651. * @param impostor imposter to remove the physics body from
  48652. */
  48653. removePhysicsBody(impostor: PhysicsImpostor): void;
  48654. /**
  48655. * Generates a joint
  48656. * @param impostorJoint the imposter joint to create the joint with
  48657. */
  48658. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48659. /**
  48660. * Removes a joint
  48661. * @param impostorJoint the imposter joint to remove the joint from
  48662. */
  48663. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48664. private _addMeshVerts;
  48665. /**
  48666. * Initialise the soft body vertices to match its object's (mesh) vertices
  48667. * Softbody vertices (nodes) are in world space and to match this
  48668. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48669. * @param impostor to create the softbody for
  48670. */
  48671. private _softVertexData;
  48672. /**
  48673. * Create an impostor's soft body
  48674. * @param impostor to create the softbody for
  48675. */
  48676. private _createSoftbody;
  48677. /**
  48678. * Create cloth for an impostor
  48679. * @param impostor to create the softbody for
  48680. */
  48681. private _createCloth;
  48682. /**
  48683. * Create rope for an impostor
  48684. * @param impostor to create the softbody for
  48685. */
  48686. private _createRope;
  48687. private _addHullVerts;
  48688. private _createShape;
  48689. /**
  48690. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48691. * @param impostor imposter containing the physics body and babylon object
  48692. */
  48693. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48694. /**
  48695. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48696. * @param impostor imposter containing the physics body and babylon object
  48697. * @param newPosition new position
  48698. * @param newRotation new rotation
  48699. */
  48700. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48701. /**
  48702. * If this plugin is supported
  48703. * @returns true if its supported
  48704. */
  48705. isSupported(): boolean;
  48706. /**
  48707. * Sets the linear velocity of the physics body
  48708. * @param impostor imposter to set the velocity on
  48709. * @param velocity velocity to set
  48710. */
  48711. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48712. /**
  48713. * Sets the angular velocity of the physics body
  48714. * @param impostor imposter to set the velocity on
  48715. * @param velocity velocity to set
  48716. */
  48717. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48718. /**
  48719. * gets the linear velocity
  48720. * @param impostor imposter to get linear velocity from
  48721. * @returns linear velocity
  48722. */
  48723. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48724. /**
  48725. * gets the angular velocity
  48726. * @param impostor imposter to get angular velocity from
  48727. * @returns angular velocity
  48728. */
  48729. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48730. /**
  48731. * Sets the mass of physics body
  48732. * @param impostor imposter to set the mass on
  48733. * @param mass mass to set
  48734. */
  48735. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48736. /**
  48737. * Gets the mass of the physics body
  48738. * @param impostor imposter to get the mass from
  48739. * @returns mass
  48740. */
  48741. getBodyMass(impostor: PhysicsImpostor): number;
  48742. /**
  48743. * Gets friction of the impostor
  48744. * @param impostor impostor to get friction from
  48745. * @returns friction value
  48746. */
  48747. getBodyFriction(impostor: PhysicsImpostor): number;
  48748. /**
  48749. * Sets friction of the impostor
  48750. * @param impostor impostor to set friction on
  48751. * @param friction friction value
  48752. */
  48753. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48754. /**
  48755. * Gets restitution of the impostor
  48756. * @param impostor impostor to get restitution from
  48757. * @returns restitution value
  48758. */
  48759. getBodyRestitution(impostor: PhysicsImpostor): number;
  48760. /**
  48761. * Sets resitution of the impostor
  48762. * @param impostor impostor to set resitution on
  48763. * @param restitution resitution value
  48764. */
  48765. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48766. /**
  48767. * Gets pressure inside the impostor
  48768. * @param impostor impostor to get pressure from
  48769. * @returns pressure value
  48770. */
  48771. getBodyPressure(impostor: PhysicsImpostor): number;
  48772. /**
  48773. * Sets pressure inside a soft body impostor
  48774. * Cloth and rope must remain 0 pressure
  48775. * @param impostor impostor to set pressure on
  48776. * @param pressure pressure value
  48777. */
  48778. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48779. /**
  48780. * Gets stiffness of the impostor
  48781. * @param impostor impostor to get stiffness from
  48782. * @returns pressure value
  48783. */
  48784. getBodyStiffness(impostor: PhysicsImpostor): number;
  48785. /**
  48786. * Sets stiffness of the impostor
  48787. * @param impostor impostor to set stiffness on
  48788. * @param stiffness stiffness value from 0 to 1
  48789. */
  48790. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48791. /**
  48792. * Gets velocityIterations of the impostor
  48793. * @param impostor impostor to get velocity iterations from
  48794. * @returns velocityIterations value
  48795. */
  48796. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48797. /**
  48798. * Sets velocityIterations of the impostor
  48799. * @param impostor impostor to set velocity iterations on
  48800. * @param velocityIterations velocityIterations value
  48801. */
  48802. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48803. /**
  48804. * Gets positionIterations of the impostor
  48805. * @param impostor impostor to get position iterations from
  48806. * @returns positionIterations value
  48807. */
  48808. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48809. /**
  48810. * Sets positionIterations of the impostor
  48811. * @param impostor impostor to set position on
  48812. * @param positionIterations positionIterations value
  48813. */
  48814. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48815. /**
  48816. * Append an anchor to a cloth object
  48817. * @param impostor is the cloth impostor to add anchor to
  48818. * @param otherImpostor is the rigid impostor to anchor to
  48819. * @param width ratio across width from 0 to 1
  48820. * @param height ratio up height from 0 to 1
  48821. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48822. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48823. */
  48824. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48825. /**
  48826. * Append an hook to a rope object
  48827. * @param impostor is the rope impostor to add hook to
  48828. * @param otherImpostor is the rigid impostor to hook to
  48829. * @param length ratio along the rope from 0 to 1
  48830. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48831. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48832. */
  48833. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48834. /**
  48835. * Sleeps the physics body and stops it from being active
  48836. * @param impostor impostor to sleep
  48837. */
  48838. sleepBody(impostor: PhysicsImpostor): void;
  48839. /**
  48840. * Activates the physics body
  48841. * @param impostor impostor to activate
  48842. */
  48843. wakeUpBody(impostor: PhysicsImpostor): void;
  48844. /**
  48845. * Updates the distance parameters of the joint
  48846. * @param joint joint to update
  48847. * @param maxDistance maximum distance of the joint
  48848. * @param minDistance minimum distance of the joint
  48849. */
  48850. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48851. /**
  48852. * Sets a motor on the joint
  48853. * @param joint joint to set motor on
  48854. * @param speed speed of the motor
  48855. * @param maxForce maximum force of the motor
  48856. * @param motorIndex index of the motor
  48857. */
  48858. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48859. /**
  48860. * Sets the motors limit
  48861. * @param joint joint to set limit on
  48862. * @param upperLimit upper limit
  48863. * @param lowerLimit lower limit
  48864. */
  48865. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48866. /**
  48867. * Syncs the position and rotation of a mesh with the impostor
  48868. * @param mesh mesh to sync
  48869. * @param impostor impostor to update the mesh with
  48870. */
  48871. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48872. /**
  48873. * Gets the radius of the impostor
  48874. * @param impostor impostor to get radius from
  48875. * @returns the radius
  48876. */
  48877. getRadius(impostor: PhysicsImpostor): number;
  48878. /**
  48879. * Gets the box size of the impostor
  48880. * @param impostor impostor to get box size from
  48881. * @param result the resulting box size
  48882. */
  48883. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48884. /**
  48885. * Disposes of the impostor
  48886. */
  48887. dispose(): void;
  48888. /**
  48889. * Does a raycast in the physics world
  48890. * @param from when should the ray start?
  48891. * @param to when should the ray end?
  48892. * @returns PhysicsRaycastResult
  48893. */
  48894. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48895. }
  48896. }
  48897. declare module BABYLON {
  48898. interface AbstractScene {
  48899. /**
  48900. * The list of reflection probes added to the scene
  48901. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48902. */
  48903. reflectionProbes: Array<ReflectionProbe>;
  48904. /**
  48905. * Removes the given reflection probe from this scene.
  48906. * @param toRemove The reflection probe to remove
  48907. * @returns The index of the removed reflection probe
  48908. */
  48909. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48910. /**
  48911. * Adds the given reflection probe to this scene.
  48912. * @param newReflectionProbe The reflection probe to add
  48913. */
  48914. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48915. }
  48916. /**
  48917. * Class used to generate realtime reflection / refraction cube textures
  48918. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48919. */
  48920. export class ReflectionProbe {
  48921. /** defines the name of the probe */
  48922. name: string;
  48923. private _scene;
  48924. private _renderTargetTexture;
  48925. private _projectionMatrix;
  48926. private _viewMatrix;
  48927. private _target;
  48928. private _add;
  48929. private _attachedMesh;
  48930. private _invertYAxis;
  48931. /** Gets or sets probe position (center of the cube map) */
  48932. position: Vector3;
  48933. /**
  48934. * Creates a new reflection probe
  48935. * @param name defines the name of the probe
  48936. * @param size defines the texture resolution (for each face)
  48937. * @param scene defines the hosting scene
  48938. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48939. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48940. */
  48941. constructor(
  48942. /** defines the name of the probe */
  48943. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48944. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48945. samples: number;
  48946. /** Gets or sets the refresh rate to use (on every frame by default) */
  48947. refreshRate: number;
  48948. /**
  48949. * Gets the hosting scene
  48950. * @returns a Scene
  48951. */
  48952. getScene(): Scene;
  48953. /** Gets the internal CubeTexture used to render to */
  48954. readonly cubeTexture: RenderTargetTexture;
  48955. /** Gets the list of meshes to render */
  48956. readonly renderList: Nullable<AbstractMesh[]>;
  48957. /**
  48958. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48959. * @param mesh defines the mesh to attach to
  48960. */
  48961. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48962. /**
  48963. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48964. * @param renderingGroupId The rendering group id corresponding to its index
  48965. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48966. */
  48967. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48968. /**
  48969. * Clean all associated resources
  48970. */
  48971. dispose(): void;
  48972. /**
  48973. * Converts the reflection probe information to a readable string for debug purpose.
  48974. * @param fullDetails Supports for multiple levels of logging within scene loading
  48975. * @returns the human readable reflection probe info
  48976. */
  48977. toString(fullDetails?: boolean): string;
  48978. /**
  48979. * Get the class name of the relfection probe.
  48980. * @returns "ReflectionProbe"
  48981. */
  48982. getClassName(): string;
  48983. /**
  48984. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48985. * @returns The JSON representation of the texture
  48986. */
  48987. serialize(): any;
  48988. /**
  48989. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48990. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48991. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48992. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48993. * @returns The parsed reflection probe if successful
  48994. */
  48995. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48996. }
  48997. }
  48998. declare module BABYLON {
  48999. /** @hidden */
  49000. export var _BabylonLoaderRegistered: boolean;
  49001. }
  49002. declare module BABYLON {
  49003. /**
  49004. * The Physically based simple base material of BJS.
  49005. *
  49006. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49007. * It is used as the base class for both the specGloss and metalRough conventions.
  49008. */
  49009. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49010. /**
  49011. * Number of Simultaneous lights allowed on the material.
  49012. */
  49013. maxSimultaneousLights: number;
  49014. /**
  49015. * If sets to true, disables all the lights affecting the material.
  49016. */
  49017. disableLighting: boolean;
  49018. /**
  49019. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49020. */
  49021. environmentTexture: BaseTexture;
  49022. /**
  49023. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49024. */
  49025. invertNormalMapX: boolean;
  49026. /**
  49027. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49028. */
  49029. invertNormalMapY: boolean;
  49030. /**
  49031. * Normal map used in the model.
  49032. */
  49033. normalTexture: BaseTexture;
  49034. /**
  49035. * Emissivie color used to self-illuminate the model.
  49036. */
  49037. emissiveColor: Color3;
  49038. /**
  49039. * Emissivie texture used to self-illuminate the model.
  49040. */
  49041. emissiveTexture: BaseTexture;
  49042. /**
  49043. * Occlusion Channel Strenght.
  49044. */
  49045. occlusionStrength: number;
  49046. /**
  49047. * Occlusion Texture of the material (adding extra occlusion effects).
  49048. */
  49049. occlusionTexture: BaseTexture;
  49050. /**
  49051. * Defines the alpha limits in alpha test mode.
  49052. */
  49053. alphaCutOff: number;
  49054. /**
  49055. * Gets the current double sided mode.
  49056. */
  49057. /**
  49058. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49059. */
  49060. doubleSided: boolean;
  49061. /**
  49062. * Stores the pre-calculated light information of a mesh in a texture.
  49063. */
  49064. lightmapTexture: BaseTexture;
  49065. /**
  49066. * If true, the light map contains occlusion information instead of lighting info.
  49067. */
  49068. useLightmapAsShadowmap: boolean;
  49069. /**
  49070. * Instantiates a new PBRMaterial instance.
  49071. *
  49072. * @param name The material name
  49073. * @param scene The scene the material will be use in.
  49074. */
  49075. constructor(name: string, scene: Scene);
  49076. getClassName(): string;
  49077. }
  49078. }
  49079. declare module BABYLON {
  49080. /**
  49081. * The PBR material of BJS following the metal roughness convention.
  49082. *
  49083. * This fits to the PBR convention in the GLTF definition:
  49084. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49085. */
  49086. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49087. /**
  49088. * The base color has two different interpretations depending on the value of metalness.
  49089. * When the material is a metal, the base color is the specific measured reflectance value
  49090. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49091. * of the material.
  49092. */
  49093. baseColor: Color3;
  49094. /**
  49095. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49096. * well as opacity information in the alpha channel.
  49097. */
  49098. baseTexture: BaseTexture;
  49099. /**
  49100. * Specifies the metallic scalar value of the material.
  49101. * Can also be used to scale the metalness values of the metallic texture.
  49102. */
  49103. metallic: number;
  49104. /**
  49105. * Specifies the roughness scalar value of the material.
  49106. * Can also be used to scale the roughness values of the metallic texture.
  49107. */
  49108. roughness: number;
  49109. /**
  49110. * Texture containing both the metallic value in the B channel and the
  49111. * roughness value in the G channel to keep better precision.
  49112. */
  49113. metallicRoughnessTexture: BaseTexture;
  49114. /**
  49115. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49116. *
  49117. * @param name The material name
  49118. * @param scene The scene the material will be use in.
  49119. */
  49120. constructor(name: string, scene: Scene);
  49121. /**
  49122. * Return the currrent class name of the material.
  49123. */
  49124. getClassName(): string;
  49125. /**
  49126. * Makes a duplicate of the current material.
  49127. * @param name - name to use for the new material.
  49128. */
  49129. clone(name: string): PBRMetallicRoughnessMaterial;
  49130. /**
  49131. * Serialize the material to a parsable JSON object.
  49132. */
  49133. serialize(): any;
  49134. /**
  49135. * Parses a JSON object correponding to the serialize function.
  49136. */
  49137. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49138. }
  49139. }
  49140. declare module BABYLON {
  49141. /**
  49142. * The PBR material of BJS following the specular glossiness convention.
  49143. *
  49144. * This fits to the PBR convention in the GLTF definition:
  49145. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49146. */
  49147. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49148. /**
  49149. * Specifies the diffuse color of the material.
  49150. */
  49151. diffuseColor: Color3;
  49152. /**
  49153. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49154. * channel.
  49155. */
  49156. diffuseTexture: BaseTexture;
  49157. /**
  49158. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49159. */
  49160. specularColor: Color3;
  49161. /**
  49162. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49163. */
  49164. glossiness: number;
  49165. /**
  49166. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49167. */
  49168. specularGlossinessTexture: BaseTexture;
  49169. /**
  49170. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49171. *
  49172. * @param name The material name
  49173. * @param scene The scene the material will be use in.
  49174. */
  49175. constructor(name: string, scene: Scene);
  49176. /**
  49177. * Return the currrent class name of the material.
  49178. */
  49179. getClassName(): string;
  49180. /**
  49181. * Makes a duplicate of the current material.
  49182. * @param name - name to use for the new material.
  49183. */
  49184. clone(name: string): PBRSpecularGlossinessMaterial;
  49185. /**
  49186. * Serialize the material to a parsable JSON object.
  49187. */
  49188. serialize(): any;
  49189. /**
  49190. * Parses a JSON object correponding to the serialize function.
  49191. */
  49192. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49193. }
  49194. }
  49195. declare module BABYLON {
  49196. /**
  49197. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49198. * It can help converting any input color in a desired output one. This can then be used to create effects
  49199. * from sepia, black and white to sixties or futuristic rendering...
  49200. *
  49201. * The only supported format is currently 3dl.
  49202. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49203. */
  49204. export class ColorGradingTexture extends BaseTexture {
  49205. /**
  49206. * The current texture matrix. (will always be identity in color grading texture)
  49207. */
  49208. private _textureMatrix;
  49209. /**
  49210. * The texture URL.
  49211. */
  49212. url: string;
  49213. /**
  49214. * Empty line regex stored for GC.
  49215. */
  49216. private static _noneEmptyLineRegex;
  49217. private _engine;
  49218. /**
  49219. * Instantiates a ColorGradingTexture from the following parameters.
  49220. *
  49221. * @param url The location of the color gradind data (currently only supporting 3dl)
  49222. * @param scene The scene the texture will be used in
  49223. */
  49224. constructor(url: string, scene: Scene);
  49225. /**
  49226. * Returns the texture matrix used in most of the material.
  49227. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49228. */
  49229. getTextureMatrix(): Matrix;
  49230. /**
  49231. * Occurs when the file being loaded is a .3dl LUT file.
  49232. */
  49233. private load3dlTexture;
  49234. /**
  49235. * Starts the loading process of the texture.
  49236. */
  49237. private loadTexture;
  49238. /**
  49239. * Clones the color gradind texture.
  49240. */
  49241. clone(): ColorGradingTexture;
  49242. /**
  49243. * Called during delayed load for textures.
  49244. */
  49245. delayLoad(): void;
  49246. /**
  49247. * Parses a color grading texture serialized by Babylon.
  49248. * @param parsedTexture The texture information being parsedTexture
  49249. * @param scene The scene to load the texture in
  49250. * @param rootUrl The root url of the data assets to load
  49251. * @return A color gradind texture
  49252. */
  49253. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49254. /**
  49255. * Serializes the LUT texture to json format.
  49256. */
  49257. serialize(): any;
  49258. }
  49259. }
  49260. declare module BABYLON {
  49261. /**
  49262. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49263. */
  49264. export class EquiRectangularCubeTexture extends BaseTexture {
  49265. /** The six faces of the cube. */
  49266. private static _FacesMapping;
  49267. private _noMipmap;
  49268. private _onLoad;
  49269. private _onError;
  49270. /** The size of the cubemap. */
  49271. private _size;
  49272. /** The buffer of the image. */
  49273. private _buffer;
  49274. /** The width of the input image. */
  49275. private _width;
  49276. /** The height of the input image. */
  49277. private _height;
  49278. /** The URL to the image. */
  49279. url: string;
  49280. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49281. coordinatesMode: number;
  49282. /**
  49283. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49284. * @param url The location of the image
  49285. * @param scene The scene the texture will be used in
  49286. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49287. * @param noMipmap Forces to not generate the mipmap if true
  49288. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49289. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49290. * @param onLoad — defines a callback called when texture is loaded
  49291. * @param onError — defines a callback called if there is an error
  49292. */
  49293. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49294. /**
  49295. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49296. */
  49297. private loadImage;
  49298. /**
  49299. * Convert the image buffer into a cubemap and create a CubeTexture.
  49300. */
  49301. private loadTexture;
  49302. /**
  49303. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49304. * @param buffer The ArrayBuffer that should be converted.
  49305. * @returns The buffer as Float32Array.
  49306. */
  49307. private getFloat32ArrayFromArrayBuffer;
  49308. /**
  49309. * Get the current class name of the texture useful for serialization or dynamic coding.
  49310. * @returns "EquiRectangularCubeTexture"
  49311. */
  49312. getClassName(): string;
  49313. /**
  49314. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49315. * @returns A clone of the current EquiRectangularCubeTexture.
  49316. */
  49317. clone(): EquiRectangularCubeTexture;
  49318. }
  49319. }
  49320. declare module BABYLON {
  49321. /**
  49322. * Based on jsTGALoader - Javascript loader for TGA file
  49323. * By Vincent Thibault
  49324. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49325. */
  49326. export class TGATools {
  49327. private static _TYPE_INDEXED;
  49328. private static _TYPE_RGB;
  49329. private static _TYPE_GREY;
  49330. private static _TYPE_RLE_INDEXED;
  49331. private static _TYPE_RLE_RGB;
  49332. private static _TYPE_RLE_GREY;
  49333. private static _ORIGIN_MASK;
  49334. private static _ORIGIN_SHIFT;
  49335. private static _ORIGIN_BL;
  49336. private static _ORIGIN_BR;
  49337. private static _ORIGIN_UL;
  49338. private static _ORIGIN_UR;
  49339. /**
  49340. * Gets the header of a TGA file
  49341. * @param data defines the TGA data
  49342. * @returns the header
  49343. */
  49344. static GetTGAHeader(data: Uint8Array): any;
  49345. /**
  49346. * Uploads TGA content to a Babylon Texture
  49347. * @hidden
  49348. */
  49349. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49350. /** @hidden */
  49351. 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;
  49352. /** @hidden */
  49353. 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;
  49354. /** @hidden */
  49355. 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;
  49356. /** @hidden */
  49357. 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;
  49358. /** @hidden */
  49359. 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;
  49360. /** @hidden */
  49361. 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;
  49362. }
  49363. }
  49364. declare module BABYLON {
  49365. /**
  49366. * Implementation of the TGA Texture Loader.
  49367. * @hidden
  49368. */
  49369. export class _TGATextureLoader implements IInternalTextureLoader {
  49370. /**
  49371. * Defines wether the loader supports cascade loading the different faces.
  49372. */
  49373. readonly supportCascades: boolean;
  49374. /**
  49375. * This returns if the loader support the current file information.
  49376. * @param extension defines the file extension of the file being loaded
  49377. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49378. * @param fallback defines the fallback internal texture if any
  49379. * @param isBase64 defines whether the texture is encoded as a base64
  49380. * @param isBuffer defines whether the texture data are stored as a buffer
  49381. * @returns true if the loader can load the specified file
  49382. */
  49383. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49384. /**
  49385. * Transform the url before loading if required.
  49386. * @param rootUrl the url of the texture
  49387. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49388. * @returns the transformed texture
  49389. */
  49390. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49391. /**
  49392. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49393. * @param rootUrl the url of the texture
  49394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49395. * @returns the fallback texture
  49396. */
  49397. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49398. /**
  49399. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49400. * @param data contains the texture data
  49401. * @param texture defines the BabylonJS internal texture
  49402. * @param createPolynomials will be true if polynomials have been requested
  49403. * @param onLoad defines the callback to trigger once the texture is ready
  49404. * @param onError defines the callback to trigger in case of error
  49405. */
  49406. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49407. /**
  49408. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49409. * @param data contains the texture data
  49410. * @param texture defines the BabylonJS internal texture
  49411. * @param callback defines the method to call once ready to upload
  49412. */
  49413. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49414. }
  49415. }
  49416. declare module BABYLON {
  49417. /**
  49418. * 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.
  49419. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49420. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49421. */
  49422. export class CustomProceduralTexture extends ProceduralTexture {
  49423. private _animate;
  49424. private _time;
  49425. private _config;
  49426. private _texturePath;
  49427. /**
  49428. * Instantiates a new Custom Procedural Texture.
  49429. * 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.
  49430. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49431. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49432. * @param name Define the name of the texture
  49433. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49434. * @param size Define the size of the texture to create
  49435. * @param scene Define the scene the texture belongs to
  49436. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49437. * @param generateMipMaps Define if the texture should creates mip maps or not
  49438. */
  49439. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49440. private _loadJson;
  49441. /**
  49442. * Is the texture ready to be used ? (rendered at least once)
  49443. * @returns true if ready, otherwise, false.
  49444. */
  49445. isReady(): boolean;
  49446. /**
  49447. * Render the texture to its associated render target.
  49448. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49449. */
  49450. render(useCameraPostProcess?: boolean): void;
  49451. /**
  49452. * Update the list of dependant textures samplers in the shader.
  49453. */
  49454. updateTextures(): void;
  49455. /**
  49456. * Update the uniform values of the procedural texture in the shader.
  49457. */
  49458. updateShaderUniforms(): void;
  49459. /**
  49460. * Define if the texture animates or not.
  49461. */
  49462. animate: boolean;
  49463. }
  49464. }
  49465. declare module BABYLON {
  49466. /** @hidden */
  49467. export var noisePixelShader: {
  49468. name: string;
  49469. shader: string;
  49470. };
  49471. }
  49472. declare module BABYLON {
  49473. /**
  49474. * Class used to generate noise procedural textures
  49475. */
  49476. export class NoiseProceduralTexture extends ProceduralTexture {
  49477. private _time;
  49478. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49479. brightness: number;
  49480. /** Defines the number of octaves to process */
  49481. octaves: number;
  49482. /** Defines the level of persistence (0.8 by default) */
  49483. persistence: number;
  49484. /** Gets or sets animation speed factor (default is 1) */
  49485. animationSpeedFactor: number;
  49486. /**
  49487. * Creates a new NoiseProceduralTexture
  49488. * @param name defines the name fo the texture
  49489. * @param size defines the size of the texture (default is 256)
  49490. * @param scene defines the hosting scene
  49491. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49492. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49493. */
  49494. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49495. private _updateShaderUniforms;
  49496. protected _getDefines(): string;
  49497. /** Generate the current state of the procedural texture */
  49498. render(useCameraPostProcess?: boolean): void;
  49499. /**
  49500. * Serializes this noise procedural texture
  49501. * @returns a serialized noise procedural texture object
  49502. */
  49503. serialize(): any;
  49504. /**
  49505. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49506. * @param parsedTexture defines parsed texture data
  49507. * @param scene defines the current scene
  49508. * @param rootUrl defines the root URL containing noise procedural texture information
  49509. * @returns a parsed NoiseProceduralTexture
  49510. */
  49511. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49512. }
  49513. }
  49514. declare module BABYLON {
  49515. /**
  49516. * Raw cube texture where the raw buffers are passed in
  49517. */
  49518. export class RawCubeTexture extends CubeTexture {
  49519. /**
  49520. * Creates a cube texture where the raw buffers are passed in.
  49521. * @param scene defines the scene the texture is attached to
  49522. * @param data defines the array of data to use to create each face
  49523. * @param size defines the size of the textures
  49524. * @param format defines the format of the data
  49525. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49526. * @param generateMipMaps defines if the engine should generate the mip levels
  49527. * @param invertY defines if data must be stored with Y axis inverted
  49528. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49529. * @param compression defines the compression used (null by default)
  49530. */
  49531. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49532. /**
  49533. * Updates the raw cube texture.
  49534. * @param data defines the data to store
  49535. * @param format defines the data format
  49536. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49537. * @param invertY defines if data must be stored with Y axis inverted
  49538. * @param compression defines the compression used (null by default)
  49539. * @param level defines which level of the texture to update
  49540. */
  49541. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49542. /**
  49543. * Updates a raw cube texture with RGBD encoded data.
  49544. * @param data defines the array of data [mipmap][face] to use to create each face
  49545. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49546. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49547. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49548. * @returns a promsie that resolves when the operation is complete
  49549. */
  49550. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49551. /**
  49552. * Clones the raw cube texture.
  49553. * @return a new cube texture
  49554. */
  49555. clone(): CubeTexture;
  49556. /** @hidden */
  49557. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49558. }
  49559. }
  49560. declare module BABYLON {
  49561. /**
  49562. * Class used to store 3D textures containing user data
  49563. */
  49564. export class RawTexture3D extends Texture {
  49565. /** Gets or sets the texture format to use */
  49566. format: number;
  49567. private _engine;
  49568. /**
  49569. * Create a new RawTexture3D
  49570. * @param data defines the data of the texture
  49571. * @param width defines the width of the texture
  49572. * @param height defines the height of the texture
  49573. * @param depth defines the depth of the texture
  49574. * @param format defines the texture format to use
  49575. * @param scene defines the hosting scene
  49576. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49577. * @param invertY defines if texture must be stored with Y axis inverted
  49578. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49579. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49580. */
  49581. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49582. /** Gets or sets the texture format to use */
  49583. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49584. /**
  49585. * Update the texture with new data
  49586. * @param data defines the data to store in the texture
  49587. */
  49588. update(data: ArrayBufferView): void;
  49589. }
  49590. }
  49591. declare module BABYLON {
  49592. /**
  49593. * Creates a refraction texture used by refraction channel of the standard material.
  49594. * It is like a mirror but to see through a material.
  49595. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49596. */
  49597. export class RefractionTexture extends RenderTargetTexture {
  49598. /**
  49599. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49600. * 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.
  49601. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49602. */
  49603. refractionPlane: Plane;
  49604. /**
  49605. * Define how deep under the surface we should see.
  49606. */
  49607. depth: number;
  49608. /**
  49609. * Creates a refraction texture used by refraction channel of the standard material.
  49610. * It is like a mirror but to see through a material.
  49611. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49612. * @param name Define the texture name
  49613. * @param size Define the size of the underlying texture
  49614. * @param scene Define the scene the refraction belongs to
  49615. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49616. */
  49617. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49618. /**
  49619. * Clone the refraction texture.
  49620. * @returns the cloned texture
  49621. */
  49622. clone(): RefractionTexture;
  49623. /**
  49624. * Serialize the texture to a JSON representation you could use in Parse later on
  49625. * @returns the serialized JSON representation
  49626. */
  49627. serialize(): any;
  49628. }
  49629. }
  49630. declare module BABYLON {
  49631. /**
  49632. * Defines the options related to the creation of an HtmlElementTexture
  49633. */
  49634. export interface IHtmlElementTextureOptions {
  49635. /**
  49636. * Defines wether mip maps should be created or not.
  49637. */
  49638. generateMipMaps?: boolean;
  49639. /**
  49640. * Defines the sampling mode of the texture.
  49641. */
  49642. samplingMode?: number;
  49643. /**
  49644. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49645. */
  49646. engine: Nullable<Engine>;
  49647. /**
  49648. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49649. */
  49650. scene: Nullable<Scene>;
  49651. }
  49652. /**
  49653. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49654. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49655. * is automatically managed.
  49656. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49657. * in your application.
  49658. *
  49659. * As the update is not automatic, you need to call them manually.
  49660. */
  49661. export class HtmlElementTexture extends BaseTexture {
  49662. /**
  49663. * The texture URL.
  49664. */
  49665. element: HTMLVideoElement | HTMLCanvasElement;
  49666. private static readonly DefaultOptions;
  49667. private _textureMatrix;
  49668. private _engine;
  49669. private _isVideo;
  49670. private _generateMipMaps;
  49671. private _samplingMode;
  49672. /**
  49673. * Instantiates a HtmlElementTexture from the following parameters.
  49674. *
  49675. * @param name Defines the name of the texture
  49676. * @param element Defines the video or canvas the texture is filled with
  49677. * @param options Defines the other none mandatory texture creation options
  49678. */
  49679. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49680. private _createInternalTexture;
  49681. /**
  49682. * Returns the texture matrix used in most of the material.
  49683. */
  49684. getTextureMatrix(): Matrix;
  49685. /**
  49686. * Updates the content of the texture.
  49687. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49688. */
  49689. update(invertY?: Nullable<boolean>): void;
  49690. }
  49691. }
  49692. declare module BABYLON {
  49693. /**
  49694. * Helper class to push actions to a pool of workers.
  49695. */
  49696. export class WorkerPool implements IDisposable {
  49697. private _workerInfos;
  49698. private _pendingActions;
  49699. /**
  49700. * Constructor
  49701. * @param workers Array of workers to use for actions
  49702. */
  49703. constructor(workers: Array<Worker>);
  49704. /**
  49705. * Terminates all workers and clears any pending actions.
  49706. */
  49707. dispose(): void;
  49708. /**
  49709. * Pushes an action to the worker pool. If all the workers are active, the action will be
  49710. * pended until a worker has completed its action.
  49711. * @param action The action to perform. Call onComplete when the action is complete.
  49712. */
  49713. push(action: (worker: Worker, onComplete: () => void) => void): void;
  49714. private _execute;
  49715. }
  49716. }
  49717. declare module BABYLON {
  49718. /**
  49719. * Configuration for Draco compression
  49720. */
  49721. export interface IDracoCompressionConfiguration {
  49722. /**
  49723. * Configuration for the decoder.
  49724. */
  49725. decoder?: {
  49726. /**
  49727. * The url to the WebAssembly module.
  49728. */
  49729. wasmUrl?: string;
  49730. /**
  49731. * The url to the WebAssembly binary.
  49732. */
  49733. wasmBinaryUrl?: string;
  49734. /**
  49735. * The url to the fallback JavaScript module.
  49736. */
  49737. fallbackUrl?: string;
  49738. };
  49739. }
  49740. /**
  49741. * Draco compression (https://google.github.io/draco/)
  49742. *
  49743. * This class wraps the Draco module.
  49744. *
  49745. * **Encoder**
  49746. *
  49747. * The encoder is not currently implemented.
  49748. *
  49749. * **Decoder**
  49750. *
  49751. * 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.
  49752. *
  49753. * To update the configuration, use the following code:
  49754. * ```javascript
  49755. * DracoCompression.Configuration = {
  49756. * decoder: {
  49757. * wasmUrl: "<url to the WebAssembly library>",
  49758. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49759. * fallbackUrl: "<url to the fallback JavaScript library>",
  49760. * }
  49761. * };
  49762. * ```
  49763. *
  49764. * 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.
  49765. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49766. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49767. *
  49768. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49769. * ```javascript
  49770. * var dracoCompression = new DracoCompression();
  49771. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49772. * [VertexBuffer.PositionKind]: 0
  49773. * });
  49774. * ```
  49775. *
  49776. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49777. */
  49778. export class DracoCompression implements IDisposable {
  49779. private _workerPoolPromise;
  49780. /**
  49781. * The configuration. Defaults to the following urls:
  49782. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49783. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49784. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49785. */
  49786. static Configuration: IDracoCompressionConfiguration;
  49787. /**
  49788. * Returns true if the decoder is available.
  49789. */
  49790. static readonly DecoderAvailable: boolean;
  49791. /**
  49792. * Default number of workers to create when creating the draco compression object.
  49793. */
  49794. static DefaultNumWorkers: number;
  49795. private static GetDefaultNumWorkers;
  49796. private static _Default;
  49797. /**
  49798. * Default instance for the draco compression object.
  49799. */
  49800. static readonly Default: DracoCompression;
  49801. /**
  49802. * Constructor
  49803. * @param numWorkers The number of workers for async operations
  49804. */
  49805. constructor(numWorkers?: number);
  49806. /**
  49807. * Stop all async operations and release resources.
  49808. */
  49809. dispose(): void;
  49810. /**
  49811. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49812. * @returns a promise that resolves when ready
  49813. */
  49814. whenReadyAsync(): Promise<void>;
  49815. /**
  49816. * Decode Draco compressed mesh data to vertex data.
  49817. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49818. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49819. * @returns A promise that resolves with the decoded vertex data
  49820. */
  49821. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49822. [kind: string]: number;
  49823. }): Promise<VertexData>;
  49824. /**
  49825. * The worker function that gets converted to a blob url to pass into a worker.
  49826. */
  49827. private static _Worker;
  49828. private _loadDecoderWasmBinaryAsync;
  49829. }
  49830. }
  49831. declare module BABYLON {
  49832. /**
  49833. * Class for building Constructive Solid Geometry
  49834. */
  49835. export class CSG {
  49836. private polygons;
  49837. /**
  49838. * The world matrix
  49839. */
  49840. matrix: Matrix;
  49841. /**
  49842. * Stores the position
  49843. */
  49844. position: Vector3;
  49845. /**
  49846. * Stores the rotation
  49847. */
  49848. rotation: Vector3;
  49849. /**
  49850. * Stores the rotation quaternion
  49851. */
  49852. rotationQuaternion: Nullable<Quaternion>;
  49853. /**
  49854. * Stores the scaling vector
  49855. */
  49856. scaling: Vector3;
  49857. /**
  49858. * Convert the Mesh to CSG
  49859. * @param mesh The Mesh to convert to CSG
  49860. * @returns A new CSG from the Mesh
  49861. */
  49862. static FromMesh(mesh: Mesh): CSG;
  49863. /**
  49864. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49865. * @param polygons Polygons used to construct a CSG solid
  49866. */
  49867. private static FromPolygons;
  49868. /**
  49869. * Clones, or makes a deep copy, of the CSG
  49870. * @returns A new CSG
  49871. */
  49872. clone(): CSG;
  49873. /**
  49874. * Unions this CSG with another CSG
  49875. * @param csg The CSG to union against this CSG
  49876. * @returns The unioned CSG
  49877. */
  49878. union(csg: CSG): CSG;
  49879. /**
  49880. * Unions this CSG with another CSG in place
  49881. * @param csg The CSG to union against this CSG
  49882. */
  49883. unionInPlace(csg: CSG): void;
  49884. /**
  49885. * Subtracts this CSG with another CSG
  49886. * @param csg The CSG to subtract against this CSG
  49887. * @returns A new CSG
  49888. */
  49889. subtract(csg: CSG): CSG;
  49890. /**
  49891. * Subtracts this CSG with another CSG in place
  49892. * @param csg The CSG to subtact against this CSG
  49893. */
  49894. subtractInPlace(csg: CSG): void;
  49895. /**
  49896. * Intersect this CSG with another CSG
  49897. * @param csg The CSG to intersect against this CSG
  49898. * @returns A new CSG
  49899. */
  49900. intersect(csg: CSG): CSG;
  49901. /**
  49902. * Intersects this CSG with another CSG in place
  49903. * @param csg The CSG to intersect against this CSG
  49904. */
  49905. intersectInPlace(csg: CSG): void;
  49906. /**
  49907. * Return a new CSG solid with solid and empty space switched. This solid is
  49908. * not modified.
  49909. * @returns A new CSG solid with solid and empty space switched
  49910. */
  49911. inverse(): CSG;
  49912. /**
  49913. * Inverses the CSG in place
  49914. */
  49915. inverseInPlace(): void;
  49916. /**
  49917. * This is used to keep meshes transformations so they can be restored
  49918. * when we build back a Babylon Mesh
  49919. * NB : All CSG operations are performed in world coordinates
  49920. * @param csg The CSG to copy the transform attributes from
  49921. * @returns This CSG
  49922. */
  49923. copyTransformAttributes(csg: CSG): CSG;
  49924. /**
  49925. * Build Raw mesh from CSG
  49926. * Coordinates here are in world space
  49927. * @param name The name of the mesh geometry
  49928. * @param scene The Scene
  49929. * @param keepSubMeshes Specifies if the submeshes should be kept
  49930. * @returns A new Mesh
  49931. */
  49932. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49933. /**
  49934. * Build Mesh from CSG taking material and transforms into account
  49935. * @param name The name of the Mesh
  49936. * @param material The material of the Mesh
  49937. * @param scene The Scene
  49938. * @param keepSubMeshes Specifies if submeshes should be kept
  49939. * @returns The new Mesh
  49940. */
  49941. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49942. }
  49943. }
  49944. declare module BABYLON {
  49945. /**
  49946. * Class used to create a trail following a mesh
  49947. */
  49948. export class TrailMesh extends Mesh {
  49949. private _generator;
  49950. private _autoStart;
  49951. private _running;
  49952. private _diameter;
  49953. private _length;
  49954. private _sectionPolygonPointsCount;
  49955. private _sectionVectors;
  49956. private _sectionNormalVectors;
  49957. private _beforeRenderObserver;
  49958. /**
  49959. * @constructor
  49960. * @param name The value used by scene.getMeshByName() to do a lookup.
  49961. * @param generator The mesh to generate a trail.
  49962. * @param scene The scene to add this mesh to.
  49963. * @param diameter Diameter of trailing mesh. Default is 1.
  49964. * @param length Length of trailing mesh. Default is 60.
  49965. * @param autoStart Automatically start trailing mesh. Default true.
  49966. */
  49967. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49968. /**
  49969. * "TrailMesh"
  49970. * @returns "TrailMesh"
  49971. */
  49972. getClassName(): string;
  49973. private _createMesh;
  49974. /**
  49975. * Start trailing mesh.
  49976. */
  49977. start(): void;
  49978. /**
  49979. * Stop trailing mesh.
  49980. */
  49981. stop(): void;
  49982. /**
  49983. * Update trailing mesh geometry.
  49984. */
  49985. update(): void;
  49986. /**
  49987. * Returns a new TrailMesh object.
  49988. * @param name is a string, the name given to the new mesh
  49989. * @param newGenerator use new generator object for cloned trail mesh
  49990. * @returns a new mesh
  49991. */
  49992. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49993. /**
  49994. * Serializes this trail mesh
  49995. * @param serializationObject object to write serialization to
  49996. */
  49997. serialize(serializationObject: any): void;
  49998. /**
  49999. * Parses a serialized trail mesh
  50000. * @param parsedMesh the serialized mesh
  50001. * @param scene the scene to create the trail mesh in
  50002. * @returns the created trail mesh
  50003. */
  50004. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50005. }
  50006. }
  50007. declare module BABYLON {
  50008. /**
  50009. * Class containing static functions to help procedurally build meshes
  50010. */
  50011. export class TorusKnotBuilder {
  50012. /**
  50013. * Creates a torus knot mesh
  50014. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50015. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50016. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50017. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50019. * * 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
  50020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50021. * @param name defines the name of the mesh
  50022. * @param options defines the options used to create the mesh
  50023. * @param scene defines the hosting scene
  50024. * @returns the torus knot mesh
  50025. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50026. */
  50027. static CreateTorusKnot(name: string, options: {
  50028. radius?: number;
  50029. tube?: number;
  50030. radialSegments?: number;
  50031. tubularSegments?: number;
  50032. p?: number;
  50033. q?: number;
  50034. updatable?: boolean;
  50035. sideOrientation?: number;
  50036. frontUVs?: Vector4;
  50037. backUVs?: Vector4;
  50038. }, scene: any): Mesh;
  50039. }
  50040. }
  50041. declare module BABYLON {
  50042. /**
  50043. * Polygon
  50044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50045. */
  50046. export class Polygon {
  50047. /**
  50048. * Creates a rectangle
  50049. * @param xmin bottom X coord
  50050. * @param ymin bottom Y coord
  50051. * @param xmax top X coord
  50052. * @param ymax top Y coord
  50053. * @returns points that make the resulting rectation
  50054. */
  50055. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50056. /**
  50057. * Creates a circle
  50058. * @param radius radius of circle
  50059. * @param cx scale in x
  50060. * @param cy scale in y
  50061. * @param numberOfSides number of sides that make up the circle
  50062. * @returns points that make the resulting circle
  50063. */
  50064. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50065. /**
  50066. * Creates a polygon from input string
  50067. * @param input Input polygon data
  50068. * @returns the parsed points
  50069. */
  50070. static Parse(input: string): Vector2[];
  50071. /**
  50072. * Starts building a polygon from x and y coordinates
  50073. * @param x x coordinate
  50074. * @param y y coordinate
  50075. * @returns the started path2
  50076. */
  50077. static StartingAt(x: number, y: number): Path2;
  50078. }
  50079. /**
  50080. * Builds a polygon
  50081. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50082. */
  50083. export class PolygonMeshBuilder {
  50084. private _points;
  50085. private _outlinepoints;
  50086. private _holes;
  50087. private _name;
  50088. private _scene;
  50089. private _epoints;
  50090. private _eholes;
  50091. private _addToepoint;
  50092. /**
  50093. * Babylon reference to the earcut plugin.
  50094. */
  50095. bjsEarcut: any;
  50096. /**
  50097. * Creates a PolygonMeshBuilder
  50098. * @param name name of the builder
  50099. * @param contours Path of the polygon
  50100. * @param scene scene to add to when creating the mesh
  50101. * @param earcutInjection can be used to inject your own earcut reference
  50102. */
  50103. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50104. /**
  50105. * Adds a whole within the polygon
  50106. * @param hole Array of points defining the hole
  50107. * @returns this
  50108. */
  50109. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50110. /**
  50111. * Creates the polygon
  50112. * @param updatable If the mesh should be updatable
  50113. * @param depth The depth of the mesh created
  50114. * @returns the created mesh
  50115. */
  50116. build(updatable?: boolean, depth?: number): Mesh;
  50117. /**
  50118. * Creates the polygon
  50119. * @param depth The depth of the mesh created
  50120. * @returns the created VertexData
  50121. */
  50122. buildVertexData(depth?: number): VertexData;
  50123. /**
  50124. * Adds a side to the polygon
  50125. * @param positions points that make the polygon
  50126. * @param normals normals of the polygon
  50127. * @param uvs uvs of the polygon
  50128. * @param indices indices of the polygon
  50129. * @param bounds bounds of the polygon
  50130. * @param points points of the polygon
  50131. * @param depth depth of the polygon
  50132. * @param flip flip of the polygon
  50133. */
  50134. private addSide;
  50135. }
  50136. }
  50137. declare module BABYLON {
  50138. /**
  50139. * Class containing static functions to help procedurally build meshes
  50140. */
  50141. export class PolygonBuilder {
  50142. /**
  50143. * Creates a polygon mesh
  50144. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50145. * * 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
  50146. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50148. * * 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)
  50149. * * Remember you can only change the shape positions, not their number when updating a polygon
  50150. * @param name defines the name of the mesh
  50151. * @param options defines the options used to create the mesh
  50152. * @param scene defines the hosting scene
  50153. * @param earcutInjection can be used to inject your own earcut reference
  50154. * @returns the polygon mesh
  50155. */
  50156. static CreatePolygon(name: string, options: {
  50157. shape: Vector3[];
  50158. holes?: Vector3[][];
  50159. depth?: number;
  50160. faceUV?: Vector4[];
  50161. faceColors?: Color4[];
  50162. updatable?: boolean;
  50163. sideOrientation?: number;
  50164. frontUVs?: Vector4;
  50165. backUVs?: Vector4;
  50166. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50167. /**
  50168. * Creates an extruded polygon mesh, with depth in the Y direction.
  50169. * * 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)
  50170. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50171. * @param name defines the name of the mesh
  50172. * @param options defines the options used to create the mesh
  50173. * @param scene defines the hosting scene
  50174. * @param earcutInjection can be used to inject your own earcut reference
  50175. * @returns the polygon mesh
  50176. */
  50177. static ExtrudePolygon(name: string, options: {
  50178. shape: Vector3[];
  50179. holes?: Vector3[][];
  50180. depth?: number;
  50181. faceUV?: Vector4[];
  50182. faceColors?: Color4[];
  50183. updatable?: boolean;
  50184. sideOrientation?: number;
  50185. frontUVs?: Vector4;
  50186. backUVs?: Vector4;
  50187. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50188. }
  50189. }
  50190. declare module BABYLON {
  50191. /**
  50192. * Class containing static functions to help procedurally build meshes
  50193. */
  50194. export class LatheBuilder {
  50195. /**
  50196. * Creates lathe mesh.
  50197. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50198. * * 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
  50199. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50200. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50201. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50202. * * 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
  50203. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50204. * * 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
  50205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50206. * * 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
  50207. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50209. * @param name defines the name of the mesh
  50210. * @param options defines the options used to create the mesh
  50211. * @param scene defines the hosting scene
  50212. * @returns the lathe mesh
  50213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50214. */
  50215. static CreateLathe(name: string, options: {
  50216. shape: Vector3[];
  50217. radius?: number;
  50218. tessellation?: number;
  50219. clip?: number;
  50220. arc?: number;
  50221. closed?: boolean;
  50222. updatable?: boolean;
  50223. sideOrientation?: number;
  50224. frontUVs?: Vector4;
  50225. backUVs?: Vector4;
  50226. cap?: number;
  50227. invertUV?: boolean;
  50228. }, scene?: Nullable<Scene>): Mesh;
  50229. }
  50230. }
  50231. declare module BABYLON {
  50232. /**
  50233. * Class containing static functions to help procedurally build meshes
  50234. */
  50235. export class TubeBuilder {
  50236. /**
  50237. * Creates a tube mesh.
  50238. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50239. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50240. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50241. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50242. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50243. * * 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)
  50244. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50245. * * 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
  50246. * * 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
  50247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50248. * * 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
  50249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50251. * @param name defines the name of the mesh
  50252. * @param options defines the options used to create the mesh
  50253. * @param scene defines the hosting scene
  50254. * @returns the tube mesh
  50255. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50256. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50257. */
  50258. static CreateTube(name: string, options: {
  50259. path: Vector3[];
  50260. radius?: number;
  50261. tessellation?: number;
  50262. radiusFunction?: {
  50263. (i: number, distance: number): number;
  50264. };
  50265. cap?: number;
  50266. arc?: number;
  50267. updatable?: boolean;
  50268. sideOrientation?: number;
  50269. frontUVs?: Vector4;
  50270. backUVs?: Vector4;
  50271. instance?: Mesh;
  50272. invertUV?: boolean;
  50273. }, scene?: Nullable<Scene>): Mesh;
  50274. }
  50275. }
  50276. declare module BABYLON {
  50277. /**
  50278. * Class containing static functions to help procedurally build meshes
  50279. */
  50280. export class IcoSphereBuilder {
  50281. /**
  50282. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50283. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50284. * * 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`)
  50285. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50286. * * 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
  50287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50288. * * 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
  50289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50290. * @param name defines the name of the mesh
  50291. * @param options defines the options used to create the mesh
  50292. * @param scene defines the hosting scene
  50293. * @returns the icosahedron mesh
  50294. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50295. */
  50296. static CreateIcoSphere(name: string, options: {
  50297. radius?: number;
  50298. radiusX?: number;
  50299. radiusY?: number;
  50300. radiusZ?: number;
  50301. flat?: boolean;
  50302. subdivisions?: number;
  50303. sideOrientation?: number;
  50304. frontUVs?: Vector4;
  50305. backUVs?: Vector4;
  50306. updatable?: boolean;
  50307. }, scene?: Nullable<Scene>): Mesh;
  50308. }
  50309. }
  50310. declare module BABYLON {
  50311. /**
  50312. * Class containing static functions to help procedurally build meshes
  50313. */
  50314. export class DecalBuilder {
  50315. /**
  50316. * Creates a decal mesh.
  50317. * 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
  50318. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50319. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50320. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50321. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50322. * @param name defines the name of the mesh
  50323. * @param sourceMesh defines the mesh where the decal must be applied
  50324. * @param options defines the options used to create the mesh
  50325. * @param scene defines the hosting scene
  50326. * @returns the decal mesh
  50327. * @see https://doc.babylonjs.com/how_to/decals
  50328. */
  50329. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50330. position?: Vector3;
  50331. normal?: Vector3;
  50332. size?: Vector3;
  50333. angle?: number;
  50334. }): Mesh;
  50335. }
  50336. }
  50337. declare module BABYLON {
  50338. /**
  50339. * Class containing static functions to help procedurally build meshes
  50340. */
  50341. export class MeshBuilder {
  50342. /**
  50343. * Creates a box mesh
  50344. * * The parameter `size` sets the size (float) of each box side (default 1)
  50345. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50346. * * 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)
  50347. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50349. * * 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
  50350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50351. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50352. * @param name defines the name of the mesh
  50353. * @param options defines the options used to create the mesh
  50354. * @param scene defines the hosting scene
  50355. * @returns the box mesh
  50356. */
  50357. static CreateBox(name: string, options: {
  50358. size?: number;
  50359. width?: number;
  50360. height?: number;
  50361. depth?: number;
  50362. faceUV?: Vector4[];
  50363. faceColors?: Color4[];
  50364. sideOrientation?: number;
  50365. frontUVs?: Vector4;
  50366. backUVs?: Vector4;
  50367. updatable?: boolean;
  50368. }, scene?: Nullable<Scene>): Mesh;
  50369. /**
  50370. * Creates a sphere mesh
  50371. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50372. * * 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`)
  50373. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50374. * * 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
  50375. * * 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)
  50376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50377. * * 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
  50378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50379. * @param name defines the name of the mesh
  50380. * @param options defines the options used to create the mesh
  50381. * @param scene defines the hosting scene
  50382. * @returns the sphere mesh
  50383. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50384. */
  50385. static CreateSphere(name: string, options: {
  50386. segments?: number;
  50387. diameter?: number;
  50388. diameterX?: number;
  50389. diameterY?: number;
  50390. diameterZ?: number;
  50391. arc?: number;
  50392. slice?: number;
  50393. sideOrientation?: number;
  50394. frontUVs?: Vector4;
  50395. backUVs?: Vector4;
  50396. updatable?: boolean;
  50397. }, scene?: Nullable<Scene>): Mesh;
  50398. /**
  50399. * Creates a plane polygonal mesh. By default, this is a disc
  50400. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50401. * * 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
  50402. * * 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
  50403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50404. * * 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
  50405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50406. * @param name defines the name of the mesh
  50407. * @param options defines the options used to create the mesh
  50408. * @param scene defines the hosting scene
  50409. * @returns the plane polygonal mesh
  50410. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50411. */
  50412. static CreateDisc(name: string, options: {
  50413. radius?: number;
  50414. tessellation?: number;
  50415. arc?: number;
  50416. updatable?: boolean;
  50417. sideOrientation?: number;
  50418. frontUVs?: Vector4;
  50419. backUVs?: Vector4;
  50420. }, scene?: Nullable<Scene>): Mesh;
  50421. /**
  50422. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50423. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50424. * * 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`)
  50425. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50426. * * 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
  50427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50428. * * 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
  50429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50430. * @param name defines the name of the mesh
  50431. * @param options defines the options used to create the mesh
  50432. * @param scene defines the hosting scene
  50433. * @returns the icosahedron mesh
  50434. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50435. */
  50436. static CreateIcoSphere(name: string, options: {
  50437. radius?: number;
  50438. radiusX?: number;
  50439. radiusY?: number;
  50440. radiusZ?: number;
  50441. flat?: boolean;
  50442. subdivisions?: number;
  50443. sideOrientation?: number;
  50444. frontUVs?: Vector4;
  50445. backUVs?: Vector4;
  50446. updatable?: boolean;
  50447. }, scene?: Nullable<Scene>): Mesh;
  50448. /**
  50449. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50450. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50451. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50452. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50453. * * 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
  50454. * * 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
  50455. * * 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
  50456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50457. * * 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
  50458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50459. * * 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
  50460. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50461. * * 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
  50462. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50464. * @param name defines the name of the mesh
  50465. * @param options defines the options used to create the mesh
  50466. * @param scene defines the hosting scene
  50467. * @returns the ribbon mesh
  50468. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50469. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50470. */
  50471. static CreateRibbon(name: string, options: {
  50472. pathArray: Vector3[][];
  50473. closeArray?: boolean;
  50474. closePath?: boolean;
  50475. offset?: number;
  50476. updatable?: boolean;
  50477. sideOrientation?: number;
  50478. frontUVs?: Vector4;
  50479. backUVs?: Vector4;
  50480. instance?: Mesh;
  50481. invertUV?: boolean;
  50482. uvs?: Vector2[];
  50483. colors?: Color4[];
  50484. }, scene?: Nullable<Scene>): Mesh;
  50485. /**
  50486. * Creates a cylinder or a cone mesh
  50487. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50488. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50489. * * 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.
  50490. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50491. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50492. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50493. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50494. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50495. * * 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).
  50496. * * 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
  50497. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50498. * * 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
  50499. * * 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.
  50500. * * If `enclose` is false, a ring surface is one element.
  50501. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50502. * * 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
  50503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50504. * * 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
  50505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50506. * @param name defines the name of the mesh
  50507. * @param options defines the options used to create the mesh
  50508. * @param scene defines the hosting scene
  50509. * @returns the cylinder mesh
  50510. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50511. */
  50512. static CreateCylinder(name: string, options: {
  50513. height?: number;
  50514. diameterTop?: number;
  50515. diameterBottom?: number;
  50516. diameter?: number;
  50517. tessellation?: number;
  50518. subdivisions?: number;
  50519. arc?: number;
  50520. faceColors?: Color4[];
  50521. faceUV?: Vector4[];
  50522. updatable?: boolean;
  50523. hasRings?: boolean;
  50524. enclose?: boolean;
  50525. sideOrientation?: number;
  50526. frontUVs?: Vector4;
  50527. backUVs?: Vector4;
  50528. }, scene?: Nullable<Scene>): Mesh;
  50529. /**
  50530. * Creates a torus mesh
  50531. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50532. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50533. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50535. * * 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
  50536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50537. * @param name defines the name of the mesh
  50538. * @param options defines the options used to create the mesh
  50539. * @param scene defines the hosting scene
  50540. * @returns the torus mesh
  50541. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50542. */
  50543. static CreateTorus(name: string, options: {
  50544. diameter?: number;
  50545. thickness?: number;
  50546. tessellation?: number;
  50547. updatable?: boolean;
  50548. sideOrientation?: number;
  50549. frontUVs?: Vector4;
  50550. backUVs?: Vector4;
  50551. }, scene?: Nullable<Scene>): Mesh;
  50552. /**
  50553. * Creates a torus knot mesh
  50554. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50555. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50556. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50557. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50559. * * 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
  50560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50561. * @param name defines the name of the mesh
  50562. * @param options defines the options used to create the mesh
  50563. * @param scene defines the hosting scene
  50564. * @returns the torus knot mesh
  50565. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50566. */
  50567. static CreateTorusKnot(name: string, options: {
  50568. radius?: number;
  50569. tube?: number;
  50570. radialSegments?: number;
  50571. tubularSegments?: number;
  50572. p?: number;
  50573. q?: number;
  50574. updatable?: boolean;
  50575. sideOrientation?: number;
  50576. frontUVs?: Vector4;
  50577. backUVs?: Vector4;
  50578. }, scene?: Nullable<Scene>): Mesh;
  50579. /**
  50580. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50581. * * 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
  50582. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50583. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50584. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50585. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50586. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50587. * * 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
  50588. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50591. * @param name defines the name of the new line system
  50592. * @param options defines the options used to create the line system
  50593. * @param scene defines the hosting scene
  50594. * @returns a new line system mesh
  50595. */
  50596. static CreateLineSystem(name: string, options: {
  50597. lines: Vector3[][];
  50598. updatable?: boolean;
  50599. instance?: Nullable<LinesMesh>;
  50600. colors?: Nullable<Color4[][]>;
  50601. useVertexAlpha?: boolean;
  50602. }, scene: Nullable<Scene>): LinesMesh;
  50603. /**
  50604. * Creates a line mesh
  50605. * 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
  50606. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50607. * * The parameter `points` is an array successive Vector3
  50608. * * 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
  50609. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50610. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50611. * * When updating an instance, remember that only point positions can change, not the number of points
  50612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50614. * @param name defines the name of the new line system
  50615. * @param options defines the options used to create the line system
  50616. * @param scene defines the hosting scene
  50617. * @returns a new line mesh
  50618. */
  50619. static CreateLines(name: string, options: {
  50620. points: Vector3[];
  50621. updatable?: boolean;
  50622. instance?: Nullable<LinesMesh>;
  50623. colors?: Color4[];
  50624. useVertexAlpha?: boolean;
  50625. }, scene?: Nullable<Scene>): LinesMesh;
  50626. /**
  50627. * Creates a dashed line mesh
  50628. * * 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
  50629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50630. * * The parameter `points` is an array successive Vector3
  50631. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50632. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50633. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50634. * * 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
  50635. * * When updating an instance, remember that only point positions can change, not the number of points
  50636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50637. * @param name defines the name of the mesh
  50638. * @param options defines the options used to create the mesh
  50639. * @param scene defines the hosting scene
  50640. * @returns the dashed line mesh
  50641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50642. */
  50643. static CreateDashedLines(name: string, options: {
  50644. points: Vector3[];
  50645. dashSize?: number;
  50646. gapSize?: number;
  50647. dashNb?: number;
  50648. updatable?: boolean;
  50649. instance?: LinesMesh;
  50650. }, scene?: Nullable<Scene>): LinesMesh;
  50651. /**
  50652. * 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.
  50653. * * 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.
  50654. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50655. * * 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.
  50656. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50657. * * 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
  50658. * * 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
  50659. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50661. * * 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
  50662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50664. * @param name defines the name of the mesh
  50665. * @param options defines the options used to create the mesh
  50666. * @param scene defines the hosting scene
  50667. * @returns the extruded shape mesh
  50668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50670. */
  50671. static ExtrudeShape(name: string, options: {
  50672. shape: Vector3[];
  50673. path: Vector3[];
  50674. scale?: number;
  50675. rotation?: number;
  50676. cap?: number;
  50677. updatable?: boolean;
  50678. sideOrientation?: number;
  50679. frontUVs?: Vector4;
  50680. backUVs?: Vector4;
  50681. instance?: Mesh;
  50682. invertUV?: boolean;
  50683. }, scene?: Nullable<Scene>): Mesh;
  50684. /**
  50685. * Creates an custom extruded shape mesh.
  50686. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50687. * * 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.
  50688. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50689. * * 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
  50690. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50691. * * 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
  50692. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50693. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50694. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50695. * * 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
  50696. * * 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
  50697. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50699. * * 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
  50700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50702. * @param name defines the name of the mesh
  50703. * @param options defines the options used to create the mesh
  50704. * @param scene defines the hosting scene
  50705. * @returns the custom extruded shape mesh
  50706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50707. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50709. */
  50710. static ExtrudeShapeCustom(name: string, options: {
  50711. shape: Vector3[];
  50712. path: Vector3[];
  50713. scaleFunction?: any;
  50714. rotationFunction?: any;
  50715. ribbonCloseArray?: boolean;
  50716. ribbonClosePath?: boolean;
  50717. cap?: number;
  50718. updatable?: boolean;
  50719. sideOrientation?: number;
  50720. frontUVs?: Vector4;
  50721. backUVs?: Vector4;
  50722. instance?: Mesh;
  50723. invertUV?: boolean;
  50724. }, scene?: Nullable<Scene>): Mesh;
  50725. /**
  50726. * Creates lathe mesh.
  50727. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50728. * * 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
  50729. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50730. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50731. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50732. * * 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
  50733. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50734. * * 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
  50735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50736. * * 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
  50737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50739. * @param name defines the name of the mesh
  50740. * @param options defines the options used to create the mesh
  50741. * @param scene defines the hosting scene
  50742. * @returns the lathe mesh
  50743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50744. */
  50745. static CreateLathe(name: string, options: {
  50746. shape: Vector3[];
  50747. radius?: number;
  50748. tessellation?: number;
  50749. clip?: number;
  50750. arc?: number;
  50751. closed?: boolean;
  50752. updatable?: boolean;
  50753. sideOrientation?: number;
  50754. frontUVs?: Vector4;
  50755. backUVs?: Vector4;
  50756. cap?: number;
  50757. invertUV?: boolean;
  50758. }, scene?: Nullable<Scene>): Mesh;
  50759. /**
  50760. * Creates a plane mesh
  50761. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50762. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50763. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50765. * * 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
  50766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50767. * @param name defines the name of the mesh
  50768. * @param options defines the options used to create the mesh
  50769. * @param scene defines the hosting scene
  50770. * @returns the plane mesh
  50771. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50772. */
  50773. static CreatePlane(name: string, options: {
  50774. size?: number;
  50775. width?: number;
  50776. height?: number;
  50777. sideOrientation?: number;
  50778. frontUVs?: Vector4;
  50779. backUVs?: Vector4;
  50780. updatable?: boolean;
  50781. sourcePlane?: Plane;
  50782. }, scene?: Nullable<Scene>): Mesh;
  50783. /**
  50784. * Creates a ground mesh
  50785. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50786. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50788. * @param name defines the name of the mesh
  50789. * @param options defines the options used to create the mesh
  50790. * @param scene defines the hosting scene
  50791. * @returns the ground mesh
  50792. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50793. */
  50794. static CreateGround(name: string, options: {
  50795. width?: number;
  50796. height?: number;
  50797. subdivisions?: number;
  50798. subdivisionsX?: number;
  50799. subdivisionsY?: number;
  50800. updatable?: boolean;
  50801. }, scene?: Nullable<Scene>): Mesh;
  50802. /**
  50803. * Creates a tiled ground mesh
  50804. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50805. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50806. * * 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
  50807. * * 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
  50808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50809. * @param name defines the name of the mesh
  50810. * @param options defines the options used to create the mesh
  50811. * @param scene defines the hosting scene
  50812. * @returns the tiled ground mesh
  50813. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50814. */
  50815. static CreateTiledGround(name: string, options: {
  50816. xmin: number;
  50817. zmin: number;
  50818. xmax: number;
  50819. zmax: number;
  50820. subdivisions?: {
  50821. w: number;
  50822. h: number;
  50823. };
  50824. precision?: {
  50825. w: number;
  50826. h: number;
  50827. };
  50828. updatable?: boolean;
  50829. }, scene?: Nullable<Scene>): Mesh;
  50830. /**
  50831. * Creates a ground mesh from a height map
  50832. * * The parameter `url` sets the URL of the height map image resource.
  50833. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50834. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50835. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50836. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50837. * * 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.
  50838. * * 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).
  50839. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50841. * @param name defines the name of the mesh
  50842. * @param url defines the url to the height map
  50843. * @param options defines the options used to create the mesh
  50844. * @param scene defines the hosting scene
  50845. * @returns the ground mesh
  50846. * @see https://doc.babylonjs.com/babylon101/height_map
  50847. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50848. */
  50849. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50850. width?: number;
  50851. height?: number;
  50852. subdivisions?: number;
  50853. minHeight?: number;
  50854. maxHeight?: number;
  50855. colorFilter?: Color3;
  50856. alphaFilter?: number;
  50857. updatable?: boolean;
  50858. onReady?: (mesh: GroundMesh) => void;
  50859. }, scene?: Nullable<Scene>): GroundMesh;
  50860. /**
  50861. * Creates a polygon mesh
  50862. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50863. * * 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
  50864. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50866. * * 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)
  50867. * * Remember you can only change the shape positions, not their number when updating a polygon
  50868. * @param name defines the name of the mesh
  50869. * @param options defines the options used to create the mesh
  50870. * @param scene defines the hosting scene
  50871. * @param earcutInjection can be used to inject your own earcut reference
  50872. * @returns the polygon mesh
  50873. */
  50874. static CreatePolygon(name: string, options: {
  50875. shape: Vector3[];
  50876. holes?: Vector3[][];
  50877. depth?: number;
  50878. faceUV?: Vector4[];
  50879. faceColors?: Color4[];
  50880. updatable?: boolean;
  50881. sideOrientation?: number;
  50882. frontUVs?: Vector4;
  50883. backUVs?: Vector4;
  50884. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50885. /**
  50886. * Creates an extruded polygon mesh, with depth in the Y direction.
  50887. * * 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)
  50888. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50889. * @param name defines the name of the mesh
  50890. * @param options defines the options used to create the mesh
  50891. * @param scene defines the hosting scene
  50892. * @param earcutInjection can be used to inject your own earcut reference
  50893. * @returns the polygon mesh
  50894. */
  50895. static ExtrudePolygon(name: string, options: {
  50896. shape: Vector3[];
  50897. holes?: Vector3[][];
  50898. depth?: number;
  50899. faceUV?: Vector4[];
  50900. faceColors?: Color4[];
  50901. updatable?: boolean;
  50902. sideOrientation?: number;
  50903. frontUVs?: Vector4;
  50904. backUVs?: Vector4;
  50905. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50906. /**
  50907. * Creates a tube mesh.
  50908. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50909. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50910. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50911. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50912. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50913. * * 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)
  50914. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50915. * * 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
  50916. * * 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
  50917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50918. * * 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
  50919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50921. * @param name defines the name of the mesh
  50922. * @param options defines the options used to create the mesh
  50923. * @param scene defines the hosting scene
  50924. * @returns the tube mesh
  50925. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50926. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50927. */
  50928. static CreateTube(name: string, options: {
  50929. path: Vector3[];
  50930. radius?: number;
  50931. tessellation?: number;
  50932. radiusFunction?: {
  50933. (i: number, distance: number): number;
  50934. };
  50935. cap?: number;
  50936. arc?: number;
  50937. updatable?: boolean;
  50938. sideOrientation?: number;
  50939. frontUVs?: Vector4;
  50940. backUVs?: Vector4;
  50941. instance?: Mesh;
  50942. invertUV?: boolean;
  50943. }, scene?: Nullable<Scene>): Mesh;
  50944. /**
  50945. * Creates a polyhedron mesh
  50946. * * 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
  50947. * * The parameter `size` (positive float, default 1) sets the polygon size
  50948. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50949. * * 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`
  50950. * * 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
  50951. * * 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)`)
  50952. * * 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
  50953. * * 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
  50954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50955. * * 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
  50956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50957. * @param name defines the name of the mesh
  50958. * @param options defines the options used to create the mesh
  50959. * @param scene defines the hosting scene
  50960. * @returns the polyhedron mesh
  50961. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50962. */
  50963. static CreatePolyhedron(name: string, options: {
  50964. type?: number;
  50965. size?: number;
  50966. sizeX?: number;
  50967. sizeY?: number;
  50968. sizeZ?: number;
  50969. custom?: any;
  50970. faceUV?: Vector4[];
  50971. faceColors?: Color4[];
  50972. flat?: boolean;
  50973. updatable?: boolean;
  50974. sideOrientation?: number;
  50975. frontUVs?: Vector4;
  50976. backUVs?: Vector4;
  50977. }, scene?: Nullable<Scene>): Mesh;
  50978. /**
  50979. * Creates a decal mesh.
  50980. * 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
  50981. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50982. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50983. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50984. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50985. * @param name defines the name of the mesh
  50986. * @param sourceMesh defines the mesh where the decal must be applied
  50987. * @param options defines the options used to create the mesh
  50988. * @param scene defines the hosting scene
  50989. * @returns the decal mesh
  50990. * @see https://doc.babylonjs.com/how_to/decals
  50991. */
  50992. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50993. position?: Vector3;
  50994. normal?: Vector3;
  50995. size?: Vector3;
  50996. angle?: number;
  50997. }): Mesh;
  50998. }
  50999. }
  51000. declare module BABYLON {
  51001. /**
  51002. * A simplifier interface for future simplification implementations
  51003. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51004. */
  51005. export interface ISimplifier {
  51006. /**
  51007. * Simplification of a given mesh according to the given settings.
  51008. * Since this requires computation, it is assumed that the function runs async.
  51009. * @param settings The settings of the simplification, including quality and distance
  51010. * @param successCallback A callback that will be called after the mesh was simplified.
  51011. * @param errorCallback in case of an error, this callback will be called. optional.
  51012. */
  51013. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51014. }
  51015. /**
  51016. * Expected simplification settings.
  51017. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51018. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51019. */
  51020. export interface ISimplificationSettings {
  51021. /**
  51022. * Gets or sets the expected quality
  51023. */
  51024. quality: number;
  51025. /**
  51026. * Gets or sets the distance when this optimized version should be used
  51027. */
  51028. distance: number;
  51029. /**
  51030. * Gets an already optimized mesh
  51031. */
  51032. optimizeMesh?: boolean;
  51033. }
  51034. /**
  51035. * Class used to specify simplification options
  51036. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51037. */
  51038. export class SimplificationSettings implements ISimplificationSettings {
  51039. /** expected quality */
  51040. quality: number;
  51041. /** distance when this optimized version should be used */
  51042. distance: number;
  51043. /** already optimized mesh */
  51044. optimizeMesh?: boolean | undefined;
  51045. /**
  51046. * Creates a SimplificationSettings
  51047. * @param quality expected quality
  51048. * @param distance distance when this optimized version should be used
  51049. * @param optimizeMesh already optimized mesh
  51050. */
  51051. constructor(
  51052. /** expected quality */
  51053. quality: number,
  51054. /** distance when this optimized version should be used */
  51055. distance: number,
  51056. /** already optimized mesh */
  51057. optimizeMesh?: boolean | undefined);
  51058. }
  51059. /**
  51060. * Interface used to define a simplification task
  51061. */
  51062. export interface ISimplificationTask {
  51063. /**
  51064. * Array of settings
  51065. */
  51066. settings: Array<ISimplificationSettings>;
  51067. /**
  51068. * Simplification type
  51069. */
  51070. simplificationType: SimplificationType;
  51071. /**
  51072. * Mesh to simplify
  51073. */
  51074. mesh: Mesh;
  51075. /**
  51076. * Callback called on success
  51077. */
  51078. successCallback?: () => void;
  51079. /**
  51080. * Defines if parallel processing can be used
  51081. */
  51082. parallelProcessing: boolean;
  51083. }
  51084. /**
  51085. * Queue used to order the simplification tasks
  51086. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51087. */
  51088. export class SimplificationQueue {
  51089. private _simplificationArray;
  51090. /**
  51091. * Gets a boolean indicating that the process is still running
  51092. */
  51093. running: boolean;
  51094. /**
  51095. * Creates a new queue
  51096. */
  51097. constructor();
  51098. /**
  51099. * Adds a new simplification task
  51100. * @param task defines a task to add
  51101. */
  51102. addTask(task: ISimplificationTask): void;
  51103. /**
  51104. * Execute next task
  51105. */
  51106. executeNext(): void;
  51107. /**
  51108. * Execute a simplification task
  51109. * @param task defines the task to run
  51110. */
  51111. runSimplification(task: ISimplificationTask): void;
  51112. private getSimplifier;
  51113. }
  51114. /**
  51115. * The implemented types of simplification
  51116. * At the moment only Quadratic Error Decimation is implemented
  51117. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51118. */
  51119. export enum SimplificationType {
  51120. /** Quadratic error decimation */
  51121. QUADRATIC = 0
  51122. }
  51123. }
  51124. declare module BABYLON {
  51125. interface Scene {
  51126. /** @hidden (Backing field) */
  51127. _simplificationQueue: SimplificationQueue;
  51128. /**
  51129. * Gets or sets the simplification queue attached to the scene
  51130. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51131. */
  51132. simplificationQueue: SimplificationQueue;
  51133. }
  51134. interface Mesh {
  51135. /**
  51136. * Simplify the mesh according to the given array of settings.
  51137. * Function will return immediately and will simplify async
  51138. * @param settings a collection of simplification settings
  51139. * @param parallelProcessing should all levels calculate parallel or one after the other
  51140. * @param simplificationType the type of simplification to run
  51141. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51142. * @returns the current mesh
  51143. */
  51144. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51145. }
  51146. /**
  51147. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51148. * created in a scene
  51149. */
  51150. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51151. /**
  51152. * The component name helpfull to identify the component in the list of scene components.
  51153. */
  51154. readonly name: string;
  51155. /**
  51156. * The scene the component belongs to.
  51157. */
  51158. scene: Scene;
  51159. /**
  51160. * Creates a new instance of the component for the given scene
  51161. * @param scene Defines the scene to register the component in
  51162. */
  51163. constructor(scene: Scene);
  51164. /**
  51165. * Registers the component in a given scene
  51166. */
  51167. register(): void;
  51168. /**
  51169. * Rebuilds the elements related to this component in case of
  51170. * context lost for instance.
  51171. */
  51172. rebuild(): void;
  51173. /**
  51174. * Disposes the component and the associated ressources
  51175. */
  51176. dispose(): void;
  51177. private _beforeCameraUpdate;
  51178. }
  51179. }
  51180. declare module BABYLON {
  51181. /**
  51182. * Class used to enable access to IndexedDB
  51183. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51184. */
  51185. export class Database implements IOfflineProvider {
  51186. private _callbackManifestChecked;
  51187. private _currentSceneUrl;
  51188. private _db;
  51189. private _enableSceneOffline;
  51190. private _enableTexturesOffline;
  51191. private _manifestVersionFound;
  51192. private _mustUpdateRessources;
  51193. private _hasReachedQuota;
  51194. private _isSupported;
  51195. private _idbFactory;
  51196. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51197. private static IsUASupportingBlobStorage;
  51198. /**
  51199. * Gets a boolean indicating if Database storate is enabled (off by default)
  51200. */
  51201. static IDBStorageEnabled: boolean;
  51202. /**
  51203. * Gets a boolean indicating if scene must be saved in the database
  51204. */
  51205. readonly enableSceneOffline: boolean;
  51206. /**
  51207. * Gets a boolean indicating if textures must be saved in the database
  51208. */
  51209. readonly enableTexturesOffline: boolean;
  51210. /**
  51211. * Creates a new Database
  51212. * @param urlToScene defines the url to load the scene
  51213. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51214. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51215. */
  51216. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51217. private static _ParseURL;
  51218. private static _ReturnFullUrlLocation;
  51219. private _checkManifestFile;
  51220. /**
  51221. * Open the database and make it available
  51222. * @param successCallback defines the callback to call on success
  51223. * @param errorCallback defines the callback to call on error
  51224. */
  51225. open(successCallback: () => void, errorCallback: () => void): void;
  51226. /**
  51227. * Loads an image from the database
  51228. * @param url defines the url to load from
  51229. * @param image defines the target DOM image
  51230. */
  51231. loadImage(url: string, image: HTMLImageElement): void;
  51232. private _loadImageFromDBAsync;
  51233. private _saveImageIntoDBAsync;
  51234. private _checkVersionFromDB;
  51235. private _loadVersionFromDBAsync;
  51236. private _saveVersionIntoDBAsync;
  51237. /**
  51238. * Loads a file from database
  51239. * @param url defines the URL to load from
  51240. * @param sceneLoaded defines a callback to call on success
  51241. * @param progressCallBack defines a callback to call when progress changed
  51242. * @param errorCallback defines a callback to call on error
  51243. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51244. */
  51245. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51246. private _loadFileAsync;
  51247. private _saveFileAsync;
  51248. /**
  51249. * Validates if xhr data is correct
  51250. * @param xhr defines the request to validate
  51251. * @param dataType defines the expected data type
  51252. * @returns true if data is correct
  51253. */
  51254. private static _ValidateXHRData;
  51255. }
  51256. }
  51257. declare module BABYLON {
  51258. /** @hidden */
  51259. export var gpuUpdateParticlesPixelShader: {
  51260. name: string;
  51261. shader: string;
  51262. };
  51263. }
  51264. declare module BABYLON {
  51265. /** @hidden */
  51266. export var gpuUpdateParticlesVertexShader: {
  51267. name: string;
  51268. shader: string;
  51269. };
  51270. }
  51271. declare module BABYLON {
  51272. /** @hidden */
  51273. export var clipPlaneFragmentDeclaration2: {
  51274. name: string;
  51275. shader: string;
  51276. };
  51277. }
  51278. declare module BABYLON {
  51279. /** @hidden */
  51280. export var gpuRenderParticlesPixelShader: {
  51281. name: string;
  51282. shader: string;
  51283. };
  51284. }
  51285. declare module BABYLON {
  51286. /** @hidden */
  51287. export var clipPlaneVertexDeclaration2: {
  51288. name: string;
  51289. shader: string;
  51290. };
  51291. }
  51292. declare module BABYLON {
  51293. /** @hidden */
  51294. export var gpuRenderParticlesVertexShader: {
  51295. name: string;
  51296. shader: string;
  51297. };
  51298. }
  51299. declare module BABYLON {
  51300. /**
  51301. * This represents a GPU particle system in Babylon
  51302. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51303. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51304. */
  51305. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51306. /**
  51307. * The layer mask we are rendering the particles through.
  51308. */
  51309. layerMask: number;
  51310. private _capacity;
  51311. private _activeCount;
  51312. private _currentActiveCount;
  51313. private _accumulatedCount;
  51314. private _renderEffect;
  51315. private _updateEffect;
  51316. private _buffer0;
  51317. private _buffer1;
  51318. private _spriteBuffer;
  51319. private _updateVAO;
  51320. private _renderVAO;
  51321. private _targetIndex;
  51322. private _sourceBuffer;
  51323. private _targetBuffer;
  51324. private _engine;
  51325. private _currentRenderId;
  51326. private _started;
  51327. private _stopped;
  51328. private _timeDelta;
  51329. private _randomTexture;
  51330. private _randomTexture2;
  51331. private _attributesStrideSize;
  51332. private _updateEffectOptions;
  51333. private _randomTextureSize;
  51334. private _actualFrame;
  51335. private readonly _rawTextureWidth;
  51336. /**
  51337. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51338. */
  51339. static readonly IsSupported: boolean;
  51340. /**
  51341. * An event triggered when the system is disposed.
  51342. */
  51343. onDisposeObservable: Observable<GPUParticleSystem>;
  51344. /**
  51345. * Gets the maximum number of particles active at the same time.
  51346. * @returns The max number of active particles.
  51347. */
  51348. getCapacity(): number;
  51349. /**
  51350. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51351. * to override the particles.
  51352. */
  51353. forceDepthWrite: boolean;
  51354. /**
  51355. * Gets or set the number of active particles
  51356. */
  51357. activeParticleCount: number;
  51358. private _preWarmDone;
  51359. /**
  51360. * Is this system ready to be used/rendered
  51361. * @return true if the system is ready
  51362. */
  51363. isReady(): boolean;
  51364. /**
  51365. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51366. * @returns True if it has been started, otherwise false.
  51367. */
  51368. isStarted(): boolean;
  51369. /**
  51370. * Starts the particle system and begins to emit
  51371. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51372. */
  51373. start(delay?: number): void;
  51374. /**
  51375. * Stops the particle system.
  51376. */
  51377. stop(): void;
  51378. /**
  51379. * Remove all active particles
  51380. */
  51381. reset(): void;
  51382. /**
  51383. * Returns the string "GPUParticleSystem"
  51384. * @returns a string containing the class name
  51385. */
  51386. getClassName(): string;
  51387. private _colorGradientsTexture;
  51388. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51389. /**
  51390. * Adds a new color gradient
  51391. * @param gradient defines the gradient to use (between 0 and 1)
  51392. * @param color1 defines the color to affect to the specified gradient
  51393. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51394. * @returns the current particle system
  51395. */
  51396. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51397. /**
  51398. * Remove a specific color gradient
  51399. * @param gradient defines the gradient to remove
  51400. * @returns the current particle system
  51401. */
  51402. removeColorGradient(gradient: number): GPUParticleSystem;
  51403. private _angularSpeedGradientsTexture;
  51404. private _sizeGradientsTexture;
  51405. private _velocityGradientsTexture;
  51406. private _limitVelocityGradientsTexture;
  51407. private _dragGradientsTexture;
  51408. private _addFactorGradient;
  51409. /**
  51410. * Adds a new size gradient
  51411. * @param gradient defines the gradient to use (between 0 and 1)
  51412. * @param factor defines the size factor to affect to the specified gradient
  51413. * @returns the current particle system
  51414. */
  51415. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51416. /**
  51417. * Remove a specific size gradient
  51418. * @param gradient defines the gradient to remove
  51419. * @returns the current particle system
  51420. */
  51421. removeSizeGradient(gradient: number): GPUParticleSystem;
  51422. /**
  51423. * Adds a new angular speed gradient
  51424. * @param gradient defines the gradient to use (between 0 and 1)
  51425. * @param factor defines the angular speed to affect to the specified gradient
  51426. * @returns the current particle system
  51427. */
  51428. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51429. /**
  51430. * Remove a specific angular speed gradient
  51431. * @param gradient defines the gradient to remove
  51432. * @returns the current particle system
  51433. */
  51434. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51435. /**
  51436. * Adds a new velocity gradient
  51437. * @param gradient defines the gradient to use (between 0 and 1)
  51438. * @param factor defines the velocity to affect to the specified gradient
  51439. * @returns the current particle system
  51440. */
  51441. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51442. /**
  51443. * Remove a specific velocity gradient
  51444. * @param gradient defines the gradient to remove
  51445. * @returns the current particle system
  51446. */
  51447. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51448. /**
  51449. * Adds a new limit velocity gradient
  51450. * @param gradient defines the gradient to use (between 0 and 1)
  51451. * @param factor defines the limit velocity value to affect to the specified gradient
  51452. * @returns the current particle system
  51453. */
  51454. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51455. /**
  51456. * Remove a specific limit velocity gradient
  51457. * @param gradient defines the gradient to remove
  51458. * @returns the current particle system
  51459. */
  51460. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51461. /**
  51462. * Adds a new drag gradient
  51463. * @param gradient defines the gradient to use (between 0 and 1)
  51464. * @param factor defines the drag value to affect to the specified gradient
  51465. * @returns the current particle system
  51466. */
  51467. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51468. /**
  51469. * Remove a specific drag gradient
  51470. * @param gradient defines the gradient to remove
  51471. * @returns the current particle system
  51472. */
  51473. removeDragGradient(gradient: number): GPUParticleSystem;
  51474. /**
  51475. * Not supported by GPUParticleSystem
  51476. * @param gradient defines the gradient to use (between 0 and 1)
  51477. * @param factor defines the emit rate value to affect to the specified gradient
  51478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51479. * @returns the current particle system
  51480. */
  51481. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51482. /**
  51483. * Not supported by GPUParticleSystem
  51484. * @param gradient defines the gradient to remove
  51485. * @returns the current particle system
  51486. */
  51487. removeEmitRateGradient(gradient: number): IParticleSystem;
  51488. /**
  51489. * Not supported by GPUParticleSystem
  51490. * @param gradient defines the gradient to use (between 0 and 1)
  51491. * @param factor defines the start size value to affect to the specified gradient
  51492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51493. * @returns the current particle system
  51494. */
  51495. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51496. /**
  51497. * Not supported by GPUParticleSystem
  51498. * @param gradient defines the gradient to remove
  51499. * @returns the current particle system
  51500. */
  51501. removeStartSizeGradient(gradient: number): IParticleSystem;
  51502. /**
  51503. * Not supported by GPUParticleSystem
  51504. * @param gradient defines the gradient to use (between 0 and 1)
  51505. * @param min defines the color remap minimal range
  51506. * @param max defines the color remap maximal range
  51507. * @returns the current particle system
  51508. */
  51509. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51510. /**
  51511. * Not supported by GPUParticleSystem
  51512. * @param gradient defines the gradient to remove
  51513. * @returns the current particle system
  51514. */
  51515. removeColorRemapGradient(): IParticleSystem;
  51516. /**
  51517. * Not supported by GPUParticleSystem
  51518. * @param gradient defines the gradient to use (between 0 and 1)
  51519. * @param min defines the alpha remap minimal range
  51520. * @param max defines the alpha remap maximal range
  51521. * @returns the current particle system
  51522. */
  51523. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51524. /**
  51525. * Not supported by GPUParticleSystem
  51526. * @param gradient defines the gradient to remove
  51527. * @returns the current particle system
  51528. */
  51529. removeAlphaRemapGradient(): IParticleSystem;
  51530. /**
  51531. * Not supported by GPUParticleSystem
  51532. * @param gradient defines the gradient to use (between 0 and 1)
  51533. * @param color defines the color to affect to the specified gradient
  51534. * @returns the current particle system
  51535. */
  51536. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51537. /**
  51538. * Not supported by GPUParticleSystem
  51539. * @param gradient defines the gradient to remove
  51540. * @returns the current particle system
  51541. */
  51542. removeRampGradient(): IParticleSystem;
  51543. /**
  51544. * Not supported by GPUParticleSystem
  51545. * @returns the list of ramp gradients
  51546. */
  51547. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51548. /**
  51549. * Not supported by GPUParticleSystem
  51550. * Gets or sets a boolean indicating that ramp gradients must be used
  51551. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51552. */
  51553. useRampGradients: boolean;
  51554. /**
  51555. * Not supported by GPUParticleSystem
  51556. * @param gradient defines the gradient to use (between 0 and 1)
  51557. * @param factor defines the life time factor to affect to the specified gradient
  51558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51559. * @returns the current particle system
  51560. */
  51561. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51562. /**
  51563. * Not supported by GPUParticleSystem
  51564. * @param gradient defines the gradient to remove
  51565. * @returns the current particle system
  51566. */
  51567. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51568. /**
  51569. * Instantiates a GPU particle system.
  51570. * 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.
  51571. * @param name The name of the particle system
  51572. * @param options The options used to create the system
  51573. * @param scene The scene the particle system belongs to
  51574. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51575. */
  51576. constructor(name: string, options: Partial<{
  51577. capacity: number;
  51578. randomTextureSize: number;
  51579. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51580. protected _reset(): void;
  51581. private _createUpdateVAO;
  51582. private _createRenderVAO;
  51583. private _initialize;
  51584. /** @hidden */
  51585. _recreateUpdateEffect(): void;
  51586. /** @hidden */
  51587. _recreateRenderEffect(): void;
  51588. /**
  51589. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51590. * @param preWarm defines if we are in the pre-warmimg phase
  51591. */
  51592. animate(preWarm?: boolean): void;
  51593. private _createFactorGradientTexture;
  51594. private _createSizeGradientTexture;
  51595. private _createAngularSpeedGradientTexture;
  51596. private _createVelocityGradientTexture;
  51597. private _createLimitVelocityGradientTexture;
  51598. private _createDragGradientTexture;
  51599. private _createColorGradientTexture;
  51600. /**
  51601. * Renders the particle system in its current state
  51602. * @param preWarm defines if the system should only update the particles but not render them
  51603. * @returns the current number of particles
  51604. */
  51605. render(preWarm?: boolean): number;
  51606. /**
  51607. * Rebuilds the particle system
  51608. */
  51609. rebuild(): void;
  51610. private _releaseBuffers;
  51611. private _releaseVAOs;
  51612. /**
  51613. * Disposes the particle system and free the associated resources
  51614. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51615. */
  51616. dispose(disposeTexture?: boolean): void;
  51617. /**
  51618. * Clones the particle system.
  51619. * @param name The name of the cloned object
  51620. * @param newEmitter The new emitter to use
  51621. * @returns the cloned particle system
  51622. */
  51623. clone(name: string, newEmitter: any): GPUParticleSystem;
  51624. /**
  51625. * Serializes the particle system to a JSON object.
  51626. * @returns the JSON object
  51627. */
  51628. serialize(): any;
  51629. /**
  51630. * Parses a JSON object to create a GPU particle system.
  51631. * @param parsedParticleSystem The JSON object to parse
  51632. * @param scene The scene to create the particle system in
  51633. * @param rootUrl The root url to use to load external dependencies like texture
  51634. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51635. * @returns the parsed GPU particle system
  51636. */
  51637. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51638. }
  51639. }
  51640. declare module BABYLON {
  51641. /**
  51642. * Represents a set of particle systems working together to create a specific effect
  51643. */
  51644. export class ParticleSystemSet implements IDisposable {
  51645. private _emitterCreationOptions;
  51646. private _emitterNode;
  51647. /**
  51648. * Gets the particle system list
  51649. */
  51650. systems: IParticleSystem[];
  51651. /**
  51652. * Gets the emitter node used with this set
  51653. */
  51654. readonly emitterNode: Nullable<TransformNode>;
  51655. /**
  51656. * Creates a new emitter mesh as a sphere
  51657. * @param options defines the options used to create the sphere
  51658. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51659. * @param scene defines the hosting scene
  51660. */
  51661. setEmitterAsSphere(options: {
  51662. diameter: number;
  51663. segments: number;
  51664. color: Color3;
  51665. }, renderingGroupId: number, scene: Scene): void;
  51666. /**
  51667. * Starts all particle systems of the set
  51668. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51669. */
  51670. start(emitter?: AbstractMesh): void;
  51671. /**
  51672. * Release all associated resources
  51673. */
  51674. dispose(): void;
  51675. /**
  51676. * Serialize the set into a JSON compatible object
  51677. * @returns a JSON compatible representation of the set
  51678. */
  51679. serialize(): any;
  51680. /**
  51681. * Parse a new ParticleSystemSet from a serialized source
  51682. * @param data defines a JSON compatible representation of the set
  51683. * @param scene defines the hosting scene
  51684. * @param gpu defines if we want GPU particles or CPU particles
  51685. * @returns a new ParticleSystemSet
  51686. */
  51687. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51688. }
  51689. }
  51690. declare module BABYLON {
  51691. /**
  51692. * This class is made for on one-liner static method to help creating particle system set.
  51693. */
  51694. export class ParticleHelper {
  51695. /**
  51696. * Gets or sets base Assets URL
  51697. */
  51698. static BaseAssetsUrl: string;
  51699. /**
  51700. * Create a default particle system that you can tweak
  51701. * @param emitter defines the emitter to use
  51702. * @param capacity defines the system capacity (default is 500 particles)
  51703. * @param scene defines the hosting scene
  51704. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51705. * @returns the new Particle system
  51706. */
  51707. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51708. /**
  51709. * This is the main static method (one-liner) of this helper to create different particle systems
  51710. * @param type This string represents the type to the particle system to create
  51711. * @param scene The scene where the particle system should live
  51712. * @param gpu If the system will use gpu
  51713. * @returns the ParticleSystemSet created
  51714. */
  51715. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51716. /**
  51717. * Static function used to export a particle system to a ParticleSystemSet variable.
  51718. * Please note that the emitter shape is not exported
  51719. * @param systems defines the particle systems to export
  51720. * @returns the created particle system set
  51721. */
  51722. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51723. }
  51724. }
  51725. declare module BABYLON {
  51726. interface Engine {
  51727. /**
  51728. * Create an effect to use with particle systems.
  51729. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51730. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51731. * @param uniformsNames defines a list of attribute names
  51732. * @param samplers defines an array of string used to represent textures
  51733. * @param defines defines the string containing the defines to use to compile the shaders
  51734. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51735. * @param onCompiled defines a function to call when the effect creation is successful
  51736. * @param onError defines a function to call when the effect creation has failed
  51737. * @returns the new Effect
  51738. */
  51739. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51740. }
  51741. interface Mesh {
  51742. /**
  51743. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51744. * @returns an array of IParticleSystem
  51745. */
  51746. getEmittedParticleSystems(): IParticleSystem[];
  51747. /**
  51748. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51749. * @returns an array of IParticleSystem
  51750. */
  51751. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51752. }
  51753. /**
  51754. * @hidden
  51755. */
  51756. export var _IDoNeedToBeInTheBuild: number;
  51757. }
  51758. declare module BABYLON {
  51759. interface Scene {
  51760. /** @hidden (Backing field) */
  51761. _physicsEngine: Nullable<IPhysicsEngine>;
  51762. /**
  51763. * Gets the current physics engine
  51764. * @returns a IPhysicsEngine or null if none attached
  51765. */
  51766. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51767. /**
  51768. * Enables physics to the current scene
  51769. * @param gravity defines the scene's gravity for the physics engine
  51770. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51771. * @return a boolean indicating if the physics engine was initialized
  51772. */
  51773. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51774. /**
  51775. * Disables and disposes the physics engine associated with the scene
  51776. */
  51777. disablePhysicsEngine(): void;
  51778. /**
  51779. * Gets a boolean indicating if there is an active physics engine
  51780. * @returns a boolean indicating if there is an active physics engine
  51781. */
  51782. isPhysicsEnabled(): boolean;
  51783. /**
  51784. * Deletes a physics compound impostor
  51785. * @param compound defines the compound to delete
  51786. */
  51787. deleteCompoundImpostor(compound: any): void;
  51788. /**
  51789. * An event triggered when physic simulation is about to be run
  51790. */
  51791. onBeforePhysicsObservable: Observable<Scene>;
  51792. /**
  51793. * An event triggered when physic simulation has been done
  51794. */
  51795. onAfterPhysicsObservable: Observable<Scene>;
  51796. }
  51797. interface AbstractMesh {
  51798. /** @hidden */
  51799. _physicsImpostor: Nullable<PhysicsImpostor>;
  51800. /**
  51801. * Gets or sets impostor used for physic simulation
  51802. * @see http://doc.babylonjs.com/features/physics_engine
  51803. */
  51804. physicsImpostor: Nullable<PhysicsImpostor>;
  51805. /**
  51806. * Gets the current physics impostor
  51807. * @see http://doc.babylonjs.com/features/physics_engine
  51808. * @returns a physics impostor or null
  51809. */
  51810. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51811. /** Apply a physic impulse to the mesh
  51812. * @param force defines the force to apply
  51813. * @param contactPoint defines where to apply the force
  51814. * @returns the current mesh
  51815. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51816. */
  51817. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51818. /**
  51819. * Creates a physic joint between two meshes
  51820. * @param otherMesh defines the other mesh to use
  51821. * @param pivot1 defines the pivot to use on this mesh
  51822. * @param pivot2 defines the pivot to use on the other mesh
  51823. * @param options defines additional options (can be plugin dependent)
  51824. * @returns the current mesh
  51825. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51826. */
  51827. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51828. /** @hidden */
  51829. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51830. }
  51831. /**
  51832. * Defines the physics engine scene component responsible to manage a physics engine
  51833. */
  51834. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51835. /**
  51836. * The component name helpful to identify the component in the list of scene components.
  51837. */
  51838. readonly name: string;
  51839. /**
  51840. * The scene the component belongs to.
  51841. */
  51842. scene: Scene;
  51843. /**
  51844. * Creates a new instance of the component for the given scene
  51845. * @param scene Defines the scene to register the component in
  51846. */
  51847. constructor(scene: Scene);
  51848. /**
  51849. * Registers the component in a given scene
  51850. */
  51851. register(): void;
  51852. /**
  51853. * Rebuilds the elements related to this component in case of
  51854. * context lost for instance.
  51855. */
  51856. rebuild(): void;
  51857. /**
  51858. * Disposes the component and the associated ressources
  51859. */
  51860. dispose(): void;
  51861. }
  51862. }
  51863. declare module BABYLON {
  51864. /**
  51865. * A helper for physics simulations
  51866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51867. */
  51868. export class PhysicsHelper {
  51869. private _scene;
  51870. private _physicsEngine;
  51871. /**
  51872. * Initializes the Physics helper
  51873. * @param scene Babylon.js scene
  51874. */
  51875. constructor(scene: Scene);
  51876. /**
  51877. * Applies a radial explosion impulse
  51878. * @param origin the origin of the explosion
  51879. * @param radiusOrEventOptions the radius or the options of radial explosion
  51880. * @param strength the explosion strength
  51881. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51882. * @returns A physics radial explosion event, or null
  51883. */
  51884. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51885. /**
  51886. * Applies a radial explosion force
  51887. * @param origin the origin of the explosion
  51888. * @param radiusOrEventOptions the radius or the options of radial explosion
  51889. * @param strength the explosion strength
  51890. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51891. * @returns A physics radial explosion event, or null
  51892. */
  51893. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51894. /**
  51895. * Creates a gravitational field
  51896. * @param origin the origin of the explosion
  51897. * @param radiusOrEventOptions the radius or the options of radial explosion
  51898. * @param strength the explosion strength
  51899. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51900. * @returns A physics gravitational field event, or null
  51901. */
  51902. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51903. /**
  51904. * Creates a physics updraft event
  51905. * @param origin the origin of the updraft
  51906. * @param radiusOrEventOptions the radius or the options of the updraft
  51907. * @param strength the strength of the updraft
  51908. * @param height the height of the updraft
  51909. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51910. * @returns A physics updraft event, or null
  51911. */
  51912. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51913. /**
  51914. * Creates a physics vortex event
  51915. * @param origin the of the vortex
  51916. * @param radiusOrEventOptions the radius or the options of the vortex
  51917. * @param strength the strength of the vortex
  51918. * @param height the height of the vortex
  51919. * @returns a Physics vortex event, or null
  51920. * A physics vortex event or null
  51921. */
  51922. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51923. }
  51924. /**
  51925. * Represents a physics radial explosion event
  51926. */
  51927. class PhysicsRadialExplosionEvent {
  51928. private _scene;
  51929. private _options;
  51930. private _sphere;
  51931. private _dataFetched;
  51932. /**
  51933. * Initializes a radial explosioin event
  51934. * @param _scene BabylonJS scene
  51935. * @param _options The options for the vortex event
  51936. */
  51937. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51938. /**
  51939. * Returns the data related to the radial explosion event (sphere).
  51940. * @returns The radial explosion event data
  51941. */
  51942. getData(): PhysicsRadialExplosionEventData;
  51943. /**
  51944. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51945. * @param impostor A physics imposter
  51946. * @param origin the origin of the explosion
  51947. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51948. */
  51949. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51950. /**
  51951. * Triggers affecterd impostors callbacks
  51952. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51953. */
  51954. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51955. /**
  51956. * Disposes the sphere.
  51957. * @param force Specifies if the sphere should be disposed by force
  51958. */
  51959. dispose(force?: boolean): void;
  51960. /*** Helpers ***/
  51961. private _prepareSphere;
  51962. private _intersectsWithSphere;
  51963. }
  51964. /**
  51965. * Represents a gravitational field event
  51966. */
  51967. class PhysicsGravitationalFieldEvent {
  51968. private _physicsHelper;
  51969. private _scene;
  51970. private _origin;
  51971. private _options;
  51972. private _tickCallback;
  51973. private _sphere;
  51974. private _dataFetched;
  51975. /**
  51976. * Initializes the physics gravitational field event
  51977. * @param _physicsHelper A physics helper
  51978. * @param _scene BabylonJS scene
  51979. * @param _origin The origin position of the gravitational field event
  51980. * @param _options The options for the vortex event
  51981. */
  51982. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51983. /**
  51984. * Returns the data related to the gravitational field event (sphere).
  51985. * @returns A gravitational field event
  51986. */
  51987. getData(): PhysicsGravitationalFieldEventData;
  51988. /**
  51989. * Enables the gravitational field.
  51990. */
  51991. enable(): void;
  51992. /**
  51993. * Disables the gravitational field.
  51994. */
  51995. disable(): void;
  51996. /**
  51997. * Disposes the sphere.
  51998. * @param force The force to dispose from the gravitational field event
  51999. */
  52000. dispose(force?: boolean): void;
  52001. private _tick;
  52002. }
  52003. /**
  52004. * Represents a physics updraft event
  52005. */
  52006. class PhysicsUpdraftEvent {
  52007. private _scene;
  52008. private _origin;
  52009. private _options;
  52010. private _physicsEngine;
  52011. private _originTop;
  52012. private _originDirection;
  52013. private _tickCallback;
  52014. private _cylinder;
  52015. private _cylinderPosition;
  52016. private _dataFetched;
  52017. /**
  52018. * Initializes the physics updraft event
  52019. * @param _scene BabylonJS scene
  52020. * @param _origin The origin position of the updraft
  52021. * @param _options The options for the updraft event
  52022. */
  52023. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52024. /**
  52025. * Returns the data related to the updraft event (cylinder).
  52026. * @returns A physics updraft event
  52027. */
  52028. getData(): PhysicsUpdraftEventData;
  52029. /**
  52030. * Enables the updraft.
  52031. */
  52032. enable(): void;
  52033. /**
  52034. * Disables the updraft.
  52035. */
  52036. disable(): void;
  52037. /**
  52038. * Disposes the cylinder.
  52039. * @param force Specifies if the updraft should be disposed by force
  52040. */
  52041. dispose(force?: boolean): void;
  52042. private getImpostorHitData;
  52043. private _tick;
  52044. /*** Helpers ***/
  52045. private _prepareCylinder;
  52046. private _intersectsWithCylinder;
  52047. }
  52048. /**
  52049. * Represents a physics vortex event
  52050. */
  52051. class PhysicsVortexEvent {
  52052. private _scene;
  52053. private _origin;
  52054. private _options;
  52055. private _physicsEngine;
  52056. private _originTop;
  52057. private _tickCallback;
  52058. private _cylinder;
  52059. private _cylinderPosition;
  52060. private _dataFetched;
  52061. /**
  52062. * Initializes the physics vortex event
  52063. * @param _scene The BabylonJS scene
  52064. * @param _origin The origin position of the vortex
  52065. * @param _options The options for the vortex event
  52066. */
  52067. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52068. /**
  52069. * Returns the data related to the vortex event (cylinder).
  52070. * @returns The physics vortex event data
  52071. */
  52072. getData(): PhysicsVortexEventData;
  52073. /**
  52074. * Enables the vortex.
  52075. */
  52076. enable(): void;
  52077. /**
  52078. * Disables the cortex.
  52079. */
  52080. disable(): void;
  52081. /**
  52082. * Disposes the sphere.
  52083. * @param force
  52084. */
  52085. dispose(force?: boolean): void;
  52086. private getImpostorHitData;
  52087. private _tick;
  52088. /*** Helpers ***/
  52089. private _prepareCylinder;
  52090. private _intersectsWithCylinder;
  52091. }
  52092. /**
  52093. * Options fot the radial explosion event
  52094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52095. */
  52096. export class PhysicsRadialExplosionEventOptions {
  52097. /**
  52098. * The radius of the sphere for the radial explosion.
  52099. */
  52100. radius: number;
  52101. /**
  52102. * The strenth of the explosion.
  52103. */
  52104. strength: number;
  52105. /**
  52106. * The strenght of the force in correspondence to the distance of the affected object
  52107. */
  52108. falloff: PhysicsRadialImpulseFalloff;
  52109. /**
  52110. * Sphere options for the radial explosion.
  52111. */
  52112. sphere: {
  52113. segments: number;
  52114. diameter: number;
  52115. };
  52116. /**
  52117. * Sphere options for the radial explosion.
  52118. */
  52119. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  52120. }
  52121. /**
  52122. * Options fot the updraft event
  52123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52124. */
  52125. export class PhysicsUpdraftEventOptions {
  52126. /**
  52127. * The radius of the cylinder for the vortex
  52128. */
  52129. radius: number;
  52130. /**
  52131. * The strenth of the updraft.
  52132. */
  52133. strength: number;
  52134. /**
  52135. * The height of the cylinder for the updraft.
  52136. */
  52137. height: number;
  52138. /**
  52139. * The mode for the the updraft.
  52140. */
  52141. updraftMode: PhysicsUpdraftMode;
  52142. }
  52143. /**
  52144. * Options fot the vortex event
  52145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52146. */
  52147. export class PhysicsVortexEventOptions {
  52148. /**
  52149. * The radius of the cylinder for the vortex
  52150. */
  52151. radius: number;
  52152. /**
  52153. * The strenth of the vortex.
  52154. */
  52155. strength: number;
  52156. /**
  52157. * The height of the cylinder for the vortex.
  52158. */
  52159. height: number;
  52160. /**
  52161. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52162. */
  52163. centripetalForceThreshold: number;
  52164. /**
  52165. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52166. */
  52167. centripetalForceMultiplier: number;
  52168. /**
  52169. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52170. */
  52171. centrifugalForceMultiplier: number;
  52172. /**
  52173. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52174. */
  52175. updraftForceMultiplier: number;
  52176. }
  52177. /**
  52178. * The strenght of the force in correspondence to the distance of the affected object
  52179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52180. */
  52181. export enum PhysicsRadialImpulseFalloff {
  52182. /** Defines that impulse is constant in strength across it's whole radius */
  52183. Constant = 0,
  52184. /** Defines that impulse gets weaker if it's further from the origin */
  52185. Linear = 1
  52186. }
  52187. /**
  52188. * The strength of the force in correspondence to the distance of the affected object
  52189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52190. */
  52191. export enum PhysicsUpdraftMode {
  52192. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52193. Center = 0,
  52194. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52195. Perpendicular = 1
  52196. }
  52197. /**
  52198. * Interface for a physics hit data
  52199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52200. */
  52201. export interface PhysicsHitData {
  52202. /**
  52203. * The force applied at the contact point
  52204. */
  52205. force: Vector3;
  52206. /**
  52207. * The contact point
  52208. */
  52209. contactPoint: Vector3;
  52210. /**
  52211. * The distance from the origin to the contact point
  52212. */
  52213. distanceFromOrigin: number;
  52214. }
  52215. /**
  52216. * Interface for radial explosion event data
  52217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52218. */
  52219. export interface PhysicsRadialExplosionEventData {
  52220. /**
  52221. * A sphere used for the radial explosion event
  52222. */
  52223. sphere: Mesh;
  52224. }
  52225. /**
  52226. * Interface for gravitational field event data
  52227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52228. */
  52229. export interface PhysicsGravitationalFieldEventData {
  52230. /**
  52231. * A sphere mesh used for the gravitational field event
  52232. */
  52233. sphere: Mesh;
  52234. }
  52235. /**
  52236. * Interface for updraft event data
  52237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52238. */
  52239. export interface PhysicsUpdraftEventData {
  52240. /**
  52241. * A cylinder used for the updraft event
  52242. */
  52243. cylinder: Mesh;
  52244. }
  52245. /**
  52246. * Interface for vortex event data
  52247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52248. */
  52249. export interface PhysicsVortexEventData {
  52250. /**
  52251. * A cylinder used for the vortex event
  52252. */
  52253. cylinder: Mesh;
  52254. }
  52255. /**
  52256. * Interface for an affected physics impostor
  52257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52258. */
  52259. export interface PhysicsAffectedImpostorWithData {
  52260. /**
  52261. * The impostor affected by the effect
  52262. */
  52263. impostor: PhysicsImpostor;
  52264. /**
  52265. * The data about the hit/horce from the explosion
  52266. */
  52267. hitData: PhysicsHitData;
  52268. }
  52269. }
  52270. declare module BABYLON {
  52271. /** @hidden */
  52272. export var blackAndWhitePixelShader: {
  52273. name: string;
  52274. shader: string;
  52275. };
  52276. }
  52277. declare module BABYLON {
  52278. /**
  52279. * Post process used to render in black and white
  52280. */
  52281. export class BlackAndWhitePostProcess extends PostProcess {
  52282. /**
  52283. * Linear about to convert he result to black and white (default: 1)
  52284. */
  52285. degree: number;
  52286. /**
  52287. * Creates a black and white post process
  52288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52289. * @param name The name of the effect.
  52290. * @param options The required width/height ratio to downsize to before computing the render pass.
  52291. * @param camera The camera to apply the render pass to.
  52292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52293. * @param engine The engine which the post process will be applied. (default: current engine)
  52294. * @param reusable If the post process can be reused on the same frame. (default: false)
  52295. */
  52296. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52297. }
  52298. }
  52299. declare module BABYLON {
  52300. /**
  52301. * This represents a set of one or more post processes in Babylon.
  52302. * A post process can be used to apply a shader to a texture after it is rendered.
  52303. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52304. */
  52305. export class PostProcessRenderEffect {
  52306. private _postProcesses;
  52307. private _getPostProcesses;
  52308. private _singleInstance;
  52309. private _cameras;
  52310. private _indicesForCamera;
  52311. /**
  52312. * Name of the effect
  52313. * @hidden
  52314. */
  52315. _name: string;
  52316. /**
  52317. * Instantiates a post process render effect.
  52318. * A post process can be used to apply a shader to a texture after it is rendered.
  52319. * @param engine The engine the effect is tied to
  52320. * @param name The name of the effect
  52321. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52322. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52323. */
  52324. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52325. /**
  52326. * Checks if all the post processes in the effect are supported.
  52327. */
  52328. readonly isSupported: boolean;
  52329. /**
  52330. * Updates the current state of the effect
  52331. * @hidden
  52332. */
  52333. _update(): void;
  52334. /**
  52335. * Attaches the effect on cameras
  52336. * @param cameras The camera to attach to.
  52337. * @hidden
  52338. */
  52339. _attachCameras(cameras: Camera): void;
  52340. /**
  52341. * Attaches the effect on cameras
  52342. * @param cameras The camera to attach to.
  52343. * @hidden
  52344. */
  52345. _attachCameras(cameras: Camera[]): void;
  52346. /**
  52347. * Detaches the effect on cameras
  52348. * @param cameras The camera to detatch from.
  52349. * @hidden
  52350. */
  52351. _detachCameras(cameras: Camera): void;
  52352. /**
  52353. * Detatches the effect on cameras
  52354. * @param cameras The camera to detatch from.
  52355. * @hidden
  52356. */
  52357. _detachCameras(cameras: Camera[]): void;
  52358. /**
  52359. * Enables the effect on given cameras
  52360. * @param cameras The camera to enable.
  52361. * @hidden
  52362. */
  52363. _enable(cameras: Camera): void;
  52364. /**
  52365. * Enables the effect on given cameras
  52366. * @param cameras The camera to enable.
  52367. * @hidden
  52368. */
  52369. _enable(cameras: Nullable<Camera[]>): void;
  52370. /**
  52371. * Disables the effect on the given cameras
  52372. * @param cameras The camera to disable.
  52373. * @hidden
  52374. */
  52375. _disable(cameras: Camera): void;
  52376. /**
  52377. * Disables the effect on the given cameras
  52378. * @param cameras The camera to disable.
  52379. * @hidden
  52380. */
  52381. _disable(cameras: Nullable<Camera[]>): void;
  52382. /**
  52383. * Gets a list of the post processes contained in the effect.
  52384. * @param camera The camera to get the post processes on.
  52385. * @returns The list of the post processes in the effect.
  52386. */
  52387. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52388. }
  52389. }
  52390. declare module BABYLON {
  52391. /** @hidden */
  52392. export var extractHighlightsPixelShader: {
  52393. name: string;
  52394. shader: string;
  52395. };
  52396. }
  52397. declare module BABYLON {
  52398. /**
  52399. * 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.
  52400. */
  52401. export class ExtractHighlightsPostProcess extends PostProcess {
  52402. /**
  52403. * The luminance threshold, pixels below this value will be set to black.
  52404. */
  52405. threshold: number;
  52406. /** @hidden */
  52407. _exposure: number;
  52408. /**
  52409. * Post process which has the input texture to be used when performing highlight extraction
  52410. * @hidden
  52411. */
  52412. _inputPostProcess: Nullable<PostProcess>;
  52413. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52414. }
  52415. }
  52416. declare module BABYLON {
  52417. /** @hidden */
  52418. export var bloomMergePixelShader: {
  52419. name: string;
  52420. shader: string;
  52421. };
  52422. }
  52423. declare module BABYLON {
  52424. /**
  52425. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52426. */
  52427. export class BloomMergePostProcess extends PostProcess {
  52428. /** Weight of the bloom to be added to the original input. */
  52429. weight: number;
  52430. /**
  52431. * Creates a new instance of @see BloomMergePostProcess
  52432. * @param name The name of the effect.
  52433. * @param originalFromInput Post process which's input will be used for the merge.
  52434. * @param blurred Blurred highlights post process which's output will be used.
  52435. * @param weight Weight of the bloom to be added to the original input.
  52436. * @param options The required width/height ratio to downsize to before computing the render pass.
  52437. * @param camera The camera to apply the render pass to.
  52438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52439. * @param engine The engine which the post process will be applied. (default: current engine)
  52440. * @param reusable If the post process can be reused on the same frame. (default: false)
  52441. * @param textureType Type of textures used when performing the post process. (default: 0)
  52442. * @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)
  52443. */
  52444. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52445. /** Weight of the bloom to be added to the original input. */
  52446. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52447. }
  52448. }
  52449. declare module BABYLON {
  52450. /**
  52451. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52452. */
  52453. export class BloomEffect extends PostProcessRenderEffect {
  52454. private bloomScale;
  52455. /**
  52456. * @hidden Internal
  52457. */
  52458. _effects: Array<PostProcess>;
  52459. /**
  52460. * @hidden Internal
  52461. */
  52462. _downscale: ExtractHighlightsPostProcess;
  52463. private _blurX;
  52464. private _blurY;
  52465. private _merge;
  52466. /**
  52467. * The luminance threshold to find bright areas of the image to bloom.
  52468. */
  52469. threshold: number;
  52470. /**
  52471. * The strength of the bloom.
  52472. */
  52473. weight: number;
  52474. /**
  52475. * Specifies the size of the bloom blur kernel, relative to the final output size
  52476. */
  52477. kernel: number;
  52478. /**
  52479. * Creates a new instance of @see BloomEffect
  52480. * @param scene The scene the effect belongs to.
  52481. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52482. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52483. * @param bloomWeight The the strength of bloom.
  52484. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52485. * @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)
  52486. */
  52487. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52488. /**
  52489. * Disposes each of the internal effects for a given camera.
  52490. * @param camera The camera to dispose the effect on.
  52491. */
  52492. disposeEffects(camera: Camera): void;
  52493. /**
  52494. * @hidden Internal
  52495. */
  52496. _updateEffects(): void;
  52497. /**
  52498. * Internal
  52499. * @returns if all the contained post processes are ready.
  52500. * @hidden
  52501. */
  52502. _isReady(): boolean;
  52503. }
  52504. }
  52505. declare module BABYLON {
  52506. /** @hidden */
  52507. export var chromaticAberrationPixelShader: {
  52508. name: string;
  52509. shader: string;
  52510. };
  52511. }
  52512. declare module BABYLON {
  52513. /**
  52514. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52515. */
  52516. export class ChromaticAberrationPostProcess extends PostProcess {
  52517. /**
  52518. * The amount of seperation of rgb channels (default: 30)
  52519. */
  52520. aberrationAmount: number;
  52521. /**
  52522. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52523. */
  52524. radialIntensity: number;
  52525. /**
  52526. * 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))
  52527. */
  52528. direction: Vector2;
  52529. /**
  52530. * 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))
  52531. */
  52532. centerPosition: Vector2;
  52533. /**
  52534. * Creates a new instance ChromaticAberrationPostProcess
  52535. * @param name The name of the effect.
  52536. * @param screenWidth The width of the screen to apply the effect on.
  52537. * @param screenHeight The height of the screen to apply the effect on.
  52538. * @param options The required width/height ratio to downsize to before computing the render pass.
  52539. * @param camera The camera to apply the render pass to.
  52540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52541. * @param engine The engine which the post process will be applied. (default: current engine)
  52542. * @param reusable If the post process can be reused on the same frame. (default: false)
  52543. * @param textureType Type of textures used when performing the post process. (default: 0)
  52544. * @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)
  52545. */
  52546. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52547. }
  52548. }
  52549. declare module BABYLON {
  52550. /** @hidden */
  52551. export var circleOfConfusionPixelShader: {
  52552. name: string;
  52553. shader: string;
  52554. };
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52559. */
  52560. export class CircleOfConfusionPostProcess extends PostProcess {
  52561. /**
  52562. * 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.
  52563. */
  52564. lensSize: number;
  52565. /**
  52566. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52567. */
  52568. fStop: number;
  52569. /**
  52570. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52571. */
  52572. focusDistance: number;
  52573. /**
  52574. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52575. */
  52576. focalLength: number;
  52577. private _depthTexture;
  52578. /**
  52579. * Creates a new instance CircleOfConfusionPostProcess
  52580. * @param name The name of the effect.
  52581. * @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.
  52582. * @param options The required width/height ratio to downsize to before computing the render pass.
  52583. * @param camera The camera to apply the render pass to.
  52584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52585. * @param engine The engine which the post process will be applied. (default: current engine)
  52586. * @param reusable If the post process can be reused on the same frame. (default: false)
  52587. * @param textureType Type of textures used when performing the post process. (default: 0)
  52588. * @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)
  52589. */
  52590. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52591. /**
  52592. * 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.
  52593. */
  52594. depthTexture: RenderTargetTexture;
  52595. }
  52596. }
  52597. declare module BABYLON {
  52598. /** @hidden */
  52599. export var colorCorrectionPixelShader: {
  52600. name: string;
  52601. shader: string;
  52602. };
  52603. }
  52604. declare module BABYLON {
  52605. /**
  52606. *
  52607. * This post-process allows the modification of rendered colors by using
  52608. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52609. *
  52610. * The object needs to be provided an url to a texture containing the color
  52611. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52612. * Use an image editing software to tweak the LUT to match your needs.
  52613. *
  52614. * For an example of a color LUT, see here:
  52615. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52616. * For explanations on color grading, see here:
  52617. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52618. *
  52619. */
  52620. export class ColorCorrectionPostProcess extends PostProcess {
  52621. private _colorTableTexture;
  52622. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52623. }
  52624. }
  52625. declare module BABYLON {
  52626. /** @hidden */
  52627. export var convolutionPixelShader: {
  52628. name: string;
  52629. shader: string;
  52630. };
  52631. }
  52632. declare module BABYLON {
  52633. /**
  52634. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52635. * input texture to perform effects such as edge detection or sharpening
  52636. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52637. */
  52638. export class ConvolutionPostProcess extends PostProcess {
  52639. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52640. kernel: number[];
  52641. /**
  52642. * Creates a new instance ConvolutionPostProcess
  52643. * @param name The name of the effect.
  52644. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52645. * @param options The required width/height ratio to downsize to before computing the render pass.
  52646. * @param camera The camera to apply the render pass to.
  52647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52648. * @param engine The engine which the post process will be applied. (default: current engine)
  52649. * @param reusable If the post process can be reused on the same frame. (default: false)
  52650. * @param textureType Type of textures used when performing the post process. (default: 0)
  52651. */
  52652. constructor(name: string,
  52653. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52654. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52655. /**
  52656. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52657. */
  52658. static EdgeDetect0Kernel: number[];
  52659. /**
  52660. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52661. */
  52662. static EdgeDetect1Kernel: number[];
  52663. /**
  52664. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52665. */
  52666. static EdgeDetect2Kernel: number[];
  52667. /**
  52668. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52669. */
  52670. static SharpenKernel: number[];
  52671. /**
  52672. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52673. */
  52674. static EmbossKernel: number[];
  52675. /**
  52676. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52677. */
  52678. static GaussianKernel: number[];
  52679. }
  52680. }
  52681. declare module BABYLON {
  52682. /**
  52683. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52684. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52685. * based on samples that have a large difference in distance than the center pixel.
  52686. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52687. */
  52688. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52689. direction: Vector2;
  52690. /**
  52691. * Creates a new instance CircleOfConfusionPostProcess
  52692. * @param name The name of the effect.
  52693. * @param scene The scene the effect belongs to.
  52694. * @param direction The direction the blur should be applied.
  52695. * @param kernel The size of the kernel used to blur.
  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 circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52699. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52701. * @param engine The engine which the post process will be applied. (default: current engine)
  52702. * @param reusable If the post process can be reused on the same frame. (default: false)
  52703. * @param textureType Type of textures used when performing the post process. (default: 0)
  52704. * @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)
  52705. */
  52706. 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);
  52707. }
  52708. }
  52709. declare module BABYLON {
  52710. /** @hidden */
  52711. export var depthOfFieldMergePixelShader: {
  52712. name: string;
  52713. shader: string;
  52714. };
  52715. }
  52716. declare module BABYLON {
  52717. /**
  52718. * Options to be set when merging outputs from the default pipeline.
  52719. */
  52720. export class DepthOfFieldMergePostProcessOptions {
  52721. /**
  52722. * The original image to merge on top of
  52723. */
  52724. originalFromInput: PostProcess;
  52725. /**
  52726. * Parameters to perform the merge of the depth of field effect
  52727. */
  52728. depthOfField?: {
  52729. circleOfConfusion: PostProcess;
  52730. blurSteps: Array<PostProcess>;
  52731. };
  52732. /**
  52733. * Parameters to perform the merge of bloom effect
  52734. */
  52735. bloom?: {
  52736. blurred: PostProcess;
  52737. weight: number;
  52738. };
  52739. }
  52740. /**
  52741. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52742. */
  52743. export class DepthOfFieldMergePostProcess extends PostProcess {
  52744. private blurSteps;
  52745. /**
  52746. * Creates a new instance of DepthOfFieldMergePostProcess
  52747. * @param name The name of the effect.
  52748. * @param originalFromInput Post process which's input will be used for the merge.
  52749. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52750. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52751. * @param options The required width/height ratio to downsize to before computing the render pass.
  52752. * @param camera The camera to apply the render pass to.
  52753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52754. * @param engine The engine which the post process will be applied. (default: current engine)
  52755. * @param reusable If the post process can be reused on the same frame. (default: false)
  52756. * @param textureType Type of textures used when performing the post process. (default: 0)
  52757. * @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)
  52758. */
  52759. 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);
  52760. /**
  52761. * Updates the effect with the current post process compile time values and recompiles the shader.
  52762. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52763. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52764. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52765. * @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
  52766. * @param onCompiled Called when the shader has been compiled.
  52767. * @param onError Called if there is an error when compiling a shader.
  52768. */
  52769. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52770. }
  52771. }
  52772. declare module BABYLON {
  52773. /**
  52774. * Specifies the level of max blur that should be applied when using the depth of field effect
  52775. */
  52776. export enum DepthOfFieldEffectBlurLevel {
  52777. /**
  52778. * Subtle blur
  52779. */
  52780. Low = 0,
  52781. /**
  52782. * Medium blur
  52783. */
  52784. Medium = 1,
  52785. /**
  52786. * Large blur
  52787. */
  52788. High = 2
  52789. }
  52790. /**
  52791. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52792. */
  52793. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52794. private _circleOfConfusion;
  52795. /**
  52796. * @hidden Internal, blurs from high to low
  52797. */
  52798. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52799. private _depthOfFieldBlurY;
  52800. private _dofMerge;
  52801. /**
  52802. * @hidden Internal post processes in depth of field effect
  52803. */
  52804. _effects: Array<PostProcess>;
  52805. /**
  52806. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52807. */
  52808. focalLength: number;
  52809. /**
  52810. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52811. */
  52812. fStop: number;
  52813. /**
  52814. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52815. */
  52816. focusDistance: number;
  52817. /**
  52818. * 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.
  52819. */
  52820. lensSize: number;
  52821. /**
  52822. * Creates a new instance DepthOfFieldEffect
  52823. * @param scene The scene the effect belongs to.
  52824. * @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.
  52825. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52826. * @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)
  52827. */
  52828. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52829. /**
  52830. * Get the current class name of the current effet
  52831. * @returns "DepthOfFieldEffect"
  52832. */
  52833. getClassName(): string;
  52834. /**
  52835. * 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.
  52836. */
  52837. depthTexture: RenderTargetTexture;
  52838. /**
  52839. * Disposes each of the internal effects for a given camera.
  52840. * @param camera The camera to dispose the effect on.
  52841. */
  52842. disposeEffects(camera: Camera): void;
  52843. /**
  52844. * @hidden Internal
  52845. */
  52846. _updateEffects(): void;
  52847. /**
  52848. * Internal
  52849. * @returns if all the contained post processes are ready.
  52850. * @hidden
  52851. */
  52852. _isReady(): boolean;
  52853. }
  52854. }
  52855. declare module BABYLON {
  52856. /** @hidden */
  52857. export var displayPassPixelShader: {
  52858. name: string;
  52859. shader: string;
  52860. };
  52861. }
  52862. declare module BABYLON {
  52863. /**
  52864. * DisplayPassPostProcess which produces an output the same as it's input
  52865. */
  52866. export class DisplayPassPostProcess extends PostProcess {
  52867. /**
  52868. * Creates the DisplayPassPostProcess
  52869. * @param name The name of the effect.
  52870. * @param options The required width/height ratio to downsize to before computing the render pass.
  52871. * @param camera The camera to apply the render pass to.
  52872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52873. * @param engine The engine which the post process will be applied. (default: current engine)
  52874. * @param reusable If the post process can be reused on the same frame. (default: false)
  52875. */
  52876. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52877. }
  52878. }
  52879. declare module BABYLON {
  52880. /** @hidden */
  52881. export var filterPixelShader: {
  52882. name: string;
  52883. shader: string;
  52884. };
  52885. }
  52886. declare module BABYLON {
  52887. /**
  52888. * Applies a kernel filter to the image
  52889. */
  52890. export class FilterPostProcess extends PostProcess {
  52891. /** The matrix to be applied to the image */
  52892. kernelMatrix: Matrix;
  52893. /**
  52894. *
  52895. * @param name The name of the effect.
  52896. * @param kernelMatrix The matrix to be applied to the image
  52897. * @param options The required width/height ratio to downsize to before computing the render pass.
  52898. * @param camera The camera to apply the render pass to.
  52899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52900. * @param engine The engine which the post process will be applied. (default: current engine)
  52901. * @param reusable If the post process can be reused on the same frame. (default: false)
  52902. */
  52903. constructor(name: string,
  52904. /** The matrix to be applied to the image */
  52905. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52906. }
  52907. }
  52908. declare module BABYLON {
  52909. /** @hidden */
  52910. export var fxaaPixelShader: {
  52911. name: string;
  52912. shader: string;
  52913. };
  52914. }
  52915. declare module BABYLON {
  52916. /** @hidden */
  52917. export var fxaaVertexShader: {
  52918. name: string;
  52919. shader: string;
  52920. };
  52921. }
  52922. declare module BABYLON {
  52923. /**
  52924. * Fxaa post process
  52925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52926. */
  52927. export class FxaaPostProcess extends PostProcess {
  52928. /** @hidden */
  52929. texelWidth: number;
  52930. /** @hidden */
  52931. texelHeight: number;
  52932. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52933. private _getDefines;
  52934. }
  52935. }
  52936. declare module BABYLON {
  52937. /** @hidden */
  52938. export var grainPixelShader: {
  52939. name: string;
  52940. shader: string;
  52941. };
  52942. }
  52943. declare module BABYLON {
  52944. /**
  52945. * The GrainPostProcess adds noise to the image at mid luminance levels
  52946. */
  52947. export class GrainPostProcess extends PostProcess {
  52948. /**
  52949. * The intensity of the grain added (default: 30)
  52950. */
  52951. intensity: number;
  52952. /**
  52953. * If the grain should be randomized on every frame
  52954. */
  52955. animated: boolean;
  52956. /**
  52957. * Creates a new instance of @see GrainPostProcess
  52958. * @param name The name of the effect.
  52959. * @param options The required width/height ratio to downsize to before computing the render pass.
  52960. * @param camera The camera to apply the render pass to.
  52961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52962. * @param engine The engine which the post process will be applied. (default: current engine)
  52963. * @param reusable If the post process can be reused on the same frame. (default: false)
  52964. * @param textureType Type of textures used when performing the post process. (default: 0)
  52965. * @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)
  52966. */
  52967. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52968. }
  52969. }
  52970. declare module BABYLON {
  52971. /** @hidden */
  52972. export var highlightsPixelShader: {
  52973. name: string;
  52974. shader: string;
  52975. };
  52976. }
  52977. declare module BABYLON {
  52978. /**
  52979. * Extracts highlights from the image
  52980. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52981. */
  52982. export class HighlightsPostProcess extends PostProcess {
  52983. /**
  52984. * Extracts highlights from the image
  52985. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52986. * @param name The name of the effect.
  52987. * @param options The required width/height ratio to downsize to before computing the render pass.
  52988. * @param camera The camera to apply the render pass to.
  52989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52990. * @param engine The engine which the post process will be applied. (default: current engine)
  52991. * @param reusable If the post process can be reused on the same frame. (default: false)
  52992. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52993. */
  52994. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52995. }
  52996. }
  52997. declare module BABYLON {
  52998. /** @hidden */
  52999. export var mrtFragmentDeclaration: {
  53000. name: string;
  53001. shader: string;
  53002. };
  53003. }
  53004. declare module BABYLON {
  53005. /** @hidden */
  53006. export var geometryPixelShader: {
  53007. name: string;
  53008. shader: string;
  53009. };
  53010. }
  53011. declare module BABYLON {
  53012. /** @hidden */
  53013. export var geometryVertexShader: {
  53014. name: string;
  53015. shader: string;
  53016. };
  53017. }
  53018. declare module BABYLON {
  53019. /**
  53020. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53021. */
  53022. export class GeometryBufferRenderer {
  53023. /**
  53024. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53025. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53026. */
  53027. static readonly POSITION_TEXTURE_TYPE: number;
  53028. /**
  53029. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53030. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53031. */
  53032. static readonly VELOCITY_TEXTURE_TYPE: number;
  53033. /**
  53034. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53035. * in order to compute objects velocities when enableVelocity is set to "true"
  53036. * @hidden
  53037. */
  53038. _previousTransformationMatrices: {
  53039. [index: number]: Matrix;
  53040. };
  53041. private _scene;
  53042. private _multiRenderTarget;
  53043. private _ratio;
  53044. private _enablePosition;
  53045. private _enableVelocity;
  53046. private _positionIndex;
  53047. private _velocityIndex;
  53048. protected _effect: Effect;
  53049. protected _cachedDefines: string;
  53050. /**
  53051. * Set the render list (meshes to be rendered) used in the G buffer.
  53052. */
  53053. renderList: Mesh[];
  53054. /**
  53055. * Gets wether or not G buffer are supported by the running hardware.
  53056. * This requires draw buffer supports
  53057. */
  53058. readonly isSupported: boolean;
  53059. /**
  53060. * Returns the index of the given texture type in the G-Buffer textures array
  53061. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53062. * @returns the index of the given texture type in the G-Buffer textures array
  53063. */
  53064. getTextureIndex(textureType: number): number;
  53065. /**
  53066. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53067. */
  53068. /**
  53069. * Sets whether or not objects positions are enabled for the G buffer.
  53070. */
  53071. enablePosition: boolean;
  53072. /**
  53073. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53074. */
  53075. /**
  53076. * Sets wether or not objects velocities are enabled for the G buffer.
  53077. */
  53078. enableVelocity: boolean;
  53079. /**
  53080. * Gets the scene associated with the buffer.
  53081. */
  53082. readonly scene: Scene;
  53083. /**
  53084. * Gets the ratio used by the buffer during its creation.
  53085. * How big is the buffer related to the main canvas.
  53086. */
  53087. readonly ratio: number;
  53088. /** @hidden */
  53089. static _SceneComponentInitialization: (scene: Scene) => void;
  53090. /**
  53091. * Creates a new G Buffer for the scene
  53092. * @param scene The scene the buffer belongs to
  53093. * @param ratio How big is the buffer related to the main canvas.
  53094. */
  53095. constructor(scene: Scene, ratio?: number);
  53096. /**
  53097. * Checks wether everything is ready to render a submesh to the G buffer.
  53098. * @param subMesh the submesh to check readiness for
  53099. * @param useInstances is the mesh drawn using instance or not
  53100. * @returns true if ready otherwise false
  53101. */
  53102. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53103. /**
  53104. * Gets the current underlying G Buffer.
  53105. * @returns the buffer
  53106. */
  53107. getGBuffer(): MultiRenderTarget;
  53108. /**
  53109. * Gets the number of samples used to render the buffer (anti aliasing).
  53110. */
  53111. /**
  53112. * Sets the number of samples used to render the buffer (anti aliasing).
  53113. */
  53114. samples: number;
  53115. /**
  53116. * Disposes the renderer and frees up associated resources.
  53117. */
  53118. dispose(): void;
  53119. protected _createRenderTargets(): void;
  53120. }
  53121. }
  53122. declare module BABYLON {
  53123. interface Scene {
  53124. /** @hidden (Backing field) */
  53125. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53126. /**
  53127. * Gets or Sets the current geometry buffer associated to the scene.
  53128. */
  53129. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53130. /**
  53131. * Enables a GeometryBufferRender and associates it with the scene
  53132. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53133. * @returns the GeometryBufferRenderer
  53134. */
  53135. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53136. /**
  53137. * Disables the GeometryBufferRender associated with the scene
  53138. */
  53139. disableGeometryBufferRenderer(): void;
  53140. }
  53141. /**
  53142. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53143. * in several rendering techniques.
  53144. */
  53145. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53146. /**
  53147. * The component name helpful to identify the component in the list of scene components.
  53148. */
  53149. readonly name: string;
  53150. /**
  53151. * The scene the component belongs to.
  53152. */
  53153. scene: Scene;
  53154. /**
  53155. * Creates a new instance of the component for the given scene
  53156. * @param scene Defines the scene to register the component in
  53157. */
  53158. constructor(scene: Scene);
  53159. /**
  53160. * Registers the component in a given scene
  53161. */
  53162. register(): void;
  53163. /**
  53164. * Rebuilds the elements related to this component in case of
  53165. * context lost for instance.
  53166. */
  53167. rebuild(): void;
  53168. /**
  53169. * Disposes the component and the associated ressources
  53170. */
  53171. dispose(): void;
  53172. private _gatherRenderTargets;
  53173. }
  53174. }
  53175. declare module BABYLON {
  53176. /** @hidden */
  53177. export var motionBlurPixelShader: {
  53178. name: string;
  53179. shader: string;
  53180. };
  53181. }
  53182. declare module BABYLON {
  53183. /**
  53184. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53185. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53186. * As an example, all you have to do is to create the post-process:
  53187. * var mb = new BABYLON.MotionBlurPostProcess(
  53188. * 'mb', // The name of the effect.
  53189. * scene, // The scene containing the objects to blur according to their velocity.
  53190. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53191. * camera // The camera to apply the render pass to.
  53192. * );
  53193. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53194. */
  53195. export class MotionBlurPostProcess extends PostProcess {
  53196. /**
  53197. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53198. */
  53199. motionStrength: number;
  53200. /**
  53201. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53202. */
  53203. /**
  53204. * Sets the number of iterations to be used for motion blur quality
  53205. */
  53206. motionBlurSamples: number;
  53207. private _motionBlurSamples;
  53208. private _geometryBufferRenderer;
  53209. /**
  53210. * Creates a new instance MotionBlurPostProcess
  53211. * @param name The name of the effect.
  53212. * @param scene The scene containing the objects to blur according to their velocity.
  53213. * @param options The required width/height ratio to downsize to before computing the render pass.
  53214. * @param camera The camera to apply the render pass to.
  53215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53216. * @param engine The engine which the post process will be applied. (default: current engine)
  53217. * @param reusable If the post process can be reused on the same frame. (default: false)
  53218. * @param textureType Type of textures used when performing the post process. (default: 0)
  53219. * @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)
  53220. */
  53221. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53222. /**
  53223. * Disposes the post process.
  53224. * @param camera The camera to dispose the post process on.
  53225. */
  53226. dispose(camera?: Camera): void;
  53227. }
  53228. }
  53229. declare module BABYLON {
  53230. /** @hidden */
  53231. export var refractionPixelShader: {
  53232. name: string;
  53233. shader: string;
  53234. };
  53235. }
  53236. declare module BABYLON {
  53237. /**
  53238. * Post process which applies a refractin texture
  53239. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53240. */
  53241. export class RefractionPostProcess extends PostProcess {
  53242. /** the base color of the refraction (used to taint the rendering) */
  53243. color: Color3;
  53244. /** simulated refraction depth */
  53245. depth: number;
  53246. /** the coefficient of the base color (0 to remove base color tainting) */
  53247. colorLevel: number;
  53248. private _refTexture;
  53249. private _ownRefractionTexture;
  53250. /**
  53251. * Gets or sets the refraction texture
  53252. * Please note that you are responsible for disposing the texture if you set it manually
  53253. */
  53254. refractionTexture: Texture;
  53255. /**
  53256. * Initializes the RefractionPostProcess
  53257. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53258. * @param name The name of the effect.
  53259. * @param refractionTextureUrl Url of the refraction texture to use
  53260. * @param color the base color of the refraction (used to taint the rendering)
  53261. * @param depth simulated refraction depth
  53262. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53263. * @param camera The camera to apply the render pass to.
  53264. * @param options The required width/height ratio to downsize to before computing the render pass.
  53265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53266. * @param engine The engine which the post process will be applied. (default: current engine)
  53267. * @param reusable If the post process can be reused on the same frame. (default: false)
  53268. */
  53269. constructor(name: string, refractionTextureUrl: string,
  53270. /** the base color of the refraction (used to taint the rendering) */
  53271. color: Color3,
  53272. /** simulated refraction depth */
  53273. depth: number,
  53274. /** the coefficient of the base color (0 to remove base color tainting) */
  53275. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53276. /**
  53277. * Disposes of the post process
  53278. * @param camera Camera to dispose post process on
  53279. */
  53280. dispose(camera: Camera): void;
  53281. }
  53282. }
  53283. declare module BABYLON {
  53284. /** @hidden */
  53285. export var sharpenPixelShader: {
  53286. name: string;
  53287. shader: string;
  53288. };
  53289. }
  53290. declare module BABYLON {
  53291. /**
  53292. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53293. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53294. */
  53295. export class SharpenPostProcess extends PostProcess {
  53296. /**
  53297. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53298. */
  53299. colorAmount: number;
  53300. /**
  53301. * How much sharpness should be applied (default: 0.3)
  53302. */
  53303. edgeAmount: number;
  53304. /**
  53305. * Creates a new instance ConvolutionPostProcess
  53306. * @param name The name of the effect.
  53307. * @param options The required width/height ratio to downsize to before computing the render pass.
  53308. * @param camera The camera to apply the render pass to.
  53309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53310. * @param engine The engine which the post process will be applied. (default: current engine)
  53311. * @param reusable If the post process can be reused on the same frame. (default: false)
  53312. * @param textureType Type of textures used when performing the post process. (default: 0)
  53313. * @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)
  53314. */
  53315. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53316. }
  53317. }
  53318. declare module BABYLON {
  53319. /**
  53320. * PostProcessRenderPipeline
  53321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53322. */
  53323. export class PostProcessRenderPipeline {
  53324. private engine;
  53325. private _renderEffects;
  53326. private _renderEffectsForIsolatedPass;
  53327. /**
  53328. * List of inspectable custom properties (used by the Inspector)
  53329. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  53330. */
  53331. inspectableCustomProperties: IInspectable[];
  53332. /**
  53333. * @hidden
  53334. */
  53335. protected _cameras: Camera[];
  53336. /** @hidden */
  53337. _name: string;
  53338. /**
  53339. * Gets pipeline name
  53340. */
  53341. readonly name: string;
  53342. /**
  53343. * Initializes a PostProcessRenderPipeline
  53344. * @param engine engine to add the pipeline to
  53345. * @param name name of the pipeline
  53346. */
  53347. constructor(engine: Engine, name: string);
  53348. /**
  53349. * Gets the class name
  53350. * @returns "PostProcessRenderPipeline"
  53351. */
  53352. getClassName(): string;
  53353. /**
  53354. * If all the render effects in the pipeline are supported
  53355. */
  53356. readonly isSupported: boolean;
  53357. /**
  53358. * Adds an effect to the pipeline
  53359. * @param renderEffect the effect to add
  53360. */
  53361. addEffect(renderEffect: PostProcessRenderEffect): void;
  53362. /** @hidden */
  53363. _rebuild(): void;
  53364. /** @hidden */
  53365. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53366. /** @hidden */
  53367. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53368. /** @hidden */
  53369. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53370. /** @hidden */
  53371. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53372. /** @hidden */
  53373. _attachCameras(cameras: Camera, unique: boolean): void;
  53374. /** @hidden */
  53375. _attachCameras(cameras: Camera[], unique: boolean): void;
  53376. /** @hidden */
  53377. _detachCameras(cameras: Camera): void;
  53378. /** @hidden */
  53379. _detachCameras(cameras: Nullable<Camera[]>): void;
  53380. /** @hidden */
  53381. _update(): void;
  53382. /** @hidden */
  53383. _reset(): void;
  53384. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53385. /**
  53386. * Disposes of the pipeline
  53387. */
  53388. dispose(): void;
  53389. }
  53390. }
  53391. declare module BABYLON {
  53392. /**
  53393. * PostProcessRenderPipelineManager class
  53394. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53395. */
  53396. export class PostProcessRenderPipelineManager {
  53397. private _renderPipelines;
  53398. /**
  53399. * Initializes a PostProcessRenderPipelineManager
  53400. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53401. */
  53402. constructor();
  53403. /**
  53404. * Gets the list of supported render pipelines
  53405. */
  53406. readonly supportedPipelines: PostProcessRenderPipeline[];
  53407. /**
  53408. * Adds a pipeline to the manager
  53409. * @param renderPipeline The pipeline to add
  53410. */
  53411. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53412. /**
  53413. * Attaches a camera to the pipeline
  53414. * @param renderPipelineName The name of the pipeline to attach to
  53415. * @param cameras the camera to attach
  53416. * @param unique if the camera can be attached multiple times to the pipeline
  53417. */
  53418. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53419. /**
  53420. * Detaches a camera from the pipeline
  53421. * @param renderPipelineName The name of the pipeline to detach from
  53422. * @param cameras the camera to detach
  53423. */
  53424. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53425. /**
  53426. * Enables an effect by name on a pipeline
  53427. * @param renderPipelineName the name of the pipeline to enable the effect in
  53428. * @param renderEffectName the name of the effect to enable
  53429. * @param cameras the cameras that the effect should be enabled on
  53430. */
  53431. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53432. /**
  53433. * Disables an effect by name on a pipeline
  53434. * @param renderPipelineName the name of the pipeline to disable the effect in
  53435. * @param renderEffectName the name of the effect to disable
  53436. * @param cameras the cameras that the effect should be disabled on
  53437. */
  53438. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53439. /**
  53440. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53441. */
  53442. update(): void;
  53443. /** @hidden */
  53444. _rebuild(): void;
  53445. /**
  53446. * Disposes of the manager and pipelines
  53447. */
  53448. dispose(): void;
  53449. }
  53450. }
  53451. declare module BABYLON {
  53452. interface Scene {
  53453. /** @hidden (Backing field) */
  53454. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53455. /**
  53456. * Gets the postprocess render pipeline manager
  53457. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53458. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53459. */
  53460. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53461. }
  53462. /**
  53463. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53464. */
  53465. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53466. /**
  53467. * The component name helpfull to identify the component in the list of scene components.
  53468. */
  53469. readonly name: string;
  53470. /**
  53471. * The scene the component belongs to.
  53472. */
  53473. scene: Scene;
  53474. /**
  53475. * Creates a new instance of the component for the given scene
  53476. * @param scene Defines the scene to register the component in
  53477. */
  53478. constructor(scene: Scene);
  53479. /**
  53480. * Registers the component in a given scene
  53481. */
  53482. register(): void;
  53483. /**
  53484. * Rebuilds the elements related to this component in case of
  53485. * context lost for instance.
  53486. */
  53487. rebuild(): void;
  53488. /**
  53489. * Disposes the component and the associated ressources
  53490. */
  53491. dispose(): void;
  53492. private _gatherRenderTargets;
  53493. }
  53494. }
  53495. declare module BABYLON {
  53496. /**
  53497. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53498. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53499. */
  53500. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53501. private _scene;
  53502. private _camerasToBeAttached;
  53503. /**
  53504. * ID of the sharpen post process,
  53505. */
  53506. private readonly SharpenPostProcessId;
  53507. /**
  53508. * @ignore
  53509. * ID of the image processing post process;
  53510. */
  53511. readonly ImageProcessingPostProcessId: string;
  53512. /**
  53513. * @ignore
  53514. * ID of the Fast Approximate Anti-Aliasing post process;
  53515. */
  53516. readonly FxaaPostProcessId: string;
  53517. /**
  53518. * ID of the chromatic aberration post process,
  53519. */
  53520. private readonly ChromaticAberrationPostProcessId;
  53521. /**
  53522. * ID of the grain post process
  53523. */
  53524. private readonly GrainPostProcessId;
  53525. /**
  53526. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53527. */
  53528. sharpen: SharpenPostProcess;
  53529. private _sharpenEffect;
  53530. private bloom;
  53531. /**
  53532. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53533. */
  53534. depthOfField: DepthOfFieldEffect;
  53535. /**
  53536. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53537. */
  53538. fxaa: FxaaPostProcess;
  53539. /**
  53540. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53541. */
  53542. imageProcessing: ImageProcessingPostProcess;
  53543. /**
  53544. * Chromatic aberration post process which will shift rgb colors in the image
  53545. */
  53546. chromaticAberration: ChromaticAberrationPostProcess;
  53547. private _chromaticAberrationEffect;
  53548. /**
  53549. * Grain post process which add noise to the image
  53550. */
  53551. grain: GrainPostProcess;
  53552. private _grainEffect;
  53553. /**
  53554. * Glow post process which adds a glow to emissive areas of the image
  53555. */
  53556. private _glowLayer;
  53557. /**
  53558. * Animations which can be used to tweak settings over a period of time
  53559. */
  53560. animations: Animation[];
  53561. private _imageProcessingConfigurationObserver;
  53562. private _sharpenEnabled;
  53563. private _bloomEnabled;
  53564. private _depthOfFieldEnabled;
  53565. private _depthOfFieldBlurLevel;
  53566. private _fxaaEnabled;
  53567. private _imageProcessingEnabled;
  53568. private _defaultPipelineTextureType;
  53569. private _bloomScale;
  53570. private _chromaticAberrationEnabled;
  53571. private _grainEnabled;
  53572. private _buildAllowed;
  53573. /**
  53574. * Gets active scene
  53575. */
  53576. readonly scene: Scene;
  53577. /**
  53578. * Enable or disable the sharpen process from the pipeline
  53579. */
  53580. sharpenEnabled: boolean;
  53581. private _resizeObserver;
  53582. private _hardwareScaleLevel;
  53583. private _bloomKernel;
  53584. /**
  53585. * Specifies the size of the bloom blur kernel, relative to the final output size
  53586. */
  53587. bloomKernel: number;
  53588. /**
  53589. * Specifies the weight of the bloom in the final rendering
  53590. */
  53591. private _bloomWeight;
  53592. /**
  53593. * Specifies the luma threshold for the area that will be blurred by the bloom
  53594. */
  53595. private _bloomThreshold;
  53596. private _hdr;
  53597. /**
  53598. * The strength of the bloom.
  53599. */
  53600. bloomWeight: number;
  53601. /**
  53602. * The strength of the bloom.
  53603. */
  53604. bloomThreshold: number;
  53605. /**
  53606. * The scale of the bloom, lower value will provide better performance.
  53607. */
  53608. bloomScale: number;
  53609. /**
  53610. * Enable or disable the bloom from the pipeline
  53611. */
  53612. bloomEnabled: boolean;
  53613. private _rebuildBloom;
  53614. /**
  53615. * If the depth of field is enabled.
  53616. */
  53617. depthOfFieldEnabled: boolean;
  53618. /**
  53619. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53620. */
  53621. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53622. /**
  53623. * If the anti aliasing is enabled.
  53624. */
  53625. fxaaEnabled: boolean;
  53626. private _samples;
  53627. /**
  53628. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53629. */
  53630. samples: number;
  53631. /**
  53632. * If image processing is enabled.
  53633. */
  53634. imageProcessingEnabled: boolean;
  53635. /**
  53636. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53637. */
  53638. glowLayerEnabled: boolean;
  53639. /**
  53640. * Enable or disable the chromaticAberration process from the pipeline
  53641. */
  53642. chromaticAberrationEnabled: boolean;
  53643. /**
  53644. * Enable or disable the grain process from the pipeline
  53645. */
  53646. grainEnabled: boolean;
  53647. /**
  53648. * @constructor
  53649. * @param name - The rendering pipeline name (default: "")
  53650. * @param hdr - If high dynamic range textures should be used (default: true)
  53651. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53652. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53653. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53654. */
  53655. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53656. /**
  53657. * Get the class name
  53658. * @returns "DefaultRenderingPipeline"
  53659. */
  53660. getClassName(): string;
  53661. /**
  53662. * Force the compilation of the entire pipeline.
  53663. */
  53664. prepare(): void;
  53665. private _hasCleared;
  53666. private _prevPostProcess;
  53667. private _prevPrevPostProcess;
  53668. private _setAutoClearAndTextureSharing;
  53669. private _depthOfFieldSceneObserver;
  53670. private _buildPipeline;
  53671. private _disposePostProcesses;
  53672. /**
  53673. * Adds a camera to the pipeline
  53674. * @param camera the camera to be added
  53675. */
  53676. addCamera(camera: Camera): void;
  53677. /**
  53678. * Removes a camera from the pipeline
  53679. * @param camera the camera to remove
  53680. */
  53681. removeCamera(camera: Camera): void;
  53682. /**
  53683. * Dispose of the pipeline and stop all post processes
  53684. */
  53685. dispose(): void;
  53686. /**
  53687. * Serialize the rendering pipeline (Used when exporting)
  53688. * @returns the serialized object
  53689. */
  53690. serialize(): any;
  53691. /**
  53692. * Parse the serialized pipeline
  53693. * @param source Source pipeline.
  53694. * @param scene The scene to load the pipeline to.
  53695. * @param rootUrl The URL of the serialized pipeline.
  53696. * @returns An instantiated pipeline from the serialized object.
  53697. */
  53698. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53699. }
  53700. }
  53701. declare module BABYLON {
  53702. /** @hidden */
  53703. export var lensHighlightsPixelShader: {
  53704. name: string;
  53705. shader: string;
  53706. };
  53707. }
  53708. declare module BABYLON {
  53709. /** @hidden */
  53710. export var depthOfFieldPixelShader: {
  53711. name: string;
  53712. shader: string;
  53713. };
  53714. }
  53715. declare module BABYLON {
  53716. /**
  53717. * BABYLON.JS Chromatic Aberration GLSL Shader
  53718. * Author: Olivier Guyot
  53719. * Separates very slightly R, G and B colors on the edges of the screen
  53720. * Inspired by Francois Tarlier & Martins Upitis
  53721. */
  53722. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53723. /**
  53724. * @ignore
  53725. * The chromatic aberration PostProcess id in the pipeline
  53726. */
  53727. LensChromaticAberrationEffect: string;
  53728. /**
  53729. * @ignore
  53730. * The highlights enhancing PostProcess id in the pipeline
  53731. */
  53732. HighlightsEnhancingEffect: string;
  53733. /**
  53734. * @ignore
  53735. * The depth-of-field PostProcess id in the pipeline
  53736. */
  53737. LensDepthOfFieldEffect: string;
  53738. private _scene;
  53739. private _depthTexture;
  53740. private _grainTexture;
  53741. private _chromaticAberrationPostProcess;
  53742. private _highlightsPostProcess;
  53743. private _depthOfFieldPostProcess;
  53744. private _edgeBlur;
  53745. private _grainAmount;
  53746. private _chromaticAberration;
  53747. private _distortion;
  53748. private _highlightsGain;
  53749. private _highlightsThreshold;
  53750. private _dofDistance;
  53751. private _dofAperture;
  53752. private _dofDarken;
  53753. private _dofPentagon;
  53754. private _blurNoise;
  53755. /**
  53756. * @constructor
  53757. *
  53758. * Effect parameters are as follow:
  53759. * {
  53760. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53761. * edge_blur: number; // from 0 to x (1 for realism)
  53762. * distortion: number; // from 0 to x (1 for realism)
  53763. * grain_amount: number; // from 0 to 1
  53764. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53765. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53766. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53767. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53768. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53769. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53770. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53771. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53772. * }
  53773. * Note: if an effect parameter is unset, effect is disabled
  53774. *
  53775. * @param name The rendering pipeline name
  53776. * @param parameters - An object containing all parameters (see above)
  53777. * @param scene The scene linked to this pipeline
  53778. * @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)
  53779. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53780. */
  53781. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53782. /**
  53783. * Get the class name
  53784. * @returns "LensRenderingPipeline"
  53785. */
  53786. getClassName(): string;
  53787. /**
  53788. * Gets associated scene
  53789. */
  53790. readonly scene: Scene;
  53791. /**
  53792. * Gets or sets the edge blur
  53793. */
  53794. edgeBlur: number;
  53795. /**
  53796. * Gets or sets the grain amount
  53797. */
  53798. grainAmount: number;
  53799. /**
  53800. * Gets or sets the chromatic aberration amount
  53801. */
  53802. chromaticAberration: number;
  53803. /**
  53804. * Gets or sets the depth of field aperture
  53805. */
  53806. dofAperture: number;
  53807. /**
  53808. * Gets or sets the edge distortion
  53809. */
  53810. edgeDistortion: number;
  53811. /**
  53812. * Gets or sets the depth of field distortion
  53813. */
  53814. dofDistortion: number;
  53815. /**
  53816. * Gets or sets the darken out of focus amount
  53817. */
  53818. darkenOutOfFocus: number;
  53819. /**
  53820. * Gets or sets a boolean indicating if blur noise is enabled
  53821. */
  53822. blurNoise: boolean;
  53823. /**
  53824. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53825. */
  53826. pentagonBokeh: boolean;
  53827. /**
  53828. * Gets or sets the highlight grain amount
  53829. */
  53830. highlightsGain: number;
  53831. /**
  53832. * Gets or sets the highlight threshold
  53833. */
  53834. highlightsThreshold: number;
  53835. /**
  53836. * Sets the amount of blur at the edges
  53837. * @param amount blur amount
  53838. */
  53839. setEdgeBlur(amount: number): void;
  53840. /**
  53841. * Sets edge blur to 0
  53842. */
  53843. disableEdgeBlur(): void;
  53844. /**
  53845. * Sets the amout of grain
  53846. * @param amount Amount of grain
  53847. */
  53848. setGrainAmount(amount: number): void;
  53849. /**
  53850. * Set grain amount to 0
  53851. */
  53852. disableGrain(): void;
  53853. /**
  53854. * Sets the chromatic aberration amount
  53855. * @param amount amount of chromatic aberration
  53856. */
  53857. setChromaticAberration(amount: number): void;
  53858. /**
  53859. * Sets chromatic aberration amount to 0
  53860. */
  53861. disableChromaticAberration(): void;
  53862. /**
  53863. * Sets the EdgeDistortion amount
  53864. * @param amount amount of EdgeDistortion
  53865. */
  53866. setEdgeDistortion(amount: number): void;
  53867. /**
  53868. * Sets edge distortion to 0
  53869. */
  53870. disableEdgeDistortion(): void;
  53871. /**
  53872. * Sets the FocusDistance amount
  53873. * @param amount amount of FocusDistance
  53874. */
  53875. setFocusDistance(amount: number): void;
  53876. /**
  53877. * Disables depth of field
  53878. */
  53879. disableDepthOfField(): void;
  53880. /**
  53881. * Sets the Aperture amount
  53882. * @param amount amount of Aperture
  53883. */
  53884. setAperture(amount: number): void;
  53885. /**
  53886. * Sets the DarkenOutOfFocus amount
  53887. * @param amount amount of DarkenOutOfFocus
  53888. */
  53889. setDarkenOutOfFocus(amount: number): void;
  53890. private _pentagonBokehIsEnabled;
  53891. /**
  53892. * Creates a pentagon bokeh effect
  53893. */
  53894. enablePentagonBokeh(): void;
  53895. /**
  53896. * Disables the pentagon bokeh effect
  53897. */
  53898. disablePentagonBokeh(): void;
  53899. /**
  53900. * Enables noise blur
  53901. */
  53902. enableNoiseBlur(): void;
  53903. /**
  53904. * Disables noise blur
  53905. */
  53906. disableNoiseBlur(): void;
  53907. /**
  53908. * Sets the HighlightsGain amount
  53909. * @param amount amount of HighlightsGain
  53910. */
  53911. setHighlightsGain(amount: number): void;
  53912. /**
  53913. * Sets the HighlightsThreshold amount
  53914. * @param amount amount of HighlightsThreshold
  53915. */
  53916. setHighlightsThreshold(amount: number): void;
  53917. /**
  53918. * Disables highlights
  53919. */
  53920. disableHighlights(): void;
  53921. /**
  53922. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53923. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53924. */
  53925. dispose(disableDepthRender?: boolean): void;
  53926. private _createChromaticAberrationPostProcess;
  53927. private _createHighlightsPostProcess;
  53928. private _createDepthOfFieldPostProcess;
  53929. private _createGrainTexture;
  53930. }
  53931. }
  53932. declare module BABYLON {
  53933. /** @hidden */
  53934. export var ssao2PixelShader: {
  53935. name: string;
  53936. shader: string;
  53937. };
  53938. }
  53939. declare module BABYLON {
  53940. /** @hidden */
  53941. export var ssaoCombinePixelShader: {
  53942. name: string;
  53943. shader: string;
  53944. };
  53945. }
  53946. declare module BABYLON {
  53947. /**
  53948. * Render pipeline to produce ssao effect
  53949. */
  53950. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53951. /**
  53952. * @ignore
  53953. * The PassPostProcess id in the pipeline that contains the original scene color
  53954. */
  53955. SSAOOriginalSceneColorEffect: string;
  53956. /**
  53957. * @ignore
  53958. * The SSAO PostProcess id in the pipeline
  53959. */
  53960. SSAORenderEffect: string;
  53961. /**
  53962. * @ignore
  53963. * The horizontal blur PostProcess id in the pipeline
  53964. */
  53965. SSAOBlurHRenderEffect: string;
  53966. /**
  53967. * @ignore
  53968. * The vertical blur PostProcess id in the pipeline
  53969. */
  53970. SSAOBlurVRenderEffect: string;
  53971. /**
  53972. * @ignore
  53973. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53974. */
  53975. SSAOCombineRenderEffect: string;
  53976. /**
  53977. * The output strength of the SSAO post-process. Default value is 1.0.
  53978. */
  53979. totalStrength: number;
  53980. /**
  53981. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53982. */
  53983. maxZ: number;
  53984. /**
  53985. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53986. */
  53987. minZAspect: number;
  53988. private _samples;
  53989. /**
  53990. * Number of samples used for the SSAO calculations. Default value is 8
  53991. */
  53992. samples: number;
  53993. private _textureSamples;
  53994. /**
  53995. * Number of samples to use for antialiasing
  53996. */
  53997. textureSamples: number;
  53998. /**
  53999. * Ratio object used for SSAO ratio and blur ratio
  54000. */
  54001. private _ratio;
  54002. /**
  54003. * Dynamically generated sphere sampler.
  54004. */
  54005. private _sampleSphere;
  54006. /**
  54007. * Blur filter offsets
  54008. */
  54009. private _samplerOffsets;
  54010. private _expensiveBlur;
  54011. /**
  54012. * If bilateral blur should be used
  54013. */
  54014. expensiveBlur: boolean;
  54015. /**
  54016. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54017. */
  54018. radius: number;
  54019. /**
  54020. * The base color of the SSAO post-process
  54021. * The final result is "base + ssao" between [0, 1]
  54022. */
  54023. base: number;
  54024. /**
  54025. * Support test.
  54026. */
  54027. static readonly IsSupported: boolean;
  54028. private _scene;
  54029. private _depthTexture;
  54030. private _normalTexture;
  54031. private _randomTexture;
  54032. private _originalColorPostProcess;
  54033. private _ssaoPostProcess;
  54034. private _blurHPostProcess;
  54035. private _blurVPostProcess;
  54036. private _ssaoCombinePostProcess;
  54037. private _firstUpdate;
  54038. /**
  54039. * Gets active scene
  54040. */
  54041. readonly scene: Scene;
  54042. /**
  54043. * @constructor
  54044. * @param name The rendering pipeline name
  54045. * @param scene The scene linked to this pipeline
  54046. * @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 }
  54047. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54048. */
  54049. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54050. /**
  54051. * Get the class name
  54052. * @returns "SSAO2RenderingPipeline"
  54053. */
  54054. getClassName(): string;
  54055. /**
  54056. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54057. */
  54058. dispose(disableGeometryBufferRenderer?: boolean): void;
  54059. private _createBlurPostProcess;
  54060. /** @hidden */
  54061. _rebuild(): void;
  54062. private _bits;
  54063. private _radicalInverse_VdC;
  54064. private _hammersley;
  54065. private _hemisphereSample_uniform;
  54066. private _generateHemisphere;
  54067. private _createSSAOPostProcess;
  54068. private _createSSAOCombinePostProcess;
  54069. private _createRandomTexture;
  54070. /**
  54071. * Serialize the rendering pipeline (Used when exporting)
  54072. * @returns the serialized object
  54073. */
  54074. serialize(): any;
  54075. /**
  54076. * Parse the serialized pipeline
  54077. * @param source Source pipeline.
  54078. * @param scene The scene to load the pipeline to.
  54079. * @param rootUrl The URL of the serialized pipeline.
  54080. * @returns An instantiated pipeline from the serialized object.
  54081. */
  54082. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54083. }
  54084. }
  54085. declare module BABYLON {
  54086. /** @hidden */
  54087. export var ssaoPixelShader: {
  54088. name: string;
  54089. shader: string;
  54090. };
  54091. }
  54092. declare module BABYLON {
  54093. /**
  54094. * Render pipeline to produce ssao effect
  54095. */
  54096. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54097. /**
  54098. * @ignore
  54099. * The PassPostProcess id in the pipeline that contains the original scene color
  54100. */
  54101. SSAOOriginalSceneColorEffect: string;
  54102. /**
  54103. * @ignore
  54104. * The SSAO PostProcess id in the pipeline
  54105. */
  54106. SSAORenderEffect: string;
  54107. /**
  54108. * @ignore
  54109. * The horizontal blur PostProcess id in the pipeline
  54110. */
  54111. SSAOBlurHRenderEffect: string;
  54112. /**
  54113. * @ignore
  54114. * The vertical blur PostProcess id in the pipeline
  54115. */
  54116. SSAOBlurVRenderEffect: string;
  54117. /**
  54118. * @ignore
  54119. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54120. */
  54121. SSAOCombineRenderEffect: string;
  54122. /**
  54123. * The output strength of the SSAO post-process. Default value is 1.0.
  54124. */
  54125. totalStrength: number;
  54126. /**
  54127. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54128. */
  54129. radius: number;
  54130. /**
  54131. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54132. * Must not be equal to fallOff and superior to fallOff.
  54133. * Default value is 0.0075
  54134. */
  54135. area: number;
  54136. /**
  54137. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54138. * Must not be equal to area and inferior to area.
  54139. * Default value is 0.000001
  54140. */
  54141. fallOff: number;
  54142. /**
  54143. * The base color of the SSAO post-process
  54144. * The final result is "base + ssao" between [0, 1]
  54145. */
  54146. base: number;
  54147. private _scene;
  54148. private _depthTexture;
  54149. private _randomTexture;
  54150. private _originalColorPostProcess;
  54151. private _ssaoPostProcess;
  54152. private _blurHPostProcess;
  54153. private _blurVPostProcess;
  54154. private _ssaoCombinePostProcess;
  54155. private _firstUpdate;
  54156. /**
  54157. * Gets active scene
  54158. */
  54159. readonly scene: Scene;
  54160. /**
  54161. * @constructor
  54162. * @param name - The rendering pipeline name
  54163. * @param scene - The scene linked to this pipeline
  54164. * @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 }
  54165. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54166. */
  54167. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54168. /**
  54169. * Get the class name
  54170. * @returns "SSAORenderingPipeline"
  54171. */
  54172. getClassName(): string;
  54173. /**
  54174. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54175. */
  54176. dispose(disableDepthRender?: boolean): void;
  54177. private _createBlurPostProcess;
  54178. /** @hidden */
  54179. _rebuild(): void;
  54180. private _createSSAOPostProcess;
  54181. private _createSSAOCombinePostProcess;
  54182. private _createRandomTexture;
  54183. }
  54184. }
  54185. declare module BABYLON {
  54186. /** @hidden */
  54187. export var standardPixelShader: {
  54188. name: string;
  54189. shader: string;
  54190. };
  54191. }
  54192. declare module BABYLON {
  54193. /**
  54194. * Standard rendering pipeline
  54195. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54196. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54197. */
  54198. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54199. /**
  54200. * Public members
  54201. */
  54202. /**
  54203. * Post-process which contains the original scene color before the pipeline applies all the effects
  54204. */
  54205. originalPostProcess: Nullable<PostProcess>;
  54206. /**
  54207. * Post-process used to down scale an image x4
  54208. */
  54209. downSampleX4PostProcess: Nullable<PostProcess>;
  54210. /**
  54211. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54212. */
  54213. brightPassPostProcess: Nullable<PostProcess>;
  54214. /**
  54215. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54216. */
  54217. blurHPostProcesses: PostProcess[];
  54218. /**
  54219. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54220. */
  54221. blurVPostProcesses: PostProcess[];
  54222. /**
  54223. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54224. */
  54225. textureAdderPostProcess: Nullable<PostProcess>;
  54226. /**
  54227. * Post-process used to create volumetric lighting effect
  54228. */
  54229. volumetricLightPostProcess: Nullable<PostProcess>;
  54230. /**
  54231. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54232. */
  54233. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54234. /**
  54235. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54236. */
  54237. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54238. /**
  54239. * Post-process used to merge the volumetric light effect and the real scene color
  54240. */
  54241. volumetricLightMergePostProces: Nullable<PostProcess>;
  54242. /**
  54243. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54244. */
  54245. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54246. /**
  54247. * Base post-process used to calculate the average luminance of the final image for HDR
  54248. */
  54249. luminancePostProcess: Nullable<PostProcess>;
  54250. /**
  54251. * Post-processes used to create down sample post-processes in order to get
  54252. * the average luminance of the final image for HDR
  54253. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54254. */
  54255. luminanceDownSamplePostProcesses: PostProcess[];
  54256. /**
  54257. * Post-process used to create a HDR effect (light adaptation)
  54258. */
  54259. hdrPostProcess: Nullable<PostProcess>;
  54260. /**
  54261. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54262. */
  54263. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54264. /**
  54265. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54266. */
  54267. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54268. /**
  54269. * Post-process used to merge the final HDR post-process and the real scene color
  54270. */
  54271. hdrFinalPostProcess: Nullable<PostProcess>;
  54272. /**
  54273. * Post-process used to create a lens flare effect
  54274. */
  54275. lensFlarePostProcess: Nullable<PostProcess>;
  54276. /**
  54277. * Post-process that merges the result of the lens flare post-process and the real scene color
  54278. */
  54279. lensFlareComposePostProcess: Nullable<PostProcess>;
  54280. /**
  54281. * Post-process used to create a motion blur effect
  54282. */
  54283. motionBlurPostProcess: Nullable<PostProcess>;
  54284. /**
  54285. * Post-process used to create a depth of field effect
  54286. */
  54287. depthOfFieldPostProcess: Nullable<PostProcess>;
  54288. /**
  54289. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54290. */
  54291. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54292. /**
  54293. * Represents the brightness threshold in order to configure the illuminated surfaces
  54294. */
  54295. brightThreshold: number;
  54296. /**
  54297. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54298. */
  54299. blurWidth: number;
  54300. /**
  54301. * Sets if the blur for highlighted surfaces must be only horizontal
  54302. */
  54303. horizontalBlur: boolean;
  54304. /**
  54305. * Gets the overall exposure used by the pipeline
  54306. */
  54307. /**
  54308. * Sets the overall exposure used by the pipeline
  54309. */
  54310. exposure: number;
  54311. /**
  54312. * Texture used typically to simulate "dirty" on camera lens
  54313. */
  54314. lensTexture: Nullable<Texture>;
  54315. /**
  54316. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54317. */
  54318. volumetricLightCoefficient: number;
  54319. /**
  54320. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54321. */
  54322. volumetricLightPower: number;
  54323. /**
  54324. * Used the set the blur intensity to smooth the volumetric lights
  54325. */
  54326. volumetricLightBlurScale: number;
  54327. /**
  54328. * Light (spot or directional) used to generate the volumetric lights rays
  54329. * The source light must have a shadow generate so the pipeline can get its
  54330. * depth map
  54331. */
  54332. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54333. /**
  54334. * For eye adaptation, represents the minimum luminance the eye can see
  54335. */
  54336. hdrMinimumLuminance: number;
  54337. /**
  54338. * For eye adaptation, represents the decrease luminance speed
  54339. */
  54340. hdrDecreaseRate: number;
  54341. /**
  54342. * For eye adaptation, represents the increase luminance speed
  54343. */
  54344. hdrIncreaseRate: number;
  54345. /**
  54346. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54347. */
  54348. /**
  54349. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54350. */
  54351. hdrAutoExposure: boolean;
  54352. /**
  54353. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54354. */
  54355. lensColorTexture: Nullable<Texture>;
  54356. /**
  54357. * The overall strengh for the lens flare effect
  54358. */
  54359. lensFlareStrength: number;
  54360. /**
  54361. * Dispersion coefficient for lens flare ghosts
  54362. */
  54363. lensFlareGhostDispersal: number;
  54364. /**
  54365. * Main lens flare halo width
  54366. */
  54367. lensFlareHaloWidth: number;
  54368. /**
  54369. * Based on the lens distortion effect, defines how much the lens flare result
  54370. * is distorted
  54371. */
  54372. lensFlareDistortionStrength: number;
  54373. /**
  54374. * Lens star texture must be used to simulate rays on the flares and is available
  54375. * in the documentation
  54376. */
  54377. lensStarTexture: Nullable<Texture>;
  54378. /**
  54379. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54380. * flare effect by taking account of the dirt texture
  54381. */
  54382. lensFlareDirtTexture: Nullable<Texture>;
  54383. /**
  54384. * Represents the focal length for the depth of field effect
  54385. */
  54386. depthOfFieldDistance: number;
  54387. /**
  54388. * Represents the blur intensity for the blurred part of the depth of field effect
  54389. */
  54390. depthOfFieldBlurWidth: number;
  54391. /**
  54392. * For motion blur, defines how much the image is blurred by the movement
  54393. */
  54394. motionStrength: number;
  54395. /**
  54396. * List of animations for the pipeline (IAnimatable implementation)
  54397. */
  54398. animations: Animation[];
  54399. /**
  54400. * Private members
  54401. */
  54402. private _scene;
  54403. private _currentDepthOfFieldSource;
  54404. private _basePostProcess;
  54405. private _fixedExposure;
  54406. private _currentExposure;
  54407. private _hdrAutoExposure;
  54408. private _hdrCurrentLuminance;
  54409. private _floatTextureType;
  54410. private _ratio;
  54411. private _bloomEnabled;
  54412. private _depthOfFieldEnabled;
  54413. private _vlsEnabled;
  54414. private _lensFlareEnabled;
  54415. private _hdrEnabled;
  54416. private _motionBlurEnabled;
  54417. private _fxaaEnabled;
  54418. private _motionBlurSamples;
  54419. private _volumetricLightStepsCount;
  54420. private _samples;
  54421. /**
  54422. * @ignore
  54423. * Specifies if the bloom pipeline is enabled
  54424. */
  54425. BloomEnabled: boolean;
  54426. /**
  54427. * @ignore
  54428. * Specifies if the depth of field pipeline is enabed
  54429. */
  54430. DepthOfFieldEnabled: boolean;
  54431. /**
  54432. * @ignore
  54433. * Specifies if the lens flare pipeline is enabed
  54434. */
  54435. LensFlareEnabled: boolean;
  54436. /**
  54437. * @ignore
  54438. * Specifies if the HDR pipeline is enabled
  54439. */
  54440. HDREnabled: boolean;
  54441. /**
  54442. * @ignore
  54443. * Specifies if the volumetric lights scattering effect is enabled
  54444. */
  54445. VLSEnabled: boolean;
  54446. /**
  54447. * @ignore
  54448. * Specifies if the motion blur effect is enabled
  54449. */
  54450. MotionBlurEnabled: boolean;
  54451. /**
  54452. * Specifies if anti-aliasing is enabled
  54453. */
  54454. fxaaEnabled: boolean;
  54455. /**
  54456. * Specifies the number of steps used to calculate the volumetric lights
  54457. * Typically in interval [50, 200]
  54458. */
  54459. volumetricLightStepsCount: number;
  54460. /**
  54461. * Specifies the number of samples used for the motion blur effect
  54462. * Typically in interval [16, 64]
  54463. */
  54464. motionBlurSamples: number;
  54465. /**
  54466. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54467. */
  54468. samples: number;
  54469. /**
  54470. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54471. * @constructor
  54472. * @param name The rendering pipeline name
  54473. * @param scene The scene linked to this pipeline
  54474. * @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)
  54475. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54476. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54477. */
  54478. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54479. private _buildPipeline;
  54480. private _createDownSampleX4PostProcess;
  54481. private _createBrightPassPostProcess;
  54482. private _createBlurPostProcesses;
  54483. private _createTextureAdderPostProcess;
  54484. private _createVolumetricLightPostProcess;
  54485. private _createLuminancePostProcesses;
  54486. private _createHdrPostProcess;
  54487. private _createLensFlarePostProcess;
  54488. private _createDepthOfFieldPostProcess;
  54489. private _createMotionBlurPostProcess;
  54490. private _getDepthTexture;
  54491. private _disposePostProcesses;
  54492. /**
  54493. * Dispose of the pipeline and stop all post processes
  54494. */
  54495. dispose(): void;
  54496. /**
  54497. * Serialize the rendering pipeline (Used when exporting)
  54498. * @returns the serialized object
  54499. */
  54500. serialize(): any;
  54501. /**
  54502. * Parse the serialized pipeline
  54503. * @param source Source pipeline.
  54504. * @param scene The scene to load the pipeline to.
  54505. * @param rootUrl The URL of the serialized pipeline.
  54506. * @returns An instantiated pipeline from the serialized object.
  54507. */
  54508. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54509. /**
  54510. * Luminance steps
  54511. */
  54512. static LuminanceSteps: number;
  54513. }
  54514. }
  54515. declare module BABYLON {
  54516. /** @hidden */
  54517. export var tonemapPixelShader: {
  54518. name: string;
  54519. shader: string;
  54520. };
  54521. }
  54522. declare module BABYLON {
  54523. /** Defines operator used for tonemapping */
  54524. export enum TonemappingOperator {
  54525. /** Hable */
  54526. Hable = 0,
  54527. /** Reinhard */
  54528. Reinhard = 1,
  54529. /** HejiDawson */
  54530. HejiDawson = 2,
  54531. /** Photographic */
  54532. Photographic = 3
  54533. }
  54534. /**
  54535. * Defines a post process to apply tone mapping
  54536. */
  54537. export class TonemapPostProcess extends PostProcess {
  54538. private _operator;
  54539. /** Defines the required exposure adjustement */
  54540. exposureAdjustment: number;
  54541. /**
  54542. * Creates a new TonemapPostProcess
  54543. * @param name defines the name of the postprocess
  54544. * @param _operator defines the operator to use
  54545. * @param exposureAdjustment defines the required exposure adjustement
  54546. * @param camera defines the camera to use (can be null)
  54547. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54548. * @param engine defines the hosting engine (can be ignore if camera is set)
  54549. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54550. */
  54551. constructor(name: string, _operator: TonemappingOperator,
  54552. /** Defines the required exposure adjustement */
  54553. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54554. }
  54555. }
  54556. declare module BABYLON {
  54557. /** @hidden */
  54558. export var depthVertexShader: {
  54559. name: string;
  54560. shader: string;
  54561. };
  54562. }
  54563. declare module BABYLON {
  54564. /** @hidden */
  54565. export var volumetricLightScatteringPixelShader: {
  54566. name: string;
  54567. shader: string;
  54568. };
  54569. }
  54570. declare module BABYLON {
  54571. /** @hidden */
  54572. export var volumetricLightScatteringPassPixelShader: {
  54573. name: string;
  54574. shader: string;
  54575. };
  54576. }
  54577. declare module BABYLON {
  54578. /**
  54579. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54580. */
  54581. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54582. private _volumetricLightScatteringPass;
  54583. private _volumetricLightScatteringRTT;
  54584. private _viewPort;
  54585. private _screenCoordinates;
  54586. private _cachedDefines;
  54587. /**
  54588. * If not undefined, the mesh position is computed from the attached node position
  54589. */
  54590. attachedNode: {
  54591. position: Vector3;
  54592. };
  54593. /**
  54594. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54595. */
  54596. customMeshPosition: Vector3;
  54597. /**
  54598. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54599. */
  54600. useCustomMeshPosition: boolean;
  54601. /**
  54602. * If the post-process should inverse the light scattering direction
  54603. */
  54604. invert: boolean;
  54605. /**
  54606. * The internal mesh used by the post-process
  54607. */
  54608. mesh: Mesh;
  54609. /**
  54610. * @hidden
  54611. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54612. */
  54613. useDiffuseColor: boolean;
  54614. /**
  54615. * Array containing the excluded meshes not rendered in the internal pass
  54616. */
  54617. excludedMeshes: AbstractMesh[];
  54618. /**
  54619. * Controls the overall intensity of the post-process
  54620. */
  54621. exposure: number;
  54622. /**
  54623. * Dissipates each sample's contribution in range [0, 1]
  54624. */
  54625. decay: number;
  54626. /**
  54627. * Controls the overall intensity of each sample
  54628. */
  54629. weight: number;
  54630. /**
  54631. * Controls the density of each sample
  54632. */
  54633. density: number;
  54634. /**
  54635. * @constructor
  54636. * @param name The post-process name
  54637. * @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)
  54638. * @param camera The camera that the post-process will be attached to
  54639. * @param mesh The mesh used to create the light scattering
  54640. * @param samples The post-process quality, default 100
  54641. * @param samplingModeThe post-process filtering mode
  54642. * @param engine The babylon engine
  54643. * @param reusable If the post-process is reusable
  54644. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54645. */
  54646. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54647. /**
  54648. * Returns the string "VolumetricLightScatteringPostProcess"
  54649. * @returns "VolumetricLightScatteringPostProcess"
  54650. */
  54651. getClassName(): string;
  54652. private _isReady;
  54653. /**
  54654. * Sets the new light position for light scattering effect
  54655. * @param position The new custom light position
  54656. */
  54657. setCustomMeshPosition(position: Vector3): void;
  54658. /**
  54659. * Returns the light position for light scattering effect
  54660. * @return Vector3 The custom light position
  54661. */
  54662. getCustomMeshPosition(): Vector3;
  54663. /**
  54664. * Disposes the internal assets and detaches the post-process from the camera
  54665. */
  54666. dispose(camera: Camera): void;
  54667. /**
  54668. * Returns the render target texture used by the post-process
  54669. * @return the render target texture used by the post-process
  54670. */
  54671. getPass(): RenderTargetTexture;
  54672. private _meshExcluded;
  54673. private _createPass;
  54674. private _updateMeshScreenCoordinates;
  54675. /**
  54676. * Creates a default mesh for the Volumeric Light Scattering post-process
  54677. * @param name The mesh name
  54678. * @param scene The scene where to create the mesh
  54679. * @return the default mesh
  54680. */
  54681. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54682. }
  54683. }
  54684. declare module BABYLON {
  54685. interface Scene {
  54686. /** @hidden (Backing field) */
  54687. _boundingBoxRenderer: BoundingBoxRenderer;
  54688. /** @hidden (Backing field) */
  54689. _forceShowBoundingBoxes: boolean;
  54690. /**
  54691. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54692. */
  54693. forceShowBoundingBoxes: boolean;
  54694. /**
  54695. * Gets the bounding box renderer associated with the scene
  54696. * @returns a BoundingBoxRenderer
  54697. */
  54698. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54699. }
  54700. interface AbstractMesh {
  54701. /** @hidden (Backing field) */
  54702. _showBoundingBox: boolean;
  54703. /**
  54704. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54705. */
  54706. showBoundingBox: boolean;
  54707. }
  54708. /**
  54709. * Component responsible of rendering the bounding box of the meshes in a scene.
  54710. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54711. */
  54712. export class BoundingBoxRenderer implements ISceneComponent {
  54713. /**
  54714. * The component name helpfull to identify the component in the list of scene components.
  54715. */
  54716. readonly name: string;
  54717. /**
  54718. * The scene the component belongs to.
  54719. */
  54720. scene: Scene;
  54721. /**
  54722. * Color of the bounding box lines placed in front of an object
  54723. */
  54724. frontColor: Color3;
  54725. /**
  54726. * Color of the bounding box lines placed behind an object
  54727. */
  54728. backColor: Color3;
  54729. /**
  54730. * Defines if the renderer should show the back lines or not
  54731. */
  54732. showBackLines: boolean;
  54733. /**
  54734. * @hidden
  54735. */
  54736. renderList: SmartArray<BoundingBox>;
  54737. private _colorShader;
  54738. private _vertexBuffers;
  54739. private _indexBuffer;
  54740. /**
  54741. * Instantiates a new bounding box renderer in a scene.
  54742. * @param scene the scene the renderer renders in
  54743. */
  54744. constructor(scene: Scene);
  54745. /**
  54746. * Registers the component in a given scene
  54747. */
  54748. register(): void;
  54749. private _evaluateSubMesh;
  54750. private _activeMesh;
  54751. private _prepareRessources;
  54752. private _createIndexBuffer;
  54753. /**
  54754. * Rebuilds the elements related to this component in case of
  54755. * context lost for instance.
  54756. */
  54757. rebuild(): void;
  54758. /**
  54759. * @hidden
  54760. */
  54761. reset(): void;
  54762. /**
  54763. * Render the bounding boxes of a specific rendering group
  54764. * @param renderingGroupId defines the rendering group to render
  54765. */
  54766. render(renderingGroupId: number): void;
  54767. /**
  54768. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54769. * @param mesh Define the mesh to render the occlusion bounding box for
  54770. */
  54771. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54772. /**
  54773. * Dispose and release the resources attached to this renderer.
  54774. */
  54775. dispose(): void;
  54776. }
  54777. }
  54778. declare module BABYLON {
  54779. /** @hidden */
  54780. export var depthPixelShader: {
  54781. name: string;
  54782. shader: string;
  54783. };
  54784. }
  54785. declare module BABYLON {
  54786. /**
  54787. * This represents a depth renderer in Babylon.
  54788. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54789. */
  54790. export class DepthRenderer {
  54791. private _scene;
  54792. private _depthMap;
  54793. private _effect;
  54794. private _cachedDefines;
  54795. private _camera;
  54796. /**
  54797. * Specifiess that the depth renderer will only be used within
  54798. * the camera it is created for.
  54799. * This can help forcing its rendering during the camera processing.
  54800. */
  54801. useOnlyInActiveCamera: boolean;
  54802. /** @hidden */
  54803. static _SceneComponentInitialization: (scene: Scene) => void;
  54804. /**
  54805. * Instantiates a depth renderer
  54806. * @param scene The scene the renderer belongs to
  54807. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54808. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54809. */
  54810. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54811. /**
  54812. * Creates the depth rendering effect and checks if the effect is ready.
  54813. * @param subMesh The submesh to be used to render the depth map of
  54814. * @param useInstances If multiple world instances should be used
  54815. * @returns if the depth renderer is ready to render the depth map
  54816. */
  54817. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54818. /**
  54819. * Gets the texture which the depth map will be written to.
  54820. * @returns The depth map texture
  54821. */
  54822. getDepthMap(): RenderTargetTexture;
  54823. /**
  54824. * Disposes of the depth renderer.
  54825. */
  54826. dispose(): void;
  54827. }
  54828. }
  54829. declare module BABYLON {
  54830. interface Scene {
  54831. /** @hidden (Backing field) */
  54832. _depthRenderer: {
  54833. [id: string]: DepthRenderer;
  54834. };
  54835. /**
  54836. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54837. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54838. * @returns the created depth renderer
  54839. */
  54840. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54841. /**
  54842. * Disables a depth renderer for a given camera
  54843. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54844. */
  54845. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54846. }
  54847. /**
  54848. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54849. * in several rendering techniques.
  54850. */
  54851. export class DepthRendererSceneComponent implements ISceneComponent {
  54852. /**
  54853. * The component name helpfull to identify the component in the list of scene components.
  54854. */
  54855. readonly name: string;
  54856. /**
  54857. * The scene the component belongs to.
  54858. */
  54859. scene: Scene;
  54860. /**
  54861. * Creates a new instance of the component for the given scene
  54862. * @param scene Defines the scene to register the component in
  54863. */
  54864. constructor(scene: Scene);
  54865. /**
  54866. * Registers the component in a given scene
  54867. */
  54868. register(): void;
  54869. /**
  54870. * Rebuilds the elements related to this component in case of
  54871. * context lost for instance.
  54872. */
  54873. rebuild(): void;
  54874. /**
  54875. * Disposes the component and the associated ressources
  54876. */
  54877. dispose(): void;
  54878. private _gatherRenderTargets;
  54879. private _gatherActiveCameraRenderTargets;
  54880. }
  54881. }
  54882. declare module BABYLON {
  54883. /** @hidden */
  54884. export var outlinePixelShader: {
  54885. name: string;
  54886. shader: string;
  54887. };
  54888. }
  54889. declare module BABYLON {
  54890. /** @hidden */
  54891. export var outlineVertexShader: {
  54892. name: string;
  54893. shader: string;
  54894. };
  54895. }
  54896. declare module BABYLON {
  54897. interface Scene {
  54898. /** @hidden */
  54899. _outlineRenderer: OutlineRenderer;
  54900. /**
  54901. * Gets the outline renderer associated with the scene
  54902. * @returns a OutlineRenderer
  54903. */
  54904. getOutlineRenderer(): OutlineRenderer;
  54905. }
  54906. interface AbstractMesh {
  54907. /** @hidden (Backing field) */
  54908. _renderOutline: boolean;
  54909. /**
  54910. * Gets or sets a boolean indicating if the outline must be rendered as well
  54911. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54912. */
  54913. renderOutline: boolean;
  54914. /** @hidden (Backing field) */
  54915. _renderOverlay: boolean;
  54916. /**
  54917. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54918. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54919. */
  54920. renderOverlay: boolean;
  54921. }
  54922. /**
  54923. * This class is responsible to draw bothe outline/overlay of meshes.
  54924. * It should not be used directly but through the available method on mesh.
  54925. */
  54926. export class OutlineRenderer implements ISceneComponent {
  54927. /**
  54928. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54929. */
  54930. private static _StencilReference;
  54931. /**
  54932. * The name of the component. Each component must have a unique name.
  54933. */
  54934. name: string;
  54935. /**
  54936. * The scene the component belongs to.
  54937. */
  54938. scene: Scene;
  54939. /**
  54940. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54941. */
  54942. zOffset: number;
  54943. private _engine;
  54944. private _effect;
  54945. private _cachedDefines;
  54946. private _savedDepthWrite;
  54947. /**
  54948. * Instantiates a new outline renderer. (There could be only one per scene).
  54949. * @param scene Defines the scene it belongs to
  54950. */
  54951. constructor(scene: Scene);
  54952. /**
  54953. * Register the component to one instance of a scene.
  54954. */
  54955. register(): void;
  54956. /**
  54957. * Rebuilds the elements related to this component in case of
  54958. * context lost for instance.
  54959. */
  54960. rebuild(): void;
  54961. /**
  54962. * Disposes the component and the associated ressources.
  54963. */
  54964. dispose(): void;
  54965. /**
  54966. * Renders the outline in the canvas.
  54967. * @param subMesh Defines the sumesh to render
  54968. * @param batch Defines the batch of meshes in case of instances
  54969. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54970. */
  54971. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54972. /**
  54973. * Returns whether or not the outline renderer is ready for a given submesh.
  54974. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54975. * @param subMesh Defines the submesh to check readyness for
  54976. * @param useInstances Defines wheter wee are trying to render instances or not
  54977. * @returns true if ready otherwise false
  54978. */
  54979. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54980. private _beforeRenderingMesh;
  54981. private _afterRenderingMesh;
  54982. }
  54983. }
  54984. declare module BABYLON {
  54985. /**
  54986. * Defines the list of states available for a task inside a AssetsManager
  54987. */
  54988. export enum AssetTaskState {
  54989. /**
  54990. * Initialization
  54991. */
  54992. INIT = 0,
  54993. /**
  54994. * Running
  54995. */
  54996. RUNNING = 1,
  54997. /**
  54998. * Done
  54999. */
  55000. DONE = 2,
  55001. /**
  55002. * Error
  55003. */
  55004. ERROR = 3
  55005. }
  55006. /**
  55007. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55008. */
  55009. export abstract class AbstractAssetTask {
  55010. /**
  55011. * Task name
  55012. */ name: string;
  55013. /**
  55014. * Callback called when the task is successful
  55015. */
  55016. onSuccess: (task: any) => void;
  55017. /**
  55018. * Callback called when the task is not successful
  55019. */
  55020. onError: (task: any, message?: string, exception?: any) => void;
  55021. /**
  55022. * Creates a new AssetsManager
  55023. * @param name defines the name of the task
  55024. */
  55025. constructor(
  55026. /**
  55027. * Task name
  55028. */ name: string);
  55029. private _isCompleted;
  55030. private _taskState;
  55031. private _errorObject;
  55032. /**
  55033. * Get if the task is completed
  55034. */
  55035. readonly isCompleted: boolean;
  55036. /**
  55037. * Gets the current state of the task
  55038. */
  55039. readonly taskState: AssetTaskState;
  55040. /**
  55041. * Gets the current error object (if task is in error)
  55042. */
  55043. readonly errorObject: {
  55044. message?: string;
  55045. exception?: any;
  55046. };
  55047. /**
  55048. * Internal only
  55049. * @hidden
  55050. */
  55051. _setErrorObject(message?: string, exception?: any): void;
  55052. /**
  55053. * Execute the current task
  55054. * @param scene defines the scene where you want your assets to be loaded
  55055. * @param onSuccess is a callback called when the task is successfully executed
  55056. * @param onError is a callback called if an error occurs
  55057. */
  55058. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55059. /**
  55060. * Execute the current task
  55061. * @param scene defines the scene where you want your assets to be loaded
  55062. * @param onSuccess is a callback called when the task is successfully executed
  55063. * @param onError is a callback called if an error occurs
  55064. */
  55065. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55066. /**
  55067. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55068. * This can be used with failed tasks that have the reason for failure fixed.
  55069. */
  55070. reset(): void;
  55071. private onErrorCallback;
  55072. private onDoneCallback;
  55073. }
  55074. /**
  55075. * Define the interface used by progress events raised during assets loading
  55076. */
  55077. export interface IAssetsProgressEvent {
  55078. /**
  55079. * Defines the number of remaining tasks to process
  55080. */
  55081. remainingCount: number;
  55082. /**
  55083. * Defines the total number of tasks
  55084. */
  55085. totalCount: number;
  55086. /**
  55087. * Defines the task that was just processed
  55088. */
  55089. task: AbstractAssetTask;
  55090. }
  55091. /**
  55092. * Class used to share progress information about assets loading
  55093. */
  55094. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55095. /**
  55096. * Defines the number of remaining tasks to process
  55097. */
  55098. remainingCount: number;
  55099. /**
  55100. * Defines the total number of tasks
  55101. */
  55102. totalCount: number;
  55103. /**
  55104. * Defines the task that was just processed
  55105. */
  55106. task: AbstractAssetTask;
  55107. /**
  55108. * Creates a AssetsProgressEvent
  55109. * @param remainingCount defines the number of remaining tasks to process
  55110. * @param totalCount defines the total number of tasks
  55111. * @param task defines the task that was just processed
  55112. */
  55113. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55114. }
  55115. /**
  55116. * Define a task used by AssetsManager to load meshes
  55117. */
  55118. export class MeshAssetTask extends AbstractAssetTask {
  55119. /**
  55120. * Defines the name of the task
  55121. */
  55122. name: string;
  55123. /**
  55124. * Defines the list of mesh's names you want to load
  55125. */
  55126. meshesNames: any;
  55127. /**
  55128. * Defines the root url to use as a base to load your meshes and associated resources
  55129. */
  55130. rootUrl: string;
  55131. /**
  55132. * Defines the filename of the scene to load from
  55133. */
  55134. sceneFilename: string;
  55135. /**
  55136. * Gets the list of loaded meshes
  55137. */
  55138. loadedMeshes: Array<AbstractMesh>;
  55139. /**
  55140. * Gets the list of loaded particle systems
  55141. */
  55142. loadedParticleSystems: Array<IParticleSystem>;
  55143. /**
  55144. * Gets the list of loaded skeletons
  55145. */
  55146. loadedSkeletons: Array<Skeleton>;
  55147. /**
  55148. * Gets the list of loaded animation groups
  55149. */
  55150. loadedAnimationGroups: Array<AnimationGroup>;
  55151. /**
  55152. * Callback called when the task is successful
  55153. */
  55154. onSuccess: (task: MeshAssetTask) => void;
  55155. /**
  55156. * Callback called when the task is successful
  55157. */
  55158. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55159. /**
  55160. * Creates a new MeshAssetTask
  55161. * @param name defines the name of the task
  55162. * @param meshesNames defines the list of mesh's names you want to load
  55163. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55164. * @param sceneFilename defines the filename of the scene to load from
  55165. */
  55166. constructor(
  55167. /**
  55168. * Defines the name of the task
  55169. */
  55170. name: string,
  55171. /**
  55172. * Defines the list of mesh's names you want to load
  55173. */
  55174. meshesNames: any,
  55175. /**
  55176. * Defines the root url to use as a base to load your meshes and associated resources
  55177. */
  55178. rootUrl: string,
  55179. /**
  55180. * Defines the filename of the scene to load from
  55181. */
  55182. sceneFilename: string);
  55183. /**
  55184. * Execute the current task
  55185. * @param scene defines the scene where you want your assets to be loaded
  55186. * @param onSuccess is a callback called when the task is successfully executed
  55187. * @param onError is a callback called if an error occurs
  55188. */
  55189. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55190. }
  55191. /**
  55192. * Define a task used by AssetsManager to load text content
  55193. */
  55194. export class TextFileAssetTask extends AbstractAssetTask {
  55195. /**
  55196. * Defines the name of the task
  55197. */
  55198. name: string;
  55199. /**
  55200. * Defines the location of the file to load
  55201. */
  55202. url: string;
  55203. /**
  55204. * Gets the loaded text string
  55205. */
  55206. text: string;
  55207. /**
  55208. * Callback called when the task is successful
  55209. */
  55210. onSuccess: (task: TextFileAssetTask) => void;
  55211. /**
  55212. * Callback called when the task is successful
  55213. */
  55214. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55215. /**
  55216. * Creates a new TextFileAssetTask object
  55217. * @param name defines the name of the task
  55218. * @param url defines the location of the file to load
  55219. */
  55220. constructor(
  55221. /**
  55222. * Defines the name of the task
  55223. */
  55224. name: string,
  55225. /**
  55226. * Defines the location of the file to load
  55227. */
  55228. url: string);
  55229. /**
  55230. * Execute the current task
  55231. * @param scene defines the scene where you want your assets to be loaded
  55232. * @param onSuccess is a callback called when the task is successfully executed
  55233. * @param onError is a callback called if an error occurs
  55234. */
  55235. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55236. }
  55237. /**
  55238. * Define a task used by AssetsManager to load binary data
  55239. */
  55240. export class BinaryFileAssetTask extends AbstractAssetTask {
  55241. /**
  55242. * Defines the name of the task
  55243. */
  55244. name: string;
  55245. /**
  55246. * Defines the location of the file to load
  55247. */
  55248. url: string;
  55249. /**
  55250. * Gets the lodaded data (as an array buffer)
  55251. */
  55252. data: ArrayBuffer;
  55253. /**
  55254. * Callback called when the task is successful
  55255. */
  55256. onSuccess: (task: BinaryFileAssetTask) => void;
  55257. /**
  55258. * Callback called when the task is successful
  55259. */
  55260. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55261. /**
  55262. * Creates a new BinaryFileAssetTask object
  55263. * @param name defines the name of the new task
  55264. * @param url defines the location of the file to load
  55265. */
  55266. constructor(
  55267. /**
  55268. * Defines the name of the task
  55269. */
  55270. name: string,
  55271. /**
  55272. * Defines the location of the file to load
  55273. */
  55274. url: string);
  55275. /**
  55276. * Execute the current task
  55277. * @param scene defines the scene where you want your assets to be loaded
  55278. * @param onSuccess is a callback called when the task is successfully executed
  55279. * @param onError is a callback called if an error occurs
  55280. */
  55281. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55282. }
  55283. /**
  55284. * Define a task used by AssetsManager to load images
  55285. */
  55286. export class ImageAssetTask extends AbstractAssetTask {
  55287. /**
  55288. * Defines the name of the task
  55289. */
  55290. name: string;
  55291. /**
  55292. * Defines the location of the image to load
  55293. */
  55294. url: string;
  55295. /**
  55296. * Gets the loaded images
  55297. */
  55298. image: HTMLImageElement;
  55299. /**
  55300. * Callback called when the task is successful
  55301. */
  55302. onSuccess: (task: ImageAssetTask) => void;
  55303. /**
  55304. * Callback called when the task is successful
  55305. */
  55306. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55307. /**
  55308. * Creates a new ImageAssetTask
  55309. * @param name defines the name of the task
  55310. * @param url defines the location of the image to load
  55311. */
  55312. constructor(
  55313. /**
  55314. * Defines the name of the task
  55315. */
  55316. name: string,
  55317. /**
  55318. * Defines the location of the image to load
  55319. */
  55320. url: string);
  55321. /**
  55322. * Execute the current task
  55323. * @param scene defines the scene where you want your assets to be loaded
  55324. * @param onSuccess is a callback called when the task is successfully executed
  55325. * @param onError is a callback called if an error occurs
  55326. */
  55327. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55328. }
  55329. /**
  55330. * Defines the interface used by texture loading tasks
  55331. */
  55332. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55333. /**
  55334. * Gets the loaded texture
  55335. */
  55336. texture: TEX;
  55337. }
  55338. /**
  55339. * Define a task used by AssetsManager to load 2D textures
  55340. */
  55341. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55342. /**
  55343. * Defines the name of the task
  55344. */
  55345. name: string;
  55346. /**
  55347. * Defines the location of the file to load
  55348. */
  55349. url: string;
  55350. /**
  55351. * Defines if mipmap should not be generated (default is false)
  55352. */
  55353. noMipmap?: boolean | undefined;
  55354. /**
  55355. * Defines if texture must be inverted on Y axis (default is false)
  55356. */
  55357. invertY?: boolean | undefined;
  55358. /**
  55359. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55360. */
  55361. samplingMode: number;
  55362. /**
  55363. * Gets the loaded texture
  55364. */
  55365. texture: Texture;
  55366. /**
  55367. * Callback called when the task is successful
  55368. */
  55369. onSuccess: (task: TextureAssetTask) => void;
  55370. /**
  55371. * Callback called when the task is successful
  55372. */
  55373. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55374. /**
  55375. * Creates a new TextureAssetTask object
  55376. * @param name defines the name of the task
  55377. * @param url defines the location of the file to load
  55378. * @param noMipmap defines if mipmap should not be generated (default is false)
  55379. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55380. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55381. */
  55382. constructor(
  55383. /**
  55384. * Defines the name of the task
  55385. */
  55386. name: string,
  55387. /**
  55388. * Defines the location of the file to load
  55389. */
  55390. url: string,
  55391. /**
  55392. * Defines if mipmap should not be generated (default is false)
  55393. */
  55394. noMipmap?: boolean | undefined,
  55395. /**
  55396. * Defines if texture must be inverted on Y axis (default is false)
  55397. */
  55398. invertY?: boolean | undefined,
  55399. /**
  55400. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55401. */
  55402. samplingMode?: number);
  55403. /**
  55404. * Execute the current task
  55405. * @param scene defines the scene where you want your assets to be loaded
  55406. * @param onSuccess is a callback called when the task is successfully executed
  55407. * @param onError is a callback called if an error occurs
  55408. */
  55409. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55410. }
  55411. /**
  55412. * Define a task used by AssetsManager to load cube textures
  55413. */
  55414. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55415. /**
  55416. * Defines the name of the task
  55417. */
  55418. name: string;
  55419. /**
  55420. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55421. */
  55422. url: string;
  55423. /**
  55424. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55425. */
  55426. extensions?: string[] | undefined;
  55427. /**
  55428. * Defines if mipmaps should not be generated (default is false)
  55429. */
  55430. noMipmap?: boolean | undefined;
  55431. /**
  55432. * Defines the explicit list of files (undefined by default)
  55433. */
  55434. files?: string[] | undefined;
  55435. /**
  55436. * Gets the loaded texture
  55437. */
  55438. texture: CubeTexture;
  55439. /**
  55440. * Callback called when the task is successful
  55441. */
  55442. onSuccess: (task: CubeTextureAssetTask) => void;
  55443. /**
  55444. * Callback called when the task is successful
  55445. */
  55446. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55447. /**
  55448. * Creates a new CubeTextureAssetTask
  55449. * @param name defines the name of the task
  55450. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55451. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55452. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55453. * @param files defines the explicit list of files (undefined by default)
  55454. */
  55455. constructor(
  55456. /**
  55457. * Defines the name of the task
  55458. */
  55459. name: string,
  55460. /**
  55461. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55462. */
  55463. url: string,
  55464. /**
  55465. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55466. */
  55467. extensions?: string[] | undefined,
  55468. /**
  55469. * Defines if mipmaps should not be generated (default is false)
  55470. */
  55471. noMipmap?: boolean | undefined,
  55472. /**
  55473. * Defines the explicit list of files (undefined by default)
  55474. */
  55475. files?: string[] | undefined);
  55476. /**
  55477. * Execute the current task
  55478. * @param scene defines the scene where you want your assets to be loaded
  55479. * @param onSuccess is a callback called when the task is successfully executed
  55480. * @param onError is a callback called if an error occurs
  55481. */
  55482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55483. }
  55484. /**
  55485. * Define a task used by AssetsManager to load HDR cube textures
  55486. */
  55487. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55488. /**
  55489. * Defines the name of the task
  55490. */
  55491. name: string;
  55492. /**
  55493. * Defines the location of the file to load
  55494. */
  55495. url: string;
  55496. /**
  55497. * Defines the desired size (the more it increases the longer the generation will be)
  55498. */
  55499. size: number;
  55500. /**
  55501. * Defines if mipmaps should not be generated (default is false)
  55502. */
  55503. noMipmap: boolean;
  55504. /**
  55505. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55506. */
  55507. generateHarmonics: boolean;
  55508. /**
  55509. * 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)
  55510. */
  55511. gammaSpace: boolean;
  55512. /**
  55513. * Internal Use Only
  55514. */
  55515. reserved: boolean;
  55516. /**
  55517. * Gets the loaded texture
  55518. */
  55519. texture: HDRCubeTexture;
  55520. /**
  55521. * Callback called when the task is successful
  55522. */
  55523. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55524. /**
  55525. * Callback called when the task is successful
  55526. */
  55527. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55528. /**
  55529. * Creates a new HDRCubeTextureAssetTask object
  55530. * @param name defines the name of the task
  55531. * @param url defines the location of the file to load
  55532. * @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.
  55533. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55534. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55535. * @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)
  55536. * @param reserved Internal use only
  55537. */
  55538. constructor(
  55539. /**
  55540. * Defines the name of the task
  55541. */
  55542. name: string,
  55543. /**
  55544. * Defines the location of the file to load
  55545. */
  55546. url: string,
  55547. /**
  55548. * Defines the desired size (the more it increases the longer the generation will be)
  55549. */
  55550. size: number,
  55551. /**
  55552. * Defines if mipmaps should not be generated (default is false)
  55553. */
  55554. noMipmap?: boolean,
  55555. /**
  55556. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55557. */
  55558. generateHarmonics?: boolean,
  55559. /**
  55560. * 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)
  55561. */
  55562. gammaSpace?: boolean,
  55563. /**
  55564. * Internal Use Only
  55565. */
  55566. reserved?: boolean);
  55567. /**
  55568. * Execute the current task
  55569. * @param scene defines the scene where you want your assets to be loaded
  55570. * @param onSuccess is a callback called when the task is successfully executed
  55571. * @param onError is a callback called if an error occurs
  55572. */
  55573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55574. }
  55575. /**
  55576. * Define a task used by AssetsManager to load Equirectangular cube textures
  55577. */
  55578. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55579. /**
  55580. * Defines the name of the task
  55581. */
  55582. name: string;
  55583. /**
  55584. * Defines the location of the file to load
  55585. */
  55586. url: string;
  55587. /**
  55588. * Defines the desired size (the more it increases the longer the generation will be)
  55589. */
  55590. size: number;
  55591. /**
  55592. * Defines if mipmaps should not be generated (default is false)
  55593. */
  55594. noMipmap: boolean;
  55595. /**
  55596. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55597. * but the standard material would require them in Gamma space) (default is true)
  55598. */
  55599. gammaSpace: boolean;
  55600. /**
  55601. * Gets the loaded texture
  55602. */
  55603. texture: EquiRectangularCubeTexture;
  55604. /**
  55605. * Callback called when the task is successful
  55606. */
  55607. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55608. /**
  55609. * Callback called when the task is successful
  55610. */
  55611. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55612. /**
  55613. * Creates a new EquiRectangularCubeTextureAssetTask object
  55614. * @param name defines the name of the task
  55615. * @param url defines the location of the file to load
  55616. * @param size defines the desired size (the more it increases the longer the generation will be)
  55617. * If the size is omitted this implies you are using a preprocessed cubemap.
  55618. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55619. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55620. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55621. * (default is true)
  55622. */
  55623. constructor(
  55624. /**
  55625. * Defines the name of the task
  55626. */
  55627. name: string,
  55628. /**
  55629. * Defines the location of the file to load
  55630. */
  55631. url: string,
  55632. /**
  55633. * Defines the desired size (the more it increases the longer the generation will be)
  55634. */
  55635. size: number,
  55636. /**
  55637. * Defines if mipmaps should not be generated (default is false)
  55638. */
  55639. noMipmap?: boolean,
  55640. /**
  55641. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55642. * but the standard material would require them in Gamma space) (default is true)
  55643. */
  55644. gammaSpace?: boolean);
  55645. /**
  55646. * Execute the current task
  55647. * @param scene defines the scene where you want your assets to be loaded
  55648. * @param onSuccess is a callback called when the task is successfully executed
  55649. * @param onError is a callback called if an error occurs
  55650. */
  55651. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55652. }
  55653. /**
  55654. * This class can be used to easily import assets into a scene
  55655. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55656. */
  55657. export class AssetsManager {
  55658. private _scene;
  55659. private _isLoading;
  55660. protected _tasks: AbstractAssetTask[];
  55661. protected _waitingTasksCount: number;
  55662. protected _totalTasksCount: number;
  55663. /**
  55664. * Callback called when all tasks are processed
  55665. */
  55666. onFinish: (tasks: AbstractAssetTask[]) => void;
  55667. /**
  55668. * Callback called when a task is successful
  55669. */
  55670. onTaskSuccess: (task: AbstractAssetTask) => void;
  55671. /**
  55672. * Callback called when a task had an error
  55673. */
  55674. onTaskError: (task: AbstractAssetTask) => void;
  55675. /**
  55676. * Callback called when a task is done (whatever the result is)
  55677. */
  55678. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55679. /**
  55680. * Observable called when all tasks are processed
  55681. */
  55682. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55683. /**
  55684. * Observable called when a task had an error
  55685. */
  55686. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55687. /**
  55688. * Observable called when all tasks were executed
  55689. */
  55690. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55691. /**
  55692. * Observable called when a task is done (whatever the result is)
  55693. */
  55694. onProgressObservable: Observable<IAssetsProgressEvent>;
  55695. /**
  55696. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55698. */
  55699. useDefaultLoadingScreen: boolean;
  55700. /**
  55701. * Creates a new AssetsManager
  55702. * @param scene defines the scene to work on
  55703. */
  55704. constructor(scene: Scene);
  55705. /**
  55706. * Add a MeshAssetTask to the list of active tasks
  55707. * @param taskName defines the name of the new task
  55708. * @param meshesNames defines the name of meshes to load
  55709. * @param rootUrl defines the root url to use to locate files
  55710. * @param sceneFilename defines the filename of the scene file
  55711. * @returns a new MeshAssetTask object
  55712. */
  55713. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55714. /**
  55715. * Add a TextFileAssetTask to the list of active tasks
  55716. * @param taskName defines the name of the new task
  55717. * @param url defines the url of the file to load
  55718. * @returns a new TextFileAssetTask object
  55719. */
  55720. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55721. /**
  55722. * Add a BinaryFileAssetTask to the list of active tasks
  55723. * @param taskName defines the name of the new task
  55724. * @param url defines the url of the file to load
  55725. * @returns a new BinaryFileAssetTask object
  55726. */
  55727. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55728. /**
  55729. * Add a ImageAssetTask to the list of active tasks
  55730. * @param taskName defines the name of the new task
  55731. * @param url defines the url of the file to load
  55732. * @returns a new ImageAssetTask object
  55733. */
  55734. addImageTask(taskName: string, url: string): ImageAssetTask;
  55735. /**
  55736. * Add a TextureAssetTask to the list of active tasks
  55737. * @param taskName defines the name of the new task
  55738. * @param url defines the url of the file to load
  55739. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55740. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55741. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55742. * @returns a new TextureAssetTask object
  55743. */
  55744. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55745. /**
  55746. * Add a CubeTextureAssetTask to the list of active tasks
  55747. * @param taskName defines the name of the new task
  55748. * @param url defines the url of the file to load
  55749. * @param extensions defines the extension to use to load the cube map (can be null)
  55750. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55751. * @param files defines the list of files to load (can be null)
  55752. * @returns a new CubeTextureAssetTask object
  55753. */
  55754. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55755. /**
  55756. *
  55757. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55758. * @param taskName defines the name of the new task
  55759. * @param url defines the url of the file to load
  55760. * @param size defines the size you want for the cubemap (can be null)
  55761. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55762. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55763. * @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)
  55764. * @param reserved Internal use only
  55765. * @returns a new HDRCubeTextureAssetTask object
  55766. */
  55767. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55768. /**
  55769. *
  55770. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  55771. * @param taskName defines the name of the new task
  55772. * @param url defines the url of the file to load
  55773. * @param size defines the size you want for the cubemap (can be null)
  55774. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55775. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55776. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55777. * @returns a new EquiRectangularCubeTextureAssetTask object
  55778. */
  55779. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55780. /**
  55781. * Remove a task from the assets manager.
  55782. * @param task the task to remove
  55783. */
  55784. removeTask(task: AbstractAssetTask): void;
  55785. private _decreaseWaitingTasksCount;
  55786. private _runTask;
  55787. /**
  55788. * Reset the AssetsManager and remove all tasks
  55789. * @return the current instance of the AssetsManager
  55790. */
  55791. reset(): AssetsManager;
  55792. /**
  55793. * Start the loading process
  55794. * @return the current instance of the AssetsManager
  55795. */
  55796. load(): AssetsManager;
  55797. /**
  55798. * Start the loading process as an async operation
  55799. * @return a promise returning the list of failed tasks
  55800. */
  55801. loadAsync(): Promise<void>;
  55802. }
  55803. }
  55804. declare module BABYLON {
  55805. /**
  55806. * Wrapper class for promise with external resolve and reject.
  55807. */
  55808. export class Deferred<T> {
  55809. /**
  55810. * The promise associated with this deferred object.
  55811. */
  55812. readonly promise: Promise<T>;
  55813. private _resolve;
  55814. private _reject;
  55815. /**
  55816. * The resolve method of the promise associated with this deferred object.
  55817. */
  55818. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55819. /**
  55820. * The reject method of the promise associated with this deferred object.
  55821. */
  55822. readonly reject: (reason?: any) => void;
  55823. /**
  55824. * Constructor for this deferred object.
  55825. */
  55826. constructor();
  55827. }
  55828. }
  55829. declare module BABYLON {
  55830. /**
  55831. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55832. */
  55833. export class MeshExploder {
  55834. private _centerMesh;
  55835. private _meshes;
  55836. private _meshesOrigins;
  55837. private _toCenterVectors;
  55838. private _scaledDirection;
  55839. private _newPosition;
  55840. private _centerPosition;
  55841. /**
  55842. * Explodes meshes from a center mesh.
  55843. * @param meshes The meshes to explode.
  55844. * @param centerMesh The mesh to be center of explosion.
  55845. */
  55846. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55847. private _setCenterMesh;
  55848. /**
  55849. * Get class name
  55850. * @returns "MeshExploder"
  55851. */
  55852. getClassName(): string;
  55853. /**
  55854. * "Exploded meshes"
  55855. * @returns Array of meshes with the centerMesh at index 0.
  55856. */
  55857. getMeshes(): Array<Mesh>;
  55858. /**
  55859. * Explodes meshes giving a specific direction
  55860. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55861. */
  55862. explode(direction?: number): void;
  55863. }
  55864. }
  55865. declare module BABYLON {
  55866. /**
  55867. * Class used to help managing file picking and drag'n'drop
  55868. */
  55869. export class FilesInput {
  55870. /**
  55871. * List of files ready to be loaded
  55872. */
  55873. static readonly FilesToLoad: {
  55874. [key: string]: File;
  55875. };
  55876. /**
  55877. * Callback called when a file is processed
  55878. */
  55879. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55880. private _engine;
  55881. private _currentScene;
  55882. private _sceneLoadedCallback;
  55883. private _progressCallback;
  55884. private _additionalRenderLoopLogicCallback;
  55885. private _textureLoadingCallback;
  55886. private _startingProcessingFilesCallback;
  55887. private _onReloadCallback;
  55888. private _errorCallback;
  55889. private _elementToMonitor;
  55890. private _sceneFileToLoad;
  55891. private _filesToLoad;
  55892. /**
  55893. * Creates a new FilesInput
  55894. * @param engine defines the rendering engine
  55895. * @param scene defines the hosting scene
  55896. * @param sceneLoadedCallback callback called when scene is loaded
  55897. * @param progressCallback callback called to track progress
  55898. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55899. * @param textureLoadingCallback callback called when a texture is loading
  55900. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55901. * @param onReloadCallback callback called when a reload is requested
  55902. * @param errorCallback callback call if an error occurs
  55903. */
  55904. 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);
  55905. private _dragEnterHandler;
  55906. private _dragOverHandler;
  55907. private _dropHandler;
  55908. /**
  55909. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55910. * @param elementToMonitor defines the DOM element to track
  55911. */
  55912. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55913. /**
  55914. * Release all associated resources
  55915. */
  55916. dispose(): void;
  55917. private renderFunction;
  55918. private drag;
  55919. private drop;
  55920. private _traverseFolder;
  55921. private _processFiles;
  55922. /**
  55923. * Load files from a drop event
  55924. * @param event defines the drop event to use as source
  55925. */
  55926. loadFiles(event: any): void;
  55927. private _processReload;
  55928. /**
  55929. * Reload the current scene from the loaded files
  55930. */
  55931. reload(): void;
  55932. }
  55933. }
  55934. declare module BABYLON {
  55935. /**
  55936. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55937. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55938. */
  55939. export class SceneOptimization {
  55940. /**
  55941. * Defines the priority of this optimization (0 by default which means first in the list)
  55942. */
  55943. priority: number;
  55944. /**
  55945. * Gets a string describing the action executed by the current optimization
  55946. * @returns description string
  55947. */
  55948. getDescription(): string;
  55949. /**
  55950. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55951. * @param scene defines the current scene where to apply this optimization
  55952. * @param optimizer defines the current optimizer
  55953. * @returns true if everything that can be done was applied
  55954. */
  55955. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55956. /**
  55957. * Creates the SceneOptimization object
  55958. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55959. * @param desc defines the description associated with the optimization
  55960. */
  55961. constructor(
  55962. /**
  55963. * Defines the priority of this optimization (0 by default which means first in the list)
  55964. */
  55965. priority?: number);
  55966. }
  55967. /**
  55968. * Defines an optimization used to reduce the size of render target textures
  55969. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55970. */
  55971. export class TextureOptimization extends SceneOptimization {
  55972. /**
  55973. * Defines the priority of this optimization (0 by default which means first in the list)
  55974. */
  55975. priority: number;
  55976. /**
  55977. * 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
  55978. */
  55979. maximumSize: number;
  55980. /**
  55981. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55982. */
  55983. step: number;
  55984. /**
  55985. * Gets a string describing the action executed by the current optimization
  55986. * @returns description string
  55987. */
  55988. getDescription(): string;
  55989. /**
  55990. * Creates the TextureOptimization object
  55991. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55992. * @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
  55993. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55994. */
  55995. constructor(
  55996. /**
  55997. * Defines the priority of this optimization (0 by default which means first in the list)
  55998. */
  55999. priority?: number,
  56000. /**
  56001. * 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
  56002. */
  56003. maximumSize?: number,
  56004. /**
  56005. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56006. */
  56007. step?: number);
  56008. /**
  56009. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56010. * @param scene defines the current scene where to apply this optimization
  56011. * @param optimizer defines the current optimizer
  56012. * @returns true if everything that can be done was applied
  56013. */
  56014. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56015. }
  56016. /**
  56017. * Defines an optimization used to increase or decrease the rendering resolution
  56018. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56019. */
  56020. export class HardwareScalingOptimization extends SceneOptimization {
  56021. /**
  56022. * Defines the priority of this optimization (0 by default which means first in the list)
  56023. */
  56024. priority: number;
  56025. /**
  56026. * Defines the maximum scale to use (2 by default)
  56027. */
  56028. maximumScale: number;
  56029. /**
  56030. * Defines the step to use between two passes (0.5 by default)
  56031. */
  56032. step: number;
  56033. private _currentScale;
  56034. private _directionOffset;
  56035. /**
  56036. * Gets a string describing the action executed by the current optimization
  56037. * @return description string
  56038. */
  56039. getDescription(): string;
  56040. /**
  56041. * Creates the HardwareScalingOptimization object
  56042. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56043. * @param maximumScale defines the maximum scale to use (2 by default)
  56044. * @param step defines the step to use between two passes (0.5 by default)
  56045. */
  56046. constructor(
  56047. /**
  56048. * Defines the priority of this optimization (0 by default which means first in the list)
  56049. */
  56050. priority?: number,
  56051. /**
  56052. * Defines the maximum scale to use (2 by default)
  56053. */
  56054. maximumScale?: number,
  56055. /**
  56056. * Defines the step to use between two passes (0.5 by default)
  56057. */
  56058. step?: number);
  56059. /**
  56060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56061. * @param scene defines the current scene where to apply this optimization
  56062. * @param optimizer defines the current optimizer
  56063. * @returns true if everything that can be done was applied
  56064. */
  56065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56066. }
  56067. /**
  56068. * Defines an optimization used to remove shadows
  56069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56070. */
  56071. export class ShadowsOptimization extends SceneOptimization {
  56072. /**
  56073. * Gets a string describing the action executed by the current optimization
  56074. * @return description string
  56075. */
  56076. getDescription(): string;
  56077. /**
  56078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56079. * @param scene defines the current scene where to apply this optimization
  56080. * @param optimizer defines the current optimizer
  56081. * @returns true if everything that can be done was applied
  56082. */
  56083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56084. }
  56085. /**
  56086. * Defines an optimization used to turn post-processes off
  56087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56088. */
  56089. export class PostProcessesOptimization extends SceneOptimization {
  56090. /**
  56091. * Gets a string describing the action executed by the current optimization
  56092. * @return description string
  56093. */
  56094. getDescription(): string;
  56095. /**
  56096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56097. * @param scene defines the current scene where to apply this optimization
  56098. * @param optimizer defines the current optimizer
  56099. * @returns true if everything that can be done was applied
  56100. */
  56101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56102. }
  56103. /**
  56104. * Defines an optimization used to turn lens flares off
  56105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56106. */
  56107. export class LensFlaresOptimization extends SceneOptimization {
  56108. /**
  56109. * Gets a string describing the action executed by the current optimization
  56110. * @return description string
  56111. */
  56112. getDescription(): string;
  56113. /**
  56114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56115. * @param scene defines the current scene where to apply this optimization
  56116. * @param optimizer defines the current optimizer
  56117. * @returns true if everything that can be done was applied
  56118. */
  56119. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56120. }
  56121. /**
  56122. * Defines an optimization based on user defined callback.
  56123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56124. */
  56125. export class CustomOptimization extends SceneOptimization {
  56126. /**
  56127. * Callback called to apply the custom optimization.
  56128. */
  56129. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56130. /**
  56131. * Callback called to get custom description
  56132. */
  56133. onGetDescription: () => string;
  56134. /**
  56135. * Gets a string describing the action executed by the current optimization
  56136. * @returns description string
  56137. */
  56138. getDescription(): string;
  56139. /**
  56140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56141. * @param scene defines the current scene where to apply this optimization
  56142. * @param optimizer defines the current optimizer
  56143. * @returns true if everything that can be done was applied
  56144. */
  56145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56146. }
  56147. /**
  56148. * Defines an optimization used to turn particles off
  56149. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56150. */
  56151. export class ParticlesOptimization extends SceneOptimization {
  56152. /**
  56153. * Gets a string describing the action executed by the current optimization
  56154. * @return description string
  56155. */
  56156. getDescription(): string;
  56157. /**
  56158. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56159. * @param scene defines the current scene where to apply this optimization
  56160. * @param optimizer defines the current optimizer
  56161. * @returns true if everything that can be done was applied
  56162. */
  56163. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56164. }
  56165. /**
  56166. * Defines an optimization used to turn render targets off
  56167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56168. */
  56169. export class RenderTargetsOptimization extends SceneOptimization {
  56170. /**
  56171. * Gets a string describing the action executed by the current optimization
  56172. * @return description string
  56173. */
  56174. getDescription(): string;
  56175. /**
  56176. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56177. * @param scene defines the current scene where to apply this optimization
  56178. * @param optimizer defines the current optimizer
  56179. * @returns true if everything that can be done was applied
  56180. */
  56181. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56182. }
  56183. /**
  56184. * Defines an optimization used to merge meshes with compatible materials
  56185. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56186. */
  56187. export class MergeMeshesOptimization extends SceneOptimization {
  56188. private static _UpdateSelectionTree;
  56189. /**
  56190. * Gets or sets a boolean which defines if optimization octree has to be updated
  56191. */
  56192. /**
  56193. * Gets or sets a boolean which defines if optimization octree has to be updated
  56194. */
  56195. static UpdateSelectionTree: boolean;
  56196. /**
  56197. * Gets a string describing the action executed by the current optimization
  56198. * @return description string
  56199. */
  56200. getDescription(): string;
  56201. private _canBeMerged;
  56202. /**
  56203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56204. * @param scene defines the current scene where to apply this optimization
  56205. * @param optimizer defines the current optimizer
  56206. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56207. * @returns true if everything that can be done was applied
  56208. */
  56209. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56210. }
  56211. /**
  56212. * Defines a list of options used by SceneOptimizer
  56213. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56214. */
  56215. export class SceneOptimizerOptions {
  56216. /**
  56217. * Defines the target frame rate to reach (60 by default)
  56218. */
  56219. targetFrameRate: number;
  56220. /**
  56221. * Defines the interval between two checkes (2000ms by default)
  56222. */
  56223. trackerDuration: number;
  56224. /**
  56225. * Gets the list of optimizations to apply
  56226. */
  56227. optimizations: SceneOptimization[];
  56228. /**
  56229. * Creates a new list of options used by SceneOptimizer
  56230. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56231. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56232. */
  56233. constructor(
  56234. /**
  56235. * Defines the target frame rate to reach (60 by default)
  56236. */
  56237. targetFrameRate?: number,
  56238. /**
  56239. * Defines the interval between two checkes (2000ms by default)
  56240. */
  56241. trackerDuration?: number);
  56242. /**
  56243. * Add a new optimization
  56244. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56245. * @returns the current SceneOptimizerOptions
  56246. */
  56247. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56248. /**
  56249. * Add a new custom optimization
  56250. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56251. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56252. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56253. * @returns the current SceneOptimizerOptions
  56254. */
  56255. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56256. /**
  56257. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56258. * @param targetFrameRate defines the target frame rate (60 by default)
  56259. * @returns a SceneOptimizerOptions object
  56260. */
  56261. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56262. /**
  56263. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56264. * @param targetFrameRate defines the target frame rate (60 by default)
  56265. * @returns a SceneOptimizerOptions object
  56266. */
  56267. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56268. /**
  56269. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56270. * @param targetFrameRate defines the target frame rate (60 by default)
  56271. * @returns a SceneOptimizerOptions object
  56272. */
  56273. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56274. }
  56275. /**
  56276. * Class used to run optimizations in order to reach a target frame rate
  56277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56278. */
  56279. export class SceneOptimizer implements IDisposable {
  56280. private _isRunning;
  56281. private _options;
  56282. private _scene;
  56283. private _currentPriorityLevel;
  56284. private _targetFrameRate;
  56285. private _trackerDuration;
  56286. private _currentFrameRate;
  56287. private _sceneDisposeObserver;
  56288. private _improvementMode;
  56289. /**
  56290. * Defines an observable called when the optimizer reaches the target frame rate
  56291. */
  56292. onSuccessObservable: Observable<SceneOptimizer>;
  56293. /**
  56294. * Defines an observable called when the optimizer enables an optimization
  56295. */
  56296. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56297. /**
  56298. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56299. */
  56300. onFailureObservable: Observable<SceneOptimizer>;
  56301. /**
  56302. * Gets a boolean indicating if the optimizer is in improvement mode
  56303. */
  56304. readonly isInImprovementMode: boolean;
  56305. /**
  56306. * Gets the current priority level (0 at start)
  56307. */
  56308. readonly currentPriorityLevel: number;
  56309. /**
  56310. * Gets the current frame rate checked by the SceneOptimizer
  56311. */
  56312. readonly currentFrameRate: number;
  56313. /**
  56314. * Gets or sets the current target frame rate (60 by default)
  56315. */
  56316. /**
  56317. * Gets or sets the current target frame rate (60 by default)
  56318. */
  56319. targetFrameRate: number;
  56320. /**
  56321. * Gets or sets the current interval between two checks (every 2000ms by default)
  56322. */
  56323. /**
  56324. * Gets or sets the current interval between two checks (every 2000ms by default)
  56325. */
  56326. trackerDuration: number;
  56327. /**
  56328. * Gets the list of active optimizations
  56329. */
  56330. readonly optimizations: SceneOptimization[];
  56331. /**
  56332. * Creates a new SceneOptimizer
  56333. * @param scene defines the scene to work on
  56334. * @param options defines the options to use with the SceneOptimizer
  56335. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56336. * @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)
  56337. */
  56338. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56339. /**
  56340. * Stops the current optimizer
  56341. */
  56342. stop(): void;
  56343. /**
  56344. * Reset the optimizer to initial step (current priority level = 0)
  56345. */
  56346. reset(): void;
  56347. /**
  56348. * Start the optimizer. By default it will try to reach a specific framerate
  56349. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56350. */
  56351. start(): void;
  56352. private _checkCurrentState;
  56353. /**
  56354. * Release all resources
  56355. */
  56356. dispose(): void;
  56357. /**
  56358. * Helper function to create a SceneOptimizer with one single line of code
  56359. * @param scene defines the scene to work on
  56360. * @param options defines the options to use with the SceneOptimizer
  56361. * @param onSuccess defines a callback to call on success
  56362. * @param onFailure defines a callback to call on failure
  56363. * @returns the new SceneOptimizer object
  56364. */
  56365. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56366. }
  56367. }
  56368. declare module BABYLON {
  56369. /**
  56370. * Class used to serialize a scene into a string
  56371. */
  56372. export class SceneSerializer {
  56373. /**
  56374. * Clear cache used by a previous serialization
  56375. */
  56376. static ClearCache(): void;
  56377. /**
  56378. * Serialize a scene into a JSON compatible object
  56379. * @param scene defines the scene to serialize
  56380. * @returns a JSON compatible object
  56381. */
  56382. static Serialize(scene: Scene): any;
  56383. /**
  56384. * Serialize a mesh into a JSON compatible object
  56385. * @param toSerialize defines the mesh to serialize
  56386. * @param withParents defines if parents must be serialized as well
  56387. * @param withChildren defines if children must be serialized as well
  56388. * @returns a JSON compatible object
  56389. */
  56390. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56391. }
  56392. }
  56393. declare module BABYLON {
  56394. /**
  56395. * Class used to host texture specific utilities
  56396. */
  56397. export class TextureTools {
  56398. /**
  56399. * Uses the GPU to create a copy texture rescaled at a given size
  56400. * @param texture Texture to copy from
  56401. * @param width defines the desired width
  56402. * @param height defines the desired height
  56403. * @param useBilinearMode defines if bilinear mode has to be used
  56404. * @return the generated texture
  56405. */
  56406. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  56407. }
  56408. }
  56409. declare module BABYLON {
  56410. /**
  56411. * This represents the different options avilable for the video capture.
  56412. */
  56413. export interface VideoRecorderOptions {
  56414. /** Defines the mime type of the video */
  56415. mimeType: string;
  56416. /** Defines the video the video should be recorded at */
  56417. fps: number;
  56418. /** Defines the chunk size for the recording data */
  56419. recordChunckSize: number;
  56420. /** The audio tracks to attach to the record */
  56421. audioTracks?: MediaStreamTrack[];
  56422. }
  56423. /**
  56424. * This can helps recording videos from BabylonJS.
  56425. * This is based on the available WebRTC functionalities of the browser.
  56426. *
  56427. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56428. */
  56429. export class VideoRecorder {
  56430. private static readonly _defaultOptions;
  56431. /**
  56432. * Returns wehther or not the VideoRecorder is available in your browser.
  56433. * @param engine Defines the Babylon Engine to check the support for
  56434. * @returns true if supported otherwise false
  56435. */
  56436. static IsSupported(engine: Engine): boolean;
  56437. private readonly _options;
  56438. private _canvas;
  56439. private _mediaRecorder;
  56440. private _recordedChunks;
  56441. private _fileName;
  56442. private _resolve;
  56443. private _reject;
  56444. /**
  56445. * True wether a recording is already in progress.
  56446. */
  56447. readonly isRecording: boolean;
  56448. /**
  56449. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56450. * a video file.
  56451. * @param engine Defines the BabylonJS Engine you wish to record
  56452. * @param options Defines options that can be used to customized the capture
  56453. */
  56454. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56455. /**
  56456. * Stops the current recording before the default capture timeout passed in the startRecording
  56457. * functions.
  56458. */
  56459. stopRecording(): void;
  56460. /**
  56461. * Starts recording the canvas for a max duration specified in parameters.
  56462. * @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.
  56463. * @param maxDuration Defines the maximum recording time in seconds.
  56464. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56465. * @return a promise callback at the end of the recording with the video data in Blob.
  56466. */
  56467. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56468. /**
  56469. * Releases internal resources used during the recording.
  56470. */
  56471. dispose(): void;
  56472. private _handleDataAvailable;
  56473. private _handleError;
  56474. private _handleStop;
  56475. }
  56476. }
  56477. declare module BABYLON {
  56478. /**
  56479. * Class containing a set of static utilities functions for screenshots
  56480. */
  56481. export class ScreenshotTools {
  56482. /**
  56483. * Captures a screenshot of the current rendering
  56484. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56485. * @param engine defines the rendering engine
  56486. * @param camera defines the source camera
  56487. * @param size This parameter can be set to a single number or to an object with the
  56488. * following (optional) properties: precision, width, height. If a single number is passed,
  56489. * it will be used for both width and height. If an object is passed, the screenshot size
  56490. * will be derived from the parameters. The precision property is a multiplier allowing
  56491. * rendering at a higher or lower resolution
  56492. * @param successCallback defines the callback receives a single parameter which contains the
  56493. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56494. * src parameter of an <img> to display it
  56495. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56496. * Check your browser for supported MIME types
  56497. */
  56498. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56499. /**
  56500. * Generates an image screenshot from the specified camera.
  56501. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56502. * @param engine The engine to use for rendering
  56503. * @param camera The camera to use for rendering
  56504. * @param size This parameter can be set to a single number or to an object with the
  56505. * following (optional) properties: precision, width, height. If a single number is passed,
  56506. * it will be used for both width and height. If an object is passed, the screenshot size
  56507. * will be derived from the parameters. The precision property is a multiplier allowing
  56508. * rendering at a higher or lower resolution
  56509. * @param successCallback The callback receives a single parameter which contains the
  56510. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56511. * src parameter of an <img> to display it
  56512. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56513. * Check your browser for supported MIME types
  56514. * @param samples Texture samples (default: 1)
  56515. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56516. * @param fileName A name for for the downloaded file.
  56517. */
  56518. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56519. }
  56520. }
  56521. declare module BABYLON {
  56522. /**
  56523. * A cursor which tracks a point on a path
  56524. */
  56525. export class PathCursor {
  56526. private path;
  56527. /**
  56528. * Stores path cursor callbacks for when an onchange event is triggered
  56529. */
  56530. private _onchange;
  56531. /**
  56532. * The value of the path cursor
  56533. */
  56534. value: number;
  56535. /**
  56536. * The animation array of the path cursor
  56537. */
  56538. animations: Animation[];
  56539. /**
  56540. * Initializes the path cursor
  56541. * @param path The path to track
  56542. */
  56543. constructor(path: Path2);
  56544. /**
  56545. * Gets the cursor point on the path
  56546. * @returns A point on the path cursor at the cursor location
  56547. */
  56548. getPoint(): Vector3;
  56549. /**
  56550. * Moves the cursor ahead by the step amount
  56551. * @param step The amount to move the cursor forward
  56552. * @returns This path cursor
  56553. */
  56554. moveAhead(step?: number): PathCursor;
  56555. /**
  56556. * Moves the cursor behind by the step amount
  56557. * @param step The amount to move the cursor back
  56558. * @returns This path cursor
  56559. */
  56560. moveBack(step?: number): PathCursor;
  56561. /**
  56562. * Moves the cursor by the step amount
  56563. * If the step amount is greater than one, an exception is thrown
  56564. * @param step The amount to move the cursor
  56565. * @returns This path cursor
  56566. */
  56567. move(step: number): PathCursor;
  56568. /**
  56569. * Ensures that the value is limited between zero and one
  56570. * @returns This path cursor
  56571. */
  56572. private ensureLimits;
  56573. /**
  56574. * Runs onchange callbacks on change (used by the animation engine)
  56575. * @returns This path cursor
  56576. */
  56577. private raiseOnChange;
  56578. /**
  56579. * Executes a function on change
  56580. * @param f A path cursor onchange callback
  56581. * @returns This path cursor
  56582. */
  56583. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56584. }
  56585. }
  56586. declare module BABYLON {
  56587. /** @hidden */
  56588. export var blurPixelShader: {
  56589. name: string;
  56590. shader: string;
  56591. };
  56592. }
  56593. declare module BABYLON {
  56594. /** @hidden */
  56595. export var bones300Declaration: {
  56596. name: string;
  56597. shader: string;
  56598. };
  56599. }
  56600. declare module BABYLON {
  56601. /** @hidden */
  56602. export var instances300Declaration: {
  56603. name: string;
  56604. shader: string;
  56605. };
  56606. }
  56607. declare module BABYLON {
  56608. /** @hidden */
  56609. export var pointCloudVertexDeclaration: {
  56610. name: string;
  56611. shader: string;
  56612. };
  56613. }
  56614. // Mixins
  56615. interface Window {
  56616. mozIndexedDB: IDBFactory;
  56617. webkitIndexedDB: IDBFactory;
  56618. msIndexedDB: IDBFactory;
  56619. webkitURL: typeof URL;
  56620. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56621. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56622. WebGLRenderingContext: WebGLRenderingContext;
  56623. MSGesture: MSGesture;
  56624. CANNON: any;
  56625. AudioContext: AudioContext;
  56626. webkitAudioContext: AudioContext;
  56627. PointerEvent: any;
  56628. Math: Math;
  56629. Uint8Array: Uint8ArrayConstructor;
  56630. Float32Array: Float32ArrayConstructor;
  56631. mozURL: typeof URL;
  56632. msURL: typeof URL;
  56633. VRFrameData: any; // WebVR, from specs 1.1
  56634. DracoDecoderModule: any;
  56635. setImmediate(handler: (...args: any[]) => void): number;
  56636. }
  56637. interface HTMLCanvasElement {
  56638. requestPointerLock(): void;
  56639. msRequestPointerLock?(): void;
  56640. mozRequestPointerLock?(): void;
  56641. webkitRequestPointerLock?(): void;
  56642. /** Track wether a record is in progress */
  56643. isRecording: boolean;
  56644. /** Capture Stream method defined by some browsers */
  56645. captureStream(fps?: number): MediaStream;
  56646. }
  56647. interface CanvasRenderingContext2D {
  56648. msImageSmoothingEnabled: boolean;
  56649. }
  56650. interface MouseEvent {
  56651. mozMovementX: number;
  56652. mozMovementY: number;
  56653. webkitMovementX: number;
  56654. webkitMovementY: number;
  56655. msMovementX: number;
  56656. msMovementY: number;
  56657. }
  56658. interface Navigator {
  56659. mozGetVRDevices: (any: any) => any;
  56660. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56661. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56662. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56663. webkitGetGamepads(): Gamepad[];
  56664. msGetGamepads(): Gamepad[];
  56665. webkitGamepads(): Gamepad[];
  56666. }
  56667. interface HTMLVideoElement {
  56668. mozSrcObject: any;
  56669. }
  56670. interface Math {
  56671. fround(x: number): number;
  56672. imul(a: number, b: number): number;
  56673. }
  56674. interface WebGLRenderingContext {
  56675. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56676. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56677. vertexAttribDivisor(index: number, divisor: number): void;
  56678. createVertexArray(): any;
  56679. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56680. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56681. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56682. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56683. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56684. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56685. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56686. // Queries
  56687. createQuery(): WebGLQuery;
  56688. deleteQuery(query: WebGLQuery): void;
  56689. beginQuery(target: number, query: WebGLQuery): void;
  56690. endQuery(target: number): void;
  56691. getQueryParameter(query: WebGLQuery, pname: number): any;
  56692. getQuery(target: number, pname: number): any;
  56693. MAX_SAMPLES: number;
  56694. RGBA8: number;
  56695. READ_FRAMEBUFFER: number;
  56696. DRAW_FRAMEBUFFER: number;
  56697. UNIFORM_BUFFER: number;
  56698. HALF_FLOAT_OES: number;
  56699. RGBA16F: number;
  56700. RGBA32F: number;
  56701. R32F: number;
  56702. RG32F: number;
  56703. RGB32F: number;
  56704. R16F: number;
  56705. RG16F: number;
  56706. RGB16F: number;
  56707. RED: number;
  56708. RG: number;
  56709. R8: number;
  56710. RG8: number;
  56711. UNSIGNED_INT_24_8: number;
  56712. DEPTH24_STENCIL8: number;
  56713. /* Multiple Render Targets */
  56714. drawBuffers(buffers: number[]): void;
  56715. readBuffer(src: number): void;
  56716. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56717. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56718. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56719. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56720. // Occlusion Query
  56721. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56722. ANY_SAMPLES_PASSED: number;
  56723. QUERY_RESULT_AVAILABLE: number;
  56724. QUERY_RESULT: number;
  56725. }
  56726. interface WebGLProgram {
  56727. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56728. }
  56729. interface EXT_disjoint_timer_query {
  56730. QUERY_COUNTER_BITS_EXT: number;
  56731. TIME_ELAPSED_EXT: number;
  56732. TIMESTAMP_EXT: number;
  56733. GPU_DISJOINT_EXT: number;
  56734. QUERY_RESULT_EXT: number;
  56735. QUERY_RESULT_AVAILABLE_EXT: number;
  56736. queryCounterEXT(query: WebGLQuery, target: number): void;
  56737. createQueryEXT(): WebGLQuery;
  56738. beginQueryEXT(target: number, query: WebGLQuery): void;
  56739. endQueryEXT(target: number): void;
  56740. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56741. deleteQueryEXT(query: WebGLQuery): void;
  56742. }
  56743. interface WebGLUniformLocation {
  56744. _currentState: any;
  56745. }
  56746. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56747. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56748. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56749. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56750. interface WebGLRenderingContext {
  56751. readonly RASTERIZER_DISCARD: number;
  56752. readonly DEPTH_COMPONENT24: number;
  56753. readonly TEXTURE_3D: number;
  56754. readonly TEXTURE_2D_ARRAY: number;
  56755. readonly TEXTURE_COMPARE_FUNC: number;
  56756. readonly TEXTURE_COMPARE_MODE: number;
  56757. readonly COMPARE_REF_TO_TEXTURE: number;
  56758. readonly TEXTURE_WRAP_R: number;
  56759. readonly HALF_FLOAT: number;
  56760. readonly RGB8: number;
  56761. readonly RED_INTEGER: number;
  56762. readonly RG_INTEGER: number;
  56763. readonly RGB_INTEGER: number;
  56764. readonly RGBA_INTEGER: number;
  56765. readonly R8_SNORM: number;
  56766. readonly RG8_SNORM: number;
  56767. readonly RGB8_SNORM: number;
  56768. readonly RGBA8_SNORM: number;
  56769. readonly R8I: number;
  56770. readonly RG8I: number;
  56771. readonly RGB8I: number;
  56772. readonly RGBA8I: number;
  56773. readonly R8UI: number;
  56774. readonly RG8UI: number;
  56775. readonly RGB8UI: number;
  56776. readonly RGBA8UI: number;
  56777. readonly R16I: number;
  56778. readonly RG16I: number;
  56779. readonly RGB16I: number;
  56780. readonly RGBA16I: number;
  56781. readonly R16UI: number;
  56782. readonly RG16UI: number;
  56783. readonly RGB16UI: number;
  56784. readonly RGBA16UI: number;
  56785. readonly R32I: number;
  56786. readonly RG32I: number;
  56787. readonly RGB32I: number;
  56788. readonly RGBA32I: number;
  56789. readonly R32UI: number;
  56790. readonly RG32UI: number;
  56791. readonly RGB32UI: number;
  56792. readonly RGBA32UI: number;
  56793. readonly RGB10_A2UI: number;
  56794. readonly R11F_G11F_B10F: number;
  56795. readonly RGB9_E5: number;
  56796. readonly RGB10_A2: number;
  56797. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56798. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56799. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56800. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56801. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56802. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56803. 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;
  56804. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56805. readonly TRANSFORM_FEEDBACK: number;
  56806. readonly INTERLEAVED_ATTRIBS: number;
  56807. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56808. createTransformFeedback(): WebGLTransformFeedback;
  56809. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56810. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56811. beginTransformFeedback(primitiveMode: number): void;
  56812. endTransformFeedback(): void;
  56813. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56814. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56815. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56816. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56817. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56818. }
  56819. interface ImageBitmap {
  56820. readonly width: number;
  56821. readonly height: number;
  56822. close(): void;
  56823. }
  56824. interface WebGLQuery extends WebGLObject {
  56825. }
  56826. declare var WebGLQuery: {
  56827. prototype: WebGLQuery;
  56828. new(): WebGLQuery;
  56829. };
  56830. interface WebGLSampler extends WebGLObject {
  56831. }
  56832. declare var WebGLSampler: {
  56833. prototype: WebGLSampler;
  56834. new(): WebGLSampler;
  56835. };
  56836. interface WebGLSync extends WebGLObject {
  56837. }
  56838. declare var WebGLSync: {
  56839. prototype: WebGLSync;
  56840. new(): WebGLSync;
  56841. };
  56842. interface WebGLTransformFeedback extends WebGLObject {
  56843. }
  56844. declare var WebGLTransformFeedback: {
  56845. prototype: WebGLTransformFeedback;
  56846. new(): WebGLTransformFeedback;
  56847. };
  56848. interface WebGLVertexArrayObject extends WebGLObject {
  56849. }
  56850. declare var WebGLVertexArrayObject: {
  56851. prototype: WebGLVertexArrayObject;
  56852. new(): WebGLVertexArrayObject;
  56853. };
  56854. // Type definitions for WebVR API
  56855. // Project: https://w3c.github.io/webvr/
  56856. // Definitions by: six a <https://github.com/lostfictions>
  56857. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56858. interface VRDisplay extends EventTarget {
  56859. /**
  56860. * Dictionary of capabilities describing the VRDisplay.
  56861. */
  56862. readonly capabilities: VRDisplayCapabilities;
  56863. /**
  56864. * z-depth defining the far plane of the eye view frustum
  56865. * enables mapping of values in the render target depth
  56866. * attachment to scene coordinates. Initially set to 10000.0.
  56867. */
  56868. depthFar: number;
  56869. /**
  56870. * z-depth defining the near plane of the eye view frustum
  56871. * enables mapping of values in the render target depth
  56872. * attachment to scene coordinates. Initially set to 0.01.
  56873. */
  56874. depthNear: number;
  56875. /**
  56876. * An identifier for this distinct VRDisplay. Used as an
  56877. * association point in the Gamepad API.
  56878. */
  56879. readonly displayId: number;
  56880. /**
  56881. * A display name, a user-readable name identifying it.
  56882. */
  56883. readonly displayName: string;
  56884. readonly isConnected: boolean;
  56885. readonly isPresenting: boolean;
  56886. /**
  56887. * If this VRDisplay supports room-scale experiences, the optional
  56888. * stage attribute contains details on the room-scale parameters.
  56889. */
  56890. readonly stageParameters: VRStageParameters | null;
  56891. /**
  56892. * Passing the value returned by `requestAnimationFrame` to
  56893. * `cancelAnimationFrame` will unregister the callback.
  56894. * @param handle Define the hanle of the request to cancel
  56895. */
  56896. cancelAnimationFrame(handle: number): void;
  56897. /**
  56898. * Stops presenting to the VRDisplay.
  56899. * @returns a promise to know when it stopped
  56900. */
  56901. exitPresent(): Promise<void>;
  56902. /**
  56903. * Return the current VREyeParameters for the given eye.
  56904. * @param whichEye Define the eye we want the parameter for
  56905. * @returns the eye parameters
  56906. */
  56907. getEyeParameters(whichEye: string): VREyeParameters;
  56908. /**
  56909. * Populates the passed VRFrameData with the information required to render
  56910. * the current frame.
  56911. * @param frameData Define the data structure to populate
  56912. * @returns true if ok otherwise false
  56913. */
  56914. getFrameData(frameData: VRFrameData): boolean;
  56915. /**
  56916. * Get the layers currently being presented.
  56917. * @returns the list of VR layers
  56918. */
  56919. getLayers(): VRLayer[];
  56920. /**
  56921. * Return a VRPose containing the future predicted pose of the VRDisplay
  56922. * when the current frame will be presented. The value returned will not
  56923. * change until JavaScript has returned control to the browser.
  56924. *
  56925. * The VRPose will contain the position, orientation, velocity,
  56926. * and acceleration of each of these properties.
  56927. * @returns the pose object
  56928. */
  56929. getPose(): VRPose;
  56930. /**
  56931. * Return the current instantaneous pose of the VRDisplay, with no
  56932. * prediction applied.
  56933. * @returns the current instantaneous pose
  56934. */
  56935. getImmediatePose(): VRPose;
  56936. /**
  56937. * The callback passed to `requestAnimationFrame` will be called
  56938. * any time a new frame should be rendered. When the VRDisplay is
  56939. * presenting the callback will be called at the native refresh
  56940. * rate of the HMD. When not presenting this function acts
  56941. * identically to how window.requestAnimationFrame acts. Content should
  56942. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56943. * asynchronously from other displays and at differing refresh rates.
  56944. * @param callback Define the eaction to run next frame
  56945. * @returns the request handle it
  56946. */
  56947. requestAnimationFrame(callback: FrameRequestCallback): number;
  56948. /**
  56949. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56950. * Repeat calls while already presenting will update the VRLayers being displayed.
  56951. * @param layers Define the list of layer to present
  56952. * @returns a promise to know when the request has been fulfilled
  56953. */
  56954. requestPresent(layers: VRLayer[]): Promise<void>;
  56955. /**
  56956. * Reset the pose for this display, treating its current position and
  56957. * orientation as the "origin/zero" values. VRPose.position,
  56958. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56959. * updated when calling resetPose(). This should be called in only
  56960. * sitting-space experiences.
  56961. */
  56962. resetPose(): void;
  56963. /**
  56964. * The VRLayer provided to the VRDisplay will be captured and presented
  56965. * in the HMD. Calling this function has the same effect on the source
  56966. * canvas as any other operation that uses its source image, and canvases
  56967. * created without preserveDrawingBuffer set to true will be cleared.
  56968. * @param pose Define the pose to submit
  56969. */
  56970. submitFrame(pose?: VRPose): void;
  56971. }
  56972. declare var VRDisplay: {
  56973. prototype: VRDisplay;
  56974. new(): VRDisplay;
  56975. };
  56976. interface VRLayer {
  56977. leftBounds?: number[] | Float32Array | null;
  56978. rightBounds?: number[] | Float32Array | null;
  56979. source?: HTMLCanvasElement | null;
  56980. }
  56981. interface VRDisplayCapabilities {
  56982. readonly canPresent: boolean;
  56983. readonly hasExternalDisplay: boolean;
  56984. readonly hasOrientation: boolean;
  56985. readonly hasPosition: boolean;
  56986. readonly maxLayers: number;
  56987. }
  56988. interface VREyeParameters {
  56989. /** @deprecated */
  56990. readonly fieldOfView: VRFieldOfView;
  56991. readonly offset: Float32Array;
  56992. readonly renderHeight: number;
  56993. readonly renderWidth: number;
  56994. }
  56995. interface VRFieldOfView {
  56996. readonly downDegrees: number;
  56997. readonly leftDegrees: number;
  56998. readonly rightDegrees: number;
  56999. readonly upDegrees: number;
  57000. }
  57001. interface VRFrameData {
  57002. readonly leftProjectionMatrix: Float32Array;
  57003. readonly leftViewMatrix: Float32Array;
  57004. readonly pose: VRPose;
  57005. readonly rightProjectionMatrix: Float32Array;
  57006. readonly rightViewMatrix: Float32Array;
  57007. readonly timestamp: number;
  57008. }
  57009. interface VRPose {
  57010. readonly angularAcceleration: Float32Array | null;
  57011. readonly angularVelocity: Float32Array | null;
  57012. readonly linearAcceleration: Float32Array | null;
  57013. readonly linearVelocity: Float32Array | null;
  57014. readonly orientation: Float32Array | null;
  57015. readonly position: Float32Array | null;
  57016. readonly timestamp: number;
  57017. }
  57018. interface VRStageParameters {
  57019. sittingToStandingTransform?: Float32Array;
  57020. sizeX?: number;
  57021. sizeY?: number;
  57022. }
  57023. interface Navigator {
  57024. getVRDisplays(): Promise<VRDisplay[]>;
  57025. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57026. }
  57027. interface Window {
  57028. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57029. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57030. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57031. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57032. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57033. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57034. }
  57035. interface Gamepad {
  57036. readonly displayId: number;
  57037. }
  57038. interface XRDevice {
  57039. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57040. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57041. }
  57042. interface XRSession {
  57043. getInputSources(): Array<any>;
  57044. baseLayer: XRWebGLLayer;
  57045. requestFrameOfReference(type: string): Promise<void>;
  57046. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57047. end(): Promise<void>;
  57048. requestAnimationFrame: Function;
  57049. addEventListener: Function;
  57050. }
  57051. interface XRSessionCreationOptions {
  57052. outputContext?: WebGLRenderingContext | null;
  57053. immersive?: boolean;
  57054. environmentIntegration?: boolean;
  57055. }
  57056. interface XRLayer {
  57057. getViewport: Function;
  57058. framebufferWidth: number;
  57059. framebufferHeight: number;
  57060. }
  57061. interface XRView {
  57062. projectionMatrix: Float32Array;
  57063. }
  57064. interface XRFrame {
  57065. getDevicePose: Function;
  57066. getInputPose: Function;
  57067. views: Array<XRView>;
  57068. baseLayer: XRLayer;
  57069. }
  57070. interface XRFrameOfReference {
  57071. }
  57072. interface XRWebGLLayer extends XRLayer {
  57073. framebuffer: WebGLFramebuffer;
  57074. }
  57075. declare var XRWebGLLayer: {
  57076. prototype: XRWebGLLayer;
  57077. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57078. };